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.aptana.ide.editor.js.wizards.JsNewWizard.java

License:Open Source License

/**
 * @see com.aptana.ide.editors.wizards.SimpleNewFileWizard#getInitialFileContents()
 *//*ww  w.j  ava  2s.c om*/
protected String getInitialFileContents() {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);

    String userName = CoreUIUtils.getUserName();
    IPreferenceStore store = JSPlugin.getDefault().getPreferenceStore();
    String contents = store.getString(IPreferenceConstants.JSEDITOR_INITIAL_CONTENTS);
    pw.print(contents.replace("{0}", userName)); //$NON-NLS-1$
    pw.close();

    return sw.toString();
}

From source file:com.aptana.ide.editor.scriptdoc.wizards.ScriptDocNewWizard.java

License:Open Source License

/**
 * @see com.aptana.ide.editors.wizards.SimpleNewFileWizard#createNewFilePage(org.eclipse.jface.viewers.ISelection)
 *///from   w  w w  .ja  va  2s  .com
protected SimpleNewWizardPage createNewFilePage(ISelection selection) {
    SimpleNewWizardPage page = new SimpleNewWizardPage(selection);
    page.setRequiredFileExtensions(new String[] { "sdoc" }); //$NON-NLS-1$
    page.setTitle(Messages.ScriptDocNewWizard_Title2);
    page.setDescription(Messages.ScriptDocNewWizard_Desc2);
    IPreferenceStore store = JSPlugin.getDefault().getPreferenceStore();
    String fileName = store.getString(IPreferenceConstants.SCRIPTDOCEDITOR_INITIAL_FILE_NAME);
    page.setDefaultFileName(fileName);
    return page;
}

From source file:com.aptana.ide.editor.text.GenericTextEditor.java

License:Open Source License

/**
 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
 *//*from   w  w  w  .  j a  va 2s .co  m*/
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    // Find file extension
    String fileName = input.getName();
    String ext = FileUtils.getExtension(fileName);
    if (ext == null || ext.length() == 0) {
        if (input instanceof NonExistingFileEditorInput) {
            IPath path = ((NonExistingFileEditorInput) input).getPath(input);
            if (path != null) {
                fileName = path.lastSegment();
                ext = FileUtils.getExtension(fileName);
            }
        }
    }
    IPreferenceStore store = TextPlugin.getDefault().getPreferenceStore();
    IEditorRegistry registry = EclipseUIUtils.getWorkbenchEditorRegistry();
    IFileEditorMapping[] mappings = registry.getFileEditorMappings();
    IFileEditorMapping candidate = null;
    for (int i = 0; i < mappings.length; i++) {
        if (mappings[i].getLabel().equals(fileName)) {
            candidate = mappings[i];
            break;
        } else if (mappings[i].getExtension().equals(ext)) {
            candidate = mappings[i];
        }
    }
    if (candidate != null) {
        String label = candidate.getLabel();
        String grammarFilePath = store.getString(TextPlugin.getGrammarPreference(label));
        String colorizerPath = TextPlugin.getColorizerPreference(label);
        extension = ext;

        // This handles file extensions that we want to open with the generic text editor but use both contributed
        // (via extension point) lexers and colorizers
        TokenList tokenList = LanguageRegistry.getTokenListByExtension(extension);
        if (tokenList != null) {
            language = tokenList.getLanguage();

            // create parser
            try {
                if (LanguageRegistry.hasParser(language)) {
                    parser = LanguageRegistry.getParser(language);
                } else {
                    parser = new UnifiedParser(language);
                }
            } catch (ParserInitializationException e) {
                throw new PartInitException(e.getMessage());
            }
        } else {
            grammarFile = new File(grammarFilePath);
        }
        FileInputStream stream = null;
        try {
            if (grammarFile != null && grammarFile.exists() && grammarFile.isFile() && grammarFile.canRead()) {
                if (language == null) {
                    AttributeSniffer sniffer = new AttributeSniffer("lexer", "language"); //$NON-NLS-1$ //$NON-NLS-2$
                    sniffer.read(grammarFilePath);
                    if (sniffer.getMatchedValue() != null) {
                        language = sniffer.getMatchedValue();
                    } else {
                        throw new PartInitException(Messages.GenericTextEditor_No_Language_Defined);
                    }
                }
                if (parser == null) {
                    parser = createParser();
                }
            }
            if (language != null) {
                ColorizerReader reader = new ColorizerReader();
                if (LanguageRegistry.hasLanguageColorizer(language)) {
                    LanguageRegistry.getLanguageColorizer(language);
                } else {
                    reader.loadColorization(colorizerPath, true);
                }
            } else {
                language = PLAIN_MIME_TYPE;
                final TokenList list = new TokenList(language);
                parser = new UnifiedParser(language) {
                    public void addLexerGrammar(ILexerBuilder builder) throws LexerException {
                        builder.addTokenList(list);
                    }
                };
            }
            if (parser != null) {
                createFileServiceFactory();
            }
            contributor = createContributor();
            documentProvider = new GenericDocumentProvider();
            createEditor();
            editor.init(site, input);
            if (grammarFile != null && grammarFile.exists()) {
                createGrammarFileMonitor();
            }
        } catch (ParserInitializationException e) {
            e.printStackTrace();
            throw new PartInitException(e.getMessage());
        } catch (FileNotFoundException e) {
            throw new PartInitException(e.getMessage());
        } catch (IOException e) {
            throw new PartInitException(e.getMessage());
        } catch (ParserConfigurationException e) {
            throw new PartInitException(e.getMessage());
        } catch (SAXException e) {
            throw new PartInitException(e.getMessage());
        } finally {
            if (stream != null) {
                try {
                    stream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    } else {
        throw new PartInitException(Messages.GenericTextEditor_ERROR_RETRIEVING_ASSOCIATION);
    }
}

From source file:com.aptana.ide.editor.xml.formatting.XMLCodeFormatterOptions.java

License:Open Source License

/**
 * initializes options from preference store
 *//* w  w  w . ja v a 2s  .  co m*/
private void initFromPreferences() {
    IPreferenceStore preferenceStore = XMLPlugin.getDefault().getPreferenceStore();

    formatterTabChar = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
    tabSize = preferenceStore.getInt(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
    spacesInMultiline = preferenceStore
            .getInt(DefaultCodeFormatterConstants.FORMATTER_SPACES_BEFORE_ATTRS_ON_MULTILINE);
    String sm = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_DO_NOT_WRAP_TAGS2);
    initTags(sm, notWrappingTags);
    sm = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_WRAP_TAGS2);
    initTags(sm, allwaysWrap);
    String string = preferenceStore.getString(DefaultCodeFormatterConstants.NO_FORMATTING);

    if (string.length() > 0) {
        doFormatting = false;
    }

    preserveReturns = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_PRESERVE_EXTRA_CARRIAGE_RETURNS);
    preserveWhitespacesInCDATA = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_PRESERVE_WHITESPACE_IN_CDATA);
    doNotWrapSimple = preferenceStore.getBoolean(DefaultCodeFormatterConstants.DO_NOT_WRAP_SIMPLE_TAGS);
}

