Search in sources :

Example 1 with XJWindow

use of org.antlr.xjlib.appkit.frame.XJWindow in project antlrworks by antlr.

the class XJMainMenuBar method handleMenuEvent.

public void handleMenuEvent(XJMenu menu, XJMenuItem item) {
    //XJDocument document = XJApplication.shared().getActiveDocument();
    XJWindow activeWindow = XJApplication.shared().getActiveWindow();
    switch(item.tag) {
        case MI_NEW:
            XJApplication.shared().newDocument();
            break;
        case MI_OPEN:
            XJApplication.shared().openDocument();
            break;
        case MI_SAVE:
            if (activeWindow != null) {
                for (XJDocument doc : activeWindow.getDocuments()) {
                    if (doc.save(false)) {
                        doc.changeReset();
                    }
                }
            }
            break;
        case MI_SAVEAS:
            if (activeWindow != null) {
                for (XJDocument doc : activeWindow.getDocuments()) {
                    if (doc.save(true)) {
                        doc.changeReset();
                    }
                }
            }
            break;
        case MI_CLEAR_RECENT_FILES:
            XJApplication.shared().clearRecentFiles();
            break;
        case MI_QUIT:
            XJApplication.shared().performQuit();
            break;
        case MI_PREFS:
            XJApplication.shared().displayPrefs();
            break;
        case MI_ABOUT:
            XJApplication.shared().displayAbout();
            break;
        case MI_HELP:
            XJApplication.shared().displayHelp();
            break;
        case MI_GC:
            System.gc();
            break;
        default:
            if (item.tag >= MI_WINDOW) {
                XJWindow window = XJApplication.shared().getWindowsInWindowMenu().get(item.tag - MI_WINDOW);
                window.bringToFront();
                item.setSelected(true);
            } else if (item.tag >= MI_RECENT_FILES && item.tag <= MI_RECENT_FILES + XJApplication.MAX_RECENT_FILES) {
                if (!XJApplication.shared().openDocument(item.getTitle())) {
                    XJApplication.shared().removeRecentFile(item.getTitle());
                }
            } else if (delegate != null)
                delegate.handleMenuEvent(menu, item);
            break;
    }
}
Also used : XJDocument(org.antlr.xjlib.appkit.document.XJDocument) XJWindow(org.antlr.xjlib.appkit.frame.XJWindow)

Example 2 with XJWindow

use of org.antlr.xjlib.appkit.frame.XJWindow in project antlrworks by antlr.

the class XJMainMenuBar method buildWindowMenu_.

private void buildWindowMenu_() {
    Iterator iterator = XJApplication.shared().getWindows().iterator();
    int count = 0;
    while (iterator.hasNext()) {
        XJWindow window = (XJWindow) iterator.next();
        if (window.shouldAppearsInWindowMenu()) {
            XJMenuItemCheck item = buildMenuItemCheck(window.getTitle(), count < 10 ? KeyEvent.VK_0 + count : -1, MI_WINDOW + count);
            item.setSelected(window.isActive());
            menuWindow.addItem(item);
            count++;
        }
    }
    if (count == 0) {
        XJMenuItem item = new XJMenuItem(XJLocalizable.getXJString("NoWindows"), MI_NO_WINDOW, null);
        item.setEnabled(false);
        menuWindow.addItem(item);
    }
}
Also used : XJWindow(org.antlr.xjlib.appkit.frame.XJWindow) Iterator(java.util.Iterator)

Example 3 with XJWindow

use of org.antlr.xjlib.appkit.frame.XJWindow in project antlrworks by antlr.

the class XJApplication method performQuit.

public void performQuit() {
    delegate.appWillTerminate();
    for (XJWindow window : new ArrayList<XJWindow>(windows)) {
        if (!window.performClose(false)) {
            // cancel quit if any document cannot or don't want to be closed
            return;
        }
    }
    XJFrame.closeDesktop();
    shutdown();
}
Also used : XJWindow(org.antlr.xjlib.appkit.frame.XJWindow) ArrayList(java.util.ArrayList)

Example 4 with XJWindow

use of org.antlr.xjlib.appkit.frame.XJWindow in project antlrworks by antlr.

the class IDE method rememberAllOpenedDocuments.

private void rememberAllOpenedDocuments() {
    final List<String> docPath = new ArrayList<String>();
    for (XJWindow window : XJApplication.shared().getWindows()) {
        final XJDocument document = window.getDocument();
        if (XJApplication.handlesDocument(document)) {
            docPath.add(document.getDocumentPath());
        }
    }
    AWPrefs.setAllOpenedDocuments(docPath);
}
Also used : XJDocument(org.antlr.xjlib.appkit.document.XJDocument) XJWindow(org.antlr.xjlib.appkit.frame.XJWindow) ArrayList(java.util.ArrayList)

Example 5 with XJWindow

use of org.antlr.xjlib.appkit.frame.XJWindow in project antlrworks by antlr.

the class XJApplication method newDocument.

public XJDocument newDocument(boolean visible, XJDocumentFactory docFactory) {
    if (documentFactories.size() == 0) {
        XJAlert.display(null, XJLocalizable.getXJString("AppNewDocErrTitle"), XJLocalizable.getXJString("AppNewDocErrMessage"));
        return null;
    }
    if (docFactory == null) {
        docFactory = askForDocumentType();
        if (docFactory == null)
            return null;
    }
    XJDocument document;
    try {
        document = docFactory.createDocument();
        document.awake();
        if (supportsPersistence())
            document.setTitle(XJLocalizable.getXJString("AppUntitled") + " " + documentAbsoluteCount);
        else
            document.setTitle(documentAbsoluteCount > 0 ? appName + " " + documentAbsoluteCount : appName);
        XJWindow window = document.getWindow();
        if (!window.isMaximized() && useDesktopMode()) {
            documentAbsoluteCount++;
            window.offsetPosition(documentAbsPositionCount * DOCUMENT_OFFSET_PIXELS, documentAbsPositionCount * DOCUMENT_OFFSET_PIXELS);
            if (window.isCompletelyOnScreen())
                documentAbsPositionCount++;
            else
                documentAbsPositionCount = 0;
        }
    } catch (Exception e) {
        e.printStackTrace();
        XJAlert.display(null, XJLocalizable.getXJString("AppNewDocError"), e.toString());
        return null;
    }
    if (visible) {
        document.showWindow();
    }
    return document;
}
Also used : XJDocument(org.antlr.xjlib.appkit.document.XJDocument) XJWindow(org.antlr.xjlib.appkit.frame.XJWindow)

Aggregations

XJWindow (org.antlr.xjlib.appkit.frame.XJWindow)7 XJDocument (org.antlr.xjlib.appkit.document.XJDocument)4 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)1