Search in sources :

Example 46 with FormToolkit

use of org.eclipse.ui.forms.widgets.FormToolkit in project yamcs-studio by yamcs.

the class ThemeColorBlock method createMasterPart.

@Override
protected void createMasterPart(IManagedForm managedForm, Composite parent) {
    FormToolkit tk = managedForm.getToolkit();
    Section section = tk.createSection(parent, Section.NO_TITLE);
    section.marginWidth = 10;
    section.marginHeight = 5;
    Composite client = tk.createComposite(section, SWT.WRAP);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 2;
    layout.marginHeight = 2;
    client.setLayout(layout);
    Composite tableWrapper = tk.createComposite(client, SWT.NONE);
    tableWrapper.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    TableColumnLayout tcl = new TableColumnLayout();
    tableWrapper.setLayout(tcl);
    Table t = tk.createTable(tableWrapper, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    t.setHeaderVisible(false);
    t.setLinesVisible(false);
    tk.paintBordersFor(client);
    Composite buttonWrapper = tk.createComposite(client);
    buttonWrapper.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    buttonWrapper.setLayout(gl);
    Button b = tk.createButton(buttonWrapper, "Add", SWT.PUSH);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    b.setLayoutData(gd);
    b = tk.createButton(buttonWrapper, "Remove", SWT.PUSH);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    b.setLayoutData(gd);
    b = tk.createButton(buttonWrapper, "Up", SWT.PUSH);
    b.setImage(upImage);
    b.setToolTipText("Move Up");
    gd = new GridData(GridData.FILL_HORIZONTAL);
    b.setLayoutData(gd);
    b = tk.createButton(buttonWrapper, "Down", SWT.PUSH);
    b.setImage(downImage);
    b.setToolTipText("Move Down");
    gd = new GridData(GridData.FILL_HORIZONTAL);
    b.setLayoutData(gd);
    section.setClient(client);
    SectionPart spart = new SectionPart(section);
    managedForm.addPart(spart);
    TableViewer viewer = new TableViewer(t);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.addSelectionChangedListener(evt -> {
        managedForm.fireSelectionChanged(spart, evt.getSelection());
    });
    TableViewerColumn colorColumn = new TableViewerColumn(viewer, SWT.NONE);
    colorColumn.setLabelProvider(new ColorLabelProvider() {

        @Override
        public Color getColor(Object element) {
            ThemeColor color = (ThemeColor) element;
            return colorMap.get(color.getRGB());
        }

        @Override
        public Color getBorderColor(Object element) {
            return parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
        }
    });
    tcl.setColumnData(colorColumn.getColumn(), new ColumnWeightData(50, 50, false));
    TableViewerColumn textColumn = new TableViewerColumn(viewer, SWT.NONE);
    textColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            ThemeColor color = (ThemeColor) element;
            return color.getLabel();
        }
    });
    tcl.setColumnData(textColumn.getColumn(), new ColumnWeightData(200, 200, true));
    viewer.setInput(def.getColors());
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) Section(org.eclipse.ui.forms.widgets.Section) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) SectionPart(org.eclipse.ui.forms.SectionPart) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ColorLabelProvider(org.yamcs.studio.core.ui.utils.ColorLabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 47 with FormToolkit

use of org.eclipse.ui.forms.widgets.FormToolkit in project yamcs-studio by yamcs.

the class ThemeColorDetailsPage method createContents.

@Override
public void createContents(Composite parent) {
    TableWrapLayout layout = new TableWrapLayout();
    layout.topMargin = 5;
    layout.leftMargin = 5;
    layout.rightMargin = 2;
    layout.bottomMargin = 2;
    parent.setLayout(layout);
    FormToolkit tk = mform.getToolkit();
    Section s1 = tk.createSection(parent, Section.NO_TITLE);
    // s1.marginWidth = 10;
    TableWrapData td = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP);
    td.grabHorizontal = true;
    s1.setLayoutData(td);
    Composite client = tk.createComposite(s1);
    GridLayout gl = new GridLayout();
    client.setLayout(gl);
    colorLabel = tk.createLabel(client, "   yy        ", SWT.BORDER);
    colorLabel.setBackground(selectedColor);
    Composite rgbScales = tk.createComposite(client);
    GridData gd = new GridData();
    rgbScales.setLayoutData(gd);
    gl = new GridLayout(3, false);
    rgbScales.setLayout(gl);
    tk.createLabel(rgbScales, "Red");
    redScale = new Scale(rgbScales, SWT.NONE);
    redScale.setMinimum(0);
    redScale.setMaximum(255);
    redScale.setIncrement(1);
    redScale.addListener(SWT.Selection, evt -> {
        redText.setText("" + redScale.getSelection());
        updateSelectedColor();
    });
    redText = tk.createText(rgbScales, "                ", SWT.RIGHT);
    redText.setEnabled(false);
    gd = new GridData();
    gd.widthHint = 50;
    redText.setLayoutData(gd);
    tk.createLabel(rgbScales, "Green");
    greenScale = new Scale(rgbScales, SWT.NONE);
    greenScale.setMinimum(0);
    greenScale.setMaximum(255);
    greenScale.setIncrement(1);
    greenScale.addListener(SWT.Selection, evt -> {
        greenText.setText("" + greenScale.getSelection());
        updateSelectedColor();
    });
    greenText = tk.createText(rgbScales, "                ", SWT.RIGHT);
    greenText.setEnabled(false);
    gd = new GridData();
    gd.widthHint = 50;
    greenText.setLayoutData(gd);
    tk.createLabel(rgbScales, "Blue");
    blueScale = new Scale(rgbScales, SWT.NONE);
    blueScale.setMinimum(0);
    blueScale.setMaximum(255);
    blueScale.setIncrement(1);
    blueScale.addListener(SWT.Selection, evt -> {
        blueText.setText("" + blueScale.getSelection());
        updateSelectedColor();
    });
    blueText = tk.createText(rgbScales, "                ", SWT.RIGHT);
    blueText.setEnabled(false);
    gd = new GridData();
    gd.widthHint = 50;
    blueText.setLayoutData(gd);
    tk.paintBordersFor(s1);
    s1.setClient(client);
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) TableWrapLayout(org.eclipse.ui.forms.widgets.TableWrapLayout) GridData(org.eclipse.swt.layout.GridData) Scale(org.eclipse.swt.widgets.Scale) Section(org.eclipse.ui.forms.widgets.Section)

Aggregations

FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)47 Composite (org.eclipse.swt.widgets.Composite)40 GridLayout (org.eclipse.swt.layout.GridLayout)35 GridData (org.eclipse.swt.layout.GridData)31 Label (org.eclipse.swt.widgets.Label)13 Button (org.eclipse.swt.widgets.Button)12 Text (org.eclipse.swt.widgets.Text)10 ScrolledForm (org.eclipse.ui.forms.widgets.ScrolledForm)10 Section (org.eclipse.ui.forms.widgets.Section)9 FillLayout (org.eclipse.swt.layout.FillLayout)8 ManagedForm (org.eclipse.ui.forms.ManagedForm)8 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)8 MessageHyperlinkAdapter (bndtools.utils.MessageHyperlinkAdapter)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 MDSashForm (bndtools.editor.common.MDSashForm)5 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)5 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)5 ISelection (org.eclipse.jface.viewers.ISelection)4 TreeViewer (org.eclipse.jface.viewers.TreeViewer)4