List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_LABEL
String NO_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.
Click Source Link
From source file:org.jboss.tools.windup.ui.internal.wizards.WindupReportExportWizardPage1.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 a 2 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(Messages.WindupReportExport_question_fileExists, pathString); } else { messageString = NLS.bind(Messages.WindupReportExport_question_overwriteNameAndPath, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), Messages.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.jboss.tools.windup.ui.internal.wizards.WindupReportExportWizardPage1.java
License:Open Source License
/** * Displays a Yes/No question to the user with the specified message and returns the user's response. * //w w w . j a v a 2s .c om * @param message the question to ask * @return <code>true</code> for Yes, and <code>false</code> for No */ private boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getContainer().getShell(), Messages.Question, (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; // ensure yes is the default return dialog.open() == 0; }
From source file:org.jkiss.dbeaver.ext.exasol.manager.ExasolConnectionManager.java
License:Apache License
@Override protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command, Map<String, Object> options) { ExasolConnection con = command.getObject(); Map<Object, Object> com = command.getProperties(); if (com.containsKey("description")) { actionList.add(Comment(con)); }//from ww w . j ava 2s.c o m // url, username or password have changed if (com.containsKey("url") | com.containsKey("userName") | com.containsKey("password")) { // possible loss of information - warn if ((com.containsKey("url") | com.containsKey("userName")) & !con.getUserName().isEmpty() & con.getPassword().isEmpty()) { int result = new UITask<Integer>() { protected Integer runTask() { ConfirmationDialog dialog = new ConfirmationDialog(UIUtils.getActiveWorkbenchShell(), ExasolMessages.dialog_connection_alter_title, null, ExasolMessages.dialog_connection_alter_message, MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, ExasolMessages.dialog_general_continue, false); return dialog.open(); } }.execute(); if (result != IDialogConstants.YES_ID) { throw new IllegalStateException("User abort"); } } StringBuilder script = new StringBuilder( String.format("ALTER CONNECTION %s ", DBUtils.getQuotedIdentifier(con))); script.append(" '" + ExasolUtils.quoteString(con.getConnectionString()) + "' "); if (!(con.getUserName().isEmpty() | con.getPassword().isEmpty())) { script.append(String.format(" USER '%s' IDENTIFIED BY '%s'", ExasolUtils.quoteString(con.getUserName()), ExasolUtils.quoteString(con.getPassword()))); } actionList.add(new SQLDatabasePersistAction("alter Connection", script.toString())); } }
From source file:org.jkiss.dbeaver.ext.exasol.manager.ExasolSchemaManager.java
License:Apache License
@Override protected void addObjectDeleteActions(List<DBEPersistAction> actions, ObjectDeleteCommand command, Map<String, Object> options) { int result = new UITask<Integer>() { protected Integer runTask() { ConfirmationDialog dialog = new ConfirmationDialog(UIUtils.getActiveWorkbenchShell(), ExasolMessages.dialog_schema_drop_title, null, ExasolMessages.dialog_schema_drop_message, MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, ExasolMessages.dialog_general_continue, false); return dialog.open(); }//from w w w . j a v a2 s.c o m }.execute(); if (result != IDialogConstants.YES_ID) { throw new IllegalStateException("User abort"); } actions.add(new SQLDatabasePersistAction("Drop schema", "DROP SCHEMA " + DBUtils.getQuotedIdentifier(command.getObject()) + " CASCADE") //$NON-NLS-1$ ); }
From source file:org.jkiss.dbeaver.ui.actions.navigator.NavigatorHandlerObjectDelete.java
License:Open Source License
private ConfirmResult confirmObjectDelete(final IWorkbenchWindow workbenchWindow, final DBNNode node, final boolean viewScript) { if (deleteAll != null) { return deleteAll ? ConfirmResult.YES : ConfirmResult.NO; }/*from www . j ava2 s . c om*/ ResourceBundle bundle = DBeaverActivator.getCoreResourceBundle(); String objectType = node instanceof DBNLocalFolder ? DBeaverPreferences.CONFIRM_LOCAL_FOLDER_DELETE : DBeaverPreferences.CONFIRM_ENTITY_DELETE; String titleKey = ConfirmationDialog.RES_CONFIRM_PREFIX + objectType + "_" //$NON-NLS-1$ + ConfirmationDialog.RES_KEY_TITLE; String messageKey = ConfirmationDialog.RES_CONFIRM_PREFIX + objectType + "_" //$NON-NLS-1$ + ConfirmationDialog.RES_KEY_MESSAGE; String nodeTypeName = node.getNodeType(); MessageDialog dialog = new MessageDialog(workbenchWindow.getShell(), UIUtils.formatMessage(bundle.getString(titleKey), nodeTypeName, node.getNodeName()), DBeaverIcons.getImage(UIIcon.REJECT), UIUtils.formatMessage(bundle.getString(messageKey), nodeTypeName.toLowerCase(), node.getNodeName()), MessageDialog.CONFIRM, null, 0) { @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); if (structSelection.size() > 1) { createButton(parent, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.YES_TO_ALL_LABEL, false); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } if (viewScript) { createButton(parent, IDialogConstants.DETAILS_ID, CoreMessages.actions_navigator_view_script_button, false); } } }; int result = dialog.open(); switch (result) { case IDialogConstants.YES_ID: return ConfirmResult.YES; case IDialogConstants.YES_TO_ALL_ID: deleteAll = true; return ConfirmResult.YES; case IDialogConstants.NO_ID: return ConfirmResult.NO; case IDialogConstants.CANCEL_ID: case -1: deleteAll = false; return ConfirmResult.NO; case IDialogConstants.DETAILS_ID: return ConfirmResult.DETAILS; default: log.warn("Unsupported confirmation dialog result: " + result); //$NON-NLS-1$ return ConfirmResult.NO; } }
From source file:org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog.java
License:Open Source License
static String[] getButtonLabels(int kind) { switch (kind) { case ERROR:/* ww w .j a v a 2 s.co m*/ case INFORMATION: case WARNING: return new String[] { IDialogConstants.OK_LABEL }; case CONFIRM: return new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; case QUESTION: return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; case QUESTION_WITH_CANCEL: { return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; } default: throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$ } }
From source file:org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.java
License:Open Source License
@Override public boolean performFinish() { // FIXME: move into separate class final TuhhCalculation calculation = m_importPage.getCalculation(); final TuhhReach reach = calculation.getReach(); final TuhhReachProfileSegment[] segments = m_importPage.getReachProfileSegments(); final IRiverProfileNetworkCollection profNetworkColl = m_networkModel; final IFEDiscretisationModel1d2d discModel = m_discretisationModel; final IFlowRelationshipModel flowRelModel = m_flowRelationCollection; final List<Feature> discModelAdds = m_discModelAdds; // TODO: do not every time create a new network: if an re-import happens // - find out if same network already exists... (how?) // - ask user to overwrite or not /* Set user friendly name and description */ final IRiverProfileNetwork foundNetwork = findExistingNetwork(profNetworkColl, reach); final IRiverProfileNetwork existingNetwork; if (foundNetwork == null) existingNetwork = null;/*from w w w . jav a2 s . co m*/ else { final String msg = Messages.getString("org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.11", //$NON-NLS-1$ foundNetwork.getName()); final MessageDialog messageDialog = new MessageDialog( getShell(), getWindowTitle(), null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 1); final int open = messageDialog.open(); System.out.println( Messages.getString("org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.12") + open); //$NON-NLS-1$ if (open == 2 || open == -1) return false; if (open == 0) existingNetwork = foundNetwork; else existingNetwork = null; // do create a new network } /* Do import */ final ICoreRunnableWithProgress op = new ICoreRunnableWithProgress() { @Override public IStatus execute(final IProgressMonitor monitor) throws InvocationTargetException { monitor.beginTask(Messages.getString("org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.4"), //$NON-NLS-1$ 3); try { /* Check if its the right calculation and if results are present */ if (calculation.getCalcMode() != TuhhCalculation.MODE.REIB_KONST) return new Status(IStatus.WARNING, KalypsoModel1D2DPlugin.PLUGIN_ID, Messages.getString("org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.5")); //$NON-NLS-1$ try { /* Import reach into profile collection */ monitor.subTask( Messages.getString("org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.6")); //$NON-NLS-1$ final SortedMap<BigDecimal, IProfileFeature> profilesByStation = doImportNetwork(reach, segments, profNetworkColl, existingNetwork); monitor.worked(1); /* Create 1D-Network */ monitor.subTask( Messages.getString("org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.7")); //$NON-NLS-1$ final SortedMap<BigDecimal, IFE1D2DNode> elementsByStation = doCreate1DNet(reach, segments, discModel, discModelAdds); monitor.worked(1); /* Create 1D-Network parameters (flow relations) */ monitor.subTask( Messages.getString("org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.8")); //$NON-NLS-1$ final IStatus status = doReadResults(calculation, segments, elementsByStation, flowRelModel, profilesByStation); monitor.worked(1); return status; } catch (final Exception e) { e.printStackTrace(); return StatusUtilities.statusFromThrowable(e, Messages.getString("org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.9")); //$NON-NLS-1$ } } catch (final Throwable t) { // TODO: remove all added features from terrainModel // TODO: remove all added features from discModel throw new InvocationTargetException(t); } finally { monitor.done(); } } }; final IStatus status = RunnableContextHelper.execute(getContainer(), true, false, op); if (!status.isOK()) KalypsoModel1D2DPlugin.getDefault().getLog().log(status); ErrorDialog.openError(getShell(), getWindowTitle(), Messages.getString("org.kalypso.kalypsomodel1d2d.ui.wizard.ImportWspmWizard.10"), status); //$NON-NLS-1$ return !status.matches(IStatus.ERROR); }
From source file:org.kalypso.model.wspm.pdb.ui.internal.wspm.PdbWspmProject.java
License:Open Source License
/** * Checks if the data should be save, and asks the user what to do.<br/> * Show a 'Yes', 'No', 'Cancel' dialog.// w ww . j a va2s.c o m * * @param If * set to <code>true</code>, the data will be reloaded if the user chooses 'NO'. * @return <code>false</code>, if the user cancels the operation. */ public boolean askForProjectSave() { if (m_provider == null) return true; final boolean dirty = m_provider.isDirty(); if (!dirty) return true; final Shell shell = m_window.getShell(); final String message = Messages.getString("PdbWspmProject.2"); //$NON-NLS-1$ final String[] buttonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; final MessageDialog dialog = new MessageDialog(shell, STR_SAVE_LOCAL_DATA_TITLE, null, message, MessageDialog.QUESTION_WITH_CANCEL, buttonLabels, 0); final int result = dialog.open(); if (result == 0) { final ICoreRunnableWithProgress operation = new ICoreRunnableWithProgress() { @Override public IStatus execute(final IProgressMonitor monitor) throws CoreException { doSave(monitor); return Status.OK_STATUS; } }; return busyCursorWhile(operation, STR_SAVE_LOCAL_DATA_TITLE, Messages.getString("PdbWspmProject.3")); //$NON-NLS-1$ } else if (result == 1) return true; else if (result == 2 || result == -1) return false; throw new IllegalStateException(); }
From source file:org.kalypso.model.wspm.tuhh.core.wspwin.WspWinOutputDirGenerator.java
License:Open Source License
private File askForExistence(final File dir) { final String message = String.format(Messages.getString("WspWinOutputDirGenerator_1"), dir.getName()); //$NON-NLS-1$ final String[] labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, Messages.getString("WspWinOutputDirGenerator_2"), Messages.getString("WspWinOutputDirGenerator_3"), //$NON-NLS-1$//$NON-NLS-2$ IDialogConstants.CANCEL_LABEL }; final Shell shell = SWT_AWT_Utilities.findActiveShell(); final MessageDialog dialog = new MessageDialog(shell, Messages.getString("WspWinOutputDirGenerator_4"), //$NON-NLS-1$ null, message, MessageDialog.QUESTION, labels, 0); switch (SWT_AWT_Utilities.openSwtWindow(dialog)) { case 0://from www . j a va 2s .c om return dir; case 1: return null; case 2: m_askMode = AskMode.ALWAYS; return dir; case 3: m_askMode = AskMode.NEVER; return null; case 4: throw new OperationCanceledException(); default: throw new IllegalStateException(); } }
From source file:org.kelvinst.psfimport.ui.importWizards.PsfImportWizardFilesSelectionPage.java
License:Open Source License
/** * Displays a Yes/No question to the user with the specified message and * returns the user's response.//from w w w .j a v a 2 s . c o m * * @param message * the question to ask * @return <code>true</code> for Yes, and <code>false</code> for No */ protected boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getContainer().getShell(), "Question", (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; // ensure yes is the default return dialog.open() == 0; }