use of com.joliciel.jochre.doc.Author in project jochre by urieli.
the class UpdateDocumentController method onClick$btnDeleteAuthor.
@Listen("onClick = #btnDeleteAuthor")
public void onClick$btnDeleteAuthor(Event event) {
LOG.debug("onClick$btnDeleteAuthor()");
try {
if (lstAuthors.getSelectedItem() == null) {
return;
}
Author author = (Author) lstAuthors.getSelectedItem().getValue();
this.currentDoc.getAuthors().remove(author);
ListModelList<Author> model = new ListModelList<Author>(this.currentDoc.getAuthors(), true);
lstAuthors.setModel(model);
} catch (Exception e) {
LOG.error("Failure in onClick$btnDeleteAuthor", e);
throw new RuntimeException(e);
}
}
use of com.joliciel.jochre.doc.Author 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.Author 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.Author in project jochre by urieli.
the class DocumentController method doAfterCompose.
@Override
public void doAfterCompose(Window window) throws Exception {
LOG.debug("doAfterCompose");
super.doAfterCompose(window);
String pageTitle = Labels.getLabel("docs.title");
winJochreHome.getPage().setTitle(pageTitle);
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();
String docIdStr = request.getParameter("docId");
if (docIdStr != null)
docId = Integer.parseInt(docIdStr);
String imageIdStr = request.getParameter("imageId");
if (imageIdStr != null)
imageId = Integer.parseInt(imageIdStr);
docTree.setModel(this.getDocumentTree());
lstAuthors.setModel(new ListModelArray<Author>(new Author[] {}, true));
lstAuthors.setItemRenderer(new AuthorListItemRenderer());
}
use of com.joliciel.jochre.doc.Author in project jochre by urieli.
the class UpdateDocumentController method onClick$btnAddAuthor.
@Listen("onClick = #btnAddAuthor")
public void onClick$btnAddAuthor(Event event) {
LOG.debug("onClick$btnAddAuthor");
try {
int authorId = 0;
Comboitem selectedItem = cmbAuthors.getSelectedItem();
if (selectedItem != null)
authorId = (Integer) selectedItem.getValue();
if (authorId != 0) {
LOG.debug("authorId: " + authorId);
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
Author author = documentDao.loadAuthor(authorId);
if (!this.currentDoc.getAuthors().contains(author)) {
this.currentDoc.getAuthors().add(author);
ListModelList<Author> model = new ListModelList<Author>(this.currentDoc.getAuthors(), true);
lstAuthors.setModel(model);
}
}
} catch (Exception e) {
LOG.error("Failure in onClick$btnAddAuthor", e);
throw new RuntimeException(e);
}
}
Aggregations