List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog close
@Override public boolean close()
ProgressMonitorDialog
implementation of this method only closes the dialog if there are no currently running runnables. From source file:ch.hsr.ifs.cdt.metriculator.tagcloud.views.TagCloudViewPart.java
License:Open Source License
private void createSideTab(SashForm form) { Composite parent = new Composite(form, SWT.NONE); parent.setLayout(new GridLayout()); parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); options = new CloudOptionsComposite(parent, SWT.NONE, viewer) { protected Group addLayoutButtons(Composite parent) { Group buttons = super.addLayoutButtons(parent); Label l = new Label(buttons, SWT.NONE); l.setText("Scale"); final Combo scale = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY); scale.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); scale.setItems(new String[] { "linear", "logarithmic" }); scale.select(1);/*from w ww.j a v a2s . c o m*/ scale.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { switch (scale.getSelectionIndex()) { case 0: labelProvider.setScale(TypeLabelProvider.Scaling.LINEAR); break; case 1: labelProvider.setScale(TypeLabelProvider.Scaling.LOGARITHMIC); break; default: break; } } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); l = new Label(buttons, SWT.NONE); l.setText("X Axis Variation"); final Combo xAxis = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY); xAxis.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); xAxis.setItems(new String[] { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" }); xAxis.select(2); xAxis.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { String item = xAxis.getItem(xAxis.getSelectionIndex()); layouter.setOption(DefaultLayouter.X_AXIS_VARIATION, Integer.parseInt(item)); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); l = new Label(buttons, SWT.NONE); l.setText("Y Axis Variation"); final Combo yAxis = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY); yAxis.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); yAxis.setItems(new String[] { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" }); yAxis.select(1); yAxis.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { String item = yAxis.getItem(yAxis.getSelectionIndex()); layouter.setOption(DefaultLayouter.Y_AXIS_VARIATION, Integer.parseInt(item)); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); Button run = new Button(buttons, SWT.NONE); run.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); run.setText("Re-Position"); run.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { final ProgressMonitorDialog dialog = new ProgressMonitorDialog( viewer.getControl().getShell()); dialog.setBlockOnOpen(false); dialog.open(); dialog.getProgressMonitor().beginTask("Layouting tag cloud...", 100); viewer.reset(dialog.getProgressMonitor(), false); dialog.close(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); Button layout = new Button(buttons, SWT.NONE); layout.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); layout.setText("Re-Layout"); layout.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(viewer.getControl().getShell()); dialog.setBlockOnOpen(false); dialog.open(); dialog.getProgressMonitor().beginTask("Layouting tag cloud...", 200); viewer.setInput(viewer.getInput(), dialog.getProgressMonitor()); viewer.reset(dialog.getProgressMonitor(), false); dialog.close(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); return buttons; }; }; GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); options.setLayoutData(gd); }
From source file:com.beck.ep.team.internal.TeamListBuilder.java
License:BSD License
public String[] createList(Shell shell, IProject project) throws Exception { error = null;//from w ww . j av a 2 s. c o m RepositoryProvider provider = RepositoryProvider.getProvider(project); if (provider == null) { error = "No Repository provider exist. Project: " + project.getName(); return null; } IListBuilder lb = newListBuilder(provider.getID()); if (lb != null) { String[] sa = lb.createList(shell, project); error = lb.getError(); return sa; } Subscriber subscriber = provider.getSubscriber(); SyncInfoSet set = new SyncInfoSet(); //set.add(SyncInfo.CONFLICTING); Filter filter = new Filter(); ProgressMonitorDialog monitor = new ProgressMonitorDialog(shell); monitor.setCancelable(true); monitor.open(); IResource[] members = project.members(); subscriber.collectOutOfSync(members, IResource.DEPTH_INFINITE, set, monitor.getProgressMonitor()); monitor.close(); SyncInfo[] infos = set.getNodes(filter); String[] sa = new String[infos.length]; for (int i = 0; i < infos.length; i++) { sa[i] = infos[i].getLocal().getProjectRelativePath().toString(); } return sa; }
From source file:com.drgarbage.controlflowgraphfactory.actions.ActionUtils.java
License:Apache License
/** * Save Diagram in file and open Editor. * @param path//from www .j a v a 2 s .co m * @param parent * @param page * @param controlFlowGraphDiagram */ public static void saveDiagramInFileAndOpenEditor(IPath path, final Shell parent, final IWorkbenchPage page, final ControlFlowGraphDiagram controlFlowGraphDiagram, final boolean openGraphInEditor) { /* check file extension, if not equals to graph set again*/ if (!path.getFileExtension().endsWith(FileExtensions.GRAPH)) { path = path.addFileExtension(FileExtensions.GRAPH); } final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); ProgressMonitorDialog monitor = new ProgressMonitorDialog(parent); try { monitor.run(false, /* don't fork */ false, /* not cancelable */ new WorkspaceModifyOperation() { /* run this operation */ public void execute(final IProgressMonitor monitor) { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(controlFlowGraphDiagram); oos.close(); /* delete if exists */ if (file.exists()) { file.delete(false, monitor); } file.create(new ByteArrayInputStream(out.toByteArray()), /* contents */ true, /* keep saving, even if IFile is out of sync with the Workspace */ monitor); /* progress monitor */ } catch (StackOverflowError e) { //Messages.error(StackOverflowError.class.getName() + PreferencesMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, StackOverflowError.class.getName(), e)); return; } catch (CoreException ce) { Messages.error( CoreException.class.getName() + CoreMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, CoreException.class.getName(), ce)); return; } catch (IOException ioe) { Messages.error( IOException.class.getName() + CoreMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, IOException.class.getName(), ioe)); return; } } }); } catch (InterruptedException ie) { Messages.error(InterruptedException.class.getName() + CoreMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, InterruptedException.class.getName(), ie)); return; } catch (InvocationTargetException ite) { Messages.error(InvocationTargetException.class.getName() + CoreMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, InvocationTargetException.class.getName(), ite)); return; } finally { monitor.close(); } /* open newly created file in the editor */ if (openGraphInEditor) { if (file != null && page != null) { try { /* close editor if already open for this file */ IEditorPart part = page.findEditor(new FileEditorInput(file)); if (part != null) page.closeEditor(part, false); IDE.openEditor(page, file, true); } catch (PartInitException e) { Messages.error(PartInitException.class.getName() + CoreMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, PartInitException.class.getName(), e)); return; } } } else { showInPackageExplorer(file, false); } }
From source file:com.drgarbage.controlflowgraphfactory.actions.ActionUtils.java
License:Apache License
/** * Save a text content in a file and open an Editor. * @param path/* ww w . ja va2 s .co m*/ * @param parent * @param page * @param content */ public static void saveContentInFileAndOpenEditor(IPath path, final Shell parent, final IWorkbenchPage page, final String content, final boolean openEditor) { final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); ProgressMonitorDialog monitor = new ProgressMonitorDialog(parent); try { monitor.run(false, /* don't fork */ false, /* not cancelable */ new WorkspaceModifyOperation() { /* run this operation */ public void execute(final IProgressMonitor monitor) { try { /* delete if exists */ if (file.exists()) { file.delete(false, monitor); } file.create(new ByteArrayInputStream(content.getBytes()), /* contents */ true, /* keep saving, even if IFile is out of sync with the Workspace */ monitor); /* progress monitor */ } catch (StackOverflowError e) { //Messages.error(StackOverflowError.class.getName() + PreferencesMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, StackOverflowError.class.getName(), e)); return; } catch (CoreException ce) { Messages.error( CoreException.class.getName() + CoreMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, CoreException.class.getName(), ce)); return; } } }); } catch (InterruptedException ie) { Messages.error(InterruptedException.class.getName() + CoreMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, InterruptedException.class.getName(), ie)); return; } catch (InvocationTargetException ite) { Messages.error(InvocationTargetException.class.getName() + CoreMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, InvocationTargetException.class.getName(), ite)); return; } finally { monitor.close(); } /* open newly created file in the editor */ if (openEditor) { if (file != null && page != null) { try { /* close editor if already open for this file */ IEditorPart part = page.findEditor(new FileEditorInput(file)); if (part != null) page.closeEditor(part, false); IDE.openEditor(page, file, true); } catch (PartInitException e) { Messages.error(PartInitException.class.getName() + CoreMessages.ExceptionAdditionalMessage); ControlFlowFactoryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ControlFlowFactoryPlugin.PLUGIN_ID, PartInitException.class.getName(), e)); return; } } } else { showInPackageExplorer(file, false); } }
From source file:com.gigaspaces.azure.runnable.CacheAccountWithProgressWindow.java
License:Open Source License
@Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try {//from ww w . j av a 2 s . co m dialog.run(true, true, this); dialog.close(); isCompletedSuccesfully = true; } catch (InvocationTargetException e) { MessageUtil.displayErrorDialog(shell, Messages.loadingCred, message); isCompletedSuccesfully = false; } catch (InterruptedException e) { } }
From source file:com.gigaspaces.azure.runnable.FetchDeploymentsForHostedServiceWithProgressWindow.java
License:Open Source License
@Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try {//from w w w . ja va 2 s . c om dialog.run(true, true, this); dialog.close(); } catch (InvocationTargetException e) { MessageUtil.displayErrorDialog(shell, com.gigaspaces.azure.wizards.Messages.fetchingDeploymentsTitle, e.getMessage()); Activator.getDefault().log(Messages.error, e); } catch (InterruptedException e) { } }
From source file:com.gigaspaces.azure.runnable.LoadAccountWithProgressWindow.java
License:Open Source License
@Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try {/* w w w. j a va 2 s . com*/ dialog.run(true, true, this); dialog.close(); PreferenceUtil.setLoaded(true); } catch (InvocationTargetException e) { // special check for Java 1.6 and bouncycastle not in classpath error if (Messages.importDlgMsgJavaVersion.equals(e.getMessage())) { MessageUtil.displayErrorDialog(shell, Messages.loadingCred, Messages.importDlgMsgJavaVersion); } else { MessageUtil.displayErrorDialog(shell, Messages.loadingCred, Messages.loadingAccountError); } Activator.getDefault().log(Messages.error, e); PreferenceUtil.setLoaded(false); } catch (InterruptedException e) { // cancel pressed, so user might not be interested in loading data again PreferenceUtil.setLoaded(true); } }
From source file:com.gigaspaces.azure.runnable.NewHostedServiceWithProgressWindow.java
License:Open Source License
@Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try {/*ww w .ja v a 2 s .c o m*/ dialog.run(true, true, this); dialog.close(); } catch (InvocationTargetException e) { MessageUtil.displayErrorDialog(shell, com.gigaspaces.azure.wizards.Messages.createHostedServiceFailedMsg, e.getMessage()); Activator.getDefault().log(Messages.error, e); } catch (InterruptedException e) { MessageDialog.openWarning(shell, Messages.interrupt, Messages.newServiceInterrupted); Activator.getDefault().log(Messages.error, e); } }
From source file:com.gigaspaces.azure.runnable.NewStorageAccountWithProgressWindow.java
License:Open Source License
@Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try {/*from ww w. j a v a 2 s. c om*/ dialog.run(true, true, this); dialog.close(); } catch (InvocationTargetException e) { MessageUtil.displayErrorDialog(shell, com.gigaspaces.azure.wizards.Messages.createStorageAccountFailedTitle, e.getMessage()); Activator.getDefault().log(Messages.error, e); } catch (InterruptedException e) { MessageDialog.openWarning(shell, Messages.interrupt, Messages.newStorageInterrupted); Activator.getDefault().log(Messages.error, e); } }
From source file:com.hudson.hibernatesynchronizer.editors.synchronizer.actions.RemoveRelatedFiles.java
License:GNU General Public License
/** * @see IActionDelegate#run(IAction)/*ww w. ja v a 2 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 classes 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.open(); ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { try { removeRelatedFiles(project, files, shell, monitor); } catch (Exception e) { throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e)); } finally { monitor.done(); } } }, dialog.getProgressMonitor()); } catch (Exception e) { UIUtil.pluginError(e, shell); } finally { dialog.close(); } } else { UIUtil.pluginError("SingleProjectSelectedFiles", shell); } } } } }