List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.safi.workshop.util.SafletPersistenceManager.java
public IProject createNewProject(SafletProject sr) throws CoreException { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); final IProject project = root.getProject(sr.getName()); // project.create(null); // project.open(null); final IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(project.getName()); // final IProjectDescription desc = project.getDescription(); desc.setLocation(null);// w ww. j av a 2s. c om // String[] natures = description.getNatureIds(); // String[] newNatures = new String[natures.length + 1]; // System.arraycopy(natures, 0, newNatures, 0, natures.length); // newNatures[natures.length] = SafiProjectNature.NATURE_ID; // description.setNatureIds(newNatures); String[] natures = desc.getNatureIds(); String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = SafiProjectNature.NATURE_ID; desc.setNatureIds(newNatures); // desc.setNatureIds(new String[] { SafiProjectNature.NATURE_ID }); // project.setDescription(desc, null); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { CreateProjectOperation op = new CreateProjectOperation(desc, ResourceMessages.NewProject_windowTitle); try { PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor, WorkspaceUndoUtil.getUIInfoAdapter(SafiWorkshopEditorUtil.getActiveShell())); } catch (ExecutionException e) { throw new InvocationTargetException(e); } } }; ProgressMonitorDialog pd = new ProgressMonitorDialog(SafiWorkshopEditorUtil.getActiveShell()); // run the new project creation operation try { pd.run(false, true, op); } catch (InterruptedException e) { return null; } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ExecutionException && t.getCause() instanceof CoreException) { CoreException cause = (CoreException) t.getCause(); StatusAdapter status; if (cause.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { status = new StatusAdapter(StatusUtil.newStatus(IStatus.WARNING, NLS.bind(ResourceMessages.NewProject_caseVariantExistsError, project.getName()), cause)); } else { status = new StatusAdapter(StatusUtil.newStatus(cause.getStatus().getSeverity(), ResourceMessages.NewProject_errorMessage, cause)); } status.setProperty(StatusAdapter.TITLE_PROPERTY, ResourceMessages.NewProject_errorMessage); StatusManager.getManager().handle(status, StatusManager.BLOCK); } else { StatusAdapter status = new StatusAdapter( new Status(IStatus.WARNING, IDEWorkbenchPlugin.IDE_WORKBENCH, 0, NLS.bind(ResourceMessages.NewProject_internalError, t.getMessage()), t)); status.setProperty(StatusAdapter.TITLE_PROPERTY, ResourceMessages.NewProject_errorMessage); StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.BLOCK); } } return project; }
From source file:com.salesforce.ide.schemabrowser.ui.SchemaBrowser.java
License:Open Source License
private void createTree(Composite composite) { imageNotChecked = ForceImages.get(ForceImages.IMAGE_NOT_CHECKED); imageChecked = ForceImages.get(ForceImages.IMAGE_CHECKED); imageArrowDown = ForceImages.get(ForceImages.IMAGE_ARROW_DOWN); imageArrowUp = ForceImages.get(ForceImages.IMAGE_ARROW_UP); imageBlank = ForceImages.get(ForceImages.IMAGE_BLANK); final Composite thisComposite = composite; provider = new SchemaTreeLabelProvider(); Tree tree = this.schemaEditorComposite.getTree(); tree.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { if (event.item instanceof TreeItem) { selectedItem = (TreeItem) event.item; } else { selectedItem = null;/* ww w .ja va2s . c om*/ } } }); tree.addTreeListener(new org.eclipse.swt.events.TreeListener() { public void treeExpanded(org.eclipse.swt.events.TreeEvent e) { final TreeItem selectedItem = (TreeItem) e.item; Boolean isTopLevel = (Boolean) selectedItem.getData(IS_TOP_LEVEL); if ((isTopLevel != null) && isTopLevel.booleanValue()) { if (selectedItem.getItemCount() == 1) { Runnable lt = new Runnable() { public void run() { ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell()); mon.getProgressMonitor(); mon.setBlockOnOpen(false); mon.open(); loadTreeData(selectedItem, thisComposite, mon.getProgressMonitor()); setHasCheckableChildren(selectedItem, Boolean.TRUE); setIsTopLevel(selectedItem, Boolean.TRUE); setItemNotChecked(selectedItem); selectedItem.setImage( provider.getImage(0, selectedItem.getText(), selectedItem.getParent())); mon.close(); } }; Runnable lb = new Runnable() { public void run() { ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell()); mon.getProgressMonitor(); mon.setBlockOnOpen(false); mon.open(); mon.getProgressMonitor().beginTask("Get object definition...", 2); loadObject(selectedItem.getText(), mon.getProgressMonitor()); mon.close(); } }; getSite().getShell().getDisplay().asyncExec(lb); getSite().getShell().getDisplay().asyncExec(lt); } } else { Integer type = (Integer) selectedItem.getData(TYPE); if (type != null) { if (type.equals(SchemaBrowser.CHILD_RELATIONSHIP_NODE) && selectedItem.getData(LOADED).equals(Boolean.FALSE)) { Runnable getThisChildSchema = new Runnable() { public void run() { ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell()); mon.getProgressMonitor(); mon.setBlockOnOpen(false); mon.open(); mon.getProgressMonitor().beginTask(MESSAGE_GETTING_CHILD, 2); loadOneChildRelationship(selectedItem, mon.getProgressMonitor()); mon.close(); } }; getSite().getShell().getDisplay().asyncExec(getThisChildSchema); } else if (SchemaBrowser.LOOKUP_RELATIONSHIP_NODE.equals(type) && Boolean.FALSE.equals(selectedItem.getData(LOADED))) { Runnable getThisChildSchema = new Runnable() { public void run() { ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell()); mon.getProgressMonitor(); mon.setBlockOnOpen(false); mon.open(); mon.getProgressMonitor().beginTask(MESSAGE_GETTING_LOOKUP, 2); loadOneChildRelationship(selectedItem, mon.getProgressMonitor()); mon.close(); } }; getSite().getShell().getDisplay().asyncExec(getThisChildSchema); } } } wasExpanded = true; } public void treeCollapsed(org.eclipse.swt.events.TreeEvent e) { wasExpanded = true; } }); tree.addMouseListener(new org.eclipse.swt.events.MouseListener() { public void mouseUp(org.eclipse.swt.events.MouseEvent e) { if (!wasExpanded) { if (selectedItem != null) { if (selectedItem.getImage() != null) { Rectangle rect = selectedItem.getBounds(); Image img = selectedItem.getImage(); Rectangle imgRect = img.getBounds(); int leftMost = rect.x - imgRect.width - 3; int rightMost = rect.x - 3; if ((e.x >= leftMost) && (e.x <= rightMost)) { Integer imageType = (Integer) selectedItem.getData(IMAGE_TYPE); if (imageType != null) { if (imageType.intValue() == IMAGE_TYPE_CHECKED) { setItemChecked(selectedItem); } else { setItemNotChecked(selectedItem); } Integer type = (Integer) selectedItem.getData(TYPE); if (SchemaBrowser.CHILD_RELATIONSHIP_NODE.equals(type) && Boolean.FALSE.equals(selectedItem.getData(LOADED))) { if ((selectedItem.getData(LOADED) != null) && Boolean.FALSE.equals(selectedItem.getData(LOADED))) { Runnable getThisChildSchema = new Runnable() { public void run() { ProgressMonitorDialog mon = new ProgressMonitorDialog( getShell()); mon.getProgressMonitor(); mon.setBlockOnOpen(false); mon.open(); mon.getProgressMonitor().beginTask(MESSAGE_GETTING_CHILD, 2); loadOneChildRelationship(selectedItem, mon.getProgressMonitor()); mon.close(); } }; getSite().getShell().getDisplay().syncExec(getThisChildSchema); } } else if (SchemaBrowser.LOOKUP_RELATIONSHIP_NODE.equals(type) && Boolean.FALSE.equals(selectedItem.getData(LOADED))) { Runnable getThisChildSchema = new Runnable() { public void run() { ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell()); mon.getProgressMonitor(); mon.setBlockOnOpen(false); mon.open(); mon.getProgressMonitor().beginTask(MESSAGE_GETTING_LOOKUP, 2); loadOneChildRelationship(selectedItem, mon.getProgressMonitor()); mon.close(); } }; getSite().getShell().getDisplay().asyncExec(getThisChildSchema); } setChildren(selectedItem, ((Integer) selectedItem.getData(IMAGE_TYPE)).intValue()); while (selectedItem.getParentItem() != null) { TreeItem parent = selectedItem.getParentItem(); boolean setParent = true; for (int i = 0; i < parent.getItemCount(); i++) { if (!parent.getItem(i).equals(selectedItem) && parent.getItem(i).getImage().equals(imageChecked)) { setParent = false; break; } } if (!setParent) { break; } if (imageType.intValue() == 0) { setItemChecked(parent); } else { setItemNotChecked(parent); } selectedItem = parent; } fireSelectionChanged(selectedItem); } } } } } wasExpanded = false; } public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) { } public void mouseDown(org.eclipse.swt.events.MouseEvent e) { } }); initialize(); }
From source file:com.salesforce.ide.ui.properties.ProjectUpdateOperation.java
License:Open Source License
public void update(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, ForceConnectionException, ForceProjectException, InsufficientPermissionsException { ProjectModel projectModel = projectController.getProjectModel(); ForceProject updatedProject = projectModel.getForceProject(); IProject project = projectModel.getProject(); ForceProject existingProject = ContainerDelegate.getInstance().getServiceLocator().getProjectService() .getForceProject(project);//from ww w.jav a 2 s . c o m if (existingProject.isOrgChange(updatedProject)) { ContainerDelegate.getInstance().getFactoryLocator().getConnectionFactory() .removeConnection(existingProject); ContainerDelegate.getInstance().getFactoryLocator().getMetadataFactory() .removeMetadataStubExt(existingProject); ContainerDelegate.getInstance().getFactoryLocator().getToolingFactory() .removeToolingStubExt(existingProject); ContainerDelegate.getInstance().getFactoryLocator().getConnectionFactory() .getConnection(updatedProject); fetchComponents = checkRefreshProject(); if (progressContainer == null) { progressContainer = new ProgressMonitorDialog(getShell()); } progressContainer.run(false, true, this); } else if (!updatedProject.equals(existingProject)) { // adjust timeout, if changed if (existingProject.getReadTimeoutSecs() != updatedProject.getReadTimeoutSecs()) { try { MetadataStubExt metadataStubExt = ContainerDelegate.getInstance().getFactoryLocator() .getMetadataFactory().getMetadataStubExt(existingProject); metadataStubExt.setTimeout(updatedProject.getReadTimeoutSecs()); } catch (ForceRemoteException e) { logger.warn("Unable to update timeout"); } } projectController.saveSettings(monitor); } }
From source file:com.salesforce.ide.ui.wizards.project.ProjectCreateOperation.java
License:Open Source License
public boolean create() throws InvocationTargetException, InterruptedException { // create new project if (progressContainer == null) { progressContainer = new ProgressMonitorDialog(getShell()); }//from ww w . j a v a2 s . co m progressContainer.run(false, true, this); return success; }
From source file:com.salesforce.ide.upgrade.ui.wizards.CompareDialog.java
License:Open Source License
public int open() { int rc = super.open(); if (rc == OK && fCompareEditorInput.isSaveNeeded()) { WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { public void execute(IProgressMonitor pm) throws CoreException { fCompareEditorInput.saveChanges(pm); }// w ww .j a v a 2 s . c o m }; Shell shell = getParentShell(); ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); try { operation.run(pmd.getProgressMonitor()); } catch (InterruptedException x) { // NeedWork } catch (OperationCanceledException x) { // NeedWork } catch (InvocationTargetException x) { String title = Utilities.getString("CompareDialog.saveErrorTitle"); //$NON-NLS-1$ String msg = Utilities.getString("CompareDialog.saveErrorMessage"); //$NON-NLS-1$ MessageDialog.openError(shell, title, msg + x.getTargetException().getMessage()); } } return rc; }
From source file:com.siteview.mde.internal.ui.launcher.OpenLogDialog.java
License:Open Source License
private void readLargeFileWithMonitor(final PrintWriter writer) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(MDEUIMessages.OpenLogDialog_message, IProgressMonitor.UNKNOWN); try { readLargeFile(writer);// www . j a v a2 s. co m } catch (IOException e) { writer.println(MDEUIMessages.OpenLogDialog_cannotDisplay); } } }; ProgressMonitorDialog dialog = new ProgressMonitorDialog(getParentShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } }
From source file:com.siteview.mde.internal.ui.launcher.OpenLogDialog.java
License:Open Source License
private void readFileWithMonitor(final PrintWriter writer) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(MDEUIMessages.OpenLogDialog_message, IProgressMonitor.UNKNOWN); try { readFile(writer);// ww w . java 2 s. c o m } catch (IOException e) { writer.println(MDEUIMessages.OpenLogDialog_cannotDisplay); } } }; ProgressMonitorDialog dialog = new ProgressMonitorDialog(getParentShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { } catch (InterruptedException e) { } }
From source file:com.siteview.mde.internal.ui.preferences.TargetPlatformPreferencePage.java
License:Open Source License
private void handleReload() { IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection(); if (!selection.isEmpty()) { isOutOfSynch = false;//from w w w . j av a 2 s.c o m ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()) { protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(MDEUIMessages.TargetPlatformPreferencePage2_12); } }; try { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (monitor.isCanceled()) { throw new InterruptedException(); } // Resolve the target fActiveTarget.resolve(monitor); if (monitor.isCanceled()) { throw new InterruptedException(); } } }); } catch (InvocationTargetException e) { MDEPlugin.log(e); setErrorMessage(e.getMessage()); } catch (InterruptedException e) { // Do nothing, resolve will happen when user presses ok } if (fActiveTarget.isResolved()) { // Check if the bundle resolution has errors IStatus bundleStatus = fActiveTarget.getBundleStatus(); if (bundleStatus.getSeverity() == IStatus.ERROR) { ErrorDialog.openError(getShell(), MDEUIMessages.TargetPlatformPreferencePage2_14, MDEUIMessages.TargetPlatformPreferencePage2_15, bundleStatus, IStatus.ERROR); } // Compare the target to the existing platform try { if (bundleStatus.getSeverity() != IStatus.ERROR && fActiveTarget.getHandle().equals(fPrevious) && ((TargetDefinition) fPrevious.getTargetDefinition()) .isContentEquivalent(fActiveTarget)) { IStatus compare = getTargetService().compareWithTargetPlatform(fActiveTarget); if (!compare.isOK()) { MessageDialog.openInformation(getShell(), MDEUIMessages.TargetPlatformPreferencePage2_17, MDEUIMessages.TargetPlatformPreferencePage2_18); isOutOfSynch = true; } } } catch (CoreException e) { MDEPlugin.log(e); setErrorMessage(e.getMessage()); } } fTableViewer.refresh(true); } }
From source file:com.siteview.mde.internal.ui.shared.target.TargetContentsGroup.java
License:Open Source License
/** * Uses the target state to determine all bundles required by the * currently checked bundles and returns them so they can be checked in the tree. * /*from www .j a va2 s . c om*/ * @param allBundles list of all bundles to search requirements in * @param checkedBundles list of bundles to get requirements for * @return list of resolved bundles from the collection to be checked */ private Object[] getRequiredPlugins(final Collection allBundles, final Object[] checkedBundles) { final Set dependencies = new HashSet(); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask(Messages.TargetContentsGroup_5, 150); // Get all the bundle locations List allLocations = new ArrayList(allBundles.size()); for (Iterator iterator = allBundles.iterator(); iterator.hasNext();) { IResolvedBundle current = (IResolvedBundle) iterator.next(); try { // Some bundles, such as those with errors, may not have locations URI location = current.getBundleInfo().getLocation(); if (location != null) { allLocations.add(new File(location).toURL()); } } catch (MalformedURLException e) { MDEPlugin.log(e); monitor.setCanceled(true); return; } } if (monitor.isCanceled()) { return; } monitor.worked(20); // Create a PDE State containing all of the target bundles MDEState state = new MDEState((URL[]) allLocations.toArray(new URL[allLocations.size()]), true, new SubProgressMonitor(monitor, 50)); if (monitor.isCanceled()) { return; } // Figure out which of the models have been checked IMonitorModelBase[] models = state.getTargetModels(); List checkedModels = new ArrayList(checkedBundles.length); for (int i = 0; i < checkedBundles.length; i++) { if (checkedBundles[i] instanceof IResolvedBundle) { BundleInfo bundle = ((IResolvedBundle) checkedBundles[i]).getBundleInfo(); for (int j = 0; j < models.length; j++) { if (models[j].getBundleDescription().getSymbolicName() .equals(bundle.getSymbolicName()) && models[j].getBundleDescription().getVersion().toString() .equals(bundle.getVersion())) { checkedModels.add(models[j]); break; } } } } monitor.worked(20); if (monitor.isCanceled()) { return; } // Get implicit dependencies as a list of strings // This is wasteful since the dependency calculation puts them back into BundleInfos NameVersionDescriptor[] implicitDependencies = fTargetDefinition.getImplicitDependencies(); List implicitIDs = new ArrayList(); if (implicitDependencies != null) { for (int i = 0; i < implicitDependencies.length; i++) { implicitIDs.add(implicitDependencies[i].getId()); } } monitor.worked(10); // Get all dependency bundles // exclude "org.eclipse.ui.workbench.compatibility" - it is only needed for pre-3.0 bundles dependencies.addAll(DependencyManager.getDependencies(checkedModels.toArray(), (String[]) implicitIDs.toArray(new String[implicitIDs.size()]), state.getState(), new String[] { "org.eclipse.ui.workbench.compatibility" })); //$NON-NLS-1$ monitor.worked(50); } finally { monitor.done(); } } }; try { // Calculate the dependencies new ProgressMonitorDialog(fTree.getControl().getShell()).run(true, true, op); // We want to check the dependents, the source of the dependents, and the source of the originally checked Set checkedNames = new HashSet(checkedBundles.length); for (int i = 0; i < checkedBundles.length; i++) { if (checkedBundles[i] instanceof IResolvedBundle) { checkedNames.add(((IResolvedBundle) checkedBundles[i]).getBundleInfo().getSymbolicName()); } } List toCheck = new ArrayList(); for (Iterator iterator = fAllBundles.iterator(); iterator.hasNext();) { IResolvedBundle bundle = (IResolvedBundle) iterator.next(); if (bundle.isSourceBundle()) { String name = bundle.getSourceTarget().getSymbolicName(); if (name != null && (dependencies.contains(name) || checkedNames.contains(name))) { toCheck.add(bundle); } } else if (dependencies.contains(bundle.getBundleInfo().getSymbolicName())) { toCheck.add(bundle); } } return toCheck.toArray(); } catch (InvocationTargetException e) { MDEPlugin.log(e); } catch (InterruptedException e) { } return new Object[0]; }
From source file:com.skratchdot.electribe.model.esx.presentation.EsxEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model file. * <!-- begin-user-doc -->/*from ww w . jav a 2 s .co m*/ * <!-- end-user-doc --> * @generated */ @Override public void doSave(IProgressMonitor progressMonitor) { // Save only resources that have actually changed. // final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); // Do the work within an operation because this is a long running activity that modifies the workbench. // IRunnableWithProgress operation = new IRunnableWithProgress() { // This is the method that gets invoked when the operation runs. // public void run(IProgressMonitor monitor) { // Save the resources to the file system. // boolean first = true; for (Resource resource : editingDomain.getResourceSet().getResources()) { if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { try { long timeStamp = resource.getTimeStamp(); resource.save(saveOptions); if (resource.getTimeStamp() != timeStamp) { savedResources.add(resource); } } catch (Exception exception) { resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); } first = false; } } } }; updateProblemIndication = false; try { // This runs the options, and shows progress. // new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); // Refresh the necessary state. // ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone(); firePropertyChange(IEditorPart.PROP_DIRTY); } catch (Exception exception) { // Something went wrong that shouldn't. // EsxEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }