Example usage for org.eclipse.jface.dialogs ProgressMonitorDialog run

List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog run

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs ProgressMonitorDialog run.

Prototype

@Override
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
        throws InvocationTargetException, InterruptedException 

Source Link

Document

This implementation of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) runs the given IRunnableWithProgress using the progress monitor for this progress dialog and blocks until the runnable has been run, regardless of the value of fork.

Usage

From source file:com.hudson.hibernatesynchronizer.popup.actions.RemoveRelatedFiles.java

License:GNU General Public License

/**
 * @see IActionDelegate#run(IAction)// w  ww .  j a va2  s  .  c o m
 */
public void run(IAction action) {
    final Shell shell = new Shell();
    if (MessageDialog.openConfirm(shell, "File Removal Confirmation",
            "Are you sure you want to delete all related class and resources to the selected mapping files?")) {
        ISelectionProvider provider = part.getSite().getSelectionProvider();
        if (null != provider) {
            if (provider.getSelection() instanceof StructuredSelection) {
                StructuredSelection selection = (StructuredSelection) provider.getSelection();
                Object[] obj = selection.toArray();
                final IFile[] files = new IFile[obj.length];
                IProject singleProject = null;
                boolean isSingleProject = true;
                for (int i = 0; i < obj.length; i++) {
                    if (obj[i] instanceof IFile) {
                        IFile file = (IFile) obj[i];
                        files[i] = file;
                        if (null == singleProject)
                            singleProject = file.getProject();
                        if (!singleProject.getName().equals(file.getProject().getName())) {
                            isSingleProject = false;
                        }
                    }
                }
                if (isSingleProject) {
                    final IProject project = singleProject;
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(part.getSite().getShell());
                    try {
                        dialog.run(false, true, new IRunnableWithProgress() {
                            public void run(IProgressMonitor monitor)
                                    throws InvocationTargetException, InterruptedException {
                                try {
                                    RemoveRelatedFilesRunnable runnable = new RemoveRelatedFilesRunnable(
                                            project, files, monitor, shell);
                                    ResourcesPlugin.getWorkspace().run(runnable, monitor);
                                } catch (Exception e) {
                                    throw new InvocationTargetException(e);
                                } finally {
                                    monitor.done();
                                }
                            }
                        });
                    } catch (Exception e) {
                    }
                } else {
                    HSUtil.showError("The selected files must belong to a single project", shell);
                }
            }
        }
    }
}

From source file:com.hudson.hibernatesynchronizer.popup.actions.SynchronizeFiles.java

License:GNU General Public License

/**
 * @see IActionDelegate#run(IAction)/*from w ww. jav a2 s .c  o m*/
 */
public void run(IAction action) {
    Shell shell = new Shell();
    final ISelectionProvider provider = part.getSite().getSelectionProvider();
    if (null != provider) {
        if (provider.getSelection() instanceof StructuredSelection) {
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(part.getSite().getShell());
            try {
                dialog.run(false, true, new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        try {
                            IStructuredSelection selection = (StructuredSelection) provider.getSelection();
                            monitor.beginTask("Synchronizing files...", 2 + (selection.toArray().length * 14));
                            exec(selection, monitor);
                        } catch (Exception e) {
                            throw new InvocationTargetException(e);
                        } finally {
                            monitor.done();
                        }
                    }
                });
            } catch (Exception e) {
            }
        }
    }
}

From source file:com.hudson.hibernatesynchronizer.wizard.NewMappingWizard.java

License:GNU General Public License

/**
 * This method is called when 'Finish' button is pressed in the wizard. We
 * will create an operation and run it using wizard as execution context.
 *///from   w w w  .  j a  v  a  2s. c  om
public boolean performFinish() {
    final String containerName = page.getContainerName();
    final List tables = page.getTables();
    final String packageName = page.getPackage();
    final Properties props = page.getProperties();
    Plugin.saveProperty(page.project.getProject(), "package", packageName);
    int foreignKeys = 0;
    for (Iterator i = tables.iterator(); i.hasNext();) {
        DBTable tbl = (DBTable) i.next();
        tbl.setProperties(props);
        foreignKeys += tbl.getForeignKeys().size();
    }
    try {
        Template template = Constants.templateGenerator.getTemplate("Mapping.vm");
        Connection c = page.getConnection(null);
        final MappingWizardRunnable runnable = new MappingWizardRunnable(containerName, tables, packageName,
                props, template, c, getShell());
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
        try {
            dialog.run(false, true, new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    try {
                        ResourcesPlugin.getWorkspace().run(runnable, monitor);
                    } catch (Exception e) {
                        throw new InvocationTargetException(e);
                    } finally {
                        monitor.done();
                    }
                }
            });
        } catch (Exception e) {
        } finally {
            if (null != c)
                c.close();
        }
        if (null != runnable.files && runnable.files.length > 0) {
            AddMappingReference.addMappingReference(page.project.getProject(), runnable.files, false,
                    getShell());
        }
    } catch (Exception e) {
        HSUtil.showError(e.getMessage(), getShell());
    }
    return true;
}

