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

项目: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);
}
项目:mytourbook    文件:DialogModifyMapProvider.java   
private void createUI30Hints(final Composite parent) {

        final Composite container = new Composite(parent, SWT.NONE);
        GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(container);
        GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
        {
            // use a bulleted list to display this info
            final StyleRange style = new StyleRange();
            style.metrics = new GlyphMetrics(0, 0, 10);
            final Bullet bullet = new Bullet(style);

            final String infoText = Messages.Modify_MapProvider_Label_Hints;
            final int lineCount = Util.countCharacter(infoText, '\n');

            final StyledText styledText = new StyledText(container, SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
            GridDataFactory.fillDefaults().grab(true, false).applyTo(styledText);
            styledText.setText(infoText);
            styledText.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
            styledText.setLineBullet(1, lineCount, bullet);
            styledText.setLineWrapIndent(1, lineCount, 10);
        }
    }
项目:mytourbook    文件:DialogModifyColumns.java   
private void createUI_76_Hints(final Composite parent) {

        // use a bulleted list to display this info
        final StyleRange style = new StyleRange();
        style.metrics = new GlyphMetrics(0, 0, 10);
        final Bullet bullet = new Bullet(style);

        final String infoText = Messages.ColumnModifyDialog_Label_Hints;
        final int lineCount = Util.countCharacter(infoText, '\n');

        final StyledText styledText = new StyledText(parent, SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
        styledText.setText(infoText);
        styledText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
        styledText.setLineBullet(1, lineCount, bullet);
        styledText.setLineWrapIndent(1, lineCount, 10);
        GridDataFactory.fillDefaults()//
                .grab(true, false)
                .span(2, 1)
                .applyTo(styledText);
    }
项目:Eclipse-Postfix-Code-Completion    文件:BulletListBlock.java   
private void configureStyledText(String text, boolean enabled) {
    if (fStyledText == null)
        return;

    fStyledText.setText(text);
    int count= fStyledText.getCharCount();
    if (count == 0)
        return;

    Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);

    fStyledText.setStyleRange(new StyleRange(0, count, foreground, null));

    StyleRange styleRange= new StyleRange(0, count, foreground, null);
    styleRange.metrics= new GlyphMetrics(0, 0, 20);
    fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange));

    fStyledText.setEnabled(enabled);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BulletListBlock.java   
private void configureStyledText(String text, boolean enabled) {
    if (fStyledText == null)
        return;

    fStyledText.setText(text);
    int count= fStyledText.getCharCount();
    if (count == 0)
        return;

    Color foreground= enabled ? null : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);

    fStyledText.setStyleRange(new StyleRange(0, count, foreground, null));

    StyleRange styleRange= new StyleRange(0, count, foreground, null);
    styleRange.metrics= new GlyphMetrics(0, 0, 20);
    fStyledText.setLineBullet(0, fStyledText.getLineCount(), new Bullet(styleRange));

    fStyledText.setEnabled(enabled);
}
项目: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 = "";
    }
}
项目:relations    文件:StyleParser.java   
private String applyBlockTags(final List<String> inLines,
        final StyledText inWidget) {
    int lLine = 0;
    final int lLength = inWidget.getLineCount();

    final ListSerializer lRoot = new ListSerializer(null, lLine, null);
    ListSerializer lSerializer = lRoot;
    while (lLine < lLength) {
        final Bullet lBullet = inWidget.getLineBullet(lLine);
        if (lBullet != null) {
            lSerializer = lSerializer.processBullet(lBullet, lLine);
        } else {
            lSerializer = lSerializer.consolidate(lLine, lRoot);
        }
        lLine++;
    }
    lSerializer.consolidate(lLength, lRoot);
    return lRoot.render(inLines);
}
项目: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);
}
项目:relations    文件:StyleParser.java   
/**
 * Processed the specified bullet. Check's whether the specified bullet
 * belongs to the acutal list, the parent list or a new sublist.
 *
 * @param inBullet
 *            Bullet
 * @param inLine
 *            int line index
 * @return BulletSerializer either the actual, the parent or a new
 *         sublist's serializer.
 */
