use of org.eclipse.swt.layout.RowLayout in project nebula by eclipse.
the class RichTextEditorExample method createControlPanel.
protected void createControlPanel(Composite parent, final RichTextEditor editor) {
Composite controlPanel = new Composite(parent, SWT.NONE);
controlPanel.setLayout(new GridLayout(3, false));
GridDataFactory.fillDefaults().grab(true, false).applyTo(controlPanel);
Label inputLabel = new Label(controlPanel, SWT.NONE);
inputLabel.setText("Text to set:");
GridDataFactory.fillDefaults().applyTo(inputLabel);
final Text input = new Text(controlPanel, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(input);
input.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
editor.setText(input.getText());
}
}
});
Button setButton = new Button(controlPanel, SWT.PUSH);
setButton.setText("Set Text");
GridDataFactory.defaultsFor(setButton).applyTo(setButton);
setButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editor.setText(input.getText());
}
});
Composite buttonPanel = new Composite(controlPanel, SWT.NONE);
buttonPanel.setLayout(new RowLayout());
GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(buttonPanel);
Button getButton = new Button(buttonPanel, SWT.PUSH);
getButton.setText("Get text");
getButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
MessageDialog.openInformation(null, "Editor Input", editor.getText());
}
});
final Button enableButton = new Button(buttonPanel, SWT.PUSH);
enableButton.setText("Disable");
enableButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean editable = editor.isEditable();
editor.setEditable(!editable);
enableButton.setText(editable ? "Enable" : "Disable");
}
});
final Button updateButton = new Button(buttonPanel, SWT.PUSH);
updateButton.setText("Update Toolbar");
final ToolbarButton button = new ToolbarButton("javaButton", "myJavaCommand", "Execute Java", "other", RichTextEditorExample.class.getResource("images/debug_exc.gif")) {
@Override
public Object execute() {
MessageDialog.openInformation(null, "Information", "Java callback: " + editor.getSelectedHTML());
editor.insertHTML("<em>" + editor.getSelectedHTML() + "</em>");
return null;
}
};
updateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!buttonVisible) {
editor.addToolbarButton(button);
} else {
editor.removeToolbarButton(button);
}
buttonVisible = !buttonVisible;
editor.updateToolbar();
}
});
Button setFocusButton = new Button(buttonPanel, SWT.PUSH);
setFocusButton.setText("Set Focus");
setFocusButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editor.setFocus();
}
});
Button changeLocaleButton = new Button(buttonPanel, SWT.PUSH);
changeLocaleButton.setText("Change Locale");
changeLocaleButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Object currentLang = editor.getEditorConfiguration().getAllOptions().get(RichTextEditorConfiguration.LANGUAGE);
if ("de".equals(currentLang)) {
editor.setLanguage("en");
} else {
editor.setLanguage("de");
}
}
});
}
use of org.eclipse.swt.layout.RowLayout in project nebula by eclipse.
the class RichTextViewerExample method createControls.
public void createControls(Composite parent) {
parent.setLayout(new GridLayout(2, true));
final RichTextEditor editor = new RichTextEditor(parent);
GridDataFactory.fillDefaults().grab(true, true).applyTo(editor);
final RichTextViewer viewer = new RichTextViewer(parent, SWT.BORDER | SWT.WRAP);
// wrap after whitespace characters and delimiter
viewer.setWordSplitRegex("\\s|\\-");
GridDataFactory.fillDefaults().grab(true, true).span(1, 2).applyTo(viewer);
final Text htmlOutput = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).hint(SWT.DEFAULT, 100).applyTo(htmlOutput);
Composite buttonPanel = new Composite(parent, SWT.NONE);
buttonPanel.setLayout(new RowLayout());
GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
Button getButton = new Button(buttonPanel, SWT.PUSH);
getButton.setText("Get text");
getButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String htmlText = editor.getText();
viewer.setText(htmlText);
htmlOutput.setText(htmlText);
}
});
}
use of org.eclipse.swt.layout.RowLayout in project nebula by eclipse.
the class GanttToolTip method internalMakeDialog.
private static void internalMakeDialog(final IColorManager colorManager, final String name, final String text, final String text2, final String text3, final String text4, final Point loc) {
Point location = new Point(loc.x, loc.y);
if (_shell != null && !_shell.isDisposed()) {
if (!_codeHoverBelow) {
location = new Point(location.x, location.y - _shell.getSize().y - 20);
}
// same text as before, same place as before, let tooltip stand
if (_lastText != null && _lastText.equals(text) && _lastLocation != null && _lastLocation.equals(location)) {
return;
}
_shell.dispose();
}
_lastText = text;
_shell = new Shell(Display.getDefault().getActiveShell(), SWT.ON_TOP | SWT.TOOL);
final RowLayout rowLayout = new RowLayout();
rowLayout.marginLeft = 1;
rowLayout.marginRight = 1;
rowLayout.marginTop = 1;
rowLayout.marginBottom = 1;
_shell.setLayout(rowLayout);
_shell.setBackground(colorManager.getTooltipBackgroundColor());
final Composite comp = new Composite(_shell, SWT.NULL);
comp.setBackground(colorManager.getTooltipBackgroundColor());
final FillLayout fillLayout = new FillLayout();
fillLayout.type = SWT.VERTICAL;
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
comp.setLayout(fillLayout);
final CLabel label = new CLabel(comp, SWT.LEFT);
label.setBackground(colorManager.getTooltipBackgroundColor());
label.setForeground(colorManager.getTooltipForegroundColor());
label.setText(name);
Font cur = label.getFont();
cur = applyBoldFont(cur);
label.setFont(cur);
final CLabel textLabel = new CLabel(comp, SWT.LEFT);
textLabel.setBackground(colorManager.getTooltipBackgroundColor());
if (text4 != null) {
textLabel.setForeground(colorManager.getTooltipForegroundColorFaded());
}
textLabel.setText(text);
if (text2 != null) {
final CLabel text2Label = new CLabel(comp, SWT.LEFT);
text2Label.setBackground(colorManager.getTooltipBackgroundColor());
text2Label.setForeground(colorManager.getTooltipForegroundColorFaded());
text2Label.setText(text2);
}
if (text3 != null) {
final CLabel text3Label = new CLabel(comp, SWT.LEFT);
text3Label.setBackground(colorManager.getTooltipBackgroundColor());
text3Label.setForeground(colorManager.getTooltipForegroundColorFaded());
text3Label.setText(text3);
}
if (text4 != null) {
final CLabel text4Label = new CLabel(comp, SWT.LEFT);
text4Label.setBackground(colorManager.getTooltipBackgroundColor());
text4Label.setForeground(colorManager.getTooltipForegroundColorFaded());
text4Label.setText(text4);
}
_shell.pack();
// show above code inside, automatically below otherwise
if (!_codeHoverBelow) {
location = new Point(location.x, location.y - _shell.getSize().y - 10);
}
_shell.setLocation(location);
_lastLocation = location;
_shell.setVisible(true);
}
use of org.eclipse.swt.layout.RowLayout in project nebula by eclipse.
the class StyledTextPrintExample method main.
/**
* Executes the StyledTextPrint example.
*
* @param args
* the command line arguments.
*/
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setText("StyledTextPrintExample.java");
shell.setLayout(new GridLayout());
shell.setSize(600, 800);
final PrintJob job = new PrintJob("StyledTextPrintExample.java", createPrint());
Composite buttonPanel = new Composite(shell, SWT.NONE);
buttonPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
buttonPanel.setLayout(new RowLayout(SWT.HORIZONTAL));
final PrintPreview preview = new PrintPreview(shell, SWT.BORDER);
Button prev = new Button(buttonPanel, SWT.PUSH);
prev.setText("<< Prev");
prev.addListener(SWT.Selection, event -> {
preview.setPageIndex(Math.max(preview.getPageIndex() - 1, 0));
});
Button next = new Button(buttonPanel, SWT.PUSH);
next.setText("Next >>");
next.addListener(SWT.Selection, event -> {
preview.setPageIndex(Math.min(preview.getPageIndex() + 1, preview.getPageCount() - 1));
});
Button print = new Button(buttonPanel, SWT.PUSH);
print.setText("Print");
print.addListener(SWT.Selection, event -> {
PrintDialog dialog = new PrintDialog(shell);
PrinterData printerData = dialog.open();
if (printerData != null)
PaperClips.print(job, printerData);
});
preview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
preview.setFitHorizontal(true);
preview.setFitVertical(true);
preview.setPrintJob(job);
shell.open();
while (!shell.isDisposed()) if (!display.readAndDispatch())
display.sleep();
display.dispose();
}
use of org.eclipse.swt.layout.RowLayout in project nebula by eclipse.
the class DateChooserExampleTab method createStyleGroup.
private void createStyleGroup(Composite parent) {
Group gp = new Group(parent, SWT.NONE);
gp.setText("Style");
gp.setLayout(new RowLayout());
GridData data = new GridData(SWT.FILL, SWT.FILL, false, false);
data.horizontalSpan = 2;
gp.setLayoutData(data);
borderStyle = new Button(gp, SWT.CHECK);
borderStyle.setText("SWT.BORDER");
borderStyle.addListener(SWT.Selection, recreateListener);
multiStyle = new Button(gp, SWT.CHECK);
multiStyle.setText("SWT.MULTI");
multiStyle.addListener(SWT.Selection, recreateListener);
}
Aggregations