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

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

Introduction

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

Prototype

public void setPreferenceStore(IPreferenceStore store) 

Source Link

Document

Sets the preference store used by this field editor.

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();/*w w w  . ja  v a 2s .com*/

    // 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 StringFieldEditor createStringField(String preferenceName, String label, Composite composite,
        boolean integerValidation) {
    StringFieldEditor editor;
    if (integerValidation) {
        // String field editor w/ integer validation, we can make this a separate class if we need to.
        editor = new StringFieldEditor(preferenceName, label, composite) {
            @Override//  w w  w  .jav a  2  s  . com
            protected boolean checkState() {
                setErrorMessage(JFaceResources.getString(INTEGER_FIELD_EDITOR_ERROR_STRING));
                Text text = getTextControl();
                if (text == null) {
                    return false;
                }
                String intString = text.getText();
                if (intString.isEmpty()) {
                    clearErrorMessage();
                    return true;
                }
                try {
                    Integer.valueOf(intString).intValue();
                } catch (NumberFormatException nfe) {
                    showErrorMessage();
                }
                return false;
            }
        };
    } else {
        editor = new StringFieldEditor(preferenceName, label, composite);
    }
    editor.setPage(this);
    editor.setPreferenceStore(this.getPreferenceStore());
    editor.fillIntoGrid(composite, NUM_COLUMNS);
    editor.load();
    return editor;
}

From source file:com.liferay.ide.debug.ui.DebugPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    Group group = SWTUtil.createGroup(getFieldEditorParent(), "FreeMarker Debugger", 1); //$NON-NLS-1$
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    group.setLayoutData(gd);//from w ww.j  ava 2s  . c  o  m
    Composite composite = SWTUtil.createComposite(group, 2, 2, GridData.FILL_HORIZONTAL);

    StringFieldEditor passwordEditor = new StringFieldEditor(LiferayDebugCore.PREF_FM_DEBUG_PASSWORD,
            "Password:", composite); //$NON-NLS-1$

    passwordEditor.setPreferenceStore(getPreferenceStore());
    addField(passwordEditor);

    IntegerFieldEditor portEditor = new IntegerFieldEditor(LiferayDebugCore.PREF_FM_DEBUG_PORT, "Port:", //$NON-NLS-1$
            composite);

    portEditor.setPreferenceStore(getPreferenceStore());
    portEditor.setErrorMessage("Port value must be an integer."); //$NON-NLS-1$
    portEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    addField(portEditor);
}

From source file:com.liferay.ide.maven.ui.pref.MavenProjectPreferencePage.java

License:Open Source License

private void createStringEditior(Composite parent, final String label, final String key) {
    final StringFieldEditor stringEditor = new StringFieldEditor(key, label, parent);
    stringEditor.setPreferenceStore(getPreferenceStore());
    addField(stringEditor);/*  w w  w .  ja v a  2  s. com*/
}

From source file:net.mldonkey.g2gui.view.pref.G2GuiPref.java

License:Open Source License

protected void createFieldEditors() {

    Composite composite = getFieldEditorParent();
    StringFieldEditor hostNameField = new StringFieldEditor("hostname", "Hostname", composite);

    hostNameField.setPreferenceStore(this.getPreferenceStore());
    hostNameField.fillIntoGrid(composite, 2);
    addField(hostNameField);//from   w w w.  j  a v  a  2 s.  c  o  m
    hostNameField.load();

    StringFieldEditor portField = new StringFieldEditor("port", "Port", composite);
    portField.setPreferenceStore(this.getPreferenceStore());
    portField.fillIntoGrid(composite, 2);
    addField(portField);
    portField.load();

    StringFieldEditor userNameField = new StringFieldEditor("username", "Username", composite);
    userNameField.setPreferenceStore(this.getPreferenceStore());
    userNameField.fillIntoGrid(composite, 2);
    addField(userNameField);
    userNameField.load();

    StringFieldEditor passwordField = new StringFieldEditor("password", "Password", composite);
    passwordField.getTextControl(composite).setEchoChar('*');
    passwordField.fillIntoGrid(composite, 2);
    passwordField.setPreferenceStore(this.getPreferenceStore());
    addField(passwordField);
    passwordField.load();

    GCJFileFieldEditor executableField = new GCJFileFieldEditor("coreExecutable",
            G2GuiResources.getString("PREF_CORE_EXEC"), true, composite);
    executableField.setPreferenceStore(this.getPreferenceStore());
    addField(executableField);
    executableField.load();

    if (VersionCheck.isWin32()) {
        executableField.setFileExtensions(new String[] { "*.exe;*.bat" });
    } else {
        executableField.setFileExtensions(new String[] { "*" });
    }

    FieldEditor mulitpleInstancesEditor = new BooleanFieldEditor("allowMultipleInstances",
            G2GuiResources.getString("PREF_ALLOW_MULIPLE"), composite);
    mulitpleInstancesEditor.setPreferenceStore(this.getPreferenceStore());
    mulitpleInstancesEditor.fillIntoGrid(composite, 2);
    addField(mulitpleInstancesEditor);
    mulitpleInstancesEditor.load();

    ExtendedBooleanFieldEditor advancedModeEditor = new ExtendedBooleanFieldEditor("advancedMode",
            "Advanced user mode (*)", composite);
    advancedModeEditor.setPreferenceStore(this.getPreferenceStore());
    advancedModeEditor.fillIntoGrid(composite, 2);

    addField(advancedModeEditor);
    advancedModeEditor.load();

    // Make this a little more obvious
    Button b = advancedModeEditor.getChangeControl(composite);
    b.setFont(JFaceResources.getBannerFont());
    b.setToolTipText(G2GuiResources.getString("PREF_ADVANCED_TOOLTIP"));
    b.setForeground(composite.getDisplay().getSystemColor(SWT.COLOR_BLUE));

    ((GridLayout) composite.getLayout()).numColumns = 2;
}