From source file:com.hudson.hibernatesynchronizer.wizard.NewMappingWizardPage.java

License:GNU General Public License

public Composite addConfiguration(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);//  w  w w .j  a  v a  2s .  c  om
    layout.numColumns = 3;
    layout.verticalSpacing = 9;

    Label label = new Label(container, SWT.NULL);
    label.setText("&Container:");

    containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
    containerText.setEnabled(false);
    containerText.setBackground(new Color(null, 255, 255, 255));
    GridData gd = new GridData();
    gd.widthHint = 250;
    containerText.setLayoutData(gd);
    containerText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    Button containerButton = new Button(container, SWT.NATIVE);
    containerButton.setText("Browse");
    containerButton.addMouseListener(new ContainerMouseListener(this));

    label = new Label(container, SWT.NULL);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 3;
    label.setLayoutData(gd);

    label = new Label(container, SWT.NULL);
    label.setText("&Driver:");
    driverText = new Text(container, SWT.BORDER | SWT.SINGLE);
    driverText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    driverText.setEnabled(false);
    driverText.setBackground(new Color(null, 255, 255, 255));
    gd = new GridData();
    gd.widthHint = 250;
    driverText.setLayoutData(gd);
    Button driverButton = new Button(container, SWT.NATIVE);
    driverButton.setText("Browse");
    driverButton.addMouseListener(new DriverMouseListener(this));

    label = new Label(container, SWT.NULL);
    label.setText("&Database URL:");
    databaseUrlText = new Text(container, SWT.BORDER | SWT.SINGLE);
    databaseUrlText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    gd = new GridData();
    gd.horizontalSpan = 2;
    gd.widthHint = 250;
    databaseUrlText.setLayoutData(gd);

    label = new Label(container, SWT.NULL);
    label.setText("&Username:");
    usernameText = new Text(container, SWT.BORDER | SWT.SINGLE);
    usernameText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    gd = new GridData();
    gd.horizontalSpan = 2;
    gd.widthHint = 150;
    usernameText.setLayoutData(gd);

    label = new Label(container, SWT.NULL);
    label.setText("&Password:");
    passwordText = new Text(container, SWT.BORDER | SWT.SINGLE);
    passwordText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    passwordText.setEchoChar('*');
    gd = new GridData();
    gd.horizontalSpan = 2;
    gd.widthHint = 150;
    passwordText.setLayoutData(gd);

    label = new Label(container, SWT.NULL);
    label.setText("Table pattern:");
    tablePattern = new Text(container, SWT.BORDER | SWT.SINGLE);
    tablePattern.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    tablePattern.setEnabled(true);
    tablePattern.setBackground(new Color(null, 255, 255, 255));
    gd = new GridData();
    gd.horizontalSpan = 2;
    gd.widthHint = 250;
    tablePattern.setLayoutData(gd);

    label = new Label(container, SWT.NULL);
    label.setText("Schema pattern:");
    schemaPattern = new Text(container, SWT.BORDER | SWT.SINGLE);
    schemaPattern.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    schemaPattern.setEnabled(true);
    schemaPattern.setBackground(new Color(null, 255, 255, 255));
    gd = new GridData();
    gd.horizontalSpan = 2;
    gd.widthHint = 250;
    schemaPattern.setLayoutData(gd);

    label = new Label(container, SWT.NULL);
    label.setText("Tables");
    table = new Table(container, SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.CHECK);
    table.setVisible(true);
    table.setLinesVisible(false);
    table.setHeaderVisible(false);
    table.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            dialogChanged();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    GridData data = new GridData();
    data.heightHint = 150;
    data.widthHint = 250;
    table.setLayoutData(data);

    // create the columns
    TableColumn nameColumn = new TableColumn(table, SWT.LEFT);
    ColumnLayoutData nameColumnLayout = new ColumnWeightData(100, false);

    // set columns in Table layout
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(nameColumnLayout);
    table.setLayout(tableLayout);

    Composite buttonContainer = new Composite(container, SWT.NULL);
    buttonContainer.setLayout(new GridLayout(1, true));
    gd = new GridData();
    gd.verticalAlignment = GridData.BEGINNING;
    gd.horizontalAlignment = GridData.BEGINNING;
    buttonContainer.setLayoutData(gd);
    tableRefreshButton = new Button(buttonContainer, SWT.PUSH);
    tableRefreshButton.setText("Refresh");
    tableRefreshButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tableRefreshButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            try {
                dialog.run(false, true, new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        try {
                            monitor.beginTask("Refreshing tables...", 21);
                            refreshTables(monitor);
                        } catch (Exception e) {
                            throw new InvocationTargetException(e);
                        } finally {
                            monitor.done();
                        }
                    }
                });
            } catch (Exception exc) {
            }
        }
    });
    selectAllButton = new Button(buttonContainer, SWT.PUSH);
    selectAllButton.setText("Select All");
    selectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    selectAllButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                for (int i = 0; i < table.getItemCount(); i++) {
                    table.getItem(i).setChecked(true);
                }
                dialogChanged();
            } catch (Exception exc) {
            }
        }
    });
    selectNoneButton = new Button(buttonContainer, SWT.PUSH);
    selectNoneButton.setText("Select None");
    selectNoneButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    selectNoneButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                for (int i = 0; i < table.getItemCount(); i++) {
                    table.getItem(i).setChecked(false);
                }
                dialogChanged();
            } catch (Exception exc) {
            }
        }
    });

    label = new Label(container, SWT.NULL);
    label.setText("&Package:");
    packageText = new Text(container, SWT.BORDER | SWT.SINGLE);
    packageText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    gd = new GridData();
    gd.widthHint = 250;
    packageText.setLayoutData(gd);

    packageButton = new Button(container, SWT.NATIVE);
    packageButton.setText("Browse");
    packageButton.addMouseListener(new MouseListener() {
        public void mouseDown(MouseEvent e) {
            if (null != project) {
                try {
                    IJavaSearchScope searchScope = SearchEngine.createWorkspaceScope();
                    SelectionDialog sd = JavaUI.createPackageDialog(getShell(), project,
                            IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS);
                    sd.open();
                    Object[] objects = sd.getResult();
                    if (null != objects && objects.length > 0) {
                        IPackageFragment pf = (IPackageFragment) objects[0];
                        packageText.setText(pf.getElementName());
                    }
                } catch (JavaModelException jme) {
                    jme.printStackTrace();
                }
            }
        }

        public void mouseDoubleClick(MouseEvent e) {
        }

        public void mouseUp(MouseEvent e) {
        }

    });

    if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) {
        IStructuredSelection ssel = (IStructuredSelection) selection;
        if (ssel.size() == 1) {
            Object obj = ssel.getFirstElement();
            if (obj instanceof IResource) {
                IContainer cont;
                if (obj instanceof IContainer)
                    cont = (IContainer) obj;
                else
                    cont = ((IResource) obj).getParent();
                containerText.setText(cont.getFullPath().toString());
                projectChanged(cont.getProject());
            } else if (obj instanceof IPackageFragment) {
                IPackageFragment frag = (IPackageFragment) obj;
                containerText.setText(frag.getPath().toString());
                projectChanged(frag.getJavaProject().getProject());
            } else if (obj instanceof IPackageFragmentRoot) {
                IPackageFragmentRoot root = (IPackageFragmentRoot) obj;
                containerText.setText(root.getPath().toString());
                projectChanged(root.getJavaProject().getProject());
            } else if (obj instanceof IJavaProject) {
                IJavaProject proj = (IJavaProject) obj;
                containerText.setText("/" + proj.getProject().getName());
                projectChanged(proj.getProject());
            } else if (obj instanceof IProject) {
                IProject proj = (IProject) obj;
                containerText.setText("/" + proj.getName());
                projectChanged(proj);
            }
        }
    }

    containerText.forceFocus();
    initialize();
    dialogChanged();
    return container;
}

