Search in sources :

Example 46 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project yamcs-studio by yamcs.

the class RuleDataEditDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    var parentComposite = (Composite) super.createDialogArea(parent);
    var mainComposite = new Composite(parentComposite, SWT.NONE);
    mainComposite.setLayout(new GridLayout(2, false));
    var gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.heightHint = 500;
    mainComposite.setLayoutData(gridData);
    var topComposite = new Composite(mainComposite, SWT.NONE);
    topComposite.setLayout(new GridLayout(2, false));
    var 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(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));
    var comboItems = new String[propIDList.size()];
    var i = 0;
    for (var id : propIDList) {
        comboItems[i++] = ruleData.getWidgetModel().getProperty(id).getDescription() + " (" + id + ")";
    }
    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 (var exp : expressionList) {
                    exp.setValue("");
                }
                valueColumn.getColumn().setText("Output Expression");
            } else {
                outPutExpButton.setEnabled(true);
            }
            if (!ruleData.isOutputExpValue()) {
                for (var exp : expressionList) {
                    exp.setValue(ruleData.isOutputExpValue() ? "" : 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 (var exp : expressionList) {
                exp.setValue(ruleData.isOutputExpValue() ? "" : ruleData.getProperty().getDefaultValue());
            }
            valueColumn.getColumn().setText(ruleData.isOutputExpValue() ? "Output Expression" : "Output Value");
            expressionViewer.refresh();
        }
    });
    // Left Panel: List of scripts
    var 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");
    var toolBarComposite = new Composite(leftComposite, SWT.NONE);
    var 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);
    var toolbarManager = new ToolBarManager(SWT.FLAT);
    var toolBar = toolbarManager.createControl(toolBarComposite);
    var 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(event -> refreshActionBarOnSelection());
    // Right panel: Input PVs for selected script
    var 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);
    createLabel(rightComposite, "Input PVs");
    pvsEditor = new PVTupleTableEditor(rightComposite, ruleData.getPVList(), SWT.NONE);
    pvsEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    if (expressionList.size() > 0) {
        setExpressionViewerSelection(expressionList.get(0));
    }
    var 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);
    var generateScriptButton = new Button(bottomComposite, SWT.PUSH);
    generateScriptButton.setText("See Generated Script");
    gd = new GridData(SWT.LEFT, SWT.TOP, false, false);
    generateScriptButton.setLayoutData(gd);
    var 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 parentComposite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) ToolBarManager(org.eclipse.jface.action.ToolBarManager) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 47 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project yamcs-studio by yamcs.

