use of org.gephi.project.api.Workspace in project gephi-plugins-bootcamp by gephi.
the class SQLiteDatabaseExporterUI method action.
@Override
public void action() {
//Create exporter
final SQLiteDatabaseExporter exporter = new SQLiteDatabaseExporter();
//Create the settings panel
SQLiteDatabaseSettingsPanel settingPanel = new SQLiteDatabaseSettingsPanel();
settingPanel.setup(exporter);
final DialogDescriptor dd = new DialogDescriptor(settingPanel, "SQLite Database Export");
Object result = DialogDisplayer.getDefault().notify(dd);
if (result == NotifyDescriptor.OK_OPTION) {
//This line will write the file path from the panel to the exporter's <code>setPath()<code> method.
settingPanel.unsetup(true);
//Create a new executor and execute
LongTaskExecutor executor = new LongTaskExecutor(true, "SQLite Exporter");
executor.setDefaultErrorHandler(errorHandler);
executor.execute(exporter, new Runnable() {
@Override
public void run() {
//Get the current workspace and set it to the exporter
Workspace currentWorkspace = Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace();
exporter.setWorkspace(currentWorkspace);
//Execute export
cancelled = !exporter.execute();
//If not cancelled, write a status line message
if (!cancelled) {
StatusDisplayer.getDefault().setStatusText("Export to SQLite database completed");
}
}
});
} else {
settingPanel.unsetup(false);
}
}
use of org.gephi.project.api.Workspace 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.Workspace 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.Workspace in project gephi by gephi.
the class ExportControllerImpl method exportStream.
@Override
public void exportStream(OutputStream stream, ByteExporter byteExporter) {
if (byteExporter.getWorkspace() == null) {
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
Workspace workspace = projectController.getCurrentWorkspace();
byteExporter.setWorkspace(workspace);
}
byteExporter.setOutputStream(stream);
try {
byteExporter.execute();
} catch (Exception ex) {
try {
stream.flush();
stream.close();
} catch (IOException exe) {
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
try {
stream.flush();
stream.close();
} catch (IOException ex) {
}
}
use of org.gephi.project.api.Workspace in project gephi by gephi.
the class ExportControllerImpl method exportWriter.
@Override
public void exportWriter(Writer writer, CharacterExporter characterExporter) {
if (characterExporter.getWorkspace() == null) {
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
Workspace workspace = projectController.getCurrentWorkspace();
characterExporter.setWorkspace(workspace);
}
characterExporter.setWriter(writer);
try {
characterExporter.execute();
} catch (Exception ex) {
try {
writer.flush();
writer.close();
} catch (IOException exe) {
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
try {
writer.flush();
writer.close();
} catch (IOException ex) {
}
}
Aggregations