Example usage for org.eclipse.jface.preference IPreferenceStore getString

List of usage examples for org.eclipse.jface.preference IPreferenceStore getString

Introduction

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

Prototype

String getString(String name);

Source Link

Document

Returns the current value of the string-valued preference with the given name.

Usage

From source file:com.elphel.vdt.core.options.OptionsUtils.java

License:Open Source License

public static boolean isVersionCompatible(final String version, final String contextID,
        IPreferenceStore store) {
    boolean compatible;
    final String versionKey = getVersionKey(contextID);
    if (version == null) {
        compatible = !store.contains(versionKey);
    } else if (store.contains(versionKey)) {
        compatible = version.equals(store.getString(versionKey));
    } else {/*from  ww  w  . ja v a2s  .  c o m*/
        compatible = !store.contains(versionKey);
    }
    return compatible;
}

From source file:com.elphel.vdt.ui.options.SetupOptionsManager.java

License:Open Source License

public static String getCurrentLocation(PackageContext context) {
    String location = pakageLocations.get(context.getName());
    if (location == null) {
        IPreferenceStore store = VerilogPlugin.getDefault().getPreferenceStore();
        location = store.getString(OptionsCore.getLocationPreferenceName(context));
    }//from w  w  w  .  j  a  va  2  s. c o m
    return location;
}

From source file:com.elphel.vdt.ui.preferences.ToolLocationFieldEditor.java

License:Open Source License

static String getLocation(IPreferenceStore store, Tool tool) {
    return store.getString(OptionsCore.getLocationPreferenceName(tool));
}

From source file:com.essiembre.eclipse.rbe.ui.preferences.RBEFormattingPrefPage.java

License:Apache License

