Search in sources :

Example 36 with ColorSelector

use of org.eclipse.jface.preference.ColorSelector in project yamcs-studio by yamcs.

the class ColoringRuleDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    var fieldArea = new Composite((Composite) super.createDialogArea(parent), SWT.NONE);
    var noExpression = expression == null;
    var title = noExpression ? "Add Coloring Rule" : "Edit Coloring Rule";
    getShell().setText(title);
    setTitle(title);
    setMessage(noExpression ? "Enter color rule details." : "Edit color rule details.");
    fieldArea.setLayoutData(new GridData(GridData.FILL_BOTH));
    var gl = new GridLayout(2, false);
    fieldArea.setLayout(gl);
    var label = new Label(fieldArea, SWT.NONE);
    label.setText("Expression");
    label.setLayoutData(new GridData());
    expressionText = new Text(fieldArea, SWT.BORDER);
    if (expression != null) {
        expressionText.setText(expression);
    }
    expressionText.setLayoutData(new GridData());
    expressionText.addModifyListener(e -> updatePageComplete());
    expressionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    new Label(fieldArea, SWT.NONE);
    var example = new Composite(fieldArea, SWT.NONE);
    example.setLayoutData(new GridData(GridData.FILL_BOTH));
    gl = new GridLayout(2, false);
    example.setLayout(gl);
    label = new Label(example, SWT.NONE);
    label.setText("Example:");
    label = new Label(example, SWT.NONE);
    label.setText("severity == WARNING &&&& type == LVPDU");
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    new Label(example, SWT.NONE);
    label = new Label(example, SWT.NONE);
    label.setText("Operator precedence: ==  !=  &&&&  ||");
    new Label(example, SWT.NONE);
    label = new Label(example, SWT.NONE);
    label.setText("Properties: severity  type  source");
    label = new Label(fieldArea, SWT.NONE);
    label.setText("Background Color");
    label.setLayoutData(new GridData());
    bgSelector = new ColorSelector(fieldArea);
    bgSelector.setColorValue(bg);
    var backgroundColorButton = bgSelector.getButton();
    backgroundColorButton.setLayoutData(new GridData());
    label = new Label(fieldArea, SWT.NONE);
    label.setText("Foreground Color");
    label.setLayoutData(new GridData());
    fgSelector = new ColorSelector(fieldArea);
    fgSelector.setColorValue(fg);
    var foregroundColorButton = fgSelector.getButton();
    foregroundColorButton.setLayoutData(new GridData());
    Dialog.applyDialogFont(fieldArea);
    return fieldArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) ColorSelector(org.eclipse.jface.preference.ColorSelector)

Example 37 with ColorSelector

use of org.eclipse.jface.preference.ColorSelector in project dbeaver by dbeaver.

the class PrefPageConnectionTypes method createContents.

