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;
}
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;
}
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);
}
}
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;
}
Aggregations