Java 类org.eclipse.swt.custom.ST 实例源码

项目:Notepad4e    文件:Note.java   
/**
 * Applies a bullet list style to the currently selected lines.
 */
public void bulletListSelection() {
    if (!getEditable()) {
        return;
    }

    String textBeforeSelection = getText().substring(0, getSelection().x);
    int selectionStartLine = getTextLineCount(textBeforeSelection) - 1;
    int selectionLineCount = getTextLineCount(getSelectionText());
    int selectionCurrentBullets = 0;
    // Count number of lines that currently have a bullet.
    for (int line = selectionStartLine; line < selectionStartLine + selectionLineCount; ++line) {
        if (getLineBullet(line) != null) {
            ++selectionCurrentBullets;
        }
    }

    if (selectionCurrentBullets == selectionLineCount) {
        // All lines have bullets, remove them all.
        setLineBullet(selectionStartLine, selectionLineCount, null);
        return;
    }

    Bullet bullet = new Bullet(ST.BULLET_DOT, bulletStyle);
    setLineBullet(selectionStartLine, selectionLineCount, bullet);
}
项目:JFaceUtils    文件:StyledTextConsole.java   
protected MenuItem createSelectAllMenuItem(final StyledText styledText) {
    final MenuItem selectAll = new MenuItem(contextMenu, SWT.PUSH);
    selectAll.setText(JFaceMessages.get("lbl.menu.item.select.all") + SwtUtils.getMod1ShortcutLabel(SwtUtils.KEY_SELECT_ALL));
    selectAll.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent se) {
            styledText.invokeAction(ST.SELECT_ALL);
        }
    });
    styledText.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent ke) {
            if (ke.stateMask == SWT.MOD1 && ke.keyCode == SwtUtils.KEY_SELECT_ALL) {
                styledText.invokeAction(ST.SELECT_ALL);
            }
        }
    });
    return selectAll;
}
项目:mat-calcite-plugin    文件:CommentLineAction.java   
@Override
public void run()
{
    int caretOffset = text.getCaretOffset();
    int lineIndex = text.getLineAtOffset(caretOffset);
    int lineStart = getLineStart(lineIndex);
    String lineText = text.getLine(lineIndex);

    // Move caret to next line
    if (lineIndex+1 < text.getLineCount())
    {
        text.invokeAction(ST.LINE_DOWN);
    }

    if (lineText.startsWith("--"))
    {
        // Uncomment
        text.replaceTextRange(lineStart, 2, "");
    }
    else
    {
        // Comment
        text.replaceTextRange(lineStart, 0, "--");
    }
}
项目:eclipse-debug-console-history    文件:StyledTextConsolePage.java   
@Override
public void lineGetStyle(LineStyleEvent e) {
    // Set the line number
    int line = tc.getLineAtOffset(e.lineOffset);
    int lastLine = tc.getLineCount() - 1;

    e.bulletIndex = line;

    String prompt = "gdb>";

    // Set the style, 12 pixles wide for each digit
    StyleRange style = new StyleRange();
    style.metrics = new GlyphMetrics(0, 0, prompt.length() * 12);

    // Create and set the bullet
    e.bullet = new Bullet(ST.BULLET_TEXT, style);
    if (line == lastLine) {
        e.bullet.text = prompt;
    } else {
        e.bullet.text = "";
    }
}
项目:Pydev    文件:StyledTextWithoutVerticalBar.java   
@Override
public void replaceStyleRanges(int start, int length, StyleRange[] styles) {
    checkWidget();
    if (isListening(ST.LineGetStyle)) {
        return;
    }
    if (styles == null) {
        SWT.error(SWT.ERROR_NULL_ARGUMENT);
    }
    RangesInfo rangesInfo = createRanges(styles, this.getCharCount());
    int[] newRanges = rangesInfo.newRanges;
    styles = rangesInfo.styles;
    try {
        setStyleRanges(start, length, newRanges, styles);
    } catch (Exception e) {
        Log.log(e);
    }
}
项目:relations    文件:StyleParser.java   
private void handleListTag(final String inName,
        final Attributes inAttributes) {
    BulletHelperFactory lFactory = null;
    if (inName.equals(ListTag.Unordered.getName())) {
        lFactory = new SimpleListFactory(ST.BULLET_DOT,
                getBulletWidth(inAttributes));
    } else if (inName.equals(ListTag.OrderedNumeric.getName())) {
        lFactory = new CustomListFactory(getBulletWidth(inAttributes));
    } else if (inName.equals(ListTag.OrderedLetterUpper.getName())) {
        lFactory = new SimpleListFactory(ST.BULLET_LETTER_UPPER,
                getBulletWidth(inAttributes));
    } else if (inName.equals(ListTag.OrderedLetterLower.getName())) {
        lFactory = new SimpleListFactory(ST.BULLET_LETTER_LOWER,
                getBulletWidth(inAttributes));
    }
    bulletStack.push(lFactory);

    final int lLength = text.length();
    if (lLength == 0) {
        return;
    }
    if (text.substring(lLength - 1).charAt(0) == LF) {
        text.delete(lLength - 1, lLength);
    }
}
项目:relations    文件:StyleParser.java   
private TagTemplate getTagTemplate(final Bullet inBullet) {
    final String template = "<%s %s=\"%%s\">%%s</%s>"; //$NON-NLS-1$
    final String item_template = "<li>%s</li>"; //$NON-NLS-1$

    String list_template = "<ul indent=\"%s\">%s</ul>"; //$NON-NLS-1$
    if ((inBullet.type & ST.BULLET_DOT) != 0) {
        list_template = String.format(template, ListTag.Unordered.getName(),
                INDENT_ATTR, ListTag.Unordered.getName());
    } else if ((inBullet.type & ST.BULLET_CUSTOM) != 0) {
        list_template = String.format(template,
                ListTag.OrderedNumeric.getName(), INDENT_ATTR,
                ListTag.OrderedNumeric.getName());
    } else if ((inBullet.type & ST.BULLET_LETTER_UPPER) != 0) {
        list_template = String.format(template,
                ListTag.OrderedLetterUpper.getName(), INDENT_ATTR,
                ListTag.OrderedLetterUpper.getName());
    } else if ((inBullet.type & ST.BULLET_LETTER_LOWER) != 0) {
        list_template = String.format(template,
                ListTag.OrderedLetterLower.getName(), INDENT_ATTR,
                ListTag.OrderedLetterLower.getName());
    }

    return new TagTemplate(list_template, item_template);
}
项目:gw4e.project    文件:TestPresentationPage.java   
private Bullet buildCheckedlStyle() {
    StyleRange style2 = new StyleRange();
    style2.metrics = new GlyphMetrics(0, 0, 80);
    style2.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
    Bullet bullet = new Bullet(ST.BULLET_TEXT, style2);
    bullet.text = "\u2713";
    return bullet;
}
项目:termsuite-ui    文件:FileEditorPart.java   
public void lineGetStyle(LineStyleEvent e) {
    int lineStart = e.lineOffset;
    int lineEnd = lineStart + e.lineText.length();
    // Set the line number
    e.bulletIndex = text.getLineAtOffset(lineStart);

    // Set the style, 12 pixels wide for each digit
    StyleRange style = new StyleRange();
    style.foreground = new Color(text.getDisplay(), 120, 120, 120);
    style.fontStyle = SWT.ITALIC;
    style.metrics = new GlyphMetrics(0, 0, Integer.toString(text.getLineCount() + 1).length() * 12);
    // Create and set the bullet
    e.bullet = new Bullet(ST.BULLET_NUMBER, style);

    List<StyleRange> ranges = Lists.newArrayList();
    for(TermOccurrence occ:FileEditorPart.this.occurrences) {
        if((occ.getBegin() < lineEnd && occ.getEnd() > lineStart)) {
            int styleStart = Ints.max(occ.getBegin(), lineStart);
            int styleEnd = Ints.min(occ.getEnd(), lineEnd);
            int overlap = styleEnd - styleStart;
            StyleRange styleRange = new StyleRange();
            styleRange.start = styleStart;
            styleRange.length =  overlap;
            if(occ.equals(activeOccurrence)) {
                styleRange.fontStyle = SWT.BOLD | SWT.ITALIC;
                styleRange.background = COLOR_CYAN;
            } else {
                styleRange.background = COLOR_GRAY;                     
            }

            ranges.add(styleRange);
        }
    }
    e.styles = ranges.toArray(new StyleRange[ranges.size()]);
}
项目:Notepad4e    文件:Note.java   
/**
 * Adds bullets to the current note based on a bullets' serialisation string (for instance "0,1,4").
 * 
 * @param serialisation
 */
