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;
}
}
Aggregations