Example usage for org.eclipse.jface.preference StringFieldEditor getStringValue

List of usage examples for org.eclipse.jface.preference StringFieldEditor getStringValue

Introduction

In this page you can find the example usage for org.eclipse.jface.preference StringFieldEditor getStringValue.

Prototype

public String getStringValue() 

Source Link

Document

Returns the field editor's value.

Usage

From source file:com.amazonaws.eclipse.core.ui.preferences.AwsAccountPreferencePage.java

License:Apache License

protected void setUpFieldEditor(String currentAccount, String preferenceKey, Composite parent,
        StringFieldEditor fieldEditor) {
    fieldEditor.setPage(this);
    fieldEditor.setPreferenceStore(this.getPreferenceStore());
    fieldEditor.load();/*from w ww .j a  v  a2  s  .c om*/

    // For backwards compatibility with single-account storage
    if (accountNamesByIdentifier.get(currentAccount) != null
            && accountNamesByIdentifier.get(currentAccount).equals(PreferenceConstants.DEFAULT_ACCOUNT_NAME)
            && (fieldEditor.getStringValue() == null || fieldEditor.getStringValue().length() == 0)) {
        String currentPrefValue = getPreferenceStore().getString(preferenceKey);
        if (ObfuscatingStringFieldEditor.isBase64(currentPrefValue)) {
            currentPrefValue = ObfuscatingStringFieldEditor.decodeString(currentPrefValue);
        }
        fieldEditor.setStringValue(currentPrefValue);
    }

    fieldEditor.fillIntoGrid(parent, LAYOUT_COLUMN_WIDTH);
    fieldEditor.getTextControl(parent).addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            updatePageValidation();
        }
    });
}

From source file:com.blackducksoftware.integration.eclipseplugin.preferences.BlackDuckPreferences.java

License:Apache License

private void storeValues() throws HubIntegrationException {
    final IPreferenceStore prefStore = getPreferenceStore();
    final StringFieldEditor[] editors = hubAuthorizationConfig.getEditors();
    for (final StringFieldEditor editor : editors) {
        prefStore.setValue(editor.getPreferenceName(), editor.getStringValue());
    }/*w ww.j  a  va 2s . com*/
    securePrefService.saveSecurePreference(SecurePreferenceNames.HUB_PASSWORD,
            hubAuthorizationConfig.getHubPasswordField().getText(), true);
    securePrefService.saveSecurePreference(SecurePreferenceNames.PROXY_PASSWORD,
            hubAuthorizationConfig.getProxyPasswordField().getText(), true);
    Activator.getPlugin()
            .updateHubConnection(hubAuthorizationConfig.validateCredentialFields().getConnection());
}

From source file:com.cloudbees.eclipse.ui.internal.preferences.GeneralPreferencePage.java

License:Open Source License

