Example usage for org.eclipse.jface.preference PreferenceStore PreferenceStore

List of usage examples for org.eclipse.jface.preference PreferenceStore PreferenceStore

Introduction

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

Prototype

public PreferenceStore() 

Source Link

Document

Creates an empty preference store.

Usage

From source file:eclipse.spellchecker.preferences.SpellingConfigurationBlock.java

License:Open Source License

/**
 * Creates the encoding field editor./*from w  ww . j  a v a2s  .  c  o m*/
 *
 * @param composite the parent composite
 * @param allControls list with all controls
 * @since 3.3
 */
private void createEncodingFieldEditor(Composite composite, List<Control> allControls) {
    Label filler = new Label(composite, SWT.NONE);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 4;
    filler.setLayoutData(gd);

    Label label = new Label(composite, SWT.NONE);
    label.setText(PreferencesMessages.SpellingPreferencePage_encoding_label);
    label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    allControls.add(label);

    fEncodingEditorParent = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    fEncodingEditorParent.setLayout(layout);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 3;
    fEncodingEditorParent.setLayoutData(gd);

    fEncodingEditor = new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, //$NON-NLS-1$
            fEncodingEditorParent);

    PreferenceStore store = new PreferenceStore();
    String defaultEncoding = ResourcesPlugin.getEncoding();
    store.setDefault(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), defaultEncoding);
    String encoding = getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING);
    if (encoding != null && encoding.length() > 0)
        store.setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), encoding);

    fEncodingEditor.setPreferenceStore(store);

    // Redirect status messages from the field editor to the status change listener
    DialogPage fakePage = new DialogPage() {
        public void createControl(Composite c) {
        }

        @Override
        public void setErrorMessage(String newMessage) {
            StatusInfo status = new StatusInfo();
            if (newMessage != null)
                status.setError(newMessage);
            fEncodingFieldEditorStatus = status;
            fContext.statusChanged(StatusUtil.getMostSevere(
                    new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
        }
    };
    fEncodingEditor.setPage(fakePage);

    fEncodingEditor.load();

    if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0)
        fEncodingEditor.loadDefault();

}

From source file:eu.esdihumboldt.hale.io.gml.ui.InspireDatasetFeedConfigurationPage.java

License:Open Source License

@Override
public void loadPreSelection(IOConfiguration conf) {
    Value createValue = conf.getProviderConfiguration()
            .get(InspireInstanceWriter.PARAM_SPATIAL_DATA_SET_CREATE_FEED);
    Value titleValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_TITLE);
    Value subTitleValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_SUBTITLE);
    Value rightsValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_RIGHTS);
    Value authorNameValue = conf.getProviderConfiguration()
            .get(InspireDatasetFeedWriter.PARAM_FEED_AUTHOR_NAME);
    Value authorMailValue = conf.getProviderConfiguration()
            .get(InspireDatasetFeedWriter.PARAM_FEED_AUTHOR_MAIL);
    Value selfLinkValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_SELFLINK);
    Value gmlLinkValue = conf.getProviderConfiguration().get(InspireDatasetFeedWriter.PARAM_FEED_GMLLINK);

    if (create != null && createValue != null) {
        // there is no other way to set the selection for the button except
        // using the preference store
        IPreferenceStore store = new PreferenceStore();
        store.setValue(create.getPreferenceName(), createValue.as(Boolean.class, false));
        create.setPreferenceStore(store);
        create.load();/*from   w w w .j a  va2  s .c o m*/
        updateStatus();
    }
    if (title != null && titleValue != null) {
        title.setStringValue(titleValue.as(String.class));
    }
    if (subTitle != null && subTitleValue != null) {
        subTitle.setStringValue(subTitleValue.as(String.class));
    }
    if (rights != null && rightsValue != null) {
        rights.setStringValue(rightsValue.as(String.class));
    }
    if (authorName != null && authorNameValue != null) {
        authorName.setStringValue(authorNameValue.as(String.class));
    }
    if (authorMail != null && authorMailValue != null) {
        authorMail.setStringValue(authorMailValue.as(String.class));
    }
    if (selfLink != null && selfLinkValue != null) {
        selfLink.setStringValue(selfLinkValue.as(String.class));
    }
    if (gmlLink != null && gmlLinkValue != null) {
        gmlLink.setStringValue(gmlLinkValue.as(String.class));
    }
}

