예제 #1
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  @Override
  public void doAfterCompose(Window comp) throws Exception {
    super.doAfterCompose(comp);

    UserCredentialManager mgmt = UserCredentialManager.getIntance();
    NoteUser user = mgmt.getUser();
    StringBuilder sb = new StringBuilder();
    if (user != null) {
      if (user.getFirstName() != null) {
        sb.append(user.getFirstName() + " ");
      }
      if (user.getLastName() != null) {
        sb.append(user.getLastName() + " ");
      }
      sb.append("(" + user.getRole().name() + ")");
      loginUsrName.setValue(sb.toString());
    } else {
      loginUsrName.setValue("Guest");
    }

    /*
     * http://www.zkoss.org/zkdemo/input/wysiwyg_editor
     * http://books.zkoss.org/wiki/ZK_Developer's_Reference/Event_Handling/Event_Queues
     */
    // editor.setCustomConfigurationsPath("/js/ckeditorcfg.js");
    // editor.setToolbar("Full");

    EventQueues.lookup("myqueue1", EventQueues.SESSION, true)
        .subscribe(
            new EventListener() {

              public void onEvent(Event evt) {
                if (!"onTopicInit".equals(evt.getName())) {
                  return;
                }
                TopicItem item = (TopicItem) evt.getData();
                log.info("I've got this!! " + item.getId());

                currentNodeId = item.getId();
                NoteNode node = noteService.findTopic(currentNodeId);
                notePath.setValue(node.getPath());
                editor.setValue(node.getText());
              }
            });

    List<NoteNode> list = noteService.findAllTopicsByUser(user.getId());
    filterbox.setModel(new SimpleListModel(list.toArray()));
  }
예제 #2
0
  /** show content when select an item in tree */
  @Listen("onTopicSelect=#notetreeList")
  public void showTopicContent(Event fe) {

    if (!(fe.getTarget() instanceof NoteTreeList)) {
      return;
    }

    NoteTreeList item = (NoteTreeList) fe.getTarget();
    currentNodeId = item.getCurrentItem().getId();

    NoteNode node = noteService.findTopic(currentNodeId);

    String text = node.getText();
    editor.setValue(text);
    notePath.setValue(node.getPath());
  }
예제 #3
0
  /*
   * http://forum.zkoss.org/question/12670/get-onchanging-value-in-java/
   * Should use InputEvent instead of Event
   *
   * Same effect as: searchBar.addEventListener(Events.ON_CHANGING, new EventListener<Event>() { ...
   */
  @SuppressWarnings({"rawtypes", "unchecked"})
  @Listen("onChanging=#searchBar")
  public void changeSelected(InputEvent fe) {
    String keyword = fe.getValue();

    log.debug(
        "onChanging=#searchBar: oldVal->"
            + ((Bandbox) fe.getTarget()).getValue()
            + " newVal->"
            + keyword);

    // refresh list
    List<NoteNode> list =
        noteService.findMatchedTopicsByUser(
            UserCredentialManager.getIntance().getUser().getId(), keyword);
    filterbox.setModel(new SimpleListModel(list.toArray()));
  }
예제 #4
0
 @Listen("onSave=#editor")
 public void updateEditorContent() {
   String text = editor.getValue();
   noteService.updateTopicText(currentNodeId, text);
   QUtils.showClientInfo("Save successfully!", editor);
 }