private void createCompositeLogin() {
    Group group = new Group(getFieldEditorParent(), SWT.SHADOW_ETCHED_IN);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    GridLayout gl = new GridLayout(1, false);
    gl.marginLeft = 5;// w ww .j  av a2s  . com
    gl.marginRight = 5;
    gl.marginTop = 5;
    gl.marginBottom = 5;
    gl.horizontalSpacing = 5;

    group.setLayout(gl);

    Composite groupInnerComp = new Composite(group, SWT.NONE);

    groupInnerComp.setLayout(new GridLayout(2, false));
    groupInnerComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    group.setText(Messages.pref_group_login);

    final StringFieldEditor fieldEmail = new StringFieldEditor(PreferenceConstants.P_EMAIL, Messages.pref_email,
            30, groupInnerComp);

    fieldEmail.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addField(fieldEmail);

    final StringFieldEditor fieldPassword = new StringFieldEditor(PreferenceConstants.P_PASSWORD,
            Messages.pref_password, 30, groupInnerComp) {

        @Override
        protected void doLoad() {
            try {
                if (getTextControl() != null) {
                    String value = CloudBeesUIPlugin.getDefault().readP();
                    getTextControl().setText(value);
                    this.oldValue = value;
                }
            } catch (StorageException e) {
                // Ignore StorageException, very likely just
                // "No password provided."
            }
        }

        @Override
        protected void doStore() {
            try {

                CloudBeesUIPlugin.getDefault().storeP(getTextControl().getText());

            } catch (Exception e) {
                CloudBeesUIPlugin.showError(
                        "Saving password failed!\nPossible cause: Eclipse security master password is not set.",
                        e);
            }
        }

        @Override
        protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns);
            getTextControl().setEchoChar('*');
        }
    };

    fieldPassword.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addField(fieldPassword);

    Composite signupAndValidateRow = new Composite(groupInnerComp, SWT.NONE);
    GridData signupRowData = new GridData(GridData.FILL_HORIZONTAL);
    signupRowData.horizontalSpan = 2;

    signupAndValidateRow.setLayoutData(signupRowData);
    GridLayout gl2 = new GridLayout(2, false);
    gl2.marginWidth = 0;
    gl2.marginHeight = 0;
    gl2.marginTop = 5;
    signupAndValidateRow.setLayout(gl2);

    createSignUpLink(signupAndValidateRow);

    Button b = new Button(signupAndValidateRow, SWT.PUSH);
    GridData validateButtonLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    validateButtonLayoutData.widthHint = 75;
    b.setLayoutData(validateButtonLayoutData);

    b.setText(Messages.pref_validate_login);
    b.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            final String email = fieldEmail.getStringValue();
            final String password = fieldPassword.getStringValue();

            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            try {
                dialog.run(true, true, new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor) {
                        try {
                            monitor.beginTask("Validating CloudBees account...", 100); //TODO i18n

                            monitor.subTask("Connecting...");//TODO i18n
                            monitor.worked(10);
                            GrandCentralService gcs = new GrandCentralService();
                            gcs.setAuthInfo(email, password);
                            monitor.worked(20);

                            monitor.subTask("Validating...");//TODO i18n

                            final boolean loginValid = gcs.validateUser(monitor);
                            monitor.worked(50);

                            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                                public void run() {
                                    if (loginValid) {
                                        MessageDialog.openInformation(
                                                CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay()
                                                        .getActiveShell(),
                                                "Validation result", "Validation successful!");//TODO i18n
                                    } else {
                                        MessageDialog.openError(
                                                CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay()
                                                        .getActiveShell(),
                                                "Validation result",
                                                "Validation was not successful!\nWrong email or password?");//TODO i18n
                                    }
                                }

                            });

                            monitor.worked(20);

                        } catch (CloudBeesException e1) {
                            throw new RuntimeException(e1);
                        } finally {
                            monitor.done();
                        }
                    }
                });
            } catch (InvocationTargetException e1) {
                Throwable t1 = e1.getTargetException().getCause() != null ? e1.getTargetException().getCause()
                        : e1.getTargetException();
                Throwable t2 = t1.getCause() != null ? t1.getCause() : null;

                CloudBeesUIPlugin.showError("Failed to validate your account.", t1.getMessage(), t2);
            } catch (InterruptedException e1) {
                CloudBeesUIPlugin.showError("Failed to validate your account.", e1);
            }

        }
    });

}

From source file:com.motorola.studio.android.common.utilities.ui.WidgetsUtil.java

License:Apache License

/**
 * This method test if a StringFieldEditor value is null or empty.
 * //from   w  w w. j ava 2s .c om
 * @param editor The StringFieldEditor
 * @return <code>true</code> if the StringFieldEditor value is null or
 *         empty, <code>false</code> otherwise.
 */
public static boolean isNullOrEmpty(StringFieldEditor editor) {
    return ((editor != null) && isNullOrEmpty(editor.getStringValue()));
}

From source file:com.motorola.studio.android.common.utilities.ui.WidgetsUtil.java

License:Apache License

/**
 * This method test if a StringFieldEditor value contains a invalid
 * character./*  ww w .j  a  v a 2 s. co m*/
 * 
 * @param editor The StringFieldEditor
 * @return <code>true</code> if the StringFieldEditor value contains invalid
 *         character, <code>false</code> otherwise.
 */
