Example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Prototype

int OK_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Click Source Link

Document

Button id for an "Ok" button (value 0).

Usage

From source file:com.aptana.ide.ui.io.dialogs.CloakExpressionDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create());
    main.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    Label label = new Label(main, SWT.NONE);
    label.setText(Messages.CloakExpressionDialog_LBL_Expression);
    label.setLayoutData(GridDataFactory.swtDefaults().create());

    expressionText = new Text(main, SWT.SINGLE | SWT.BORDER);
    expressionText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    expressionText.setText(expression);//  w ww .ja  va 2 s.co m
    expressionText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            getButton(IDialogConstants.OK_ID).setEnabled(!StringUtil.isEmpty(expressionText.getText()));
        }
    });

    Dialog.applyDialogFont(main);

    setTitle(Messages.CloakExpressionDialog_LBL_Title);
    setMessage(Messages.CloakExpressionDialog_LBL_Message);

    return main;
}

From source file:com.aptana.ide.ui.io.dialogs.CloakExpressionDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);
    getButton(IDialogConstants.OK_ID).setEnabled(!StringUtil.isEmpty(expression));
}

From source file:com.aptana.ide.update.ui.BrowserDialog.java

License:Open Source License

@Override
protected Control createButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;/*from ww w  .  j  a v  a  2s. com*/
    layout.marginHeight = 0;
    layout.horizontalSpacing = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    composite.setFont(parent.getFont());

    // create help control if needed
    if (isHelpAvailable()) {
        Control helpControl = createHelpControl(composite);
        ((GridData) helpControl.getLayoutData()).horizontalIndent = convertHorizontalDLUsToPixels(
                IDialogConstants.HORIZONTAL_MARGIN);
    }

    Composite checkboxComposite = new Composite(composite, SWT.NONE);
    GridLayout layout2 = new GridLayout();
    layout2.numColumns = 2;
    layout2.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout2.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout2.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout2.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    checkboxComposite.setLayout(layout2);
    checkboxComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    checkboxComposite.setFont(parent.getFont());

    bTurnOffThisAnnouncement = new Button(checkboxComposite, SWT.CHECK);
    bTurnOffThisAnnouncement.setText(Messages.BrowserDialog_Label_DoNotShowThisAnnouncementAgain);

    new Label(checkboxComposite, SWT.None);

    bTurnOffAllAnnouncements = new Button(checkboxComposite, SWT.CHECK);
    bTurnOffAllAnnouncements.setText(Messages.BrowserDialog_Label_DoNotShowAllAnnouncements);

    Button okButton = createButton(composite, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    GridData okGridData = (GridData) okButton.getLayoutData();
    okGridData.grabExcessVerticalSpace = false;
    okGridData.horizontalSpan = 2;
    okGridData.verticalAlignment = SWT.END;
    okGridData.horizontalAlignment = SWT.END;

    return composite;
}

From source file:com.aptana.ide.update.ui.BrowserDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        IPreferenceStore prefs = UpdateUIActivator.getDefault().getPreferenceStore();
        prefs.setValue(IPreferenceConstants.NEVER_SHOW_THIS_ANNOUNCEMENT,
                bTurnOffThisAnnouncement.getSelection());
        prefs.setValue(IPreferenceConstants.NEVER_SHOW_ANNOUNCEMENTS, bTurnOffAllAnnouncements.getSelection());
    }/*from   w ww.  j a va2  s  .c o  m*/
    super.buttonPressed(buttonId);
}

From source file:com.aptana.jira.ui.internal.SubmitTicketDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    getButton(IDialogConstants.OK_ID).setEnabled(false);
}

From source file:com.aptana.jira.ui.internal.SubmitTicketDialog.java

License:Open Source License

protected boolean validate() {
    String message = null;/*from   w ww.  j  a v a  2s  . co m*/
    if (typeCombo.getSelection().isEmpty()) {
        message = Messages.SubmitTicketDialog_ERR_EmptyType;
    } else if (StringUtil.isEmpty(summaryText.getText())) {
        message = Messages.SubmitTicketDialog_ERR_EmptySummary;
    } else if (StringUtil.isEmpty(reproduceText.getText())) {
        message = Messages.SubmitTicketDialog_ERR_EmptyStepsToReproduce;
    } else if (StringUtil.isEmpty(actualResultText.getText())) {
        message = Messages.SubmitTicketDialog_ERR_EmptyActualResult;
    } else if (StringUtil.isEmpty(expectedResultText.getText())) {
        message = Messages.SubmitTicketDialog_ERR_EmptyExpectedResult;
    }

    setErrorMessage(message);
    if (message == null) {
        setMessage(Messages.SubmitTicketDialog_DefaultMessage);
    }

    Button button = getButton(IDialogConstants.OK_ID);
    if (button != null) {
        button.setEnabled(message == null);
    }
    return message == null;
}

