Changeset 3818


Ignore:
Timestamp:
Jun 21, 2008, 10:15:21 PM (12 years ago)
Author:
yura
Message:
  • Module creating and opening.
Location:
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/wizards
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/wizards/NewRfpModulePage.java

    r3816 r3818  
    11package org.refal.rfpdt.ui.wizards;
    22
     3import java.lang.reflect.InvocationTargetException;
     4
     5import org.eclipse.core.commands.ExecutionException;
     6import org.eclipse.core.resources.IFile;
     7import org.eclipse.core.runtime.CoreException;
     8import org.eclipse.core.runtime.IProgressMonitor;
    39import org.eclipse.core.runtime.IStatus;
    410import org.eclipse.jdt.core.IJavaElement;
    511import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
     12import org.eclipse.jface.operation.IRunnableWithProgress;
    613import org.eclipse.jface.viewers.IStructuredSelection;
    714import org.eclipse.swt.SWT;
    815import org.eclipse.swt.layout.GridLayout;
    916import org.eclipse.swt.widgets.Composite;
     17import org.eclipse.ui.PlatformUI;
     18import org.eclipse.ui.ide.undo.CreateFileOperation;
     19import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
     20import org.refal.rfpdt.core.RfpCore;
     21import org.refal.rfpdt.ui.RfpUI;
    1022
    1123public class NewRfpModulePage extends NewTypeWizardPage {
     
    6476        createTypeNameControls(composite, nColumns);
    6577
     78        // Button button = new Button(composite, SWT.CHECK | SWT.LEFT);
     79        // button.setLayoutData(new GridData(SWT.LEFT, SWT.LEFT, false, false, 4, 1));
     80        // button.setText("Create function $func Main = e");
     81
    6682        setControl(composite);
    6783    }
     
    6985    public void setVisible (boolean visible) {
    7086        super.setVisible(visible);
    71         if (visible) {
     87        if (visible)
    7288            setFocus();
     89    }
     90
     91    public IFile createModule () throws CoreException, InterruptedException {
     92        final IFile file = RfpCore.getRfpProject(getJavaProject().getProject()).getSource(
     93                getPackageFragmentRoot().getPath(), getPackageText() + '.' + getTypeName(), "rf");
     94        IRunnableWithProgress op = new IRunnableWithProgress() {
     95            public void run (IProgressMonitor monitor) {
     96                CreateFileOperation op = new CreateFileOperation(file, null, null, "NewFile");
     97                try {
     98                    PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor,
     99                            WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
     100                } catch (ExecutionException e) {
     101                    RfpUI.log(e);
     102                }
     103            }
     104        };
     105        try {
     106            getContainer().run(true, true, op);
     107        } catch (InterruptedException e) {
     108            RfpUI.log(e);
     109            return null;
     110        } catch (InvocationTargetException e) {
     111            RfpUI.log(e);
     112            return null;
    73113        }
     114        return file;
    74115    }
    75116}
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/wizards/NewRfpModuleWizard.java

    r3816 r3818  
    11package org.refal.rfpdt.ui.wizards;
    22
     3import org.eclipse.core.resources.IFile;
    34import org.eclipse.core.runtime.CoreException;
    45import org.eclipse.jface.viewers.IStructuredSelection;
     
    67import org.eclipse.ui.INewWizard;
    78import org.eclipse.ui.IWorkbench;
     9import org.eclipse.ui.IWorkbenchPage;
     10import org.eclipse.ui.IWorkbenchWindow;
     11import org.eclipse.ui.PartInitException;
     12import org.eclipse.ui.ide.IDE;
     13import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
    814import org.refal.rfpdt.ui.RfpUI;
    915
    1016public class NewRfpModuleWizard extends Wizard implements INewWizard {
    11     // private IWorkbench workbench;
     17    private IWorkbench workbench;
    1218    private IStructuredSelection selection;
    1319    private NewRfpModulePage page;
     
    3036
    3137    public void init (IWorkbench workbench, IStructuredSelection selection) {
    32         // this.workbench = workbench;
     38        this.workbench = workbench;
    3339        this.selection = selection;
    3440    }
    3541
    3642    public boolean performFinish () {
     43        IFile file = null;
    3744        try {
    38             page.createType(null);
     45            file = page.createModule();
    3946        } catch (CoreException e) {
    4047            RfpUI.log(e);
     
    4451            return false;
    4552        }
     53        if (file == null)
     54            return false;
     55        try {
     56            IWorkbenchWindow dw = workbench.getActiveWorkbenchWindow();
     57            if (dw != null) {
     58                BasicNewResourceWizard.selectAndReveal(file, dw);
     59                IWorkbenchPage page = dw.getActivePage();
     60                if (page != null) {
     61                    IDE.openEditor(page, file, true);
     62                }
     63            }
     64        } catch (PartInitException e) {
     65            RfpUI.log(e);
     66        }
    4667        return true;
    4768    }
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/wizards/NewRfpProjectOperation.java

    r3815 r3818  
    7171        IProjectDescription desc = null;
    7272
    73         if (isDefaultLocation(projectLocation)) {
     73        if (isDefaultLocation(projectLocation))
    7474            desc = null;
    75         } else {
     75        else {
    7676            desc = result.getWorkspace().newProjectDescription(projectName);
    7777            desc.setLocation(new Path(projectLocation));
    7878        }
    7979
    80         if (!result.exists()) {
     80        if (!result.exists())
    8181            result.create(desc, null);
    82         }
    83         if (!result.isOpen()) {
     82        if (!result.isOpen())
    8483            result.open(null);
    85         }
    8684        return result;
    8785    }
Note: See TracChangeset for help on using the changeset viewer.