From source file:org.chromium.debug.ui.launcher.ChromiumRemoteTab.java

License:Open Source License

protected static TabElements createBasicTabElements(Composite composite, final Runnable modifyListener,
        PreferenceStore store, Params params) {
    final StringFieldEditor debugHost;
    final IntegerFieldEditor debugPort;
    final BooleanFieldEditor addNetworkConsole;
    {//from  w  ww .  j ava 2s  .co m
        Group connectionGroup = new Group(composite, 0);
        connectionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        connectionGroup.setText(Messages.ChromiumRemoteTab_CONNECTION_GROUP);
        connectionGroup.setLayout(new GridLayout(1, false));

        IPropertyChangeListener propertyModifyListener = new IPropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                modifyListener.run();
            }
        };

        Composite propertiesComp = createInnerComposite(connectionGroup, 2);

        // Host text field
        debugHost = new StringFieldEditor(HOST_FIELD_NAME, Messages.ChromiumRemoteTab_HostLabel,
                propertiesComp);
        debugHost.setPropertyChangeListener(propertyModifyListener);
        debugHost.setPreferenceStore(store);

        // Port text field
        debugPort = new IntegerFieldEditor(PORT_FIELD_NAME, Messages.ChromiumRemoteTab_PortLabel,
                propertiesComp);
        debugPort.setPropertyChangeListener(propertyModifyListener);
        debugPort.setPreferenceStore(store);

        addNetworkConsole = new BooleanFieldEditor(ADD_NETWORK_CONSOLE_FIELD_NAME,
                Messages.ChromiumRemoteTab_ShowDebuggerNetworkCommunication, propertiesComp);
        addNetworkConsole.setPreferenceStore(store);
        addNetworkConsole.setPropertyChangeListener(propertyModifyListener);
    }

    return new TabElements() {
        @Override
        public StringFieldEditor getHost() {
            return debugHost;
        }

        @Override
        public IntegerFieldEditor getPort() {
            return debugPort;
        }

        @Override
        public BooleanFieldEditor getAddNetworkConsole() {
            return addNetworkConsole;
        }
    };
}

From source file:org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.EnvironmentVariablesPreferencePage.java

License:Open Source License

/**
 * Creates and returns a StringFieldEditor object with preferences set to it.
 *
 * @param name Name of the field./*ww w .  j ava 2s . c om*/
 * @param lblText Label text of the field.
 * @param parent Composite object parent of the object.
 *
 * @return The created and configued StringFieldEditor ojbect.
 */
private StringFieldEditor createStringFieldEditor(String name, String lblText, Composite parent) {
    StringFieldEditor sfe = new StringFieldEditor(name, lblText, parent);
    sfe.setPage(this);
    sfe.setPreferenceStore(getPreferenceStore());
    sfe.load();

    return sfe;
}

From source file:org.eclipse.linuxtools.systemtap.ui.systemtapgui.preferences.EnvironmentVariablesPreferencePage.java

License:Open Source License

/**
 * Creates and returns a StringFieldEditor object with preferences set to it.
 *
 * @param name Name of the field.//from   w  ww  .  j a v a 2 s  .c  o m
 * @param lblText Label text of the field.
 * @param parent Composite object parent of the object.
 * 
 * @return The created and configued StringFieldEditor ojbect.
 */
private StringFieldEditor createStringFieldEditor(String name, String lblText, Composite parent) {
    LogManager.logDebug(
            "Start createStringFieldEditor: name-" + name + ", lblText-" + lblText + ", parent-" + parent,
            this);
    StringFieldEditor sfe = new StringFieldEditor(name, lblText, parent);
    sfe.setPage(this);
    sfe.setPreferenceStore(getPreferenceStore());
    sfe.load();

    LogManager.logDebug("End createStringFieldEditor: returnVal-" + sfe, this);
    return sfe;
}

From source file:org.eclipse.umlgen.gen.c.ui.UML2CPropertyPage.java

License:Open Source License

/**
 * Creates the string button field editor for selecting one model element among a set.
 *
 * @param parent/* ww w.j  ava2 s .  c  o  m*/
 *            The parent composite hosting this field editor.
 * @param key
 *            The key to retrieve value inside the preference store.
 * @param label
 *            The label to display before the text field.
 * @return The string button field editor.
 */
protected StringFieldEditor createStringFieldEditor(Composite parent, String key, String label) {
    StringFieldEditor fieldEditor = new StringFieldEditor(key, label, parent);
    fieldEditor.setPage(this);
    fieldEditor.setPreferenceStore(getPreferenceStore());
    return fieldEditor;
}

From source file:org.jboss.tools.feedhenry.ui.cordova.internal.preferences.FeedHenryPreferencesPage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    final Composite parent = getFieldEditorParent();
    parent.setFont(getControl().getFont());

    // FH target URL
    final URLFieldEditor targetUrlField = new URLFieldEditor(PREF_TARGET_URL, LABEL_TARGET_URL, parent);
    targetUrlField.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST);
    targetUrlField.setPreferenceStore(getPreferenceStore());
    targetUrlField.setPage(this);
    targetUrlField.load();//from   ww w .j a  v a2  s .com
    targetUrlField.setPropertyChangeListener(this);
    targetUrlField.getTextControl(parent).setMessage(MESSAGE_TARGET_URL);
    addField(targetUrlField);

    // API key
    final StringFieldEditor apikeyField = new StringFieldEditor(PREF_API_KEY, LABEL_API_KEY, parent);
    apikeyField.setPreferenceStore(getPreferenceStore());
    apikeyField.setPage(this);
    apikeyField.load();
    addField(apikeyField);
}