Ignore:
Timestamp:
02/05/06 15:03:38 (19 years ago)
Author:
boris
Message:
  • moved the modelica project creation code where it belongs IMHO
  • wraped the call to modelica project creation operation from new project wizard into IWorkspaceRunnable to improve batching of change events
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/wizards/NewProjectWizard.java

    r288 r291  
    4646import org.modelica.mdt.ui.UIPlugin;
    4747
    48 import org.eclipse.core.resources.IProject;
    4948import org.eclipse.core.resources.IResource;
     49import org.eclipse.core.resources.IWorkspaceRunnable;
    5050import org.eclipse.core.resources.ResourcesPlugin;
     51import org.eclipse.core.runtime.CoreException;
     52import org.eclipse.core.runtime.IProgressMonitor;
    5153import org.eclipse.core.runtime.IStatus;
    5254import org.eclipse.jface.dialogs.DialogPage;
     55import org.eclipse.jface.dialogs.ErrorDialog;
    5356import org.eclipse.jface.viewers.IStructuredSelection;
    5457import org.eclipse.jface.wizard.Wizard;
     
    150153    }   
    151154   
     155    private static void showProjectCreationError(IStatus status)
     156    {
     157        ErrorDialog.openError(null, "Error", "Could not create project", status);   
     158    }
    152159
    153160    @Override
    154161    public boolean performFinish()
    155162    {
    156         IProject proj =
    157             ModelicaCore.createProject(projectPage.projectName.getText(),
    158                     this.getContainer());
     163        /*
     164         * run creation of the project operation inside
     165         * an instance of IWorkspaceRunnable to batch the
     166         * changes to the workspace
     167         */
     168        try
     169        {
     170            IWorkspaceRunnable wr = new IWorkspaceRunnable()
     171            {
     172                public void run(IProgressMonitor monitor) throws CoreException
     173                {
     174                    ModelicaCore.getModelicaRoot().createProject
     175                        (projectPage.projectName.getText());
     176                }
     177            };
     178            ResourcesPlugin.getWorkspace().run(wr, null);
     179        }
     180        catch (CoreException e)
     181        {
     182            /*
     183             * on error show the error dialog and don't
     184             * close the new project wizard to give user a
     185             * chance to correct the error and try again
     186             */
     187            showProjectCreationError(e.getStatus());
     188            return false;
     189        }
    159190       
    160         return proj != null;
     191        return true;
    161192    }
    162193   
Note: See TracChangeset for help on using the changeset viewer.