Search in sources :

Example 1 with BlueProjectManager

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);
    });
}
Also used : BlueProjectManager(blue.projects.BlueProjectManager) BlueProject(blue.projects.BlueProject)

Example 2 with BlueProjectManager

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;
}
Also used : BlueProjectManager(blue.projects.BlueProjectManager) BlueProject(blue.projects.BlueProject) JComponent(javax.swing.JComponent) JMenuItem(javax.swing.JMenuItem) File(java.io.File)

Example 3 with BlueProjectManager

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);
    }
}
Also used : BlueProjectManager(blue.projects.BlueProjectManager)

Example 4 with BlueProjectManager

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);
}
Also used : BlueProjectManager(blue.projects.BlueProjectManager) BlueProject(blue.projects.BlueProject)

Example 5 with BlueProjectManager

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);
        }
    }
}
Also used : BlueProjectManager(blue.projects.BlueProjectManager) BlueProject(blue.projects.BlueProject) File(java.io.File)

Aggregations

BlueProjectManager (blue.projects.BlueProjectManager)5 BlueProject (blue.projects.BlueProject)4 File (java.io.File)2 JComponent (javax.swing.JComponent)1 JMenuItem (javax.swing.JMenuItem)1