@Override
protected Control createContents(Composite parent) {
    IPreferenceStore prefs = getPreferenceStore();
    Composite field = null;//w  w w  . j  a  v  a2s.com
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    // Show generated by comment?
    field = createFieldComposite(composite);
    showGeneratedBy = new Button(field, SWT.CHECK);
    showGeneratedBy.setSelection(prefs.getBoolean(RBEPreferences.SHOW_GENERATOR));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.showGeneratedBy"));

    // Convert unicode to encoded?
    field = createFieldComposite(composite);
    convertUnicodeToEncoded = new Button(field, SWT.CHECK);
    convertUnicodeToEncoded.setSelection(prefs.getBoolean(RBEPreferences.CONVERT_UNICODE_TO_ENCODED));
    convertUnicodeToEncoded.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.convertUnicode"));

    // Use upper case for encoded hexadecimal values?
    field = createFieldComposite(composite, indentPixels);
    convertUnicodeUpperCase = new Button(field, SWT.CHECK);
    convertUnicodeUpperCase.setSelection(prefs.getBoolean(RBEPreferences.CONVERT_UNICODE_TO_ENCODED_UPPER));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.convertUnicode.upper"));

    // Align equal signs?
    field = createFieldComposite(composite);
    alignEqualSigns = new Button(field, SWT.CHECK);
    alignEqualSigns.setSelection(prefs.getBoolean(RBEPreferences.ALIGN_EQUAL_SIGNS));
    alignEqualSigns.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.alignEquals"));

    field = createFieldComposite(composite);
    ensureSpacesAroundEquals = new Button(field, SWT.CHECK);
    ensureSpacesAroundEquals.setSelection(prefs.getBoolean(RBEPreferences.SPACES_AROUND_EQUAL_SIGNS));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.spacesAroundEquals"));

    // Group keys?
    field = createFieldComposite(composite);
    groupKeys = new Button(field, SWT.CHECK);
    groupKeys.setSelection(prefs.getBoolean(RBEPreferences.GROUP_KEYS));
    groupKeys.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.groupKeys"));

    // Group keys by how many level deep?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.levelDeep"));
    groupLevelDeep = new Text(field, SWT.BORDER);
    groupLevelDeep.setText(prefs.getString(RBEPreferences.GROUP_LEVEL_DEPTH));
    groupLevelDeep.setTextLimit(2);
    setWidthInChars(groupLevelDeep, 2);
    groupLevelDeep
            .addKeyListener(new IntTextValidatorKeyListener(RBEPlugin.getString("prefs.levelDeep.error")));

    // How many lines between groups?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.linesBetween"));
    groupLineBreaks = new Text(field, SWT.BORDER);
    groupLineBreaks.setText(prefs.getString(RBEPreferences.GROUP_LINE_BREAKS));
    groupLineBreaks.setTextLimit(2);
    setWidthInChars(groupLineBreaks, 2);
    groupLineBreaks
            .addKeyListener(new IntTextValidatorKeyListener(RBEPlugin.getString("prefs.linesBetween.error")));

    // Align equal signs within groups?
    field = createFieldComposite(composite, indentPixels);
    groupAlignEqualSigns = new Button(field, SWT.CHECK);
    groupAlignEqualSigns.setSelection(prefs.getBoolean(RBEPreferences.GROUP_ALIGN_EQUAL_SIGNS));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.groupAlignEquals"));

    // Wrap lines?
    field = createFieldComposite(composite);
    wrapLines = new Button(field, SWT.CHECK);
    wrapLines.setSelection(prefs.getBoolean(RBEPreferences.WRAP_LINES));
    wrapLines.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.wrapLines"));

    // After how many characters should we wrap?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.wrapLinesChar"));
    wrapCharLimit = new Text(field, SWT.BORDER);
    wrapCharLimit.setText(prefs.getString(RBEPreferences.WRAP_CHAR_LIMIT));
    wrapCharLimit.setTextLimit(4);
    setWidthInChars(wrapCharLimit, 4);
    wrapCharLimit
            .addKeyListener(new IntTextValidatorKeyListener(RBEPlugin.getString("prefs.wrapLinesChar.error")));

    // Align wrapped lines with equal signs?
    field = createFieldComposite(composite, indentPixels);
    wrapAlignEqualSigns = new Button(field, SWT.CHECK);
    wrapAlignEqualSigns.setSelection(prefs.getBoolean(RBEPreferences.WRAP_ALIGN_EQUAL_SIGNS));
    wrapAlignEqualSigns.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.wrapAlignEquals"));

    // How many spaces/tabs to use for indenting?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.wrapIndent"));
    wrapIndentSpaces = new Text(field, SWT.BORDER);
    wrapIndentSpaces.setText(prefs.getString(RBEPreferences.WRAP_INDENT_SPACES));
    wrapIndentSpaces.setTextLimit(2);
    setWidthInChars(wrapIndentSpaces, 2);
    wrapIndentSpaces
            .addKeyListener(new IntTextValidatorKeyListener(RBEPlugin.getString("prefs.wrapIndent.error")));

    // Should we wrap after new line characters
    field = createFieldComposite(composite);
    wrapNewLine = new Button(field, SWT.CHECK);
    wrapNewLine.setSelection(prefs.getBoolean(RBEPreferences.NEW_LINE_NICE));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.newline.nice"));

    // How should new lines appear in properties file
    field = createFieldComposite(composite);
    newLineTypeForce = new Button(field, SWT.CHECK);
    newLineTypeForce.setSelection(prefs.getBoolean(RBEPreferences.FORCE_NEW_LINE_TYPE));
    newLineTypeForce.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    Composite newLineRadioGroup = new Composite(field, SWT.NONE);
    new Label(newLineRadioGroup, SWT.NONE).setText(RBEPlugin.getString("prefs.newline.force"));
    newLineRadioGroup.setLayout(new RowLayout());
    newLineTypes[RBEPreferences.NEW_LINE_UNIX] = new Button(newLineRadioGroup, SWT.RADIO);
    newLineTypes[RBEPreferences.NEW_LINE_UNIX].setText("UNIX (\\n)");
    newLineTypes[RBEPreferences.NEW_LINE_WIN] = new Button(newLineRadioGroup, SWT.RADIO);
    newLineTypes[RBEPreferences.NEW_LINE_WIN].setText("Windows (\\r\\n)");
    newLineTypes[RBEPreferences.NEW_LINE_MAC] = new Button(newLineRadioGroup, SWT.RADIO);
    newLineTypes[RBEPreferences.NEW_LINE_MAC].setText("Mac (\\r)");
    newLineTypes[prefs.getInt(RBEPreferences.NEW_LINE_TYPE)].setSelection(true);

    // Keep empty fields?
    field = createFieldComposite(composite);
    keepEmptyFields = new Button(field, SWT.CHECK);
    keepEmptyFields.setSelection(prefs.getBoolean(RBEPreferences.KEEP_EMPTY_FIELDS));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.keepEmptyFields"));

    refreshEnabledStatuses();

    return composite;
}

