use of com.joliciel.jochre.doc.DocumentDao in project jochre by urieli.
the class JochreImage method getPage.
/**
* The page containing this image (in multi-page documents).
*/
public JochrePage getPage() {
if (this.page == null && this.pageId != 0) {
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
this.page = documentDao.loadJochrePage(this.pageId);
}
return page;
}
use of com.joliciel.jochre.doc.DocumentDao in project jochre by urieli.
the class UpdateDocumentController method doAfterCompose.
@Override
public void doAfterCompose(Window window) throws Exception {
super.doAfterCompose(window);
Session session = Sessions.getCurrent();
User user = (User) session.getAttribute(LoginController.SESSION_JOCHRE_USER);
if (user == null)
Executions.sendRedirect("login.zul");
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
List<Author> authors = documentDao.findAuthors();
List<Comboitem> authorItems = cmbAuthors.getItems();
for (Author author : authors) {
Comboitem item = new Comboitem(author.getFullName());
item.setValue(author.getId());
authorItems.add(item);
}
lstAuthors.setItemRenderer(new AuthorListItemRenderer());
winUpdateDocument.addEventListener("onModalOpen", new UpdateDocumentControllerModalListener());
}
use of com.joliciel.jochre.doc.DocumentDao in project jochre by urieli.
the class UpdateDocumentController method onClick$btnAddNewAuthor.
@Listen("onClick = #btnAddNewAuthor")
public void onClick$btnAddNewAuthor(Event event) {
LOG.debug("onClick$btnAddNewAuthor");
try {
Author author = currentAuthor;
boolean isNew = false;
if (author == null) {
author = new Author(jochreSession);
isNew = true;
}
author.setFirstName(txtAuthorFirstName.getValue());
author.setLastName(txtAuthorLastName.getValue());
author.setFirstNameLocal(txtAuthorFirstNameLocal.getValue());
author.setLastNameLocal(txtAuthorLastNameLocal.getValue());
author.save();
currentAuthor = null;
txtAuthorFirstName.setValue("");
txtAuthorLastName.setValue("");
txtAuthorFirstNameLocal.setValue("");
txtAuthorLastNameLocal.setValue("");
btnAddNewAuthor.setLabel(Labels.getLabel("docs.documentDetails.addAuthor"));
if (isNew) {
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
List<Author> authors = documentDao.findAuthors();
List<Comboitem> authorItems = cmbAuthors.getItems();
authorItems.clear();
for (Author oneAuthor : authors) {
Comboitem item = new Comboitem(oneAuthor.getFullName());
item.setValue(oneAuthor.getId());
authorItems.add(item);
if (oneAuthor.getId() == author.getId())
cmbAuthors.setSelectedItem(item);
}
} else {
ListModelList<Author> model = new ListModelList<Author>(this.currentDoc.getAuthors(), true);
lstAuthors.setModel(model);
}
} catch (Exception e) {
LOG.error("Failure in onClick$btnAddNewAuthor", e);
throw new RuntimeException(e);
}
}
use of com.joliciel.jochre.doc.DocumentDao in project jochre by urieli.
the class DocumentController method getDocumentTree.
public TreeModel<TreeNode<DocOrImage>> getDocumentTree() {
LOG.debug("getDocumentTree2");
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
List<JochreDocument> docs = documentDao.findDocuments();
List<TreeNode<DocOrImage>> docNodeList = new ArrayList<>();
for (JochreDocument doc : docs) {
List<TreeNode<DocOrImage>> imageNodeList = new ArrayList<>();
for (JochrePage page : doc.getPages()) {
LOG.debug("page " + page.getIndex());
for (JochreImage image : page.getImages()) {
DefaultTreeNode<DocOrImage> imageNode = new DefaultTreeNode<DocumentController.DocOrImage>(new DocOrImage(image));
imageNodeList.add(imageNode);
if (imageId == image.getId())
currentImage = image;
}
// have images?
}
boolean open = docId == doc.getId();
if (open)
currentDoc = doc;
DefaultTreeNode<DocOrImage> docNode = new DirectoryTreeNode<DocumentController.DocOrImage>(new DocOrImage(doc), imageNodeList, open);
docNodeList.add(docNode);
}
DefaultTreeNode<DocOrImage> root = new DefaultTreeNode<DocumentController.DocOrImage>(null, docNodeList);
TreeModel<TreeNode<DocOrImage>> docTree = new DefaultTreeModel<>(root);
this.reloadDoc();
this.reloadImage();
return docTree;
}
use of com.joliciel.jochre.doc.DocumentDao in project jochre by urieli.
the class TextController method doAfterCompose.
@Override
public void doAfterCompose(Window window) throws Exception {
try {
super.doAfterCompose(window);
Session session = Sessions.getCurrent();
currentUser = (User) session.getAttribute(LoginController.SESSION_JOCHRE_USER);
if (currentUser == null)
Executions.sendRedirect("login.zul");
HttpServletRequest request = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
if (request.getParameter("imageId") != null) {
int imageId = Integer.parseInt(request.getParameter("imageId"));
GraphicsDao graphicsDao = GraphicsDao.getInstance(jochreSession);
currentImage = graphicsDao.loadJochreImage(imageId);
currentDoc = currentImage.getPage().getDocument();
uploadPanel.setVisible(false);
progressBox.setVisible(true);
startRenderTimer.setRunning(true);
} else if (request.getParameter("docId") != null) {
int docId = Integer.parseInt(request.getParameter("docId"));
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
currentDoc = documentDao.loadJochreDocument(docId);
if (request.getParameter("addPages") != null) {
uploadPanel.setVisible(true);
// progressBox.setVisible(false);
lblAwaitingFile.setVisible(true);
} else {
uploadPanel.setVisible(false);
progressBox.setVisible(true);
startRenderTimer.setRunning(true);
}
} else {
uploadPanel.setVisible(true);
// progressBox.setVisible(false);
lblAwaitingFile.setVisible(true);
}
if (currentDoc != null && !currentDoc.isLeftToRight())
htmlContent.setSclass("rightToLeft");
if (currentDoc != null) {
documentGrid.setVisible(true);
lblDocName.setValue(currentDoc.getName());
}
} catch (Exception e) {
LOG.error("Failure in TextController$doAfterCompose", e);
throw new RuntimeException(e);
}
}
Aggregations