Search in sources :

Example 31 with RowData

use of org.eclipse.swt.layout.RowData in project BiglyBT by BiglySoftware.

the class Legend method createLegendComposite.

public static Composite createLegendComposite(final Composite panel, final Color[] blockColors, final String[] keys, final String[] key_texts, Object layoutData, boolean horizontal, final LegendListener listener) {
    final ConfigurationManager config = ConfigurationManager.getInstance();
    if (blockColors.length != keys.length)
        return null;
    final Color[] defaultColors = new Color[blockColors.length];
    final ParameterListener[] paramListeners = new ParameterListener[keys.length];
    System.arraycopy(blockColors, 0, defaultColors, 0, blockColors.length);
    Composite legend = new Composite(panel, SWT.NONE);
    if (layoutData != null)
        legend.setLayoutData(layoutData);
    RowLayout layout = new RowLayout(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
    layout.wrap = true;
    layout.marginBottom = 0;
    layout.marginTop = 0;
    layout.marginLeft = 0;
    layout.marginRight = 0;
    layout.spacing = 0;
    legend.setLayout(layout);
    RowData data;
    final int[] hover_state = { -1, 0 };
    for (int i = 0; i < blockColors.length; i++) {
        int r = config.getIntParameter(keys[i] + ".red", -1);
        if (r >= 0) {
            int g = config.getIntParameter(keys[i] + ".green");
            int b = config.getIntParameter(keys[i] + ".blue");
            Color color = ColorCache.getColor(panel.getDisplay(), r, g, b);
            blockColors[i] = color;
        }
        Composite colorSet = new Composite(legend, SWT.NONE);
        Utils.setLayout(colorSet, new RowLayout(SWT.HORIZONTAL));
        final Canvas cColor = new Canvas(colorSet, SWT.BORDER);
        cColor.setData("Index", new Integer(i));
        Messages.setLanguageTooltip(cColor, "label.click.to.change.tooltip");
        // XXX Use paint instead of setBackgrond, because OSX does translucent
        // crap
        cColor.addPaintListener(new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                int i = ((Integer) cColor.getData("Index")).intValue();
                e.gc.setBackground(blockColors[i]);
                e.gc.fillRectangle(e.x, e.y, e.width, e.height);
            }
        });
        cColor.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseUp(MouseEvent e) {
                Integer iIndex = (Integer) cColor.getData("Index");
                if (iIndex == null)
                    return;
                int index = iIndex.intValue();
                if (e.button == 1) {
                    RGB rgb = Utils.showColorDialog(panel, blockColors[index].getRGB());
                    if (rgb != null) {
                        config.setRGBParameter(keys[index], rgb.red, rgb.green, rgb.blue);
                    }
                } else {
                    config.removeRGBParameter(keys[index]);
                }
            }
        });
        final Label lblDesc = new Label(colorSet, SWT.NULL);
        if (key_texts == null) {
            Messages.setLanguageText(lblDesc, keys[i]);
        } else {
            lblDesc.setText(key_texts[i]);
        }
        if (listener != null) {
            Messages.setLanguageTooltip(lblDesc, "label.click.to.showhide.tooltip");
            final int f_i = i;
            lblDesc.addMouseListener(new MouseAdapter() {

                @Override
                public void mouseUp(MouseEvent e) {
                    boolean vis = !config.getBooleanParameter(keys[f_i] + ".vis", true);
                    config.setParameter(keys[f_i] + ".vis", vis);
                    listener.visibilityChange(vis, f_i);
                    lblDesc.setForeground(vis ? Colors.getSystemColor(lblDesc.getDisplay(), SWT.COLOR_BLACK) : Colors.grey);
                }
            });
            boolean vis = config.getBooleanParameter(keys[f_i] + ".vis", true);
            if (!vis) {
                listener.visibilityChange(vis, i);
                lblDesc.setForeground(Colors.grey);
            }
        }
        data = new RowData();
        data.width = 20;
        data.height = lblDesc.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 3;
        cColor.setLayoutData(data);
        // If color changes, update our legend
        config.addParameterListener(keys[i], paramListeners[i] = new ParameterListener() {

            @Override
            public void parameterChanged(String parameterName) {
                for (int j = 0; j < keys.length; j++) {
                    if (keys[j].equals(parameterName)) {
                        final int index = j;
                        final int r = config.getIntParameter(keys[j] + ".red", -1);
                        if (r >= 0) {
                            final int g = config.getIntParameter(keys[j] + ".green");
                            final int b = config.getIntParameter(keys[j] + ".blue");
                            Utils.execSWTThread(new AERunnable() {

                                @Override
                                public void runSupport() {
                                    if (panel == null || panel.isDisposed())
                                        return;
                                    Color color = ColorCache.getColor(panel.getDisplay(), r, g, b);
                                    blockColors[index] = color;
                                    cColor.redraw();
                                }
                            });
                        } else {
                            Utils.execSWTThread(new AERunnable() {

                                @Override
                                public void runSupport() {
                                    if (panel == null || panel.isDisposed())
                                        return;
                                    blockColors[index] = defaultColors[index];
                                    cColor.redraw();
                                }
                            });
                        }
                    }
                }
            }
        });
        if (listener != null) {
            final int f_i = i;
            Control[] controls = { colorSet, cColor, lblDesc };
            MouseTrackListener ml = new MouseTrackListener() {

                @Override
                public void mouseEnter(MouseEvent e) {
                    handleHover(listener, true, f_i, hover_state);
                }

                @Override
                public void mouseExit(MouseEvent e) {
                    handleHover(listener, false, f_i, hover_state);
                }

                @Override
                public void mouseHover(MouseEvent e) {
                }
            };
            for (Control c : controls) {
                c.addMouseTrackListener(ml);
            }
        }
    }
    legend.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            // We don't want to give them disposed colors
            // Restore defaults in case blockColors is a static or is used
            // afterwards, or if the view wants to dispose of the old colors.
            System.arraycopy(defaultColors, 0, blockColors, 0, blockColors.length);
            for (int i = 0; i < keys.length; i++) config.removeParameterListener(keys[i], paramListeners[i]);
        }
    });
    return legend;
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) Label(org.eclipse.swt.widgets.Label) RowData(org.eclipse.swt.layout.RowData) Control(org.eclipse.swt.widgets.Control) RowLayout(org.eclipse.swt.layout.RowLayout) ConfigurationManager(com.biglybt.core.config.impl.ConfigurationManager) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) Canvas(org.eclipse.swt.widgets.Canvas) RGB(org.eclipse.swt.graphics.RGB) ParameterListener(com.biglybt.core.config.ParameterListener)

