List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.aljoschability.defectr.ui.handlers.SaveHandler.java
License:Open Source License
@Execute public void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution) throws InvocationTargetException, InterruptedException { final IEclipseContext pmContext = context.createChild(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.open();/*from ww w. j ava2 s .c o m*/ dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { pmContext.set(IProgressMonitor.class.getName(), monitor); if (contribution != null) { Object clientObject = contribution.getObject(); System.out.println(clientObject); // ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$ // pmContext, null); } } }); pmContext.dispose(); }
From source file:com.amalto.workbench.editors.actions.DeleteItemsAction.java
License:Open Source License
@Override public void run() { try {// www . ja v a 2 s .co m super.run(); // retrieve the list of items IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection()); List<WSRoutingOrderV2> lineItems = selection.toList(); if (lineItems.size() == 0) { return; } if (!MessageDialog.openConfirm(this.shell, Messages.RoutingEngineV2BrowserMainPage_ConfirmDeletion, Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg2, lineItems.size()))) { return; } // Instantiate the Monitor with actual deletes DeleteItemsWithProgress diwp = new DeleteItemsWithProgress( (TMDMService) routingEngineV2BrowserMainPage.getAdapter(TMDMService.class), lineItems, this.shell); // run new ProgressMonitorDialog(this.shell).run(false, // fork true, // cancelable diwp); // refresh the search routingEngineV2BrowserMainPage.doSearch(); } catch (Exception e) { log.error(e.getMessage(), e); MessageDialog.openError(shell, Messages._Error, Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg3, e.getLocalizedMessage())); } }
From source file:com.amalto.workbench.editors.actions.ExecuteRoutingOrdersAction.java
License:Open Source License
@Override public void run() { try {// w ww . j a va2 s . c o m super.run(); // retrieve the list of items IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection()); List<WSRoutingOrderV2> lineItems = selection.toList(); if (lineItems.size() == 0) { return; } if (!MessageDialog.openConfirm(this.shell, Messages.RoutingEngineV2BrowserMainPage_ConfirmTitle, Messages.RoutingEngineV2BrowserMainPage_ConfirmContent + (synchronously ? Messages.RoutingEngineV2BrowserMainPage_Text2 : Messages.RoutingEngineV2BrowserMainPage_Text3) + Messages.RoutingEngineV2BrowserMainPage_ConfirmContentA + lineItems.size() + Messages.RoutingEngineV2BrowserMainPage_B)) { return; } // Instantiate the Monitor with actual deletes ExecuteRoutingOrdersWithProgress diwp = new ExecuteRoutingOrdersWithProgress( (TMDMService) routingEngineV2BrowserMainPage.getAdapter(TMDMService.class), lineItems, this.shell); // run new ProgressMonitorDialog(this.shell).run(false, // fork true, // cancelable diwp); // refresh the search routingEngineV2BrowserMainPage.doSearch(); } catch (Exception e) { log.error(e.getMessage(), e); MessageDialog.openError(shell, Messages._Error, Messages.bind(Messages.RoutingEngineV2BrowserMainPage_ErrorMsg4, e.getLocalizedMessage())); } }
From source file:com.amalto.workbench.editors.TransformerMainPage.java
License:Open Source License
public void execute() { try {/*from ww w. j a va 2s .co m*/ service = getService(); if (service == null) { return; } java.util.List<WSTransformerContextPipelinePipelineItem> items = new ArrayList<WSTransformerContextPipelinePipelineItem>(); for (Line line : cacheList) { String variableName = line.keyValues.get(0).value; String contentType = line.keyValues.get(1).value; String value = line.keyValues.get(2).value; items.add(new WSTransformerContextPipelinePipelineItem(variableName, new WSTypedContent(contentType, null, new WSByteArray(value.getBytes("utf-8"))))); //$NON-NLS-1$ } final WSBackgroundJobPK jobPK = service.executeTransformerV2AsJob(new WSExecuteTransformerV2AsJob( new WSTransformerContext(new WSTransformerContextPipeline(items), null, new WSTransformerV2PK(transformer.getName())))); IRunnableWithProgress progress = new IRunnableWithProgress() { WSBackgroundJob job = null; public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { /****************************************** * Watch the Background Job ******************************************/ try { boolean firstTime = true; do { if (firstTime) { Thread.sleep(1500L); firstTime = false; } else { Thread.sleep(5000L); } if (monitor.isCanceled()) { throw new InterruptedException(Messages.TransformerMainPage_UserCancel); } job = service.getBackgroundJob(new WSGetBackgroundJob(jobPK.getPk())); monitor.subTask(job.getMessage()); } while (job.getStatus().equals(BackgroundJobStatusType.RUNNING) || job.getStatus().equals(BackgroundJobStatusType.SCHEDULED)); if (job.getStatus().equals(BackgroundJobStatusType.STOPPED)) { getSite().getShell().getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openError( TransformerMainPage.this.getEditor().getSite().getShell(), Messages.bind(Messages.TransformerMainPage_ErrorMsg, transformer.getName()), job.getMessage()); } }); throw new XtentisException( Messages.bind(Messages.TransformerMainPage_JobWasStoped, job.getMessage())); } monitor.worked(1); monitor.done(); /****************************************** * Build the result console ******************************************/ // Auto sorts the entries final TreeMap pipeline = new TreeMap<String, WSExtractedContent>(); WSPipeline wsPipeline = job.getPipeline(); java.util.List<WSPipelineTypedContentEntry> entries = wsPipeline.getTypedContentEntry(); for (WSPipelineTypedContentEntry entry : entries) { pipeline.put(entry.getOutput(), entry.getWsExtractedContent()); } getSite().getShell().getDisplay().asyncExec(new Runnable() { public void run() { try { /* * ProcessResultsPage page = new ProcessResultsPage(editor,pipeline); * parent.editor.addPage(page); parent.editor.setActivePage(page.getId()); * * parent.editor.getEditorSite().getShell() */ // Shell shell = new Shell(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN); ProcessResultsDialog dialog = new ProcessResultsDialog(getSite().getShell(), Messages.bind(Messages.TransformerMainPage_DailogTitle, sdf.format(new Date(System.currentTimeMillis()))), pipeline); dialog.setBlockOnOpen(false); dialog.open(); } catch (Exception e) { log.error(e.getMessage(), e); throw new RuntimeException(e); } } }); } catch (Exception e1) { log.error(e1.getMessage(), e1); } } }; new ProgressMonitorDialog(TransformerMainPage.this.getSite().getWorkbenchWindow().getShell()).run(true, // fork true, progress); } catch (Exception e1) { log.error(e1.getMessage(), e1); } }
From source file:com.amalto.workbench.editors.ViewMainPage.java
License:Open Source License
@Override public void doSave(IProgressMonitor monitor) { super.doSave(monitor); if (this.viewName != null && this.viewName.length() > 0) { if (viewName.matches("Browse_items.*")) {//$NON-NLS-1$ // lastDataModelName=XpathSelectDialog.getDataModelName(); String concept = viewName.replaceAll("Browse_items_", "").replaceAll("#.*", "");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ java.util.List<String> avaiList = getAvailableDataModel(); if (avaiList.size() > 0) { lastDataModelName = avaiList.get(0); }// w w w . j a v a2s .c o m if (concept != null && concept.length() > 0 && lastDataModelName != null && lastDataModelName.length() > 0) { // if(concept!=null&&concept.length()>0&&lastDataModelName!=null&&lastDataModelName.length()>0){ // keys validate java.util.List<String> toAddViewableList = new ArrayList<String>(); WSGetBusinessConceptKey wsGetBusinessConceptKey = new WSGetBusinessConceptKey(concept, new WSDataModelPK(lastDataModelName)); WSConceptKey wsConceptKey = null; try { wsConceptKey = getBusinessConceptKey(wsGetBusinessConceptKey); } catch (XtentisException e) { log.error(e.getMessage(), e); } if (wsConceptKey != null) { java.util.List<String> viewableList = new ArrayList<String>(); java.util.List<Line> vlines = (java.util.List<Line>) viewableViewer.getViewer().getInput(); for (int j = 0; j < vlines.size(); j++) { Line item = vlines.get(j); viewableList.add(item.keyValues.get(0).value); } java.util.List<String> keys = wsConceptKey.getFields(); for (int i = 0; i < keys.size(); i++) { if (".".equals(wsConceptKey.getSelector())) { keys.set(i, "/" + concept + "/" + keys.get(i));//$NON-NLS-1$//$NON-NLS-2$ } else { keys.set(i, wsConceptKey.getSelector() + keys.get(i)); } } java.util.List<String> ids = wsConceptKey.getFields(); for (String id : ids) { // need to care about more case if (id.startsWith("/")) {//$NON-NLS-1$ id = id.substring(1); } else if (id.startsWith("//")) {//$NON-NLS-1$ id = id.substring(2); } if (!viewableList.contains(id)) { toAddViewableList.add(0, id); } } } // show verify report if (toAddViewableList.size() > 0) { String msg = Messages.ViewMainPage_Msg; for (Object element : toAddViewableList) { String toAddItem = (String) element; msg += (toAddItem + "\n"); //$NON-NLS-1$ } msg += Messages.ViewMainPage_Addtions; MessageDialog.openInformation(this.getSite().getShell(), Messages.ViewMainPage_VerifyReport, msg); } // auto fix IRunnableWithProgress autoFixProcess = new AutoFixProgress(toAddViewableList, viewableViewer, this.getSite().getShell()); try { new ProgressMonitorDialog(this.getSite().getShell()).run(false, true, autoFixProcess); } catch (InvocationTargetException e) { log.error(e.getMessage(), e); } catch (InterruptedException e) { log.error(e.getMessage(), e); } } } } }
From source file:com.amalto.workbench.export.ImportItemsWizard.java
License:Open Source License
@Override public boolean performFinish() { closeOpenEditors();/*from ww w. j a v a 2 s .co m*/ final String zipFilePath = getZipFilePath(); final boolean selectZip = zipBtn.getSelection(); if (selectZip) { try { ZipToFile.unZipFile(zipFilePath, importFolder); } catch (Exception e) { log.error(e.getMessage(), e); } } if (folderBtn.getSelection()) { importFolder = folder.getText().getText(); } final Object[] objs = getCheckedObjects(); IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { doImport(objs, monitor); // run initMDM to call backend migration task if (service != null) { service.initMDM(null); } } catch (Exception e) { log.error(e.getMessage(), e); } finally { refreshViewJob(); // modified by honghb ,fix bug 21552 if (selectZip && zipFilePath != null && new File(importFolder).exists()) { ZipToFile.deleteDirectory(new File(importFolder)); } } } }; try { new ProgressMonitorDialog(getShell()).run(true, true, iRunnableWithProgress); } catch (Exception e) { log.error(e.getMessage(), e); } return true; }
From source file:com.android.ddmuilib.heap.NativeHeapPanel.java
License:Apache License
/** {@inheritDoc} */ @Override/*from www .ja v a 2 s . co m*/ public void clientChanged(final Client client, int changeMask) { if (client != getCurrentClient()) { return; } if ((changeMask & Client.CHANGE_NATIVE_HEAP_DATA) != Client.CHANGE_NATIVE_HEAP_DATA) { return; } List<NativeAllocationInfo> allocations = client.getClientData().getNativeAllocationList(); if (allocations.size() == 0) { return; } // We need to clone this list since getClientData().getNativeAllocationList() clobbers // the list on future updates final List<NativeAllocationInfo> nativeAllocations = shallowCloneList(allocations); addNativeHeapSnapshot(new NativeHeapSnapshot(nativeAllocations)); updateDisplay(); // Attempt to resolve symbols in a separate thread. // The UI should be refreshed once the symbols have been resolved. if (USE_OLD_RESOLVER) { Thread t = new Thread( new SymbolResolverTask(nativeAllocations, client.getClientData().getMappedNativeLibraries())); t.setName("Address to Symbol Resolver"); t.start(); } else { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { resolveSymbols(); mDetailsTreeViewer.refresh(); mStackTraceTreeViewer.refresh(); } public void resolveSymbols() { Shell shell = Display.getDefault().getActiveShell(); ProgressMonitorDialog d = new ProgressMonitorDialog(shell); NativeSymbolResolverTask resolver = new NativeSymbolResolverTask(nativeAllocations, client.getClientData().getMappedNativeLibraries(), mSymbolSearchPathText.getText(), client.getClientData().getAbi()); try { d.run(true, true, resolver); } catch (InvocationTargetException e) { MessageDialog.openError(shell, "Error Resolving Symbols", e.getCause().getMessage()); return; } catch (InterruptedException e) { return; } MessageDialog.openInformation(shell, "Symbol Resolution Status", getResolutionStatusMessage(resolver)); } }); } }
From source file:com.android.ddmuilib.heap.NativeHeapPanel.java
License:Apache License
private void loadHeapDataFromFile() { // pop up a file dialog and get the file to load final String path = getHeapDumpToImport(); if (path == null) { return;//from w w w. j ava 2 s . com } Reader reader = null; try { reader = new FileReader(path); } catch (FileNotFoundException e) { // cannot occur since user input was via a FileDialog } Shell shell = Display.getDefault().getActiveShell(); ProgressMonitorDialog d = new ProgressMonitorDialog(shell); NativeHeapDataImporter importer = new NativeHeapDataImporter(reader); try { d.run(true, true, importer); } catch (InvocationTargetException e) { // exception while parsing, display error to user and then return MessageDialog.openError(shell, "Error Importing Heap Data", e.getCause().getMessage()); return; } catch (InterruptedException e) { // operation cancelled by user, simply return return; } NativeHeapSnapshot snapshot = importer.getImportedSnapshot(); addToImportedSnapshots(snapshot); // save imported snapshot for future use addNativeHeapSnapshot(snapshot); // add to currently displayed snapshots as well updateDisplay(); }
From source file:com.android.ddmuilib.screenrecord.ScreenRecorderAction.java
License:Apache License
public void performAction() { ScreenRecorderOptionsDialog optionsDialog = new ScreenRecorderOptionsDialog(mParentShell); if (optionsDialog.open() == Window.CANCEL) { return;//from ww w. ja v a 2 s . c o m } final ScreenRecorderOptions options = new ScreenRecorderOptions.Builder() .setBitRate(optionsDialog.getBitRate()).setSize(optionsDialog.getWidth(), optionsDialog.getHeight()) .build(); final CountDownLatch latch = new CountDownLatch(1); final CollectingOutputReceiver receiver = new CollectingOutputReceiver(latch); new Thread(new Runnable() { @Override public void run() { try { mDevice.startScreenRecorder(REMOTE_PATH, options, receiver); } catch (Exception e) { showError("Unexpected error while launching screenrecorder", e); latch.countDown(); } } }, "Screen Recorder").start(); try { new ProgressMonitorDialog(mParentShell).run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { int timeInSecond = 0; monitor.beginTask("Recording...", IProgressMonitor.UNKNOWN); while (true) { // Wait for a second to see if the command has completed if (latch.await(1, TimeUnit.SECONDS)) { break; } // update recording time in second monitor.subTask(String.format("Recording...%d seconds elapsed", timeInSecond++)); // If not, check if user has cancelled if (monitor.isCanceled()) { receiver.cancel(); monitor.subTask("Stopping..."); // wait for an additional second to make sure that the command // completed and screenrecorder finishes writing the output latch.await(1, TimeUnit.SECONDS); break; } } } }); } catch (InvocationTargetException e) { showError("Unexpected error while recording: ", e.getTargetException()); return; } catch (InterruptedException ignored) { } try { mDevice.pullFile(REMOTE_PATH, optionsDialog.getDestination().getAbsolutePath()); } catch (Exception e) { showError("Unexpected error while copying video recording from device", e); } MessageDialog.openInformation(mParentShell, TITLE, "Screen recording saved at " + optionsDialog.getDestination().getAbsolutePath()); }
From source file:com.android.ddmuilib.SyncProgressHelper.java
License:Apache License
/** * Runs a {@link SyncRunnable} in a {@link ProgressMonitorDialog}. * @param runnable The {@link SyncRunnable} to run. * @param progressMessage the message to display in the progress dialog * @param parentShell the parent shell for the progress dialog. * * @throws InvocationTargetException// www. ja va 2 s. c o m * @throws InterruptedException * @throws SyncException if an error happens during the push of the package on the device. * @throws IOException * @throws TimeoutException */ public static void run(final SyncRunnable runnable, final String progressMessage, final Shell parentShell) throws InvocationTargetException, InterruptedException, SyncException, IOException, TimeoutException { final Exception[] result = new Exception[1]; new ProgressMonitorDialog(parentShell).run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) { try { runnable.run(new SyncProgressMonitor(monitor, progressMessage)); } catch (Exception e) { result[0] = e; } finally { runnable.close(); } } }); if (result[0] instanceof SyncException) { SyncException se = (SyncException) result[0]; if (se.wasCanceled()) { // no need to throw this return; } throw se; } // just do some casting so that the method declaration matches what's thrown. if (result[0] instanceof TimeoutException) { throw (TimeoutException) result[0]; } if (result[0] instanceof IOException) { throw (IOException) result[0]; } if (result[0] instanceof RuntimeException) { throw (RuntimeException) result[0]; } }