Changeset 3814 for devel-tools


Ignore:
Timestamp:
Jun 21, 2008, 5:18:40 PM (12 years ago)
Author:
yura
Message:
Location:
devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/wizards
Files:
1 deleted
1 edited

Legend:

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

    r3508 r3814  
    11package org.refal.rfpdt.ui.wizards;
    22
     3import java.lang.reflect.InvocationTargetException;
     4
     5import org.eclipse.core.runtime.CoreException;
     6import org.eclipse.core.runtime.IConfigurationElement;
     7import org.eclipse.core.runtime.IExecutableExtension;
     8import org.eclipse.core.runtime.IStatus;
     9import org.eclipse.jface.dialogs.ErrorDialog;
     10import org.eclipse.jface.dialogs.MessageDialog;
     11import org.eclipse.jface.operation.IRunnableWithProgress;
    312import org.eclipse.jface.resource.ImageDescriptor;
     13import org.eclipse.jface.viewers.IStructuredSelection;
     14import org.eclipse.jface.wizard.Wizard;
     15import org.eclipse.ui.INewWizard;
     16import org.eclipse.ui.IWorkbench;
     17import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
     18import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
     19import org.refal.rfpdt.ui.RfpUI;
    420
    5 public class NewRfpProjectWizard extends ProjectCreationWizard {
     21public class NewRfpProjectWizard extends Wizard implements INewWizard, IExecutableExtension {
    622
    7         public NewRfpProjectWizard() {
    8                 super(new RfpProjectCreationOperation());
    9         }
    10        
    11         @Override
    12         protected ImageDescriptor getBannerImage() {
    13                 // TODO Auto-generated method stub
    14                 return null;
    15         }
     23    private ProjectCreationWizardPage page;
     24    private IConfigurationElement configElement;
     25    private RfpProjectCreationOperation fOperation;
    1626
    17         @Override
    18         protected String getPageDescrition() {
    19                 return "Create a new Refal Plus project in the workspace";
    20         }
     27    public NewRfpProjectWizard () {
     28        super();
     29        fOperation = new RfpProjectCreationOperation();
     30        setDialogSettings(RfpUI.getDefault().getDialogSettings());
     31        setWindowTitle("Choose project name");
     32        setNeedsProgressMonitor(true);
     33    }
    2134
    22         @Override
    23         protected String getPageTitle() {
    24                 return "Refal Plus project";
    25         }
     35    protected ImageDescriptor getBannerImage () {
     36        // TODO Auto-generated method stub
     37        return null;
     38    }
     39
     40    protected String getPageDescrition () {
     41        return "Create a new Refal Plus project in the workspace";
     42    }
     43
     44    protected String getPageTitle () {
     45        return "Refal Plus project";
     46    }
     47
     48    public void addPages () {
     49        super.addPages();
     50        page = new ProjectCreationWizardPage(getPageTitle(), getPageDescrition());
     51        addPage(page);
     52    }
     53
     54    @Override
     55    public boolean performFinish () {
     56        fOperation.setProjectName(page.getProjectName());
     57        fOperation.setProjectLocation(page.getLocationPath().toString());
     58
     59        IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(fOperation);
     60        boolean result = true;
     61        try {
     62            getContainer().run(false, true, op);
     63        } catch (InvocationTargetException e) {
     64            handleException(e.getTargetException());
     65            result = false;
     66        } catch (InterruptedException e) {
     67            result = false;
     68        }
     69        BasicNewProjectResourceWizard.updatePerspective(configElement);
     70        return result;
     71    }
     72
     73    public void init (final IWorkbench workbench, final IStructuredSelection selection) {
     74        initializePageImageDescriptor();
     75    }
     76
     77    /**
     78     * Stores the configuration element for the wizard. The config element will be used in <code>performFinish</code>
     79     * to set the result perspective.
     80     */
     81    public void setInitializationData (final IConfigurationElement configElement, final String propertyName,
     82            final Object data) {
     83        this.configElement = configElement;
     84    }
     85
     86    private void initializePageImageDescriptor () {
     87        ImageDescriptor bannerImage = getBannerImage();
     88        if (bannerImage != null) {
     89            setDefaultPageImageDescriptor(bannerImage);
     90        }
     91    }
     92
     93    private void handleException (final Throwable target) {
     94        String title = "A problem occured.";
     95        String message = "Could not create project.";
     96        if (target instanceof CoreException) {
     97            IStatus status = ((CoreException) target).getStatus();
     98            ErrorDialog.openError(getShell(), title, message, status);
     99            RfpUI.log(status);
     100        } else {
     101            MessageDialog.openError(getShell(), title, target.getMessage());
     102            RfpUI.log(target.getMessage(), target);
     103        }
     104    }
    26105
    27106}
Note: See TracChangeset for help on using the changeset viewer.