List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog
public ProgressMonitorDialog(Shell parent)
From source file:com.nextep.datadesigner.gui.impl.CommandProgress.java
License:Open Source License
public static List<?> runWithProgress(boolean fork, String name, Shell shell, boolean cancellable, ICommand... commands) {/* w ww . j a va 2s. c o m*/ waitVolatileJobs(); ProgressMonitorDialog pd = new ProgressMonitorDialog(shell); try { CommandProgress cmdProgress = new CommandProgress(fork, name, shell, commands); pd.run(fork, cancellable, cmdProgress); return cmdProgress.getResults(); } catch (InvocationTargetException e) { if (e.getCause() instanceof DesignerException) { throw (DesignerException) e.getCause(); } else if (e.getCause() instanceof SWTException && e.getCause().getCause() instanceof DesignerException) { // In case of Display.syncExec or asyncExec call, we will fall here // with our exception wrapped into a SWTException throw (DesignerException) e.getCause().getCause(); } else { throw new ErrorException(e.getCause()); } } catch (InterruptedException e) { throw new ErrorException(e); } }
From source file:com.nextep.datadesigner.vcs.gui.dialog.MergeResultGUI.java
License:Open Source License
private void createMergeNavigators() { // Sorting results by source name / target name final List<IComparisonItem> sortedResult = Arrays.asList(result); // Sorting items unless told not to do so if (!noSort) { Collections.sort(sortedResult, new Comparator<IComparisonItem>() { @Override/*from w w w.ja va 2 s.c o m*/ public int compare(IComparisonItem o1, IComparisonItem o2) { IReferenceable src = o1.getSource() == null ? o1.getTarget() : o1.getSource(); IReferenceable tgt = o2.getSource() == null ? o2.getTarget() : o2.getSource(); return ((INamedObject) src).getName().compareTo(((INamedObject) tgt).getName()); } }); } // Creating merge lines items ProgressMonitorDialog pd = new ProgressMonitorDialog(this.getShell()); try { pd.run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.setTaskName("Initializing..."); monitor.beginTask("Preparing preview for user validation...", result.length); for (IComparisonItem content : sortedResult) { // if(!hideUnchanged || content.getDifferenceType()!=DifferenceType.EQUALS) { int type = UPDATES; switch (content.getDifferenceType()) { case EQUALS: if (hideUnchanged) { continue; } type = UNCHANGED; break; case DIFFER: type = UPDATES; break; case MISSING_SOURCE: type = DELETIONS; break; case MISSING_TARGET: type = ADDITIONS; break; } sourceConn = new MergeNavigator(sourceRoot[type], targetRoot[type], mergedRoot[type], content); sourceConn.setShowAllChecks(repositoryMergeWindow); if (content.getDifferenceType() != DifferenceType.EQUALS) { sourceConn.showUnchangedItems(!hideUnchanged); } else { sourceConn.showUnchangedItems(true); } sourceConn.create(sourceRoot[type], -1); sourceConn.initialize(); sourceConn.refreshConnector(false); monitor.worked(1); } // } for (int i = 0; i < 4; i++) { final int count = sourceRoot[i].getItemCount(); if (count > 0) { sourceRoot[i].setText(VCSUIMessages.getString(msgKeys[i]) + " (" + count + ")"); sourceRoot[i].setFont(FontFactory.FONT_BOLD); // Unchecking everything to ensure reprocessing sourceRoot[i].setChecked(false); targetRoot[i].setChecked(false); mergedRoot[i].setChecked(false); // Processing gray checks gray(sourceRoot[i]); gray(targetRoot[i]); gray(mergedRoot[i]); } else { sourceRoot[i].setText(VCSUIMessages.getString(msgKeys[i])); sourceRoot[i].setFont(null); } } monitor.done(); } }); } catch (Exception e) { throw new ErrorException(e); } }
From source file:com.nextep.datadesigner.vcs.gui.dialog.VersionDiffViewer.java
License:Open Source License
private void refreshGUI() { if (result.length == 1) { IComparisonItem soloResult = result[0]; // Setting source & target release in a null safe way if (soloResult.getSource() instanceof IVersionable) { IVersionable<?> srcVersion = (IVersionable<?>) soloResult.getSource(); sourceText.setText(srcVersion.getVersion().getLabel() + " - " + srcVersion.getVersion().getStatus().getLabel()); }//w ww. ja v a 2s . c om if (soloResult.getTarget() instanceof IVersionable) { IVersionable<?> tgtVersion = (IVersionable<?>) soloResult.getTarget(); targetText.setText(tgtVersion.getVersion().getLabel() + " - " + tgtVersion.getVersion().getStatus().getLabel()); } } else { sourceText.setText("Comparing a set of source items"); targetText.setText("Comparing a set of target items"); } // Setting proper button action if (diffOnlyFlag) { diffOnlyButton.setText("Show all hierarchy"); } else { diffOnlyButton.setText("Show differences only"); } sourceTree.removeAll(); TreeItem srcRoot = new TreeItem(sourceTree, SWT.NONE); srcRoot.setText("Comparison results..."); //result.getSource().toString()); srcRoot.setImage(VCSImages.ICON_DIFF); //generateViewer(result,srcRoot); ProgressMonitorDialog pd = new ProgressMonitorDialog(this.getShell()); try { pd.run(true, false, new GenerationProgress(srcRoot, result)); } catch (Exception e) { throw new ErrorException(e); } srcRoot.setExpanded(true); }
From source file:com.nextep.designer.vcs.ui.controllers.MergeController.java
License:Open Source License
/** * @see com.nextep.datadesigner.gui.model.InvokableController#invoke(java.lang.Object) *///from w ww. ja v a 2 s . c om @Override public Object invoke(Object... model) { if (model.length == 0) { throw new ErrorException("The merge controller need at least 1 non-null argument to proceed."); } else { final IVersionable<?> versionable = (IVersionable<?>) model[0]; final MergeWizard wiz = new MergeWizard(new MergeInitGUI(versionable), new MergePreviewWizard(versionable)); wiz.setToVersionable(versionable); WizardDialog w = new WizardDialog( VCSUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), wiz); w.setBlockOnOpen(true); w.open(); if (w.getReturnCode() != Window.CANCEL) { // FIXME QUICKFIX calling this static method => TO remove !!! MergeStrategy.setIsGenerating(false); // try { final IMerger m = MergerFactory.getMerger(wiz.getToRelease()); // Building compare command ICommand compareCommand = new ICommand() { @Override public Object execute(Object... parameters) { return m.compare(wiz.getReference(), wiz.getFromRelease(), wiz.getToRelease(), true); } @Override public String getName() { return "Computing differences between " + wiz.getToRelease().getLabel() + " and " + wiz.getFromRelease().getLabel(); } }; final IComparisonItem comp = (IComparisonItem) CommandProgress.runWithProgress(compareCommand) .iterator().next(); ProgressMonitorDialog pd = new ProgressMonitorDialog( VCSUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell()); try { pd.run(true, false, new MergeProgress(comp, m)); } catch (Exception e) { throw new ErrorException(e); } // } finally { MergeStrategy.setIsGenerating(true); // } MergeResultGUI mergeGUI = new MergeResultGUI(true, comp); mergeGUI.setIsRepositoryMerge(true); mergeGUI.setRootText( "Source release " + wiz.getFromRelease().getLabel() + " [" + wiz.getFromRelease().getBranch().getName() + "]", "Current target release " + wiz.getToRelease().getLabel() + " [" + wiz.getToRelease().getBranch().getName() + "]", "Merge result"); boolean doItAgain = true; while (doItAgain) { invokeGUI(new GUIWrapper(mergeGUI, "Merge results", 800, 600)); // Checking that everything is resolved if (comp.getMergeInfo().getStatus() != MergeStatus.MERGE_RESOLVED) { // IF not we ask if the user would like to edit again doItAgain = MessageDialog.openQuestion( VCSUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), VCSUIMessages.getString("mergeUnresolvedTitle"), VCSUIMessages.getString("mergeUnresolved")); if (!doItAgain) { throw new CancelException("Merge operation aborted due to unresolved conflicts."); } } else { doItAgain = false; } } // We fall here if no cancel exception // HibernateUtil.getInstance().getSession().clear(); // IdentifiableDAO.getInstance().loadAll(VersionReference.class); HibernateUtil.getInstance().clearAllSessions(); pd = new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); try { pd.run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Merge in progress...", 5); // Global listeners switch off Observable.deactivateListeners(); // Refreshing progress monitor.worked(1); IVersionable<?> mergedObject = null; try { // Building the merge result final String activityText = "Merged " + wiz.getFromRelease().getLabel() + " -> " + wiz.getFromRelease().getBranch().getName(); final IVersioningService versioningService = VCSPlugin .getService(IVersioningService.class); final IActivity mergeActivity = versioningService.createActivity(activityText); mergedObject = (IVersionable<?>) m.buildMergedObject(comp, mergeActivity); // Checking if the merge did anything if (mergedObject instanceof IVersionable<?>) { if (((IVersionable<?>) mergedObject).getVersion() .getStatus() == IVersionStatus.CHECKED_IN) { final boolean forceMerge = MessageDialog.openQuestion( Display.getCurrent().getActiveShell(), VCSUIMessages.getString("mergeDidNothingTitle"), VCSUIMessages.getString("mergeDidNothing")); if (forceMerge) { comp.getMergeInfo().setMergeProposal(null); mergedObject = (IVersionable<?>) m.buildMergedObject(comp, mergeActivity); } else { return; } } } } finally { Observable.activateListeners(); } log.info("Merged successfully!"); // Refreshing progress monitor.worked(1); monitor.setTaskName("Updating view contents..."); // Temporary bugfix for DES-710 // TODO refactor EVERYTHING as a service final Session session = HibernateUtil.getInstance().getSandBoxSession(); // FIXME draft of view removal / addition of the merged object // Switching versionables (for database only) IVersionContainer parent = versionable.getContainer(); // First removing current versionable in current session parent.getContents().remove(versionable); versionable.setContainer(null); // Forcing save of module without parent final IIdentifiableDAO identifiableDao = CorePlugin.getIdentifiableDao(); identifiableDao.save(parent); // Refreshing progress monitor.worked(1); // Reloading parent container in sandbox (because merged object is in // sandbox) if (parent instanceof IWorkspace) { parent = (IVersionContainer) identifiableDao.load(Workspace.class, parent.getUID(), session, false); } else { parent = (IVersionContainer) identifiableDao.load(IVersionable.class, parent.getUID(), session, false); } // Refreshing progress monitor.worked(1); monitor.setTaskName("Committing to repository..."); // Adding sandbox merged object mergedObject.setContainer(parent); parent.getContents().add(mergedObject); // Saving to sandbox before reloading view identifiableDao.save(mergedObject); session.flush(); // ************** // DES-710 urgent workaround // Hibernate does not properly send the INSERT statements to the db // But logs it properly in the logs ! final IRepositoryService repositoryService = CorePlugin.getRepositoryService(); final IDatabaseConnector connector = repositoryService.getRepositoryConnector(); final IConnection repositoryConnection = repositoryService.getRepositoryConnection(); Connection conn = null; PreparedStatement stmt = null; try { conn = connector.connect(repositoryConnection); String insertSql = null; if (parent instanceof IWorkspace) { insertSql = "INSERT INTO REP_VIEW_CONTENTS (VIEW_ID,VERSION_ID) VALUES (?,?)"; //$NON-NLS-1$ } else { insertSql = "INSERT INTO REP_MODULE_CONTENTS (MODULE_ID,VERSION_ID) VALUES (?,?)"; //$NON-NLS-1$ } stmt = conn.prepareStatement(insertSql); stmt.setLong(1, parent.getUID().rawId()); stmt.setLong(2, mergedObject.getUID().rawId()); stmt.execute(); if (!conn.getAutoCommit()) { conn.commit(); } } catch (SQLException e) { log.error(e); } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { log.error(e); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { log.error(e); } } } // End of DES-710 workaround // ************** // HibernateUtil.getInstance().reconnectAll(); // Merger.save(mergedObject); // Merger.save(parent); monitor.worked(1); log.info("Please wait while view is reloading..."); monitor.setTaskName("Finished: Reloading view..."); monitor.done(); // END OF the fixme part } }); } catch (Exception e) { throw new ErrorException(e); } // Restoring a new view log.info("Refreshing current view"); VersionUIHelper.changeView(VersionHelper.getCurrentView().getUID()); // Designer.getInstance().invokeSelection("com.neXtep.designer.vcs.SelectionInvoker", // "version.compare", comp); } } return null; }
From source file:com.nginious.http.plugin.PublishHandler.java
License:Apache License
private void publishProject(Shell shell, IProject project) { logger.log("ENTER PublishHandler.publishProject project={0}", project); IRunnableContext context = new ProgressMonitorDialog(shell); try {//ww w . j a v a2s . c om Publisher publisher = new Publisher(shell, project); context.run(true, false, publisher); } catch (InterruptedException e) { } catch (InvocationTargetException e) { logger.log("PublishHandler.publishProject exception", e); String title = Messages.PublishHandler_error_title; Object[] args = { project.getName() }; String message = MessageFormat.format(Messages.PublishHandler_error_message, args); MessagesUtils.displayMessageDialog(e.getMessage(), null, title, message); } }
From source file:com.nokia.carbide.search.system.internal.ui.text.ReplaceAction2.java
License:Open Source License
private boolean validateResources(final FileSearchQuery operation) { IFile[] readOnlyFiles = getReadOnlyFiles(); IStatus status = ResourcesPlugin.getWorkspace().validateEdit(readOnlyFiles, fSite.getShell()); if (!status.isOK()) { if (status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(fSite.getShell(), SearchMessages.ReplaceAction2_error_validate_title, SearchMessages.ReplaceAction2_error_validate_message, status); }/*from w w w. ja v a2 s .c o m*/ return false; } final List outOfDateEntries = new ArrayList(); for (int j = 0; j < fElements.length; j++) { IFileStore entry = fElements[j]; Match[] markers = fPage.getDisplayedMatches(entry); for (int i = 0; i < markers.length; i++) { if (isOutOfDate((FileMatch) markers[i])) { outOfDateEntries.add(entry); break; } } } final List outOfSyncEntries = new ArrayList(); // for (int i= 0; i < fElements.length; i++) { // IFileStore entry = fElements[i]; // if (isOutOfSync(entry)) { // outOfSyncEntries.add(entry); // } // } if (outOfDateEntries.size() > 0 || outOfSyncEntries.size() > 0) { if (askForResearch(outOfDateEntries, outOfSyncEntries)) { ProgressMonitorDialog pmd = new ProgressMonitorDialog(fSite.getShell()); try { pmd.run(true, true, new WorkspaceModifyOperation(null) { protected void execute(IProgressMonitor monitor) throws CoreException { research(monitor, outOfDateEntries, operation); } }); return true; } catch (InvocationTargetException e) { ExceptionHandler.handle(e, fSite.getShell(), SearchMessages.ReplaceAction_label, SearchMessages.ReplaceAction_research_error); } catch (InterruptedException e) { // canceled } } return false; } return true; }
From source file:com.nokia.carbide.search.system.internal.ui.util.ExtendedDialogWindow.java
License:Open Source License
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { // The operation can only be canceled if it is executed in a separate thread. // Otherwise the UI is blocked anyway. Object state = null;// w ww . j a va 2s.c o m try { fActiveRunningOperations++; state = aboutToStart(fork && cancelable); if (fUseEmbeddedProgressMonitorPart) { ModalContext.run(runnable, fork, fProgressMonitorPart, getShell().getDisplay()); } else { new ProgressMonitorDialog(getShell()).run(fork, cancelable, runnable); } } finally { if (state != null) stopped(state); fActiveRunningOperations--; } }
From source file:com.nokia.carbide.search.system2.internal.ui.InternalSearchUI.java
License:Open Source License
public IStatus runSearchInForeground(IRunnableContext context, final ISearchQuery query, ISearchResultViewPart view) {/* www . j av a 2 s . c om*/ if (isQueryRunning(query)) { return Status.CANCEL_STATUS; } // prepare view if (view == null) { getSearchViewManager().activateSearchView(true); } else { getSearchViewManager().activateSearchView(view); } addQuery(query); SearchJobRecord sjr = new SearchJobRecord(query, false); fSearchJobs.put(query, sjr); if (context == null) context = new ProgressMonitorDialog(null); return doRunSearchInForeground(sjr, context); }
From source file:com.nokia.s60ct.cenrep.gui.editors.CRBrowser.java
License:Open Source License
@Override public void doSave(IProgressMonitor monitor) { 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. ///*www .j a v a2 s . co m*/ IRunnableWithProgress operation = new IRunnableWithProgress() { // This is the method that gets invoked when the operation runs. // public void run(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 { savedResources.add(resource); resource.save(saveOptions); } 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) { CenRepPlugin.INSTANCE.log(exception); } }
From source file:com.nokia.s60ct.gui.editors.ConfigurationBrowser.java
License:Open Source License
@Override public void doSave(IProgressMonitor monitor) { checkUndefinedTypes();/*ww w .j a va2 s. co m*/ 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. // IRunnableWithProgress operation = new IRunnableWithProgress() { // This is the method that gets invoked when the operation runs. // public void run(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 { savedResources.add(resource); Object rootConf = resource.getContents().get(0); if (rootConf instanceof RootConf && ((RootConf) rootConf).getRoot() == null) resource.save(saveOptions); } 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) { S60CtEditorPlugin.INSTANCE.log(exception); } }