List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_ID
int OK_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_ID.
Click Source Link
From source file:com.aptana.ide.core.ui.dialogs.InputURLDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); //do this here because setting the text will set enablement on the ok // button//from w w w . j a va2 s . c om loadList(); combo.setFocus(); if (value != null) { combo.setText(value); setErrorMessage(null); if (validator.isValid(value) != null) { Control button = getButton(IDialogConstants.OK_ID); if (button != null) { button.setEnabled(false); } } } }
From source file:com.aptana.ide.debug.internal.ui.InstallDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *//* w w w .j a v a 2 s. c o m*/ public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = DebugUiPlugin.getActiveWorkbenchShell(); String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension; if ("install".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit); return null; } else if ("postinstall".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit); return null; } else if ("nopdm".equals(source)) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING, new String[] { StringUtils.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download), CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP }, 0); switch (md.open()) { case 0: WorkbenchHelper.launchBrowser("http://www.aptana.com/pro/pdm.php", "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ //$NON-NLS-2$ /* continue */ case 1: return new Boolean(true); case 3: WorkbenchHelper.launchBrowser("http://www.aptana.com/docs/index.php/Installing_the_IE_debugger"); //$NON-NLS-1$ return new Boolean(true); default: break; } return null; } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, new String[] { ((String) source).substring(5) })); return null; } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled, new String[] { ((String) source).substring(10) })); return null; } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$ MessageDialog.openWarning(shell, title, ((String) source).substring(8)); return null; } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed, new Object[] { ((String) source).substring(7) }), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0); while (true) { switch (md.open()) { case IDialogConstants.OK_ID: return null; default: break; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } } IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IDebugUIConstants.PREF_INSTALL_DEBUGGER); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return new Boolean(true); } } String message = StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled, new String[] { (String) source }); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null, false); dialog.setPrefKey(IDebugUIConstants.PREF_INSTALL_DEBUGGER); dialog.setPrefStore(store); while (true) { switch (dialog.open()) { case IDialogConstants.YES_ID: return new Boolean(true); case IDialogConstants.NO_ID: return new Boolean(false); default: break; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } }
From source file:com.aptana.ide.debug.internal.ui.WorkbenchCloseListener.java
License:Open Source License
/** * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) *//* w w w . java 2 s . c om*/ public void handleEvent(Event event) { if (event.widget instanceof Shell && PlatformUI.getWorkbench().getWorkbenchWindowCount() == 1 && PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell() == event.widget) { // last workbench window is about to close if ("true".equals(System.getProperty(JSDebugOptionsManager.DEBUGGER_ACTIVE))) { //$NON-NLS-1$ IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore(); if (store.contains(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)) { if (store.getBoolean(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER) == false) { return; } } event.doit = false; MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm((Shell) event.widget, Messages.WorkbenchCloseListener_ConfirmDebuggerExit, Messages.WorkbenchCloseListener_AptanaDebuggerIsActive_DoYouWantToExit, Messages.WorkbenchCloseListener_AlwaysExitDebuggerWithoutPrompt, false, null, null); int returnValue = dlg.getReturnCode(); if (returnValue != IDialogConstants.OK_ID) { // SWT hack - discard close event event.type = SWT.None; return; } if (dlg.getToggleState()) { store.setValue(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER, false); DebugUiPlugin.getDefault().savePluginPreferences(); } } } }
From source file:com.aptana.ide.editors.preferences.CodeAssistExpressionInfoDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) *//* w ww .ja v a 2s.com*/ protected void createButtonsForButtonBar(Composite parent) { okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); okButton.setEnabled(validateErrorDescriptor()); }
From source file:com.aptana.ide.logging.preferences.NewRuleDialog.java
License:Open Source License
/** * Validates values.//from ww w. ja va2 s. c o m */ private void validate() { String contentText = contentEdit.getText(); //replacing ignorable characters if (hasIgnorableCharacters(contentText)) { contentEdit.setText(replaceIgnorableCharacters(contentText)); setRegexpBased(true); } if (newRuleMode) { String nameText = nameEdit.getText(); if (nameText.length() == 0) { disableOKButton(); setErrorMessage(Messages.NewRuleDialog_RuleError_Name); return; } String trimmedName = nameText.trim(); if (forbiddenNames != null && forbiddenNames.contains(trimmedName)) { disableOKButton(); setErrorMessage(Messages.NewRuleDialog_RuleError_Name_AlreadyExists); return; } } if (contentText.length() == 0) { setErrorMessage(Messages.NewRuleDialog_RuleError_RegexpRule_Content); disableOKButton(); return; } setErrorMessage(null); Button button = getButton(IDialogConstants.OK_ID); if (button != null) { button.setEnabled(true); } }
From source file:com.aptana.ide.logging.preferences.NewRuleDialog.java
License:Open Source License
/** * Disables OK button.//from ww w . j av a 2s.c o m */ private void disableOKButton() { Button button = getButton(IDialogConstants.OK_ID); if (button != null) { button.setEnabled(false); } }
From source file:com.aptana.ide.rcp.IDEWorkbenchWindowAdvisor.java
License:Open Source License
public boolean preWindowShellClose() { if (getWorkbench().getWorkbenchWindowCount() > 1) { return true; }//w ww .j a v a2 s . co m // the user has asked to close the last window, while will cause the // workbench to close in due course - prompt the user for confirmation IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); boolean promptOnExit = store.getBoolean(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW); if (promptOnExit) { String message; String productName = null; IProduct product = Platform.getProduct(); if (product != null) { productName = product.getName(); } if (productName == null) { message = IDEWorkbenchMessages.PromptOnExitDialog_message0; } else { message = NLS.bind(IDEWorkbenchMessages.PromptOnExitDialog_message1, productName); } MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm( getWindowConfigurer().getWindow().getShell(), IDEWorkbenchMessages.PromptOnExitDialog_shellTitle, message, IDEWorkbenchMessages.PromptOnExitDialog_choice, false, null, null); if (dlg.getReturnCode() != IDialogConstants.OK_ID) { return false; } if (dlg.getToggleState()) { store.setValue(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, false); IDEWorkbenchPlugin.getDefault().savePluginPreferences(); } } return true; }
From source file:com.aptana.ide.security.internal.linux.StorageLoginDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { okButton = createButton(parent, IDialogConstants.OK_ID, Messages.buttonLogin, true); okButton.setEnabled(false);/*from w w w . ja v a2s. c o m*/ createButton(parent, IDialogConstants.CANCEL_ID, Messages.buttonExit, false); }
From source file:com.aptana.ide.server.jetty.ui.dialogs.JettyConfigurationDialog.java
License:Open Source License
/** * @param isOk//from w ww .ja v a2s . c o m * @param message */ public void updateStatus(boolean isOk, String message) { Button button = getButton(IDialogConstants.OK_ID); if (!isOk) { wasError = true; setErrorMessage(message); if (button != null) { button.setEnabled(false); } } else { if (!wasError) { if (server != null && !(server.getServerState() == IServer.STATE_STOPPED || server.getServerState() == IServer.STATE_UNKNOWN)) { setErrorMessage(ServerLabelProvider.SERVER_IS_RUNNING_NO_EDIT); if (button != null) { button.setEnabled(false); } return; } return; } wasError = false; setErrorMessage(null); if (button != null) { button.setEnabled(true); } } }
From source file:com.aptana.ide.server.ui.generic.dialogs.GenericConfigurationDialog.java
License:Open Source License
private void validate() { String name = serverNameText.getText(); String hostname = hostnameText.getText(); Button ok = getButton(IDialogConstants.OK_ID); String port = portText.getText(); boolean error = false; if (name.trim().length() == 0) { setErrorMessage(Messages.GenericConfigurationDialog_SERVER_NAME_MUST_NOT_BE_BLANK); error = true;//from w w w. jav a2s .com ok.setEnabled(false); } else if (serverNames.contains(name)) { setErrorMessage(Messages.GenericConfigurationDialog_SERVER_NAME_EXISTS); error = true; } else if (hostname.trim().length() == 0) { setErrorMessage(Messages.GenericConfigurationDialog_HOST_NAME_MUST_NOT_BE_BLANK); error = true; } if (!error) { try { Integer i = Integer.parseInt(port); if (i < 0 || i > 65535) { setErrorMessage(Messages.GenericConfigurationDialog_PORT_MUST_BE_IN_RANGE); error = true; } } catch (NumberFormatException e) { setErrorMessage(Messages.GenericConfigurationDialog_PORT_MUST_BE_INTEGER); error = true; } } if (!error && isLocal.getSelection()) { File file = new File(path.getText()); if (file.exists()) { if (file.isFile()) { error = false; if (startText.getText().length() == 0) { setErrorMessage(Messages.GenericConfigurationDialog_START_IS_EMPTY); error = true; } else if (stopText.getText().length() == 0) { setErrorMessage(Messages.GenericConfigurationDialog_STOP_IS_EMPTY); error = true; } else if (log.getText().length() != 0) { file = new File(log.getText()); if (!file.exists() || !file.isFile()) { setErrorMessage( Messages.GenericConfigurationDialog_PATH_TO_LOG_FILE_SHOULD_BE_EMPTY_OR_POINT_TO_FILE); error = true; } } } else { error = true; setErrorMessage(Messages.GenericConfigurationDialog_PATH_SHOULD_NOT_POINT_TO_DIRECTORY); } } else { error = true; setErrorMessage(Messages.GenericConfigurationDialog_NO_FILE_UNDER_A_GIVEN_PATH); } if (!error) { String docRootPath = docRootText.getText().trim(); if (docRootPath.length() == 0 && !new File(docRootPath).isDirectory()) { error = true; setErrorMessage(Messages.GenericConfigurationDialog_DOCUMENT_ROOT_ERROR); } } } if (!error) { if (healthURLText.getText().trim().length() > 0) { try { new URL(healthURLText.getText().trim()); } catch (MalformedURLException e) { error = true; setErrorMessage(Messages.GenericConfigurationDialog_MSG_InvalidHeartbeat); } if (!error) { try { Integer i = Integer.parseInt(pollingIntervalText.getText()); if (i < 1) { setErrorMessage(Messages.GenericConfigurationDialog_MSG_PollingBound); error = true; } } catch (NumberFormatException e) { setErrorMessage(Messages.GenericConfigurationDialog_MSG_PollingInteger); error = true; } } } } if (!error) { boolean allowed = false; if (server instanceof GenericServer) { boolean isLocal = configuration.getBooleanAttribute(GenericServerTypeDelegate.IS_LOCAL); String healthURL = configuration.getStringAttribute(GenericServerTypeDelegate.HEALTH_URL); int pollingInterval = configuration.getIntAttribute(GenericServerTypeDelegate.POLLING_INTERVAL); // Allow edits of running servers that are just polling if (!isLocal && healthURL != null && healthURL.length() > 0 && pollingInterval > 0) { allowed = true; } } if (server != null) { if (!allowed && !(server.getServerState() == IServer.STATE_STOPPED || server.getServerState() == IServer.STATE_UNKNOWN || server.getServerState() == IServer.STATE_NOT_APPLICABLE)) { setErrorMessage(ServerLabelProvider.SERVER_IS_RUNNING_NO_EDIT); ok.setEnabled(false); return; } } setErrorMessage(null); } ok.setEnabled(!error); }