public static boolean checkExistInvalidCharacter(StringFieldEditor editor, String invalidChars) {
    for (int i = 0; i < invalidChars.length(); i++) {
        String invalidChar = invalidChars.substring(i, i + 1);
        if (editor.getStringValue().contains(invalidChar)) {
            return true;
        }
    }
    return false;
}

From source file:com.safi.workshop.sqlexplorer.preferences.GeneralPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    IntegerFieldEditor iEdit;/*  www.j a v  a  2s .c o  m*/
    StringFieldEditor sEdit;

    iEdit = new IntegerFieldEditor(IConstants.PRE_ROW_COUNT, Messages.getString("Preview_Max_Rows_3"),
            getFieldEditorParent(), 5);
    iEdit.setValidRange(1, 100);
    iEdit.setErrorMessage(Messages.getString("Accepted_Range_is__1_-_100_1"));
    iEdit.setEmptyStringAllowed(false);
    addField(iEdit);

    iEdit = new IntegerFieldEditor(IConstants.MAX_SQL_ROWS, Messages.getString("SQL_Limit_Rows_2"),
            getFieldEditorParent());
    iEdit.setValidRange(100, 5000);
    iEdit.setErrorMessage(Messages.getString("Accepted_Range_is__100_-_5000_3"));
    addField(iEdit);

    BooleanFieldEditor bfe;
    addField(bfe = new BooleanFieldEditor(IConstants.AUTO_COMMIT,
            Messages.getString("GeneralPreferencePage.AutoCommit_1"), getFieldEditorParent()));
    final Button autoCommitBox = bfe.getCheckbox();
    addField(bfe = new BooleanFieldEditor(IConstants.COMMIT_ON_CLOSE,
            Messages.getString("GeneralPreferencePage.Commit_On_Close_2"), getFieldEditorParent()));
    final Button commitOnCloseBox = bfe.getCheckbox();

    /*
     * final Button autoCommitBox = new Button(getFieldEditorParent(), SWT.CHECK);
     * autoCommitBox.setText(Messages.getString("GeneralPreferencePage.AutoCommit_1"));
     * //$NON-NLS-1$ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
     * gd.horizontalAlignment = GridData.BEGINNING; gd.horizontalSpan = 2;
     * autoCommitBox.setLayoutData(gd); addAccessor(new
     * CheckBoxAccessor(IConstants.AUTO_COMMIT, autoCommitBox));
     * 
     * 
     * final Button commitOnCloseBox = new Button(getFieldEditorParent(), SWT.CHECK);
     * commitOnCloseBox
     * .setText(Messages.getString("GeneralPreferencePage.Commit_On_Close_2"));
     * //$NON-NLS-1$ gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment =
     * GridData.BEGINNING; gd.horizontalSpan = 2; commitOnCloseBox.setLayoutData(gd);
     * addAccessor(new CheckBoxAccessor(IConstants.COMMIT_ON_CLOSE, commitOnCloseBox));
     */

    autoCommitBox.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (autoCommitBox.getSelection())
                commitOnCloseBox.setEnabled(false);
            else
                commitOnCloseBox.setEnabled(true);
        }
    });
    commitOnCloseBox.setEnabled(!autoCommitBox.getSelection());

    addField(new BooleanFieldEditor(IConstants.SQL_ASSIST, Messages.getString(
            "GeneralPreferencePage.Tables_and_columns_auto-completing_assistance._Use_only_with_fast_database_connections_1"),
            getFieldEditorParent()));

    sEdit = new StringFieldEditor(IConstants.SQL_QRY_DELIMITER,
            Messages.getString("Preferences.SQLExplorer.QueryDelimiter"), getFieldEditorParent());
    sEdit.setEmptyStringAllowed(false);
    sEdit.setTextLimit(1);
    sEdit.setErrorMessage(Messages.getString("Preferences.SQLExplorer.QueryDelimiter.Error"));
    addField(sEdit);
    if (sEdit.getStringValue() == null || sEdit.getStringValue().length() == 0)
        sEdit.loadDefault();

    sEdit = new StringFieldEditor(IConstants.SQL_ALT_QRY_DELIMITER,
            Messages.getString("Preferences.SQLExplorer.AltQueryDelimiter"), getFieldEditorParent());
    sEdit.setEmptyStringAllowed(true);
    sEdit.setTextLimit(4);
    addField(sEdit);

    sEdit = new StringFieldEditor(IConstants.SQL_SL_COMMENT,
            Messages.getString("Preferences.SQLExplorer.SLComment"), getFieldEditorParent());
    sEdit.setEmptyStringAllowed(true);
    sEdit.setTextLimit(4);
    sEdit.setErrorMessage(Messages.getString("Preferences.SQLExplorer.SLComment.Error"));
    addField(sEdit);
    if (sEdit.getStringValue() == null)
        sEdit.loadDefault();

    sEdit = new StringFieldEditor(IConstants.SQL_ML_COMMENT_START,
            Messages.getString("Preferences.SQLExplorer.MLCommentStart"), getFieldEditorParent());
    sEdit.setEmptyStringAllowed(true);
    sEdit.setTextLimit(4);
    sEdit.setErrorMessage(Messages.getString("Preferences.SQLExplorer.MLCommentStart.Error"));
    addField(sEdit);
    if (sEdit.getStringValue() == null)
        sEdit.loadDefault();

    sEdit = new StringFieldEditor(IConstants.SQL_ML_COMMENT_END,
            Messages.getString("Preferences.SQLExplorer.MLCommentEnd"), getFieldEditorParent());
    sEdit.setEmptyStringAllowed(true);
    sEdit.setTextLimit(4);
    sEdit.setErrorMessage(Messages.getString("Preferences.SQLExplorer.MLCommentEnd.Error"));
    addField(sEdit);
    if (sEdit.getStringValue() == null)
        sEdit.loadDefault();

    sEdit = new StringFieldEditor(IConstants.SQL_QUOTE_ESCAPE_CHAR,
            Messages.getString("Preferences.SQLExplorer.QuoteEscapeChar"), getFieldEditorParent());
    sEdit.setEmptyStringAllowed(true);
    sEdit.setTextLimit(1);
    sEdit.setErrorMessage(Messages.getString("Preferences.SQLExplorer.QuoteEscapeChar.Error"));
    addField(sEdit);
    if (sEdit.getStringValue() == null)
        sEdit.loadDefault();

    addField(new BooleanFieldEditor(IConstants.WORD_WRAP,
            Messages.getString("Preferences.SQLExplorer.WordWrap"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.AUTO_OPEN_EDITOR,
            Messages.getString("Preferences.SQLExplorer.OpenEditorOnConnection"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.CLEAR_RESULTS_ON_EXECUTE,
            Messages.getString("Preferences.SQLExplorer.ClearResultsOnExecute"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.USE_LONG_CAPTIONS_ON_RESULTS,
            Messages.getString("Preferences.SQLExplorer.UseLongCaptionsOnResults"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.STOP_ON_ERROR,
            Messages.getString("Preferences.SQLExplorer.StopOnError"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.LOG_SUCCESS_MESSAGES,
            Messages.getString("Preferences.SQLExplorer.LogSuccessMessages"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.REQUIRE_SAVE_ON_CLOSE_EDITOR,
            Messages.getString("Preferences.SQLExplorer.RequireSaveOnClose"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.ENABLE_STRUCTURED_COMMENTS,
            Messages.getString("Preferences.SQLExplorer.EnableStructuredComments"), getFieldEditorParent()));

    addField(new BooleanFieldEditor(IConstants.WORD_WRAP,
            Messages.getString("Preferences.SQLExplorer.WordWrap"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.AUTO_OPEN_EDITOR,
            Messages.getString("Preferences.SQLExplorer.OpenEditorOnConnection"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.TREAT_NEW_AS_SCRATCH,
            Messages.getString("Preferences.SQLExplorer.TreatNewAsScratch"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.CLEAR_RESULTS_ON_EXECUTE,
            Messages.getString("Preferences.SQLExplorer.ClearResultsOnExecute"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.USE_LONG_CAPTIONS_ON_RESULTS,
            Messages.getString("Preferences.SQLExplorer.UseLongCaptionsOnResults"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.STOP_ON_ERROR,
            Messages.getString("Preferences.SQLExplorer.StopOnError"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.LOG_SUCCESS_MESSAGES,
            Messages.getString("Preferences.SQLExplorer.LogSuccessMessages"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.LOG_SQL_HISTORY,
            Messages.getString("Preferences.SQLExplorer.LogSQLHistory"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.REQUIRE_SAVE_ON_CLOSE_EDITOR,
            Messages.getString("Preferences.SQLExplorer.RequireSaveOnClose"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.ENABLE_STRUCTURED_COMMENTS,
            Messages.getString("Preferences.SQLExplorer.EnableStructuredComments"), getFieldEditorParent()));

    final String[][] DEBUG_LEVEL_VALUES = new String[][] {
            { Messages.getString("Preferences.SQLExplorer.DebugLevelOff"), IConstants.QUERY_DEBUG_OFF },
            { Messages.getString("Preferences.SQLExplorer.DebugLevelFailed"), IConstants.QUERY_DEBUG_FAILED },
            { Messages.getString("Preferences.SQLExplorer.DebugLevelAll"), IConstants.QUERY_DEBUG_ALL } };
    ComboFieldEditor combo = new ComboFieldEditor(IConstants.QUERY_DEBUG_LOG_LEVEL,
            Messages.getString("Preferences.SQLExplorer.QueryDebugLog"), DEBUG_LEVEL_VALUES,
            getFieldEditorParent());
    addField(combo);
}

From source file:com.siemens.ct.mp3m.ui.editors.id3.Id3TagPage.java

License:Open Source License

private void writeFieldsToTag() {
    for (StringFieldEditor stringEditor : fieldEditors) {
        if (stringEditor.getLabelText().equals(Messages.getString("Id3TagPage.Title_Label") + ":")) { //$NON-NLS-1$ //$NON-NLS-2$
            id3TagInfo.setTitle(stringEditor.getStringValue());
        } else if (stringEditor.getLabelText().equals(Messages.getString("Id3TagPage.Album_Label") + ":")) { //$NON-NLS-1$ //$NON-NLS-2$
            id3TagInfo.setAlbum(stringEditor.getStringValue());
        } else if (stringEditor.getLabelText().equals(Messages.getString("Id3TagPage.Artist_Label") + ":")) { //$NON-NLS-1$ //$NON-NLS-2$
            id3TagInfo.setArtist(stringEditor.getStringValue());
        } else if (stringEditor.getLabelText().equals(Messages.getString("Id3TagPage.Track_Label") + ":")) { //$NON-NLS-1$ //$NON-NLS-2$
            id3TagInfo.setTrack(stringEditor.getStringValue());
        } else if (stringEditor.getLabelText().equals(Messages.getString("Id3TagPage.Year_Label") + ":")) { //$NON-NLS-1$ //$NON-NLS-2$
            id3TagInfo.setYear(stringEditor.getStringValue());
        } else if (stringEditor.getLabelText().equals(Messages.getString("Id3TagPage.Comment_Label") + ":")) { //$NON-NLS-1$ //$NON-NLS-2$
            id3TagInfo.setComment(stringEditor.getStringValue());
        } else if (stringEditor.getLabelText().equals(Messages.getString("Id3TagPage.Genre_Label") + ":")) { //$NON-NLS-1$ //$NON-NLS-2$
            id3TagInfo.setGenre(stringEditor.getStringValue());
        }/*from   www . j a  va  2  s . c om*/
    }
}

From source file:net.sourceforge.sqlexplorer.preferences.GeneralPreferencePage.java

License:Open Source License

protected void createFieldEditors() {
    IntegerFieldEditor iEdit;//from ww  w .  ja  va  2 s . c o m
    StringFieldEditor sEdit;

    iEdit = new IntegerFieldEditor(IConstants.PRE_ROW_COUNT, Messages.getString("Preview_Max_Rows_3"),
            getFieldEditorParent(), 5);
    iEdit.setValidRange(1, 100);
    iEdit.setErrorMessage(Messages.getString("Accepted_Range_is__1_-_100_1"));
    iEdit.setEmptyStringAllowed(false);
    addField(iEdit);

    iEdit = new IntegerFieldEditor(IConstants.MAX_SQL_ROWS, Messages.getString("SQL_Limit_Rows_2"),
            getFieldEditorParent());
    iEdit.setValidRange(100, 5000);
    iEdit.setErrorMessage(Messages.getString("Accepted_Range_is__100_-_5000_3"));
    addField(iEdit);

    BooleanFieldEditor bfe;
    addField(bfe = new BooleanFieldEditor(IConstants.AUTO_COMMIT,
            Messages.getString("GeneralPreferencePage.AutoCommit_1"), getFieldEditorParent()));
    final Button autoCommitBox = bfe.getCheckbox();
    addField(bfe = new BooleanFieldEditor(IConstants.COMMIT_ON_CLOSE,
            Messages.getString("GeneralPreferencePage.Commit_On_Close_2"), getFieldEditorParent()));
    final Button commitOnCloseBox = bfe.getCheckbox();

    /*
    final Button autoCommitBox = new Button(getFieldEditorParent(), SWT.CHECK);
    autoCommitBox.setText(Messages.getString("GeneralPreferencePage.AutoCommit_1")); //$NON-NLS-1$
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    autoCommitBox.setLayoutData(gd);
    addAccessor(new CheckBoxAccessor(IConstants.AUTO_COMMIT, autoCommitBox));
            
            
    final Button commitOnCloseBox = new Button(getFieldEditorParent(), SWT.CHECK);
    commitOnCloseBox.setText(Messages.getString("GeneralPreferencePage.Commit_On_Close_2")); //$NON-NLS-1$
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    commitOnCloseBox.setLayoutData(gd);
    addAccessor(new CheckBoxAccessor(IConstants.COMMIT_ON_CLOSE, commitOnCloseBox));
    */

    autoCommitBox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (autoCommitBox.getSelection())
                commitOnCloseBox.setEnabled(false);
            else
                commitOnCloseBox.setEnabled(true);
        }
    });
    commitOnCloseBox.setEnabled(!autoCommitBox.getSelection());

    addField(new BooleanFieldEditor(IConstants.SQL_ASSIST, Messages.getString(
            "GeneralPreferencePage.Tables_and_columns_auto-completing_assistance._Use_only_with_fast_database_connections_1"),
            getFieldEditorParent()));

    sEdit = new StringFieldEditor(IConstants.SQL_QRY_DELIMITER,
            Messages.getString("Preferences.SQLExplorer.QueryDelimiter"), getFieldEditorParent());
    sEdit.setEmptyStringAllowed(false);
    sEdit.setTextLimit(1);
    sEdit.setErrorMessage(Messages.getString("Preferences.SQLExplorer.QueryDelimiter.Error"));
    addField(sEdit);
    if (sEdit.getStringValue() == null || sEdit.getStringValue().length() == 0)
        sEdit.loadDefault();

    sEdit = new StringFieldEditor(IConstants.SQL_ALT_QRY_DELIMITER,
            Messages.getString("Preferences.SQLExplorer.AltQueryDelimiter"), getFieldEditorParent());
    sEdit.setEmptyStringAllowed(true);
    sEdit.setTextLimit(4);
    addField(sEdit);

    sEdit = new StringFieldEditor(IConstants.SQL_COMMENT_DELIMITER,
            Messages.getString("Preferences.SQLExplorer.CommentDelimiter"), getFieldEditorParent());
    sEdit.setEmptyStringAllowed(false);
    sEdit.setTextLimit(4);
    sEdit.setErrorMessage(Messages.getString("Preferences.SQLExplorer.CommentDelimiter.Error"));
    addField(sEdit);
    if (sEdit.getStringValue() == null || sEdit.getStringValue().length() == 0)
        sEdit.loadDefault();

    addField(new BooleanFieldEditor(IConstants.WORD_WRAP,
            Messages.getString("Preferences.SQLExplorer.WordWrap"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.AUTO_OPEN_EDITOR,
            Messages.getString("Preferences.SQLExplorer.OpenEditorOnConnection"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.CLEAR_RESULTS_ON_EXECUTE,
            Messages.getString("Preferences.SQLExplorer.ClearResultsOnExecute"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.USE_LONG_CAPTIONS_ON_RESULTS,
            Messages.getString("Preferences.SQLExplorer.UseLongCaptionsOnResults"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.STOP_ON_ERROR,
            Messages.getString("Preferences.SQLExplorer.StopOnError"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.LOG_SUCCESS_MESSAGES,
            Messages.getString("Preferences.SQLExplorer.LogSuccessMessages"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.REQUIRE_SAVE_ON_CLOSE_EDITOR,
            Messages.getString("Preferences.SQLExplorer.RequireSaveOnClose"), getFieldEditorParent()));
    addField(new BooleanFieldEditor(IConstants.ENABLE_STRUCTURED_COMMENTS,
            Messages.getString("Preferences.SQLExplorer.EnableStructuredComments"), getFieldEditorParent()));

    final String[][] DEBUG_LEVEL_VALUES = new String[][] {
            { Messages.getString("Preferences.SQLExplorer.DebugLevelOff"), IConstants.QUERY_DEBUG_OFF },
            { Messages.getString("Preferences.SQLExplorer.DebugLevelFailed"), IConstants.QUERY_DEBUG_FAILED },
            { Messages.getString("Preferences.SQLExplorer.DebugLevelAll"), IConstants.QUERY_DEBUG_ALL } };
    ComboFieldEditor combo = new ComboFieldEditor(IConstants.QUERY_DEBUG_LOG_LEVEL,
            Messages.getString("Preferences.SQLExplorer.QueryDebugLog"), DEBUG_LEVEL_VALUES,
            getFieldEditorParent());
    addField(combo);
}

From source file:org.ebix.umm.uml2text.preferences.UmmStereotypeProjectPropertiesPage.java

License:Open Source License

@Override
public boolean performOk() {
    try {/*  w w  w.  j  ava2 s.  com*/
        IAdaptable _element = this.getElement();
        final IProject project = ((IProject) _element);
        InputOutput.<String>println(("in performOk of " + project));
        final ProjectScope projectScope = new ProjectScope(project);
        final IEclipsePreferences projectNode = projectScope.getNode("org.ebix.umm.uml2text");
        boolean _notEquals = (!Objects.equal(projectNode, null));
        if (_notEquals) {
            Collection<StringFieldEditor> _values = this.editors.values();
            for (final StringFieldEditor st_editor : _values) {
                String _labelText = st_editor.getLabelText();
                String _stringValue = st_editor.getStringValue();
                projectNode.put(_labelText, _stringValue);
            }
            projectNode.flush();
        }
        return true;
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}

From source file:org.eclipse.cdt.dsf.gdb.internal.ui.preferences.GdbDebugPreferencePage.java

License:Open Source License

private void handleBrowseButtonSelected(final String dialogTitle, final StringFieldEditor stringFieldEditor) {
    FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
    dialog.setText(dialogTitle);/*from  ww w.  j  av  a  2 s  .com*/
    String gdbCommand = stringFieldEditor.getStringValue().trim();
    int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator);
    if (lastSeparatorIndex != -1) {
        dialog.setFilterPath(gdbCommand.substring(0, lastSeparatorIndex));
    }
    String res = dialog.open();
    if (res == null) {
        return;
    }
    stringFieldEditor.setStringValue(res);
}