Search in sources :

Example 1 with StringPref

use of edu.mit.csail.sdg.alloy4.A4Preferences.StringPref in project org.alloytools.alloy by AlloyTools.

the class SimpleGUI method doRefreshFile.

// ===============================================================================================================//
/**
 * This method refreshes the "file" menu.
 */
private Runner doRefreshFile() {
    if (wrap)
        return wrapMe();
    try {
        wrap = true;
        filemenu.removeAll();
        menuItem(filemenu, "New", 'N', 'N', doNew());
        menuItem(filemenu, "Open...", 'O', 'O', doOpen());
        if (!Util.onMac())
            menuItem(filemenu, "Open Sample Models...", VK_ALT, 'O', doBuiltin());
        else
            menuItem(filemenu, "Open Sample Models...", doBuiltin());
        JMenu recentmenu;
        filemenu.add(recentmenu = new JMenu("Open Recent"));
        menuItem(filemenu, "Reload all", 'R', 'R', doReloadAll());
        menuItem(filemenu, "Save", 'S', 'S', doSave());
        if (Util.onMac())
            menuItem(filemenu, "Save As...", VK_SHIFT, 'S', doSaveAs());
        else
            menuItem(filemenu, "Save As...", 'A', doSaveAs());
        menuItem(filemenu, "Close", 'W', 'W', doClose());
        menuItem(filemenu, "Clear Temporary Directory", doClearTemp());
        menuItem(filemenu, "Quit", 'Q', (Util.onMac() ? -1 : 'Q'), doQuit());
        boolean found = false;
        for (StringPref p : new StringPref[] { Model0, Model1, Model2, Model3 }) {
            String name = p.get();
            if (name.length() > 0) {
                found = true;
                menuItem(recentmenu, name, doOpenFile(name));
            }
        }
        recentmenu.addSeparator();
        menuItem(recentmenu, "Clear Menu", doClearRecent());
        recentmenu.setEnabled(found);
    } finally {
        wrap = false;
    }
    return null;
}
Also used : StringPref(edu.mit.csail.sdg.alloy4.A4Preferences.StringPref) JMenu(javax.swing.JMenu)

Aggregations

StringPref (edu.mit.csail.sdg.alloy4.A4Preferences.StringPref)1 JMenu (javax.swing.JMenu)1