the class ColorMapEditDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    var parentComposite = (Composite) super.createDialogArea(parent);
    var topComposite = new Composite(parentComposite, SWT.NONE);
    var gl = new GridLayout();
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.horizontalSpacing = 0;
    topComposite.setLayout(gl);
    var gd = new GridData(GridData.FILL_BOTH);
    topComposite.setLayoutData(gd);
    var toolbarManager = new ToolBarManager(SWT.FLAT);
    var toolBar = toolbarManager.createControl(topComposite);
    var 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);
    var mainComposite = new Composite(topComposite, SWT.NONE);
    gl = new GridLayout(2, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    mainComposite.setLayout(gl);
    var gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.heightHint = 300;
    mainComposite.setLayoutData(gridData);
    var leftComposite = new Composite(mainComposite, SWT.NONE);
    gl = new GridLayout(1, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    leftComposite.setLayout(gl);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 250;
    leftComposite.setLayoutData(gd);
    colorListViewer = createColorListViewer(leftComposite);
    colorListViewer.setInput(colorList);
    var rightComposite = new Composite(mainComposite, SWT.NONE);
    gl = new GridLayout(1, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    rightComposite.setLayout(gl);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 340;
    rightComposite.setLayoutData(gd);
    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());
    var i = 0;
    for (var colorMap : PredefinedColorMap.values()) {
        if (predefinedColorMap == colorMap) {
            break;
        } else {
            i++;
        }
    }
    preDefinedMapCombo.select(i);
    var interpolateCheckBox = new Button(rightComposite, SWT.CHECK);
    interpolateCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
    interpolateCheckBox.setSelection(interpolate);
    interpolateCheckBox.setText("Interpolate");
    var 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 + ").");
    var group = new Group(rightComposite, SWT.None);
    group.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true));
    group.setLayout(new GridLayout(2, false));
    group.setText("Output" + " (" + min + "~" + max + ")");
    colorMapLabel = new Label(group, SWT.None);
    colorMapLabel.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true));
    refreshGUI();
    preDefinedMapCombo.addModifyListener(e -> {
        predefinedColorMap = PredefinedColorMap.values()[preDefinedMapCombo.getSelectionIndex()];
        if (preDefinedMapCombo.getSelectionIndex() != 0) {
            var map = PredefinedColorMap.values()[preDefinedMapCombo.getSelectionIndex()].getMap();
            colorList.clear();
            for (var 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 parentComposite;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) ToolBarManager(org.eclipse.jface.action.ToolBarManager) GridLayout(org.eclipse.swt.layout.GridLayout) ColorTuple(org.csstudio.swt.widgets.datadefinition.ColorTuple) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 48 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager 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);
    var 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) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 49 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project dbeaver by dbeaver.

the class GISTextViewer method createControl.

@Override
protected Control createControl(Composite editPlaceholder) {
    Composite composite = UIUtils.createPlaceholder(editPlaceholder, 1);
    CSSUtils.setCSSClass(composite, DBStyles.COLORED_BY_CONNECTION_TYPE);
    Composite controlPanel = UIUtils.createPlaceholder(composite, 1);
    controlPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
    controlPanel.setLayout(new FillLayout());
    Control textControl = super.createControl(controlPanel);
    // new Composite(composite, SWT.NONE);
    Composite bottomPanel = UIUtils.createPlaceholder(composite, 1);
    bottomPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    CSSUtils.setCSSClass(bottomPanel, DBStyles.COLORED_BY_CONNECTION_TYPE);
    ToolBar bottomToolbar = new ToolBar(bottomPanel, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
    toolBarManager = new ToolBarManager(bottomToolbar);
    return textControl;
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) FillLayout(org.eclipse.swt.layout.FillLayout) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 50 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project dbeaver by dbeaver.

the class ProgressPageControl method createSearchControls.

private void createSearchControls() {
    if (searchText != null) {
        return;
    }
    hideControls(false);
    ((GridLayout) searchControlsComposite.getLayout()).numColumns = 2;
    searchText = new Text(searchControlsComposite, SWT.BORDER);
    UIUtils.addDefaultEditActionsSupport(UIUtils.getActiveWorkbenchWindow(), this.searchText);
    if (curSearchText != null) {
        searchText.setText(curSearchText);
        searchText.setSelection(curSearchText.length());
    }
    // searchText.setBackground(searchNotFoundColor);
    searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    searchText.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            switch(e.keyCode) {
                case SWT.ESC:
                    cancelSearch(true);
                    break;
                case SWT.CR:
                case SWT.ARROW_UP:
                case SWT.ARROW_DOWN:
                    if (childPageControl != null) {
                        childPageControl.setFocus();
                    }
                    e.doit = false;
                    // performSearch(SearchType.NEXT);
                    break;
            }
        }
    });
    searchText.addModifyListener(e -> {
        curSearchText = searchText.getText();
        if (curSearchJob == null) {
            curSearchJob = new UIJob(UIMessages.controls_progress_page_job_search) {

                @Override
                public IStatus runInUIThread(IProgressMonitor monitor) {
                    if (monitor.isCanceled()) {
                        return Status.CANCEL_STATUS;
                    }
                    performSearch(SearchType.NEXT);
                    curSearchJob = null;
                    return Status.OK_STATUS;
                }
            };
            curSearchJob.schedule(200);
        }
    });
    // ToolBar searchTools = new ToolBar(searchControlsComposite, SWT.HORIZONTAL);
    if (searchToolbarManager == null) {
        searchToolbarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
        // Do not add prev/next buttons - they doesn't make sense now.
        // Keep code just in case
        /*
            searchToolbarManager.add(ActionUtils.makeCommandContribution(
                    PlatformUI.getWorkbench(),
                    IWorkbenchActionDefinitionIds.FIND_NEXT,
                    null,
                    UIIcon.ARROW_DOWN));
            searchToolbarManager.add(ActionUtils.makeCommandContribution(
                    PlatformUI.getWorkbench(),
                    IWorkbenchActionDefinitionIds.FIND_PREVIOUS,
                    null,
                    UIIcon.ARROW_UP));
*/
        searchToolbarManager.add(new Action(UIMessages.controls_progress_page_action_close, UIUtils.getShardImageDescriptor(ISharedImages.IMG_ELCL_REMOVE)) {

            @Override
            public void run() {
                cancelSearch(true);
            }
        });
    }
    searchToolbarManager.createControl(searchControlsComposite);
    searchControlsComposite.getParent().layout();
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) Action(org.eclipse.jface.action.Action) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) UIJob(org.eclipse.ui.progress.UIJob) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Aggregations

ToolBarManager (org.eclipse.jface.action.ToolBarManager)237 Composite (org.eclipse.swt.widgets.Composite)86 ToolBar (org.eclipse.swt.widgets.ToolBar)80 Action (org.eclipse.jface.action.Action)70 GridData (org.eclipse.swt.layout.GridData)62 IToolBarManager (org.eclipse.jface.action.IToolBarManager)61 Control (org.eclipse.swt.widgets.Control)51 GridLayout (org.eclipse.swt.layout.GridLayout)49 Separator (org.eclipse.jface.action.Separator)39 List (java.util.List)35 SWT (org.eclipse.swt.SWT)33 ArrayList (java.util.ArrayList)32 IAction (org.eclipse.jface.action.IAction)29 IMenuManager (org.eclipse.jface.action.IMenuManager)27 IContributionItem (org.eclipse.jface.action.IContributionItem)25 MenuManager (org.eclipse.jface.action.MenuManager)25 Images (name.abuchen.portfolio.ui.Images)24 Messages (name.abuchen.portfolio.ui.Messages)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)24 Inject (javax.inject.Inject)23