Search in sources :

Example 1 with IconManager

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();
    }
}
Also used : Vertex(org.opennms.features.topology.api.topo.Vertex) IconManager(org.opennms.features.topology.api.IconManager)

Example 2 with IconManager

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();
}
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

IconManager (org.opennms.features.topology.api.IconManager)2 List (java.util.List)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 Vertex (org.opennms.features.topology.api.topo.Vertex)1 VertexRef (org.opennms.features.topology.api.topo.VertexRef)1 IconSelectionDialog (org.opennms.features.topology.app.internal.ui.icons.IconSelectionDialog)1