From source file:com.aptana.js.debug.ui.internal.InstallDebuggerPromptStatusHandler.java

License:Open Source License

/**
 * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
 *//* ww w. j a va2  s.  c om*/
public Object handleStatus(IStatus status, Object source) throws CoreException {
    Shell shell = UIUtils.getActiveShell();
    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[] { StringUtil.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download),
                        CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP },
                0);
        switch (md.open()) {
        case 0:
            WorkbenchBrowserUtil.launchExternalBrowser(URL_INSTALL_PDM, "org.eclipse.ui.browser.ie"); //$NON-NLS-1$
            return Boolean.TRUE;
        case 1:
            return Boolean.TRUE;
        case 3:
            WorkbenchBrowserUtil.launchExternalBrowser(URL_DOCS_INSTALL_IE_DEBUGGER);
            return Boolean.TRUE;
        default:
            break;
        }
        return null;
    } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title, MessageFormat.format(
                Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, ((String) source).substring(5)));
        return null;
    } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$
        MessageDialog.openInformation(shell, title,
                MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled,
                        ((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;
            }
            String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$
                    ? URL_DOCS_INSTALL_IE_DEBUGGER
                    : URL_DOCS_INSTALL_DEBUGGER;
            WorkbenchBrowserUtil.launchExternalBrowser(urlString);
        }
    }
    IPreferenceStore store = JSDebugUIPlugin.getDefault().getPreferenceStore();

    String pref = store.getString(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER);
    if (pref != null) {
        if (pref.equals(MessageDialogWithToggle.ALWAYS)) {
            return Boolean.TRUE;
        }
    }
    String message = MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled,
            (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(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER);
    dialog.setPrefStore(store);

    while (true) {
        switch (dialog.open()) {
        case IDialogConstants.YES_ID:
            return Boolean.TRUE;
        case IDialogConstants.NO_ID:
            return Boolean.FALSE;
        default:
            break;
        }
        String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$
                ? URL_DOCS_INSTALL_IE_DEBUGGER
                : URL_DOCS_INSTALL_DEBUGGER;
        WorkbenchBrowserUtil.launchExternalBrowser(urlString);
    }
}

From source file:com.aptana.js.debug.ui.internal.WorkbenchCloseListener.java

License:Open Source License

public void handleEvent(Event event) {
    if (event.widget instanceof Shell && PlatformUI.getWorkbench().getWorkbenchWindowCount() == 1
            && PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell().equals(event.widget)) {
        // last workbench window is about to close
        if (DebugOptionsManager.isDebuggerActive(JSDebugModel.getModelIdentifier())) {
            IEclipsePreferences preferences = EclipseUtil.instanceScope().getNode(JSDebugUIPlugin.PLUGIN_ID);
            if (!preferences.getBoolean(IJSDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER, true)) {
                return;
            }//from   w  w  w.  j  a v  a 2 s  .  co  m
            event.doit = false;
            MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm((Shell) event.widget,
                    Messages.WorkbenchCloseListener_ConfirmDebuggerExit,
                    Messages.WorkbenchCloseListener_DebuggerIsActive_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()) {
                preferences.putBoolean(IJSDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER, false);
                try {
                    preferences.flush();
                } catch (BackingStoreException e) {
                    IdeLog.logError(JSDebugUIPlugin.getDefault(), e);
                }
            }
        }
    }
}

From source file:com.aptana.php.debug.ui.launching.LaunchConfigurationsSelectionDialog.java

License:Open Source License

/**
 * This method allows the newly created controls to be initialized. This method is called only once all controls
 * have been created from the <code>createContents</code> method. By default this method initializes the OK button
 * control.//from www .  j  a  va  2  s .  c  o m
 */
protected void initializeControls() {
    getCheckBoxTableViewer().setAllChecked(true);
    getButton(IDialogConstants.OK_ID).setEnabled(isValid());
}

From source file:com.aptana.php.debug.ui.launching.LaunchConfigurationsSelectionDialog.java

License:Open Source License

protected void addCustomFooterControls(Composite parent) {
    if (fShowSelectButtons) {
        Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL);
        GridData gd = (GridData) comp.getLayoutData();
        gd.horizontalAlignment = SWT.END;
        Button button = SWTFactory.createPushButton(comp,
                Messages.LaunchConfigurationsSelectionDialog_selectAll, null);
        button.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                getCheckBoxTableViewer().setAllChecked(true);
                getButton(IDialogConstants.OK_ID).setEnabled(isValid());
            }/* ww  w  .j a  va 2 s.co m*/
        });
        button = SWTFactory.createPushButton(comp, Messages.LaunchConfigurationsSelectionDialog_deselectAll,
                null);
        button.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                getCheckBoxTableViewer().setAllChecked(false);
                getButton(IDialogConstants.OK_ID).setEnabled(isValid());
            }
        });
    }
}