use of org.opennms.features.topology.app.internal.ui.icons.IconSelectionDialog in project opennms by OpenNMS.
the class IconSelectionOperation method execute.
@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();
}
Aggregations