public void deserialiseBullets(String serialisation) {
    Bullet bullet = new Bullet(ST.BULLET_DOT, bulletStyle);
    for (String lineNumber : serialisation.split(STRING_SEPARATOR)) {
        setLineBullet(Integer.parseInt(lineNumber), 1, bullet);
    }
}
项目:Black    文件:logShell.java   
public void appendLog(String text,Point location, boolean clearlog){
    if(clearlog)
        styledText.setText(text);
    else {
        if(!text.equals(""))
            styledText.append("\n"+time.getCurrentDate("-")+" "+time.getCurrentTime()+" "+text);
        else styledText.append(text);
    }
    styledText.invokeAction(ST.PAGE_DOWN);
    if(location != null)
        setLocation(location);
    else windowLocation.onLeftBottomInScreen(this);
}
项目:TranskribusSwtGui    文件:ATranscriptionWidget.java   
protected void setLineBulletAndStuff() {
        text.setLineBullet(0, text.getLineCount(), null); // delete line bullet first to guarantee update! (bug in SWT?)
        if (settings.isShowLineBullets() && currentRegionObject!=null && getNTextLines()>0) {
            Storage store = Storage.getInstance();
            for (int i=0; i<text.getLineCount(); ++i) {             
                final int docId = store.getDoc().getId();
                final int pNr = store.getPage().getPageNr();

                int bulletFgColor = SWT.COLOR_BLACK;

                int fontStyle = SWT.NORMAL;
                if (i>= 0 && i <currentRegionObject.getTextLine().size()) {
                    final String lineId = currentRegionObject.getTextLine().get(i).getId();
                    boolean hasWg = store.hasWordGraph(docId, pNr, lineId);

                    fontStyle = (i == getCurrentLineIndex()) ? SWT.BOLD : SWT.NORMAL;   
                    bulletFgColor = hasWg ? SWT.COLOR_DARK_GREEN : SWT.COLOR_BLACK;
                }

                StyleRange style = new StyleRange(0, text.getCharCount(), Colors.getSystemColor(bulletFgColor), Colors.getSystemColor(SWT.COLOR_GRAY), fontStyle);
                style.metrics = new GlyphMetrics(0, 0, Integer.toString(text.getLineCount() + 1).length() * 12);
//              style.background = Colors.getSystemColor(SWT.COLOR_GRAY);
                Bullet bullet = new Bullet(/*ST.BULLET_NUMBER |*/ ST.BULLET_TEXT, style);
                bullet.text = ""+(i+1);

                text.setLineBullet(i, 1, bullet);
                text.setLineIndent(i, 1, 25);
                text.setLineAlignment(i, 1, settings.getTextAlignment());
                text.setLineWrapIndent(i, 1, 25+style.metrics.width);
            }

//          text.setLineBullet(0, text.getLineCount(), bullet);
//          text.setLineIndent(0, text.getLineCount(), 25);
//          text.setLineAlignment(0, text.getLineCount(), textAlignment);
//          text.setLineWrapIndent(0, text.getLineCount(), 25+style.metrics.width);         


        }
    }
