Search in sources :

Example 1 with WorkspaceInformation

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

the class WorkspacePanel method initialize.

// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
@Override
public void initialize(final Workspace workspace) {
    final WorkspaceInformation workspaceInformation = workspace.getLookup().lookup(WorkspaceInformation.class);
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            tabDataModel.addTab(tabDataModel.size(), new TabData(new WorkspaceComponent(workspace), workspaceIcon, workspaceInformation.getName(), workspaceInformation.getSource()));
            if (tabDataModel.size() == 1) {
                tabbedContainer.getSelectionModel().setSelectedIndex(0);
                add(tabbedContainer, BorderLayout.CENTER);
                getParent().revalidate();
            }
        }
    });
}
Also used : WorkspaceInformation(org.gephi.project.api.WorkspaceInformation) TabData(org.netbeans.swing.tabcontrol.TabData)

Example 2 with WorkspaceInformation

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

the class DataTableTopComponent method prepareTableExportFileName.

private String prepareTableExportFileName() {
    String fileName = null;
    ProjectInformation projectInfo = pc.getCurrentProject().getLookup().lookup(ProjectInformation.class);
    if (projectInfo.hasFile()) {
        fileName = removeFileNameExtension(projectInfo.getFileName());
    }
    WorkspaceProvider wp = pc.getCurrentProject().getLookup().lookup(WorkspaceProvider.class);
    if (wp.getWorkspaces().length > 1 || fileName == null) {
        if (fileName != null) {
            fileName += " - ";
        } else {
            fileName = "";
        }
        WorkspaceInformation workspaceInfo = pc.getCurrentWorkspace().getLookup().lookup(WorkspaceInformation.class);
        if (workspaceInfo.hasSource()) {
            fileName += removeFileNameExtension(workspaceInfo.getSource());
        } else {
            fileName += workspaceInfo.getName();
        }
    }
    return fileName;
}
Also used : WorkspaceInformation(org.gephi.project.api.WorkspaceInformation) WorkspaceProvider(org.gephi.project.api.WorkspaceProvider) ProjectInformation(org.gephi.project.api.ProjectInformation)

Example 3 with WorkspaceInformation

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

the class GephiWriter method writeWorkspace.

public static void writeWorkspace(XMLStreamWriter writer, Workspace workspace) throws Exception {
    writer.writeStartDocument("UTF-8", "1.0");
    writer.writeStartElement("workspace");
    WorkspaceInformation info = workspace.getLookup().lookup(WorkspaceInformation.class);
    writer.writeAttribute("name", info.getName());
    writer.writeAttribute("id", String.valueOf(workspace.getId()));
    if (info.isOpen()) {
        writer.writeAttribute("status", "open");
    } else if (info.isClosed()) {
        writer.writeAttribute("status", "closed");
    } else {
        writer.writeAttribute("status", "invalid");
    }
    writer.writeEndElement();
    writer.writeEndDocument();
}
Also used : WorkspaceInformation(org.gephi.project.api.WorkspaceInformation)

Example 4 with WorkspaceInformation

use of org.gephi.project.api.WorkspaceInformation 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 5 with WorkspaceInformation

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

the class WorkspacePanel method propertyChange.

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals(WorkspaceInformation.EVENT_RENAME)) {
        final WorkspaceInformation workspaceInformation = (WorkspaceInformation) evt.getSource();
        final int index = tabbedContainer.getSelectionModel().getSelectedIndex();
        if (!tabDataModel.getTab(index).getText().equals(workspaceInformation.getName())) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    tabbedContainer.setTitleAt(index, workspaceInformation.getName());
                }
            });
        }
    } else if (evt.getPropertyName().equals(WorkspaceInformation.EVENT_SET_SOURCE)) {
        final WorkspaceInformation workspaceInformation = (WorkspaceInformation) evt.getSource();
        final int index = tabbedContainer.getSelectionModel().getSelectedIndex();
        if (tabDataModel.getTab(index).getTooltip() == null || !tabDataModel.getTab(index).getTooltip().equals(workspaceInformation.getSource())) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    tabbedContainer.setToolTipTextAt(index, workspaceInformation.getSource());
                }
            });
        }
    }
}
Also used : WorkspaceInformation(org.gephi.project.api.WorkspaceInformation)

Aggregations

WorkspaceInformation (org.gephi.project.api.WorkspaceInformation)5 WorkspaceProvider (org.gephi.project.api.WorkspaceProvider)2 TabData (org.netbeans.swing.tabcontrol.TabData)2 ProjectController (org.gephi.project.api.ProjectController)1 ProjectInformation (org.gephi.project.api.ProjectInformation)1 Workspace (org.gephi.project.api.Workspace)1