@Override
protected Control createContents(final Composite parent) {
    Composite composite = UIUtils.createComposite(parent, 1);
    {
        typeTable = new Table(composite, SWT.SINGLE | SWT.BORDER);
        typeTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        UIUtils.createTableColumn(typeTable, SWT.LEFT, CoreMessages.pref_page_connection_types_label_table_column_name);
        UIUtils.createTableColumn(typeTable, SWT.LEFT, CoreMessages.pref_page_connection_types_label_table_column_description);
        typeTable.setHeaderVisible(true);
        typeTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        typeTable.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                showSelectedType(getSelectedType());
            }
        });
        ToolBar toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL);
        final ToolItem newButton = new ToolItem(toolbar, SWT.NONE);
        newButton.setImage(DBeaverIcons.getImage(UIIcon.ROW_ADD));
        deleteButton = new ToolItem(toolbar, SWT.NONE);
        deleteButton.setImage(DBeaverIcons.getImage(UIIcon.ROW_DELETE));
        newButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                String name;
                for (int i = 1; ; i++) {
                    name = "Type" + i;
                    boolean hasName = false;
                    for (DBPConnectionType type : changedInfo.keySet()) {
                        if (type.getName().equals(name)) {
                            hasName = true;
                            break;
                        }
                    }
                    if (!hasName) {
                        break;
                    }
                }
                DBPConnectionType newType = new DBPConnectionType(name.toLowerCase(), name, "255,255,255", "New type", true, false, true);
                addTypeToTable(newType, newType);
                typeTable.select(typeTable.getItemCount() - 1);
                typeTable.showSelection();
                showSelectedType(newType);
            }
        });
        this.deleteButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DBPConnectionType connectionType = getSelectedType();
                if (!UIUtils.confirmAction(getShell(), CoreMessages.pref_page_connection_types_label_delete_connection_type, NLS.bind(CoreMessages.pref_page_connection_types_label_delete_connection_type_description, connectionType.getName(), DBPConnectionType.DEFAULT_TYPE.getName()))) {
                    return;
                }
                changedInfo.remove(connectionType);
                int index = typeTable.getSelectionIndex();
                typeTable.remove(index);
                if (index > 0)
                    index--;
                typeTable.select(index);
                showSelectedType(getSelectedType());
            }
        });
    }
    {
        Group groupSettings = UIUtils.createControlGroup(composite, CoreMessages.pref_page_connection_types_group_settings, 2, GridData.VERTICAL_ALIGN_BEGINNING, 300);
        groupSettings.setLayoutData(new GridData(GridData.FILL_BOTH));
        typeId = UIUtils.createLabelText(groupSettings, CoreMessages.pref_page_connection_types_label_id, null);
        typeId.addModifyListener(e -> {
            getSelectedType().setId(typeId.getText());
            updateTableInfo();
        });
        typeName = UIUtils.createLabelText(groupSettings, CoreMessages.pref_page_connection_types_label_name, null);
        typeName.addModifyListener(e -> {
            getSelectedType().setName(typeName.getText());
            updateTableInfo();
        });
        typeDescription = UIUtils.createLabelText(groupSettings, CoreMessages.pref_page_connection_types_label_description, null);
        typeDescription.addModifyListener(e -> {
            getSelectedType().setDescription(typeDescription.getText());
            updateTableInfo();
        });
        {
            UIUtils.createControlLabel(groupSettings, CoreMessages.pref_page_connection_types_label_color);
            // Composite colorGroup = UIUtils.createPlaceholder(groupSettings, 2, 5);
            // colorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            colorPicker = new ColorSelector(groupSettings);
            // colorPicker.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            colorPicker.addListener(event -> {
                getSelectedType().setColor(StringConverter.asString(colorPicker.getColorValue()));
                updateTableInfo();
            });
        /*
                Button pickerButton = new Button(colorGroup, SWT.PUSH);
                pickerButton.setText("...");
                pickerButton.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e)
                    {
                        DBPConnectionType connectionType = getSelectedType();
                        ColorDialog colorDialog = new ColorDialog(parent.getShell());
                        colorDialog.setRGB(StringConverter.asRGB(connectionType.getColor()));
                        RGB rgb = colorDialog.open();
                        if (rgb != null) {
                            Color color = null;
                            int count = colorPicker.getItemCount();
                            for (int i = 0; i < count; i++) {
                                Color item = colorPicker.getColorItem(i);
                                if (item != null && item.getRGB().equals(rgb)) {
                                    color = item;
                                    break;
                                }
                            }
                            if (color == null) {
                                color = new Color(colorPicker.getDisplay(), rgb);
                                colorPicker.addColor(color);
                            }
                            colorPicker.select(color);
                            getSelectedType().setColor(StringConverter.asString(color.getRGB()));
                            updateTableInfo();
                        }
                    }
                });
*/
        }
        autocommitCheck = UIUtils.createCheckbox(groupSettings, CoreMessages.pref_page_connection_types_label_auto_commit_by_default, null, false, 2);
        autocommitCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                getSelectedType().setAutocommit(autocommitCheck.getSelection());
            }
        });
        confirmCheck = UIUtils.createCheckbox(groupSettings, CoreMessages.pref_page_connection_types_label_confirm_sql_execution, null, false, 2);
        confirmCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                getSelectedType().setConfirmExecute(confirmCheck.getSelection());
            }
        });
        confirmDataChange = UIUtils.createCheckbox(groupSettings, CoreMessages.pref_page_connection_types_label_confirm_data_change, CoreMessages.pref_page_connection_types_label_confirm_data_change_tip, false, 2);
        confirmDataChange.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                getSelectedType().setConfirmDataChange(confirmDataChange.getSelection());
            }
        });
        Button epButton = UIUtils.createDialogButton(groupSettings, "Edit permissions ...", new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                EditConnectionPermissionsDialog dialog = new EditConnectionPermissionsDialog(getShell(), getSelectedType().getModifyPermission());
                if (dialog.open() == IDialogConstants.OK_ID) {
                    getSelectedType().setModifyPermissions(dialog.getAccessRestrictions());
                }
            }
        });
        GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gd.horizontalSpan = 2;
        epButton.setLayoutData(gd);
    }
    performDefaults();
    return composite;
}
Also used : DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) java.util(java.util) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) ColorSelector(org.eclipse.jface.preference.ColorSelector) ControlEvent(org.eclipse.swt.events.ControlEvent) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) DBeaverIcons(org.jkiss.dbeaver.ui.DBeaverIcons) UIUtils(org.jkiss.dbeaver.ui.UIUtils) SecurityUtils(org.jkiss.utils.SecurityUtils) DataSourceProviderRegistry(org.jkiss.dbeaver.registry.DataSourceProviderRegistry) UIIcon(org.jkiss.dbeaver.ui.UIIcon) GridData(org.eclipse.swt.layout.GridData) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) IAdaptable(org.eclipse.core.runtime.IAdaptable) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) NLS(org.eclipse.osgi.util.NLS) IWorkbenchPropertyPage(org.eclipse.ui.IWorkbenchPropertyPage) org.eclipse.swt.widgets(org.eclipse.swt.widgets) IWorkbenchPreferencePage(org.eclipse.ui.IWorkbenchPreferencePage) CoreMessages(org.jkiss.dbeaver.core.CoreMessages) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) List(java.util.List) Color(org.eclipse.swt.graphics.Color) EditConnectionPermissionsDialog(org.jkiss.dbeaver.ui.dialogs.connection.EditConnectionPermissionsDialog) ControlAdapter(org.eclipse.swt.events.ControlAdapter) SWT(org.eclipse.swt.SWT) StringConverter(org.eclipse.jface.resource.StringConverter) IWorkbench(org.eclipse.ui.IWorkbench) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ColorSelector(org.eclipse.jface.preference.ColorSelector) EditConnectionPermissionsDialog(org.jkiss.dbeaver.ui.dialogs.connection.EditConnectionPermissionsDialog)