From source file:com.essiembre.eclipse.rbe.ui.preferences.RBEGeneralPrefPage.java

License:Apache License

/**
 * @see org.eclipse.jface.preference.PreferencePage
 *         #createContents(org.eclipse.swt.widgets.Composite)
 *///www .j  av  a  2 s.  c  o m
@Override
protected Control createContents(Composite parent) {
    IPreferenceStore prefs = getPreferenceStore();
    Composite field = null;
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    // Key group separator
    field = createFieldComposite(composite);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.groupSep"));
    keyGroupSeparator = new Text(field, SWT.BORDER);
    keyGroupSeparator.setText(prefs.getString(RBEPreferences.KEY_GROUP_SEPARATOR));
    keyGroupSeparator.setTextLimit(2);
    setWidthInChars(keyGroupSeparator, 2);

    // Convert encoded to unicode?
    field = createFieldComposite(composite);
    convertEncodedToUnicode = new Button(field, SWT.CHECK);
    convertEncodedToUnicode.setSelection(prefs.getBoolean(RBEPreferences.CONVERT_ENCODED_TO_UNICODE));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.convertEncoded"));

    // Support "NL" localization structure
    field = createFieldComposite(composite);
    supportNL = new Button(field, SWT.CHECK);
    supportNL.setSelection(prefs.getBoolean(RBEPreferences.SUPPORT_NL));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.supportNL"));

    // Support loading resources from fragment 
    field = createFieldComposite(composite);
    supportFragments = new Button(field, SWT.CHECK);
    supportFragments.setSelection(prefs.getBoolean(RBEPreferences.SUPPORT_FRAGMENTS));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.supportFragments"));

    // Support loading resources from fragment 
    field = createFieldComposite(composite);
    loadOnlyFragmentResources = new Button(field, SWT.CHECK);
    loadOnlyFragmentResources.setSelection(prefs.getBoolean(RBEPreferences.LOAD_ONLY_FRAGMENT_RESOURCES));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.loadOnlyFragmentResources"));

    // Default key tree mode (tree vs flat)
    field = createFieldComposite(composite);
    keyTreeHierarchical = new Button(field, SWT.CHECK);
    keyTreeHierarchical.setSelection(prefs.getBoolean(RBEPreferences.KEY_TREE_HIERARCHICAL));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.keyTree.hierarchical"));

    // Default key tree expand status (expanded vs collapsed)
    field = createFieldComposite(composite);
    keyTreeExpanded = new Button(field, SWT.CHECK);
    keyTreeExpanded.setSelection(prefs.getBoolean(RBEPreferences.KEY_TREE_EXPANDED));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.keyTree.expanded"));

    // Default tab key behaviour in text field
    field = createFieldComposite(composite);
    fieldTabInserts = new Button(field, SWT.CHECK);
    fieldTabInserts.setSelection(prefs.getBoolean(RBEPreferences.FIELD_TAB_INSERTS));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.fieldTabInserts"));

    field = createFieldComposite(composite);
    noTreeInEditor = new Button(field, SWT.CHECK);
    noTreeInEditor.setSelection(prefs.getBoolean(RBEPreferences.NO_TREE_IN_EDITOR));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.noTreeInEditor"));

    field = createFieldComposite(composite);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.minHeight"));
    minHeight = new Text(field, SWT.BORDER);
    minHeight.setText(prefs.getString(RBEPreferences.MIN_HEIGHT));
    minHeight.setTextLimit(3);
    setWidthInChars(minHeight, 3);
    minHeight.addKeyListener(new IntTextValidatorKeyListener(RBEPlugin.getString("prefs.minHeight.error")));

    return composite;
}

