Search in sources :

Example 1 with NamedSelectionStatePlugin

use of au.gov.asd.tac.constellation.views.namedselection.state.NamedSelectionStatePlugin in project constellation by constellation-app.

the class NamedSelectionManager method saveStateToGraph.

/**
 * Helper method that saves the current Named Selection state to the graph.
 *
 * @return The state that was saved to the graph.
 */
@SuppressWarnings("unchecked")
private NamedSelectionState saveStateToGraph() {
    final Graph graph = graphNode.getGraph();
    final NamedSelectionState newState;
    if (state != null) {
        newState = new NamedSelectionState(state);
    } else {
        newState = new NamedSelectionState();
    }
    // Only write graph if it exists.
    if (graph != null) {
        // Write what we have to the graph:
        final NamedSelectionStatePlugin nssp = new NamedSelectionStatePlugin(newState);
        final Future<?> f = PluginExecution.withPlugin(nssp).interactively(true).executeLater(graph);
        try {
            f.get();
        } catch (final InterruptedException ex) {
            LOGGER.log(Level.SEVERE, "Saving Named Selection state was interrupted", ex);
            Thread.currentThread().interrupt();
        } catch (final ExecutionException ex) {
            LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
        }
    }
    // Update the old state now:
    state = newState;
    return newState;
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) NamedSelectionStatePlugin(au.gov.asd.tac.constellation.views.namedselection.state.NamedSelectionStatePlugin) ExecutionException(java.util.concurrent.ExecutionException) NamedSelectionState(au.gov.asd.tac.constellation.views.namedselection.state.NamedSelectionState)

Aggregations

Graph (au.gov.asd.tac.constellation.graph.Graph)1 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 NamedSelectionState (au.gov.asd.tac.constellation.views.namedselection.state.NamedSelectionState)1 NamedSelectionStatePlugin (au.gov.asd.tac.constellation.views.namedselection.state.NamedSelectionStatePlugin)1 ExecutionException (java.util.concurrent.ExecutionException)1