项目:TranskribusSwtGui    文件:XmlViewer.java   
private void setLineBullet() {
        StyleRange style = new StyleRange();
        style.metrics = new GlyphMetrics(0, 0, Integer.toString(text.getLineCount() + 1).length() * 12);
        style.background = Colors.getSystemColor(SWT.COLOR_GRAY);
        Bullet bullet = new Bullet(ST.BULLET_NUMBER, style);
        text.setLineBullet(0, text.getLineCount(), bullet);
//      text.setLineIndent(0, text.getLineCount(), 25);
//      text.setLineAlignment(0, text.getLineCount(), textAlignment);
//      text.setLineWrapIndent(0, text.getLineCount(), 25+style.metrics.width);     
    }
项目:bts    文件:XtextEditor.java   
@Override
protected void setCaretPosition(final int position) {
    if (!validateEditorInputState())
        return;

    final ISourceViewer viewer = getSourceViewer();
    StyledText text = viewer.getTextWidget();
    Point widgetSelection = text.getSelection();
    if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
        final int caret = text.getCaretOffset();
        final int offset = modelOffset2WidgetOffset(viewer, position);

        if (caret == widgetSelection.x)
            text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
        else
            text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
        text.invokeAction(ST.DELETE_NEXT);
    } else {
        Point selection = viewer.getSelectedRange();
        final int caret, length;
        if (selection.y != 0) {
            caret = selection.x;
            length = selection.y;
        } else {
            caret = widgetOffset2ModelOffset(viewer, text.getCaretOffset());
            length = position - caret;
        }

        try {
            viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
        } catch (BadLocationException exception) {
            // Should not happen
        }
    }
}
项目:bts    文件:XtextEditor.java   
@Override
protected void setCaretPosition(int position) {
    if (!validateEditorInputState())
        return;

    final int length;
    final ISourceViewer viewer = getSourceViewer();
    StyledText text = viewer.getTextWidget();
    Point widgetSelection = text.getSelection();
    if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
        final int caret = text.getCaretOffset();
        final int offset = modelOffset2WidgetOffset(viewer, position);

        if (caret == widgetSelection.x)
            text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
        else
            text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
        text.invokeAction(ST.DELETE_PREVIOUS);
    } else {
        Point selection = viewer.getSelectedRange();
        if (selection.y != 0) {
            position = selection.x;
            length = selection.y;
        } else {
            length = widgetOffset2ModelOffset(viewer, text.getCaretOffset()) - position;
        }

        try {
            viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
        } catch (BadLocationException exception) {
            // Should not happen
        }
    }
}
项目:SPELL    文件:CustomStyledText.java   
@Override
/**************************************************************************
 * Callback from LineStyleListener interface for the styled text widget.
 * Used to set the text styles (bold, italic, etc)
 *************************************************************************/
