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

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

Introduction

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

Prototype

boolean getBoolean(String name);

Source Link

Document

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

Usage

From source file:com.aptana.ide.editor.css.contentassist.CSSContentAssistProcessor.java

License:Open Source License

/**
 * Do we insert a colon?//from  w ww  .j a va 2s.co m
 * 
 * @param store
 * @return String
 */
public static boolean insertColon(IPreferenceStore store) {
    if (store != null) {
        return store.getBoolean(IPreferenceConstants.CSSEDITOR_INSERT_COLON);
    } else {
        return false;
    }
}

From source file:com.aptana.ide.editor.css.contentassist.CSSContentAssistProcessor.java

License:Open Source License

/**
 * Do we insert a semicolon?/*  w w w. ja  v a2  s . c  o  m*/
 * 
 * @param store
 * @return String
 */
public static boolean insertSemicolon(IPreferenceStore store) {
    if (store != null) {
        return store.getBoolean(IPreferenceConstants.CSSEDITOR_INSERT_SEMICOLON);
    } else {
        return false;
    }
}

From source file:com.aptana.ide.editor.css.formatting.CSSCodeFormatterOptions.java

License:Open Source License

private void initFromPreferences() {
    IPreferenceStore preferenceStore = CSSPlugin.getDefault().getPreferenceStore();

    formatterTabChar = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
    tabSize = preferenceStore.getInt(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
    formatterBracePositionForBlock = parseOption(preferenceStore,
            DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
    newlinesBetweenSelectors = preferenceStore.getBoolean(NEWLINES_BETWEEN_SELECTORS);
    String string = preferenceStore.getString(DefaultCodeFormatterConstants.NO_FORMATTING);
    if (string.length() > 0) {
        doFormatting = false;/*from  www .j a v a  2 s .  c  o  m*/
    }
}

From source file:com.aptana.ide.editor.css.MultiPageCSSEditor.java

License:Open Source License

/**
 * @see org.eclipse.ui.part.MultiPageEditorPart#createPageContainer(org.eclipse.swt.widgets.Composite)
 *///from  w ww .j  a  va  2 s  . c  om
protected Composite createPageContainer(Composite parent) {
    displayArea = new Composite(parent, SWT.NONE);
    GridLayout daLayout = new GridLayout(1, true);
    daLayout.marginHeight = 0;
    daLayout.marginWidth = 0;
    displayArea.setLayout(daLayout);
    displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    IPreferenceStore store = CSSPlugin.getDefault().getPreferenceStore();
    boolean show = store.getBoolean(IPreferenceConstants.SHOW_CSS_TOOLBAR);
    if (show) {
        toolbar = new ToolbarWidget(new String[] { CSSMimeType.MimeType },
                new String[] { CSSMimeType.MimeType }, CSSPlugin.getDefault().getPreferenceStore(),
                IPreferenceConstants.LINK_CURSOR_WITH_CSS_TOOLBAR_TAB, this);
        toolbar.createControl(displayArea);
    }
    Composite editorArea = new Composite(displayArea, SWT.NONE);
    editorArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout eaLayout = new GridLayout(1, true);
    eaLayout.marginHeight = 0;
    eaLayout.marginWidth = 0;
    editorArea.setLayout(new FillLayout());
    return editorArea;
}

From source file:com.aptana.ide.editor.js.formatting.JSCodeFormatterOptions.java

License:Open Source License

private void initFromPreferences() {
    IPreferenceStore preferenceStore = JSPlugin.getDefault().getPreferenceStore();
    insertNewLineBeforeReturn = parseInsert(preferenceStore
            .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_RETURN_STATEMENT));
    insertNewLineBeforeIf = parseInsert(preferenceStore
            .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_IF_STATEMENT));
    insertNewLineBeforeElse = parseInsert(preferenceStore
            .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT));
    insertNewLineBeforeCatch = parseInsert(preferenceStore
            .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT));
    insertNewLineBeforeFinally = parseInsert(preferenceStore.getString(
            DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT));
    insertNewLineBeforeWhile = parseInsert(preferenceStore
            .getString(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT));
    keepThenSameLine = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE);
    keepSimpleIfOnOneLine = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE);
    keepElseStatementOnSameLine = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE);
    compactElseIf = preferenceStore.getBoolean(DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF);
    keepGuardianClauseOnOneLine = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE);
    formatterTabChar = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
    tabSize = preferenceStore.getInt(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
    indentStatementsCompareToBody = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY);
    indentStatementsCompareToBlock = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
    indentStatementsCompareToSwitch = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH);
    indentStatementsCompareToCases = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES);
    indentBreaksCompareToCases = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES);
    indentEmptyLines = preferenceStore.getBoolean(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES);
    blankLinesBeforeMethod = preferenceStore
            .getInt(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD);
    blankLinesInStartOfMethodBody = preferenceStore
            .getInt(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY);

    preserveLineBreaks = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_PRESERVE_EXTRA_CARRIAGE_RETURNS);

    formatterBracePositionForMethodDecl = parseOption(preferenceStore,
            DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION);
    formatterBracePositionForBlock = parseOption(preferenceStore,
            DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
    formatterBracePositionForBlockInCase = parseOption(preferenceStore,
            DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE);
    formatterBracePositionForBlockInSwitch = parseOption(preferenceStore,
            DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH);
    formatterBracePositionForArrayInitializer = parseOption(preferenceStore,
            DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER);
    keepEmptyArrayInitializerOnOneLine = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE);
    addSpaceAfterFunctionDeclaration = preferenceStore
            .getBoolean(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK);

    String string = preferenceStore.getString(DefaultCodeFormatterConstants.NO_FORMATTING);
    if (string.length() > 0) {
        doFormatting = false;//  w w w .  j  av  a2  s  . c o m
    }
}

