List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.google.gdt.eclipse.appsmarketplace.job.BackendJob.java
License:Open Source License
public static ProgressMonitorDialog launchBackendJob(BackendJob job, Shell shell) { ProgressMonitorDialog pdlg = new ProgressMonitorDialog(shell); job.setProgressDialog(pdlg);/*from www.j a v a 2 s . c o m*/ pdlg.open(); pdlg.setCancelable(true); Thread thread = new Thread(job); thread.start(); pdlg.setBlockOnOpen(true); return pdlg; }
From source file:com.google.gdt.eclipse.designer.actions.deploy.DeployModuleAction.java
License:Open Source License
@Override protected void runWithSelectedModule() throws Exception { final DeployDialog deployDialog = new DeployDialog(DesignerPlugin.getShell(), Activator.getDefault(), m_selectedModule);/*w ww .ja va 2 s . c om*/ if (deployDialog.open() != Window.OK) { return; } // IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { monitor.beginTask("Deployment of module '" + m_selectedModule.getId() + "'", 1); // create script { monitor.worked(1); createBuildScript(deployDialog); } // execute script { IProject project = m_selectedModule.getProject(); IFolder targetFolder = m_selectedModule.getModuleFolder(); File buildFile = targetFolder.getFile("build.xml").getLocation().toFile(); AntHelper antHelper = new AntHelper(buildFile, project.getLocation().toFile()); antHelper.execute(monitor); } } catch (Throwable e) { throw new InvocationTargetException(e); } } }; ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(DesignerPlugin.getShell()); progressMonitorDialog.run(true, false, runnableWithProgress); }
From source file:com.googlecode.efactory.examples.entity.presentation.EntityEditor.java
License:Open Source License
/** * This is for implementing {@link IEditorPart} and simply saves the model * file. <!-- begin-user-doc --> <!-- end-user-doc --> * //from w w w . j ava2 s. co m * @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. // WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { // This is the method that gets invoked when the operation runs. // @Override public void execute(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. // EntityEditorPlugin.INSTANCE.log(exception); } updateProblemIndication = true; updateProblemIndication(); }
From source file:com.hilotec.elexis.messwerte.v2.views.MessungenUebersichtV21.java
License:Open Source License
/** * Aktionen fuer Menuleiste und Kontextmenu initialisieren *///from www . j av a 2 s . co m private void erstelleAktionen() { neuAktion = new Action(Messages.MessungenUebersicht_action_neu) { { setImageDescriptor(Images.IMG_ADDITEM.getImageDescriptor()); setToolTipText(Messages.MessungenUebersicht_action_neu_ToolTip); } @Override public void run() { Patient p = (Patient) tabfolder.getData(DATA_PATIENT); if (p == null) { return; } CTabItem tab = tabfolder.getSelection(); Control c = tab.getControl(); MessungTyp t = (MessungTyp) c.getData(DATA_TYP); Messung messung = new Messung(p, t); MessungBearbeiten dialog = new MessungBearbeiten(getSite().getShell(), messung); if (dialog.open() != Dialog.OK) { messung.delete(); } refreshContent(p, t); } }; editAktion = new Action(Messages.MessungenUebersicht_action_edit) { { setImageDescriptor(Images.IMG_EDIT.getImageDescriptor()); setToolTipText(Messages.MessungenUebersicht_action_edit_ToolTip); } @Override public void run() { Patient p = (Patient) tabfolder.getData(DATA_PATIENT); if (p == null) { return; } CTabItem tab = tabfolder.getSelection(); Control c = tab.getControl(); MessungTyp t = (MessungTyp) c.getData(DATA_TYP); TableItem[] tableitems = ((Table) c).getSelection(); if (tableitems.length == 1) { Messung messung = (Messung) tableitems[0].getData(); MessungBearbeiten dialog = new MessungBearbeiten(getSite().getShell(), messung); if (dialog.open() == Dialog.OK) { refreshContent(p, t); } } } }; copyAktion = new Action(Messages.MessungenUebersicht_action_copy) { { setImageDescriptor(Images.IMG_CLIPBOARD.getImageDescriptor()); setToolTipText(Messages.MessungenUebersicht_action_copy_ToolTip); } @Override public void run() { Patient p = (Patient) tabfolder.getData(DATA_PATIENT); if (p == null) { return; } CTabItem tab = tabfolder.getSelection(); Control c = tab.getControl(); MessungTyp t = (MessungTyp) c.getData(DATA_TYP); TableItem[] tableitems = ((Table) c).getSelection(); if (tableitems.length == 1) { Messung messung = (Messung) tableitems[0].getData(); String messungsdatum = messung.getDatum(); TimeTool date = new TimeTool(); String newdatum = date.toString(TimeTool.DATE_GER); if (!messungsdatum.equalsIgnoreCase(newdatum)) { // Nur wenn Messung nich vom selben Tag wie heute!! System.out.println(messung.getDatum()); System.out.println(date.toString(TimeTool.DATE_GER)); Messung messungnew = new Messung(messung.getPatient(), messung.getTyp()); messungnew.setDatum(date.toString(TimeTool.DATE_GER)); for (Messwert messwert : messung.getMesswerte()) { Messwert copytemp = messungnew.getMesswert(messwert.getName()); copytemp.setWert(messwert.getWert()); } messungnew.set("deleted", "0"); // kopierte Messung als gltig markieren //$NON-NLS-1$ //$NON-NLS-2$ refreshContent(p, t); } else { SWTHelper.showError(Messages.MessungenUebersicht_action_copy_error, Messages.MessungenUebersicht_action_copy_errorMessage); } } } }; loeschenAktion = new Action(Messages.MessungenUebersicht_action_loeschen) { { setImageDescriptor(Images.IMG_DELETE.getImageDescriptor()); setToolTipText(Messages.MessungenUebersicht_action_loeschen_ToolTip); } @Override public void run() { Patient p = (Patient) tabfolder.getData(DATA_PATIENT); if (p == null) { return; } CTabItem tab = tabfolder.getSelection(); Control c = tab.getControl(); MessungTyp t = (MessungTyp) c.getData(DATA_TYP); TableItem[] tableitems = ((Table) c).getSelection(); if ((tableitems.length > 0) && SWTHelper.askYesNo(Messages.MessungenUebersicht_action_loeschen_delete_0, Messages.MessungenUebersicht_action_loeschen_delete_1)) { for (TableItem ti : tableitems) { Messung messung = (Messung) ti.getData(); messung.delete(); } refreshContent(p, t); } } }; exportAktion = new Action(Messages.MessungenUebersicht_action_export) { { setImageDescriptor(Images.IMG_EXPORT.getImageDescriptor()); setToolTipText(Messages.MessungenUebersicht_action_export_ToolTip); } @Override public void run() { Patient p = (Patient) tabfolder.getData(DATA_PATIENT); CTabItem tab = tabfolder.getSelection(); Control c = tab.getControl(); MessungTyp t = (MessungTyp) c.getData(DATA_TYP); ExportData expData = new ExportData(); if (p != null) { expData.setPatientNumberFrom(Integer.parseInt(p.getPatCode())); expData.setPatientNumberTo(Integer.parseInt(p.getPatCode())); } ExportDialog expDialog = new ExportDialog(form.getShell(), expData); if (expDialog.open() == Dialog.OK) { String label = t.getTitle(); String date = new TimeTool().toString(TimeTool.DATE_COMPACT); String filename = label + "-export-" + date + ".csv"; //$NON-NLS-1$ //$NON-NLS-2$ FileDialog fd = new FileDialog(getSite().getShell(), SWT.SAVE); String[] extensions = { "*.csv" //$NON-NLS-1$ }; fd.setOverwrite(true); fd.setFilterExtensions(extensions); fd.setFileName(filename); fd.setFilterPath(System.getProperty("user.home")); //$NON-NLS-1$ String filepath = fd.open(); if (filepath != null) { try { Exporter exporter = new Exporter(expData, t, filepath); new ProgressMonitorDialog(form.getShell()).run(true, true, exporter); if (!exporter.wasAborted()) { SWTHelper.showInfo( MessageFormat.format(Messages.MessungenUebersicht_action_export_title, label), MessageFormat.format(Messages.MessungenUebersicht_action_export_success, label, filepath)); } else { SWTHelper.showError( MessageFormat.format(Messages.MessungenUebersicht_action_export_title, label), MessageFormat.format(Messages.MessungenUebersicht_action_export_aborted, label, filepath)); } } catch (InvocationTargetException e) { SWTHelper.showError(Messages.MessungenUebersichtV21_Error, e.getMessage()); } catch (InterruptedException e) { SWTHelper.showInfo(Messages.MessungenUebersichtV21_Cancelled, e.getMessage()); } } else { SWTHelper.showInfo(Messages.MessungenUebersichtV21_Information, Messages.MessungenUebersicht_action_export_filepath_error); } } } }; reloadXMLAction = new Action(Messages.MessungenUebersicht_action_reload) { { setImageDescriptor(Images.IMG_REFRESH.getImageDescriptor()); setToolTipText(Messages.MessungenUebersicht_action_reload_ToolTip); } @Override public void run() { Patient p = (Patient) tabfolder.getData(DATA_PATIENT); if (p == null) { return; } for (CTabItem ci : tabfolder.getItems()) { ci.getControl().dispose(); ci.dispose(); } for (Control ctrl : tabfolder.getChildren()) { ctrl.dispose(); } if (form.getCursor() == null) form.setCursor(new Cursor(form.getShell().getDisplay(), SWT.CURSOR_WAIT)); initializeContent(); refreshContent(p, null); if (form.getCursor() != null) form.setCursor(null); } }; }
From source file:com.hsveclipse.phototoolkit.application.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 w ww . jav a 2 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(); ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$ pmContext, null); } } }); pmContext.dispose(); }
From source file:com.htmlhifive.tools.jslint.dialog.CreateEngineDialog.java
License:Apache License
@Override protected void okPressed() { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(getShell()); DownloadEngineSupport support = createEngineDownload((Boolean) wvJslint.getValue()); try {//www. j av a 2s. co m IFile file = ResourcesPlugin.getWorkspace().getRoot() .getFile(new Path(wvOutputDir.getValue() + "/" + support.getEngine().getFileName())); if (file.exists()) { MessageBox box = new MessageBox(getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); box.setMessage(Messages.DM0004.getText()); box.setText(Messages.DT0011.getText()); if (box.open() == SWT.CANCEL) { return; } } DownloadRunnable progress = new DownloadRunnable(support); progressDialog.run(true, false, progress); EngineInfo info = progress.getResult(); if (info == null) { ErrorDialog.openError(getShell(), Messages.DT0003.getText(), Messages.EM0015.getText(), ValidationStatus.error(Messages.EM0015.getText())); return; } ConfirmLicenseDialog dialog = new ConfirmLicenseDialog(getShell(), StringUtils.trim(info.getLicenseStr()), Messages.DT0009.getText()); if (dialog.open() == IDialogConstants.OK_ID) { if (file.exists()) { file.setContents(new ByteArrayInputStream(info.getMainSource().getBytes()), IResource.FORCE, null); } else { file.create(new ByteArrayInputStream(info.getMainSource().getBytes()), true, null); } this.engineFilePath = file.getFullPath().toString(); } else { return; } } catch (InvocationTargetException e) { ErrorDialog.openError(getShell(), Messages.DT0003.getText(), Messages.EM0015.getText(), new Status(IStatus.ERROR, JSLintPlugin.PLUGIN_ID, e.getMessage(), e)); logger.put(Messages.EM0100, e); } catch (InterruptedException e) { // ????????. throw new AssertionError(); } catch (CoreException e) { ErrorDialog.openError(getShell(), Messages.DT0003.getText(), Messages.EM0016.getText(), e.getStatus()); logger.put(Messages.EM0100, e); } super.okPressed(); }
From source file:com.htmlhifive.tools.wizard.RemoteContentManager.java
License:Apache License
/** * .//from ww w .j a va 2s . c om * * @param refresh * @param shell * @return */ public static LibraryList getLibraryList(boolean refresh) { if (!refresh && H5WizardPlugin.getInstance().getLibraryList() != null) { return H5WizardPlugin.getInstance().getLibraryList(); } // ????? H5WizardPlugin.getInstance().setLibraryList(null); H5WizardPlugin.getInstance().getSelectedLibrarySet().clear(); ResultStatus resultStatus = new ResultStatus(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(null); // ?. for (String urlStr : new String[] { PluginConstant.URL_LIBRARY_LIST, PluginConstant.URL_LIBRARY_LIST_MIRROR, LOCAL_LIBRARIES_XML }) { if (StringUtils.isNotEmpty(urlStr)) { InputStream is = null; DownloadModule downloadModule = new DownloadModule(); try { // IConnectMethod method = ConnectMethodFactory.getMethod(urlStr, true); // method.setConnectionTimeout(PluginConstant.URL_LIBRARY_LIST_CONNECTION_TIMEOUT); // method.setProxy(downloadModule.getProxyService()); // is = method.getInputStream(); // if (is == null) { // resultStatus.log(Messages.SE0046, urlStr); // } else { // LibraryFileParser parser = LibraryFileParserFactory.createParser(is); // LibraryList libraryList = parser.getLibraryList(); // libraryList.setLastModified(method.getLastModified()); // libraryList.setSource(urlStr); // H5WizardPlugin.getInstance().setLibraryList(libraryList); // ??????. // return libraryList; // } // } catch (ParseException e) { // resultStatus.log(e, Messages.SE0046, urlStr); // } catch (MalformedURLException e) { // resultStatus.log(e, Messages.SE0046, urlStr); // } catch (IOException e) { // resultStatus.log(e, Messages.SE0046, urlStr); //??? final IRunnableWithProgress runnable = getSiteDownLoad(resultStatus, urlStr, downloadModule); try { dialog.run(true, false, runnable); if (resultStatus.isSuccess()) { return H5WizardPlugin.getInstance().getLibraryList(); } } catch (InvocationTargetException e) { resultStatus.log(e, Messages.SE0046, urlStr); } catch (InterruptedException e) { resultStatus.log(e, Messages.SE0046, urlStr); } } finally { downloadModule.close(); IOUtils.closeQuietly(is); } } } // // ??. // InputStream is = null; // try { // URLConnection connection = RemoteContentManager.class.getResource(LOCAL_LIBRARIES_XML).openConnection(); // is = connection.getInputStream(); // if (is == null) { // resultStatus.log(Messages.SE0046, LOCAL_LIBRARIES_XML); // } else { // LibraryFileParser parser = LibraryFileParserFactory.createParser(is); // LibraryList libraryList = parser.getLibraryList(); // if (connection.getLastModified() > 0) { // libraryList.setLastModified(new Date(connection.getLastModified())); // } // libraryList.setSource(null); // H5WizardPlugin.getInstance().setLibraryList(libraryList); // ??????. // return libraryList; // } // } catch (ParseException e) { // resultStatus.log(e, Messages.SE0046, LOCAL_LIBRARIES_XML); // } catch (IOException e) { // resultStatus.log(e, Messages.SE0046, LOCAL_LIBRARIES_XML); // } finally { // IOUtils.closeQuietly(is); // } if (!resultStatus.isSuccess()) { // ?. resultStatus.falureDialog(Messages.PI0139, Messages.PI0140); } return null; }
From source file:com.htmlhifive.tools.wizard.ui.property.LibraryImportPropertyPage.java
License:Apache License
/** * Nature??.// ww w . j a v a2 s. c o m * * @param project * @param natureId NatureID * @return ??????. */ private boolean addNature(IProject project, String natureId) { // JSNature?. if (MessageDialog.openQuestion(getShell(), Messages.SE0119.format(), Messages.SE0120.format(getTitle()))) { // ?. final ResultStatus logger = new ResultStatus(); try { // . final IRunnableWithProgress downloadRunnable = getAddNatureRunnnable(logger, project, natureId); ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.run(false, false, downloadRunnable); // ?????. return true; } catch (InvocationTargetException e) { final Throwable ex = e.getTargetException(); H5LogUtils.putLog(ex, Messages.SE0025); } catch (InterruptedException e) { logger.setInterrupted(true); // We were cancelled... //removeProject(logger); } finally { // // ?. // logger.showDialog(Messages.PI0138); if (logger.isSuccess()) { return true; } // ??(??). container.refreshTreeLibrary(false, true); // SE0103=INFO,????? logger.log(Messages.SE0103); } } return false; }
From source file:com.htmlhifive.tools.wizard.ui.property.LibraryImportPropertyPage.java
License:Apache License
/** * {@inheritDoc}/*from w w w . jav a2 s.com*/ * * @see org.eclipse.jface.preference.PreferencePage#performOk() */ @Override public boolean performOk() { logger.log(Messages.TR0021, getClass().getName(), "performOk"); if (!getApplyButton().isEnabled()) { // ?. return true; } // ????????. boolean needConfirmDialog = false; for (LibraryNode libraryNode : H5WizardPlugin.getInstance().getSelectedLibrarySet()) { if (libraryNode.isNeedConfirmDialog()) { needConfirmDialog = true; } } // ?. if (needConfirmDialog) { WizardDialog confirmLicenseWizardDialog = new WizardDialog(getShell(), new ConfirmLicenseWizard()); confirmLicenseWizardDialog.setPageSize(getShell().getSize()); // ????. int ret = confirmLicenseWizardDialog.open(); if (ret == SWT.ERROR) { // . return false; } } // ?. final ResultStatus logger = new ResultStatus(); try { // . final IRunnableWithProgress downloadRunnable = getDownloadRunnnable(logger); ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.run(false, false, downloadRunnable); } catch (InvocationTargetException e) { final Throwable ex = e.getTargetException(); H5LogUtils.putLog(ex, Messages.SE0025); } catch (InterruptedException e) { logger.setInterrupted(true); // We were cancelled... //removeProject(logger); return false; } finally { // ?. logger.showDialog(Messages.PI0138); // ??(??). container.refreshTreeLibrary(false, true); // SE0103=INFO,????? logger.log(Messages.SE0103); } return logger.isSuccess(); }
From source file:com.hudson.hibernatesynchronizer.editors.synchronizer.actions.RemoveRelatedFiles.java
License:GNU General Public License
/** * @see IActionDelegate#run(IAction)/*ww w . ja va 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); } } } } }