use of org.gephi.project.api.Project in project gephi by gephi.
the class ProjectControllerImpl method deleteWorkspace.
@Override
public void deleteWorkspace(Workspace workspace) {
Project project = workspace.getProject();
WorkspaceProviderImpl workspaceProvider = project.getLookup().lookup(WorkspaceProviderImpl.class);
Workspace toSelectWorkspace = null;
if (getCurrentWorkspace() == workspace) {
toSelectWorkspace = workspaceProvider.getPrecedingWorkspace(workspace);
}
workspaceProvider.removeWorkspace(workspace);
//Event
fireWorkspaceEvent(EventType.CLOSE, workspace);
if (getCurrentWorkspace() == workspace) {
//Select the one before, or after
if (toSelectWorkspace == null) {
closeCurrentProject();
} else {
openWorkspace(toSelectWorkspace);
}
}
}
use of org.gephi.project.api.Project in project gephi by gephi.
the class ProjectControllerUIImpl method saveAsProject.
@Override
public void saveAsProject() {
final String LAST_PATH = "SaveAsProject_Last_Path";
final String LAST_PATH_DEFAULT = "SaveAsProject_Last_Path_Default";
DialogFileFilter filter = new DialogFileFilter(NbBundle.getMessage(ProjectControllerUIImpl.class, "SaveAsProject_filechooser_filter"));
filter.addExtension(".gephi");
//Get last directory
String lastPathDefault = NbPreferences.forModule(ProjectControllerUIImpl.class).get(LAST_PATH_DEFAULT, null);
String lastPath = NbPreferences.forModule(ProjectControllerUIImpl.class).get(LAST_PATH, lastPathDefault);
//File chooser
final JFileChooser chooser = new JFileChooser(lastPath);
chooser.addChoosableFileFilter(filter);
int returnFile = chooser.showSaveDialog(null);
if (returnFile == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
//Save last path
NbPreferences.forModule(ProjectControllerUIImpl.class).put(LAST_PATH, file.getAbsolutePath());
//File management
try {
if (!file.getPath().endsWith(".gephi")) {
file = new File(file.getPath() + ".gephi");
}
if (!file.exists()) {
if (!file.createNewFile()) {
String failMsg = NbBundle.getMessage(ProjectControllerUIImpl.class, "SaveAsProject_SaveFailed", new Object[] { file.getPath() });
JOptionPane.showMessageDialog(null, failMsg);
return;
}
} else {
String overwriteMsg = NbBundle.getMessage(ProjectControllerUIImpl.class, "SaveAsProject_Overwrite", new Object[] { file.getPath() });
if (JOptionPane.showConfirmDialog(null, overwriteMsg) != JOptionPane.OK_OPTION) {
return;
}
}
file = FileUtil.normalizeFile(file);
final String SaveAsFileName = file.getName();
//File exist now, Save project
Project project = controller.getCurrentProject();
saveProject(project, file);
//Modifying Title bar
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = (JFrame) WindowManager.getDefault().getMainWindow();
String title = frame.getTitle();
title = title.substring(0, title.indexOf(" - ")) + " - " + SaveAsFileName;
frame.setTitle(title);
}
});
} catch (Exception e) {
Logger.getLogger("").log(Level.WARNING, "", e);
}
}
}
use of org.gephi.project.api.Project in project gephi by gephi.
the class ProjectControllerUIImpl method newProject.
@Override
public Project newProject() {
if (closeCurrentProject()) {
controller.newProject();
final Project project = controller.getCurrentProject();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = (JFrame) WindowManager.getDefault().getMainWindow();
String title = frame.getTitle() + " - " + project.getLookup().lookup(ProjectInformation.class).getName();
frame.setTitle(title);
}
});
unlockProjectActions();
return project;
}
return null;
}
use of org.gephi.project.api.Project in project gephi by gephi.
the class ProjectControllerUIImpl method projectProperties.
@Override
public void projectProperties() {
Project project = controller.getCurrentProject();
ProjectPropertiesUI ui = Lookup.getDefault().lookup(ProjectPropertiesUI.class);
if (ui != null) {
JPanel panel = ui.getPanel();
ui.setup(project);
DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(ProjectControllerUIImpl.class, "ProjectProperties_dialog_title"));
Object result = DialogDisplayer.getDefault().notify(dd);
if (result == NotifyDescriptor.OK_OPTION) {
ui.unsetup(project);
}
}
}
use of org.gephi.project.api.Project in project gephi by gephi.
the class ProjectControllerUIImpl method saveProject.
@Override
public void saveProject() {
Project project = controller.getCurrentProject();
if (project.getLookup().lookup(ProjectInformation.class).hasFile()) {
File file = project.getLookup().lookup(ProjectInformation.class).getFile();
saveProject(project, file);
} else {
saveAsProject();
}
}
Aggregations