public ListSerializer processBullet(final Bullet inBullet,
        final int inLine) {
    // we're still in the same list
    if (inBullet == bullet) {
        return this;
    }

    // we returned to the parent list
    final ListSerializer lAncestor = getAncestor(inBullet);
    if (lAncestor != null) {
        return consolidate(inLine, lAncestor);
    }

    // create new list or sublist
    endLine = inLine; // at this line, we switched to another bullet
    return new ListSerializer(inBullet, inLine, this);
}
项目:relations    文件:TextStyler.java   
private boolean doIndent(final Point inLineSelection) {
    final int lBlockStart = inLineSelection.x;
    final Bullet lBullet = widget.getLineBullet(lBlockStart);
    if (lBullet == null) {
        return false;
    }
    if (lBlockStart > 0) {
        final Bullet lBulletBefore = widget.getLineBullet(lBlockStart - 1);
        if (lBulletBefore == null) {
            return false;
        }
        if (lBullet.hashCode() == lBulletBefore.hashCode()) {
            return true;
        }
    }
    return false;
}
项目:relations    文件:TextStyler.java   
/**
 * Remove indent of the selected or (if no selection) actual line.
 */
public void dedentLines() {
    final Point lLineSelection = getLineSelection();
    Bullet lBullet = widget.getLineBullet(lLineSelection.x);
    // do we have to merge the selection with the preceding line style?
    if (lLineSelection.x > 0) {
        lBullet = searchFistDifferentBullet(lLineSelection.x, lBullet);
    } else {
        final int lIndent = Math.max(Styles.BULLET_WIDTH,
                lBullet.style.metrics.width - Styles.INDENT);
        lBullet = Styles.getBullet(lBullet.type, lIndent);
    }
    widget.setLineBullet(lLineSelection.x, lLineSelection.y, null);
    widget.setLineBullet(lLineSelection.x, lLineSelection.y, lBullet);
    widget.redraw();
}
项目:relations    文件:TextStyler.java   
private void unformatSelectedBlock(final int inLineStart,
        final int inLineCount) {
    final Bullet lOldBullet = widget.getLineBullet(inLineStart);
    widget.setLineBullet(inLineStart, inLineCount, null);
    // check for nested lists
    if (inLineStart == 0) {
        return;
    }
    final Bullet lBullet = widget.getLineBullet(inLineStart - 1);
    if (lBullet == null) {
        return;
    }
    // the bullet of the preceding line is different, therefore, apply it to
    // the actual lines
    if (lBullet != lOldBullet) {
        widget.setLineBullet(inLineStart, inLineCount, lBullet);
    }
}
项目:gw4e.project    文件:TestPresentationPage.java   
private Bullet buildMainModelStyle() {
    StyleRange style = new StyleRange();
    style.metrics = new GlyphMetrics(0, 0, 40);
    style.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
    Bullet bullet = new Bullet(style);
    return bullet;
}
项目:gw4e.project    文件:TestPresentationPage.java   
private Bullet buildAdditionalTitleModelStyle() {
    StyleRange style = new StyleRange();
    style.metrics = new GlyphMetrics(0, 0, 40);
    style.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
    Bullet bullet = new Bullet(style);
    return bullet;
}
项目: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);
    }
}
项目: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);     
    }
