本文整理汇总了Java中org.eclipse.swt.custom.StyledText类的典型用法代码示例。如果您正苦于以下问题:Java StyledText类的具体用法?Java StyledText怎么用?Java StyledText使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StyledText类属于org.eclipse.swt.custom包,在下文中一共展示了StyledText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStyledTextRenderer
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
private static /* org.eclipse.swt.custom.StyledTextRenderer */ Object createStyledTextRenderer(
StyledText styledText, ILineSpacingProvider lineSpacingProvider) throws Exception {
// get the org.eclipse.swt.custom.StyledTextRenderer instance of
// StyledText
/* org.eclipse.swt.custom.StyledTextRenderer */ Object originalRenderer = getRendererField(styledText)
.get(styledText);
// Create a Javassist proxy
ProxyFactory factory = new ProxyFactory();
factory.setSuperclass(originalRenderer.getClass());
StyledTextRenderer renderer = new StyledTextRenderer(styledText, originalRenderer.getClass());
renderer.setLineSpacingProvider(lineSpacingProvider);
factory.setHandler(renderer);
return factory.create(new Class[] { Device.class, StyledText.class },
new Object[] { styledText.getDisplay(), styledText });
}
示例2: createSuffixText
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
* Creates, configures and returns the suffix text control.
*/
private StyledText createSuffixText() {
StyledText styledText = new StyledText(this, SWT.TRANSPARENT);
styledText.setText("");
styledText.setForeground(INACTIVE_COLOR);
styledText.setBackground(getDisplay().getSystemColor(SWT.COLOR_TRANSPARENT));
styledText.setEditable(false);
styledText.setEnabled(false);
styledText.setLeftMargin(0);
return styledText;
}
示例3: createPartControl
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
Control adapter = getAdapter(Control.class);
if (adapter instanceof StyledText) {
StyledText text = (StyledText) adapter;
text.addCaretListener(new BatchEditorCaretListener());
}
activateBatchEditorContext();
installAdditionalSourceViewerSupport();
StyledText styledText = getSourceViewer().getTextWidget();
styledText.addKeyListener(new BatchBracketInsertionCompleter(this));
/*
* register as resource change listener to provide marker change
* listening
*/
ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
setTitleImageInitial();
}
示例4: createPartControl
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
Control adapter = getAdapter(Control.class);
if (adapter instanceof StyledText) {
StyledText text = (StyledText) adapter;
text.addCaretListener(new BashEditorCaretListener());
}
activateBashEditorContext();
installAdditionalSourceViewerSupport();
StyledText styledText = getSourceViewer().getTextWidget();
styledText.addKeyListener(new BashBracketInsertionCompleter(this));
/*
* register as resource change listener to provide marker change
* listening
*/
ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
setTitleImageInitial();
}
示例5: paint
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
@Override
public void paint(int reason) {
IDocument document = textViewer.getDocument();
if (document == null) {
deactivate(false);
return;
}
if (!fIsActive) {
StyledText styledText = textViewer.getTextWidget();
fIsActive = true;
styledText.addPaintListener(this);
redrawAll();
} else if (reason == CONFIGURATION || reason == INTERNAL) {
redrawAll();
}
}
示例6: draw
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
@Override
public void draw(int paintX, int paintSpaceLeadingX, int paintY, GC gc) {
StyledText styledText = getTextViewer().getTextWidget();
Rectangle client = styledText.getClientArea();
gc.setBackground(styledText.getDisplay().getSystemColor(SWT.COLOR_WHITE));
styledText.drawBackground(gc, paintX, paintY, client.width, this.getHeightInPx());
gc.setForeground(styledText.getDisplay().getSystemColor(SWT.COLOR_GRAY));
Font font = new Font(styledText.getDisplay(), "Arial", 9, SWT.ITALIC);
gc.setFont(font);
String text = getText(gc, paintSpaceLeadingX);
if (text != null) {
int y = paintY + 4;
gc.drawText(text, paintSpaceLeadingX, y);
if (hoveredCodeLensEndX != null) {
Point extent = gc.textExtent(text);
gc.drawLine(hoveredCodeLensStartX, y + extent.y - 1, hoveredCodeLensEndX, y + extent.y - 1);
}
}
}
示例7: setupControls
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
* Recursive function for setting up children controls for a control if it is
* a composite and setting up the main control's manager.
* @param part
* @param control
*/
private void setupControls(IWorkbenchPart part, Control control) {
//If composite, setup children controls.
if (control instanceof Composite) {
Composite composite = (Composite) control;
Control[] children = composite.getChildren();
if (children.length > 0 && children[0] != null) {
for (Control curControl : children)
setupControls(part, curControl);
}
}
if (control instanceof StyledText) {
//set up styled text manager if there is one
setupStyledText((IEditorPart) part, (StyledText) control);
} else if (control instanceof Browser) {
//set up browser manager if there is one
setupBrowser((Browser) control);
}
//TODO: no control set up for a ProjectExplorer, since there isn't an need for
//a Manager right now, might be needed in the future
}
示例8: createTextWidget
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
protected void createTextWidget(String textContents) {
StyledText styledText = new StyledText(getComposite(), SWT.NONE);
styledText.setText(textContents);
styledText.setFont(getCourierFont());
styledText.setEditable(false);
//styledText.setWordWrap(true); // seems to throw size out-of-whack
Point size = styledText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
getComposite().setContent(styledText);
getComposite().setExpandHorizontal(true);
getComposite().setExpandVertical(true);
getComposite().setMinWidth(size.x);
getComposite().setMinHeight(size.y);
getComposite().getContent().addListener(SWT.KeyUp, getToolbarCommandHandler());
getToolItem().setSelection(true);
setContentTypeAdapter(new StyledTextAdapter(styledText, getFileEntry().getFilename()));
}
示例9: createContents
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
private void createContents(String str) {
aboutToolsShell = new Shell(getParent(), getStyle());
aboutToolsShell.setImage(SWTResourceManager.getImage(ShortcutKeyExplain.class, Resource.IMAGE_ICON));
aboutToolsShell.setSize(400, 391);
aboutToolsShell.setText(getText());
PubUtils.setCenterinParent(getParent(), aboutToolsShell);
Link link = new Link(aboutToolsShell, SWT.NONE);
link.setBounds(143, 336, 108, 17);
link.setText("<a>www.itlaborer.com</a>");
link.addSelectionListener(new LinkSelection());
StyledText readMeTextLabel = new StyledText(aboutToolsShell,
SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
readMeTextLabel.setBounds(3, 33, 389, 297);
readMeTextLabel.setText(str);
Label label_2 = new Label(aboutToolsShell, SWT.NONE);
label_2.setFont(org.eclipse.wb.swt.SWTResourceManager.getFont("微软雅黑", 9, SWT.BOLD));
label_2.setText("快捷键说明:");
label_2.setBounds(3, 12, 136, 17);
}
示例10: createStyledText
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
private StyledText createStyledText() {
styledText = new StyledText(shell,
SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); // SWT.WRAP
GridData gridData = new GridData();
styledText.setFont(
new Font(shell.getDisplay(), "Source Code Pro Light", 10, SWT.NORMAL));
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
styledText.setLayoutData(gridData);
styledText.addLineStyleListener(lineStyler);
styledText.setEditable(false);
styledText
.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
return styledText;
}
示例11: newTextArea
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
public StyledText newTextArea(Composite composite, boolean editable, int sty) {
int style = SWT.MULTI | SWT.V_SCROLL;
if (!editable)
style |= SWT.READ_ONLY;
else
style |= SWT.WRAP;
StyledText d = new StyledText(composite, style);
d.setText("To be entered\ntest\n\test\ntest");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 80;
gd.widthHint = 460;
gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
d.setEditable(editable);
d.setLayoutData(gd);
d.setFont(FontShop.textFont());
if (keyListener != null)
d.addKeyListener(keyListener);
d.setWordWrap(editable);
WidgetShop.tweakTextWidget(d);
return d;
}
示例12: prevButtonListener
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
* The function will move cursor in reverse direction.
* @param styledText
* @param text
* @param prevLineIndex
* @param nextLineIndex
* @return int[]
*/
public int[] prevButtonListener(StyledText styledText, String text, int prevLineIndex, int nextLineIndex){
logger.debug("StyledText prev button selected");
if(prevLineIndex == 0){
prevLineIndex = styledText.getText().length() - 1;
}
int lastIndex = StringUtils.lastIndexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), prevLineIndex-1);
if(lastIndex < 0 ){
prevLineIndex = styledText.getText().length() - 1;
prevLineIndex= StringUtils.lastIndexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), prevLineIndex-1);
styledText.setSelection(prevLineIndex);
setStyledRange(styledText, prevLineIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
nextLineIndex = prevLineIndex + 1;
return new int[]{prevLineIndex,nextLineIndex};
}else{
setStyledRange(styledText, lastIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
styledText.setSelection(lastIndex);
prevLineIndex = lastIndex;
nextLineIndex = lastIndex + 1;
styledText.redraw();
}
return new int[]{prevLineIndex,nextLineIndex};
}
示例13: nextButtonListener
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
* The function will move the cursor in forward direction.
* @param styledText
* @param text
* @param prevLineIndex
* @param nextLineIndex
* @return int[]
*/
public int[] nextButtonListener(StyledText styledText, String text, int prevLineIndex, int nextLineIndex){
logger.debug("StyledText next button selected");
int txtIndex = StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), nextLineIndex);
if(txtIndex < 0){
nextLineIndex = 0;
prevLineIndex = StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), nextLineIndex);
nextLineIndex = prevLineIndex + 1;
styledText.setSelection(prevLineIndex);
setStyledRange(styledText, prevLineIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
return new int[]{prevLineIndex,nextLineIndex};
}else{
setStyledRange(styledText, txtIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
styledText.setSelection(txtIndex);
prevLineIndex = txtIndex;
nextLineIndex = txtIndex+1;
styledText.redraw();
}
return new int[]{prevLineIndex,nextLineIndex};
}
示例14: allButtonListener
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
* The function will change selected text background color.
* @param styledText
* @param text
* @param foreground
* @param background
*/
public void allButtonListener(StyledText styledText, String text, Color foreground, Color background, Label label){
logger.debug("StyledText All button selected");
int index = 0;
int recordCount = 0;
if(styledText == null){return;}
for(;index < styledText.getText().length();){
int lastIndex = StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), index);
if(lastIndex < 0){return;}
else{
setStyledRange(styledText, lastIndex, text.length(), null, background);
index = lastIndex + 1;
recordCount++ ;
label.setVisible(true);
label.setText("Matching count - " + recordCount);
}
}
}
示例15: validateAndCloseCommentEditor
import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
private void validateAndCloseCommentEditor(StyledText styledText) {
commentFigure.setText(styledText.getText(),commentBoxModel);
if (!StringUtils.equals(styledText.getText(), commentBoxModel.getLabelContents())) {
commentBoxModel.setLabelContents(styledText.getText());
((ELTGraphicalEditor) commentFigure.getComponentCanvas()).setDirty(true);
}
shell.close();
}