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

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

Introduction

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

Prototype

String OK_LABEL

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

Click Source Link

Document

The label for OK buttons.

Usage

From source file:com.aptana.git.ui.internal.actions.DiffHandler.java

License:Open Source License

@Override
protected Object doExecute(ExecutionEvent event) throws ExecutionException {
    Map<String, String> diffs = new HashMap<String, String>();
    List<ChangedFile> changedFiles = getSelectedChangedFiles();
    if (changedFiles == null || changedFiles.isEmpty()) {
        return null;
    }//from   www .  java 2s  .  c  o m

    GitRepository repo = getSelectedRepository();
    if (repo == null) {
        return null;
    }
    for (ChangedFile file : changedFiles) {
        if (file == null) {
            continue;
        }

        if (diffs.containsKey(file.getPath())) {
            continue; // already calculated diff...
        }
        String diff = repo.index().diffForFile(file, file.hasStagedChanges(), 3);
        diffs.put(file.getPath(), diff);
    }
    if (diffs.isEmpty()) {
        return null;
    }

    String diff = ""; //$NON-NLS-1$
    try {
        diff = DiffFormatter.toHTML(diffs);
    } catch (Throwable t) {
        IdeLog.logError(GitUIPlugin.getDefault(), "Failed to turn diff into HTML", t, IDebugScopes.DEBUG); //$NON-NLS-1$
    }

    final String finalDiff = diff;
    UIUtils.showMessageDialogFromBgThread(new SafeMessageDialogRunnable() {
        public int openMessageDialog() {
            MessageDialog dialog = new MessageDialog(getShell(), Messages.GitProjectView_GitDiffDialogTitle,
                    null, "", 0, new String[] { IDialogConstants.OK_LABEL }, 0) //$NON-NLS-1$
            {
                @Override
                protected Control createCustomArea(Composite parent) {
                    Browser diffArea = new Browser(parent, SWT.BORDER);
                    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
                    data.heightHint = 300;
                    diffArea.setLayoutData(data);
                    diffArea.setText(finalDiff);
                    return diffArea;
                }

                @Override
                protected boolean isResizable() {
                    return true;
                }
            };
            return dialog.open();
        }
    });

    return null;
}

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// w  w  w  .j a v a2s . c o m
    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)
 *///from w  w  w. j  a v a2 s  . c  om
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.editors.preferences.CodeAssistExpressionInfoDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
 *//*from   w  w  w.ja v a  2  s.  c o m*/
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.server.ui.views.actions.OpenStatisticsAction.java

License:Open Source License

/**
 * @see org.eclipse.jface.action.Action#run()
 *//*from  w w w  .j  a v a  2 s.  c o m*/
public void run() {
    ISelection selection = provider.getSelection();
    if (selection instanceof StructuredSelection && !selection.isEmpty()) {
        StructuredSelection ss = (StructuredSelection) selection;
        if (ss.getFirstElement() != null && ss.getFirstElement() instanceof IServer) {
            IServer server = (IServer) ss.getFirstElement();
            if (server.suppliesStatisticsInterface()) {
                server.showStatisticsInterface();
            } else {
                String stats = server.fetchStatistics();
                MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(),
                        StringUtils.format(Messages.OpenStatisticsAction_Stats_Title, server.getName()), null,
                        stats, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0) {

                    protected Control createMessageArea(Composite composite) {
                        super.createMessageArea(composite);
                        GridData mlData = new GridData(SWT.FILL, SWT.FILL, true, true);
                        super.messageLabel.setLayoutData(mlData);
                        return composite;
                    }

                    protected int getMessageLabelStyle() {
                        return SWT.LEFT;
                    }

                };
                dialog.open();
            }
        }

    }
}

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  .ja  v a2s .  co  m
    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.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.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)
 *//*from   www  . j  ava  2 s  .  co m*/
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.portal.ui.browser.AbstractPortalBrowserEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    try {/*from   ww  w  .j a  va  2  s.  co m*/
        browserViewer = createBrowserViewer(parent);
        final Browser browserControl = (Browser) browserViewer.getBrowser();
        browser = new BrowserWrapper(browserControl);

        // Add a listener for new browser windows. If new ones are opened, close it and open in an external
        // browser
        browserControl.addOpenWindowListener(new OpenWindowListener() {
            public void open(WindowEvent event) {
                Browser newBrowser = event.browser;
                final BrowserViewer browserContainer = new BrowserViewer(browserControl.getShell(),
                        browserControl.getStyle());
                event.browser = browserContainer.getBrowser();

                // Close the new browser window that was opened by previous listener
                newBrowser.getShell().close();
                event.required = true; // avoid opening new windows.

                if (newBrowser != browserControl) {
                    LocationAdapter locationAdapter = new LocationAdapter() {

                        public void changing(LocationEvent event) {
                            final String url = event.location;
                            if (!StringUtil.isEmpty(url)) {
                                WorkbenchBrowserUtil.openURL(url);
                            }
                            // The location change listener has to be removed as it might
                            // be triggered again when we open new browser editor tab.
                            browserContainer.getBrowser().removeLocationListener(this);
                        }
                    };
                    browserContainer.getBrowser().addLocationListener(locationAdapter);
                }
            }
        });

        browser.setJavascriptEnabled(true);

        // Usually, we would just listen to a location change. However, since IE
        // does not
        // behave well with notifying us when hitting refresh (F5), we have to
        // do it on
        // a title change (which should work for all browsers)
        browser.addTitleListener(new PortalTitleListener());

        // Register a location listener anyway, just to make sure that the
        // functions are
        // removed when we have a location change.
        // The title-listener will place them back in when the TitleEvent is
        // fired.
        browser.addProgressListener(new ProgressAdapter() {
            public void completed(ProgressEvent event) {
                browser.addLocationListener(new LocationAdapter() {
                    public void changed(LocationEvent event) {
                        // browser.removeLocationListener(this);
                        refreshBrowserRegistration();

                    }
                });
            }
        });
        browser.setUrl(initialURL);
        // Register this browser to receive notifications from any
        // Browser-Notifier that was
        // added to do so through the browserInteractions extension point.
        BrowserNotifier.getInstance().registerBrowser(getSite().getId(), browser);
    } catch (Throwable e) {
        // Open a dialog pointing user at docs for workaround
        HyperlinkMessageDialog dialog = new HyperlinkMessageDialog(UIUtils.getActiveShell(),
                Messages.AbstractPortalBrowserEditor_ErrorTitle, null,
                Messages.AbstractPortalBrowserEditor_ErrorMsg, MessageDialog.ERROR,
                new String[] { IDialogConstants.OK_LABEL }, 0, null) {
            @Override
            protected void openLink(SelectionEvent e) {
                WorkbenchBrowserUtil.launchExternalBrowser(BROWSER_DOCS);
            }
        };
        dialog.open();
    }
}

From source file:com.aptana.radrails.cloud.internal.EndpointDialog.java

License:Open Source License

/**
 * Create contents of the button bar//w  w  w.j a va2  s  .co m
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    getButton(IDialogConstants.OK_ID).setText(Messages.EndpointDialog_LBL_Deploy_button);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}