From source file:com.aptana.ide.editor.js.JSEditor.java

License:Open Source License

/**
 * @see com.aptana.ide.editors.unified.UnifiedEditor#createPartControl(org.eclipse.swt.widgets.Composite)
 *///from w w  w .  ja  v a 2 s. c om
public void createPartControl(Composite parent) {
    this._displayArea = new Composite(parent, SWT.NONE);
    GridLayout daLayout = new GridLayout(1, true);
    daLayout.marginHeight = 0;
    daLayout.marginWidth = 0;
    this._displayArea.setLayout(daLayout);
    this._displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    IPreferenceStore store = getPreferenceStore();
    boolean show = store.getBoolean(IPreferenceConstants.SHOW_JS_TOOLBAR);

    if (show && this._toolbarEnabled) {
        this._toolbar = new ToolbarWidget(new String[] { JSMimeType.MimeType },
                new String[] { JSMimeType.MimeType }, getPreferenceStore(),
                IPreferenceConstants.LINK_CURSOR_WITH_JS_TOOLBAR_TAB, this);
        this._toolbar.createControl(this._displayArea);
    }

    Composite editorArea = new Composite(this._displayArea, SWT.NONE);
    editorArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout eaLayout = new GridLayout(1, true);
    eaLayout.marginHeight = 0;
    eaLayout.marginWidth = 0;
    editorArea.setLayout(new FillLayout());
    super.createPartControl(editorArea);
}

From source file:com.aptana.ide.editor.jscomment.formatting.JSCommentAutoIndentStrategy.java

License:Open Source License

/**
 * Copies the indentation of the previous line and adds a star. If the javadoc just started on
 * this line add standard method tags and close the javadoc.
 * /*from   ww w  . j a va  2s. c  o m*/
 * @param d
 *            the document to work on
 * @param c
 *            the command to deal with
 */
protected void indentAfterNewLine(IDocument d, DocumentCommand c) {

    int offset = c.offset;
    if (offset == -1 || d.getLength() == 0) {
        return;
    }

    try {
        int p = (offset == d.getLength() ? offset - 1 : offset);
        IRegion line = d.getLineInformationOfOffset(p);

        int lineOffset = line.getOffset();
        int firstNonWS = findEndOfWhiteSpace(d, lineOffset, offset);

        // find out if this is a return after a */ (in which case only add an indent, not a *)
        if (indentCloseToken(d, c, offset, lineOffset, firstNonWS)) {
            return;
        }

        // find out if this is a // style single line comment
        if ((d.getLength() > firstNonWS + 1) && (d.getChar(firstNonWS + 1) == '/')) {
            super.indentAfterNewLine(d, c);
            return;
        }
        // get line prefix
        IPreferenceStore store = JSPlugin.getDefault().getPreferenceStore();
        boolean useStar = true;
        if (store != null) {
            useStar = store.getBoolean(IPreferenceConstants.PREFERENCE_COMMENT_INDENT_USE_STAR);
        }
        linePrefix = useStar ? "* " : " "; //$NON-NLS-1$ //$NON-NLS-2$

        StringBuffer buf = new StringBuffer(c.text);
        IRegion prefix = findPrefixRange(d, line);
        String indentation = d.get(prefix.getOffset(), prefix.getLength());
        // String indentation = getIndentationString(d, lineOffset, firstNonWS);
        // if(indentation == "")
        // return;

        int lengthToAdd = Math.min(offset - prefix.getOffset(), prefix.getLength());

        buf.append(indentation.substring(0, lengthToAdd));

        if (firstNonWS < offset) {
            if (d.getChar(firstNonWS) == '/') {
                // javadoc started on this line
                buf.append(" " + linePrefix); //$NON-NLS-1$

                if (isNewComment(d, offset)) {
                    c.shiftsCaret = false;
                    c.caretOffset = c.offset + buf.length();
                    String lineDelimiter = TextUtilities.getDefaultLineDelimiter(d);

                    String endTag = lineDelimiter + indentation + " */"; //$NON-NLS-1$

                    // guard for end of doc (multiline comment at very end of doc
                    if (d.getLength() > firstNonWS + 2 && d.getChar(firstNonWS + 1) == '*') {
                        // we need to close the comment
                        d.replace(offset, 0, endTag);
                    } else {
                        buf.append(endTag);
                    }
                }

            }
        }

        // move the caret behind the prefix, even if we do not have to insert it.
        if (lengthToAdd < prefix.getLength()) {
            c.caretOffset = offset + prefix.getLength() - lengthToAdd;
        }
        c.text = buf.toString();

    } catch (BadLocationException excp) {
        // stop work
    }
}