项目: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 };
}
项目:relations    文件:StyleParserTest.java   
private void assertEqualBullets(final String inMsg,
        final Bullet inExpected, final Bullet inActual) {
    if (inExpected == null) {
        assertNull(inMsg, inActual);
        return;
    }
    assertTrue(
            inMsg,
            inExpected.type == inActual.type
                    && inExpected.style.metrics.width == inActual.style.metrics.width);
}
项目: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));
    }
}
项目:relations    文件:StyleParser.java   
public ListSerializer(final Bullet inBullet, final int inStart,
        final ListSerializer inParent) {
    bullet = inBullet;
    startLine = inStart;
    parent = inParent;
    if (inBullet != null) {
        tagTemplate = getTagTemplate(inBullet);
    }
}
项目:relations    文件:StyleParser.java   
public ListSerializer getAncestor(final Bullet inBullet) {
    if (isRoot()) {
        return null;
    }
    if (inBullet == parent.bullet) {
        return parent;
    }
    return parent.getAncestor(inBullet);
}
项目:relations    文件:StyledTextComponent.java   
private boolean similarBullet(final Bullet inBullet) {
    if (bullet == inBullet)
        return true;
    if (inBullet == null)
        return false;
    if (bullet == null) {
        if (inBullet != null)
            return false;
    } else if (bullet.type != inBullet.type)
        return false;
    return true;
}
项目:relations    文件:StyledTextComponent.java   
public BulletsState(final StyledText inWidget) {
    inWidget.getLineCount();
    for (int i = 0; i < inWidget.getLineCount(); i++) {
        final Bullet lBullet = inWidget.getLineBullet(i);
        if (lBullet != null) {
            bullets.add(new LineBulletState(i, lBullet.type,
                    lBullet.style.metrics.width));
        }
    }
}
项目:relations    文件:StyledTextComponent.java   
public void undo(final StyledText inWidget) {
    final Hashtable<String, Bullet> lUsed = new Hashtable<String, Bullet>();
    for (final LineBulletState lBulletState : bullets) {
        Bullet lBullet = lUsed.get(lBulletState.getKey());
        if (lBullet == null) {
            lBullet = Styles.getBullet(lBulletState.type,
                    lBulletState.width);
            lUsed.put(lBulletState.getKey(), lBullet);
        }
        inWidget.setLineBullet(lBulletState.index, 1, lBullet);
    }
}
项目:relations    文件:TextStyler.java   
private Bullet searchFistDifferentBullet(final int inLineStart,
        final Bullet inBullet) {
    int i = inLineStart;
    while (i > 0) {
        Bullet outBullet = null;
        if ((outBullet = widget.getLineBullet(--i)) != inBullet) {
            return outBullet;
        }
    }
    return null;
}
项目:mytourbook    文件:PrefPageMap2Appearance.java   
private void createUI_60_PaintingMethod(final Composite parent) {

        final Display display = parent.getDisplay();

        /*
         * checkbox: paint tour method
         */

        final Group groupMethod = new Group(parent, SWT.NONE);
        GridDataFactory.fillDefaults().applyTo(groupMethod);
        groupMethod.setText(Messages.Pref_MapLayout_Label_TourPaintMethod);
//      groupMethod.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
        {
            _editorTourPaintMethod = new RadioGroupFieldEditor(
                    ITourbookPreferences.MAP_LAYOUT_TOUR_PAINT_METHOD,
                    UI.EMPTY_STRING,
                    2,
                    new String[][] {
                            { Messages.Pref_MapLayout_Label_TourPaintMethod_Simple, TOUR_PAINT_METHOD_SIMPLE },
                            { Messages.Pref_MapLayout_Label_TourPaintMethod_Complex, TOUR_PAINT_METHOD_COMPLEX } },
                    groupMethod);

            addField(_editorTourPaintMethod);

            _pageBookPaintMethod = new PageBook(groupMethod, SWT.NONE);
            GridDataFactory.fillDefaults()//
                    .grab(true, false)
                    .span(2, 1)
                    .hint(350, SWT.DEFAULT)
                    .indent(16, 0)
                    .applyTo(_pageBookPaintMethod);

            // use a bulleted list to display this info
            final StyleRange style = new StyleRange();
            style.metrics = new GlyphMetrics(0, 0, 10);
            final Bullet bullet = new Bullet(style);

            /*
             * simple painting method
             */
            String infoText = Messages.Pref_MapLayout_Label_TourPaintMethod_Simple_Tooltip;
            int lineCount = Util.countCharacter(infoText, '\n');

            _pageSimple = new StyledText(_pageBookPaintMethod, SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
            GridDataFactory.fillDefaults().grab(true, false).applyTo(_pageSimple);
            _pageSimple.setText(infoText);
            _pageSimple.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
            _pageSimple.setLineBullet(0, lineCount + 1, bullet);
            _pageSimple.setLineWrapIndent(0, lineCount + 1, 10);

            /*
             * complex painting method
             */
            infoText = Messages.Pref_MapLayout_Label_TourPaintMethod_Complex_Tooltip;
            lineCount = Util.countCharacter(infoText, '\n');

            _pageComplex = new StyledText(_pageBookPaintMethod, SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
            GridDataFactory.fillDefaults().grab(true, false).applyTo(_pageComplex);
            _pageComplex.setText(infoText);
            _pageComplex.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
            _pageComplex.setLineBullet(0, lineCount + 1, bullet);
            _pageComplex.setLineWrapIndent(0, lineCount + 1, 10);
        }

        // set group margin after the fields are created
        GridLayoutFactory.swtDefaults().margins(0, 5).numColumns(2).applyTo(groupMethod);
    }
项目:mytourbook    文件:FormTools.java   
/**
 * Display text as a bulleted list
 * 
 * @param parent
 * @param bulletText
 * @param startLine
 *            Line where bullets should be started, 0 is the first line
 * @param spanHorizontal
 * @param horizontalHint
 * @param backgroundColor
 *            background color or <code>null</code> when color should not be set
 * @return Returns the bulleted list as styled text
 */
public static StyledText createBullets( final Composite parent,
                                        final String bulletText,
                                        final int startLine,
                                        final int spanHorizontal,
                                        final int horizontalHint,
                                        final Color backgroundColor) {

    StyledText styledText = null;

    try {

        final Composite container = new Composite(parent, SWT.NONE);
        GridDataFactory.fillDefaults()//
                .grab(true, false)
                .span(spanHorizontal, 1)
                .hint(horizontalHint, SWT.DEFAULT)
                .applyTo(container);
        GridLayoutFactory.fillDefaults()//
                .numColumns(1)
                .margins(5, 5)
                .applyTo(container);

        container.setBackground(backgroundColor == null ? //
                container.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)
                : backgroundColor);
        {
            final StyleRange style = new StyleRange();
            style.metrics = new GlyphMetrics(0, 0, 10);

            final Bullet bullet = new Bullet(style);
            final int lineCount = Util.countCharacter(bulletText, '\n');

            styledText = new StyledText(container, SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
            GridDataFactory.fillDefaults().grab(true, false).applyTo(styledText);
            styledText.setText(bulletText);

            styledText.setLineBullet(startLine, lineCount, bullet);
            styledText.setLineWrapIndent(startLine, lineCount, 10);

            styledText.setBackground(backgroundColor == null ? //
                    container.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)
                    : backgroundColor);
        }

    } catch (final Exception e) {
        // ignore exception when there are less lines as required
        StatusUtil.log(e);
    }

    return styledText;
}
项目:relations    文件:StyleParserTest.java   
@Test
public void testParseList() throws Exception {
    final String lTestList1 = "line 1" + NL
            + "<ol_number indent=\"0\"><li>line 2" + NL
            + "<ol_upper indent=\"1\"><li>line 3</li>" + NL
            + "<li>line 4</li>" + NL
            + "</ol_upper><ol_lower indent=\"2\"><li>line 5</li>" + NL
            + "</ol_lower></li><li>line 6" + NL
            + "<ul indent=\"1\"><li>line 7</li>" + NL + "<li>line 8</li>"
            + NL + "</ul></li><li>line 9</li>" + NL + "</ol_number>line 10";
    final String lTestList2 = "<ol_number indent=\"0\"><li>line 1" + NL
            + "<ol_upper indent=\"1\"><li>line 2</li>" + NL + "<li>line 3"
            + NL + "<ol_lower indent=\"2\"><li>line 4</li>" + NL
            + "<li>line 5</li>" + NL + "</ol_lower></li><li>line 6</li>"
            + NL + "</ol_upper></li><li>line 7" + NL
            + "<ul indent=\"1\"><li>line 8</li>" + NL + "<li>line 9</li>"
            + NL + "</ul></li><li>line 10</li>" + NL + "</ol_number>";
    final String lTestList3 = "line 1" + NL
            + "<ol_number indent=\"0\"><li>line 2</li>" + NL
            + "<li>line 3</li>" + NL + "<li>line 4</li>" + NL
            + "<li>line 5</li>" + NL + "<li>line 6</li>" + NL
            + "<li>line 7</li>" + NL + "</ol_number>line 8";

    StyledText lWidget = new StyledText(parent, SWT.NONE);
    StyleParser.getInstance().parseTagged(lTestList1, lWidget);

    final Bullet lBullet1 = Styles.getBullet(ST.BULLET_CUSTOM,
            Styles.BULLET_WIDTH);
    final Bullet lBullet2 = Styles.getBullet(ST.BULLET_LETTER_UPPER,
            Styles.BULLET_WIDTH + Styles.INDENT);
    final Bullet lBullet3 = Styles.getBullet(ST.BULLET_LETTER_LOWER,
            Styles.BULLET_WIDTH + 2 * Styles.INDENT);
    final Bullet lBullet4 = Styles.getBullet(ST.BULLET_DOT,
            Styles.BULLET_WIDTH + Styles.INDENT);

    String lExpectedText = "line 1" + NL + "line 2" + NL + "line 3" + NL
            + "line 4" + NL + "line 5" + NL + "line 6" + NL + "line 7" + NL
            + "line 8" + NL + "line 9" + NL + "line 10";
    Bullet[] lExpectedBullets = new Bullet[] { null, lBullet1, lBullet2,
            lBullet2, lBullet3, lBullet1, lBullet4, lBullet4, lBullet1,
            null };
    for (int i = 0; i < lExpectedBullets.length; i++) {
        assertEqualBullets("Bullet 1." + i, lExpectedBullets[i],
                lWidget.getLineBullet(i));
    }
    assertEquals("text 1", lExpectedText, lWidget.getText());

    lWidget = new StyledText(parent, SWT.NONE);
    StyleParser.getInstance().parseTagged(lTestList2, lWidget);
    lExpectedText = "line 1" + NL + "line 2" + NL + "line 3" + NL
            + "line 4" + NL + "line 5" + NL + "line 6" + NL + "line 7" + NL
            + "line 8" + NL + "line 9" + NL + "line 10" + NL;
    lExpectedBullets = new Bullet[] { lBullet1, lBullet2, lBullet2,
            lBullet3, lBullet3, lBullet2, lBullet1, lBullet4, lBullet4,
            lBullet1 };
    for (int i = 0; i < lExpectedBullets.length; i++) {
        assertEqualBullets("Bullet 2." + i, lExpectedBullets[i],
                lWidget.getLineBullet(i));
    }
    assertEquals("text 2", lExpectedText, lWidget.getText());

    lWidget = new StyledText(parent, SWT.NONE);
    StyleParser.getInstance().parseTagged(lTestList3, lWidget);

    lExpectedText = "line 1" + NL + "line 2" + NL + "line 3" + NL
            + "line 4" + NL + "line 5" + NL + "line 6" + NL + "line 7" + NL
            + "line 8";
    lExpectedBullets = new Bullet[] { null, lBullet1, lBullet1, lBullet1,
            lBullet1, lBullet1, lBullet1, null };
    for (int i = 0; i < lExpectedBullets.length; i++) {
        assertEqualBullets("Bullet 3." + i, lExpectedBullets[i],
                lWidget.getLineBullet(i));
    }
    assertEquals("text 3", lExpectedText, lWidget.getText());
}
项目:relations    文件:StyleParser.java   
public BulletHelper(final int inStart, final int inLength,
        final Bullet inBullet) {
    startLine = inStart;
    lineCount = inLength;
    bullet = inBullet;
}
项目:relations    文件:StyleParser.java   
public CustomBulletHelper(final int inStart, final int inLength,
        final Bullet inBullet) {
    super(inStart, inLength, inBullet);
}
项目:relations    文件:StyleParser.java   
public HelperFactory(final Bullet inBullet) {
    bullet = inBullet;
}
项目:relations    文件:TextStyler.java   
/**
 * Indents the selected block.
 *
 * @param inStyle
 *            StyleProperty. If <code>null</code>, the actual bullet style
 *            is used.
 * @param inLineStart
 *            int start of the lines to be indented
 * @param inLineCount
 *            int number of lines to be indented
 */
private void indentSelectedBlock(final Styles.Style inStyle,
        final int inLineStart, final int inLineCount) {
    final Bullet lBullet = widget.getLineBullet(inLineStart);
    final int lStyle = inStyle == null ? lBullet.type
            : inStyle.getStyleBit();
    widget.setLineBullet(inLineStart, inLineCount, null);
    widget.setLineBullet(inLineStart, inLineCount, Styles.getBullet(lStyle,
            lBullet.style.metrics.width + Styles.INDENT));
    widget.redraw();
}
项目:relations    文件:Styles.java   
/**
 * Factory method: creates a style parameter object from the specified
 * inline and list styles. This parameter object is used when the cursor is
 * moved in the styled text widget and the style buttons should reflect the
 * style states at the actual cursor position.
 * 
 * @param inStyleRange
 *            {@link StyleRange}
 * @param inBullet
 *            {@link Bullet}
 * 
 * @return {@link StyleParameter} indicating which styles at the actual
 *         cursor position are active
 */
public static StyleParameter createStyleParameter(
        final StyleRange inStyleRange, final Bullet inBullet) {
    return new StyleParameter(inStyleRange, inBullet);
}