本文整理汇总了Java中org.eclipse.swt.custom.ST类的典型用法代码示例。如果您正苦于以下问题:Java ST类的具体用法?Java ST怎么用?Java ST使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ST类属于org.eclipse.swt.custom包,在下文中一共展示了ST类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bulletListSelection
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
/**
* 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);
}
示例2: createSelectAllMenuItem
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
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;
}
示例3: run
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
@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, "--");
}
}
示例4: lineGetStyle
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
@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 = "";
}
}
示例5: replaceStyleRanges
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
@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);
}
}
示例6: handleListTag
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
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);
}
}
示例7: getTagTemplate
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
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);
}
示例8: buildCheckedlStyle
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
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;
}
示例9: lineGetStyle
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
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()]);
}
示例10: deserialiseBullets
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
/**
* 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);
}
}
示例11: appendLog
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
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);
}
示例12: setLineBulletAndStuff
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
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);
}
}
示例13: setLineBullet
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
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);
}
示例14: setCaretPosition
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
@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
}
}
}
示例15: lineGetStyle
import org.eclipse.swt.custom.ST; //导入依赖的package包/类
@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 };
}