From source file:com.essiembre.eclipse.rbe.ui.preferences.RBEReportingPrefPage.java

License:Apache License

@Override
protected Control createContents(Composite parent) {
    IPreferenceStore prefs = getPreferenceStore();
    Composite field = null;//from   ww  w . j  av a 2 s.  co  m
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    new Label(composite, SWT.NONE).setText(RBEPlugin.getString("prefs.perform.intro1"));
    new Label(composite, SWT.NONE).setText(RBEPlugin.getString("prefs.perform.intro2"));
    new Label(composite, SWT.NONE).setText(" ");

    // Report missing values?
    field = createFieldComposite(composite);
    reportMissingVals = new Button(field, SWT.CHECK);
    reportMissingVals.setSelection(prefs.getBoolean(RBEPreferences.REPORT_MISSING_VALUES));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.perform.missingVals"));

    // Report duplicate values?
    field = createFieldComposite(composite);
    reportDuplVals = new Button(field, SWT.CHECK);
    reportDuplVals.setSelection(prefs.getBoolean(RBEPreferences.REPORT_DUPL_VALUES));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.perform.duplVals"));

    // Report similar values?
    field = createFieldComposite(composite);
    reportSimVals = new Button(field, SWT.CHECK);
    reportSimVals.setSelection(prefs.getBoolean(RBEPreferences.REPORT_SIM_VALUES));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.perform.simVals"));
    reportSimVals.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });

    Composite simValModeGroup = new Composite(composite, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginWidth = indentPixels;
    gridLayout.marginHeight = 0;
    gridLayout.verticalSpacing = 0;
    simValModeGroup.setLayout(gridLayout);

    // Report similar values: word count
    reportSimValsMode[0] = new Button(simValModeGroup, SWT.RADIO);
    reportSimValsMode[0].setSelection(prefs.getBoolean(RBEPreferences.REPORT_SIM_VALUES_WORD_COMPARE));
    new Label(simValModeGroup, SWT.NONE).setText(RBEPlugin.getString("prefs.perform.simVals.wordCount"));

    // Report similar values: Levensthein
    reportSimValsMode[1] = new Button(simValModeGroup, SWT.RADIO);
    reportSimValsMode[1].setSelection(prefs.getBoolean(RBEPreferences.REPORT_SIM_VALUES_LEVENSTHEIN));
    new Label(simValModeGroup, SWT.NONE).setText(RBEPlugin.getString("prefs.perform.simVals.levensthein"));

    // Report similar values: precision level
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.perform.simVals.precision"));
    reportSimPrecision = new Text(field, SWT.BORDER);
    reportSimPrecision.setText(prefs.getString(RBEPreferences.REPORT_SIM_VALUES_PRECISION));
    reportSimPrecision.setTextLimit(6);
    setWidthInChars(reportSimPrecision, 6);
    reportSimPrecision.addKeyListener(new DoubleTextValidatorKeyListener(
            RBEPlugin.getString("prefs.perform.simVals.precision.error"), 0, 1));

    refreshEnabledStatuses();

    return composite;
}

From source file:com.generalrobotix.ui.GrxPluginManager.java

License:Open Source License

/**
 * @brief//  w w  w . ja  va  2s  .  c om
 * @param cls
 * @return
 */