From source file:com.aptana.ide.editor.xml.outline.XMLLabelProvider.java

License:Open Source License

/**
 * getAttributeNameList//from   ww w. j a  va  2  s .co  m
 */
private void getAttributeNameList() {
    // get XML preference store
    IPreferenceStore prefStore = XMLPlugin.getDefault().getPreferenceStore();

    // grab list of attribute names
    String result = prefStore.getString(IPreferenceConstants.XMLEDITOR_OUTLINER_ATTRIBUTE_LIST);

    this._attributeNames = result.split("\\s+,\\s*|\\s*,\\s+|,|\\s+"); //$NON-NLS-1$
}

From source file:com.aptana.ide.editor.xml.wizards.XmlNewWizard.java

License:Open Source License

/**
 * @param selection// w  w w .j a  v  a 2 s. c o m
 * @return NewFilePage
 */
protected SimpleNewWizardPage createNewFilePage(ISelection selection) {
    SimpleNewWizardPage page = new SimpleNewWizardPage(selection);

    page.setRequiredFileExtensions(new String[] { "xml" }); //$NON-NLS-1$
    page.setTitle(Messages.XmlNewWizard_Title2);
    page.setDescription(Messages.XmlNewWizard_Desc);

    IPreferenceStore store = XMLPlugin.getDefault().getPreferenceStore();
    String fileName = store.getString(IPreferenceConstants.XMLEDITOR_INITIAL_FILE_NAME);
    page.setDefaultFileName(fileName);

    return page;
}

From source file:com.aptana.ide.editor.xml.wizards.XmlNewWizard.java

License:Open Source License

/**
 * @see com.aptana.ide.editors.wizards.SimpleNewFileWizard#getInitialFileContents()
 *//*ww  w  . j a  v  a 2 s .c  o  m*/
protected String getInitialFileContents() {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);

    IPreferenceStore store = XMLPlugin.getDefault().getPreferenceStore();
    String contents = store.getString(IPreferenceConstants.XMLEDITOR_INITIAL_CONTENTS);
    pw.print(contents);
    pw.close();

    return sw.toString();
}

From source file:com.aptana.ide.editor.yml.wizards.YMLNewFileWizard.java

License:Open Source License

/**
 * @see com.aptana.ide.editors.wizards.SimpleNewFileWizard#createNewFilePage(org.eclipse.jface.viewers.ISelection)
 *///  w ww .  j  av  a 2 s. c om
protected SimpleNewWizardPage createNewFilePage(ISelection selection) {
    SimpleNewWizardPage page = new SimpleNewWizardPage(selection);

    page.setRequiredFileExtensions(new String[] { "yml" }); //$NON-NLS-1$
    page.setTitle(Messages.YMLNewFileWizard_Filename);
    page.setDescription(Messages.YMLNewFileWizard_Description);
    IPreferenceStore store = YMLPlugin.getDefault().getPreferenceStore();
    String filename = store.getString(IPreferenceConstants.YMLEDITOR_INITIAL_FILE_NAME);
    page.setDefaultFileName(filename);
    return page;
}

From source file:com.aptana.ide.editor.yml.wizards.YMLNewFileWizard.java

License:Open Source License

/**
 * @see com.aptana.ide.editors.wizards.SimpleNewFileWizard#getInitialFileContents()
 *///from w ww  . j  ava 2  s .co  m
protected String getInitialFileContents() {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);

    IPreferenceStore store = YMLPlugin.getDefault().getPreferenceStore();
    String contents = store.getString(IPreferenceConstants.YMLEDITOR_INITIAL_CONTENTS);
    pw.println(contents);
    pw.close();

    return sw.toString();
}

From source file:com.aptana.ide.editors.formatting.UnifiedBracketInserter.java

License:Open Source License

/**
 * isAutoInsertEnabled/* w  w  w  .  j  a  v  a 2 s  .c om*/
 * 
 * @return boolean
 */
protected boolean isAutoInsertEnabled() {
    IPreferenceStore store = getPreferenceStore();
    String abi = com.aptana.ide.editors.preferences.IPreferenceConstants.AUTO_BRACKET_INSERTION;

    return (store == null || store.getString(abi).equals("NONE") == false); //$NON-NLS-1$
}