org.eclipse.jface.preference.ListEditor Java Examples

The following examples show how to use org.eclipse.jface.preference.ListEditor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeCompletionPreferencesPage.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void createFieldEditors() {
    Composite p = getFieldEditorParent();

    addField(new IntegerFieldEditor(
            PyCodeCompletionPreferences.CHARS_FOR_CTX_INSENSITIVE_MODULES_COMPLETION,
            "Number of chars for showing modules in context-insensitive completions?", p));

    addField(new IntegerFieldEditor(
            PyCodeCompletionPreferences.CHARS_FOR_CTX_INSENSITIVE_TOKENS_COMPLETION,
            "Number of chars for showing global tokens in context-insensitive completions?", p));

    addField(new BooleanFieldEditor(PyCodeCompletionPreferences.USE_KEYWORDS_CODE_COMPLETION,
            "Use common tokens auto code completion?", p));
    addField(new LabelFieldEditor("LabelFieldEditor", "", p));

    addField(new BooleanFieldEditor(PyCodeCompletionPreferences.ADD_SPACE_WHEN_NEEDED,
            "Add <SPACE> for common cases (e.g.: \"and \", \"assert \", etc.)?", p));
    addField(new LabelFieldEditor("LabelFieldEditor", "", p));

    addField(new BooleanFieldEditor(PyCodeCompletionPreferences.ADD_SPACE_AND_COLON_WHEN_NEEDED,
            "Add <SPACE><COLON> for common cases (e.g.: \"class :\", \"if :\", etc.)?", p));
    addField(new LabelFieldEditor("LabelFieldEditor", "", p));

    addField(new BooleanFieldEditor(PyCodeCompletionPreferences.FORCE_PY3K_PRINT_ON_PY2,
            "Force print() function on Python 2.x projects?", p));
    addField(new LabelFieldEditor("LabelFieldEditor", "", p));

    addField(new ListEditor(PyCodeCompletionPreferences.KEYWORDS_CODE_COMPLETION, "Tokens to use:", p) {

        @Override
        protected String createList(String[] items) {
            return PyCodeCompletionPreferences.wordsAsString(items);
        }

        @Override
        protected String getNewInputObject() {
            InputDialog d = new InputDialog(getShell(), "New word", "Add the word you wish.", "",
                    new IInputValidator() {

                        @Override
                        public String isValid(String newText) {
                            if (newText.indexOf(' ') != -1) {
                                return "The input cannot have spaces";
                            }
                            return null;
                        }
                    });

            int retCode = d.open();
            if (retCode == InputDialog.OK) {
                return d.getValue();
            }
            return null;
        }

        @Override
        protected String[] parseString(String stringList) {
            return PyCodeCompletionPreferences.stringAsWords(stringList);
        }

        @Override
        protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns);
            List listControl = getListControl(parent);
            GridData layoutData = (GridData) listControl.getLayoutData();
            layoutData.heightHint = 300;
        }
    });
}
 
Example #2
Source File: InteractiveConsoleUMDPrefs.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void createFieldEditors() {
    Composite p = getFieldEditorParent();

    addField(new BooleanFieldEditor(PydevConsoleConstants.INTERACTIVE_CONSOLE_UMD_ENABLED,
            "Enable UMD", p));
    addField(new LabelFieldEditor("LabelFieldEditor", "", p));

    addField(new BooleanFieldEditor(PydevConsoleConstants.INTERACTIVE_CONSOLE_UMD_VERBOSE,
            "Show reloaded modules list", p));
    addField(new LabelFieldEditor("LabelFieldEditor", "", p));

    addField(new ListEditor(PydevConsoleConstants.INTERACTIVE_CONSOLE_UMD_EXCLUDE_MODULE_LIST,
            "UMD Excluded Modules:", p) {

        @Override
        protected String createList(String[] items) {
            return StringUtils.join(",", items);
        }

        @Override
        protected String[] parseString(String stringList) {
            return stringList.split(",");
        }

        @Override
        protected String getNewInputObject() {
            InputDialog d = new InputDialog(getShell(), "New Excluded Module",
                    "Add the module you want to exclude.", "",
                    new IInputValidator() {
                        @Override
                        public String isValid(String newText) {
                            if (newText.indexOf(',') != -1) {
                                return "The input cannot have a comma";
                            }
                            return null;
                        }
                    });

            if (d.open() == InputDialog.OK) {
                return d.getValue();
            }
            return null;
        }

        @Override
        protected void doFillIntoGrid(Composite parent, int numColumns) {
            super.doFillIntoGrid(parent, numColumns);
            List listControl = getListControl(parent);
            GridData layoutData = (GridData) listControl.getLayoutData();
            layoutData.heightHint = 300;
        }
    });

}