Example 38 with ColorSelector

use of org.eclipse.jface.preference.ColorSelector in project dbeaver by dbeaver.

the class ColorSettingsDialog method createAttributeSettingsArea.

private void createAttributeSettingsArea(Composite composite) {
    Composite mainGroup = UIUtils.createComposite(composite, 1);
    mainGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH));
    {
        Composite colorsGroup = UIUtils.createComposite(mainGroup, 2);
        colorsGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH));
        // UIUtils.createControlLabel(colorsGroup, "Cell conditions");
        colorsTable = new Table(colorsGroup, SWT.BORDER | SWT.FULL_SELECTION);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 300;
        gd.heightHint = 100;
        colorsTable.setLayoutData(gd);
        colorsTable.addListener(SWT.EraseItem, event -> {
            if ((event.detail & SWT.SELECTED) != 0) {
                // event.detail &= ~SWT.SELECTED;
                Color bgColor = getColorTableBackground((DBVColorOverride) event.item.getData());
                if (bgColor != null) {
                    event.gc.setBackground(bgColor);
                } else {
                    event.gc.setBackground(colorsTable.getBackground());
                }
                event.gc.fillRectangle(event.x, event.y, event.width, event.height);
                event.gc.drawRectangle(event.x, event.y, event.width - 1, event.height - 1);
            }
        });
        /*
            colorsTable.addListener(SWT.PaintItem, event -> {
                if ((event.detail & SWT.SELECTED) == 0) {
                    return;
                }
                event.gc.drawText(((TableItem) event.item).getText(), event.x, event.y);
            });
*/
        // UIUtils.createTableColumn(colorsTable, SWT.LEFT, "Operator");
        UIUtils.createTableColumn(colorsTable, SWT.RIGHT, "Value(s)");
        UIUtils.executeOnResize(colorsTable, () -> UIUtils.packColumns(colorsTable, true));
        colorsTable.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                int selectionIndex = colorsTable.getSelectionIndex();
                curOverride = selectionIndex < 0 ? null : (DBVColorOverride) colorsTable.getItem(selectionIndex).getData();
                btnDelete.setEnabled(selectionIndex >= 0);
                updateControlsState();
            }
        });
        {
            ToolBar buttonsPanel = new ToolBar(colorsGroup, SWT.FLAT | SWT.VERTICAL);
            buttonsPanel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
            UIUtils.createToolItem(buttonsPanel, "Add", UIIcon.ROW_ADD, new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    curOverride = new DBVColorOverride(attribute.getName(), DBCLogicalOperator.EQUALS, null, null, null);
                    vEntity.addColorOverride(curOverride);
                    TableItem tableItem = new TableItem(colorsTable, SWT.NONE);
                    tableItem.setData(curOverride);
                    colorsTable.setSelection(tableItem);
                    updateColorItem(tableItem);
                    updateControlsState();
                }
            });
            btnDelete = UIUtils.createToolItem(buttonsPanel, "Delete", UIIcon.ROW_DELETE, new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (curOverride != null) {
                        colorsTable.getItem(colorsTable.getSelectionIndex()).dispose();
                        vEntity.removeColorOverride(curOverride);
                        curOverride = null;
                        updateControlsState();
                    }
                }
            });
            btnDelete.setEnabled(false);
        }
    }
    {
        settingsGroup = new Composite(mainGroup, SWT.NONE);
        settingsGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL));
        settingsGroup.setLayout(new GridLayout(3, false));
        GridData gd = new GridData();
        gd.horizontalSpan = 3;
        UIUtils.createControlLabel(settingsGroup, "Settings").setLayoutData(gd);
        rangeCheck = UIUtils.createCheckbox(settingsGroup, "Range / gradient", "Use value range / color gradient", false, 3);
        rangeCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (curOverride != null) {
                    curOverride.setRange(rangeCheck.getSelection());
                }
                updateControlsState();
            }
        });
        singleColumnCheck = UIUtils.createCheckbox(settingsGroup, "Apply colors to this column only", "Apply colors to this column only, otherwise color full row", false, 3);
        singleColumnCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (curOverride != null) {
                    curOverride.setSingleColumn(singleColumnCheck.getSelection());
                }
            }
        });
        UIUtils.createControlLabel(settingsGroup, "Value(s)");
        editorPlaceholder1 = new Composite(settingsGroup, SWT.NONE);
        editorPlaceholder1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        editorPlaceholder1.setLayout(new FillLayout());
        editorPlaceholder2 = new Composite(settingsGroup, SWT.NONE);
        editorPlaceholder2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        editorPlaceholder2.setLayout(new FillLayout());
        valueEditor1 = createValueEditor(editorPlaceholder1, 0);
        valueEditor2 = createValueEditor(editorPlaceholder2, 1);
        UIUtils.createControlLabel(settingsGroup, "Background");
        bgColorSelector1 = new ColorSelector(settingsGroup);
        bgColorSelector1.addListener(event -> {
            curOverride.setColorBackground(StringConverter.asString(bgColorSelector1.getColorValue()));
            updateCurrentTreeItem();
        });
        bgColorSelector2 = new ColorSelector(settingsGroup);
        bgColorSelector2.addListener(event -> {
            curOverride.setColorBackground2(StringConverter.asString(bgColorSelector2.getColorValue()));
            updateCurrentTreeItem();
        });
        UIUtils.createControlLabel(settingsGroup, "Foreground");
        fgColorSelector1 = new ColorSelector(settingsGroup);
        fgColorSelector1.addListener(event -> {
            curOverride.setColorForeground(StringConverter.asString(fgColorSelector1.getColorValue()));
            updateCurrentTreeItem();
        });
        fgColorSelector2 = new ColorSelector(settingsGroup);
        fgColorSelector2.addListener(event -> {
            curOverride.setColorForeground2(StringConverter.asString(fgColorSelector2.getColorValue()));
            updateCurrentTreeItem();
        });
        UIUtils.createInfoLabel(settingsGroup, "To use gradient set minimum and maximum\ncolumn values and two\ncolors for gradient range. ", GridData.FILL_HORIZONTAL, 3);
    }
}
Also used : Arrays(java.util.Arrays) SashForm(org.eclipse.swt.custom.SashForm) IValueManager(org.jkiss.dbeaver.ui.data.IValueManager) ControlEnableState(org.eclipse.jface.dialogs.ControlEnableState) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) ResultSetRow(org.jkiss.dbeaver.ui.controls.resultset.ResultSetRow) Nullable(org.jkiss.code.Nullable) Point(org.eclipse.swt.graphics.Point) NotNull(org.jkiss.code.NotNull) ColorSelector(org.eclipse.jface.preference.ColorSelector) ArrayList(java.util.ArrayList) BaseDialog(org.jkiss.dbeaver.ui.dialogs.BaseDialog) DBVColorOverride(org.jkiss.dbeaver.model.virtual.DBVColorOverride) DBeaverIcons(org.jkiss.dbeaver.ui.DBeaverIcons) IValueEditor(org.jkiss.dbeaver.ui.data.IValueEditor) DBDDisplayFormat(org.jkiss.dbeaver.model.data.DBDDisplayFormat) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity) UIUtils(org.jkiss.dbeaver.ui.UIUtils) ResultSetViewer(org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer) Log(org.jkiss.dbeaver.Log) RGB(org.eclipse.swt.graphics.RGB) UIIcon(org.jkiss.dbeaver.ui.UIIcon) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) ResultSetUtils(org.jkiss.dbeaver.ui.controls.resultset.ResultSetUtils) ResultSetValueController(org.jkiss.dbeaver.ui.controls.resultset.ResultSetValueController) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) DBCLogicalOperator(org.jkiss.dbeaver.model.exec.DBCLogicalOperator) DBValueFormatting(org.jkiss.dbeaver.model.DBValueFormatting) org.eclipse.swt.widgets(org.eclipse.swt.widgets) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) ArrayUtils(org.jkiss.utils.ArrayUtils) List(java.util.List) Color(org.eclipse.swt.graphics.Color) DBException(org.jkiss.dbeaver.DBException) SWT(org.eclipse.swt.SWT) StringConverter(org.eclipse.jface.resource.StringConverter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ValueManagerRegistry(org.jkiss.dbeaver.ui.data.registry.ValueManagerRegistry) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) DBVColorOverride(org.jkiss.dbeaver.model.virtual.DBVColorOverride) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ColorSelector(org.eclipse.jface.preference.ColorSelector) DBVColorOverride(org.jkiss.dbeaver.model.virtual.DBVColorOverride)

