Package cx.fbn.nevernote.dialog

Examples of cx.fbn.nevernote.dialog.NotebookEdit


   
  // Add a new notebook
  @SuppressWarnings("unused")
  private void addNotebook() {
    logger.log(logger.HIGH, "Inside NeverNote.addNotebook");
    NotebookEdit edit = new NotebookEdit();
    edit.setNotebooks(listManager.getNotebookIndex());
    edit.exec();
 
    if (!edit.okPressed())
      return;
       
    Calendar currentTime = new GregorianCalendar();
    Long l = new Long(currentTime.getTimeInMillis());
    String randint = new String(Long.toString(l));
 
    Notebook newBook = new Notebook();
    newBook.setUpdateSequenceNum(0);
    newBook.setGuid(randint);
    newBook.setName(edit.getNotebook());
    newBook.setServiceCreated(new Date().getTime());
    newBook.setServiceUpdated(new Date().getTime());
    newBook.setDefaultNotebook(false);
    newBook.setPublished(false);
   
    listManager.getNotebookIndex().add(newBook);
    if (edit.isLocal())
      listManager.getLocalNotebooks().add(newBook.getGuid());
    conn.getNotebookTable().addNotebook(newBook, true, edit.isLocal());
    notebookIndexUpdated();
    listManager.countNotebookResults(listManager.getNoteIndex());
//    notebookTree.updateCounts(listManager.getNotebookIndex(), listManager.getNotebookCounter());
    logger.log(logger.HIGH, "Leaving NeverNote.addNotebook");
  }
View Full Code Here


  }
  // Edit an existing notebook
  @SuppressWarnings("unused")
  private void editNotebook() {
    logger.log(logger.HIGH, "Entering NeverNote.editNotebook");
    NotebookEdit edit = new NotebookEdit();
   
    List<QTreeWidgetItem> selections = notebookTree.selectedItems();
    QTreeWidgetItem currentSelection;
    currentSelection = selections.get(0);
    edit.setNotebook(currentSelection.text(0));
   
    String guid = currentSelection.text(2);
    if (!guid.equalsIgnoreCase("STACK")) {
      edit.setTitle(tr("Edit Notebook"));
      edit.setNotebooks(listManager.getNotebookIndex());
      edit.setLocalCheckboxEnabled(false);
      for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
        if (listManager.getNotebookIndex().get(i).getGuid().equals(guid)) {
          edit.setDefaultNotebook(listManager.getNotebookIndex().get(i).isDefaultNotebook());
          i=listManager.getNotebookIndex().size();
        }
      }
    } else {
      edit.setTitle(tr("Edit Stack"));
      edit.setStacks(conn.getNotebookTable().getAllStackNames());
      edit.hideLocalCheckbox();
      edit.hideDefaultCheckbox();
    }
   
    edit.exec();
 
    if (!edit.okPressed())
      return;
       
   
    if (guid.equalsIgnoreCase("STACK")) {
      conn.getNotebookTable().renameStacks(currentSelection.text(0), edit.getNotebook());
      for (int j=0; j<listManager.getNotebookIndex().size(); j++) {
        if (listManager.getNotebookIndex().get(j).getStack() != null &&
          listManager.getNotebookIndex().get(j).getStack().equalsIgnoreCase(currentSelection.text(0)))
            listManager.getNotebookIndex().get(j).setStack(edit.getNotebook());
      }
      conn.getNotebookTable().renameStacks(currentSelection.text(0), edit.getNotebook());
      currentSelection.setText(0, edit.getNotebook());
      return;
    }
   
    updateListNotebookName(currentSelection.text(0), edit.getNotebook());
    currentSelection.setText(0, edit.getNotebook());
   
    for (int i=0; i<listManager.getNotebookIndex().size(); i++) {
      if (listManager.getNotebookIndex().get(i).getGuid().equals(guid)) {
        listManager.getNotebookIndex().get(i).setName(edit.getNotebook());
        if (!listManager.getNotebookIndex().get(i).isDefaultNotebook() && edit.isDefaultNotebook()) {
          for (int j=0; j<listManager.getNotebookIndex().size(); j++)
            listManager.getNotebookIndex().get(j).setDefaultNotebook(false);
          listManager.getNotebookIndex().get(i).setDefaultNotebook(true);
          conn.getNotebookTable().setDefaultNotebook(listManager.getNotebookIndex().get(i).getGuid());
        }
        conn.getNotebookTable().updateNotebook(listManager.getNotebookIndex().get(i), true);
        if (conn.getNotebookTable().isLinked(listManager.getNotebookIndex().get(i).getGuid())) {
          LinkedNotebook linkedNotebook = conn.getLinkedNotebookTable().getByNotebookGuid(listManager.getNotebookIndex().get(i).getGuid());
          linkedNotebook.setShareName(edit.getNotebook());
          conn.getLinkedNotebookTable().updateNotebook(linkedNotebook, true);
        }
        i=listManager.getNotebookIndex().size();
      }
    }
View Full Code Here

TOP

Related Classes of cx.fbn.nevernote.dialog.NotebookEdit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.