List of usage examples for org.eclipse.jface.dialogs IDialogConstants INTERNAL_ID
int INTERNAL_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants INTERNAL_ID.
Click Source Link
From source file:com.aptana.editor.common.AbstractThemeableEditor.java
License:Open Source License
@Override protected void performSaveAs(IProgressMonitor progressMonitor) { progressMonitor = (progressMonitor == null) ? new NullProgressMonitor() : progressMonitor; IEditorInput input = getEditorInput(); if (input instanceof UntitledFileStorageEditorInput) { Shell shell = getSite().getShell(); // checks if user wants to save on the file system or in a workspace project boolean saveToProject = false; boolean byPassDialog = Platform.getPreferencesService().getBoolean(CommonEditorPlugin.PLUGIN_ID, IPreferenceConstants.REMEMBER_UNTITLED_FILE_SAVE_TYPE, false, null); if (byPassDialog) { // grabs from preferences saveToProject = Platform.getPreferencesService().getBoolean(CommonEditorPlugin.PLUGIN_ID, IPreferenceConstants.SAVE_UNTITLED_FILE_TO_PROJECT, false, null); } else {// w w w. ja va2 s. com // asks the user MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, Messages.AbstractThemeableEditor_SaveToggleDialog_Title, null, Messages.AbstractThemeableEditor_SaveToggleDialog_Message, MessageDialog.NONE, new String[] { Messages.AbstractThemeableEditor_SaveToggleDialog_LocalFilesystem, Messages.AbstractThemeableEditor_SaveToggleDialog_Project }, 0, null, false); int code = dialog.open(); if (code == SWT.DEFAULT) { return; } saveToProject = (code != IDialogConstants.INTERNAL_ID); if (dialog.getToggleState()) { // the decision is remembered, so saves it IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(CommonEditorPlugin.PLUGIN_ID); prefs.putBoolean(IPreferenceConstants.REMEMBER_UNTITLED_FILE_SAVE_TYPE, true); prefs.putBoolean(IPreferenceConstants.SAVE_UNTITLED_FILE_TO_PROJECT, saveToProject); try { prefs.flush(); } catch (BackingStoreException e) { IdeLog.logError(CommonEditorPlugin.getDefault(), e); } } } if (!saveToProject) { // saves to local filesystem FileDialog fileDialog = new FileDialog(shell, SWT.SAVE); String path = fileDialog.open(); if (path == null) { progressMonitor.setCanceled(true); return; } // Check whether file exists and if so, confirm overwrite File localFile = new File(path); if (localFile.exists()) { if (!MessageDialog.openConfirm(shell, Messages.AbstractThemeableEditor_ConfirmOverwrite_Title, MessageFormat.format(Messages.AbstractThemeableEditor_ConfirmOverwrite_Message, path))) { progressMonitor.setCanceled(true); } } IFileStore fileStore; try { fileStore = EFS.getStore(localFile.toURI()); } catch (CoreException e) { IdeLog.logError(CommonEditorPlugin.getDefault(), e); MessageDialog.openError(shell, Messages.AbstractThemeableEditor_Error_Title, MessageFormat.format(Messages.AbstractThemeableEditor_Error_Message, path)); return; } IDocumentProvider provider = getDocumentProvider(); if (provider == null) { return; } IEditorInput newInput; IFile file = getWorkspaceFile(fileStore); if (file != null) { newInput = new FileEditorInput(file); } else { newInput = new FileStoreEditorInput(fileStore); } boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException e) { IStatus status = e.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { MessageDialog.openError(shell, Messages.AbstractThemeableEditor_Error_Title, MessageFormat.format(Messages.AbstractThemeableEditor_Error_Message, path)); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } progressMonitor.setCanceled(!success); } else { super.performSaveAs(progressMonitor); } } else { super.performSaveAs(progressMonitor); } }
From source file:com.aptana.ide.debug.internal.ui.Startup.java
License:Open Source License
private String showBrowserNotFoundDialog(final boolean download) { final String[] path = new String[] { null }; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { if (Display.getCurrent().getActiveShell() == null) { // another message box is shown return; }/* w w w . j av a 2s . c o m*/ MessageDialogWithToggle md = new MessageDialogWithToggle( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.Startup_Notification, null, Messages.Startup_AptanaRequiresFirefox, MessageDialog.INFORMATION, new String[] { IDialogConstants.PROCEED_LABEL, StringUtils.ellipsify(CoreStrings.BROWSE), download ? Messages.Startup_Download : Messages.Startup_CheckAgain }, 0, Messages.Startup_DontAskAgain, false); md.setPrefKey(com.aptana.ide.debug.internal.ui.IDebugUIConstants.PREF_SKIP_FIREFOX_CHECK); md.setPrefStore(DebugUiPlugin.getDefault().getPreferenceStore()); int returnCode = md.open(); switch (returnCode) { case IDialogConstants.INTERNAL_ID: FileDialog fileDialog = new FileDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN); if (Platform.OS_WIN32.equals(Platform.getOS())) { fileDialog.setFilterExtensions(new String[] { "*.exe" }); //$NON-NLS-1$ fileDialog.setFilterNames(new String[] { Messages.Startup_ExecutableFiles }); } path[0] = fileDialog.open(); break; case IDialogConstants.INTERNAL_ID + 1: if (download) { WorkbenchHelper.launchBrowser("http://www.getfirefox.com"); //$NON-NLS-1$ } path[0] = StringUtils.EMPTY; break; default: } } }); return path[0]; }
From source file:com.aptana.js.debug.ui.internal.LaunchConfigurationsHelper.java
License:Open Source License
public static String showBrowserNotFoundDialog(final boolean download) { final String[] path = new String[] { null }; UIUtils.getDisplay().syncExec(new Runnable() { public void run() { MessageDialogWithToggle md = new MessageDialogWithToggle(UIUtils.getActiveShell(), Messages.Startup_Notification, null, Messages.Startup_StudioRequiresFirefox, MessageDialog.INFORMATION, new String[] { StringUtil.ellipsify(CoreStrings.BROWSE), download ? Messages.Startup_Download : Messages.Startup_CheckAgain, IDialogConstants.CANCEL_LABEL }, 0, Messages.Startup_DontAskAgain, false); md.setPrefKey(com.aptana.js.debug.ui.internal.IJSDebugUIConstants.PREF_SKIP_FIREFOX_CHECK); md.setPrefStore(JSDebugUIPlugin.getDefault().getPreferenceStore()); int returnCode = md.open(); switch (returnCode) { case IDialogConstants.INTERNAL_ID: FileDialog fileDialog = new FileDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN); if (Platform.OS_WIN32.equals(Platform.getOS())) { fileDialog.setFilterExtensions(new String[] { "*.exe" }); //$NON-NLS-1$ fileDialog.setFilterNames(new String[] { Messages.Startup_ExecutableFiles }); }/*from w w w.j a v a 2 s .com*/ path[0] = fileDialog.open(); break; case IDialogConstants.INTERNAL_ID + 1: if (download) { WorkbenchBrowserUtil.launchExternalBrowser("http://www.getfirefox.com"); //$NON-NLS-1$ } path[0] = StringUtil.EMPTY; break; default: } } }); return path[0]; }
From source file:com.ibm.xsp.extlib.designer.tooling.palette.applicationlayout.ApplicationLayoutDropAction.java
License:Open Source License
private boolean showWarning() { IPreferenceStore prefs = ExtLibToolingPlugin.getDefault().getPreferenceStore(); boolean bHidePrompt = true; if (prefs != null) { bHidePrompt = prefs.getBoolean(ExtLibToolingPlugin.PREFKEY_HIDE_XPAGE_WARNING); }/* w w w .j a v a2s .c o m*/ if (bHidePrompt) return true; Shell shell = getControl().getShell(); String msg = "You are placing the Application Layout control on an XPage.\n\nThe Application Layout control is most effective when placed in a custom control, where you can configure the layout once and then use the custom control on multiple pages."; // $NLX-ApplicationLayoutDropAction.YouareplacingtheApplicationLayout-1$ MessageDialogWithToggle dlg = new MessageDialogWithToggle(shell, "Application Layout", // $NLX-ApplicationLayoutDropAction.ApplicationLayout-1$ null, // image msg, MessageDialog.WARNING, new String[] { "Continue", "Cancel" }, // $NLX-ApplicationLayoutDropAction.Continue-1$ $NLX-ApplicationLayoutDropAction.Cancel-2$ 1, "Do not show this message again", // $NLX-ApplicationLayoutDropAction.Donotshowthismessageagain-1$ bHidePrompt) { // this is necessary because "Continue" maps to IDialogConstants.INTERNAL_ID, // (and prefs are stored as "always" or "never" by the dialog) // if "Continue" text changes, the use of IDialogConstants.INTERNAL_ID may need to change. protected void buttonPressed(int buttonId) { super.buttonPressed(buttonId); if (buttonId == IDialogConstants.INTERNAL_ID && getPrefStore() != null && getPrefKey() != null) { getPrefStore().setValue(getPrefKey(), getToggleState()); } } }; dlg.setPrefKey(ExtLibToolingPlugin.PREFKEY_HIDE_XPAGE_WARNING); dlg.setPrefStore(prefs); int code = dlg.open(); boolean bShouldContinue = (code == IDialogConstants.INTERNAL_ID); return bShouldContinue; }
From source file:org.eclipse.ptp.internal.rdt.sync.ui.handlers.CommonSyncExceptionHandler.java
License:Open Source License
@Override public void handle(final IProject project, final CoreException e) { RDTSyncUIPlugin.log(e);/*from w w w. ja v a 2s . c o m*/ if (!alwaysShowDialog && !SyncManager.getShowErrors(project)) { return; } String message; String endOfLineChar = System.getProperty("line.separator"); //$NON-NLS-1$ message = Messages.CommonSyncExceptionHandler_0 + project.getName() + ":" + endOfLineChar + endOfLineChar; //$NON-NLS-1$ if (e.getMessage() != null) { message = message + e.getMessage(); } final String finalMessage = message; Display errorDisplay = RDTSyncUIPlugin.getStandardDisplay(); errorDisplay.syncExec(new Runnable() { @Override public void run() { String[] buttonLabels; if (e instanceof RemoteSyncMergeConflictException) { // Avoid flooding the display with merge conflict dialogs. if (System.currentTimeMillis() - lastMergeConflictDialogTimeStamp <= timeBetweenMergeConflicts) { return; } lastMergeConflictDialogTimeStamp = System.currentTimeMillis(); buttonLabels = new String[2]; buttonLabels[0] = IDialogConstants.OK_LABEL; buttonLabels[1] = Messages.CommonSyncExceptionHandler_1; // Custom button } else { buttonLabels = new String[1]; buttonLabels[0] = IDialogConstants.OK_LABEL; } MessageDialog dialog; if (showErrorMessageToggle) { dialog = new MessageDialogWithToggle(null, Messages.CommonSyncExceptionHandler_2, null, finalMessage, MessageDialog.ERROR, buttonLabels, 0, Messages.CommonSyncExceptionHandler_3, !SyncManager.getShowErrors(project)); } else { dialog = new MessageDialog(null, Messages.CommonSyncExceptionHandler_4, null, finalMessage, MessageDialog.ERROR, buttonLabels, 0); } int buttonPressed = dialog.open(); if (showErrorMessageToggle) { if (((MessageDialogWithToggle) dialog).getToggleState()) { SyncManager.setShowErrors(project, false); } else { SyncManager.setShowErrors(project, true); } } // See bug #236617 concerning custom button ids. if ((showErrorMessageToggle && IDialogConstants.INTERNAL_ID - buttonPressed == 0) || (!showErrorMessageToggle && buttonPressed == 1)) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(SYNC_MERGE_FILE_VIEW, null, IWorkbenchPage.VIEW_VISIBLE); SyncMergeFileTableViewer viewer = SyncMergeFileTableViewer.getActiveInstance(); if (viewer != null) { viewer.update(project); } } catch (CoreException e) { throw new RuntimeException(e); } } }; }); }
From source file:org.eclipse.recommenders.internal.rcp.BundleResolutionFailureDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { setReturnCode(buttonId);/* ww w .jav a2s. co m*/ close(); if (getToggleState() && getPrefStore() != null && getPrefKey() != null) { getPrefStore().setValue(getPrefKey(), ALWAYS); try { ((ScopedPreferenceStore) getPrefStore()).save(); } catch (IOException e) { log(ERROR_PREFERENCES_NOT_SAVED, e); } } if (buttonId == IDialogConstants.INTERNAL_ID) { String commandLine = buildCommandLine(); if (commandLine == null) { return; } System.setProperty(PROP_EXIT_CODE, Integer.toString(24)); System.setProperty(PROP_EXIT_DATA, buildCommandLine()); PlatformUI.getWorkbench().restart(); } }
From source file:org.eclipse.scada.sec.ui.providers.KeySelectorDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(final Composite parent) { super.createButtonsForButtonBar(parent); this.unlockButton = createButton(parent, IDialogConstants.INTERNAL_ID, Messages.KeySelectorDialog_ButtonUnlock_Text, false); }
From source file:org.eclipse.scada.sec.ui.providers.KeySelectorDialog.java
License:Open Source License
@Override protected void buttonPressed(final int buttonId) { if (buttonId == IDialogConstants.INTERNAL_ID) { performUnlock(this.lockable); }/*w w w . j a v a 2s .co m*/ super.buttonPressed(buttonId); }
From source file:org.eclipse.sirius.common.ui.tools.api.dialog.SiriusMessageDialogWithToggle.java
License:Open Source License
/** * {@inheritDoc}.//from ww w. j a va 2s . co m * * Overridden to be able to extend mapButtonLabelToButtonID method. * * @see Dialog#createButtonBar(Composite) */ protected void createButtonsForButtonBar(Composite parent) { final String[] buttonLabels = getButtonLabels(); final Button[] buttons = new Button[buttonLabels.length]; final int defaultButtonIndex = getDefaultButtonIndex(); int suggestedId = IDialogConstants.INTERNAL_ID; for (int i = 0; i < buttonLabels.length; i++) { String label = buttonLabels[i]; // get the JFace button ID that matches the label, or use the // specified // id if there is no match. int id = mapButtonLabelToButtonID(label, suggestedId); // if the suggested id was used, increment the default for next use if (id == suggestedId) { suggestedId++; } Button button = createButton(parent, id, label, defaultButtonIndex == i); buttons[i] = button; } setButtons(buttons); }
From source file:org.eclipse.tcf.te.launch.ui.handler.LaunchDialogHandler.java
License:Open Source License
protected void doLaunch(LaunchNode node) { if (node != null && node.getLaunchConfiguration() != null) { final String[] modes = LaunchConfigHelper.getLaunchConfigTypeModes(node.getLaunchConfigurationType(), false);//www . j a v a 2s .co m List<String> modeLabels = new ArrayList<String>(); int defaultIndex = 0; for (String mode : modes) { if (LaunchManager.getInstance().validate(node.getLaunchConfiguration(), mode)) { ILaunchMode launchMode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(mode); modeLabels.add(launchMode.getLabel()); if (mode.equals(ILaunchManager.DEBUG_MODE)) { defaultIndex = modeLabels.size() - 1; } } } if (modeLabels.size() >= 1) { modeLabels.add(IDialogConstants.CANCEL_LABEL); OptionalMessageDialog dialog = new OptionalMessageDialog( UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.LaunchDialogHandler_dialog_title, null, NLS.bind(Messages.LaunchDialogHandler_dialog_message, node.getLaunchConfigurationType().getName(), node.getLaunchConfiguration().getName()), MessageDialog.QUESTION, modeLabels.toArray(new String[modeLabels.size()]), defaultIndex, null, null); int result = dialog.open(); if (result >= IDialogConstants.INTERNAL_ID) { DebugUITools.launch(node.getLaunchConfiguration(), modes[result - IDialogConstants.INTERNAL_ID]); } } } }