use of org.opennms.features.topology.api.IconManager in project opennms by OpenNMS.
the class IconResetOperation method execute.
@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();
}
}
use of org.opennms.features.topology.api.IconManager 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