Example 39 with ColorSelector

use of org.eclipse.jface.preference.ColorSelector in project pmd-eclipse-plugin by pmd.

the class GeneralPreferencesPage method buildPriorityGroup.

/**
 * Build the group of priority preferences
 *
 * @param parent
 *            the parent composite
 * @return the group widget
 */
private Group buildPriorityGroup(final Composite parent) {
    Group group = new Group(parent, SWT.SHADOW_IN);
    group.setText(getMessage(StringKeys.PREF_GENERAL_GROUP_PRIORITIES));
    group.setLayout(new GridLayout(2, false));
    Link link = createPreferenceLink(group, "PMD folder annotations can be enabled on the <A>label decorations</A> page", "org.eclipse.ui.preferencePages.Decorators");
    link.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));
    useCustomPriorityNames = buildUseCustomPriorityNamesButton(group);
    useCustomPriorityNames.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false, 1, 1));
    IStructuredContentProvider contentProvider = new IStructuredContentProvider() {

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public Object[] getElements(Object inputElement) {
            return (RulePriority[]) inputElement;
        }
    };
    BasicTableLabelProvider labelProvider = new BasicTableLabelProvider(PriorityColumnUI.VISIBLE_COLUMNS);
    priorityTableMgr = new BasicTableManager("prio", null, PriorityColumnUI.VISIBLE_COLUMNS);
    tableViewer = priorityTableMgr.buildTableViewer(group);
    priorityTableMgr.setupColumns(PriorityColumnUI.VISIBLE_COLUMNS);
    Table table = tableViewer.getTable();
    table.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true, 2, 1));
    tableViewer.setLabelProvider(labelProvider);
    tableViewer.setContentProvider(contentProvider);
    table.setHeaderVisible(true);
    // labelProvider.addColumnsTo(table);
    tableViewer.setInput(UISettings.currentPriorities(true));
    // TableColumn[] columns = table.getColumns();
    // for (TableColumn column : columns) column.pack();
    Composite editorPanel = new Composite(group, SWT.None);
    editorPanel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
    editorPanel.setLayout(new GridLayout(6, false));
    Label shapeLabel = new Label(editorPanel, SWT.None);
    shapeLabel.setLayoutData(new GridData());
    shapeLabel.setText("Shape:");
    final ShapePicker<Shape> ssc = new ShapePicker<Shape>(editorPanel, SWT.None, 14);
    ssc.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    ssc.setSize(280, 30);
    ssc.setShapeMap(UISettings.shapeSet(SHAPE_COLOR, 10));
    ssc.setItems(UISettings.allShapes());
    Label colourLabel = new Label(editorPanel, SWT.None);
    colourLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
    colourLabel.setText("Color:");
    final ColorSelector colorPicker = new ColorSelector(editorPanel);
    Label nameLabel = new Label(editorPanel, SWT.None);
    nameLabel.setLayoutData(new GridData());
    nameLabel.setText("Name:");
    final Text priorityName = new Text(editorPanel, SWT.BORDER);
    priorityName.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
    nameFields = new Control[] { nameLabel, priorityName };
    // final Label descLabel = new Label(editorPanel, SWT.None);
    // descLabel.setLayoutData( new GridData(GridData.FILL, GridData.CENTER,
    // false, true, 1, 1));
    // descLabel.setText("Description:");
    // final Text priorityDesc = new Text(editorPanel, SWT.BORDER);
    // priorityDesc.setLayoutData( new GridData(GridData.FILL,
    // GridData.CENTER, true, true, 5, 1) );
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            selectedPriorities(selection.toList(), ssc, colorPicker, priorityName);
        }
    });
    ssc.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            setShape((Shape) selection.getFirstElement());
        }
    });
    colorPicker.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            setColor((RGB) event.getNewValue());
        }
    });
    priorityName.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent e) {
            setName(priorityName.getText());
        }
    });
    // only set this once the name fields are built
    useCustomPriorityNames.setSelection(preferences.useCustomPriorityNames());
    return group;
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Shape(net.sourceforge.pmd.eclipse.ui.Shape) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ShapePicker(net.sourceforge.pmd.eclipse.ui.ShapePicker) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) BasicTableManager(net.sourceforge.pmd.eclipse.ui.preferences.br.BasicTableManager) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) BasicTableLabelProvider(net.sourceforge.pmd.eclipse.ui.BasicTableLabelProvider) Text(org.eclipse.swt.widgets.Text) RGB(org.eclipse.swt.graphics.RGB) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ColorSelector(org.eclipse.jface.preference.ColorSelector) Link(org.eclipse.swt.widgets.Link)

Aggregations

ColorSelector (org.eclipse.jface.preference.ColorSelector)39 GridData (org.eclipse.swt.layout.GridData)37 Composite (org.eclipse.swt.widgets.Composite)31 GridLayout (org.eclipse.swt.layout.GridLayout)27 Label (org.eclipse.swt.widgets.Label)27 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 Button (org.eclipse.swt.widgets.Button)20 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)14 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 SelectionListener (org.eclipse.swt.events.SelectionListener)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)13 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)12 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)12 Group (org.eclipse.swt.widgets.Group)11 Link (org.eclipse.swt.widgets.Link)10 SashForm (org.eclipse.swt.custom.SashForm)9 RGB (org.eclipse.swt.graphics.RGB)8 Iterator (java.util.Iterator)7 SourceViewer (org.eclipse.jface.text.source.SourceViewer)7