use of org.jkiss.dbeaver.model.virtual.DBVColorOverride in project dbeaver by dbeaver.
the class ResultSetModel method updateColorMapping.
void updateColorMapping() {
colorMapping.clear();
DBSEntity entity = getSingleSource();
if (entity == null) {
return;
}
DBVEntity virtualEntity = DBVUtils.findVirtualEntity(entity, false);
if (virtualEntity != null) {
List<DBVColorOverride> coList = virtualEntity.getColorOverrides();
if (!CommonUtils.isEmpty(coList)) {
for (DBVColorOverride co : coList) {
DBDAttributeBinding binding = getAttributeBinding(entity, co.getAttributeName());
if (binding != null) {
List<AttributeColorSettings> cmList = colorMapping.get(binding);
if (cmList == null) {
cmList = new ArrayList<>();
colorMapping.put(binding, cmList);
}
cmList.add(new AttributeColorSettings(co));
}
}
}
}
updateRowColors(curRows);
}
use of org.jkiss.dbeaver.model.virtual.DBVColorOverride in project dbeaver by serge-rider.
the class ColorSettingsDialog method updateAttributeSelection.
private void updateAttributeSelection() {
TableItem[] selection = attributeTable.getSelection();
if (selection.length == 0) {
attribute = null;
} else {
attribute = (DBDAttributeBinding) selection[0].getData();
}
colorsTable.removeAll();
if (attribute == null) {
// Nothing to load
curOverride = null;
colorOverrides = null;
} else {
colorOverrides = vEntity.getColorOverrides(attribute.getName());
if (colorOverrides == null) {
colorOverrides = new ArrayList<>();
}
for (DBVColorOverride co : colorOverrides) {
TableItem tableItem = new TableItem(colorsTable, SWT.NONE);
tableItem.setData(co);
updateColorItem(tableItem);
}
if (!colorOverrides.isEmpty()) {
curOverride = colorOverrides.get(0);
colorsTable.setSelection(0);
} else {
curOverride = null;
}
}
updateControlsState();
}
use of org.jkiss.dbeaver.model.virtual.DBVColorOverride in project dbeaver by serge-rider.
the class ColorSettingsDialog method createAttributeSelectorArea.
private void createAttributeSelectorArea(Composite composite) {
Composite panel = UIUtils.createComposite(composite, 1);
attributeTable = new Table(panel, SWT.FULL_SELECTION | SWT.BORDER);
attributeTable.setHeaderVisible(true);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 400;
attributeTable.setLayoutData(gd);
UIUtils.executeOnResize(attributeTable, () -> UIUtils.packColumns(attributeTable, true));
UIUtils.createTableColumn(attributeTable, SWT.LEFT, "Name");
UIUtils.createTableColumn(attributeTable, SWT.LEFT, "Colors");
for (DBDAttributeBinding attr : resultSetViewer.getModel().getVisibleAttributes()) {
TableItem attrItem = new TableItem(attributeTable, SWT.NONE);
attrItem.setData(attr);
attrItem.setText(0, attr.getName());
attrItem.setImage(0, DBeaverIcons.getImage(DBValueFormatting.getObjectImage(attr, true)));
if (this.attribute == attr) {
attributeTable.setSelection(attrItem);
}
// updateColumnItem(attrItem);
}
attributeTable.addListener(SWT.PaintItem, event -> {
if (event.index == 1) {
int x = event.x + 4;
DBDAttributeBinding attr = (DBDAttributeBinding) event.item.getData();
List<DBVColorOverride> coList = vEntity.getColorOverrides(attr.getName());
if (!coList.isEmpty()) {
for (DBVColorOverride co : coList) {
List<String> coStrings = new ArrayList<>();
if (co.getAttributeValues() != null) {
for (Object value : co.getAttributeValues()) {
coStrings.add(CommonUtils.toString(value));
}
}
// String colorSettings = " ";//String.join(", ", coStrings);
// Point textSize = event.gc.stringExtent(colorSettings);
int boxSize = attributeTable.getItemHeight() - 4;
Point textSize = new Point(boxSize, boxSize);
// getColorTableForeground(co);
Color fg = attributeTable.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
Color bg = getColorTableBackground(co);
if (fg != null)
event.gc.setForeground(fg);
if (bg != null)
event.gc.setBackground(bg);
event.gc.fillRectangle(x, event.y + 2, textSize.x, textSize.y);
event.gc.drawRectangle(x, event.y + 2, textSize.x - 1, textSize.y - 1);
// event.gc.drawText(colorSettings, x, event.y);
x += textSize.x + 4;
}
}
}
});
attributeTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateAttributeSelection();
}
});
}
use of org.jkiss.dbeaver.model.virtual.DBVColorOverride in project dbeaver by serge-rider.
the class ColorSettingsDialog method updateColorItem.
private void updateColorItem(TableItem tableItem) {
DBVColorOverride co = (DBVColorOverride) tableItem.getData();
String text;
Object[] values = co.getAttributeValues();
if (ArrayUtils.isEmpty(values)) {
text = co.getOperator().getStringValue() + " ?";
} else if (values.length == 1) {
text = co.getOperator().getStringValue() + " " + DBValueFormatting.getDefaultValueDisplayString(values[0], DBDDisplayFormat.UI);
} else {
if (co.isRange()) {
text = "In " + Arrays.toString(values);
} else {
text = co.getOperator().getStringValue() + " " + Arrays.toString(values);
}
}
tableItem.setText(0, text);
tableItem.setForeground(getColorTableForeground((DBVColorOverride) tableItem.getData()));
tableItem.setBackground(getColorTableBackground((DBVColorOverride) tableItem.getData()));
}
use of org.jkiss.dbeaver.model.virtual.DBVColorOverride in project dbeaver by serge-rider.
the class ResultSetModel method updateColorMapping.
void updateColorMapping() {
colorMapping.clear();
DBSEntity entity = getSingleSource();
if (entity == null) {
return;
}
DBVEntity virtualEntity = DBVUtils.findVirtualEntity(entity, false);
if (virtualEntity != null) {
List<DBVColorOverride> coList = virtualEntity.getColorOverrides();
if (!CommonUtils.isEmpty(coList)) {
for (DBVColorOverride co : coList) {
DBDAttributeBinding binding = getAttributeBinding(entity, co.getAttributeName());
if (binding != null) {
List<AttributeColorSettings> cmList = colorMapping.get(binding);
if (cmList == null) {
cmList = new ArrayList<>();
colorMapping.put(binding, cmList);
}
cmList.add(new AttributeColorSettings(co));
}
}
}
}
updateRowColors(curRows);
}
Aggregations