提交 23d1b3f1 编写于 作者: S serge-rider

#2265 RSV: reset all color mappings


Former-commit-id: 922fc385
上级 6e10520e
......@@ -579,6 +579,11 @@ public class ResultSetModel {
return colorMapping.containsKey(binding);
}
boolean hasColorMapping(DBSEntity entity) {
DBVEntity virtualEntity = DBVUtils.findVirtualEntity(entity, false);
return virtualEntity != null && !CommonUtils.isEmpty(virtualEntity.getColorOverrides());
}
void updateColorMapping() {
colorMapping.clear();
DBSEntity entity = getSingleSource();
......
......@@ -1674,6 +1674,9 @@ public class ResultSetViewer extends Viewer
}
}
viewMenu.add(new CustomizeColorsAction(attr, row));
if (getModel().hasColorMapping(getModel().getSingleSource())) {
viewMenu.add(new ResetAllColorAction());
}
viewMenu.add(new Separator());
}
viewMenu.add(new Action("Data formats ...") {
......@@ -3351,6 +3354,22 @@ public class ResultSetViewer extends Viewer
}
}
private class ResetAllColorAction extends ColorAction {
ResetAllColorAction() {
super("Reset all colors");
}
@Override
public void run() {
final DBVEntity vEntity = getVirtualEntity(getModel().getAttributes()[0]);
if (!UIUtils.confirmAction("Reset all row coloring", "Are you sure you want to reset all color settings for '" + vEntity.getName() + "'?")) {
return;
}
vEntity.removeAllColorOverride();
updateColors(vEntity);
}
}
private class CustomizeColorsAction extends ColorAction {
private final DBDAttributeBinding curAttribute;
private final ResultSetRow row;
......
......@@ -415,12 +415,14 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
return;
}
final String attrName = attribute.getName();
for (Iterator<DBVColorOverride> iterator = colorOverrides.iterator(); iterator.hasNext(); ) {
DBVColorOverride c = iterator.next();
if (c.getAttributeName().equals(attrName)) {
iterator.remove();
}
colorOverrides.removeIf(c -> c.getAttributeName().equals(attrName));
}
public void removeAllColorOverride() {
if (colorOverrides == null) {
return;
}
colorOverrides.clear();
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册