本文整理匯總了Java中org.eclipse.swt.custom.StyledText.setLayoutData方法的典型用法代碼示例。如果您正苦於以下問題:Java StyledText.setLayoutData方法的具體用法?Java StyledText.setLayoutData怎麽用?Java StyledText.setLayoutData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.custom.StyledText
的用法示例。
在下文中一共展示了StyledText.setLayoutData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: createContents
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
/**
* Create contents of the application window.
*
* @param parent the parent
* @return the control
*/
@Override
protected Control createContents(Composite parent) {
getShell().setText("Execution tracking console - " + consoleName);
getShell().setBounds(50, 250, 450, 500);
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new GridLayout(1, false));
{
styledText = new StyledText(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
styledText.setEditable(false);
}
statusLineManager.setMessage("Waiting for tracking status from server. Please wait!");
return container;
}
示例3: 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;
}
示例4: createErrorGroup
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
private void createErrorGroup(Composite parent) {
Composite errorGroup = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
errorGroup.setLayout(layout);
errorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
errorGroup.setFont(parent.getFont());
errorText = new StyledText(errorGroup, SWT.READ_ONLY | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
errorText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
}
示例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: 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(2, false));
ITextViewer textViewer = new TextViewer(parent, SWT.V_SCROLL | SWT.BORDER);
textViewer.setDocument(new Document(""));
StyledText styledText = textViewer.getTextWidget();
styledText.setLayoutData(new GridData(GridData.FILL_BOTH));
ViewZoneChangeAccessor viewZones = new ViewZoneChangeAccessor(textViewer);
Button add = new Button(parent, SWT.NONE);
add.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 0, 0));
add.setText("Add Zone");
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "", "Enter view zone content",
"Zone " + viewZones.getSize(), null);
if (dlg.open() == Window.OK) {
int line = styledText.getLineAtOffset(styledText.getCaretOffset());
IViewZone zone = new DefaultViewZone(line, 20, dlg.getValue());
viewZones.addZone(zone);
viewZones.layoutZone(zone);
}
}
});
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
}
示例7: 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(2, false));
ITextViewer textViewer = new TextViewer(parent, SWT.V_SCROLL | SWT.BORDER);
String delim = textViewer.getTextWidget().getLineDelimiter();
textViewer.setDocument(new Document(delim + " class A" + delim + "new A" + delim + "new A" + delim + "class B"
+ delim + "new B" + delim + "interface I" + delim + "class C implements I"));
StyledText styledText = textViewer.getTextWidget();
styledText.setLayoutData(new GridData(GridData.FILL_BOTH));
CodeLensProviderRegistry registry = CodeLensProviderRegistry.getInstance();
registry.register(CONTENT_TYPE_ID, new ClassReferencesCodeLensProvider());
registry.register(CONTENT_TYPE_ID, new ClassImplementationsCodeLensProvider());
CodeLensStrategy codelens = new CodeLensStrategy(new DefaultCodeLensContext(textViewer), false);
codelens.addTarget(CONTENT_TYPE_ID).reconcile(null);
styledText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
codelens.reconcile(null);
}
});
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
}
示例8: intializeEditor
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
private void intializeEditor(StyledText expressionEditor, JavaLineStyler javaLineStyler,Composite toolBarComposite) {
expressionEditor.setWordWrap(false);
expressionEditor.addLineStyleListener(javaLineStyler);
expressionEditor.setFont(new Font(null,"Arial", 10, SWT.NORMAL));
expressionEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 0, 0));
expressionEditor.getSize();
addDropSupport();
}
示例9: attachToPropertySubGroup
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
@Override
public void attachToPropertySubGroup(AbstractELTContainerWidget container) {
ELTDefaultSubgroupComposite defaultSubgroupComposite = new ELTDefaultSubgroupComposite(
container.getContainerControl());
defaultSubgroupComposite.createContainerWidget();
AbstractELTWidget eltDefaultLable = new ELTDefaultLable(Messages.EXECUTION_COMMAND);
defaultSubgroupComposite.attachWidget(eltDefaultLable);
styledText=new StyledText(defaultSubgroupComposite.getContainerControl(), SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
GridData gridData=new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.heightHint=80;
styledText.setLayoutData(gridData);
txtDecorator = WidgetUtility.addDecorator(styledText, Messages.bind(Messages.EMPTY_FIELD, Messages.EXECUTION_COMMAND));
ListenerHelper helper = new ListenerHelper();
helper.put(HelperType.CONTROL_DECORATION, txtDecorator);
populateWidget();
styledText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if(StringUtils.isNotBlank(styledText.getText())){
txtDecorator.hide();
}else{
txtDecorator.show();
}
showHideErrorSymbol(widgets);
propertyDialogButtonBar.enableApplyButton(true);
}
});
}
示例10: createUnformattedViewTabItem
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
/**
*
* Create unformatted view tab in data viewer tab folder
*
*/
public void createUnformattedViewTabItem() {
if (isViewTabExist(Views.UNFORMATTED_VIEW_NAME)) {
CTabItem item = getViewTabItem(Views.UNFORMATTED_VIEW_NAME);
tabFolder.setSelection(item);
dataViewLoader.reloadloadViews();
return;
}
CTabItem tbtmUnformattedView = new CTabItem(tabFolder, SWT.CLOSE);
tbtmUnformattedView.setData(Views.VIEW_NAME_KEY, Views.UNFORMATTED_VIEW_NAME);
tbtmUnformattedView.setText(Views.UNFORMATTED_VIEW_DISPLAY_NAME);
{
Composite composite = new Composite(tabFolder, SWT.NONE);
tbtmUnformattedView.setControl(composite);
composite.setLayout(new GridLayout(1, false));
{
unformattedViewTextarea = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL
| SWT.H_SCROLL);
unformattedViewTextarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
}
}
tabFolder.setSelection(tbtmUnformattedView);
dataViewLoader.setUnformattedViewTextarea(unformattedViewTextarea);
dataViewLoader.reloadloadViews();
actionFactory.getAction(SelectColumnAction.class.getName()).setEnabled(false);
}
示例11: createFormatedViewTabItem
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
/**
*
* Create formatted view tab in data viewer tab folder
*
*/
public void createFormatedViewTabItem() {
if (isViewTabExist(Views.FORMATTED_VIEW_NAME)) {
CTabItem item = getViewTabItem(Views.FORMATTED_VIEW_NAME);
tabFolder.setSelection(item);
dataViewLoader.reloadloadViews();
return;
}
CTabItem tbtmFormattedView = new CTabItem(tabFolder, SWT.CLOSE);
tbtmFormattedView.setData(Views.VIEW_NAME_KEY, Views.FORMATTED_VIEW_NAME);
tbtmFormattedView.setText(Views.FORMATTED_VIEW_DISPLAYE_NAME);
{
Composite composite = new Composite(tabFolder, SWT.NONE);
tbtmFormattedView.setControl(composite);
composite.setLayout(new GridLayout(1, false));
{
formattedViewTextarea = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL
| SWT.V_SCROLL);
formattedViewTextarea.setFont(SWTResourceManager.getFont("Courier New", 9, SWT.NORMAL));
formattedViewTextarea.setEditable(false);
formattedViewTextarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
}
}
tabFolder.setSelection(tbtmFormattedView);
dataViewLoader.setFormattedViewTextarea(formattedViewTextarea);
dataViewLoader.reloadloadViews();
}
示例12: createCommentBoxEditorArea
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
private StyledText createCommentBoxEditorArea() {
StyledText styledText = new StyledText(shell, SWT.NONE);
styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
addDefaultCommentTextInEditor(styledText);
styledText.selectAll();
return styledText;
}
示例13: SummaryPanel
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
SummaryPanel(Composite parent) {
summary = new StyledText(parent, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL);
summary.setCaret(null);
summary.setEditable(false);
GridData gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan = 2;
// gd.heightHint = 100;
summary.setLayoutData(gd);
BookNotifier.getInstance().addListener(this);
}
示例14: createControl
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
private void createControl() {
GridLayout layout = new GridLayout();
layout.marginTop = 0;
text = new StyledText(parent, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
text.setLayout(layout);
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
text.setMargins(3, 3, 3, 3);
text.layout(true);
text.addModifyListener(modifyListener);
parent.layout(true, true);
// add empty string on ENTER pressed
text.addTraverseListener(e -> {
switch (e.detail) {
case SWT.TRAVERSE_RETURN:
if (!text.isDisposed()) {
text.append("\n");
text.setTopIndex(text.getLineCount() - 1);
text.setCaretOffset(text.getCharCount() - 1);
}
break;
default:
break;
}
});
// wheel up and down
text.addMouseWheelListener(e -> autoScrollEnabled = e.count <= 0);
styledTextContent = text.getContent();
}
示例15: 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;
}