public Vector<Action> getItemMenu(final Class<? extends GrxBaseItem> cls) {
    final PluginInfo pi = pinfoMap_.get(cls);
    Vector<Action> menu = pi.menu;
    if (menu != null) {
        dynamicChangeMenu(cls, menu);
        return menu;
    }
    menu = pi.menu = new Vector<Action>();

    // menu item : create
    Action create = new Action() {
        public String getText() {
            return MessageBundle.get("GrxPluginManager.menu.create"); //$NON-NLS-1$
        }

        public void run() {
            GrxBaseItem item = createItem(cls, null);
            itemChange(item, GrxPluginManager.ADD_ITEM);
            setSelectedItem(item, true);
        }
    };
    menu.add(create);

    // menu item : load
    Action load = new Action() {
        public String getText() {
            return MessageBundle.get("GrxPluginManager.menu.load"); //$NON-NLS-1$
        }

        public void run() {
            FileDialog fdlg = new FileDialog(GrxUIPerspectiveFactory.getCurrentShell(), SWT.OPEN);
            String[] fe = { pi.filter };
            fdlg.setFilterExtensions(fe);
            fdlg.setFilterPath(pi.lastDir.getAbsolutePath());
            String fPath = fdlg.open();
            if (fPath != null) {
                File f = new File(fPath);
                GrxBaseItem newItem = loadItem(cls, null, f.getAbsolutePath());
                if (newItem != null) {
                    itemChange(newItem, GrxPluginManager.ADD_ITEM);
                    setSelectedItem(newItem, true);
                    pi.lastDir = f.getParentFile();
                }
            }
        }
    };
    menu.add(load);

    // menu item : clear
    Action clear = new Action() {
        public String getText() {
            return MessageBundle.get("GrxPluginManager.menu.clear"); //$NON-NLS-1$
        }

        public void run() {
            String mes = MessageBundle.get("GrxPluginManager.dialog.message.removeItem"); //$NON-NLS-1$
            mes = NLS.bind(mes, new String[] { GrxPluginManager.this.getItemTitle(cls) });
            if (MessageDialog.openConfirm(null, MessageBundle.get("GrxPluginManager.dialog.title.removeItem"), //$NON-NLS-1$
                    mes)) {
                refuseItemChange();
                removeItems(cls);
                acceptItemChange();
            }
        }
    };
    menu.add(clear);

    // menu item : delete
    Action delete = new Action() {
        public String getText() {
            return MessageBundle.get("GrxPluginManager.menu.delete"); //$NON-NLS-1$
        }

        public void run() {
            String mes = MessageBundle.get("GrxPluginManager.dialog.message.deletePlugin"); //$NON-NLS-1$
            mes = NLS.bind(mes, new String[] { GrxPluginManager.this.getItemTitle(cls) });
            if (MessageDialog.openConfirm(null, MessageBundle.get("GrxPluginManager.dialog.title.deletePlugin"), //$NON-NLS-1$
                    mes))
                deletePlugin(cls);
        }
    };
    menu.add(delete);

    try {
        Method m = cls.getMethod("create", (Class[]) null); //$NON-NLS-1$
        Class<?> c = m.getDeclaringClass();
        create.setEnabled(!(c == GrxBaseItem.class));

        m = cls.getMethod("load", File.class); //$NON-NLS-1$
        c = m.getDeclaringClass();
        load.setEnabled(!(c == GrxBaseItem.class));
        m = cls.getMethod("paste", String.class); //$NON-NLS-1$
        c = m.getDeclaringClass();
        if (c != GrxBaseItem.class) {
            Action paste = new Action() {
                public String getText() {
                    return "paste"; //$NON-NLS-1$
                }

                public void run() {
                    GrxDebugUtil.println("GrxPluginManager.GrxModelItemClass paste Action"); //$NON-NLS-1$
                    // paste();
                }
            };
            paste.setEnabled(!isEmptyClipBord());
            menu.add(paste);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    // if plugin is user then delete menu is enable
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    String itemClassList = store.getString(PreferenceConstants.ITEM + "." + PreferenceConstants.CLASS);
    String[] itemClass = itemClassList.split(PreferenceConstants.SEPARATOR, -1);
    boolean found = false;
    for (int i = 0; i < itemClass.length; i++) {
        if (cls.getName().equals(itemClass[i])) {
            found = true;
            break;
        }
    }
    if (!found)
        delete.setEnabled(true);
    else
        delete.setEnabled(false);
    return menu;
}

From source file:com.generalrobotix.ui.GrxPluginManager.java

License:Open Source License

private void setInitialMode() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    String modes = store.getString(PreferenceConstants.MODE);
    String[] mode = modes.split(PreferenceConstants.SEPARATOR, -1);
    String itemIndexs = store.getString(PreferenceConstants.MODE + "." + PreferenceConstants.ITEMINDEX);
    String[] itemIndex = itemIndexs.split(PreferenceConstants.SEPARATOR, -1);
    String itemClassList = store.getString(PreferenceConstants.ITEM + "." + PreferenceConstants.CLASS);
    String[] itemClass = itemClassList.split(PreferenceConstants.SEPARATOR, -1);
    String itemVisibleList = store.getString(PreferenceConstants.ITEM + "." + PreferenceConstants.VISIBLE);
    String[] itemVisible = itemVisibleList.split(PreferenceConstants.SEPARATOR, -1);
    String userItemClassList = store.getString(PreferenceConstants.USERITEM + "." + PreferenceConstants.CLASS);
    String[] userItemClass = userItemClassList.split(PreferenceConstants.SEPARATOR, -1);
    String userItemPathList = store
            .getString(PreferenceConstants.USERITEM + "." + PreferenceConstants.CLASSPATH);
    String[] userItemPath = userItemPathList.split(PreferenceConstants.SEPARATOR, -1);
    String userItemVisibleList = store
            .getString(PreferenceConstants.USERITEM + "." + PreferenceConstants.VISIBLE);
    String[] userItemVisible = userItemVisibleList.split(PreferenceConstants.SEPARATOR, -1);
    for (int i = 0; i < mode.length; i++) {
        GrxModeInfoItem item = (GrxModeInfoItem) createItem(GrxModeInfoItem.class, mode[i]);
        String[] index = itemIndex[i].split(",", -1);
        for (int j = 0; j < index.length; j++) {
            int k = Integer.valueOf(index[j]);
            if (k < itemClass.length) {
                if (pluginLoader_.existClass(itemClass[k])) {
                    Class<? extends GrxBasePlugin> plugin = registerPlugin(itemClass[k]);
                    if (plugin != null) {
                        PluginInfo pi = pinfoMap_.get(plugin);
                        pi.visible = itemVisible[k].equals("true") ? true : false;
                        pinfoMap_.put(plugin, pi);
                        item.addItemClassList(plugin);
                    }/*from w  w w  .j a va2s.c  o  m*/
                }
            }
        }
        for (int j = 0; j < userItemClass.length; j++) {
            if (!userItemClass[j].equals("")) {
                pluginLoader_.addURL(userItemPath[j]);
                if (pluginLoader_.existClass(userItemClass[j])) {
                    Class<? extends GrxBasePlugin> plugin = registerPlugin(userItemClass[j]);
                    if (plugin != null) {
                        PluginInfo pi = pinfoMap_.get(plugin);
                        pi.visible = userItemVisible[j].equals("true") ? true : false;
                        pinfoMap_.put(plugin, pi);
                        item.addItemClassList(plugin);
                    }
                }
            }
        }
    }
    store.addPropertyChangeListener(this);
    //   ???      //
    GrxModeInfoItem item = (GrxModeInfoItem) getItem(mode[0]);
    setSelectedItem(item, true);
    currentMode_ = item;
}

From source file:com.generalrobotix.ui.GrxPluginManager.java

License:Open Source License

private void versionCheck() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    String version = store.getString(PreferenceConstants.VERSION);
    if (version.equals("") || !version.equals(PreferenceConstants.CURRENT_VERSION)) {
        //  ????????????
        if (version.equals("")) {
            store.setToDefault(PreferenceConstants.PROCESS + "." + PreferenceConstants.ID);
            store.setToDefault(PreferenceConstants.PROCESS + "." + PreferenceConstants.COM);
            store.setToDefault(PreferenceConstants.PROCESS + "." + PreferenceConstants.ARGS);
            store.setToDefault(PreferenceConstants.PROCESS + "." + PreferenceConstants.AUTOSTART);
            store.setToDefault(PreferenceConstants.PROCESS + "." + PreferenceConstants.USEORB);
        }//from ww  w. j  av  a 2s.com
        store.setValue(PreferenceConstants.VERSION, PreferenceConstants.CURRENT_VERSION);
    }
}

