当前位置: 首页>>代码示例>>Java>>正文


Java ST类代码示例

本文整理汇总了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);
}
 
开发者ID:PyvesB,项目名称:Notepad4e,代码行数:29,代码来源:Note.java

示例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;
}
 
开发者ID:Albertus82,项目名称:JFaceUtils,代码行数:20,代码来源:StyledTextConsole.java

示例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, "--");
    }
}
 
开发者ID:vlsi,项目名称:mat-calcite-plugin,代码行数:26,代码来源:CommentLineAction.java

示例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 = "";
	}
}
 
开发者ID:AndersDala,项目名称:eclipse-debug-console-history,代码行数:23,代码来源:StyledTextConsolePage.java

示例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);
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:19,代码来源:StyledTextWithoutVerticalBar.java

示例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);
	}
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:26,代码来源:StyleParser.java

示例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);
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:25,代码来源:StyleParser.java

示例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;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:9,代码来源:TestPresentationPage.java

示例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()]);
}
 
开发者ID:termsuite,项目名称:termsuite-ui,代码行数:36,代码来源:FileEditorPart.java

示例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);
	}
}
 
开发者ID:PyvesB,项目名称:Notepad4e,代码行数:12,代码来源:Note.java

示例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);
}
 
开发者ID:piiiiq,项目名称:Black,代码行数:14,代码来源:logShell.java

示例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);			
			

		}
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:40,代码来源:ATranscriptionWidget.java

示例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);		
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:11,代码来源:XmlViewer.java

示例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
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:36,代码来源:XtextEditor.java

示例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 };
}
 
开发者ID:Spacecraft-Code,项目名称:SPELL,代码行数:41,代码来源:CustomStyledText.java


注:本文中的org.eclipse.swt.custom.ST类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。