From source file:eu.esdihumboldt.hale.ui.cache.CachePreferencePage.java

License:Open Source License

/**
 * Constructor./*from ww w.j a v a2s.com*/
 */
public CachePreferencePage() {
    super(GRID);

    IConfigurationService org = OsgiUtils.getService(IConfigurationService.class);
    if (org == null) {
        // if no configuration service is present, fall back to new instance

        // 1. use user prefs, may not have rights to access system prefs
        // 2. no default properties
        // 3. default to system properties
        org = new JavaPreferencesConfigurationService(false, null, true);
    }

    configService = new NamespaceConfigurationServiceDecorator(org,
            Request.class.getPackage().getName().replace(".", DELIMITER), //$NON-NLS-1$
            DELIMITER);

    // TODO implement preference store based on configuration service
    prefs = new PreferenceStore() {

        @Override
        public void load() throws IOException {
            setValue("cache.enabled", configService.getBoolean("hale.cache.enabled", true));
        }

        @Override
        public void save() throws IOException {
            configService.setBoolean("hale.cache.enabled", getBoolean("cache.enabled"));
        }

    };
    try {
        prefs.load();
    } catch (IOException e) {
        // TODO log
    }
    setPreferenceStore(prefs);
}

From source file:ext.org.eclipse.jdt.internal.ui.preferences.formatter.JavaPreview.java

License:Open Source License

public JavaPreview(Map<String, String> workingValues, Composite parent) {
    JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools();
    fPreviewDocument = new Document();
    fWorkingValues = workingValues;/*from  ww  w  .j a  v  a2  s.  c  o  m*/
    tools.setupJavaDocumentPartitioner(fPreviewDocument, IJavaPartitions.JAVA_PARTITIONING);

    PreferenceStore prioritizedSettings = new PreferenceStore();
    prioritizedSettings.setValue(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
    prioritizedSettings.setValue(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
    prioritizedSettings.setValue(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
    prioritizedSettings.setValue(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);

    IPreferenceStore[] chain = { prioritizedSettings, JavaPlugin.getDefault().getCombinedPreferenceStore() };
    fPreferenceStore = new ChainedPreferenceStore(chain);
    fSourceViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER,
            fPreferenceStore);
    fSourceViewer.setEditable(false);
    Cursor arrowCursor = fSourceViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
    fSourceViewer.getTextWidget().setCursor(arrowCursor);

    // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263
    //      fSourceViewer.getTextWidget().setCaret(null);

    fViewerConfiguration = new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore,
            null, IJavaPartitions.JAVA_PARTITIONING, true);
    fSourceViewer.configure(fViewerConfiguration);
    fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));

    fMarginPainter = new MarginPainter(fSourceViewer);
    final RGB rgb = PreferenceConverter.getColor(fPreferenceStore,
            AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
    fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb));
    fSourceViewer.addPainter(fMarginPainter);

    new JavaSourcePreviewerUpdater();
    fSourceViewer.setDocument(fPreviewDocument);
}

From source file:gov.redhawk.ui.port.nxmplot.preferences.Preference.java

License:Open Source License

public static IPreferenceStore createRuntimeStore() {
    return new PreferenceStore() {
        @Override/* w  ww . java  2 s .c o m*/
        public void save() throws IOException {

        }
    };
}

From source file:isabelle.eclipse.ui.preferences.OverlayPreferenceStore.java

License:Open Source License

/**
 * Creates and returns a new overlay preference store.
 *
 * @param parent the parent preference store
 * @param overlayKeys the overlay keys//from ww  w. ja  v a2 s.  c o  m
 */
public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
    fParent = parent;
    fOverlayKeys = overlayKeys;
    fStore = new PreferenceStore();
}

From source file:melnorme.util.swt.jface.preference.OverlayPreferenceStore.java

