List of usage examples for org.eclipse.jface.dialogs MessageDialog CONFIRM
int CONFIRM
To view the source code for org.eclipse.jface.dialogs MessageDialog CONFIRM.
Click Source Link
From source file:org.kalypso.model.wspm.pdb.db.PdbUpdater.java
License:Open Source License
private IStatus handleUpdate(final Version version) { // 0) ggf. check preconditions /* ask user what to do */ final String baseMsg = String.format(STR_UPDATE, version, PdbInfo.CURRENT_VERSION); final String msg = baseMsg + Messages.getString("PdbUpdater_9"); //$NON-NLS-1$ final MessageDialog dialog = new MessageDialog(m_shell, WINDOW_TITLE, null, msg, MessageDialog.CONFIRM, new String[] { Messages.getString("PdbUpdater_10"), IDialogConstants.CANCEL_LABEL }, 1); //$NON-NLS-1$ if (dialog.open() != Window.OK) return Status.CANCEL_STATUS; /* Do update */ final String dbType = m_connection.getSettings().getType(); final UpdateScript[] scripts = UpdateScriptExtenions.getUpdateScripts(version, dbType); if (scripts == null) throw new IllegalStateException("Missing create script"); //$NON-NLS-1$ return executeScripts(scripts, Messages.getString("PdbUpdater_11")); //$NON-NLS-1$ }
From source file:org.netxms.ui.eclipse.tools.MessageDialogHelper.java
License:Open Source License
/** * Convenience method to open a simple confirm (OK/Cancel) dialog. * // w w w. ja va2 s . co m * @param parent the parent shell of the dialog, or <code>null</code> if none * @param title the dialog's title, or <code>null</code> if none * @param message the message * @return <code>true</code> if the user presses the OK button, <code>false</code> otherwise */ public static boolean openConfirm(Shell parent, String title, String message) { return open(MessageDialog.CONFIRM, parent, title, message); }
From source file:org.netxms.ui.eclipse.tools.MessageDialogHelper.java
License:Open Source License
/** * Convenience method to open a simple confirm (OK/Cancel) dialog with a check box * to remember selection. /*ww w . j a va 2s . com*/ * * @param parent the parent shell of the dialog, or <code>null</code> if none * @param title the dialog's title, or <code>null</code> if none * @param label the label for the check box * @param message the message * @return */ public static DialogData openConfirmWithCheckbox(Shell parent, String title, String label, String message) { MessageDialogWithCheckbox msg = new MessageDialogWithCheckbox(MessageDialog.CONFIRM, new String[] { JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY), JFaceResources.getString(IDialogLabelKeys.CANCEL_LABEL_KEY) }, parent, title, label, message); return msg.openMsg(); }
From source file:org.opentravel.schemas.stl2developer.ApplicationWorkbenchAdvisor.java
License:Apache License
private int getUserConfirmation() { MessageDialog dialog = new MessageDialog(OtmRegistry.getActiveShell(), Messages.getString("dialog.exit.title"), null, Messages.getString("dialog.exit.question"), MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 1);/* www . j a va 2 s .c o m*/ return dialog.open(); }
From source file:org.sf.feeling.decompiler.update.DecompilerUpdateHandler.java
License:Open Source License
private void updateDecompiler(IProgressMonitor monitor) throws Exception { if (version == null) { version = getUpdateVersion(monitor); }//from ww w. j a va2s.c om final String versionString = getVersion(version); final boolean force = isForce(monitor); if (versionString != null && (!versionString.equals(DecompilerUpdatePlugin.getDefault().getPreferenceStore() .getString(DecompilerUpdatePlugin.NOT_UPDATE_VERSION)) || force)) { Display.getDefault().asyncExec(new Runnable() { public void run() { MessageDialogWithToggle dialog = new MessageDialogWithToggle( Display.getDefault().getActiveShell(), Messages.getString("DecompilerUpdateHandler.ConfirmDialog.Title"), //$NON-NLS-1$ null, // accept the default window icon Messages.getString("DecompilerUpdateHandler.ConfirmDialog.Message"), //$NON-NLS-1$ MessageDialog.CONFIRM, new String[] { Messages.getString("DecompilerUpdateHandler.ConfirmDialog.Button.NotNow"), //$NON-NLS-1$ Messages.getString("DecompilerUpdateHandler.ConfirmDialog.Button.Continue") //$NON-NLS-1$ }, 1, Messages.getString("DecompilerUpdateHandler.ConfirmDialog.Button.NotAskAgain"), //$NON-NLS-1$ false) { protected Button createToggleButton(Composite parent) { Button button = super.createToggleButton(parent); if (force) { button.setVisible(false); } return button; } }; int result = dialog.open(); if (!force && dialog.getToggleState()) { DecompilerUpdatePlugin.getDefault().getPreferenceStore() .setValue(DecompilerUpdatePlugin.NOT_UPDATE_VERSION, versionString); } if (result - IDialogConstants.INTERNAL_ID == 1) { String installUrl = "http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=472922"; //$NON-NLS-1$ if (MarsDecompilerMarketplace.isInteresting()) { new MarsMarketClientHandler().proceedInstallation(installUrl); } else if (LunaDecompilerMarketplace.isInteresting()) { new LunaDecompilerMarketplace().proceedInstallation(installUrl); } } } }); } }
From source file:org.talend.core.model.metadata.builder.database.ExtractMetaDataFromDataBase.java
License:Open Source License
public static boolean checkSchemaConnection(final String schema, Connection connection, boolean notCaseSensitive, String dbType, final StringBuffer retPropsedSchema) throws SQLException { ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance(); DatabaseMetaData dbMetaData = extractMeta.getDatabaseMetaData(connection, dbType); final StringBuffer proposeSchema = new StringBuffer(); if (dbMetaData != null) { ResultSet rs = dbMetaData.getSchemas(); while (rs.next()) { if (notCaseSensitive) { if (rs.getString(1).toLowerCase().compareTo(schema.toLowerCase()) == 0) { extractMeta.setSchema(rs.getString(1)); rs.close();//from ww w. java2 s . c om return (true); } } else { String schemaFromDB = rs.getString(1); if (schemaFromDB.toLowerCase().compareTo(schema.toLowerCase()) == 0) { if (schemaFromDB.compareTo(schema) == 0) { extractMeta.setSchema(schema); rs.close(); return (true); } else { proposeSchema.append(schemaFromDB); } } } } rs.close(); } if (retPropsedSchema != null && 0 < proposeSchema.length()) { final StringBuffer userSelectResult = new StringBuffer(); Display.getDefault().syncExec(new Runnable() { @Override public void run() { String title = Messages.getString("CheckConnection.CheckSchema.ProposeSchema.title"); //$NON-NLS-1$ String proposeMessage = Messages.getString("CheckConnection.CheckSchema.ProposeSchema.message", //$NON-NLS-1$ new Object[] { schema, proposeSchema }); MessageDialog messageDialog = new MessageDialog(new Shell(), title, null, proposeMessage, MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (messageDialog.open() == 0) { retPropsedSchema.append(proposeSchema); userSelectResult.append("true"); //$NON-NLS-1$ } } }); if (0 < userSelectResult.length()) { return true; } } return false; }
From source file:org.talend.repository.hdfs.ui.HDFSFileSelectorForm.java
License:Open Source License
private synchronized void showTableIsExistConfirmDialog(final MetadataTable existTable) { if (notShowAgain == false) { // orgomg.cwm.objectmodel.core.Package pack = (orgomg.cwm.objectmodel.core.Package) existTable.eContainer(); MessageDialogWithToggle dialog = new MessageDialogWithToggle(Display.getDefault().getActiveShell(), Messages.getString("HDFSFileSelectorForm.title.confirm"), null, Messages.getString( //$NON-NLS-1$ "HDFSFileSelectorForm.tableIsExist.new", existTable.getLabel()), //$NON-NLS-1$ MessageDialog.CONFIRM, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1, Messages.getString("HDFSFileSelectorForm.tableIsExist.notShowAgain"), //$NON-NLS-1$ false);//w w w .jav a 2 s . co m int result = dialog.open(); notShowAgain = dialog.getToggleState(); if (result == IDialogConstants.YES_ID) { userConfirmed = true; } else { userConfirmed = false; } } }
From source file:org.talend.repository.ui.actions.ExportJobScriptAction.java
License:Open Source License
@Override protected void doRun() { JobScriptsExportWizard processWizard = new JobScriptsExportWizard(); IWorkbench workbench = getWorkbench(); processWizard.setWindowTitle(EXPORTJOBSCRIPTS); processWizard.init(workbench, (IStructuredSelection) this.getSelection()); Shell activeShell = Display.getCurrent().getActiveShell(); WizardDialog dialog = new WizardDialog(activeShell, processWizard); if (checkDirtyPart(workbench)) { MessageDialog messageDialog = new MessageDialog(new Shell(), "", //$NON-NLS-1$ null, Messages.getString("ExportJobScriptAction.confirmMessage"), //$NON-NLS-1$ MessageDialog.CONFIRM, new String[] { Messages.getString("ExportJobScriptAction.confirmContiune"), //$NON-NLS-1$ IDialogConstants.CANCEL_LABEL }, 0);/*w w w. ja va 2 s. com*/ if (messageDialog.open() != 0) { return; // don't do anything } } dialog.setPageSize(830, 580); dialog.open(); // collector IPreferenceStore preferenceStore = RepositoryPlugin.getDefault().getPreferenceStore(); int num = preferenceStore.getInt(ExportJobTokenCollector.TOS_COUNT_JOB_EXPORTS.getPrefKey()); preferenceStore.setValue(ExportJobTokenCollector.TOS_COUNT_JOB_EXPORTS.getPrefKey(), num + 1); }
From source file:org.xmind.ui.internal.e4handlers.SaveWorkbookAsHandler.java
License:Open Source License
/** * @param context//from w w w . j a va 2 s . co m * the context where this operation happens * @param workbookRef * the source workbook ref to be saved * @param runner * an {@link IRunnableContext} to run the job * @param optionFilter * <code>null</code> to accept all options at beginning, or an * {@link IFilter} instance that selects available option ids * @param onlyToLocal * is only save to local * @return a new workbook ref that is filled with contents from the source * workbook ref * @throws InvocationTargetException */ public static IWorkbookRef saveWorkbookAs(ISaveContext context, final IWorkbookRef workbookRef, IRunnableContext runner, IFilter optionFilter, boolean onlyToLocal) throws InvocationTargetException { Assert.isLegal(context != null); Shell shell = context.getContextVariable(Shell.class); // list all available location options List<SaveWizardDescriptor> wizards = MindMapUIPlugin.getDefault().getSaveWizardManager().getWizards(); if (wizards.isEmpty()) { // no location options available.... // should not happen? // no need to extract strings MessageDialog.openWarning(shell, "Save As", //$NON-NLS-1$ "No 'Save As' options available in this application. " //$NON-NLS-1$ + "Please contact the software provider for this issue."); //$NON-NLS-1$ return null; } // make a new array so that we can remove unavailable ones wizards = new ArrayList<SaveWizardDescriptor>(wizards); if (optionFilter != null) { Iterator<SaveWizardDescriptor> locationProviderIt = wizards.iterator(); while (locationProviderIt.hasNext()) { SaveWizardDescriptor locationProvider = locationProviderIt.next(); if (!optionFilter.select(locationProvider.getId())) { locationProviderIt.remove(); } } } sortLocationProviders(wizards); // ensure runnable context available if (runner == null) { runner = new ProgressMonitorDialog(shell); } // prepare save options String oldName = workbookRef.getName(); if (oldName == null) { IWorkbook workbook = workbookRef.getWorkbook(); if (workbook != null) { oldName = workbook.getPrimarySheet().getRootTopic().getTitleText(); } if (oldName == null) oldName = MindMapMessages.SaveWorkbookAsHandler_oldName_default; } while (true) { if (wizards.isEmpty()) { // tried out all possible location options.... // should not happen? // no need to extract strings MessageDialog.openError(shell, "Save As", //$NON-NLS-1$ "No 'Save As' options available now for this workbook. " //$NON-NLS-1$ + "Please contact the software provider for this issue."); //$NON-NLS-1$ return null; } SaveOptions options = SaveOptions.getDefault() // .proposalName(oldName) // .oldURI(workbookRef.getURI()); SaveWizardDescriptor wizard; if (onlyToLocal || wizards.size() == 1) { wizard = wizards.get(0); } else { String oldWizardId = workbookRef.getSaveWizardId(); SaveWizardDescriptor defaultWizard = oldWizardId == null ? null : findSaveWizard(wizards, oldWizardId, false); if (defaultWizard == null) { int maxPriority = 0; for (SaveWizardDescriptor wizardDescriptor : wizards) { /// sort by priority /// choose highest priority /// exclude those whose priority < 0 int priority = wizardDescriptor.getWizard().getPriorityFor(context, options); if (priority > maxPriority) { maxPriority = priority; defaultWizard = wizardDescriptor; } if (priority < 0) wizards.remove(wizardDescriptor); } } if (defaultWizard == null) { defaultWizard = wizards.get(0); } SaveWizardDialog dialog = new SaveWizardDialog(shell, wizards, defaultWizard, options); if (dialog.open() != SaveWizardDialog.OK) // canceled return null; wizard = dialog.getTargetWizard(); options = dialog.getTargetOptions(); } ISaveWizard wizardImpl = wizard.getWizard(); Assert.isNotNull(wizardImpl); URI newURI; try { newURI = wizardImpl.askForTargetURI(context, options); } catch (SaveWizardNotAvailable na) { wizards.remove(wizard); String saveText; if (wizards.size() == 0) { MessageDialog.openInformation(shell, "No options", //$NON-NLS-1$ na.getMessage()); return null; } else if (wizards.size() == 1) { saveText = NLS.bind(MindMapMessages.SaveWorkbookAsHandler_saveToOtherDialog_saveTo_text, wizards.get(0).getName()); } else { saveText = MindMapMessages.SaveWorkbookAsHandler_saveToOtherDialog_saveToAnother_text; } MessageDialog dialog = new MessageDialog( shell, MindMapMessages.SaveWorkbookAsHandler_saveToOtherDialog_title, null, na.getMessage(), MessageDialog.CONFIRM, new String[] { saveText, IDialogConstants.CANCEL_LABEL }, 0 ); if (dialog.open() != MessageDialog.OK) return null; continue; } if (newURI == null) // canceled return null; IWorkbookRefFactory workbookRefFactory = MindMapUIPlugin.getDefault().getWorkbookRefFactory(); final IWorkbookRef newWorkbookRef = workbookRefFactory.createWorkbookRef(newURI, null); Assert.isNotNull(newWorkbookRef); if (!newWorkbookRef.isInState(IEditable.CLOSED)) { MessageDialog.openWarning(shell, MindMapMessages.SaveWorkbookAsHandler_warningDialog_title, MindMapMessages.SaveWorkbookAsHandler_warningDialog_description); continue; } newWorkbookRef.setActiveContext(workbookRef.getActiveContext()); if (newWorkbookRef.equals(workbookRef)) { // same location // just save the old workbook ref if (!workbookRef.isInState(IWorkbookRef.CLOSED)) { try { runner.run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { workbookRef.save(monitor); } }); } catch (InterruptedException e) { // canceled return null; } } return newWorkbookRef; } if (!newWorkbookRef.canImportFrom(workbookRef)) { MessageDialog.openError(shell, MindMapMessages.SaveWorkbookAsHandler_saveAsDialog_title, MindMapMessages.SaveWorkbookAsHandler_saveAsDialog_description); wizards.remove(wizard); continue; } try { runner.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { doSaveAs(monitor, workbookRef, newWorkbookRef, 0); } }); } catch (InterruptedException e) { // canceled return null; } // should return here in normal cases return newWorkbookRef; } }
From source file:org.xmind.ui.internal.editor.MindMapEditor.java
License:Open Source License
@Override public void fileChanged(final String title, final String message, final String[] buttons) { if (workbookRef.getState() != IWorkbookRef.NORMAL) { return;/*from w w w .j ava 2 s .c o m*/ } if (ignoreFileChanged) { return; } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { deactivateFileNotifier(); getEditorSite().getPage().activate(MindMapEditor.this); if (!isDirty()) { reload(); } else { MessageDialog dialog = new MessageDialog(null, title, null, NLS.bind(MindMapMessages.MindMapEditor_fileChangedDialog_message_prefix + message, workbookRef.getName()), MessageDialog.CONFIRM, buttons, 0); int code = dialog.open(); if (code == 0) { reload(); } else if (code == 1 || code == -1) { ignoreFileChanged = true; } } activateFileNotifier(); } }); }