From source file:com.ibm.etools.mft.conversion.esb.editor.parameter.ConversionEditor.java

License:Open Source License

@Override
public void widgetSelected(SelectionEvent e) {
    if (e.getSource() == startConversion) {
        // if (!showFlashWarning()) {
        // return;
        // }//from  w  w  w. j  a v a 2 s  .co  m

        if (!checkAllConverters()) {
            return;
        }

        ProgressMonitorDialog pmd = new ProgressMonitorDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
        try {
            pmd.run(true, false, new IRunnableWithProgress() {
                @Override
                public void run(IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {

                    if (!showWarningIfNecessary()) {
                        return;
                    }

                    WESBConversionManager manager = new WESBConversionManager(getModel(), getLog());

                    manager.convert(((Controller) getPropertyEditorHelper().getController()).getModelFile(),
                            monitor);
                    Display.getDefault().syncExec(new Runnable() {

                        @Override
                        public void run() {
                            getController().getConvertStep().setCompleted(true);
                            getController().getEditor().getNavigationbar().selectNextItem();
                            getController().refreshLogStatus(new Status(Status.INFO,
                                    WESBConversionPlugin.getDefault().getBundle().getSymbolicName(),
                                    WESBConversionMessages.messageConversionCompleted));
                            getController().refreshLogViewer();
                            getController().refreshNavigationBar();
                            changed();
                        }
                    });
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

From source file:com.ibm.xsp.extlib.designer.bluemix.manifest.editor.ManifestEditorPage.java

License:Open Source License

private void createServicesArea(Composite parent) {
    Section section = XSPEditorUtil.createSection(_toolkit, parent, "Bound Services", 1, 1); // $NLX-ManifestEditorPage.BoundServices-1$
    Composite container = XSPEditorUtil.createSectionChild(section, 1);

    XSPEditorUtil.createLabel(container, "Specify the bound services for this application.", 1); // $NLX-ManifestEditorPage.Specifytheboundservicesforthisapp-1$

    // Create the Table
    _serviceTableEditor = new ManifestTableEditor(container, 1, new String[] { "service" },
            new String[] { "Service" }, true, true, 3, 60, "bluemix.services", _serviceList, true, this, null,
            null); // $NON-NLS-1$ $NON-NLS-3$ $NLX-ManifestEditorPage.Service-2$

    // Create the Buttons
    Composite btnContainer = new Composite(container, SWT.NONE);
    btnContainer.setLayout(SWTLayoutUtils.createLayoutNoMarginDefaultSpacing(3));
    btnContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    btnContainer.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));

    // Add Button
    Button addBtn = new Button(btnContainer, SWT.PUSH);
    addBtn.setText("Add"); // $NLX-ManifestEditorPage.Add-1$
    addBtn.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            _serviceTableEditor.createItem(new TableEntry("Service")); // $NLX-ManifestEditorPage.Service.1-1$
        }//from  w  w  w.j  av  a2s.c  o  m
    });

    // Delete Button
    Button delBtn = new Button(btnContainer, SWT.PUSH);
    delBtn.setText("Delete"); // $NLX-ManifestEditorPage.Delete-1$
    delBtn.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            _serviceTableEditor.deleteItem();
        }
    });

    // Choose button
    Button chooseBtn = new Button(btnContainer, SWT.PUSH);
    chooseBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1));
    chooseBtn.setText("Choose..."); // $NLX-ManifestEditorPage.Choose-1$
    chooseBtn.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            if (BluemixUtil.isServerConfigured()) {
                boolean success = false;
                try {
                    // Retrieve the Services List from the Cloud Space
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
                    dialog.run(true, true, new GetBluemixServices());
                    success = true;
                } catch (InvocationTargetException e) {
                    MessageDialog.openError(getShell(), "Error retrieving services",
                            BluemixUtil.getErrorText(e)); // $NLX-ManifestEditorPage.ErrorRetrievingServices-1$
                } catch (InterruptedException e) {
                    // Ignore
                }
                if (success) {
                    // Open the Services Dialog
                    if (_cloudServices.size() == 0) {
                        MessageDialog.openInformation(getShell(),
                                BluemixUtil.productizeString("%BM_PRODUCT% Services"),
                                "There are no defined services in this Cloud Space"); // $NLX-ManifestEditorPage.IBMBluemixServices-1$ $NLX-ManifestEditorPage.TherearenodefinedServicesinthisCl-2$
                    } else {
                        ManifestServicesDialog dialog = new ManifestServicesDialog(getShell(), _cloudServices,
                                _serviceList);
                        if (dialog.open() == Dialog.OK) {
                            updateServices();
                            _serviceTableEditor.refresh();
                        }
                    }
                }
            }
        }
    });

    section.setClient(container);
}

