Search in sources :

Example 1 with IconSelectionDialog

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();
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) List(java.util.List) IconSelectionDialog(org.opennms.features.topology.app.internal.ui.icons.IconSelectionDialog) Operation(org.opennms.features.topology.api.Operation) OperationContext(org.opennms.features.topology.api.OperationContext) IconManager(org.opennms.features.topology.api.IconManager) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) VertexRef(org.opennms.features.topology.api.topo.VertexRef) IconSelectionDialog(org.opennms.features.topology.app.internal.ui.icons.IconSelectionDialog) IconManager(org.opennms.features.topology.api.IconManager)

Aggregations

List (java.util.List)1 IconManager (org.opennms.features.topology.api.IconManager)1 Operation (org.opennms.features.topology.api.Operation)1 OperationContext (org.opennms.features.topology.api.OperationContext)1 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)1 VertexRef (org.opennms.features.topology.api.topo.VertexRef)1 IconSelectionDialog (org.opennms.features.topology.app.internal.ui.icons.IconSelectionDialog)1