List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:com.freescale.deadlockpreventer.agent.LauncherView.java
License:Open Source License
protected int handleConflict(Conflict conflictItem) { if (!passFilters(conflictItem)) return IConflictListener.CONTINUE; int flag = 0; if (Boolean.parseBoolean(InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).get(PREF_PRINT_TO_STDOUT, Boolean.toString(false)))) flag |= IConflictListener.LOG_TO_CONSOLE; if (logAndContinue.getSelection()) return flag | IConflictListener.CONTINUE; if (throwsException.getSelection()) return flag | IConflictListener.EXCEPTION; if (terminate.getSelection()) return flag | IConflictListener.ABORT; if (interactive.getSelection()) { final String conflictMessage = conflictItem.message; MessageDialog dialog = new MessageDialog(getSite().getShell(), "Deadlock confict occured", null, "An incorrect synchronization primitive acquisition order has occured.", MessageDialog.QUESTION, new String[] { "Continue", "Throw exception", "Terminate process" }, 0) { protected Control createCustomArea(Composite parent) { parent.setLayout(new GridLayout()); Text text = new Text(parent, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); text.setText(conflictMessage); text.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); text.setLayoutData(layoutData); return super.createCustomArea(parent); }//from w w w.jav a 2s . c o m protected Point getInitialSize() { Point pt = super.getInitialSize(); pt.x = Math.min(pt.x, 600); pt.y = Math.min(pt.y, 600); return pt; } }; int index = dialog.open(); if (index == 1) return flag | IConflictListener.EXCEPTION; if (index == 2) return flag | IConflictListener.ABORT; } return flag | IConflictListener.CONTINUE; }
From source file:com.ge.research.sadl.ui.editor.SadlEditorCallback.java
License:Open Source License
private void handleNatureAdding(XtextEditor editor) { IResource resource = editor.getResource(); if (resource != null && !toggleNature.hasNature(resource.getProject()) && resource.getProject().isAccessible() && !resource.getProject().isHidden()) { String title = Messages.NatureAddingEditorCallback_MessageDialog_Title; String message = Messages.NatureAddingEditorCallback_MessageDialog_Msg0 + resource.getProject().getName() + Messages.NatureAddingEditorCallback_MessageDialog_Msg1; MessageDialog dialog = new MessageDialog( editor.getEditorSite().getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);/*w w w . ja v a 2 s. c o m*/ int open = dialog.open(); if (open == 0) { toggleNature.toggleNature(resource.getProject()); } } }
From source file:com.generalrobotix.ui.item.GrxModelItem.java
License:Open Source License
public int checkModifiedModel(boolean reload) { if (bModified_) { String mes = MessageBundle.get("GrxProjectItem.dialog.message.changeModel.mes"); //$NON-NLS-1$ mes = NLS.bind(mes, new String[] { getName() }); MessageDialog msgDlg = new MessageDialog(GrxUIPerspectiveFactory.getCurrentShell(), MessageBundle.get("GrxProjectItem.dialog.message.changeModel.title"), null, mes, MessageDialog.INFORMATION, new String[] { MessageBundle.get("GrxProjectItem.dialog.message.changeModel.btn.save"), MessageBundle.get("GrxProjectItem.dialog.message.changeModel.btn.reverse"), MessageBundle.get("GrxProjectItem.dialog.message.changeModel.btn.cancel") }, 2);/*from ww w .j av a 2s . co m*/ switch (msgDlg.open()) { case 0: if (reload) { if (!saveAndLoad()) return MODIFIED_NG; else return MODIFIED_OK; } else { if (!_saveAs()) return MODIFIED_NG; cancelModified(); return MODIFIED_OK; } case 1: if (reload) { if (!reload()) return MODIFIED_NG; else return MODIFIED_OK; } else { cancelModified(); return MODIFIED_OK; } case 2: default: return MODIFIED_NG; } } return MODIFIED_NOT; }
From source file:com.generalrobotix.ui.item.GrxSimulationItem.java
License:Open Source License
private boolean _setupController(GrxModelItem model, ControllerAttribute deactivatedController) { String controllerName = model.getProperty("controller"); //$NON-NLS-1$ if (controllerName == null || controllerName.equals("")) //$NON-NLS-1$ return true; double step = model.getDbl("controlTime", 0.005); //$NON-NLS-1$ if (stepTime_ > step) { MessageDialog.openInformation(GrxUIPerspectiveFactory.getCurrentShell(), "", //$NON-NLS-1$ MessageBundle.get("GrxOpenHRPView.dialog.message.errorControlTime")); //$NON-NLS-1$ return false; }//w w w .ja va 2s. c o m String optionAdd = null; if (!isTrue("integrate", true)) optionAdd = " -nosim"; //$NON-NLS-1$ GrxDebugUtil.println("model name = " + model.getName() + " : controller = " + controllerName //$NON-NLS-1$//$NON-NLS-2$ + " : cycle time[s] = " + step); //$NON-NLS-1$ GrxProcessManager pManager = (GrxProcessManager) manager_.getItem("processManager"); ; boolean doRestart = false; org.omg.CORBA.Object cobj = GrxCorbaUtil.getReference(controllerName); AProcess proc = pManager.get(controllerName); String dir = model.getStr("setupDirectory", ""); //$NON-NLS-1$ //$NON-NLS-2$ String com = model.getStr("setupCommand", ""); //$NON-NLS-1$ //$NON-NLS-2$ if (cobj != null) { try { cobj._non_existent(); if (isInteractive_ && (!com.equals("") || proc != null)) { // ask only in case being abled to restart process //$NON-NLS-1$ MessageDialog dialog = new MessageDialog(GrxUIPerspectiveFactory.getCurrentShell(), MessageBundle.get("GrxOpenHRPView.dialog.title.restartController"), null, //$NON-NLS-1$ MessageBundle.get("GrxOpenHRPView.dialog.message.restartController0") + controllerName //$NON-NLS-1$ + MessageBundle.get("GrxOpenHRPView.dialog.message.restartController1") //$NON-NLS-1$ + MessageBundle.get("GrxOpenHRPView.dialog.message.restartController2"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { MessageBundle.get("GrxOpenHRPView.dialog.button.yes"), //$NON-NLS-1$ MessageBundle.get("GrxOpenHRPView.dialog.button.no"), //$NON-NLS-1$ MessageBundle.get("GrxOpenHRPView.dialog.button.cancel") }, //$NON-NLS-1$ 2); switch (dialog.open()) { case 0: // 0 == "YES" doRestart = true; break; case 1: // 1 == "NO" if (deactivatedController != null) deactivatedController.active(); break; default: return false; } } else { if ((!com.equals("") || proc != null) && deactivatedController != null) deactivatedController.active(); } } catch (Exception e) { cobj = null; } } if (cobj == null || doRestart) { if (proc != null) proc.stop(); if (!com.equals("")) { //$NON-NLS-1$ com = dir + java.io.File.separator + com; String osname = System.getProperty("os.name"); //$NON-NLS-1$ if (osname.indexOf("Windows") >= 0) { //$NON-NLS-1$ com = "\"" + com + "\""; //$NON-NLS-1$ //$NON-NLS-2$ } ProcessInfo pi = new ProcessInfo(); pi.id = controllerName; pi.dir = dir; pi.com.add(com); pi.waitCount = 2000; pi.isCorbaServer = true; pi.hasShutdown = true; pi.doKillall = false; pi.autoStart = false; pi.autoStop = true; if (proc != null) pManager.unregister(proc.pi_.id); pManager.register(pi); proc = pManager.get(controllerName); } if (proc != null) { GrxDebugUtil.println("Executing controller process ..."); //$NON-NLS-1$ GrxDebugUtil.println("dir: " + dir); //$NON-NLS-1$ GrxDebugUtil.println("command: " + com); //$NON-NLS-1$ proc.start(optionAdd); } } Date before = new Date(); for (int j = 0;; j++) { cobj = GrxCorbaUtil.getReference(controllerName); if (cobj != null) { try { Controller controller = ControllerHelper.narrow(cobj); controller.setModelName(model.getName()); controller.setDynamicsSimulator(currentDynamics_); if (isTrue("viewsimulate")) {//simParamPane_.isSimulatingView()) { cobj = GrxCorbaUtil.getReference("ViewSimulator"); //$NON-NLS-1$ ViewSimulator viewsim = ViewSimulatorHelper.narrow(cobj); controller.setViewSimulator(viewsim); } ControllerAttribute refAttr = _getControllerFromControllerName(controllerName); if (refAttr == null) { controllers_ .add(new ControllerAttribute(model.getName(), controllerName, controller, step)); } else { refAttr.reset(controller, step); } GrxDebugUtil.println(" connected to the Controller(" + controllerName + ")\n"); //$NON-NLS-1$ //$NON-NLS-2$ controller.setTimeStep(step); controller.initialize(); controller.start(); break; } catch (ControllerException e) { System.out.println("setupController:" + e.description); MessageDialog.openInformation(GrxUIPerspectiveFactory.getCurrentShell(), e.description, MessageBundle.get("GrxOpenHRPView.dialog.message.failedController")); if (proc != null) proc.stop(); return false; } catch (Exception e) { GrxDebugUtil.printErr("setupController:", e); //$NON-NLS-1$ } } if (j > WAIT_COUNT_ || (new Date().getTime() - before.getTime() > WAIT_COUNT_ * 1000)) { GrxDebugUtil.println(" failed to setup controller:" + controllerName); //$NON-NLS-1$ //??????????EE??E??????null???? MessageDialog dialog = new MessageDialog(GrxUIPerspectiveFactory.getCurrentShell(), MessageBundle.get("GrxOpenHRPView.dialog.title.setupController"), null, //$NON-NLS-1$ MessageBundle.get("GrxOpenHRPView.dialog.message.setupController0") + controllerName //$NON-NLS-1$ + ").\n" + MessageBundle.get("GrxOpenHRPView.dialog.message.setupController1"), //$NON-NLS-1$//$NON-NLS-2$ MessageDialog.QUESTION, new String[] { MessageBundle.get("GrxOpenHRPView.dialog.button.yes"), //$NON-NLS-1$ MessageBundle.get("GrxOpenHRPView.dialog.button.no"), //$NON-NLS-1$ MessageBundle.get("GrxOpenHRPView.dialog.button.cancel") }, //$NON-NLS-1$ 2); int ans = dialog.open(); if (ans == 0) { before = new Date(); j = 0; } else if (ans == 1) { MessageDialog.openInformation(GrxUIPerspectiveFactory.getCurrentShell(), "", MessageBundle.get("GrxOpenHRPView.dialog.message.failedController")); return false; } else { MessageDialog.openInformation(GrxUIPerspectiveFactory.getCurrentShell(), "", MessageBundle.get("GrxOpenHRPView.dialog.message.failedController")); return false; } } else { try { Thread.sleep(1000); } catch (Exception e) { } } } return true; }
From source file:com.genuitec.eclipse.gerrit.tools.internal.fbranches.BranchingUtils.java
License:Open Source License
public static boolean deleteBranches(Shell shell, final Repository repository, final List<Ref> toDelete) { final List<Ref> unmerged = new ArrayList<Ref>(); try {/*from w w w.j av a 2s.c om*/ new ProgressMonitorDialog(shell).run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { unmerged.addAll(deleteBranches(repository, toDelete, false, monitor)); } }); } catch (InvocationTargetException e1) { RepositoryUtils.handleException(e1); return false; } catch (InterruptedException e1) { // ignore return false; } if (!unmerged.isEmpty()) { MessageDialog messageDialog = new UnmergedBranchDialog<Ref>(shell, unmerged); if (messageDialog.open() != Window.OK) return false; try { new ProgressMonitorDialog(shell).run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { deleteBranches(repository, toDelete, true, monitor); } }); } catch (InvocationTargetException e1) { RepositoryUtils.handleException(e1); return false; } catch (InterruptedException e1) { // ignore return false; } } return true; }
From source file:com.genuitec.org.eclipse.egit.ui.internal.branch.BranchOperationUI.java
License:Open Source License
private String getTargetWithCheckoutRemoteTrackingDialog() { String[] buttons = new String[] { UIText.BranchOperationUI_CheckoutRemoteTrackingAsLocal, UIText.BranchOperationUI_CheckoutRemoteTrackingCommit, IDialogConstants.CANCEL_LABEL }; MessageDialog questionDialog = new MessageDialog(getShell(), UIText.BranchOperationUI_CheckoutRemoteTrackingTitle, null, UIText.BranchOperationUI_CheckoutRemoteTrackingQuestion, MessageDialog.QUESTION, buttons, 0); int result = questionDialog.open(); if (result == 0) { // Check out as new local branch CreateBranchWizard wizard = new CreateBranchWizard(repository, target); WizardDialog createBranchDialog = new WizardDialog(getShell(), wizard); createBranchDialog.open();//from w w w . j a v a 2 s . co m return null; } else if (result == 1) { // Check out commit return target; } else { // Cancel return null; } }
From source file:com.google.appengine.eclipse.core.preferences.ui.GaePreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { noDefaultAndApplyButton();//from w w w . j a v a 2s .co m sdkSet = GaePreferences.getSdks(); return new SdkTable<GaeSdk>(parent, SWT.NONE, sdkSet, null, this) { @Override protected IStatus doAddSdk() { AddSdkDialog<GaeSdk> addGaeSdkDialog = new AddSdkDialog<GaeSdk>(getShell(), sdkSet, AppEngineCorePlugin.PLUGIN_ID, "Add App Engine SDK", GaeSdk.getFactory()); if (addGaeSdkDialog.open() == Window.OK) { GaeSdk newSdk = addGaeSdkDialog.getSdk(); if (newSdk != null) { sdkSet.add(newSdk); } return Status.OK_STATUS; } return Status.CANCEL_STATUS; } @Override protected IStatus doDownloadSdk() { MessageDialog dialog = new MessageDialog(AppEngineCorePlugin.getActiveWorkbenchShell(), "Google Eclipse Plugin", null, "Would you like to open the Google App Engine download page in your " + "web browser?\n\nFrom there, you can " + "download the latest App Engine SDK and extract it to the" + " location of your choice. Add it to Eclipse" + " with the \"Add...\" button.", MessageDialog.QUESTION, new String[] { "Open Browser", IDialogConstants.CANCEL_LABEL }, 0); if (dialog.open() == Window.OK) { if (BrowserUtilities .launchBrowserAndHandleExceptions(AppEngineCorePlugin.SDK_DOWNLOAD_URL) == null) { return Status.CANCEL_STATUS; } } else { return Status.CANCEL_STATUS; } return Status.OK_STATUS; } }; }
From source file:com.google.appraise.eclipse.ui.editor.AppraiseReviewTaskActivationListener.java
License:Open Source License
/** * Asks the user if they want to switch to the review branch, and performs * the switch if so.// w w w. ja v a 2s. c o m */ private void promptSwitchToReviewBranch(TaskRepository taskRepository, String reviewBranch) { MessageDialog dialog = new MessageDialog(null, "Appraise Review", null, "Do you want to switch to the review branch (" + reviewBranch + ")", MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0); int result = dialog.open(); if (result == 0) { Repository repo = AppraisePluginUtils.getGitRepoForRepository(taskRepository); try (Git git = new Git(repo)) { previousBranch = repo.getFullBranch(); git.checkout().setName(reviewBranch).call(); } catch (RefNotFoundException rnfe) { MessageDialog alert = new MessageDialog(null, "Oops", null, "Branch " + reviewBranch + " not found", MessageDialog.INFORMATION, new String[] { "OK" }, 0); alert.open(); } catch (Exception e) { AppraiseUiPlugin.logError("Unable to switch to review branch: " + reviewBranch, e); } } }
From source file:com.google.appraise.eclipse.ui.editor.CommitAttributeEditor.java
License:Open Source License
@Override public void createControl(final Composite parent, FormToolkit toolkit) { link = new Link(parent, SWT.BORDER); link.setText("<a>" + getValue() + "</a>"); link.addListener(SWT.Selection, new Listener() { @Override//w w w. ja va 2s .co m public void handleEvent(Event event) { try { RepositoryCommit commit = getCommit(); if (commit != null) { CommitEditor.openQuiet(commit); } else { MessageDialog alert = new MessageDialog(parent.getShell(), "Oops", null, "Commit " + getValue() + " not found", MessageDialog.ERROR, new String[] { "OK" }, 0); alert.open(); } } catch (IOException e) { AppraiseUiPlugin.logError("Error reading commit " + getValue(), e); } } }); setControl(link); }
From source file:com.google.dart.tools.ui.internal.dialogs.OptionalMessageDialog.java
License:Open Source License
/** * Opens the dialog but only if the user hasn't choosen to hide it. Returns <code>NOT_SHOWN</code> * if the dialog was not shown.//from w w w . j av a 2 s . co m */ public static int open(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) { if (!isDialogEnabled(id)) { return OptionalMessageDialog.NOT_SHOWN; } MessageDialog dialog = new OptionalMessageDialog(id, parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex); return dialog.open(); }