From source file:com.ibm.xsp.extlib.designer.bluemix.preference.PreferencePage.java

License:Open Source License

@Override
public void widgetSelected(SelectionEvent event) {
    if (event.widget == _testButton) {
        boolean showSuccess = true;
        try {/*w ww.j  av a2  s.c  o m*/
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            dialog.run(true, true,
                    new BluemixTest(_serverCombo.getText(), _usernameText.getText(), _passwordText.getText()));
        } catch (InvocationTargetException e) {
            showSuccess = false;
            MessageDialog.openError(getShell(), "Connection Error", BluemixUtil.getErrorText(e)); // $NLX-PreferencePage.ConnectionError-1$
        } catch (InterruptedException e) {
            showSuccess = false;
        }

        if (showSuccess) {
            String msg = StringUtil.format("The connection to \"{0}\" was successful",
                    _serverCombo.getText().trim()); // $NLX-PreferencePage.Theconnectionto0wassuccessful-1$
            MessageDialog.openInformation(getShell(), "Connection Success", msg); // $NLX-PreferencePage.ConnectionSuccess-1$
        }
    } else if (event.widget == _newProfileButton) {
        HybridProfile profile = new HybridProfile();
        if (HybridBluemixWizard.launch(profile, true) == Window.OK) {
            _hybridTableEditor.createItem(new ProfileListItem(profile));
        }
    } else if (event.widget == _editProfileButton) {
        HybridProfile profile = ((ProfileListItem) _profileList.get(_hybridTableEditor.getSelectedRow()))
                .getProfile();
        HybridBluemixWizard.launch(profile, false);
    } else if (event.widget == _dupProfileButton) {
        HybridProfile profile = (HybridProfile) ((ProfileListItem) _profileList
                .get(_hybridTableEditor.getSelectedRow())).getProfile().clone();
        _hybridTableEditor.createItem(new ProfileListItem(profile));
    } else if (event.widget == _deleteProfileButton) {
        _hybridTableEditor.deleteItem();
    }

    updateComposites();
}

