本文整理汇总了Java中org.eclipse.swt.custom.StyledText.setText方法的典型用法代码示例。如果您正苦于以下问题:Java StyledText.setText方法的具体用法?Java StyledText.setText怎么用?Java StyledText.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.custom.StyledText
的用法示例。
在下文中一共展示了StyledText.setText方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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()));
}
示例3: 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);
}
示例4: 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;
}
示例5: main
import org.eclipse.swt.custom.StyledText; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// create the widget's shell
Shell shell = new Shell();
shell.setLayout(new FillLayout());
shell.setSize(500, 500);
Display display = shell.getDisplay();
Composite parent = new Composite(shell, SWT.NONE);
parent.setLayout(new GridLayout());
StyledText styledText = new StyledText(parent, SWT.BORDER | SWT.V_SCROLL);
styledText.setLayoutData(new GridData(GridData.FILL_BOTH));
styledText.setText("a\nb\nc\nd");
StyledTextPatcher.setLineSpacingProvider(styledText, new ILineSpacingProvider() {
@Override
public Integer getLineSpacing(int lineIndex) {
if (lineIndex == 0) {
return 10;
} else if (lineIndex == 1) {
return 30;
}
return null;
}
});
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
}
示例6: toStyledText
import org.eclipse.swt.custom.StyledText; //导入方法依赖的package包/类
/**
* Creates and returns with a new {@link StyledText styled text} instance hooked up to the given parent composite.
*
* @param parent
* the parent of the styled text control.
* @param style
* style bits for the new text control.
* @return a new styled text control initialized from the descriptor.
*/
default StyledText toStyledText(final Composite parent, final int style) {
final StyledText text = new StyledText(parent, READ_ONLY | style);
text.setText(getText());
text.setStyleRanges(getRanges());
text.setFont(getFont());
text.setEditable(false);
text.setEnabled(false);
final AtomicReference<Color> colorRef = new AtomicReference<>();
final IPreferenceStore prefStore = EditorsUI.getPreferenceStore();
if (null == prefStore
|| prefStore.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
colorRef.set(getDefault().getSystemColor(COLOR_LIST_BACKGROUND));
} else {
RGB rgb = null;
if (prefStore.contains(PREFERENCE_COLOR_BACKGROUND)) {
if (prefStore.isDefault(PREFERENCE_COLOR_BACKGROUND)) {
rgb = getDefaultColor(prefStore, PREFERENCE_COLOR_BACKGROUND);
} else {
rgb = getColor(prefStore, PREFERENCE_COLOR_BACKGROUND);
}
if (rgb != null) {
colorRef.set(new Color(text.getDisplay(), rgb));
}
}
}
if (null != colorRef.get()) {
text.setBackground(colorRef.get());
text.addDisposeListener(e -> {
if (!colorRef.get().isDisposed()) {
colorRef.get().dispose();
}
});
}
text.pack();
return text;
}
示例7: createCustomAreaWithLink
import org.eclipse.swt.custom.StyledText; //导入方法依赖的package包/类
/**
* Creates a control with some message and with link to the Binaries preference page.
*
* @param parent
* the parent composite.
* @param dialog
* the container dialog that has to be closed.
* @param binary
* the binary with the illegal state.
*
* @return a control with error message and link that can be reused in dialogs.
*/
public static Control createCustomAreaWithLink(final Composite parent, final Dialog dialog, final Binary binary) {
final String binaryLabel = binary.getLabel();
final String prefix = "The requested operation cannot be performed due to invalid '" + binaryLabel
+ "' settings. Check your '" + binaryLabel
+ "' configuration and preferences under the corresponding ";
final String link = "preference page";
final String suffix = ".";
final String text = prefix + link + suffix;
final Composite control = new Composite(parent, NONE);
control.setLayout(GridLayoutFactory.fillDefaults().create());
final GridData gridData = GridDataFactory.fillDefaults().align(LEFT, TOP).grab(true, true).create();
control.setLayoutData(gridData);
final StyleRange style = new StyleRange();
style.underline = true;
style.underlineStyle = UNDERLINE_LINK;
final StyledText styledText = new StyledText(control, MULTI | READ_ONLY | WRAP);
styledText.setWordWrap(true);
styledText.setJustify(true);
styledText.setText(text);
final GridData textGridData = GridDataFactory.fillDefaults().align(FILL, FILL).grab(true, true).create();
textGridData.widthHint = TEXT_WIDTH_HINT;
textGridData.heightHint = TEXT_HEIGHT_HINT;
styledText.setLayoutData(textGridData);
styledText.setEditable(false);
styledText.setBackground(UIUtils.getSystemColor(COLOR_WIDGET_BACKGROUND));
final int[] ranges = { text.indexOf(link), link.length() };
final StyleRange[] styles = { style };
styledText.setStyleRanges(ranges, styles);
styledText.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(final MouseEvent event) {
try {
final int offset = styledText.getOffsetAtLocation(new Point(event.x, event.y));
final StyleRange actualStyle = styledText.getStyleRangeAtOffset(offset);
if (null != actualStyle && actualStyle.underline
&& UNDERLINE_LINK == actualStyle.underlineStyle) {
dialog.close();
final PreferenceDialog preferenceDialog = createPreferenceDialogOn(
UIUtils.getShell(),
BinariesPreferencePage.ID,
FILTER_IDS,
null);
if (null != preferenceDialog) {
preferenceDialog.open();
}
}
} catch (final IllegalArgumentException e) {
// We are not over the actual text.
}
}
});
return control;
}
示例8: createContents
import org.eclipse.swt.custom.StyledText; //导入方法依赖的package包/类
private void createContents(String exlplain, String version) {
aboutToolsShell = new Shell(getParent(), getStyle());
aboutToolsShell.setImage(SWTResourceManager.getImage(AboutTools.class, Resource.IMAGE_ICON));
aboutToolsShell.setSize(400, 391);
aboutToolsShell.setText(getText());
PubUtils.setCenterinParent(getParent(), aboutToolsShell);
Label copyRightlabel = new Label(aboutToolsShell, SWT.CENTER);
copyRightlabel.setBounds(10, 311, 375, 17);
copyRightlabel.setText(Resource.AUTHOR);
Link link = new Link(aboutToolsShell, SWT.NONE);
link.setBounds(143, 336, 108, 17);
link.setText("<a>www.itlaborer.com</a>");
link.addSelectionListener(new LinkSelection());
Label versionLabel = new Label(aboutToolsShell, SWT.NONE);
versionLabel.setAlignment(SWT.CENTER);
versionLabel.setBounds(156, 288, 82, 17);
versionLabel.setText(version);
StyledText readMeTextLabel = new StyledText(aboutToolsShell,
SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
readMeTextLabel.setBounds(3, 33, 389, 114);
readMeTextLabel.setText(exlplain);
StyledText lblgplV = new StyledText(aboutToolsShell, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
lblgplV.setText(
"Copyright itlaborer.com\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.");
lblgplV.setBounds(3, 176, 389, 106);
Label label_1 = new Label(aboutToolsShell, SWT.NONE);
label_1.setFont(org.eclipse.wb.swt.SWTResourceManager.getFont("微软雅黑", 9, SWT.BOLD));
label_1.setText("Apache License:");
label_1.setBounds(3, 155, 136, 17);
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);
}
示例9: createControl
import org.eclipse.swt.custom.StyledText; //导入方法依赖的package包/类
@Override
public void createControl(Composite parent) {
Composite control = new Composite(parent, SWT.NONE);
setControl(control);
control.setLayout(new GridLayout(1, false));
StyledText summaryText = new StyledText(control, SWT.BORDER);
summaryText.setData(GW4E_MANUAL_ELEMENT_ID,GW4E_MANUAL_SUMMARY_TEXT_ID);
summaryText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
StringBuffer text = new StringBuffer();
text.append(MessageUtil.getString("your_test_will_be_based_on_the_following") + "\n\n");
text.append(MessageUtil.getString("main_model") + "\n");
text.append( modelPath + "\n");
text.append(MessageUtil.getString("additional_models") + "\n");
for (ModelData path : additionalModels) {
text.append(path.getFullPath() + "\n");
}
text.append(MessageUtil.getString("generator_stop_condition" ) + "\n");
text.append( generatorstopcondition + "\n");
text.append( MessageUtil.getString("start_element" ) + "\n");
text.append(startnode + "\n");
text.append(MessageUtil.getString("remove_Blocked_Element") + "\n");
text.append((removeBlockedElement ? "Yes" : "No") + "\n");
summaryText.setText(text.toString());
int start = 2;
int length = 1;
summaryText.setLineBullet(start, length, buildMainModelStyle());
start = start + length;
summaryText.setLineBullet(start, length, buildCheckedlStyle());
start = start + length;
summaryText.setLineBullet(start, length, buildAdditionalTitleModelStyle());
start = start + length;
length = additionalModels.length;
summaryText.setLineBullet(start,length, buildCheckedlStyle());
start = start + length;
length = 1;
summaryText.setLineBullet(start, length, buildMainModelStyle());
start = start + length;
length = 1;
summaryText.setLineBullet(start, length, buildCheckedlStyle());
start = start + length;
length = 1;
summaryText.setLineBullet(start, length, buildMainModelStyle());
start = start + length;
length = 1;
summaryText.setLineBullet(start, length, buildCheckedlStyle());
start = start + length;
length = 1;
summaryText.setLineBullet(start, length, buildMainModelStyle());
start = start + length;
length = 1;
summaryText.setLineBullet(start, length, buildCheckedlStyle());
}
示例10: createText
import org.eclipse.swt.custom.StyledText; //导入方法依赖的package包/类
private void createText(EclipseEnvironment eclipseEnvironment, StyledText text) {
List<StyleRange> styles = new ArrayList<>();
StringBuilder builder = new StringBuilder();
appendLabeledValue(Messages.UsageReportPreferencePage_Version,
Activator.getDefault().getBundle().getVersion().toString(), builder, styles);
appendLabeledValue(Messages.UsageReportPreferencePage_Components,
eclipseEnvironment.getKeyword(), builder, styles);
builder.append(UIConsts._NL);
appendLabeledValue(Messages.UsageReportPreferencePage_ProductId,
eclipseEnvironment.getApplicationName(), builder, styles);
appendLabeledValue(Messages.UsageReportPreferencePage_ProductVersion,
eclipseEnvironment.getApplicationVersion(), builder, styles);
appendLabeledValue(Messages.UsageReportPreferencePage_OperatingSystem, Platform.getOS(),
builder, styles);
appendLabeledValue(Messages.UsageReportPreferencePage_OperatingSystemVersion,
eclipseEnvironment.getOSVersion(), builder, styles);
appendLabeledValue(Messages.UsageReportPreferencePage_JvmName, eclipseEnvironment.getJavaVmName(),
builder, styles);
builder.append(UIConsts._NL);
appendLabeledValue(Messages.UsageReportPreferencePage_NumberOfUsageHits,
String.valueOf(eclipseEnvironment.getVisitCount()), builder,
styles);
appendLabeledValue(Messages.UsageReportPreferencePage_FirstUsageHit,
getFormattedDate(eclipseEnvironment.getFirstVisit()), builder, styles);
appendLabeledValue(Messages.UsageReportPreferencePage_LastUsageHit,
getFormattedDate(eclipseEnvironment.getLastVisit()), builder, styles);
appendLabeledValue(Messages.UsageReportPreferencePage_CurrentUsageHit,
getFormattedDate(eclipseEnvironment.getCurrentVisit()), builder,
styles);
builder.append(UIConsts._NL);
appendEvents(builder, styles);
text.setText(builder.toString());
for (StyleRange style : styles) {
text.setStyleRange(style);
}
}
示例11: TextAreaParameter
import org.eclipse.swt.custom.StyledText; //导入方法依赖的package包/类
public
TextAreaParameter(
Composite composite,
UITextAreaImpl _ui_text_area)
{
super( "" );
ui_text_area = _ui_text_area;
text_area = new StyledText(composite,SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
ClipboardCopy.addCopyToClipMenu(
text_area,
new ClipboardCopy.copyToClipProvider()
{
@Override
public String
getText()
{
return( text_area.getText().trim());
}
});
text_area.addKeyListener(
new KeyAdapter()
{
@Override
public void
keyPressed(
KeyEvent event )
{
int key = event.character;
if ( key <= 26 && key > 0 ){
key += 'a' - 1;
}
if ( key == 'a' && event.stateMask == SWT.MOD1 ){
event.doit = false;
text_area.selectAll();
}
}
});
text_area.setText(ui_text_area.getText());
ui_text_area.addPropertyChangeListener(this);
}
示例12: addDefaultCommentTextInEditor
import org.eclipse.swt.custom.StyledText; //导入方法依赖的package包/类
/**
*
* Adds existing comment text in editor text area
*
* @param styledText
*/
private void addDefaultCommentTextInEditor(StyledText styledText) {
styledText.setText(commentFigure.getText());
}