use of org.jkiss.dbeaver.ext.erd.part.IColorizedPart in project dbeaver by dbeaver.
the class SetPartColorAction method createColorCommand.
private Command createColorCommand(final Object[] objects) {
return new Command() {
private final Map<IColorizedPart, Color> oldColors = new HashMap<>();
private Color newColor;
@Override
public void execute() {
final Shell shell = UIUtils.createCenteredShell(getWorkbenchPart().getSite().getShell());
try {
ColorDialog colorDialog = new ColorDialog(shell);
RGB color = colorDialog.open();
if (color == null) {
return;
}
newColor = new Color(Display.getCurrent(), color);
for (Object item : objects) {
if (item instanceof IColorizedPart) {
IColorizedPart colorizedPart = (IColorizedPart) item;
oldColors.put(colorizedPart, colorizedPart.getCustomBackgroundColor());
colorizedPart.customizeBackgroundColor(newColor);
}
}
} finally {
shell.dispose();
}
}
@Override
public void undo() {
for (Object item : objects) {
if (item instanceof IColorizedPart) {
IColorizedPart colorizedPart = (IColorizedPart) item;
colorizedPart.customizeBackgroundColor(oldColors.get(colorizedPart));
}
}
}
@Override
public void redo() {
for (Object item : objects) {
if (item instanceof IColorizedPart) {
IColorizedPart colorizedPart = (IColorizedPart) item;
colorizedPart.customizeBackgroundColor(newColor);
}
}
}
};
}
Aggregations