Example 32 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class DciSummaryTable method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    config = (DciSummaryTableConfig) getElement().getAdapter(DciSummaryTableConfig.class);
    Composite dialogArea = new Composite(parent, SWT.NONE);
    currSortingList = config.getSortingColumnList();
    GridLayout layout = new GridLayout();
    dialogArea.setLayout(layout);
    objectSelector = new ObjectSelector(dialogArea, SWT.NONE, true);
    objectSelector.setLabel(Messages.get().DciSummaryTable_BaseObject);
    objectSelector.setObjectClass(AbstractObject.class);
    objectSelector.setObjectId(config.getBaseObjectId());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    objectSelector.setLayoutData(gd);
    tableSelector = new SummaryTableSelector(dialogArea, SWT.NONE, AbstractSelector.SHOW_CLEAR_BUTTON);
    tableSelector.setLabel(Messages.get().DciSummaryTable_SummaryTable);
    tableSelector.setTableId(config.getTableId());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    tableSelector.setLayoutData(gd);
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    refreshInterval = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().DciSummaryTable_RefreshInterval, 0, 10000, gd);
    refreshInterval.setSelection(config.getRefreshInterval());
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    checkShowSortAndLimitFields = new Button(dialogArea, SWT.CHECK);
    checkShowSortAndLimitFields.setText("Show top N nodes");
    checkShowSortAndLimitFields.setSelection(config.isEnableSortingAndLineLimit());
    checkShowSortAndLimitFields.setLayoutData(gd);
    checkShowSortAndLimitFields.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (checkShowSortAndLimitFields.getSelection()) {
                sortTables.setSelection(null);
                buttonAdd.setEnabled(true);
                numRowsShow.setEnabled(true);
            } else {
                buttonUp.setEnabled(false);
                buttonDown.setEnabled(false);
                buttonEdit.setEnabled(false);
                buttonRemove.setEnabled(false);
                buttonAdd.setEnabled(false);
                numRowsShow.setEnabled(false);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    Composite showTopNNodes = new Composite(dialogArea, SWT.BORDER);
    layout = new GridLayout();
    showTopNNodes.setLayout(layout);
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    numRowsShow = WidgetHelper.createLabeledSpinner(showTopNNodes, SWT.BORDER, "Number of lines to show", 0, 10000, gd);
    numRowsShow.setSelection(config.getNumRowShown());
    numRowsShow.setEnabled(config.isEnableSortingAndLineLimit());
    Label label = new Label(showTopNNodes, SWT.NONE);
    label.setText("Sort by columns");
    final String[] columnNames = { "Name", "Sort order" };
    final int[] columnWidths = { 320, 120 };
    sortTables = new SortableTableViewer(showTopNNodes, columnNames, columnWidths, 0, 0, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalSpan = 2;
    gd.heightHint = 150;
    sortTables.getTable().setLayoutData(gd);
    sortTables.setContentProvider(new ArrayContentProvider());
    sortTables.setLabelProvider(new SortColumnTableLabelProvider());
    sortTables.setInput(currSortingList);
    sortTables.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (checkShowSortAndLimitFields.getSelection()) {
                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                int index = currSortingList.indexOf(selection.getFirstElement());
                buttonUp.setEnabled((selection.size() == 1) && (index > 0));
                buttonDown.setEnabled((selection.size() == 1) && (index >= 0) && (index < currSortingList.size() - 1));
                buttonEdit.setEnabled(selection.size() == 1);
                buttonRemove.setEnabled(selection.size() > 0);
            } else {
                buttonUp.setEnabled(false);
                buttonDown.setEnabled(false);
                buttonEdit.setEnabled(false);
                buttonRemove.setEnabled(false);
            }
        }
    });
    sortTables.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            buttonEdit.notifyListeners(SWT.Selection, new Event());
        }
    });
    Composite buttons = new Composite(showTopNNodes, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    buttons.setLayoutData(gd);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttons.setLayout(buttonLayout);
    buttonUp = new Button(buttons, SWT.PUSH);
    buttonUp.setText("UP");
    buttonUp.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveUp();
        }
    });
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonUp.setLayoutData(rd);
    buttonUp.setEnabled(false);
    buttonDown = new Button(buttons, SWT.PUSH);
    buttonDown.setText("Down");
    buttonDown.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDown();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonDown.setLayoutData(rd);
    buttonDown.setEnabled(false);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    gd.verticalIndent = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
    buttons.setLayoutData(gd);
    buttonAdd = new Button(buttons, SWT.PUSH);
    buttonAdd.setText("Add");
    buttonAdd.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            add();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonAdd.setLayoutData(rd);
    buttonAdd.setEnabled(config.isEnableSortingAndLineLimit());
    buttonEdit = new Button(buttons, SWT.PUSH);
    buttonEdit.setText("Edit");
    buttonEdit.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            edit();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonEdit.setLayoutData(rd);
    buttonEdit.setEnabled(false);
    buttonRemove = new Button(buttons, SWT.PUSH);
    buttonRemove.setText("Delete");
    buttonRemove.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            remove();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonRemove.setLayoutData(rd);
    buttonRemove.setEnabled(false);
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SortColumnTableLabelProvider(org.netxms.ui.eclipse.dashboard.propertypages.helpers.SortColumnTableLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SummaryTableSelector(org.netxms.ui.eclipse.datacollection.widgets.SummaryTableSelector) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) ObjectSelector(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 33 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class IntegerConditionEditor method createContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createContent(Composite parent, ColumnFilter initialFilter) {
    Composite group = new Composite(this, SWT.NONE);
    RowLayout layout = new RowLayout();
    layout.type = SWT.HORIZONTAL;
    layout.marginBottom = 0;
    layout.marginTop = 0;
    layout.marginLeft = 0;
    layout.marginRight = 0;
    group.setLayout(layout);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    group.setLayoutData(gd);
    // $NON-NLS-1$
    value1 = toolkit.createText(group, "0");
    RowData rd = new RowData();
    rd.width = 90;
    value1.setLayoutData(rd);
    andLabel = toolkit.createLabel(group, Messages.get().IntegerConditionEditor_And);
    andLabel.setVisible(false);
    // $NON-NLS-1$
    value2 = toolkit.createText(group, "0");
    rd = new RowData();
    rd.width = 90;
    value2.setLayoutData(rd);
    value2.setVisible(false);
    if (initialFilter != null) {
        switch(initialFilter.getType()) {
            case EQUALS:
                setSelectedOperation(initialFilter.isNegated() ? 1 : 0);
                value1.setText(Long.toString(initialFilter.getNumericValue()));
                break;
            case GREATER:
                setSelectedOperation(initialFilter.isNegated() ? 3 : 5);
                value1.setText(Long.toString(initialFilter.getNumericValue()));
                break;
            case LESS:
                setSelectedOperation(initialFilter.isNegated() ? 4 : 2);
                value1.setText(Long.toString(initialFilter.getNumericValue()));
                break;
            case RANGE:
                setSelectedOperation(6);
                andLabel.setVisible(true);
                value2.setVisible(true);
                value1.setText(Long.toString(initialFilter.getRangeFrom()));
                value2.setText(Long.toString(initialFilter.getRangeTo()));
                break;
            default:
                break;
        }
    }
}
Also used : RowData(org.eclipse.swt.layout.RowData) Composite(org.eclipse.swt.widgets.Composite) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData)

