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:org.apache.directory.studio.ldapservers.actions.CreateConnectionActionHelper.java

License:Apache License

public static void createLdapBrowserConnection(LdapServer server, Connection connection) {
    // Adding the connection to the connection manager
    ConnectionCorePlugin.getDefault().getConnectionManager().addConnection(connection);

    // Adding the connection to the root connection folder
    ConnectionCorePlugin.getDefault().getConnectionFolderManager().getRootConnectionFolder()
            .addConnectionId(connection.getId());

    // Getting the window, LDAP perspective and current perspective
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IPerspectiveDescriptor ldapPerspective = getLdapPerspective();
    IPerspectiveDescriptor currentPerspective = window.getActivePage().getPerspective();

    // Checking if we are already in the LDAP perspective
    if ((ldapPerspective != null) && (ldapPerspective.equals(currentPerspective))) {
        // As we're already in the LDAP perspective, we only indicate to the user 
        // the name of the connection that has been created
        MessageDialog dialog = new MessageDialog(window.getShell(),
                Messages.getString("CreateConnectionActionHelper.ConnectionCreated"), null, //$NON-NLS-1$
                NLS.bind(Messages.getString("CreateConnectionActionHelper.ConnectionCalledCreated"), //$NON-NLS-1$
                        new String[] { connection.getName() }),
                MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK);
        dialog.open();//from w w  w. j  a v a  2  s .  c o m
    } else {
        // We're not already in the LDAP perspective, we indicate to the user
        // the name of the connection that has been created and we ask him
        // if we wants to switch to the LDAP perspective
        MessageDialog dialog = new MessageDialog(window.getShell(),
                Messages.getString("CreateConnectionActionHelper.ConnectionCreated"), null, //$NON-NLS-1$
                NLS.bind(Messages.getString("CreateConnectionActionHelper.ConnectionCalledCreatedSwitch"), //$NON-NLS-1$
                        new String[] { connection.getName() }), MessageDialog.INFORMATION,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, MessageDialog.OK);
        if (dialog.open() == MessageDialog.OK) {
            // Switching to the LDAP perspective
            window.getActivePage().setPerspective(ldapPerspective);
        }
    }
}

From source file:org.apache.directory.studio.ldapservers.actions.StartAction.java

License:Apache License

/**
 * {@inheritDoc}/*from ww  w  . j  av a 2s  .  c  o  m*/
 */
public void run() {
    if (view != null) {
        // Getting the selection
        StructuredSelection selection = (StructuredSelection) view.getViewer().getSelection();
        if ((!selection.isEmpty()) && (selection.size() == 1)) {
            // Getting the server
            LdapServer server = (LdapServer) selection.getFirstElement();

            LdapServerAdapterExtension ldapServerAdapterExtension = server.getLdapServerAdapterExtension();
            if ((ldapServerAdapterExtension != null) && (ldapServerAdapterExtension.getInstance() != null)) {
                LdapServerAdapter ldapServerAdapter = ldapServerAdapterExtension.getInstance();

                try {

                    // Getting the ports already in use
                    String[] portsAlreadyInUse = ldapServerAdapter.checkPortsBeforeServerStart(server);
                    if ((portsAlreadyInUse == null) || (portsAlreadyInUse.length > 0)) {
                        String title = null;
                        String message = null;

                        if (portsAlreadyInUse.length == 1) {
                            title = Messages.getString("StartAction.PortInUse"); //$NON-NLS-1$
                            message = NLS.bind(Messages.getString("StartAction.PortOfProtocolInUse"), //$NON-NLS-1$
                                    new String[] { portsAlreadyInUse[0] });
                        } else {
                            title = Messages.getString("StartAction.PortsInUse"); //$NON-NLS-1$
                            message = Messages.getString("StartAction.PortsOfProtocolsInUse"); //$NON-NLS-1$
                            for (String portAlreadyInUse : portsAlreadyInUse) {
                                message += "\n    - " + portAlreadyInUse; //$NON-NLS-1$
                            }
                        }

                        message += "\n\n" + Messages.getString("StartAction.Continue"); //$NON-NLS-1$ //$NON-NLS-2$

                        MessageDialog dialog = new MessageDialog(view.getSite().getShell(), title, null,
                                message, MessageDialog.WARNING,
                                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL },
                                MessageDialog.OK);
                        if (dialog.open() == MessageDialog.CANCEL) {
                            return;
                        }
                    }

                    // Creating and scheduling the job to start the server
                    StudioLdapServerJob job = new StudioLdapServerJob(new StartLdapServerRunnable(server));
                    job.schedule();
                } catch (Exception e) {
                    // Showing an error in case no LDAP Server Adapter can be found
                    MessageDialog.openError(view.getSite().getShell(),
                            Messages.getString("StartAction.ErrorStartingServer"), //$NON-NLS-1$
                            NLS.bind(
                                    Messages.getString("StartAction.ServerCanNotBeStarted") + "\n" //$NON-NLS-1$//$NON-NLS-2$
                                            + Messages.getString("StartAction.Cause"), //$NON-NLS-1$
                                    server.getName(), e.getMessage()));
                }
            } else {
                // Showing an error in case no LDAP Server Adapter can be found
                MessageDialog.openError(view.getSite().getShell(),
                        Messages.getString("StartAction.NoLdapServerAdapter"), //$NON-NLS-1$
                        NLS.bind(Messages.getString("StartAction.ServerCanNotBeStarted") + "\n" //$NON-NLS-1$ //$NON-NLS-2$
                                + Messages.getString("StartAction.NoLdapServerAdapterCouldBeFound"), //$NON-NLS-1$
                                server.getName()));
            }
        }
    }
}