License:Open Source License

public OverlayPreferenceStore(IPreferenceStore parent, List<OverlayKey> overlayKeys) {
    fParent = parent;/*from   www.ja  v  a 2s  .c  o m*/
    fOverlayKeys = ArrayUtil.createFrom(overlayKeys, OverlayKey.class);
    fStore = new PreferenceStore();
}

From source file:mpj_express_debugger.JavaConnectTab.java

License:Open Source License

/**
 * Update the argument area to show the selected connector's arguments
 */// ww  w . ja va  2s.  co m
private void handleConnectorComboModified() {
    int index = fConnectorCombo.getSelectionIndex();
    if ((index < 0) || (index >= fConnectors.length)) {
        return;
    }
    IVMConnector vm = fConnectors[index];
    if (vm.equals(fConnector)) {
        return; // selection did not change
    }
    fConnector = vm;
    try {
        fArgumentMap = vm.getDefaultArguments();
    } catch (CoreException e) {
        JDIDebugUIPlugin.statusDialog(LauncherMessages.JavaConnectTab_Unable_to_display_connection_arguments__2,
                e.getStatus());
        return;
    }

    // Dispose of any current child widgets in the tab holder area
    Control[] children = fArgumentComposite.getChildren();
    for (int i = 0; i < children.length; i++) {
        children[i].dispose();
    }
    fFieldEditorMap.clear();
    store = new PreferenceStore();

    Iterator keys = vm.getArgumentOrder().iterator();

    while (keys.hasNext()) {
        String key = (String) keys.next();

        arg = (Connector.Argument) fArgumentMap.get(key);

        if (arg instanceof Connector.IntegerArgument) {
            store.setDefault(arg.name(), ((Connector.IntegerArgument) arg).intValue());
            field = new IntegerFieldEditor(arg.name(), getLabel(arg.label()), fArgumentComposite);

        } else if (arg instanceof Connector.SelectedArgument) {
            List choices = ((Connector.SelectedArgument) arg).choices();
            String[][] namesAndValues = new String[choices.size()][2];
            Iterator iter = choices.iterator();
            int count = 0;

            while (iter.hasNext()) {
                String choice = (String) iter.next();
                namesAndValues[count][0] = choice;
                namesAndValues[count][1] = choice;
                count++;
            }
            store.setDefault(arg.name(), arg.value());
            field = new ComboFieldEditor(arg.name(), getLabel(arg.label()), namesAndValues, fArgumentComposite);
        } else if (arg instanceof Connector.StringArgument) {

            store.setDefault(arg.name(), arg.value());

            if (arg.name().equals("confFile")) {

                field = new FileFieldEditor(arg.name(), getLabel(arg.label()), fArgumentComposite);
            } else
                field = new StringFieldEditor(arg.name(), getLabel(arg.label()), fArgumentComposite);
        } else if (arg instanceof Connector.BooleanArgument) {
            store.setDefault(arg.name(), ((Connector.BooleanArgument) arg).booleanValue());
            field = new BooleanFieldEditor(arg.name(), getLabel(arg.label()), fArgumentComposite);
        }
        if (field != null) {
            field.setPreferenceStore(store);
            field.loadDefault();
            field.setPropertyChangeListener(this);
            fFieldEditorMap.put(key, field);
        }
    }
    fArgumentComposite.getParent().getParent().layout();
    fArgumentComposite.layout(true);
    updateLaunchConfigurationDialog();
}

From source file:mpj_express_debugger.JavaMPJConnectTab.java

License:Open Source License

/**
 * Update the argument area to show the selected connector's arguments
 *//*from www  .j  a  va 2  s .c om*/
