Search in sources :

Example 1 with GraphManagerListener

use of au.gov.asd.tac.constellation.graph.manager.GraphManagerListener in project constellation by constellation-app.

the class FrameworkGraphManager method resultChanged.

@Override
public final void resultChanged(final LookupEvent ev) {
    final Graph oldActiveGraph = activeGraph;
    activeGraph = getActiveGraph();
    if (activeGraph != oldActiveGraph) {
        for (final GraphManagerListener listener : new ArrayList<>(listeners)) {
            listener.newActiveGraph(activeGraph);
        }
    }
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) ArrayList(java.util.ArrayList) GraphManagerListener(au.gov.asd.tac.constellation.graph.manager.GraphManagerListener)

Example 2 with GraphManagerListener

use of au.gov.asd.tac.constellation.graph.manager.GraphManagerListener in project constellation by constellation-app.

the class JDBCImportController method processImport.

@Override
public void processImport() throws PluginException {
    final List<ImportDefinition> definitions = configurationPane.createDefinitions(false);
    final Graph importGraph = currentDestination.getGraph();
    final boolean schema = schemaInitialised;
    if (currentDestination instanceof SchemaDestination) {
        final GraphManagerListener graphListener = new GraphManagerListener() {

            private boolean opened;

            @Override
            public void graphOpened(final Graph graph) {
            // Do nothing
            }

            @Override
            public void graphClosed(final Graph graph) {
            // Do nothing
            }

            @Override
            public synchronized void newActiveGraph(final Graph graph) {
                if (graph == importGraph && !opened) {
                    opened = true;
                    GraphManager.getDefault().removeGraphManagerListener(this);
                    PluginExecutor.startWith(ImportJDBCPlugin.class.getName(), false).set(ImportJDBCPlugin.DEFINITIONS_PARAMETER_ID, definitions).set(ImportJDBCPlugin.CONNECTION_PARAMETER_ID, connection).set(ImportJDBCPlugin.SCHEMA_PARAMETER_ID, schema).set(ImportJDBCPlugin.QUERY_PARAMETER_ID, query).set(ImportJDBCPlugin.USERNAME_PARAMETER_ID, username).set(ImportJDBCPlugin.PASSWORD_PARAMETER_ID, password).followedBy(ArrangementPluginRegistry.GRID_COMPOSITE).followedBy(InteractiveGraphPluginRegistry.RESET_VIEW).executeWriteLater(importGraph);
                }
            }
        };
        GraphManager.getDefault().addGraphManagerListener(graphListener);
        GraphOpener.getDefault().openGraph(importGraph, "graph");
    } else {
        PluginExecutor.startWith(ImportJDBCPlugin.class.getName(), false).set(ImportJDBCPlugin.DEFINITIONS_PARAMETER_ID, definitions).set(ImportJDBCPlugin.CONNECTION_PARAMETER_ID, connection).set(ImportJDBCPlugin.QUERY_PARAMETER_ID, query).set(ImportJDBCPlugin.USERNAME_PARAMETER_ID, username).set(ImportJDBCPlugin.PASSWORD_PARAMETER_ID, password).set(ImportJDBCPlugin.SCHEMA_PARAMETER_ID, schema).followedBy(ArrangementPluginRegistry.GRID_COMPOSITE).followedBy(InteractiveGraphPluginRegistry.RESET_VIEW).executeWriteLater(importGraph);
    }
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) SchemaDestination(au.gov.asd.tac.constellation.plugins.importexport.SchemaDestination) ImportDefinition(au.gov.asd.tac.constellation.plugins.importexport.ImportDefinition) GraphManagerListener(au.gov.asd.tac.constellation.graph.manager.GraphManagerListener)

Example 3 with GraphManagerListener

use of au.gov.asd.tac.constellation.graph.manager.GraphManagerListener in project constellation by constellation-app.

the class DelimitedImportController method processImport.

@Override
public void processImport() throws PluginException {
    final List<ImportDefinition> definitions = configurationPane.createDefinitions(isFilesIncludeHeadersEnabled());
    final Graph importGraph = currentDestination.getGraph();
    final boolean schema = schemaInitialised;
    final List<File> importFiles = new ArrayList<>(files);
    final ImportFileParser parser = importFileParser;
    if (currentDestination instanceof SchemaDestination) {
        final GraphManagerListener graphManagerListener = new GraphManagerListener() {

            private boolean opened = false;

            @Override
            public void graphOpened(Graph graph) {
            // Do nothing
            }

            @Override
            public void graphClosed(Graph graph) {
            // Do nothing
            }

            @Override
            public synchronized void newActiveGraph(final Graph graph) {
                if (graph == importGraph && !opened) {
                    opened = true;
                    GraphManager.getDefault().removeGraphManagerListener(this);
                    PluginExecutor.startWith(ImportExportPluginRegistry.IMPORT_DELIMITED, false).set(ImportDelimitedPlugin.DEFINITIONS_PARAMETER_ID, definitions).set(ImportDelimitedPlugin.PARSER_PARAMETER_ID, parser).set(ImportDelimitedPlugin.FILES_PARAMETER_ID, importFiles).set(ImportDelimitedPlugin.SCHEMA_PARAMETER_ID, schema).set(ImportDelimitedPlugin.PARSER_PARAMETER_IDS_PARAMETER_ID, currentParameters).set(ImportDelimitedPlugin.FILES_INCLUDE_HEADERS_PARAMETER_ID, filesIncludeHeaders).followedBy(ArrangementPluginRegistry.GRID_COMPOSITE).followedBy(InteractiveGraphPluginRegistry.RESET_VIEW).executeWriteLater(importGraph);
                }
            }
        };
        GraphManager.getDefault().addGraphManagerListener(graphManagerListener);
        GraphOpener.getDefault().openGraph(importGraph, "graph");
    } else {
        PluginExecutor.startWith(ImportExportPluginRegistry.IMPORT_DELIMITED, false).set(ImportDelimitedPlugin.DEFINITIONS_PARAMETER_ID, definitions).set(ImportDelimitedPlugin.PARSER_PARAMETER_ID, parser).set(ImportDelimitedPlugin.FILES_PARAMETER_ID, importFiles).set(ImportDelimitedPlugin.SCHEMA_PARAMETER_ID, schema).set(ImportDelimitedPlugin.FILES_INCLUDE_HEADERS_PARAMETER_ID, filesIncludeHeaders).followedBy(ArrangementPluginRegistry.GRID_COMPOSITE).followedBy(InteractiveGraphPluginRegistry.RESET_VIEW).executeWriteLater(importGraph);
    }
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) ImportFileParser(au.gov.asd.tac.constellation.plugins.importexport.delimited.parser.ImportFileParser) SchemaDestination(au.gov.asd.tac.constellation.plugins.importexport.SchemaDestination) ArrayList(java.util.ArrayList) ImportDefinition(au.gov.asd.tac.constellation.plugins.importexport.ImportDefinition) File(java.io.File) GraphManagerListener(au.gov.asd.tac.constellation.graph.manager.GraphManagerListener)

Aggregations

Graph (au.gov.asd.tac.constellation.graph.Graph)3 GraphManagerListener (au.gov.asd.tac.constellation.graph.manager.GraphManagerListener)3 ImportDefinition (au.gov.asd.tac.constellation.plugins.importexport.ImportDefinition)2 SchemaDestination (au.gov.asd.tac.constellation.plugins.importexport.SchemaDestination)2 ArrayList (java.util.ArrayList)2 ImportFileParser (au.gov.asd.tac.constellation.plugins.importexport.delimited.parser.ImportFileParser)1 File (java.io.File)1