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.browser.CustomSizeDialog.java

License:Open Source License

private void validate() {
    String message = null;/* w  w w  .  java 2  s .  c  o m*/
    // checks the width first
    String text = fWidthText.getText();
    if (text.trim().length() == 0) {
        message = Messages.WebBrowserViewer_ERR_InvalidWidth;
    } else {
        try {
            int width = Integer.parseInt(text);
            if (width <= 0) {
                throw new NumberFormatException();
            }
        } catch (NumberFormatException e) {
            message = Messages.WebBrowserViewer_ERR_InvalidWidth;
        }
    }
    // then checks the height if width is valid
    if (message == null) {
        text = fHeightText.getText();
        if (text.trim().length() == 0) {
            message = Messages.WebBrowserViewer_ERR_InvalidHeight;
        } else {
            try {
                int height = Integer.parseInt(text);
                if (height <= 0) {
                    throw new NumberFormatException();
                }
            } catch (NumberFormatException e) {
                message = Messages.WebBrowserViewer_ERR_InvalidHeight;
            }
        }
    }
    setErrorMessage(message);
    getButton(IDialogConstants.OK_ID).setEnabled(message == null);
}

From source file:com.aptana.git.ui.dialogs.AddRemoteDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        remoteName = originNameText.getText();
        remoteURI = remoteURIText.getText();
    } else {/*w  w w.  j  av  a 2s  . co  m*/
        remoteName = null;
        remoteURI = null;
    }
    super.buttonPressed(buttonId);
}

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

License:Open Source License

@Override
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
    if (id == IDialogConstants.OK_ID) {
        label = Messages.CommitDialog_CommitButton_Label;
    } else if (id == IDialogConstants.CANCEL_ID) {
        label = Messages.CommitDialog_CloseButton_Label;
    }/*from   w  ww . j  a v a2 s. com*/
    return super.createButton(parent, id, label, defaultButton);
}

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

License:Open Source License

@Override
protected void okPressed() {
    // if there are still unstaged changes don't set return code and close.
    if (unstagedTable.getItemCount() > 0) {
        // disable the buttons until commit is done
        getButton(IDialogConstants.CANCEL_ID).setEnabled(false);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        boolean success = gitRepository.index().commit(getCommitMessage());
        if (success) {
            // commit worked, wipe commit message and staged files in table
            commitMessage.setText(StringUtil.EMPTY);
            stagedTable.removeAll();//from  www.j a  v a  2 s .c  o  m
            // TODO Show some sort of success message?
        }
        // TODO What if the commit failed for some reason?!
        // Re-enable buttons
        getButton(IDialogConstants.CANCEL_ID).setEnabled(true);
        getButton(IDialogConstants.OK_ID).setEnabled(true);
    } else {
        super.okPressed();
    }
}

From source file:com.aptana.ide.core.ui.DiagnosticDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
 *///from   ww  w. j a v a2 s.c o  m
protected void createButtonsForButtonBar(Composite parent) {
    // creates the Copy to Clipboard and Close buttons
    createButton(parent, COPY_ID, Messages.DiagnosticDialog_CopyToClipboard, false);
    createButton(parent, IDialogConstants.OK_ID, Messages.DiagnosticDialog_Close, true);
}

From source file:com.aptana.ide.core.ui.dialogs.AptanaSignInDialog.java

License:Open Source License

/**
 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
 *//*from w  w  w .ja  va 2 s . c  om*/
public void modifyText(ModifyEvent e) {
    setErrorMessage(null);
    getButton(IDialogConstants.OK_ID).setEnabled(true);
}

From source file:com.aptana.ide.core.ui.dialogs.AptanaSignInDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite)
 *///w  w w . ja  v  a2 s. c o m
protected void createButtonsForButtonBar(Composite parent) {
    if (allowAnonymous) {
        createButton(parent, IDialogConstants.IGNORE_ID, Messages.AptanaSignInDialog_LBL_Anonymous, false);
    }
    super.createButtonsForButtonBar(parent);
    getButton(IDialogConstants.OK_ID).setText(Messages.AptanaSignInWidget_LBL_SignIn);
    getButton(IDialogConstants.OK_ID).setEnabled(false);
}

From source file:com.aptana.ide.core.ui.dialogs.AptanaSignInDialog.java

License:Open Source License

private void signIn() {
    if (!validate()) {
        return;//  ww w  .  j  a va 2 s.c o  m
    }

    // fetches and verifies the user
    final User user = new User(username.getText().toLowerCase(), password.getText(), null, null, null, null,
            null);
    try {
        user.setDefaultLocation(new URL(AptanaUser.LOGINS));
        user.setServiceProvider(new RESTServiceProvider());
        user.setRequestBuilder(new UserRequestBuilder());
        AptanaUser.signOut();
        // gets the user location
        user.update();
        if (user.hasLocation()) {
            // gets the user model
            user.update();
            AptanaUser.signIn(username.getText().toLowerCase(), password.getText(), user.getLocation(),
                    user.getId());
            super.okPressed();
            return;
        }
        if (user.getLastServiceErrors() != null && user.getLastServiceErrors().getItems().length > 0) {
            String message = user.getLastServiceErrors().getItems()[0].getMessage();
            if (message.length() > 1) {
                message = message.substring(0, 1).toUpperCase() + message.substring(1, message.length());
            }
            setErrorMessage(message);
        } else if (!OnlineDetectionService.isAvailable(new URL(WHAT_IS_APTANA_ID))) {
            setErrorMessage(Messages.AptanaSignInDialog_Label_ErrorOffline);
        } else {
            setErrorMessage(Messages.AptanaSignInWidget_Label_ErrorVerified);
        }
    } catch (MalformedURLException e) {
        setErrorMessage(Messages.AptanaSignInWidget_Label_ErrorVerified);
    }
    getButton(IDialogConstants.OK_ID).setEnabled(false);
}

From source file:com.aptana.ide.core.ui.dialogs.AptanaSignInDialog.java

License:Open Source License

private boolean validate() {
    if (username.getText().trim().length() == 0) {
        setErrorMessage(Messages.AptanaSignInWidget_LBL_ErrorUsername);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return false;
    }//  w w w. ja  v  a2  s.  c  o m
    if (password.getText().trim().length() == 0) {
        setErrorMessage(Messages.AptanaSignInWidget_LBL_ErrorPassword);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return false;
    }
    setErrorMessage(null);
    getButton(IDialogConstants.OK_ID).setEnabled(true);
    return true;
}

From source file:com.aptana.ide.core.ui.dialogs.InputURLDialog.java

License:Open Source License

protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        value = combo.getText();// w  w w .j av  a 2 s. co  m
        saveMemento();
    } else {
        value = null;
    }
    super.buttonPressed(buttonId);
}