@Override public boolean enabled(List<VertexRef> targets, OperationContext operationContext) { if (targets.size() != 1 || !(targets.get(0) instanceof AbstractVertex)) { return false; } return operationContext.getGraphContainer().getIconManager().findRepositoryByIconKey(((AbstractVertex) targets.get(0)).getIconKey()) != null; }
@Override public boolean enabled(List<VertexRef> targets, OperationContext operationContext) { if (targets.size() != 1 || !(targets.get(0) instanceof AbstractVertex)) { return false; } return operationContext.getGraphContainer().getIconManager().findRepositoryByIconKey(((AbstractVertex) targets.get(0)).getIconKey()) != null; }
@Override public boolean enabled(List<VertexRef> targets, OperationContext operationContext) { // only enabled, if all elements are a Vertex return targets.stream() .allMatch(v -> v instanceof Vertex && operationContext.getGraphContainer().getIconManager().findRepositoryByIconKey(((Vertex) v).getIconKey()) != null); }
@Override public boolean enabled(List<VertexRef> targets, OperationContext operationContext) { // only enabled, if all elements are a Vertex return targets.stream() .allMatch(v -> v instanceof Vertex && operationContext.getGraphContainer().getIconManager().findRepositoryByIconKey(((Vertex) v).getIconKey()) != null); }
@Override public void execute(List<VertexRef> targets, OperationContext operationContext) { IconManager iconManager = operationContext.getGraphContainer().getIconManager(); final boolean[] updated = {false}; targets.forEach(vertex -> { updated[0] |= iconManager.removeIconMapping((Vertex) vertex); }); // Redo the layout to apply new icon if (updated[0]) { // HACK! We have no concept of "get the default icon for a vertex" at the moment. // In order to populate the icon, we have to redo the layout operationContext.getGraphContainer().setDirty(true); operationContext.getGraphContainer().redoLayout(); } }
@Override public void execute(List<VertexRef> targets, OperationContext operationContext) { IconManager iconManager = operationContext.getGraphContainer().getIconManager(); final boolean[] updated = {false}; targets.forEach(vertex -> { updated[0] |= iconManager.removeIconMapping((Vertex) vertex); }); // Redo the layout to apply new icon if (updated[0]) { // HACK! We have no concept of "get the default icon for a vertex" at the moment. // In order to populate the icon, we have to redo the layout operationContext.getGraphContainer().setDirty(true); operationContext.getGraphContainer().redoLayout(); } }
@Override public void execute(List<VertexRef> targets, OperationContext operationContext) { final AbstractVertex vertex = (AbstractVertex) targets.get(0); final String preSelectedIconId = operationContext.getGraphContainer().getIconManager().getSVGIconId(vertex); new IconSelectionDialog(preSelectedIconId) .withOkAction(iconWindow -> { final IconManager iconManager = operationContext.getGraphContainer().getIconManager(); final String newIconId = iconWindow.getSelectedIcon(); String newIconKey = iconManager.setIconMapping(vertex, newIconId); if (newIconKey != null) { // We have to temporary update the icon key, otherwise the icon is not updated (redoLayout has no effect) vertex.setIconKey(newIconKey); // Redo the layout to apply new icon operationContext.getGraphContainer().setDirty(true); operationContext.getGraphContainer().redoLayout(); } }) .open(); }
@Override public void execute(List<VertexRef> targets, OperationContext operationContext) { final AbstractVertex vertex = (AbstractVertex) targets.get(0); final String preSelectedIconId = operationContext.getGraphContainer().getIconManager().getSVGIconId(vertex); new IconSelectionDialog(preSelectedIconId) .withOkAction(iconWindow -> { final IconManager iconManager = operationContext.getGraphContainer().getIconManager(); final String newIconId = iconWindow.getSelectedIcon(); String newIconKey = iconManager.setIconMapping(vertex, newIconId); if (newIconKey != null) { // We have to temporary update the icon key, otherwise the icon is not updated (redoLayout has no effect) vertex.setIconKey(newIconKey); // Redo the layout to apply new icon operationContext.getGraphContainer().setDirty(true); operationContext.getGraphContainer().redoLayout(); } }) .open(); }