From source file:org.apache.directory.studio.ldapservers.apacheds.CreateConnectionAction.java

License:Apache License

/**
 * {@inheritDoc}/*from w w w. ja v  a 2s .  c  o  m*/
 */
public void run(IAction action) {
    if (view != null) {
        // Getting the selection
        StructuredSelection selection = (StructuredSelection) view.getViewer().getSelection();
        if ((!selection.isEmpty()) && (selection.size() == 1)) {
            // Getting the server
            LdapServer server = (LdapServer) selection.getFirstElement();

            // Checking that the server is really an ApacheDS 2.0.0 server
            if (!ExtensionUtils.verifyApacheDs200OrPrintError(server, view)) {
                return;
            }

            // Parsing the 'config.ldif' file
            ConfigBean configuration = null;
            try {
                configuration = ApacheDS200LdapServerAdapter.getServerConfiguration(server).getConfigBean();
            } catch (Exception e) {
                String message = Messages.getString("CreateConnectionAction.UnableReadServerConfiguration") //$NON-NLS-1$
                        + "\n\n" //$NON-NLS-1$
                        + Messages.getString("CreateConnectionAction.FollowingErrorOccurred") + e.getMessage(); //$NON-NLS-1$

                reportErrorReadingServerConfiguration(view, message);
                return;
            }

            // Checking if we could read the 'server.xml' file
            if (configuration == null) {
                reportErrorReadingServerConfiguration(view,
                        Messages.getString("CreateConnectionAction.UnableReadServerConfiguration")); //$NON-NLS-1$
                return;
            }

            // Checking is LDAP and/or LDAPS is/are enabled
            if ((ApacheDS200LdapServerAdapter.isEnableLdap(configuration))
                    || (ApacheDS200LdapServerAdapter.isEnableLdaps(configuration))) {
                // Creating the connection using the helper class
                createConnection(server, configuration);
            } else {
                // LDAP and LDAPS protocols are disabled, we report this error to the user
                MessageDialog dialog = new MessageDialog(view.getSite().getShell(),
                        Messages.getString("CreateConnectionAction.UnableCreateConnection"), null, //$NON-NLS-1$
                        Messages.getString("CreateConnectionAction.LDAPAndLDAPSDisabled"), MessageDialog.ERROR, //$NON-NLS-1$
                        new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK);
                dialog.open();
            }
        }
    }
}

From source file:org.apache.directory.studio.ldapservers.apacheds.CreateConnectionAction.java

License:Apache License

/**
 * Reports to the user an error message indicating the server 
 * configuration could not be read correctly.
 *
 * @param message/*from ww w.j av a 2 s.c o m*/
 *      the message
 */
private void reportErrorReadingServerConfiguration(ServersView view, String message) {
    MessageDialog dialog = new MessageDialog(view.getSite().getShell(),
            Messages.getString("CreateConnectionAction.UnableReadServerConfiguration"), //$NON-NLS-1$
            null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK);
    dialog.open();
}

From source file:org.apache.directory.studio.ldapservers.apacheds.ExtensionUtils.java

License:Apache License

/**
 * Reports to the user an error message indicating the server 
 * configuration could not be read correctly.
 *
 * @param message//from  ww  w. j ava2 s .  c  o m
 *      the message
 */
private static void reportErrorReadingServerConfiguration(ServersView view, String message) {
    MessageDialog dialog = new MessageDialog(view.getSite().getShell(),
            Messages.getString("CreateConnectionAction.UnableReadServerConfiguration"), //$NON-NLS-1$
            null, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK);
    dialog.open();
}

From source file:org.apache.directory.studio.ldapservers.dialogs.DeleteServerDialog.java

License:Apache License

/**
 * Creates a new DeleteServerDialog.//from   w  ww .  ja v  a  2 s  .  c o  m
 * 
 * @param parentShell a shell
 * @param server
 *      the server
 */
public DeleteServerDialog(Shell parentShell, LdapServer server) {
    super(parentShell, Messages.getString("DeleteServerDialog.DeleteServer"), null, null, QUESTION, new String[] //$NON-NLS-1$
    { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, OK);

    if (server == null) {
        throw new IllegalArgumentException();
    }

    this.server = server;
    message = NLS.bind(Messages.getString("DeleteServerDialog.SureToDelete"), server.getName()); //$NON-NLS-1$
}

From source file:org.apache.directory.studio.ldifeditor.dialogs.LdifEntryEditorDialog.java

License:Apache License

protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
    if (entry != null) {
        createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    }/*from w ww .  jav  a2s . c  o  m*/

    getShell().update();
    getShell().layout(true, true);
}

From source file:org.apache.directory.studio.openldap.common.ui.dialogs.PasswordDialog.java

License:Apache License

/**
 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
 *///from  w w  w  .j ava  2 s . c  o  m
protected void createButtonsForButtonBar(Composite parent) {
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

    if (hasCurrentPassword()) {
        updateCurrentPasswordGroup();
    }

    updateNewPasswordGroup();
}

From source file:org.apache.directory.studio.openldap.config.acl.dialogs.OpenLdapAccessLevelDialog.java

License:Apache License

/**
 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
 *///from   w  w w .j  a  v a2s  .c  o  m
protected void createButtonsForButtonBar(Composite parent) {
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:org.apache.directory.studio.openldap.config.acl.dialogs.OpenLdapAclDialog.java

License:Apache License

/**
 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
 *//*ww w  .  j  av  a  2 s  .c  o  m*/
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, FORMAT_BUTTON, "Format", false);
    createButton(parent, CHECK_SYNTAX_BUTTON, "Check Syntax", false);
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}