List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.feup.contribution.druid.data.DruidProject.java
License:Open Source License
public boolean detectInteractions() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try {/* ww w .j ava 2 s.c o m*/ dialog.run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException { detectInteractionsBuild(monitor); } }); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { return false; } return true; }
From source file:com.foglyn.ui.OpenAttachmentWithDefaultProgramHandler.java
License:Open Source License
private void openAttachments(final Shell shell, final ITaskAttachment attachment) { String extension = getAttachmentExtension(attachment); final Program program = Program.findProgram(extension); if (program == null) { MessageDialog.openError(shell, "Unable to find default program", "Cannot find default program associated with " + attachment.getFileName()); return;/*from www . j a v a 2 s . co m*/ } IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { String filename = "unknown.bin"; if (attachment.getFileName() != null) { filename = attachment.getFileName(); } File file = null; try { file = File.createTempFile("attach-", "-" + filename); } catch (IOException e) { throw new InvocationTargetException(e); } file.deleteOnExit(); monitor.beginTask("Downloading attachment " + filename, IProgressMonitor.UNKNOWN); try { AttachmentUtils.download(attachment, monitor, file); } catch (IOException e) { AttachmentUtils.delete(file); throw new InvocationTargetException(e); } catch (CoreException e) { AttachmentUtils.delete(file); throw new InvocationTargetException(e); } Program program = Program.findProgram(getAttachmentExtension(attachment)); if (program == null) { throw new InvocationTargetException( new CoreException(new Status(IStatus.ERROR, FoglynUIPlugin.PLUGIN_ID, "Cannot find default program associated with " + attachment.getFileName()))); } // everything is OK... invoke if (!program.execute(file.getAbsolutePath())) { throw new InvocationTargetException(new CoreException(new Status(IStatus.ERROR, FoglynUIPlugin.PLUGIN_ID, "Unable to start " + program.getName()))); } } }; ProgressMonitorDialog dlg = new ProgressMonitorDialog(shell); try { dlg.run(true, true, runnable); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof IOException) { MessageDialog.openError(shell, "Unable to open attachment in default program", "Input/output problem occured: " + cause.getMessage()); } else { MessageDialog.openError(shell, "Unable to open attachment in default program", cause.getMessage()); } } catch (InterruptedException e) { // } }
From source file:com.freescale.deadlockpreventer.agent.InstrumentedProcess.java
License:Open Source License
public void downloadGlobalLockState() { FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE);//from ww w. j a va2s . c o m dialog.setFileName(label + ".lockState"); final String filePath = dialog.open(); if (filePath == null) return; try { new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()).run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { XMLMemento root = XMLMemento.createWriteRoot("locks"); ITransaction transaction = null; try { IMemento locksRoot = root.createChild("root"); HashMap<String, QueryService.IBundleInfo> plugins = new HashMap<String, QueryService.IBundleInfo>(); transaction = queryService.createTransaction(); if (transaction == null) return; int count = transaction.getLockCount(); monitor.beginTask("Saving state...", count); int index = 0; int interval = 100; while (index < count) { ILock[] tmp = transaction.getLocks(index, Math.min(index + interval, count)); monitor.worked(tmp.length); for (int i = 0; i < tmp.length; i++) { XMLUtil.write(locksRoot, tmp[i]); String[] stackTrace = tmp[i].getStackTrace(); if (stackTrace.length > 0) { QueryService.IBundleInfo bundle = transaction.getBundleInfo(tmp[i]); if (!plugins.containsKey(bundle.getName())) plugins.put(bundle.getName(), bundle); } } index += interval; if (monitor.isCanceled()) break; } XMLUtil.write(root, plugins.values()); } finally { if (transaction != null) transaction.close(); } File file = new File(filePath); if (file.exists()) file.delete(); try { FileWriter writer = new FileWriter(file); root.save(writer); writer.close(); } catch (IOException e) { e.printStackTrace(); } monitor.done(); } }); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } finally { } }
From source file:com.freescale.deadlockpreventer.agent.InstrumentedProcess.java
License:Open Source License
private ArrayList<StatisticsDialog.Row> downloadLocks(final ITransaction[] transactions) { final ArrayList<StatisticsDialog.Row> locks = new ArrayList<StatisticsDialog.Row>(); if (!queryService.isConnected()) { try {// ww w. j a va 2s . com new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()).run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { while (!queryService.isConnected()) { if (Display.getDefault().readAndDispatch()) Thread.sleep(100); if (monitor.isCanceled()) break; } } }); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } if (queryService.isConnected()) { if (!queryService.isClosed()) { try { new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()) .run(true, true, new DownloadRunnable(transactions, locks)); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } if (locks.size() == 0) MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Can't retrieve process information", "Process need to be running to get lock information."); else { StatisticsDialog dialog = new StatisticsDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), locks.toArray(new StatisticsDialog.Row[0]), transactions[0]); dialog.open(); } } return locks; }
From source file:com.freescale.deadlockpreventer.agent.StatisticsUtil.java
License:Open Source License
public static void export(final ITransaction transaction) { FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); String file = dialog.open();/*w ww . j ava2s . c o m*/ if (file != null) { File outputFile = new File(file); if (!outputFile.getParentFile().exists()) outputFile.getParentFile().mkdirs(); try { if (!outputFile.exists()) outputFile.createNewFile(); final FileWriter writer = new FileWriter(outputFile); new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()).run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { int count = transaction.getLockCount(); monitor.beginTask("Downloading statistics...", count); int index = 0; int interval = 100; while (index < count) { ILock[] tmp = transaction.getLocks(index, Math.min(index + interval, count)); monitor.worked(tmp.length); Logger.dumpLockInformation(tmp, writer); index += interval; if (monitor.isCanceled()) break; } monitor.done(); } }); writer.close(); } catch (IOException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:com.generalrobotix.ui.item.GrxProjectItem.java
License:Open Source License
public void restoreProject() { String mode = manager_.getCurrentModeName(); System.out.println("Restore Project (Mode:" + mode + ")"); //$NON-NLS-1$ //$NON-NLS-2$ IRunnableWithProgress runnableProgress = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InterruptedException { String mode = manager_.getCurrentModeName(); monitor.beginTask("Restore Project (Mode:" + mode + ")", 10); //$NON-NLS-1$ //$NON-NLS-2$ restoreProject_work(mode, monitor); monitor.done();//from ww w .j a v a2 s .com } }; ProgressMonitorDialog progressMonitorDlg = new ProgressMonitorDialog( GrxUIPerspectiveFactory.getCurrentShell()); try { progressMonitorDlg.run(false, false, runnableProgress); //????????E// Grx3DView view3d = (Grx3DView) manager_.getView(Grx3DView.class, true); if (view3d != null) { view3d.repaint(); } } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:com.generalrobotix.ui.item.GrxWorldStateItem.java
License:Open Source License
private void _loadLog(final File logFile) { try {//from w ww . j a v a2 s .com IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { int size = 0; try { ZipFile local = new ZipFile(logFile); size = local.size(); local.close(); } catch (IOException ex) { ex.printStackTrace(); return; } catch (Exception ex) { ex.printStackTrace(); return; } monitor.beginTask("Loading log as a file:" + logFile.getName(), //$NON-NLS-1$ size + LOAD_LOG_MODITOR_DIM + 2); _loadLog(logFile, monitor); monitor.done(); notifyObservers("LoadLog"); } }; new ProgressMonitorDialog(GrxUIPerspectiveFactory.getCurrentShell()).run(false, true, op); setLogMenus(true); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { clearLog(); } }
From source file:com.generalrobotix.ui.view.GrxServerManagerView.java
License:Open Source License
private void restartServers() { try {/* www .j a va 2s .c o m*/ IRunnableWithProgress iProgress = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(MessageBundle.get("GrxServerManagerView.dialog.title.progress"), 2 + (serverManager_.getServerInfo().size() + 1) * 2); //$NON-NLS-1$ restartServers(monitor); monitor.done(); } }; new ProgressMonitorDialog(GrxUIPerspectiveFactory.getCurrentShell()).run(false, false, iProgress); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { } }
From source file:com.genuitec.eclipse.gerrit.tools.internal.changes.commands.FetchChangeCommand.java
License:Open Source License
@Override protected Object internalExecute(ExecutionEvent event) throws Exception { Shell shell = HandlerUtil.getActiveShell(event); Repository repository = RepositoryUtils.getRepository(HandlerUtil.getCurrentSelection(event)); if (repository == null) { return null; }/*from w w w . ja v a 2 s .com*/ //configure branch creation try { FetchChangeBranchDialog fetchChangeBranchDialog = new FetchChangeBranchDialog(shell, repository); if (fetchChangeBranchDialog.open() != IDialogConstants.OK_ID) { return null; } //perform branch operation try { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell); final CreateChangeBranchOperation op = new CreateChangeBranchOperation(progressDialog.getShell(), event, repository, fetchChangeBranchDialog.getSettings()); progressDialog.run(true, true, op); } catch (InterruptedException e) { //ignore } } catch (NoClassDefFoundError err) { MessageLinkDialog.openWarning(shell, "Mylyn for Gerrit is not installed", "To be able to fetch a change from Gerrit, please install Mylyn Gerrit connector. Detailed instructions can be found <a>here</a>.", new MessageLinkDialog.IMessageLinkDialogListener() { @Override public void linkSelected(SelectionEvent e) { try { PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL( "https://github.com/Genuitec/gerrit-tools/wiki/Fetch-from-Gerrit-setup")); } catch (Exception ex) { RepositoryUtils.handleException(ex); } } }); } return null; }
From source file:com.genuitec.eclipse.gerrit.tools.internal.changes.commands.NewChangeBranchCommand.java
License:Open Source License
@Override protected Object internalExecute(ExecutionEvent event) throws Exception { Shell shell = HandlerUtil.getActiveShell(event); Repository repository = RepositoryUtils.getRepository(HandlerUtil.getCurrentSelection(event)); if (repository == null) { return null; }/* w ww .j av a 2 s. c o m*/ //fetch remote branches RepositoryUtils.fetchOrigin(shell, repository); //configure branch creation CreateChangeBranchDialog createChangeBranchDialog = new CreateChangeBranchDialog(shell, repository); if (createChangeBranchDialog.open() != IDialogConstants.OK_ID) { return null; } //perform branch operation try { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell); final CreateChangeBranchOperation op = new CreateChangeBranchOperation(progressDialog.getShell(), event, repository, createChangeBranchDialog.getSettings()); progressDialog.run(true, true, op); } catch (InterruptedException e) { //ignore } return null; }