From source file:com.aptana.ide.editor.scriptdoc.formatting.ScriptDocAutoIndentStrategy.java

License:Open Source License

/**
 * Copies the indentation of the previous line and adds a star. If the javadoc just started on
 * this line add standard method tags and close the javadoc.
 * /*from   w  ww  .j  av a 2  s  . c  o m*/
 * @param d
 *            the document to work on
 * @param c
 *            the command to deal with
 */
protected void indentAfterNewLine(IDocument d, DocumentCommand c) {

    int offset = c.offset;
    if (offset == -1 || d.getLength() == 0) {
        return;
    }

    try {
        int p = (offset == d.getLength() ? offset - 1 : offset);
        IRegion line = d.getLineInformationOfOffset(p);

        int lineOffset = line.getOffset();
        int firstNonWS = findEndOfWhiteSpace(d, lineOffset, offset);

        // find out if this is a return after a */ (in which case only add an indent, not a *)
        if (indentCloseToken(d, c, offset, lineOffset, firstNonWS)) {
            return;
        }

        // get line prefix
        IPreferenceStore store = JSPlugin.getDefault().getPreferenceStore();
        boolean useStar = true;
        if (store != null) {
            useStar = store.getBoolean(IPreferenceConstants.PREFERENCE_COMMENT_INDENT_USE_STAR);
        }
        linePrefix = useStar ? "* " : " "; //$NON-NLS-1$ //$NON-NLS-2$

        StringBuffer buf = new StringBuffer(c.text);
        IRegion prefix = findPrefixRange(d, line);
        String indentation = d.get(prefix.getOffset(), prefix.getLength());
        int lengthToAdd = Math.min(offset - prefix.getOffset(), prefix.getLength());

        buf.append(indentation.substring(0, lengthToAdd));

        if (firstNonWS < offset) {
            if (d.getChar(firstNonWS) == '/') {
                // javadoc started on this line
                buf.append(" " + linePrefix); //$NON-NLS-1$

                if (isNewComment(d, offset))
                // TODO: isPreferenceTrue(PreferenceConstants.EDITOR_CLOSE_JAVADOCS) && )
                {
                    c.shiftsCaret = false;
                    c.caretOffset = c.offset + buf.length();
                    String lineDelimiter = TextUtilities.getDefaultLineDelimiter(d);

                    String endTag = lineDelimiter + indentation + " */"; //$NON-NLS-1$

                    // guard for end of doc (multiline comment at very end of doc
                    if (d.getLength() > firstNonWS + 2 && d.getChar(firstNonWS + 1) == '*'
                            && d.getChar(firstNonWS + 2) == '*') // TODO:
                    // isPreferenceTrue(PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS))
                    {
                        // we need to close the comment before computing
                        // the correct tags in order to get the method
                        d.replace(offset, 0, endTag);

                        // evaluate method signature
                        String string = createJSDocTags(offset, d, c, indentation, lineDelimiter);

                        if (string != null) {
                            buf.append(string);
                        }
                    } else {
                        buf.append(endTag);
                    }
                }
            }
        }

        // move the caret behind the prefix, even if we do not have to insert it.
        if (lengthToAdd < prefix.getLength()) {
            c.caretOffset = offset + prefix.getLength() - lengthToAdd;
        }
        c.text = buf.toString();

    } catch (BadLocationException excp) {
        // stop work
    }
}

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

License:Open Source License

/**
 * Makes an indent on new line./* w  w w.  j  a v  a  2 s . c om*/
 * 
 * @param document -
 *            document.
 * @param command -
 *            document command.
 * @param store -
 *            preference store.
 * @param xmlParseState -
 *            parse state.
 */
private void indentOnNewLine(IDocument document, DocumentCommand command, IPreferenceStore store,
        XMLParseState xmlParseState) {
    if (command.text == null || command.length > 0) {
        return;
    }

    if (store != null && store.getBoolean(IPreferenceConstants.AUTO_INDENT_ON_CARRIAGE_RETURN)) {
        if (UnifiedConfiguration.isNewlineString(command.text)
                && indentNextTag(document, command, xmlParseState)) {
            return;
        }
    }
}

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

License:Open Source License

/**
 * initializes options from preference store
 *//*from w  w  w.jav  a  2 s.c  om*/
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);
}