public void lineGetStyle(LineStyleEvent event)
{
    /*
     * Icon style range
     */
    // This method basically establishes the glyph metrics required for
    // creating the leading blank space at the beginning of each line,
    // which will allow us to paint the icons later. Besides, the
    // corresponding line model is stored in the style range in order
    // to be utilized later on in paintObject().
    int lineIndex = m_view.getLineAtOffset(event.lineOffset);
    TextViewLine line = (TextViewLine) m_model.getLineObject(lineIndex);
    // We need to create a style rang for each line
    StyleRange bulletStyle = new StyleRange();
    // Reuse the same glyphmetrics, it never changes and we save memory and
    // creation time
    bulletStyle.metrics = s_metrics;
    bulletStyle.start = event.lineOffset;
    // Store the line model that will be used later for painting

    // NOT COMPATIBLE WITH ECLIPSE 3.3 --BEGIN
    // This is the corresponding line index
    // int lineIndex = m_model.getLineAtOffset(event.lineOffset);
    // theStyle.data = (TextViewLine) m_model.getLineObject(lineIndex);
    // NOT COMPATIBLE WITH ECLIPSE 3.3 --END
    event.bullet = new Bullet(ST.BULLET_CUSTOM, bulletStyle);

    TextStyle lineStyle = new TextStyle(null, null, null);
    lineStyle.foreground = m_labelProvider.getForegroundColor(line.getType(), line.getScope());
    StyleRange lineStyleRange = new StyleRange(lineStyle);
    lineStyleRange.start = event.lineOffset;
    lineStyleRange.length = event.lineText.length();
    lineStyleRange.fontStyle = m_labelProvider.getFontStyle(line.getScope());
    event.styles = new StyleRange[] { lineStyleRange };
}
项目:JFaceUtils    文件:StyledTextConsole.java   
protected MenuItem createCopyMenuItem(final StyledText styledText) {
    final MenuItem copy = new MenuItem(contextMenu, SWT.PUSH);
    copy.setText(JFaceMessages.get("lbl.menu.item.copy") + SwtUtils.getMod1ShortcutLabel(SwtUtils.KEY_COPY));
    copy.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent se) {
            styledText.invokeAction(ST.COPY);
        }
    });
    return copy;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaEditor.java   
