use of blue.projects.BlueProjectManager in project blue by kunstmusik.
the class Installer method setWindowTitle.
private void setWindowTitle() {
BlueProjectManager bpm = BlueProjectManager.getInstance();
BlueProject proj = bpm.getCurrentProject();
String title = "blue - " + BlueConstants.getVersion();
if (proj != null) {
title += " - ";
if (proj.getDataFile() == null) {
title += "New Project";
} else {
title += proj.getDataFile().getName();
}
}
final String t = title;
SwingUtilities.invokeLater(() -> {
WindowManager.getDefault().getMainWindow().setTitle(t);
});
}
use of blue.projects.BlueProjectManager in project blue by kunstmusik.
the class CurrentProjectsAction method getMenuPresenters.
@Override
public JComponent[] getMenuPresenters() {
BlueProjectManager manager = BlueProjectManager.getInstance();
if (manager.getNumProjects() == 0) {
return new JComponent[0];
}
JComponent[] items = new JComponent[manager.getNumProjects()];
for (int i = 0; i < manager.getNumProjects(); i++) {
BlueProject proj = manager.getProject(i);
File f = proj.getDataFile();
String name = (f == null) ? "[new blue project]" : f.getName();
JMenuItem menuItem = new JMenuItem(i + " " + name);
menuItem.putClientProperty("project", proj);
menuItem.setMnemonic(Integer.toString(i).charAt(0));
menuItem.setEnabled(proj != manager.getCurrentProject());
menuItem.addActionListener(al);
items[i] = menuItem;
}
return items;
}
use of blue.projects.BlueProjectManager in project blue by kunstmusik.
the class Installer method restored.
@Override
public void restored() {
final BlueProjectManager instance = BlueProjectManager.getInstance();
instance.addPropertyChangeListener(projectListener);
if (instance.getCurrentProject() != projectListener.currentProject) {
projectListener.currentProject = instance.getCurrentProject();
projectListener.attachListeners(projectListener.currentProject);
}
}
use of blue.projects.BlueProjectManager in project blue by kunstmusik.
the class NewProjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
final BlueProjectManager blueProjectManager = BlueProjectManager.getInstance();
BlueProject project = BlueProjectManager.createNewProject();
blueProjectManager.setCurrentProject(project);
}
use of blue.projects.BlueProjectManager in project blue by kunstmusik.
the class TempFileCleaner method propertyChange.
@Override
public void propertyChange(PropertyChangeEvent evt) {
BlueProjectManager bpm = BlueProjectManager.getInstance();
BlueProject currentProject = bpm.getCurrentProject();
if (currentProject.isTempCsdFilesChecked()) {
return;
}
currentProject.setTempCsdFilesChecked(true);
File curProjFile = currentProject.getDataFile();
if (curProjFile == null) {
return;
}
File parentProjDir = curProjFile.getParentFile();
int size = bpm.getNumProjects();
boolean otherOpenProjectsFound = false;
for (int i = 0; i < size; i++) {
BlueProject project = bpm.getProject(i);
if (project != currentProject) {
if (project.getDataFile() != null) {
File parentDir = project.getDataFile().getParentFile();
if (parentDir.equals(parentProjDir)) {
otherOpenProjectsFound = true;
break;
}
}
}
}
if (otherOpenProjectsFound) {
return;
}
File[] tempFiles = parentProjDir.listFiles((File dir, String name) -> name.startsWith("tempCsd") && name.endsWith(".csd"));
if (tempFiles.length > 0) {
int retVal = JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(), "Temporary CSD files were found. These are " + "probably from a previous Blue session that crashed. Would you like to " + "delete these?", "Temp CSD Files Found", JOptionPane.YES_NO_OPTION);
if (retVal == JOptionPane.YES_OPTION) {
deleteTempFiles(tempFiles);
}
}
}
Aggregations