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

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

Introduction

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

Prototype

public void loadDefault() 

Source Link

Document

Initializes this field editor with the default preference value from the preference store.

Usage

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

License:Open Source License

@Override
protected void createFieldEditors() {
    IntegerFieldEditor iEdit;//from   w  ww  .j ava 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() {
        @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:net.sourceforge.sqlexplorer.preferences.GeneralPreferencePage.java

License:Open Source License

protected void createFieldEditors() {
    IntegerFieldEditor iEdit;/*from w  w w. j  a v  a 2 s  .c  om*/
    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.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.EnvironmentVariablesPreferencePage.java

License:Open Source License

/**
 * Loads the default environment variables.
 *//*from   w w  w. j  ava2  s . co m*/
@Override
protected void performDefaults() {
    for (StringFieldEditor envVariable : envVariables) {
        envVariable.loadDefault();
    }

    super.performDefaults();
}