List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:gov.redhawk.ide.idl.ui.wizard.ScaIDLProjectPropertiesWizardPage.java
License:Open Source License
/** * Scan the first idl file in the list for a module name and if it's different than the current * module name, ask the user if they want to update it. *//*from w w w. jav a2s . c om*/ private void updateModuleName() { final File file = new File(this.idlFiles.get(0)); Scanner input = null; try { input = new Scanner(file); } catch (final FileNotFoundException e) { // PASS } while (input != null && input.hasNext()) { final String line = input.nextLine(); if (line.contains("module")) { final String[] splitNames = line.split("[ ]+"); for (final String token : splitNames) { if (!"module".equals(token) && token.matches("[A-Z]+") && !this.moduleNameText.getText().equalsIgnoreCase(token)) { final MessageDialog dialog = new MessageDialog(getShell(), "Update Module Name", null, "Module " + token + " was found in the imported IDL file(s). Update?", MessageDialog.QUESTION, new String[] { "No", "Yes" }, 1); final int selection = dialog.open(); if (selection == 1) { this.moduleNameText.setText(token.toLowerCase()); } } } break; } } }
From source file:gov.redhawk.ide.pydev.PyDevConfigureStartup.java
License:Open Source License
@Override public void earlyStartup() { final String app = System.getProperty("eclipse.application"); final boolean runConfig = app == null || "org.eclipse.ui.ide.workbench".equals(app); if (!runConfig) { return;/*from ww w. ja v a2 s . c o m*/ } // If PyDev isn't configured at all, then prompt the user if (PydevPlugin.getPythonInterpreterManager().isConfigured()) { try { boolean configuredCorrectly = AutoConfigPydevInterpreterUtil .isPydevConfigured(new NullProgressMonitor(), null); if (!configuredCorrectly) { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { final String[] buttons = { "Ok", "Cancel" }; final MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Configure PyDev", null, "PyDev appears to be mis-configured for REDHAWK, would you like it to be re-configured?", MessageDialog.QUESTION, buttons, 0); dialog.open(); PyDevConfigureStartup.this.result = dialog.getReturnCode(); if (PyDevConfigureStartup.this.result < 1) { new ConfigurePythonJob(false).schedule(); } } }); } } catch (CoreException e) { RedhawkIdePyDevPlugin.getDefault().getLog().log(new Status(e.getStatus().getSeverity(), RedhawkIdePyDevPlugin.PLUGIN_ID, "Failed to auto configure.", e)); } } else { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { new ConfigurePythonJob(false).schedule(); } }); } }
From source file:gov.redhawk.ide.snapshot.internal.ui.SnapshotHandler.java
License:Open Source License
/** * the command has been executed, so extract extract the needed information * from the application context./* w w w . jav a 2 s. c o m*/ */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveShell(event); ISelection selection = HandlerUtil.getActiveMenuSelection(event); if (selection == null) { selection = HandlerUtil.getCurrentSelection(event); } if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; Object obj = ss.getFirstElement(); ScaUsesPort port = PluginUtil.adapt(ScaUsesPort.class, obj); if (port != null) { if (port.eContainer() instanceof ResourceOperations) { final ResourceOperations lf = (ResourceOperations) port.eContainer(); if (!lf.started()) { MessageDialog dialog = new MessageDialog(HandlerUtil.getActiveShell(event), "Start Resource", null, "The ports container is not started. Would you like to start it now?", MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0); if (dialog.open() == Window.OK) { Job job = new Job("Starting...") { @Override protected IStatus run(IProgressMonitor monitor) { try { lf.start(); } catch (StartError e) { return new Status(Status.ERROR, SnapshotActivator.PLUGIN_ID, "Failed to start resource", e); } return Status.OK_STATUS; } }; job.schedule(); } } } BulkIOSnapshotWizard wizard = new BulkIOSnapshotWizard(); WizardDialog dialog = new WizardDialog(shell, wizard); if (dialog.open() == Window.OK) { CorbaDataReceiver receiver = wizard.getCorbaReceiver(); receiver.setPort(port); receiver.getDataWriter().getSettings().setType(BulkIOType.getType(port.getRepid())); final ScaItemProviderAdapterFactory factory = new ScaItemProviderAdapterFactory(); final StringBuilder tooltip = new StringBuilder(); List<String> tmpList = new LinkedList<String>(); for (EObject eObj = port; !(eObj instanceof ScaDomainManagerRegistry) && eObj != null; eObj = eObj.eContainer()) { Adapter adapter = factory.adapt(eObj, IItemLabelProvider.class); if (adapter instanceof IItemLabelProvider) { IItemLabelProvider lp = (IItemLabelProvider) adapter; tmpList.add(0, lp.getText(eObj)); } } for (Iterator<String> i = tmpList.iterator(); i.hasNext();) { tooltip.append(i.next()); if (i.hasNext()) { tooltip.append(" -> "); } } factory.dispose(); SnapshotJob job = new SnapshotJob("Snapshot of " + tooltip, receiver); job.schedule(); } } } return null; }
From source file:gov.redhawk.ide.spd.internal.ui.editor.wizard.OpenAssociatedPerspectiveJob.java
License:Open Source License
/** * Creates the dialog for changing perspectives. * /* w ww . j a v a 2 s.c o m*/ * @return the {@link MessageDialogWithToggle} to display */ private MessageDialogWithToggle createDialog() { final String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; return new MessageDialogWithToggle(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Open Associated Perspective?", null, "Do you want to open the perspective associated with the " + this.descriptor.getName() + "?", MessageDialog.QUESTION, buttons, 0, "Remember my decision", false); }
From source file:gov.redhawk.ide.ui.wizard.RedhawkImportWizardPage1.java
License:Open Source License
/** * The <code>WizardDataTransfer</code> implementation of this * <code>IOverwriteQuery</code> method asks the user whether the existing * resource at the given path should be overwritten. * /*from w w w . j a v a 2s. co m*/ * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, * <code>"ALL"</code>, or <code>"CANCEL"</code> */ public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); return (dialog.getReturnCode() < 0) ? CANCEL : response[dialog.getReturnCode()]; }
From source file:gov.redhawk.sca.internal.ui.handlers.RemoveDomainHandler.java
License:Open Source License
/** * {@inheritDoc}/*from w w w . j a va 2 s.c o m*/ */ @Override public Object execute(final ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getActiveMenuSelection(event); if (selection == null) { selection = HandlerUtil.getCurrentSelection(event); } if (selection instanceof IStructuredSelection) { final IStructuredSelection ss = (IStructuredSelection) selection; final MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Delete Domain Connection", null, "Are you sure you want to remove the selected domains?", MessageDialog.QUESTION, new String[] { "OK", "Cancel" }, 0); if (dialog.open() == Window.OK) { for (final Object obj : ss.toArray()) { if (obj instanceof ScaDomainManager) { final ScaDomainManager domMgr = (ScaDomainManager) obj; domMgr.disconnect(); ScaModelCommand.execute(domMgr, new ScaModelCommand() { @Override public void execute() { ScaPlugin.getDefault().getDomainManagerRegistry(Display.getCurrent()).getDomains() .remove(domMgr); } }); } } } } return null; }
From source file:Gui.MainWindow_ver2.java
License:Open Source License
public MainWindow_ver2(org.eclipse.swt.widgets.Composite parent, int style) { super(parent, style); GameGui.getG().mainWindow = this; initGUI();/* w ww. j a v a 2 s.com*/ // addMouseListenersToCells(); addDragListenersToLetters(); addDropListenersToCells(); initTextStatus(); initAllCellsColors(); initWindow(); GameGui.initUsedLetters(); shell.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent evt) { // System.out.println("shell.shellClosed, event="+evt); if (isSaved == false) { saveBeforExitMessage(); } String title = ("Are you sure you want to exit?"); String message = ("Game Exit"); String[] options = new String[2]; options[0] = "YES"; options[1] = "NO"; MessageDialog m = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, options, 1); // SWT.ICON_QUESTION | SWT.YES | SWT.NO); if (m.open() == 0) { GameGui.updateRecordList(); GameGui.saveRecordList('b'); GameGui.saveRecordList('a'); display.dispose(); try { client.closeSocket(); gameThread.stop(); } catch (Exception e) { } } else { evt.doit = false; } } }); }
From source file:Gui.MainWindow_ver2.java
License:Open Source License
public boolean showMessageDialog(String string, String string2) { String message = (string);/*w w w .j a va2 s . c o m*/ String title = (string2); String[] options = new String[2]; options[0] = "YES"; options[1] = "NO"; MessageDialog messageBox = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, options, 2); int response = messageBox.open(); if (response == 0) { return true; } else { return false; } }
From source file:msi.gama.application.Application.java
public static Object checkWorkspace() throws IOException, MalformedURLException { final Location instanceLoc = Platform.getInstanceLocation(); if (instanceLoc == null) { // -data @none was specified but GAMA requires a workspace MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", "A workspace is required to run GAMA"); return EXIT_OK; }/*from w ww . ja v a 2s. com*/ boolean remember = false; String lastUsedWs = null; if (instanceLoc.isSet()) { lastUsedWs = instanceLoc.getURL().getFile(); final String ret = WorkspacePreferences.checkWorkspaceDirectory(lastUsedWs, false, false, false); if (ret != null) { // if ( ret.equals("Restart") ) { return EXIT_RESTART; } /* If we dont or cant remember and the location is set, we cant do anything as we need a workspace */ MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", "The workspace provided cannot be used. Please change it"); if (PlatformUI.isWorkbenchRunning()) { PlatformUI.getWorkbench().close(); } System.exit(0); return EXIT_OK; } } else { /* Get what the user last said about remembering the workspace location */ remember = PickWorkspaceDialog.isRememberWorkspace(); /* Get the last used workspace location */ lastUsedWs = PickWorkspaceDialog.getLastSetWorkspaceDirectory(); /* If we have a "remember" but no last used workspace, it's not much to remember */ if (remember && (lastUsedWs == null || lastUsedWs.length() == 0)) { remember = false; } if (remember) { /* * If there's any problem with the workspace, force a dialog */ final String ret = WorkspacePreferences.checkWorkspaceDirectory(lastUsedWs, false, false, false); if (ret != null) { // if ( ret.equals("Restart") ) { return EXIT_RESTART; } if (ret.equals("models")) { final MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), "Different version of the models library", Display.getCurrent().getSystemImage(SWT.ICON_QUESTION), "The workspace contains a different version of the models library. Do you want to use another workspace ?", MessageDialog.QUESTION, 1, "Use another workspace", "No, thanks"); remember = dialog.open() == 1; } else { remember = false; } } } } /* If we don't remember the workspace, show the dialog */ if (!remember) { final int pick = new PickWorkspaceDialog().open(); /* If the user cancelled, we can't do anything as we need a workspace */ if (pick == 1 /* Window.CANCEL */ && WorkspacePreferences.getSelectedWorkspaceRootLocation() == null) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", "The application can not start without a workspace and will now exit."); System.exit(0); return IApplication.EXIT_OK; } /* Tell Eclipse what the selected location was and continue */ instanceLoc.set(new URL("file", null, WorkspacePreferences.getSelectedWorkspaceRootLocation()), false); if (WorkspacePreferences.applyPrefs()) { WorkspacePreferences .applyEclipsePreferences(WorkspacePreferences.getSelectedWorkspaceRootLocation()); } } else { if (!instanceLoc.isSet()) { /* Set the last used location and continue */ instanceLoc.set(new URL("file", null, lastUsedWs), false); } } return null; }
From source file:msi.gama.gui.swt.commands.ResetSimulationPerspective.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event); if (activeWorkbenchWindow != null) { WorkbenchPage page = (WorkbenchPage) activeWorkbenchWindow.getActivePage(); if (page != null) { IPerspectiveDescriptor descriptor = page.getPerspective(); if (descriptor != null) { String message = "Resetting the simulation perspective will close the current simulation. Do you want to proceed ?"; boolean result = MessageDialog.open(MessageDialog.QUESTION, activeWorkbenchWindow.getShell(), WorkbenchMessages.ResetPerspective_title, message, SWT.SHEET); if (result) { GAMA.controller.closeExperiment(); page.resetPerspective(); }// www .j a v a 2 s. c o m } } } return null; }