Search in sources :

Example 56 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project yamcs-studio by yamcs.

the class DrillDownComposite method createNavigationButtons.

/**
 * Creates the navigation buttons for this viewer.
 */
private void createNavigationButtons() {
    GridData gid;
    GridLayout layout;
    // Define layout.
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    setLayout(layout);
    // Create a toolbar.
    _toolBarMgr = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = _toolBarMgr.createControl(this);
    gid = new GridData();
    gid.horizontalAlignment = GridData.FILL;
    gid.verticalAlignment = GridData.BEGINNING;
    toolBar.setLayoutData(gid);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 57 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project yamcs-studio by yamcs.

the class DrillDownComposite method createNavigationButtons.

/**
 * Creates the navigation buttons for this viewer.
 */
private void createNavigationButtons() {
    GridData gid;
    GridLayout layout;
    // Define layout.
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    setLayout(layout);
    // Create a toolbar.
    _toolBarMgr = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = _toolBarMgr.createControl(this);
    gid = new GridData();
    gid.horizontalAlignment = GridData.FILL;
    gid.verticalAlignment = GridData.BEGINNING;
    toolBar.setLayoutData(gid);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 58 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project yamcs-studio by yamcs.

the class RuleDataEditDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final Composite parent_Composite = (Composite) super.createDialogArea(parent);
    // Parent composite has GridLayout with 1 columns.
    // Create embedded composite w/ 2 columns
    final Composite mainComposite = new Composite(parent_Composite, SWT.None);
    mainComposite.setLayout(new GridLayout(2, false));
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.heightHint = 500;
    mainComposite.setLayoutData(gridData);
    final Composite topComposite = new Composite(mainComposite, SWT.None);
    topComposite.setLayout(new GridLayout(2, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    topComposite.setLayoutData(gd);
    createLabel(topComposite, "Rule Name: ");
    nameText = new Text(topComposite, SWT.BORDER);
    nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    nameText.setText(ruleData.getName());
    nameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            ruleData.setName(nameText.getText());
        }
    });
    createLabel(topComposite, "Property: ");
    propCombo = new Combo(topComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    propCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    String[] comboItems = new String[propIDList.size()];
    int i = 0;
    for (String id : propIDList) {
        comboItems[i++] = ruleData.getWidgetModel().getProperty(id).getDescription() + " (" + id + // $NON-NLS-1$ //$NON-NLS-2$
        ")";
    }
    propCombo.setItems(comboItems);
    propCombo.select(propIDList.indexOf(ruleData.getPropId()));
    propCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (propIDList.get(propCombo.getSelectionIndex()).equals(AbstractPVWidgetModel.PROP_PVVALUE)) {
                MessageDialog.openWarning(propCombo.getShell(), "Warning", "Note: Changing pv_value property with rule or " + "script will not write value to the PV. " + "It only change the graphical value on the widget! " + "If you need to write a PV, please call PV.setValue() from script.");
            }
            ruleData.setPropId(propIDList.get(propCombo.getSelectionIndex()));
            if (ruleData.getProperty().getPropertyDescriptor() == null || ruleData.getProperty().onlyAcceptExpressionInRule()) {
                ruleData.setOutputExpValue(true);
                outPutExpButton.setSelection(true);
                outPutExpButton.setEnabled(false);
                for (Expression exp : expressionList) // $NON-NLS-1$
                exp.setValue("");
                valueColumn.getColumn().setText("Output Expression");
            } else
                outPutExpButton.setEnabled(true);
            if (!ruleData.isOutputExpValue()) {
                for (Expression exp : expressionList) exp.setValue(ruleData.isOutputExpValue() ? "" : // $NON-NLS-1$
                ruleData.getProperty().getDefaultValue());
            }
            expressionViewer.refresh();
        }
    });
    outPutExpButton = new Button(topComposite, SWT.CHECK);
    gd = new GridData();
    gd.horizontalSpan = 2;
    outPutExpButton.setLayoutData(gd);
    outPutExpButton.setText("Output Expression");
    if (ruleData.getProperty().getPropertyDescriptor() == null || ruleData.getProperty().onlyAcceptExpressionInRule()) {
        ruleData.setOutputExpValue(true);
        outPutExpButton.setEnabled(false);
    }
    outPutExpButton.setSelection(ruleData.isOutputExpValue());
    outPutExpButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ruleData.setOutputExpValue(outPutExpButton.getSelection());
            for (Expression exp : expressionList) exp.setValue(ruleData.isOutputExpValue() ? "" : // $NON-NLS-1$
            ruleData.getProperty().getDefaultValue());
            valueColumn.getColumn().setText(ruleData.isOutputExpValue() ? "Output Expression" : "Output Value");
            expressionViewer.refresh();
        }
    });
    // Left Panel: List of scripts
    final Composite leftComposite = new Composite(mainComposite, SWT.NONE);
    leftComposite.setLayout(new GridLayout(1, false));
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 350;
    leftComposite.setLayoutData(gd);
    createLabel(leftComposite, "Expressions");
    Composite toolBarComposite = new Composite(leftComposite, SWT.BORDER);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridLayout.marginBottom = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    toolBarComposite.setLayout(gridLayout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    toolBarComposite.setLayoutData(gd);
    ToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = toolbarManager.createControl(toolBarComposite);
    GridData grid = new GridData();
    grid.horizontalAlignment = GridData.FILL;
    grid.verticalAlignment = GridData.BEGINNING;
    toolBar.setLayoutData(grid);
    createActions();
    toolbarManager.add(addAction);
    toolbarManager.add(copyAction);
    toolbarManager.add(removeAction);
    toolbarManager.add(moveUpAction);
    toolbarManager.add(moveDownAction);
    toolbarManager.update(true);
    expressionViewer = createExpressionsTableViewer(toolBarComposite);
    expressionViewer.setInput(expressionList);
    expressionViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            refreshActionBarOnSelection();
        }
    });
    // Right panel: Input PVs for selected script
    final Composite rightComposite = new Composite(mainComposite, SWT.NONE);
    gridLayout = new GridLayout(1, false);
    rightComposite.setLayout(gridLayout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    // Account for the StringTableEditor's minimum size
    gd.minimumWidth = 250;
    rightComposite.setLayoutData(gd);
    this.createLabel(rightComposite, "Input PVs");
    pvsEditor = new PVTupleTableEditor(rightComposite, ruleData.getPVList(), SWT.BORDER);
    pvsEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    if (expressionList.size() > 0)
        setExpressionViewerSelection(expressionList.get(0));
    final Composite bottomComposite = new Composite(mainComposite, SWT.None);
    bottomComposite.setLayout(new GridLayout(1, false));
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.horizontalSpan = 2;
    bottomComposite.setLayoutData(gd);
    Button generateScriptButton = new Button(bottomComposite, SWT.PUSH);
    generateScriptButton.setText("See Generated Script");
    gd = new GridData(SWT.LEFT, SWT.TOP, false, false);
    generateScriptButton.setLayoutData(gd);
    final Text scriptText = new Text(bottomComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    scriptText.setLayoutData(gd);
    generateScriptButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            scriptText.setText(ruleData.generateScript());
        }
    });
    return parent_Composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ToolBarManager(org.eclipse.jface.action.ToolBarManager) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Expression(org.csstudio.opibuilder.script.Expression) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolBar(org.eclipse.swt.widgets.ToolBar)

