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;
}