From source file:com.iw.plugins.spindle.editorlib.RenamedLibraryAction.java

License:Mozilla Public License

private void performChanges(Object[] toChange, Map changeData) {
    if (toChange.length > 0) {

        ProgressMonitorDialog dialog = new ProgressMonitorDialog(
                TapestryPlugin.getDefault().getActiveWorkbenchWindow().getShell());

        try {/*from   w  w  w . j a  v a2 s.  c  o  m*/

            dialog.run(false, true, getRunnable(toChange, changeData, oldName, newName));

        } catch (InvocationTargetException e) {

        } catch (InterruptedException e) {

        }

    }
}

From source file:com.iw.plugins.spindle.project.actions.MigrateToTapestryDTD13.java

License:Mozilla Public License

private void findAllModels() {

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(
            TapestryPlugin.getDefault().getActiveWorkbenchShell());

    ModelCollectorRunnable runnable = new ModelCollectorRunnable();

    try {//from w w  w .j  a  v a 2s . com

        dialog.run(false, false, runnable);
        mgr = runnable.getResult();

    } catch (InvocationTargetException e) {

    } catch (InterruptedException e) {
    }

}

From source file:com.iw.plugins.spindle.project.actions.MigrationModelManager.java

License:Mozilla Public License

/**
 * @see com.iw.plugins.spindle.model.manager.TapestryProjectModelManager#initializeProjectTapestryModels()
 *//* ww w .  jav  a  2  s. c  om*/
protected void initializeProjectTapestryModels() {

    if (initialized) {
        return;
    }

    initialized = true;

    allModels = new ArrayList();

    models = new HashMap();

    Shell shell = TapestryPlugin.getDefault().getActiveWorkbenchShell();

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);

    try {

        dialog.run(false, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

                populateAllModels(project,
                        TapestryLookup.ACCEPT_TAPESTRY_PROJECTS_ONLY | TapestryLookup.WRITEABLE, monitor);

                try {

                    int acceptFlags = TapestryLookup.ACCEPT_LIBRARIES | TapestryLookup.FULL_TAPESTRY_PATH;

                    IJavaProject jproject = TapestryPlugin.getDefault().getJavaProjectFor(project);
                    TapestryLookup lookup = new TapestryLookup();
                    lookup.configure(jproject);

                    IStorage storage = lookup.findDefaultLibrary();

                    if (storage != null) {

                        TapestryLibraryModel framework = new TapestryLibraryModel(storage);
                        framework.load();
                        setDefaultLibrary(framework);

                    }

                } catch (CoreException e) {

                    ErrorDialog.openError(TapestryPlugin.getDefault().getActiveWorkbenchShell(),
                            "Migration Error", "could not find the Tapestry Project", e.getStatus());
                }
            }

        });

    } catch (InvocationTargetException e) {
    } catch (InterruptedException e) {
    } finally {

    }

}