Example 59 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project yamcs-studio by yamcs.

the class ColorMapEditDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final Composite parent_Composite = (Composite) super.createDialogArea(parent);
    final Composite mainComposite = new Composite(parent_Composite, SWT.None);
    mainComposite.setLayout(new GridLayout(2, false));
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.heightHint = 300;
    mainComposite.setLayoutData(gridData);
    final Composite leftComposite = new Composite(mainComposite, SWT.None);
    leftComposite.setLayout(new GridLayout(1, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 250;
    leftComposite.setLayoutData(gd);
    createLabel(leftComposite, "Color Map:");
    Composite toolBarComposite = new Composite(leftComposite, SWT.BORDER);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridLayout.marginBottom = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    toolBarComposite.setLayout(gridLayout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    toolBarComposite.setLayoutData(gd);
    ToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = toolbarManager.createControl(toolBarComposite);
    GridData grid = new GridData();
    grid.horizontalAlignment = GridData.FILL;
    grid.verticalAlignment = GridData.BEGINNING;
    toolBar.setLayoutData(grid);
    createActions();
    toolbarManager.add(addAction);
    toolbarManager.add(copyAction);
    toolbarManager.add(removeAction);
    toolbarManager.add(moveUpAction);
    toolbarManager.add(moveDownAction);
    toolbarManager.update(true);
    colorListViewer = createColorListViewer(toolBarComposite);
    colorListViewer.setInput(colorList);
    Composite rightComposite = new Composite(mainComposite, SWT.NONE);
    rightComposite.setLayout(new GridLayout(1, false));
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 340;
    rightComposite.setLayoutData(gd);
    this.createLabel(rightComposite, "Use predefined color map:");
    preDefinedMapCombo = new Combo(rightComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    preDefinedMapCombo.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false));
    preDefinedMapCombo.setItems(PredefinedColorMap.getStringValues());
    int i = 0;
    for (PredefinedColorMap colorMap : PredefinedColorMap.values()) {
        if (predefinedColorMap == colorMap)
            break;
        else
            i++;
    }
    preDefinedMapCombo.select(i);
    final Button InterpolateCheckBox = new Button(rightComposite, SWT.CHECK);
    InterpolateCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
    InterpolateCheckBox.setSelection(interpolate);
    InterpolateCheckBox.setText("Interpolate");
    final Button autoScaleCheckBox = new Button(rightComposite, SWT.CHECK);
    autoScaleCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
    autoScaleCheckBox.setSelection(autoScale);
    autoScaleCheckBox.setText("Auto Scale");
    autoScaleCheckBox.setToolTipText("Scale the color map values to the range of" + " (" + min + ", " + max + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    ").");
    Group group = new Group(rightComposite, SWT.None);
    group.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true));
    group.setLayout(new GridLayout(2, false));
    // $NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-3$
    group.setText("Output" + " (" + min + "~" + max + ")");
    colorMapLabel = new Label(group, SWT.None);
    colorMapLabel.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true));
    refreshGUI();
    preDefinedMapCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            predefinedColorMap = PredefinedColorMap.values()[preDefinedMapCombo.getSelectionIndex()];
            if (preDefinedMapCombo.getSelectionIndex() != 0) {
                LinkedHashMap<Double, RGB> map = PredefinedColorMap.values()[preDefinedMapCombo.getSelectionIndex()].getMap();
                colorList.clear();
                for (Entry<Double, RGB> entry : map.entrySet()) colorList.add(new ColorTuple(entry.getKey(), entry.getValue()));
                colorListViewer.refresh();
            }
            refreshGUI();
        }
    });
    InterpolateCheckBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            interpolate = InterpolateCheckBox.getSelection();
            refreshGUI();
        }
    });
    autoScaleCheckBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            autoScale = autoScaleCheckBox.getSelection();
            refreshGUI();
        }
    });
    return parent_Composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) ToolBarManager(org.eclipse.jface.action.ToolBarManager) LinkedHashMap(java.util.LinkedHashMap) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Entry(java.util.Map.Entry) ColorTuple(org.csstudio.swt.widgets.datadefinition.ColorTuple) Button(org.eclipse.swt.widgets.Button) PredefinedColorMap(org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 60 with ToolBar

use of org.eclipse.swt.widgets.ToolBar in project cubrid-manager by CUBRID.

the class BrowserEditorPart method initToolbar.

private void initToolbar(Composite parent) {
    Composite toolbarCom = new Composite(parent, SWT.None);
    toolbarCom.setLayoutData(createGridData(HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
    toolbarCom.setLayout(new FillLayout());
    ToolBar toolBar = new ToolBar(toolbarCom, SWT.FLAT);
    goItem = new ToolItem(toolBar, SWT.CHECK);
    goItem.setImage(getImage("icons/browsereditor/go.gif"));
    goItem.setToolTipText(Messages.tooltipGo);
    goItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            go(location.getText());
        }
    });
    refreshItem = new ToolItem(toolBar, SWT.CHECK);
    refreshItem.setImage(getImage("icons/browsereditor/refresh.gif"));
    refreshItem.setToolTipText(Messages.tooltipRefresh);
    refreshItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            browser.refresh();
        }
    });
    stopItem = new ToolItem(toolBar, SWT.CHECK);
    stopItem.setImage(getImage("icons/browsereditor/stop.gif"));
    stopItem.setToolTipText(Messages.tooltipStop);
    stopItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            browser.stop();
        }
    });
    backItem = new ToolItem(toolBar, SWT.CHECK);
    backItem.setImage(getImage("icons/browsereditor/back.gif"));
    backItem.setToolTipText(Messages.tooltipBack);
    backItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            browser.back();
        }
    });
    forwardItem = new ToolItem(toolBar, SWT.CHECK);
    forwardItem.setImage(getImage("icons/browsereditor/forward.gif"));
    forwardItem.setToolTipText(Messages.tooltipForward);
    forwardItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            browser.forward();
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FillLayout(org.eclipse.swt.layout.FillLayout) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

ToolBar (org.eclipse.swt.widgets.ToolBar)127 ToolItem (org.eclipse.swt.widgets.ToolItem)110 SelectionEvent (org.eclipse.swt.events.SelectionEvent)82 GridData (org.eclipse.swt.layout.GridData)81 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)74 GridLayout (org.eclipse.swt.layout.GridLayout)68 Composite (org.eclipse.swt.widgets.Composite)67 Image (org.eclipse.swt.graphics.Image)35 Label (org.eclipse.swt.widgets.Label)34 DisposeEvent (org.eclipse.swt.events.DisposeEvent)27 DisposeListener (org.eclipse.swt.events.DisposeListener)26 Point (org.eclipse.swt.graphics.Point)24 Cursor (org.eclipse.swt.graphics.Cursor)22 TableViewer (org.eclipse.jface.viewers.TableViewer)18 FillLayout (org.eclipse.swt.layout.FillLayout)18 Button (org.eclipse.swt.widgets.Button)17 Text (org.eclipse.swt.widgets.Text)17 ArrayList (java.util.ArrayList)14 SashForm (org.eclipse.swt.custom.SashForm)14 Combo (org.eclipse.swt.widgets.Combo)14