List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog getShell
@Override
public Shell getShell()
From source file:de.blizzy.backup.restore.RestoreDialog.java
License:Open Source License
@Override public int open() { final ProgressMonitorDialog dlg = new ProgressMonitorDialog(getParentShell()); IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override/* w ww . j a v a 2s. c o m*/ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.Title_OpenBackupDatabase, IProgressMonitor.UNKNOWN); final boolean[] ok = { true }; List<StorageInterceptorDescriptor> descs = BackupPlugin.getDefault().getStorageInterceptors(); for (final StorageInterceptorDescriptor desc : descs) { final IStorageInterceptor interceptor = desc.getStorageInterceptor(); SafeRunner.run(new ISafeRunnable() { @Override public void run() { IDialogSettings settings = Utils .getChildSection(Utils.getSection("storageInterceptors"), desc.getId()); //$NON-NLS-1$ if (!interceptor.initialize(dlg.getShell(), settings)) { ok[0] = false; } } @Override public void handleException(Throwable t) { ok[0] = false; interceptor.showErrorMessage(t, dlg.getShell()); BackupPlugin.getDefault().logError( "error while initializing storage interceptor '" + desc.getName() + "'", t); //$NON-NLS-1$ //$NON-NLS-2$ } }); storageInterceptors.add(interceptor); } if (!ok[0]) { monitor.done(); throw new InterruptedException(); } Cursor<BackupsRecord> cursor = null; try { database.open(storageInterceptors); database.initialize(); cursor = database.factory().selectFrom(Tables.BACKUPS) .where(Tables.BACKUPS.NUM_ENTRIES.isNotNull()).orderBy(Tables.BACKUPS.RUN_TIME.desc()) .fetchLazy(); while (cursor.hasNext()) { BackupsRecord record = cursor.fetchOne(); Backup backup = new Backup(record.getId().intValue(), new Date(record.getRunTime().getTime()), record.getNumEntries().intValue()); backups.add(backup); } } catch (SQLException | IOException e) { boolean handled = false; for (IStorageInterceptor interceptor : storageInterceptors) { if (interceptor.showErrorMessage(e, dlg.getShell())) { handled = true; } } if (handled) { throw new InterruptedException(); } throw new InvocationTargetException(e); } finally { database.closeQuietly(cursor); monitor.done(); } } }; try { dlg.run(true, false, runnable); } catch (InvocationTargetException e) { // TODO BackupPlugin.getDefault().logError("Error while opening backup database", e); //$NON-NLS-1$ } catch (InterruptedException e) { return Window.CANCEL; } return super.open(); }
From source file:de.blizzy.backup.Updater.java
License:Open Source License
public boolean update(Shell shell) throws Throwable { final boolean[] restartNecessary = new boolean[1]; if (needsCheck()) { final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override/*from w w w . ja v a2 s . co m*/ @SuppressWarnings("synthetic-access") public void run(IProgressMonitor monitor) { SubMonitor progress = SubMonitor.convert(monitor); restartNecessary[0] = updateInJob(progress, pmd.getShell()); monitor.done(); } }; try { pmd.run(true, true, runnable); } catch (InvocationTargetException e) { throw e.getCause(); } } if (restartNecessary[0]) { IDialogSettings settings = Utils.getSection("versionCheck"); //$NON-NLS-1$ settings.put("cleanupOldFeatures", true); //$NON-NLS-1$ } return restartNecessary[0]; }
From source file:de.fu_berlin.inf.dpp.project.SharedResourcesManager.java
License:Open Source License
protected void handleVCSActivity(VCSActivity activity) { final VCSActivity.Type activityType = activity.getType(); SPath path = activity.getPath();//from w ww. ja va 2 s .c o m final IResource resource = ((EclipseResourceImpl) path.getResource()).getDelegate(); final IProject project = ((EclipseProjectImpl) path.getProject()).getDelegate(); final String url = activity.getURL(); final String directory = activity.getDirectory(); final String revision = activity.getParam1(); // Connect is special since the project doesn't have a VCSAdapter // yet. final VCSAdapter vcs = activityType == VCSActivity.Type.CONNECT ? VCSAdapter.getAdapter(revision) : VCSAdapter.getAdapter(project); if (vcs == null) { log.warn("Could not execute VCS activity. Do you have the Subclipse plug-in installed?"); if (activity.containedActivity.size() > 0) { log.trace("contained activities: " + activity.containedActivity.toString()); } for (IResourceActivity a : activity.containedActivity) { consumer.exec(a); } return; } try { // TODO Should these operations run in an IWorkspaceRunnable? Shell shell = SWTUtils.getShell(); ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); progressMonitorDialog.open(); Shell pmdShell = progressMonitorDialog.getShell(); pmdShell.setText("Saros running VCS operation"); log.trace("about to call progressMonitorDialog.run"); progressMonitorDialog.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor progress) throws InvocationTargetException, InterruptedException { log.trace("progressMonitorDialog.run started"); if (!SWTUtils.isSWT()) log.trace("not in SWT thread"); if (activityType == VCSActivity.Type.CONNECT) { vcs.connect(project, url, directory, progress); } else if (activityType == VCSActivity.Type.DISCONNECT) { vcs.disconnect(project, revision != null, progress); } else if (activityType == VCSActivity.Type.SWITCH) { vcs.switch_(resource, url, revision, progress); } else if (activityType == VCSActivity.Type.UPDATE) { vcs.update(resource, revision, progress); } else { log.error("VCS activity type not implemented yet."); } log.trace("progressMonitorDialog.run done"); } }); pmdShell.dispose(); } catch (InvocationTargetException e) { // TODO We can't get here, right? throw new IllegalStateException(e); } catch (InterruptedException e) { log.error("Code not designed to be interrupted!"); } }
From source file:es.bsc.servicess.ide.dialogs.JarFileDialog.java
License:Apache License
private boolean loadWarFile(final String selectedDirectory) { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(this.getShell()); try {//from w w w.ja va2 s . c o m log.debug("Selected dir: " + selectedDirectory); final File warFile = new File(selectedDirectory); if (warFile.exists()) { dialog.run(false, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { IFolder importFolder = project.getProject().getFolder(ProjectMetadata.IMPORT_FOLDER); if (!importFolder.exists()) importFolder.create(true, true, monitor); String name = PackagingUtils.getPackageName(warFile); log.debug("Package name is " + name); IFolder extractFolder = importFolder.getFolder(name); if (!extractFolder.exists()) { extractWar(warFile, extractFolder, monitor); } else log.info("Package already exists. Not extracting"); } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); return true; } else throw (new InvocationTargetException(new Exception("The selected file doesn't exists"))); } catch (InvocationTargetException e) { log.error("Error loading package"); ErrorDialog.openError(dialog.getShell(), "Error loading new package file", "Exception when loading package", new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); return false; } catch (InterruptedException e) { log.error("Error loading package"); ErrorDialog.openError(dialog.getShell(), "Package load interrumped", "Exception when loading package", new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); return false; } }
From source file:es.bsc.servicess.ide.editors.BuildingDeploymentFormPage.java
License:Apache License
/** * Build the service packages//from ww w. ja v a 2s. co m */ private void buildPackages() { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getSite().getShell()); try { dialog.run(true, true, new IRunnableWithProgress() { /* (non-Javadoc) * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) */ public void run(IProgressMonitor monitor) throws InvocationTargetException { IJavaProject project = ((ServiceFormEditor) getEditor()).getProject(); try { ProjectMetadata pr_meta = ((ServiceFormEditor) getEditor()).getProjectMetadata(); PackagingUtils.buildPackages(project, pr_meta, monitor); /* monitor.beginTask("Building project classes...", 100); IFolder output = project.getProject().getFolder( ProjectMetadata.OUTPUT_FOLDER); if (output == null || !output.exists()) { output.create(true, true, monitor); } project.getProject().build( IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); // monitor.beginTask("Instrumenting Orchestrations...", // 100); // PackagingUtils.instrumentOrchestrations(pr_meta.getRuntimeLocation(),pr_meta.getOrchestrationClasses(), // output, monitor); monitor.beginTask("Creating packages...", 100); IFolder packages = output .getFolder(ProjectMetadata.PACKAGES_FOLDER); if (packages != null && packages.exists()) { packages.delete(true, monitor); } packages.create(true, true, monitor); // PackagingUtils.copyConfigFiles((ServiceFormEditor)getEditor()); log.debug("Getting packages..."); String[] packs = pr_meta.getPackages(); String runtime = pr_meta.getRuntimeLocation(); String[] orch_cls = pr_meta.getOrchestrationClasses(); IFolder src_fld = project.getProject().getFolder( pr_meta.getSourceDir()); IPackageFragmentRoot source = null; if (src_fld != null) source = project.findPackageFragmentRoot(src_fld .getFullPath()); IFolder gen_fld = project.getProject().getFolder( "generated"); IPackageFragmentRoot generated = null; if (gen_fld != null) generated = project.findPackageFragmentRoot(project .getProject().getFolder("generated") .getFullPath()); if (source != null && source.exists()) { if (constraintsElements == null) { constraintsElements = getElements(orch_cls, ProjectMetadata.CORE_TYPE, project, pr_meta); } if (packs != null && packs.length > 0) { log.debug("Building core element packages"); for (String p : packs) { String[] elements = pr_meta .getElementsInPackage(p); if (elements != null && elements.length > 0) { PackagingUtils.createCorePackage( runtime, p, elements, pr_meta.getDependencies(elements), constraintsElements, source, output, packages, monitor); } } } else { log.warn("Warning: No core element packages built"); monitor.setCanceled(true); throw (new InvocationTargetException( new Exception("No core element packages built"))); } if (orch_cls!= null && orch_cls.length>0){ log.debug("Generating Orchestration"); PackagingUtils.createServiceOrchestrationPackage( runtime, PackagingUtils.getClasspath(project), project.getProject().getName(), orch_cls, pr_meta.getDependencies(getOrchestrationElementsLabels( orch_cls, project, pr_meta)), source, generated, output, packages, monitor, shouldBeWarFile(pr_meta.getOrchestrationClassesTypes())); monitor.done(); }else{ log.warn("Warning: No orchestration element packages built"); monitor.setCanceled(true); throw (new InvocationTargetException( new Exception("No orchestration packages built"))); } } else { log.error("Source dir not found"); monitor.setCanceled(true); throw (new InvocationTargetException(new Exception( "Source dir " + src_fld.getFullPath() + " not found"))); }*/ } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); } catch (InvocationTargetException e) { ErrorDialog.openError(dialog.getShell(), "Error creating packages", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); e.printStackTrace(); } catch (InterruptedException e) { ErrorDialog.openError(dialog.getShell(), "Building interrumped", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); e.printStackTrace(); } }
From source file:es.bsc.servicess.ide.editors.ImplementationFormPage.java
License:Apache License
/** * Update the runtime location modifiying the dependency to the runtime libraries *//* w ww.ja v a2 s . c om*/ protected void updateRuntimeLocation() { if (previousRuntimeLocation != null && !previousRuntimeLocation.equals(runtimetext.getText().trim())) { IFile f = ((ServiceFormEditor) getEditor()).getMetadataFile(); try { ProjectMetadata pr_meta = new ProjectMetadata(f.getRawLocation().toFile()); pr_meta.removeDependency(previousRuntimeLocation + ProjectMetadata.ITJAR_EXT); pr_meta.setRuntimeLocation(runtimetext.getText().trim()); pr_meta.addDependency(runtimetext.getText().trim() + ProjectMetadata.ITJAR_EXT, ProjectMetadata.JAR_DEP_TYPE); pr_meta.toFile(f.getRawLocation().toFile()); final IJavaProject project = ((ServiceFormEditor) getEditor()).getProject(); final ProgressMonitorDialog mon = new ProgressMonitorDialog(getEditor().getSite().getShell()); mon.run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { project.getProject().refreshLocal(Resource.DEPTH_INFINITE, monitor); } catch (CoreException e) { ErrorDialog.openError(mon.getShell(), "Error refreshing the classpath", e.getMessage(), e.getStatus()); e.printStackTrace(); } } }); } catch (Exception e) { ErrorDialog.openError(this.getEditor().getSite().getShell(), "Error adding runtime to the classpath", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); e.printStackTrace(); } } previousRuntimeLocation = runtimetext.getText().trim(); }
From source file:es.bsc.servicess.ide.editors.ImplementationFormPage.java
License:Apache License
/** * Delete an orchestration class// w w w .j a v a 2 s. c o m * @param index Index of the selected Orchestration class */ protected void deleteServiceClass(int index) { if (MessageDialog.openQuestion(this.getEditor().getSite().getShell(), "Service Class Delete", " Delete service class " + serviceClassList.getItem(index) + ".\nAre you sure?")) { IPackageFragment frag = ((ServiceFormEditor) getEditor()).getMainPackage(); final ICompilationUnit cu_class = frag .getCompilationUnit(Signature.getSimpleName(serviceClassList.getItem(index)) + ".java"); final ICompilationUnit cu_itf = frag .getCompilationUnit(Signature.getSimpleName(serviceClassList.getItem(index)) + "Itf.java"); final ProgressMonitorDialog mon = new ProgressMonitorDialog(getEditor().getSite().getShell()); try { deleteClassFromMetadataFile(serviceClassList.getItem(index)); mon.run(false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { cu_class.delete(true, monitor); cu_itf.delete(true, monitor); } catch (JavaModelException e) { log.error("Error deleting service class", e); ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(), e.getStatus()); } } }); initData(); } catch (InvocationTargetException e) { log.error("Error deleting service class", e); ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); } catch (InterruptedException e) { log.error("Error deleting service class", e); ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); } catch (ConfigurationException e) { log.error("Error deleting service class", e); ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); } catch (PartInitException e) { log.error("Error deleting service class", e); ErrorDialog.openError(mon.getShell(), "Error deleting service class", e.getMessage(), e.getStatus()); } } }
From source file:es.bsc.servicess.ide.wizards.coretypes.ServiceWarSpecificTreatment.java
License:Apache License
private void loadWarFile(final String selectedDirectory, final IFolder extractFolder) { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try {// w w w. jav a 2 s. c o m log.debug("Selected dir: " + selectedDirectory); final File warFile = new File(selectedDirectory); if (warFile.exists()) { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { extractWar(warFile, extractFolder, monitor); } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); resetServiceInfo(); warLocation.setText(selectedDirectory); warPath = selectedDirectory; wsdlLocation.setText(""); urlPattern.setText(""); wsdl = null; serviceURLPath = null; wsdlSelectButton.setEnabled(true); urlPatternSelectButton.setEnabled(true); } else throw (new InvocationTargetException(new Exception("The selected file doesn't exists"))); } catch (InvocationTargetException e) { ErrorDialog.openError(dialog.getShell(), "Error loading new war file", "Exception when loading war", new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); e.printStackTrace(); } catch (InterruptedException e) { ErrorDialog.openError(dialog.getShell(), "War load interrumped", "Exception when loading war", new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); e.printStackTrace(); } }
From source file:es.bsc.servicess.ide.wizards.coretypes.ServiceWarSpecificTreatment.java
License:Apache License
private void loadWSDLFile(final String selectedDirectory) { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try {/* ww w.j a v a2 s.c om*/ final File fpath = new File(selectedDirectory); if (fpath.exists()) { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { loadWSDL(fpath); } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); wsdlLocation.setText(selectedDirectory); resetServiceInfo(); } else { throw (new InvocationTargetException(new Exception("The selected file doesn't exists"))); } } catch (InvocationTargetException e) { ErrorDialog.openError(dialog.getShell(), "Error loading new WSDL file", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); e.printStackTrace(); } catch (InterruptedException e) { ErrorDialog.openError(dialog.getShell(), "WSDL load interrumped", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); e.printStackTrace(); } }
From source file:es.bsc.servicess.ide.wizards.ServiceSsImportOrchestrationClassPage.java
License:Apache License
private boolean loadWarFile(final String selectedDirectory, final IFolder importFolder) { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(this.getShell()); try {/* w ww . j av a 2 s . co m*/ log.debug("Selected dir: " + selectedDirectory); final File warFile = new File(selectedDirectory); if (warFile.exists()) { dialog.run(false, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { if (!importFolder.exists()) importFolder.create(true, true, monitor); String name = PackagingUtils.getPackageName(warFile); log.debug("Package name is " + name); IFolder extractFolder = importFolder.getFolder(name); if (!extractFolder.exists()) { extractWar(warFile, extractFolder, monitor); updateDeps(warPath, selectedDirectory, ProjectMetadata.WAR_DEP_TYPE, monitor); } else log.info("Package already exists. Not extracting"); } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); return true; } else throw (new InvocationTargetException(new Exception("The selected file doesn't exists"))); } catch (InvocationTargetException e) { log.error("Error loading package"); ErrorDialog.openError(dialog.getShell(), "Error loading new package file", "Exception when loading package", new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); return false; } catch (InterruptedException e) { log.error("Error loading package"); ErrorDialog.openError(dialog.getShell(), "Package load interrumped", "Exception when loading package", new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); return false; } }