use of org.gephi.project.api.ProjectController in project gephi by gephi.
the class CopyOrMoveToWorkspace method getSubItems.
@Override
public ContextMenuItemManipulator[] getSubItems() {
if (nodes != null) {
int i = 0;
ArrayList<GraphContextMenuItem> subItems = new ArrayList<>();
if (canExecute()) {
//New workspace
subItems.add(new CopyOrMoveToWorkspaceSubItem(null, true, 0, 0, isCopy()));
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
for (final Workspace w : projectController.getCurrentProject().getLookup().lookup(WorkspaceProvider.class).getWorkspaces()) {
GraphContextMenuItem item = new CopyOrMoveToWorkspaceSubItem(w, w != projectController.getCurrentWorkspace(), 1, i, isCopy());
subItems.add(item);
i++;
}
return subItems.toArray(new ContextMenuItemManipulator[0]);
} else {
return null;
}
} else {
return null;
}
}
use of org.gephi.project.api.ProjectController 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