Search in sources :

Example 16 with Workspace

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());
    }
}
Also used : Workspace(org.gephi.project.api.Workspace)

Example 17 with Workspace

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;
}
Also used : WorkspaceDuplicateProvider(org.gephi.project.spi.WorkspaceDuplicateProvider) Workspace(org.gephi.project.api.Workspace)

Example 18 with Workspace

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);
    }
}
Also used : WorkspaceInformation(org.gephi.project.api.WorkspaceInformation) WorkspaceProvider(org.gephi.project.api.WorkspaceProvider) TabData(org.netbeans.swing.tabcontrol.TabData) ProjectController(org.gephi.project.api.ProjectController) Workspace(org.gephi.project.api.Workspace)

Example 19 with Workspace

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();
    }
}
Also used : SelectionManager(org.gephi.visualization.api.selection.SelectionManager) CompatibilityEngine(org.gephi.visualization.opengl.CompatibilityEngine) TextManager(org.gephi.visualization.text.TextManager) StandardVizEventManager(org.gephi.visualization.events.StandardVizEventManager) CompatibilityScheduler(org.gephi.visualization.scheduler.CompatibilityScheduler) ProjectController(org.gephi.project.api.ProjectController) WorkspaceListener(org.gephi.project.api.WorkspaceListener) StandardGraphIO(org.gephi.visualization.swing.StandardGraphIO) ScreenshotMaker(org.gephi.visualization.screenshot.ScreenshotMaker) VizConfig(org.gephi.visualization.apiimpl.VizConfig) DataBridge(org.gephi.visualization.bridge.DataBridge) Workspace(org.gephi.project.api.Workspace)

Example 20 with Workspace

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;
    }
}
Also used : GraphContextMenuItem(org.gephi.visualization.spi.GraphContextMenuItem) WorkspaceProvider(org.gephi.project.api.WorkspaceProvider) ArrayList(java.util.ArrayList) ProjectController(org.gephi.project.api.ProjectController) 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