use of org.antlr.xjlib.appkit.document.XJDocument 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;
}
}
use of org.antlr.xjlib.appkit.document.XJDocument 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);
}
use of org.antlr.xjlib.appkit.document.XJDocument 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;
}
use of org.antlr.xjlib.appkit.document.XJDocument in project antlrworks by antlr.
the class XJApplication method openDocument.
public boolean openDocument(String file) {
if (file == null)
return false;
// application in the didRun method (see above).
if (startingUp) {
documentsToOpenAtStartup.add(file);
return true;
}
XJWindow window = getWindowContainingDocumentForPath(file);
if (window != null) {
window.selectDocument(window.getDocumentForPath(file));
window.bringToFront();
return true;
} else {
XJDocument document = newDocument(false, getDocumentTypeForPath(file));
if (document == null)
return false;
else if (loadDocument(file, document)) {
addRecentFile(file);
document.showWindow();
closeFirstCreatedWindowIfNonDirty(document.getWindow());
return true;
} else {
document.getWindow().performClose(true);
return false;
}
}
}
use of org.antlr.xjlib.appkit.document.XJDocument in project antlrworks by antlr.
the class XJWindow method reloadDocuments.
public void reloadDocuments() {
for (XJDocument doc : documents) {
if (doc.isModifiedOnDisk()) {
windowDocumentPathDidChange(doc);
doc.synchronizeLastModifiedDate();
}
}
}
Aggregations