Search in sources :

Example 21 with Workspace

use of org.gephi.project.api.Workspace in project gephi by gephi.

the class CopyOrMoveToWorkspaceSubItem method copyToWorkspace.

public boolean copyToWorkspace(Workspace workspace) {
    ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
    Workspace currentWorkspace = projectController.getCurrentWorkspace();
    GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
    GraphModel graphModel;
    if (workspace == null) {
        workspace = Lookup.getDefault().lookup(ProjectControllerUI.class).newWorkspace();
        graphModel = graphController.getGraphModel(workspace);
        GraphModel currentGraphModel = graphController.getGraphModel(currentWorkspace);
        graphModel.setConfiguration(currentGraphModel.getConfiguration());
        graphModel.setTimeFormat(currentGraphModel.getTimeFormat());
        graphModel.setTimeZone(currentGraphModel.getTimeZone());
    } else {
        graphModel = graphController.getGraphModel(workspace);
    }
    try {
        graphModel.bridge().copyNodes(nodes);
        return true;
    } catch (Exception e) {
        String error = NbBundle.getMessage(CopyOrMoveToWorkspace.class, "GraphContextMenu_CopyOrMoveToWorkspace_ConfigurationNotCompatible");
        String title = NbBundle.getMessage(CopyOrMoveToWorkspace.class, "GraphContextMenu_CopyOrMoveToWorkspace_ConfigurationNotCompatible_Title");
        JOptionPane.showMessageDialog(null, error, title, JOptionPane.ERROR_MESSAGE);
        return false;
    }
}
Also used : GraphModel(org.gephi.graph.api.GraphModel) ProjectController(org.gephi.project.api.ProjectController) GraphController(org.gephi.graph.api.GraphController) Workspace(org.gephi.project.api.Workspace)

Aggregations

Workspace (org.gephi.project.api.Workspace)21 ProjectController (org.gephi.project.api.ProjectController)12 IOException (java.io.IOException)4 GraphModel (org.gephi.graph.api.GraphModel)3 WorkspaceListener (org.gephi.project.api.WorkspaceListener)3 WorkspaceProvider (org.gephi.project.api.WorkspaceProvider)3 BufferedOutputStream (java.io.BufferedOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 ArrayList (java.util.ArrayList)2 JPanel (javax.swing.JPanel)2 ProjectControllerUI (org.gephi.desktop.project.api.ProjectControllerUI)2 GraphController (org.gephi.graph.api.GraphController)2 WorkspaceInformation (org.gephi.project.api.WorkspaceInformation)2 WorkspaceProviderImpl (org.gephi.project.impl.WorkspaceProviderImpl)2 WorkspaceBytesPersistenceProvider (org.gephi.project.spi.WorkspaceBytesPersistenceProvider)2 WorkspacePersistenceProvider (org.gephi.project.spi.WorkspacePersistenceProvider)2 WorkspaceXMLPersistenceProvider (org.gephi.project.spi.WorkspaceXMLPersistenceProvider)2 DialogDescriptor (org.openide.DialogDescriptor)2 BorderLayout (java.awt.BorderLayout)1 ActionEvent (java.awt.event.ActionEvent)1