@Override
protected void setCaretPosition(final int position) {
    if (!validateEditorInputState())
        return;

    final ISourceViewer viewer= getSourceViewer();
    StyledText text= viewer.getTextWidget();
    Point widgetSelection= text.getSelection();
    if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
        final int caret= text.getCaretOffset();
        final int offset= modelOffset2WidgetOffset(viewer, position);

        if (caret == widgetSelection.x)
            text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
        else
            text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
        text.invokeAction(ST.DELETE_NEXT);
    } else {
        Point selection= viewer.getSelectedRange();
        final int caret, length;
        if (selection.y != 0) {
            caret= selection.x;
            length= selection.y;
        } else {
            caret= widgetOffset2ModelOffset(viewer, text.getCaretOffset());
            length= position - caret;
        }

        try {
            viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
        } catch (BadLocationException exception) {
            // Should not happen
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaEditor.java   
@Override
protected void setCaretPosition(int position) {
    if (!validateEditorInputState())
        return;

    final int length;
    final ISourceViewer viewer= getSourceViewer();
    StyledText text= viewer.getTextWidget();
    Point widgetSelection= text.getSelection();
    if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
        final int caret= text.getCaretOffset();
        final int offset= modelOffset2WidgetOffset(viewer, position);

        if (caret == widgetSelection.x)
            text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
        else
            text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
        text.invokeAction(ST.DELETE_PREVIOUS);
    } else {
        Point selection= viewer.getSelectedRange();
        if (selection.y != 0) {
            position= selection.x;
            length= selection.y;
        } else {
            length= widgetOffset2ModelOffset(viewer, text.getCaretOffset()) - position;
        }

        try {
            viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
        } catch (BadLocationException exception) {
            // Should not happen
        }
    }
}
项目:translationstudio8    文件:GridCopyEnable.java   
public void doAction(int action) {
    switch (action) {
    case ST.COPY:
        copy();
        break;
    default:
        break;
    }
}
项目:translationstudio8    文件:GridCopyEnable.java   
/**
 * Updates the selection based on the caret position
 */
void doMouseSelection() {
    if (caretOffset <= selection.x
            || (caretOffset > selection.x && caretOffset < selection.y && selectionAnchor == selection.x)) {
        doSelection(ST.COLUMN_PREVIOUS);// left
    } else {
        doSelection(ST.COLUMN_NEXT); // right
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaEditor.java   
@Override
protected void setCaretPosition(final int position) {
    if (!validateEditorInputState())
        return;

    final ISourceViewer viewer= getSourceViewer();
    StyledText text= viewer.getTextWidget();
    Point widgetSelection= text.getSelection();
    if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
        final int caret= text.getCaretOffset();
        final int offset= modelOffset2WidgetOffset(viewer, position);

        if (caret == widgetSelection.x)
            text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
        else
            text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
        text.invokeAction(ST.DELETE_NEXT);
    } else {
        Point selection= viewer.getSelectedRange();
        final int caret, length;
        if (selection.y != 0) {
            caret= selection.x;
            length= selection.y;
        } else {
            caret= widgetOffset2ModelOffset(viewer, text.getCaretOffset());
            length= position - caret;
        }

        try {
            viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
        } catch (BadLocationException exception) {
            // Should not happen
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaEditor.java   
@Override
protected void setCaretPosition(int position) {
    if (!validateEditorInputState())
        return;

    final int length;
    final ISourceViewer viewer= getSourceViewer();
    StyledText text= viewer.getTextWidget();
    Point widgetSelection= text.getSelection();
    if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
        final int caret= text.getCaretOffset();
        final int offset= modelOffset2WidgetOffset(viewer, position);

        if (caret == widgetSelection.x)
            text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
        else
            text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
        text.invokeAction(ST.DELETE_PREVIOUS);
    } else {
        Point selection= viewer.getSelectedRange();
        if (selection.y != 0) {
            position= selection.x;
            length= selection.y;
        } else {
            length= widgetOffset2ModelOffset(viewer, text.getCaretOffset()) - position;
        }

        try {
            viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
        } catch (BadLocationException exception) {
            // Should not happen
        }
    }
}
项目:tmxeditor8    文件:GridCopyEnable.java   
public void doAction(int action) {
    switch (action) {
    case ST.COPY:
        copy();
        break;
    default:
        break;
    }
}
项目:tmxeditor8    文件:GridCopyEnable.java   
/**
 * Updates the selection based on the caret position
 */
void doMouseSelection() {
    if (caretOffset <= selection.x
            || (caretOffset > selection.x && caretOffset < selection.y && selectionAnchor == selection.x)) {
        doSelection(ST.COLUMN_PREVIOUS);// left
    } else {
        doSelection(ST.COLUMN_NEXT); // right
    }
}
项目:Pydev    文件:SubWordActions.java   
@Override
protected void setCaretPosition(final int position) {
    if (!validateEditorInputState()) {
        return;
    }

    final ISourceViewer viewer = getSourceViewer();
    StyledText text = viewer.getTextWidget();
    Point widgetSelection = text.getSelection();
    if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
        final int caret = text.getCaretOffset();
        final int offset = modelOffset2WidgetOffset(viewer, position);

        if (caret == widgetSelection.x) {
            text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
        } else {
            text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
        }
        text.invokeAction(ST.DELETE_NEXT);
    } else {
        Point selection = viewer.getSelectedRange();
        final int caret, length;
        if (selection.y != 0) {
            caret = selection.x;
            length = selection.y;
        } else {
            caret = widgetOffset2ModelOffset(viewer, text.getCaretOffset());
            length = position - caret;
        }

        try {
            viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
        } catch (BadLocationException exception) {
            // Should not happen
        }
    }
}
项目:Pydev    文件:SubWordActions.java   
@Override
protected void setCaretPosition(int position) {
    if (!validateEditorInputState()) {
        return;
    }

    final int length;
    final ISourceViewer viewer = getSourceViewer();
    StyledText text = viewer.getTextWidget();
    Point widgetSelection = text.getSelection();
    if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
        final int caret = text.getCaretOffset();
        final int offset = modelOffset2WidgetOffset(viewer, position);

        if (caret == widgetSelection.x) {
            text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
        } else {
            text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
        }
        text.invokeAction(ST.DELETE_PREVIOUS);
    } else {
        Point selection = viewer.getSelectedRange();
        if (selection.y != 0) {
            position = selection.x;
            length = selection.y;
        } else {
            length = widgetOffset2ModelOffset(viewer, text.getCaretOffset()) - position;
        }

        try {
            viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
        } catch (BadLocationException exception) {
            // Should not happen
        }
    }
}
项目:relations    文件:Styles.java   
/**
 * Convenience method, returns the appropriate <code>Bullet</code> instance
 * for the specified bullet style.
 * 
 * @param inBulletStyle
 *            bullet style
 * @param inWidth
 *            int
 * @return Bullet
 */
public static Bullet getBullet(final int inBulletStyle, final int inWidth) {
    int lOr = 0;
    String lBulletText = ""; //$NON-NLS-1$
    if ((inBulletStyle & (ST.BULLET_LETTER_UPPER | ST.BULLET_LETTER_LOWER)) != 0) {
        lOr = ST.BULLET_TEXT;
        lBulletText = ")"; //$NON-NLS-1$
    }
    final Bullet outBullet = new Bullet(inBulletStyle | lOr,
            getDefaultRange(inWidth));
    outBullet.text = lBulletText;
    return outBullet;
}
项目:relations    文件:Styles.java   
/**
 * @param inStyleRange
 * @param inBullet
 */
private StyleParameter(final StyleRange inStyleRange,
        final Bullet inBullet) {
    toggleStates = new HashMap<Styles.Style, Boolean>(7);

    // font styles
    if (inStyleRange == null) {
        toggleStates.put(Style.BOLD, Boolean.FALSE);
        toggleStates.put(Style.ITALIC, Boolean.FALSE);
        toggleStates.put(Style.UNDERLINE, Boolean.FALSE);
    } else {
        toggleStates.put(Style.BOLD, Boolean
                .valueOf((inStyleRange.fontStyle & SWT.BOLD) != 0));
        toggleStates.put(Style.ITALIC, Boolean
                .valueOf((inStyleRange.fontStyle & SWT.ITALIC) != 0));
        toggleStates.put(Style.UNDERLINE,
                Boolean.valueOf(inStyleRange.underline));
    }

    // list styles
    if (inBullet == null) {
        toggleStates.put(Style.UNORDERED, Boolean.FALSE);
        toggleStates.put(Style.NUMBERED, Boolean.FALSE);
        toggleStates.put(Style.UPPERCASE, Boolean.FALSE);
        toggleStates.put(Style.LOWERCASE, Boolean.FALSE);
    } else {
        toggleStates.put(Style.UNORDERED,
                Boolean.valueOf((inBullet.type & ST.BULLET_DOT) != 0));
        toggleStates.put(Style.NUMBERED, Boolean
                .valueOf((inBullet.type & ST.BULLET_CUSTOM) != 0));
        toggleStates
                .put(Style.UPPERCASE,
                        Boolean.valueOf((inBullet.type & ST.BULLET_LETTER_UPPER) != 0));
        toggleStates
                .put(Style.LOWERCASE,
                        Boolean.valueOf((inBullet.type & ST.BULLET_LETTER_LOWER) != 0));
    }
}
项目:Black    文件:logDialog.java   
public void appendLog(String text){
    styledText.append(text);
    styledText.invokeAction(ST.PAGE_DOWN);
}
项目:bts    文件:XtextEditor.java   
/**
 * Creates a new navigate next sub-word action.
 */
public NavigateNextSubWordAction() {
    super(ST.WORD_NEXT);
}
项目:bts    文件:XtextEditor.java   
/**
 * Creates a new delete next sub-word action.
 */
public DeleteNextSubWordAction() {
    super(ST.DELETE_WORD_NEXT);
}
项目:bts    文件:XtextEditor.java   
/**
 * Creates a new select next sub-word action.
 */
public SelectNextSubWordAction() {
    super(ST.SELECT_WORD_NEXT);
}
项目:bts    文件:XtextEditor.java   
/**
 * Creates a new navigate previous sub-word action.
 */
public NavigatePreviousSubWordAction() {
    super(ST.WORD_PREVIOUS);
}
项目:bts    文件:XtextEditor.java   
/**
 * Creates a new delete previous sub-word action.
 */
public DeletePreviousSubWordAction() {
    super(ST.DELETE_WORD_PREVIOUS);
}
项目:bts    文件:XtextEditor.java   
/**
 * Creates a new select previous sub-word action.
 */
public SelectPreviousSubWordAction() {
    super(ST.SELECT_WORD_PREVIOUS);
}
项目:mipsasm    文件:Ide.java   
private void onCreateShell() {

        shell = new Shell(display, SWT.SHELL_TRIM);

        shell.setImages(icons);

        shell.setLayout(new FillLayout());

        sashForm = new SashForm(shell, SWT.VERTICAL);

        editText = new StyledText(sashForm, SWT.H_SCROLL | SWT.V_SCROLL);
        editText.setAlwaysShowScrollBars(false);
        editText.setFont(editFont);
        editText.setTabs(8);
        editText.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent modifyEvent) {
                onTextChanged();
            }
        });
        editText.setKeyBinding(SWT.MOD1 | 'A', ST.SELECT_ALL);
        StyledTextStyleHelper.setup(editText);
        undoRedoHelper = new StyledTextUndoRedoHelper(editText);
        editText.setMenu(StyledTextMenuHelper.createMenu(SWT.POP_UP, editText, undoRedoHelper, resourceBundle));
        DropTarget dropTarget = new DropTarget(editText, DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_MOVE
                | DND.DROP_LINK);
        dropTarget.setTransfer(new Transfer[]{FileTransfer.getInstance()});
        dropTarget.addDropListener(new DropTargetAdapter() {
            @Override
            public void drop(DropTargetEvent dropTargetEvent) {
                FileTransfer fileTransfer = FileTransfer.getInstance();
                if (fileTransfer.isSupportedType(dropTargetEvent.currentDataType)) {
                    String filename = ((String[]) dropTargetEvent.data)[0];
                    if (confirmOpen()) {
                        openFile(filename);
                    }
                }
            }
        });

        messageText = new StyledText(sashForm, SWT.H_SCROLL | SWT.V_SCROLL);
        messageText.setAlwaysShowScrollBars(false);
        messageText.setEditable(false);
        messageText.setFont(editFont);
        messageText.setKeyBinding(SWT.MOD1 | 'A', ST.SELECT_ALL);
        messageText.setMenu(StyledTextMenuHelper.createMenu(SWT.POP_UP, messageText, resourceBundle));

        sashForm.setWeights(new int[]{8, 2});

        // Menu depends on editText
        onCreateMenu();
        shell.setMenuBar(menu);

        shell.addListener(SWT.Close, new Listener() {
            @Override
            public void handleEvent(Event event) {
                event.doit = onClose();
            }
        });

        updateTitle();
    }
项目:Eclipse-Postfix-Code-Completion    文件:JavaEditor.java   
/**
 * Creates a new navigate next sub-word action.
 */
public NavigateNextSubWordAction() {
    super(ST.WORD_NEXT);
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaEditor.java   
/**
 * Creates a new delete next sub-word action.
 */
public DeleteNextSubWordAction() {
    super(ST.DELETE_WORD_NEXT);
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaEditor.java   
/**
 * Creates a new select next sub-word action.
 */
public SelectNextSubWordAction() {
    super(ST.SELECT_WORD_NEXT);
}