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:com.google.dart.tools.ui.internal.cleanup.preference.DartPreview.java

License:Open Source License

public DartPreview(Map<String, String> workingValues, Composite parent) {
    DartTextTools tools = DartToolsPlugin.getDefault().getDartTextTools();
    fPreviewDocument = new Document();
    fWorkingValues = workingValues;/*from   w ww . ja va  2s .c o  m*/
    tools.setupDartDocumentPartitioner(fPreviewDocument, DartPartitions.DART_PARTITIONING);

    PreferenceStore prioritizedSettings = new PreferenceStore();
    //    prioritizedSettings.setValue(DartCore.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,
            DartToolsPlugin.getDefault().getCombinedPreferenceStore() };
    fPreferenceStore = new ChainedPreferenceStore(chain);
    fSourceViewer = new DartSourceViewer(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 SimpleDartSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore,
            null, DartPartitions.DART_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:com.hudson.hibernatesynchronizer.properties.EditProjectTemplate.java

License:GNU General Public License

protected Control createDialogArea(Composite parent) {

    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout(3, false);
    composite.setLayout(layout);/*from www  . java2s.c  o  m*/

    try {
        Label label = new Label(composite, SWT.NULL);
        label.setText("Template:");
        label = new Label(composite, SWT.NULL);
        label.setText(projectTemplate.getTemplate().getName());
        GridData gd = new GridData();
        gd.horizontalSpan = 2;
        gd.grabExcessHorizontalSpace = true;
        label.setLayoutData(gd);

        label = new Label(composite, SWT.NULL);
        gd = new GridData();
        gd.horizontalSpan = 3;
        gd.grabExcessHorizontalSpace = true;
        label.setLayoutData(gd);
        label.setText("Tip: you can use Velocity variables in the fields below.");

        resourceNameLBL = new Label(composite, SWT.NULL);
        if (projectTemplate.getTemplate().isJavaClass())
            resourceNameLBL.setText("Name:");
        else
            resourceNameLBL.setText("Name:");
        nameTXT = new Text(composite, SWT.BORDER);
        nameTXT.setText(projectTemplate.getName());
        gd = new GridData();
        gd.horizontalSpan = 2;
        gd.widthHint = 200;
        gd.grabExcessHorizontalSpace = true;
        nameTXT.setLayoutData(gd);

        locationLBL = new Label(composite, SWT.NULL);
        if (projectTemplate.getTemplate().isJavaClass())
            locationLBL.setText("Package:");
        else
            locationLBL.setText("Location:");
        locationTXT = new Text(composite, SWT.BORDER);
        locationTXT.setText(projectTemplate.getLocation());
        gd = new GridData();
        gd.widthHint = 200;
        locationTXT.setLayoutData(gd);
        locationSearchBTN = new Button(composite, SWT.NATIVE);
        locationSearchBTN.setText("Browse");
        gd = new GridData();
        locationSearchBTN.setLayoutData(gd);
        locationSearchBTN.addSelectionListener(new SelectionListener() {
            public void widgetSelected(SelectionEvent e) {
                try {
                    if (projectTemplate.getTemplate().isJavaClass()) {
                        IJavaProject javaProject = JavaCore.create(project);
                        SelectionDialog sd = JavaUI.createPackageDialog(getShell(), javaProject,
                                IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS);
                        sd.open();
                        Object[] objects = sd.getResult();
                        if (null != objects && objects.length > 0) {
                            PackageFragment pf = (PackageFragment) objects[0];
                            locationTXT.setText(pf.getElementName());
                        }
                    } else {
                        ContainerSelectionDialog d = new ContainerSelectionDialog(getShell(), project, false,
                                "Resource location selection");
                        d.open();
                        Object[] arr = d.getResult();
                        StringBuffer sb = new StringBuffer();
                        for (int i = 0; i < arr.length; i++) {
                            Path path = (Path) arr[i];
                            for (int j = 0; j < path.segments().length; j++) {
                                if (j == 0) {
                                    if (!path.segments()[j].equals(project.getName())) {
                                        MessageDialog.openError(getParentShell(), "Location Error",
                                                "You may only choose a location in the current project");
                                        return;
                                    }
                                } else {
                                    sb.append("/");
                                    sb.append(path.segments()[j]);
                                }
                            }
                            locationTXT.setText(sb.toString());
                        }
                    }
                } catch (Exception exc) {
                    exc.printStackTrace();
                }
            }

            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        MessageDialog.openError(parent.getShell(), "An error has occured", e.getMessage());
    }

    IPreferenceStore store = new PreferenceStore();
    store.setValue("TemplateOverwrite", projectTemplate.shouldOverride());
    new Label(composite, SWT.NULL);
    Composite subComp = new Composite(composite, SWT.NULL);
    overwrite = new BooleanFieldEditor("TemplateOverwrite", "Overwrite if a resource/class already exists",
            subComp);
    overwrite.setPreferenceStore(store);
    overwrite.load();

    return parent;
}

From source file:com.hudson.hibernatesynchronizer.properties.HibernateProperties.java

License:Apache License

public IPreferenceStore getLocalPreferenceStore() {
    if (null == preferenceStore) {
        preferenceStore = new PreferenceStore();
        try {//from  ww  w  . ja v a2 s. c o  m
            String s = Plugin.getProperty(getElement(), Constants.PROP_GENERATION_ENABLED);
            if (null == s)
                s = Boolean.TRUE.toString();
            preferenceStore.setValue(Constants.PROP_GENERATION_ENABLED, s);
            s = Plugin.getProperty(getElement(), Constants.PROP_BASE_VO_PACKAGE_STYLE);
            if (null == s)
                s = Constants.PROP_VALUE_RELATIVE;
            preferenceStore.setValue(Constants.PROP_BASE_VO_PACKAGE_STYLE, s);
            basePackageStyleSelection = s;
            s = Plugin.getProperty(getElement(), Constants.PROP_GENERATION_VALUE_OBJECT_ENABLED);
            if (null == s)
                s = Boolean.TRUE.toString();
            preferenceStore.setValue(Constants.PROP_GENERATION_VALUE_OBJECT_ENABLED, s);
            s = Plugin.getProperty(getElement(), Constants.PROP_DAO_PACKAGE_STYLE);
            if (null == s)
                s = Constants.PROP_VALUE_RELATIVE;
            preferenceStore.setValue(Constants.PROP_DAO_PACKAGE_STYLE, s);
            managerPackageStyleSelection = s;
            s = Plugin.getProperty(getElement(), Constants.PROP_GENERATION_DAO_ENABLED);
            if (null == s)
                s = Boolean.TRUE.toString();
            preferenceStore.setValue(Constants.PROP_GENERATION_DAO_ENABLED, s);
            s = Plugin.getProperty(getElement(), Constants.PROP_BASE_DAO_USE_BASE_PACKAGE);
            if (null == s)
                s = Boolean.TRUE.toString();
            preferenceStore.setValue(Constants.PROP_BASE_DAO_USE_BASE_PACKAGE, s);
            s = Plugin.getProperty(getElement(), Constants.PROP_BASE_DAO_PACKAGE_STYLE);
            if (null == s)
                s = Constants.PROP_VALUE_SAME;
            preferenceStore.setValue(Constants.PROP_BASE_DAO_PACKAGE_STYLE, s);
            baseManagerPackageStyleSelection = s;
            s = Plugin.getProperty(getElement(), Constants.PROP_USE_CUSTOM_ROOT_DAO);
            if (null == s)
                s = Boolean.FALSE.toString();
            preferenceStore.setValue(Constants.PROP_USE_CUSTOM_ROOT_DAO, s);
            s = Plugin.getProperty(getElement(), Constants.PROP_BASE_DAO_EXCEPTION);
        } catch (Exception e) {
        }
    }
    return preferenceStore;
}

From source file:com.marvinformatics.formatter.groovy.GroovyFormatter.java

License:Apache License

private static PreferenceStore createPreferences(final Map<String, String> options) {
    final PreferenceStore preferences = new PreferenceStore();
    options.forEach(preferences::putValue);
    return preferences;
}

From source file:com.matlab.eclipse.meditor.dialogs.ExportDialog.java

License:Open Source License

public ExportDialog(Shell parentShell) {
    super(parentShell);
    this.preferences = Activator.getDefault().getPreferenceStore();
    if (this.preferences == null) {
        this.preferences = new PreferenceStore();
    }//from w  w  w  .j  a v  a 2 s . c o  m
    this.exportProperties = new Properties();
    this.loadedProperties = null;
}

From source file:com.python.pydev.analysis.system_info_builder.InterpreterInfoBuilderTest.java

License:Open Source License

public void testInterpreterInfoBuilder() throws Exception {
    Collection<String> pythonpath = new ArrayList<String>();
    pythonpath.add(libDir.toString());/*from   w w w . j  a v  a2  s. co  m*/

    final InterpreterInfo info = new InterpreterInfo("2.6", TestDependent.PYTHON_EXE, pythonpath);

    IPreferenceStore preferences = new PreferenceStore();
    final PythonInterpreterManager manager = new PythonInterpreterManager(preferences);
    PydevPlugin.setPythonInterpreterManager(manager);
    manager.setInfos(new IInterpreterInfo[] { info }, null, null);

    final AdditionalSystemInterpreterInfo additionalInfo = new AdditionalSystemInterpreterInfo(manager,
            info.getExecutableOrJar());
    AdditionalSystemInterpreterInfo.setAdditionalSystemInfo(manager, info.getExecutableOrJar(), additionalInfo);

    //Don't load it (otherwise it'll get the 'proper' info).
    //AdditionalSystemInterpreterInfo.loadAdditionalSystemInfo(manager, info.getExecutableOrJar());

    final ISystemModulesManager modulesManager = info.getModulesManager();
    assertEquals(0, modulesManager.getSize(false));
    assertEquals(0, additionalInfo.getAllTokens().size());

    InterpreterInfoBuilder builder = new InterpreterInfoBuilder();
    builder.syncInfoToPythonPath(null, info);

    int size = modulesManager.getSize(false);
    if (size != 3) {
        fail("Expected size = 3, found: " + size);
    }

    try {
        AbstractAdditionalDependencyInfo additionalSystemInfo = AdditionalSystemInterpreterInfo
                .getAdditionalSystemInfo(manager, manager.getInterpreterInfos()[0].getExecutableOrJar(), true);
        if (additionalInfo != additionalSystemInfo) {
            throw new RuntimeException("Expecting it to be the same instance.");
        }
    } catch (MisconfigurationException e) {
        throw new RuntimeException(e);
    }

    Collection<IInfo> allTokens = additionalInfo.getAllTokens();
    size = allTokens.size();
    if (size != 3) {
        FastStringBuffer buf = new FastStringBuffer();
        for (IInfo i : allTokens) {
            buf.append(i.toString());
        }
        fail("Expected size = 3, found: " + size + "\nTokens: " + buf);
    }
}

From source file:com.python.pydev.codecompletion.parameter.ParameterCompletionTest.java

License:Open Source License

@Override
public void setUp() throws Exception {
    super.setUp();
    CompiledModule.COMPILED_MODULES_ENABLED = false;

    useOriginalRequestCompl = true;//from  ww w.j ava  2s  .  com
    participant = new CtxParticipant();

    ExtensionHelper.testingParticipants = new HashMap<String, List<Object>>();
    ArrayList<Object> participants = new ArrayList<Object>(); /*IPyDevCompletionParticipant*/
    participants.add(participant);
    ExtensionHelper.testingParticipants.put(ExtensionHelper.PYDEV_COMPLETION, participants);

    codeCompletion = new PyCodeCompletion();
    this.restorePythonPath(false);

    final IPreferenceStore prefs = new PreferenceStore();
    PyCodeCompletionPreferencesPage.getPreferencesForTests = new ICallback<IPreferenceStore, Object>() {

        @Override
        public IPreferenceStore call(Object arg) {
            return prefs;
        }
    };

    prefs.setValue(PyCodeCompletionPreferencesPage.MATCH_BY_SUBSTRING_IN_CODE_COMPLETION, false);

}

From source file:com.vectrace.MercurialEclipse.repository.RepoPropertiesPage.java

License:Open Source License

public RepoPropertiesPage() {
    super(GRID);//from  w w w . j a  v  a  2  s  .co m
    PreferenceStore store = new PreferenceStore() {
        @Override
        public void save() throws IOException {
            internalSave();
        }
    };
    setPreferenceStore(store);
}

From source file:de.walware.ecommons.preferences.ui.OverlayPreferenceStore.java

License:Open Source License

public OverlayPreferenceStore(final IPreferenceStore parent, final OverlayStorePreference[] PreferenceKeys) {
    fParent = parent;/*  w  ww  . j  a v a 2s. c om*/
    fPreferenceKeys = PreferenceKeys;
    fStore = new PreferenceStore();
}

From source file:descent.internal.ui.preferences.formatter.JavaPreview.java

License:Open Source License

/**
 * Create a new Java preview/* w w  w.  j a  va2s.  c o m*/
 * @param workingValues
 * @param parent
 */
public JavaPreview(Map workingValues, Composite parent) {
    JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools();
    fPreviewDocument = new Document();
    fWorkingValues = workingValues;
    tools.setupJavaDocumentPartitioner(fPreviewDocument, IJavaPartitions.JAVA_PARTITIONING);

    PreferenceStore prioritizedSettings = new PreferenceStore();
    prioritizedSettings.setValue(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_x);
    prioritizedSettings.setValue(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_x);
    prioritizedSettings.setValue(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_x);
    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.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore);
    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);
}