use of org.gephi.project.api.Workspace in project gephi by gephi.
the class ProjectControllerImpl method openProject.
public void openProject(Project project) {
final ProjectImpl projectImpl = (ProjectImpl) project;
final ProjectInformationImpl projectInformationImpl = projectImpl.getLookup().lookup(ProjectInformationImpl.class);
final WorkspaceProviderImpl workspaceProviderImpl = project.getLookup().lookup(WorkspaceProviderImpl.class);
if (projects.hasCurrentProject()) {
closeCurrentProject();
}
projects.addProject(projectImpl);
projects.setCurrentProject(projectImpl);
projectInformationImpl.open();
for (Workspace ws : project.getLookup().lookup(WorkspaceProviderImpl.class).getWorkspaces()) {
fireWorkspaceEvent(EventType.INITIALIZE, ws);
}
if (!workspaceProviderImpl.hasCurrentWorkspace()) {
if (workspaceProviderImpl.getWorkspaces().length == 0) {
Workspace workspace = newWorkspace(project);
openWorkspace(workspace);
} else {
Workspace workspace = workspaceProviderImpl.getWorkspaces()[0];
openWorkspace(workspace);
}
} else {
fireWorkspaceEvent(EventType.SELECT, workspaceProviderImpl.getCurrentWorkspace());
}
}
use of org.gephi.project.api.Workspace in project gephi by gephi.
the class ProjectControllerImpl method duplicateWorkspace.
@Override
public Workspace duplicateWorkspace(Workspace workspace) {
if (projects.hasCurrentProject()) {
Workspace duplicate = newWorkspace(projects.getCurrentProject());
for (WorkspaceDuplicateProvider dp : Lookup.getDefault().lookupAll(WorkspaceDuplicateProvider.class)) {
dp.duplicate(workspace, duplicate);
}
openWorkspace(duplicate);
return duplicate;
}
return null;
}
use of org.gephi.project.api.Workspace in project gephi by gephi.
the class WorkspacePanel method refreshModel.
private synchronized void refreshModel() {
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
if (pc.getCurrentProject() != null) {
WorkspaceProvider workspaceProvider = pc.getCurrentProject().getLookup().lookup(WorkspaceProvider.class);
Workspace[] workspaces = workspaceProvider.getWorkspaces();
if (workspaces.length > 0) {
for (Workspace workspace : workspaces) {
int index = tabDataModel.size();
WorkspaceInformation workspaceInformation = workspace.getLookup().lookup(WorkspaceInformation.class);
tabDataModel.addTab(index, new TabData(new WorkspaceComponent(workspace), null, workspaceInformation.getName(), workspaceInformation.getSource()));
if (workspaceProvider.getCurrentWorkspace() == workspace) {
tabbedContainer.getSelectionModel().setSelectedIndex(index);
workspace.getLookup().lookup(WorkspaceInformation.class).addChangeListener(this);
}
}
return;
}
}
// Clear
tabbedContainer.getSelectionModel().clearSelection();
if (tabDataModel.size() > 0) {
tabDataModel.removeTabs(0, tabDataModel.size() - 1);
}
}
use of org.gephi.project.api.Workspace in project gephi by gephi.
the class VizController method initInstances.
public void initInstances() {
vizConfig = new VizConfig();
graphIO = new StandardGraphIO();
engine = new CompatibilityEngine();
vizEventManager = new StandardVizEventManager();
scheduler = new CompatibilityScheduler();
limits = new GraphLimits();
dataBridge = new DataBridge();
textManager = new TextManager();
screenshotMaker = new ScreenshotMaker();
currentModel = new VizModel(true);
selectionManager = new SelectionManager();
if (vizConfig.isUseGLJPanel()) {
//No more supported
} else if (Utilities.isMac()) {
drawable = createCanvas();
} else {
drawable = createNewtCanvas();
}
drawable.initArchitecture();
engine.initArchitecture();
((CompatibilityScheduler) scheduler).initArchitecture();
((StandardGraphIO) graphIO).initArchitecture();
dataBridge.initArchitecture();
textManager.initArchitecture();
screenshotMaker.initArchitecture();
vizEventManager.initArchitecture();
selectionManager.initArchitecture();
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
pc.addWorkspaceListener(new WorkspaceListener() {
@Override
public void initialize(Workspace workspace) {
if (workspace.getLookup().lookup(VizModel.class) == null) {
workspace.add(new VizModel(workspace));
}
}
@Override
public void select(Workspace workspace) {
engine.reinit();
}
@Override
public void unselect(Workspace workspace) {
}
@Override
public void close(Workspace workspace) {
}
@Override
public void disable() {
engine.reinit();
}
});
if (pc.getCurrentWorkspace() != null) {
engine.reinit();
}
}
use of org.gephi.project.api.Workspace 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;
}
}
Aggregations