Example 34 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class RulePStorage method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    editor = (RuleEditor) getElement().getAdapter(RuleEditor.class);
    rule = editor.getRule();
    pStorageDelete.addAll(rule.getPStorageDelete());
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.INNER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    final int vInd = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
    Label label = new Label(dialogArea, SWT.NONE);
    label.setText("Set persistent storage values");
    GridData gd = new GridData();
    gd.verticalIndent = vInd;
    label.setLayoutData(gd);
    sEditor = new SetEditor(dialogArea, SWT.NONE);
    sEditor.putAll(rule.getPStorageSet());
    gd = new GridData();
    gd.verticalIndent = vInd;
    gd.verticalAlignment = GridData.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    sEditor.setLayoutData(gd);
    label = new Label(dialogArea, SWT.NONE);
    label.setText("Delete persistent storage entries");
    gd = new GridData();
    gd.verticalIndent = vInd;
    label.setLayoutData(gd);
    final String[] deleteColumnNames = { "Key" };
    final int[] deleteColumnWidths = { 150 };
    viewerDeleteValue = new SortableTableViewer(dialogArea, deleteColumnNames, deleteColumnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewerDeleteValue.setContentProvider(new ArrayContentProvider());
    viewerDeleteValue.setComparator(new ObjectLabelComparator((ILabelProvider) viewerDeleteValue.getLabelProvider()));
    viewerDeleteValue.setInput(pStorageDelete.toArray());
    viewerDeleteValue.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            int size = ((IStructuredSelection) viewerDeleteValue.getSelection()).size();
            editDeleteValueButton.setEnabled(size == 1);
            removeDeleteValueButton.setEnabled(size > 0);
        }
    });
    gd = new GridData();
    gd.verticalAlignment = GridData.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    viewerDeleteValue.getControl().setLayoutData(gd);
    Composite buttonsDeleteValue = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginLeft = 0;
    buttonLayout.marginRight = 0;
    buttonsDeleteValue.setLayout(buttonLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    buttonsDeleteValue.setLayoutData(gd);
    addDeleteValueButton = new Button(buttonsDeleteValue, SWT.PUSH);
    addDeleteValueButton.setText("Add");
    addDeleteValueButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            addPStorageDeleteAction();
        }
    });
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addDeleteValueButton.setLayoutData(rd);
    editDeleteValueButton = new Button(buttonsDeleteValue, SWT.PUSH);
    editDeleteValueButton.setText("Edit");
    editDeleteValueButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            editPStorageDeleteAction();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    editDeleteValueButton.setLayoutData(rd);
    editDeleteValueButton.setEnabled(false);
    removeDeleteValueButton = new Button(buttonsDeleteValue, SWT.PUSH);
    removeDeleteValueButton.setText("Delete");
    removeDeleteValueButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            deletePStorageDeleteAction();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    removeDeleteValueButton.setLayoutData(rd);
    removeDeleteValueButton.setEnabled(false);
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SetEditor(org.netxms.ui.eclipse.widgets.SetEditor) ObjectLabelComparator(org.netxms.ui.eclipse.tools.ObjectLabelComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 35 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class RuleEvents method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    session = (NXCSession) ConsoleSharedData.getSession();
    editor = (RuleEditor) getElement().getAdapter(RuleEditor.class);
    rule = editor.getRule();
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    checkInverted = new Button(dialogArea, SWT.CHECK);
    checkInverted.setText(Messages.get().RuleEvents_InvertedRule);
    checkInverted.setSelection(rule.isEventsInverted());
    final String[] columnNames = { Messages.get().RuleEvents_Event };
    final int[] columnWidths = { 300 };
    viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new EventObjectLabelProvider());
    viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            int size = ((IStructuredSelection) viewer.getSelection()).size();
            deleteButton.setEnabled(size > 0);
        }
    });
    for (EventObject o : session.findMultipleEventObjects(rule.getEvents().toArray(new Long[0]))) events.put(o.getCode(), o);
    viewer.setInput(events.values().toArray());
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 0;
    viewer.getControl().setLayoutData(gridData);
    Composite buttons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginLeft = 0;
    buttonLayout.marginRight = 0;
    buttons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gridData);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().RuleEvents_Add);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            addEvent();
        }
    });
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().RuleEvents_Delete);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteEvent();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.setEnabled(false);
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ObjectLabelComparator(org.netxms.ui.eclipse.tools.ObjectLabelComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) EventObject(org.netxms.client.events.EventObject) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) EventObjectLabelProvider(org.netxms.ui.eclipse.epp.propertypages.helpers.EventObjectLabelProvider) RowLayout(org.eclipse.swt.layout.RowLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

RowData (org.eclipse.swt.layout.RowData)55 RowLayout (org.eclipse.swt.layout.RowLayout)52 Composite (org.eclipse.swt.widgets.Composite)48 Button (org.eclipse.swt.widgets.Button)45 GridData (org.eclipse.swt.layout.GridData)44 SelectionEvent (org.eclipse.swt.events.SelectionEvent)43 GridLayout (org.eclipse.swt.layout.GridLayout)40 SelectionListener (org.eclipse.swt.events.SelectionListener)33 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)26 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)26 Label (org.eclipse.swt.widgets.Label)26 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)25 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)21 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)21 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)20 Event (org.eclipse.swt.widgets.Event)15 TableViewer (org.eclipse.jface.viewers.TableViewer)12 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 Text (org.eclipse.swt.widgets.Text)11