use of org.gephi.project.api.WorkspaceListener in project gephi by gephi.
the class GraphTopComponent method initToolPanels.
private void initToolPanels() {
final ToolController tc = Lookup.getDefault().lookup(ToolController.class);
if (tc != null) {
if (VizController.getInstance().getVizConfig().isToolbar()) {
JPanel westPanel = new JPanel(new BorderLayout(0, 0));
if (UIUtils.isAquaLookAndFeel()) {
westPanel.setBackground(UIManager.getColor("NbExplorerView.background"));
}
toolbar = tc.getToolbar();
if (toolbar != null) {
westPanel.add(toolbar, BorderLayout.CENTER);
}
selectionToolbar = new SelectionToolbar();
actionsToolbar = new ActionsToolbar();
westPanel.add(selectionToolbar, BorderLayout.NORTH);
westPanel.add(actionsToolbar, BorderLayout.SOUTH);
add(westPanel, BorderLayout.WEST);
}
if (VizController.getInstance().getVizConfig().isPropertiesbar()) {
propertiesBar = tc.getPropertiesBar();
if (propertiesBar != null) {
add(propertiesBar, BorderLayout.NORTH);
}
}
}
//Workspace events
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
projectController.addWorkspaceListener(new WorkspaceListener() {
@Override
public void initialize(Workspace workspace) {
}
@Override
public void select(Workspace workspace) {
if (toolbar != null) {
toolbar.setEnabled(true);
}
if (propertiesBar != null) {
propertiesBar.setEnabled(true);
}
if (actionsToolbar != null) {
actionsToolbar.setEnabled(true);
}
if (selectionToolbar != null) {
selectionToolbar.setEnabled(true);
}
}
@Override
public void unselect(Workspace workspace) {
}
@Override
public void close(Workspace workspace) {
}
@Override
public void disable() {
if (toolbar != null) {
toolbar.setEnabled(false);
}
if (tc != null) {
//Unselect any selected tool
tc.select(null);
}
if (propertiesBar != null) {
propertiesBar.setEnabled(false);
}
if (actionsToolbar != null) {
actionsToolbar.setEnabled(false);
}
if (selectionToolbar != null) {
selectionToolbar.setEnabled(false);
}
}
});
boolean hasWorkspace = projectController.getCurrentWorkspace() != null;
if (toolbar != null) {
toolbar.setEnabled(hasWorkspace);
}
if (propertiesBar != null) {
propertiesBar.setEnabled(hasWorkspace);
}
if (actionsToolbar != null) {
actionsToolbar.setEnabled(hasWorkspace);
}
if (selectionToolbar != null) {
selectionToolbar.setEnabled(hasWorkspace);
}
}
use of org.gephi.project.api.WorkspaceListener in project gephi by gephi.
the class DataTableTopComponent method initEvents.
private void initEvents() {
//Workspace Listener
pc.addWorkspaceListener(new WorkspaceListener() {
@Override
public void initialize(Workspace workspace) {
//Prepare DataTablesEvent listener
Lookup.getDefault().lookup(DataTablesController.class).setDataTablesEventListener(DataTableTopComponent.this);
if (workspace.getLookup().lookup(DataTablesModel.class) == null) {
workspace.add(new DataTablesModel(workspace));
}
}
@Override
public void select(Workspace workspace) {
activateWorkspace(workspace);
setAutoRefreshEnabled(true);
}
@Override
public void unselect(Workspace workspace) {
deactivateAll();
setAutoRefreshEnabled(false);
}
@Override
public void close(Workspace workspace) {
}
@Override
public void disable() {
clearAll();
//No more workspaces active, disable the DataTablesEvent listener
Lookup.getDefault().lookup(DataTablesController.class).setDataTablesEventListener(null);
setAutoRefreshEnabled(false);
}
});
if (pc.getCurrentWorkspace() != null) {
activateWorkspace(pc.getCurrentWorkspace());
setAutoRefreshEnabled(true);
}
observersTimer = new java.util.Timer("DataLaboratoryGraphObservers");
observersTimer.schedule(new TimerTask() {
@Override
public void run() {
if (!autoRefreshEnabled) {
return;
}
if (dataTablesObservers != null) {
if (dataTablesObservers.hasChanges()) {
//Execute refresh
graphChanged();
}
}
}
}, 0, //Check graph and tables for changes every 100 ms
AUTO_REFRESH_RATE_MILLISECONDS);
//Filter
if (dynamicFiltering) {
filterTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
refreshAppliedFilter();
}
@Override
public void removeUpdate(DocumentEvent e) {
refreshAppliedFilter();
}
@Override
public void changedUpdate(DocumentEvent e) {
}
});
} else {
filterTextField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshAppliedFilter();
}
});
}
columnComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshAppliedFilter();
}
});
initKeyEventContextMenuActionMappings();
}
use of org.gephi.project.api.WorkspaceListener 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();
}
}
Aggregations