From source file:com.generalrobotix.ui.GrxPluginManager.java

License:Open Source License

@SuppressWarnings("unchecked")
public void propertyChange(PropertyChangeEvent event) {
    if (event.getProperty().equals("userItemChange")) {
        String newItemList = (String) event.getNewValue();
        String[] newItems = newItemList.split(PreferenceConstants.SEPARATOR, -1);
        String oldItemList = (String) event.getOldValue();
        String[] oldItems = oldItemList.split(PreferenceConstants.SEPARATOR, -1);
        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        String userItemPathList = store
                .getString(PreferenceConstants.USERITEM + "." + PreferenceConstants.CLASSPATH);
        String[] userItemPath = userItemPathList.split(PreferenceConstants.SEPARATOR, -1);
        String userItemVisibleList = store
                .getString(PreferenceConstants.USERITEM + "." + PreferenceConstants.VISIBLE);
        String[] userItemVisible = userItemVisibleList.split(PreferenceConstants.SEPARATOR, -1);
        Vector<Integer> delList = new Vector<Integer>();
        for (int i = 0; i < oldItems.length; i++) {
            boolean flg = false;
            for (String newItem : newItems) {
                if (newItem.equals(oldItems[i])) {
                    flg = true;/*from   www  . j  av  a2s  .co m*/
                    break;
                }
            }
            if (!flg && !oldItems[i].equals(""))
                delList.add(new Integer(i));

        }

        OrderedHashMap modes = (OrderedHashMap) getItemMap(GrxModeInfoItem.class);
        for (Integer i : delList) {
            Class<? extends GrxBasePlugin> itemClass = null;
            try {
                itemClass = (Class<? extends GrxBasePlugin>) Class.forName(oldItems[i.intValue()], false,
                        pluginLoader_);
            } catch (ClassNotFoundException e) {
                continue;
            }
            if (currentMode_.activeItemClassList_.contains(itemClass))
                removeItems((Class<? extends GrxBaseItem>) itemClass);
            Iterator<GrxModeInfoItem> it = modes.values().iterator();
            while (it.hasNext()) {
                GrxModeInfoItem mode = it.next();
                if (mode.activeItemClassList_.contains(itemClass))
                    mode.activeItemClassList_.remove(itemClass);
            }
        }
        for (int i = 0; i < newItems.length; i++) {
            pluginLoader_.addURL(userItemPath[i]);
            Class<? extends GrxBasePlugin> itemClass = null;
            try {
                itemClass = (Class<? extends GrxBasePlugin>) Class.forName(newItems[i], false, pluginLoader_);
            } catch (ClassNotFoundException e) {
                continue;
            }
            Iterator<GrxModeInfoItem> it = modes.values().iterator();
            while (it.hasNext()) {
                GrxModeInfoItem mode = it.next();
                if (mode.activeItemClassList_.contains(itemClass)) {
                    PluginInfo pi = pinfoMap_.get(itemClass);
                    pi.visible = userItemVisible[i].equals("true") ? true : false;
                    pinfoMap_.put(itemClass, pi);
                } else {
                    if (pluginLoader_.existClass(newItems[i])) {
                        Class<? extends GrxBasePlugin> plugin = registerPlugin(newItems[i]);
                        if (plugin != null) {
                            PluginInfo pi = pinfoMap_.get(plugin);
                            pi.visible = userItemVisible[i].equals("true") ? true : false;
                            pinfoMap_.put(plugin, pi);
                            mode.addItemClassList(plugin);
                        }
                    }
                }
            }
        }
    } else if (event.getProperty().equals(PreferenceConstants.FONT_TABLE)) {
        Activator.getDefault().updateTableFont();
        List<GrxBaseView> list = getViewList();
        for (GrxBaseView v : list) {
            v.updateTableFont();
        }
    } else if (event.getProperty().equals(PreferenceConstants.FONT_EDITER)) {
        Activator.getDefault().updateEditerFont();
        List<GrxBaseView> list = getViewList();
        for (GrxBaseView v : list) {
            v.updateEditerFont();
        }
    }
    itemChange(currentMode_, CHANGE_MODE);
}