private void handleConnectorComboModified() {
    int index = fConnectorCombo.getSelectionIndex();
    if ((index < 0) || (index >= fConnectors.length)) {
        return;
    }
    IVMConnector vm = fConnectors[index];
    if (vm.equals(fConnector)) {
        return; // selection did not change
    }
    fConnector = vm;
    try {
        fArgumentMap = vm.getDefaultArguments();
    } catch (CoreException e) {
        JDIDebugUIPlugin.statusDialog(LauncherMessages.JavaConnectTab_Unable_to_display_connection_arguments__2,
                e.getStatus());
        return;
    }

    // Dispose of any current child widgets in the tab holder area
    Control[] children = fArgumentComposite.getChildren();
    for (int i = 0; i < children.length; i++) {
        children[i].dispose();
    }
    fFieldEditorMap.clear();
    PreferenceStore store = new PreferenceStore();
    // create editors
    Iterator keys = vm.getArgumentOrder().iterator();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        Connector.Argument arg = (Connector.Argument) fArgumentMap.get(key);
        FieldEditor field = null;
        if (arg instanceof Connector.IntegerArgument) {
            store.setDefault(arg.name(), ((Connector.IntegerArgument) arg).intValue());
            field = new IntegerFieldEditor(arg.name(), arg.label(), fArgumentComposite);
        } else if (arg instanceof Connector.SelectedArgument) {
            List choices = ((Connector.SelectedArgument) arg).choices();
            String[][] namesAndValues = new String[choices.size()][2];
            Iterator iter = choices.iterator();
            int count = 0;
            while (iter.hasNext()) {
                String choice = (String) iter.next();
                namesAndValues[count][0] = choice;
                namesAndValues[count][1] = choice;
                count++;
            }
            store.setDefault(arg.name(), arg.value());
            field = new ComboFieldEditor(arg.name(), arg.label(), namesAndValues, fArgumentComposite);
        } else if (arg instanceof Connector.StringArgument) {
            store.setDefault(arg.name(), arg.value());
            field = new StringFieldEditor(arg.name(), arg.label(), fArgumentComposite);
        } else if (arg instanceof Connector.BooleanArgument) {
            store.setDefault(arg.name(), ((Connector.BooleanArgument) arg).booleanValue());
            field = new BooleanFieldEditor(arg.name(), arg.label(), fArgumentComposite);
        }
        if (field != null) {
            field.setPreferenceStore(store);
            field.loadDefault();
            field.setPropertyChangeListener(this);
            fFieldEditorMap.put(key, field);
        }
    }
    fArgumentComposite.getParent().getParent().layout();
    fArgumentComposite.layout(true);
    updateLaunchConfigurationDialog();
}

From source file:net.certiv.fluentmark.spell.SpellingConfigurationBlock.java

License:Open Source License

/**
 * Creates the encoding field editor.//from w w w .  ja v  a  2 s .  com
 *
 * @param composite the parent composite
 * @param string list with all controls
 */
private void encodingControl(Composite composite, String text) {

    Label label = new Label(composite, SWT.NONE);
    label.setText(text);
    label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    fEncodingEditorParent = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    fEncodingEditorParent.setLayout(layout);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 3;
    gd.horizontalIndent += SwtUtil.getIndent();
    fEncodingEditorParent.setLayoutData(gd);

    encEditor = new EncodingFieldEditor(SPELLING_USER_DICTIONARY_ENCODING, "", null, fEncodingEditorParent); //$NON-NLS-1$

    PreferenceStore store = new PreferenceStore();
    String defaultEncoding = ResourcesPlugin.getEncoding();
    store.setDefault(SPELLING_USER_DICTIONARY_ENCODING, defaultEncoding);
    String encoding = store.getString(SPELLING_USER_DICTIONARY_ENCODING);
    if (encoding != null && encoding.length() > 0)
        store.setValue(SPELLING_USER_DICTIONARY_ENCODING, encoding);

    encEditor.setPreferenceStore(store);

    // Redirect status messages from the field editor to the status change listener
    DialogPage fakePage = new DialogPage() {

        @Override
        public void createControl(Composite c) {
        }

        @Override
        public void setErrorMessage(String newMessage) {
            StatusInfo status = new StatusInfo();
            if (newMessage != null)
                status.setError(newMessage);
            fEncodingFieldEditorStatus = status;
            fContext.statusChanged(StatusUtil.getMostSevere(
                    new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
        }
    };
    encEditor.setPage(fakePage);
    encEditor.load();
    if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0) {
        encEditor.loadDefault();
    }
}