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:org.eclipse.rcptt.ui.resources.wizards.WizardFileSystemResourceImportPage1.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 av a2 s. c o 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( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS.bind( org.eclipse.ui.internal.ide.IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), org.eclipse.ui.internal.ide.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:org.eclipse.rcptt.ui.wizards.imports.BaseProjectsImportPage.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. * // w ww . j a v a 2s . c o 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(Messages.BaseProjectsImportPage_29, pathString); } else { messageString = NLS.bind(Messages.BaseProjectsImportPage_30, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), Messages.BaseProjectsImportPage_31, 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:org.eclipse.recommenders.snipmatch.rcp.SnippetEditor.java
License:Open Source License
@Override public void doSave(IProgressMonitor monitor) { SnippetEditorInput input = (SnippetEditorInput) getEditorInput(); Snippet snippet = input.getSnippet(); if (isNullOrEmpty(snippet.getName())) { MessageDialog.openError(getSite().getShell(), Messages.DIALOG_TITLE_INAVLID_SNIPPET_NAME, Messages.DIALOG_MESSAGE_INVALID_SNIPPET_NAME); monitor.setCanceled(true);//from w ww. j a v a2s . c om return; } if (snippet.getLocation() == null || snippet.getLocation() == NONE) { MessageDialog.openError(getSite().getShell(), Messages.DIALOG_TITLE_INVALID_SNIPPET_LOCATION, Messages.DIALOG_MESSAGE_INVALID_SNIPPET_LOCATION); monitor.setCanceled(true); return; } final String sourceValid; if (snippet.getLocation() == FILE) { sourceValid = TextSnippetSourceValidator.isSourceValid(snippet.getCode()); } else { sourceValid = JavaSnippetSourceValidator.isSourceValid(snippet.getCode()); } if (!sourceValid.isEmpty()) { MessageDialog.openError(getSite().getShell(), Messages.DIALOG_TITLE_ERROR_SNIPPET_SOURCE_INVALID, MessageFormat.format(Messages.DIALOG_MESSAGE_ERROR_SNIPPET_SOURCE_INVALID, sourceValid)); monitor.setCanceled(true); return; } ISnippetRepository repo = input.getRepository(); if (repo == null) { repo = SelectRepositoryDialog.openSelectRepositoryDialog(getSite().getShell(), repos, configs).orNull(); if (repo == null) { return; } input.setRepository(repo); } ISnippet oldSnippet = input.getOldSnippet(); if (!oldSnippet.getCode().isEmpty() && !snippet.getCode().equals(oldSnippet.getCode())) { int status = new MessageDialog(getSite().getShell(), Messages.DIALOG_TITLE_SAVE_SNIPPET, null, Messages.DIALOG_MESSAGE_SAVE_SNIPPET_WITH_MODIFIED_CODE, MessageDialog.QUESTION, new String[] { Messages.DIALOG_OPTION_SAVE, Messages.DIALOG_OPTION_SAVE_AS_NEW, Messages.DIALOG_OPTION_CANCEL }, 0).open(); if (status == 1) { // Store as new snippet.setUuid(randomUUID()); setInputWithNotify(new SnippetEditorInput(snippet, input.getRepository())); } if (status == 2) { // Explicit Cancel monitor.setCanceled(true); return; } if (status == SWT.DEFAULT) { // Dialog closed => implicit Cancel monitor.setCanceled(true); return; } } try { commitPages(true); input.setOldSnippet(Snippet.copy(snippet)); repo.importSnippet(snippet); setPartName(getEditorInput().getName()); editorDirtyStateChanged(); } catch (IOException e) { Logs.log(LogMessages.ERROR_FAILED_TO_STORE_SNIPPET, e); } }
From source file:org.eclipse.remote.internal.ui.preferences.ConnectionsPreferencePage.java
License:Open Source License
/** * Add a new connection/*from w w w. j a v a2s . c o m*/ */ private void addConnection() { if (fIsDirty) { MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions, null, Messages.ConnectionsPreferencePage_There_are_unsaved_changes, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (dialog.open() == 1) { return; } performOk(); } if (fUIConnectionManager != null) { IRemoteUIConnectionWizard wizard = fUIConnectionManager.getConnectionWizard(getShell()); if (wizard != null) { wizard.setConnectionName(initialConnectionName()); wizard.setInvalidConnectionNames(invalidConnectionNames()); IRemoteConnectionWorkingCopy conn = wizard.open(); if (conn != null) { fWorkingCopies.put(conn.getName(), conn); if (!fConnectionViewer.getTable().isDisposed()) { fConnectionViewer.refresh(); } fIsDirty = true; } } } }
From source file:org.eclipse.remote.internal.ui.preferences.ConnectionsPreferencePage.java
License:Open Source License
/** * Toggle the connection/*from w w w. java 2 s . c o m*/ */ private void toggleConnection() { TableItem[] items = fConnectionTable.getSelection(); if (items.length > 0) { IRemoteConnection conn = getOriginalIfClean((IRemoteConnection) items[0].getData()); if (conn.hasService(IRemoteConnectionControlService.class) && conn.isOpen()) { conn.close(); } else { if (conn instanceof IRemoteConnectionWorkingCopy) { IRemoteConnectionWorkingCopy wc = (IRemoteConnectionWorkingCopy) conn; if (wc.isDirty()) { MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions, null, Messages.ConnectionsPreferencePage_This_connection_contains_unsaved_changes, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (dialog.open() == 1) { return; } try { conn = wc.save(); } catch (RemoteConnectionException e) { RemoteUIPlugin.log(e); } /* * Replace working copy with original so that the correct version will be used in the future */ fWorkingCopies.put(conn.getName(), conn); } } IRemoteUIConnectionService mgr = conn.getConnectionType() .getService(IRemoteUIConnectionService.class); if (mgr != null) { mgr.openConnectionWithProgress(getShell(), null, conn); } } fConnectionViewer.refresh(); updateEnablement(); } }
From source file:org.eclipse.riena.internal.ui.ridgets.swt.MessageBoxRidget.java
License:Open Source License
private int getType(final Type type) { switch (type) { case PLAIN:// ww w . j a v a 2s. c o m return MessageDialog.NONE; case INFORMATION: return MessageDialog.INFORMATION; case WARNING: return MessageDialog.WARNING; case ERROR: return MessageDialog.ERROR; case HELP: return MessageDialog.INFORMATION; case QUESTION: return MessageDialog.QUESTION; default: return MessageDialog.NONE; } }
From source file:org.eclipse.riena.internal.ui.ridgets.swt.MessageBoxRidgetTest.java
License:Open Source License
public void testSetType() throws Exception { // show message box to transfer values set getRidget().show();// w w w . j a v a 2s . c o m assertEquals(MessageDialog.NONE, getWidget().type); assertEquals(IMessageBoxRidget.Type.PLAIN, getRidget().getType()); getRidget().setType(IMessageBoxRidget.Type.ERROR); // show message box to transfer values set getRidget().show(); assertEquals(MessageDialog.ERROR, getWidget().type); assertEquals(IMessageBoxRidget.Type.ERROR, getRidget().getType()); getRidget().setType(IMessageBoxRidget.Type.WARNING); // show message box to transfer values set getRidget().show(); assertEquals(MessageDialog.WARNING, getWidget().type); assertEquals(IMessageBoxRidget.Type.WARNING, getRidget().getType()); getRidget().setType(IMessageBoxRidget.Type.INFORMATION); // show message box to transfer values set getRidget().show(); assertEquals(MessageDialog.INFORMATION, getWidget().type); assertEquals(IMessageBoxRidget.Type.INFORMATION, getRidget().getType()); getRidget().setType(IMessageBoxRidget.Type.HELP); // show message box to transfer values set getRidget().show(); assertEquals(MessageDialog.INFORMATION, getWidget().type); assertEquals(IMessageBoxRidget.Type.HELP, getRidget().getType()); getRidget().setType(IMessageBoxRidget.Type.QUESTION); // show message box to transfer values set getRidget().show(); assertEquals(MessageDialog.QUESTION, getWidget().type); assertEquals(IMessageBoxRidget.Type.QUESTION, getRidget().getType()); getRidget().setType(null); // show message box to transfer values set getRidget().show(); assertEquals(MessageDialog.NONE, getWidget().type); assertEquals(IMessageBoxRidget.Type.PLAIN, getRidget().getType()); }
From source file:org.eclipse.riena.internal.ui.ridgets.swt.MessageBoxRidgetTest.java
License:Open Source License
public void testUsedInSharedView() throws Exception { getRidget().setText("TestMessageText1"); getRidget().setTitle("TestMessageTitle1"); getRidget().setType(IMessageBoxRidget.Type.QUESTION); getRidget().setOptions(IMessageBoxRidget.OPTIONS_OK_CANCEL); // show message box to transfer values set getRidget().show();//w ww .ja v a 2 s. c o m final IMessageBoxRidget ridget2 = new MessageBoxRidget(); ridget2.setText("TestMessageText2"); ridget2.setTitle("TestMessageTitle2"); ridget2.setType(IMessageBoxRidget.Type.WARNING); ridget2.setOptions(new IMessageBoxRidget.MessageBoxOption[] { new IMessageBoxRidget.MessageBoxOption("TestCustomOption") }); getRidget().setUIControl(null); ridget2.setUIControl(getWidget()); // show message box to transfer values set ridget2.show(); assertEquals("TestMessageText2", getWidget().text); assertEquals("TestMessageTitle2", getWidget().title); assertEquals(MessageDialog.WARNING, getWidget().type); assertEquals(1, getWidget().buttonLabels.length); assertEquals("TestCustomOption", getWidget().buttonLabels[0]); getRidget().setUIControl(getWidget()); // show message box to transfer values set getRidget().show(); ridget2.setUIControl(null); assertEquals("TestMessageText1", getWidget().text); assertEquals("TestMessageTitle1", getWidget().title); assertEquals(MessageDialog.QUESTION, getWidget().type); assertEquals(2, getWidget().buttonLabels.length); assertEquals(IDialogConstants.OK_LABEL, getWidget().buttonLabels[0]); assertEquals(IDialogConstants.CANCEL_LABEL, getWidget().buttonLabels[1]); }
From source file:org.eclipse.servicesregistry.ui.internal.prefpage.SrPreferencePage.java
License:Open Source License
protected int showUserCredentialsExistDialog() { return new MessageDialog(getShell(), SrUiMessages.SrPreferencePage_IdenticalCredentialsDialogTitle, null, SrUiMessages.SrPreferencePage_IdenticalCredentialsDialogMessage, MessageDialog.QUESTION, new String[] { SrUiMessages.SrPreferencePage_ReuseButton, SrUiMessages.SrPreferencePage_OverrideButton }, SWT.ICON_QUESTION).open();/* w ww . ja v a 2s .co m*/ }
From source file:org.eclipse.servicesregistry.ui.internal.prefpage.SrPreferencePage.java
License:Open Source License
protected int showConfirmDialog(final IServicesRegistrySystem config) { String description;//from www . j a v a2 s . co m if (config.areCredentialsStored()) description = SrUiMessages.SrPreferencesController_DeleteConfigWithAuthDetails; else description = SrUiMessages.SrPreferencesController_DeleteConfigWithoutAuthDetails; return new MessageDialog(getShell(), SrUiMessages.SrPreferencesController_DeleteConfigConfirmTitle, null, description, MessageDialog.QUESTION, new String[] { SrUiMessages.SrPreferencesController_YesButton, SrUiMessages.SrPreferencesController_NoButton }, SWT.ICON_QUESTION).open(); }