Search in sources :

Example 96 with RowLayout

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");
            }
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) KeyEvent(org.eclipse.swt.events.KeyEvent) ToolbarButton(org.eclipse.nebula.widgets.richtext.toolbar.ToolbarButton) GridLayout(org.eclipse.swt.layout.GridLayout) ToolbarButton(org.eclipse.nebula.widgets.richtext.toolbar.ToolbarButton) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 97 with RowLayout

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);
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) RichTextEditor(org.eclipse.nebula.widgets.richtext.RichTextEditor) RichTextViewer(org.eclipse.nebula.widgets.richtext.RichTextViewer)

Example 98 with RowLayout

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);
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) RowLayout(org.eclipse.swt.layout.RowLayout) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout) Font(org.eclipse.swt.graphics.Font)

Example 99 with RowLayout

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();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) PrintJob(org.eclipse.nebula.paperclips.core.PrintJob) Button(org.eclipse.swt.widgets.Button) PrintDialog(org.eclipse.swt.printing.PrintDialog) PrinterData(org.eclipse.swt.printing.PrinterData) RowLayout(org.eclipse.swt.layout.RowLayout) PrintPreview(org.eclipse.nebula.paperclips.widgets.PrintPreview) GridData(org.eclipse.swt.layout.GridData) Display(org.eclipse.swt.widgets.Display)

Example 100 with RowLayout

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);
}
Also used : Group(org.eclipse.swt.widgets.Group) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData)

Aggregations

RowLayout (org.eclipse.swt.layout.RowLayout)651 Composite (org.eclipse.swt.widgets.Composite)495 Button (org.eclipse.swt.widgets.Button)392 GridData (org.eclipse.swt.layout.GridData)357 SelectionEvent (org.eclipse.swt.events.SelectionEvent)353 GridLayout (org.eclipse.swt.layout.GridLayout)346 Label (org.eclipse.swt.widgets.Label)251 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)215 RowData (org.eclipse.swt.layout.RowData)173 SelectionListener (org.eclipse.swt.events.SelectionListener)159 Group (org.eclipse.swt.widgets.Group)141 Text (org.eclipse.swt.widgets.Text)125 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)109 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)106 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)105 Shell (org.eclipse.swt.widgets.Shell)102 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)101 Display (org.eclipse.swt.widgets.Display)86 Point (org.eclipse.swt.graphics.Point)66 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)62