/**
   * Gets the timestamp for the scene and creates a label on the panel that displays the timestamp
   *
   * @return
   */
  private JLabel addSceneTimeTextToPanel() {
    JLabel label = new JLabel();
    if (scene.hasSceneTs()) {
      DateFormat formatter = I18N.getDateTimeFormatter();
      label.setText(formatter.format(scene.getSceneTs()));
    } else {
      // Add the date of scenes with relative dates to the panel
      if (scene.hasRelativeScene()) {
        BookModel model = mainFrame.getBookModel();
        Session session = model.beginTransaction();
        SceneDAOImpl dao = new SceneDAOImpl(session);
        // Get all scenes from the book
        Scene relative = dao.findRealtiveScene(scene.getRelativeSceneId());
        session.close();
        // Create the timestamp for the relative date
        Timestamp ts = relative.getSceneTs();
        Calendar cal = Calendar.getInstance();
        cal.setTime(ts);
        cal.add(Calendar.DAY_OF_WEEK, scene.getRelativeDateDifference());
        ts.setTime(cal.getTime().getTime());
        DateFormat formatter = I18N.getDateTimeFormatter();
        label.setText("[" + formatter.format(ts) + "]");
      }
    }

    return label;
  }
Esempio n. 2
0
 public boolean exportToTxtFile() {
   Internal internal =
       BookUtil.get(
           this.mainFrame,
           SbConstants.BookKey.EXPORT_DIRECTORY,
           EnvUtil.getDefaultExportDir(this.mainFrame));
   File file1 = new File(internal.getStringValue());
   JFileChooser chooser = new JFileChooser(file1);
   chooser.setApproveButtonText(I18N.getMsg("msg.common.export"));
   chooser.setSelectedFile(new File(getFileName()));
   chooser.setFileFilter(new TextFileFilter());
   int i = chooser.showOpenDialog(this.mainFrame);
   if (i == 1) {
     return false;
   }
   File outFile = chooser.getSelectedFile();
   if (!outFile.getName().endsWith(".txt")) {
     outFile = new File(outFile.getPath() + ".txt");
   }
   StringBuffer buffer = getContent();
   try {
     try (BufferedWriter outStream = new BufferedWriter(new FileWriter(outFile))) {
       String str = buffer.toString();
       outStream.write(HtmlUtil.htmlToText(str, true));
     }
   } catch (IOException e) {
     return false;
   }
   JOptionPane.showMessageDialog(
       this.mainFrame,
       I18N.getMsg("msg.common.export.success") + "\n" + outFile.getAbsolutePath(),
       I18N.getMsg("msg.common.export"),
       1);
   return true;
 }
Esempio n. 3
0
 private String getOptionsOdf() {
   String str = "";
   str += "<p>" + I18N.getMsg("msg.export.current_options_for") + " ODF :</p>";
   str += "<ul>";
   str += "<li>" + I18N.getMsg("msg.export.odf.no_options") + "</li>";
   str += "</ul>";
   str += getBookOptions();
   return (str);
 }
Esempio n. 4
0
 private String getOptionsXml() {
   String str = "";
   str += "<p>" + I18N.getMsg("msg.export.current_options_for") + " XML DocBook :</p>";
   str += "<ul>";
   str += "<li>" + I18N.getMsg("msg.export.xml.no_options") + "</li>";
   str += "</ul>";
   str += getBookOptions();
   return (str);
 }
Esempio n. 5
0
 private String getOptionsCsv() {
   String str = "";
   str += "<p>" + I18N.getMsg("msg.export.current_options_for") + " CSV :</p>";
   str += "<ul>";
   if (paramExport.csvNoQuotes) str += "<li>" + I18N.getMsg("msg.export.not_quoted") + "</li>";
   else
     str +=
         "<li>"
             + I18N.getMsg(
                 "msg.export.csv_quoted_by",
                 (paramExport.csvSingleQuotes
                     ? I18N.getMsg("msg.export.options.csv.quoted.single")
                     : I18N.getMsg("msg.export.options.csv.quoted.double")))
             + "</li>";
   str +=
       "<li>"
           + I18N.getMsg("msg.export.csv_separator_is")
           + " "
           + (paramExport.csvComma
               ? I18N.getMsg("msg.export.options.csv.separate.comma")
               : I18N.getMsg("msg.export.options.csv.separate.semicolon"))
           + "</li>";
   str += "</ul>";
   str += I18N.getMsg("msg.export.csv_not_book");
   str += getBookOptions();
   return (str);
 }
Esempio n. 6
0
 private String getOptionsTxt() {
   String str = "";
   str += "<p>" + I18N.getMsg("msg.export.current_options_for") + " TXT :</p>";
   str += "<ul>";
   str +=
       "<li>"
           + I18N.getMsg(
               "msg.export.txt_separator",
               (paramExport.txtTab ? "'tab'" : "'" + paramExport.txtSeparator + "'"))
           + "</li>";
   str += "<li>" + I18N.getMsg("msg.export.txt_EOL") + "</li>";
   str += "</ul>";
   str += getBookOptions();
   return (str);
 }
Esempio n. 7
0
 private void cbReportItemStateChanged(
     java.awt.event.ItemEvent evt) { // GEN-FIRST:event_cbReportItemStateChanged
   if (evt.getStateChange() == ItemEvent.SELECTED) {
     if (evt.getItem().toString().equals(I18N.getMsg("msg.export.book.text")))
       setOptions(cbFormat.getSelectedItem().toString());
   }
 } // GEN-LAST:event_cbReportItemStateChanged
Esempio n. 8
0
  @Override
  public void refresh() {
    Part currentPart = mainFrame.getCurrentPart();
    BookModel model = mainFrame.getBookModel();
    Session session = model.beginTransaction();
    ChapterDAOImpl dao = new ChapterDAOImpl(session);
    List<Chapter> chapters = dao.findAll(currentPart);
    model.commit();

    removeAll();

    // "chapter" for unassigned scenes
    JScrollPane scrollerUnassigend = new JScrollPane(new ChapterPanel(mainFrame));
    scrollerUnassigend.setMinimumSize(new Dimension(200, 180));
    add(scrollerUnassigend, "growx");
    add(scroller, "grow");

    // chapters
    MigLayout layout =
        new MigLayout(
            "wrap " + cols,
            "", // columns
            "[top]" // rows
            );
    panel.setLayout(layout);
    panel.removeAll();
    for (Chapter chapter : chapters) {
      panel.add(new ChapterPanel(mainFrame, chapter), "grow");
    }
    if (panel.getComponentCount() == 0) {
      panel.add(new JLabel(I18N.getMsg("msg.warning.no.chapters")));
    }
    revalidate();
    repaint();
  }
Esempio n. 9
0
 @SuppressWarnings("unchecked")
 private JTable createTable() {
   Part part = this.mainFrame.getCurrentPart();
   BookModel documentModel = this.mainFrame.getBookModel();
   Session session = documentModel.beginTransaction();
   PersonDAOImpl personDAO = new PersonDAOImpl(session);
   List<Person> persons = personDAO.findByCategories(this.selectedCategories);
   SceneDAOImpl sceneDAO = new SceneDAOImpl(session);
   List<Date> dates = sceneDAO.findDistinctDates(part);
   LocationDAOImpl locationDAO = new LocationDAOImpl(session);
   List<Location> locations = locationDAO.findAll();
   documentModel.commit();
   Object[] arrayOfObject1 =
       ArrayUtils.addAll(new Object[] {I18N.getMsg("msg.common.location"), ""}, dates.toArray());
   this.foundCharacters.clear();
   ArrayList localArrayList = new ArrayList();
   Iterator<Location> locationsIterator = locations.iterator();
   while (locationsIterator.hasNext()) {
     Location location = locationsIterator.next();
     Object[] localObject2 = new Object[arrayOfObject1.length];
     int j = 0;
     localObject2[(j++)] = location.getName();
     localObject2[(j++)] = location.getCountryCity();
     int m = 0;
     Iterator<Date> datesIterator = dates.iterator();
     while (datesIterator.hasNext()) {
       Date localDate = datesIterator.next();
       WiWWContainer localWiWWContainer =
           new WiWWContainer(this.mainFrame, localDate, location, persons);
       localObject2[j] = localWiWWContainer;
       if (localWiWWContainer.isFound()) {
         this.foundCharacters.addAll(localWiWWContainer.getCharacterList());
         m = 1;
       }
       j++;
     }
     if (m != 0) {
       localArrayList.add(localObject2);
     }
   }
   //	Object[] localObject1 = new Object[localArrayList.size()][];
   //	int i = 0;
   /* Obfuscator ?
   Object localObject2 = localArrayList.iterator();
   while (((Iterator) localObject2).hasNext()) {
   	Object[] arrayOfObject2 = (Object[]) ((Iterator) localObject2).next();
   	localObject1[(i++)] = arrayOfObject2;
   }*/
   ReadOnlyTable jTable =
       new ReadOnlyTable((Object[][]) localArrayList.toArray(new Object[0][]), arrayOfObject1);
   for (int k = 2; k < jTable.getColumnCount(); k++) {
     TableColumn localTableColumn = jTable.getColumnModel().getColumn(k);
     localTableColumn.setPreferredWidth(120);
     localTableColumn.setCellRenderer(new WiWWTableCellRenderer());
   }
   jTable.setAutoResizeMode(0);
   jTable.getTableHeader().setReorderingAllowed(false);
   return jTable;
 }
Esempio n. 10
0
 private String getOptionsPdf() {
   String str = "";
   str += "<p>" + I18N.getMsg("msg.export.current_options_for") + " PDF :</p>";
   str += "<ul>";
   str +=
       "<li>" + I18N.getMsg("msg.export.options.pdf.pagesize", paramExport.pdfPageSize) + "</li>";
   str +=
       "<li>"
           + I18N.getMsg("msg.export.options.pdf.orientation")
           + " : "
           + (paramExport.pdfLandscape
               ? I18N.getMsg("msg.export.options.pdf.orientation.landscape")
               : I18N.getMsg("msg.export.options.pdf.orientation.portrait"))
           + "</li>";
   str += "</ul>";
   str += getBookOptions();
   return (str);
 }
Esempio n. 11
0
 protected void initOptionsUi() {
   super.initOptionsUi();
   this.cbShowUnusedPersons = new JCheckBox();
   this.cbShowUnusedPersons.setSelected(true);
   this.cbShowUnusedPersons.setText(I18N.getMsg("msg.chart.common.unused.characters"));
   this.cbShowUnusedPersons.setOpaque(false);
   this.cbShowUnusedPersons.addActionListener(this);
   JLabel localJLabel = new JLabel(I18N.getIcon("icon.small.size"));
   this.colSlider = SwingUtil.createSafeSlider(0, 5, 200, this.colWidth);
   this.colSlider.setMinorTickSpacing(1);
   this.colSlider.setMajorTickSpacing(2);
   this.colSlider.setSnapToTicks(false);
   this.colSlider.addChangeListener(this);
   this.colSlider.setOpaque(false);
   this.optionsPanel.add(this.cbShowUnusedPersons, "right,gap push");
   this.optionsPanel.add(localJLabel, "gap 20");
   this.optionsPanel.add(this.colSlider);
 }
Esempio n. 12
0
 @Override
 protected void initOptionsUi() {
   super.initOptionsUi();
   JLabel localJLabel = new JLabel(I18N.getIcon("icon.small.size"));
   this.colSlider = SwingUtil.createSafeSlider(0, 5, 300, this.colWidth);
   this.colSlider.setMinorTickSpacing(1);
   this.colSlider.setMajorTickSpacing(2);
   this.colSlider.setSnapToTicks(false);
   this.colSlider.addChangeListener(this);
   this.colSlider.setOpaque(false);
   this.optionsPanel.add(localJLabel, "gap push,right");
   this.optionsPanel.add(this.colSlider);
 }
Esempio n. 13
0
 private String getBookOptions() {
   String str = "";
   if (cbReport.getSelectedItem().toString().equals(I18N.getMsg("msg.export.book.text"))) {
     str += "<p>" + I18N.getMsg("msg.export.book.htmloption") + " ";
     if (paramExport.htmlBookMulti) str += I18N.getMsg("msg.export.book.htmloption.multifile");
     else str += I18N.getMsg("msg.export.book.htmloption.onefile");
     str += "</p>";
     str += "<ul>";
     if (paramExport.isExportChapterNumbers)
       str += "<li>" + I18N.getMsg("msg.export.chapter.numbers") + "</li>";
     if (paramExport.isExportChapterNumbersRoman)
       str += "<li>" + I18N.getMsg("msg.export.roman.numerals") + "</li>";
     if (paramExport.isExportChapterTitles)
       str += "<li>" + I18N.getMsg("msg.export.chapter.titles") + "</li>";
     if (paramExport.isExportChapterDatesLocs)
       str += "<li>" + I18N.getMsg("msg.export.chapter.dates.locations") + "</li>";
     if (paramExport.isExportSceneTitles)
       str += "<li>" + I18N.getMsg("msg.export.scene.titles") + "</li>";
     if (paramExport.isExportSceneSeparator)
       str += "<li>" + I18N.getMsg("msg.export.scene.separator") + "</li>";
     str += "</ul>";
   }
   return (str);
 }
  @Override
  public void modelPropertyChange(PropertyChangeEvent evt) {
    // Object oldValue = evt.getOldValue();
    Object newValue = evt.getNewValue();
    String propName = evt.getPropertyName();

    if (BookController.StrandProps.UPDATE.check(propName)) {
      EntityUtil.refresh(mainFrame, scene.getStrand());
      setEndBgColor(scene.getStrand().getJColor());
      repaint();
      return;
    }

    if (BookController.SceneProps.UPDATE.check(propName)) {
      Scene newScene = (Scene) newValue;
      if (!newScene.getId().equals(scene.getId())) {
        // not this scene
        return;
      }
      scene = newScene;
      lbSceneNo.setText(scene.getChapterSceneNo(false));
      lbSceneNo.setToolTipText(scene.getChapterSceneToolTip());
      lbStatus.setIcon(scene.getStatusIcon());
      taTitle.setText(scene.getTitle());
      taTitle.setCaretPosition(0);
      tcText.setText(scene.getSummary());
      tcText.setCaretPosition(0);
      if (scene.hasSceneTs()) {
        if (!DateUtil.isZeroTimeDate(scene.getSceneTs())) {
          DateFormat formatter = I18N.getDateTimeFormatter();
          lbTime.setText(formatter.format(scene.getSceneTs()));
        } else {
          lbTime.setText("");
        }
      }
      return;
    }

    if (BookController.ChronoViewProps.ZOOM.check(propName)) {
      setZoomedSize((Integer) newValue);
      refresh();
    }
  }
Esempio n. 15
0
 private String getOptionsHtml() {
   String str = "";
   str += "<p>" + I18N.getMsg("msg.export.current_options_for") + " HTML :</p>";
   str += "<ul>";
   str +=
       "<li>"
           + I18N.getMsg("msg.export.html_use_css")
           + " : "
           + (paramExport.htmlUseCss
               ? I18N.getMsg("msg.common.yes")
               : I18N.getMsg("msg.common.no"))
           + "</li>";
   if (paramExport.htmlUseCss)
     str +=
         "<li>"
             + I18N.getMsg("msg.export.html_css_file")
             + " : "
             + paramExport.htmlCssFile
             + "</li>";
   str += "</ul>";
   str += "<p>" + I18N.getMsg("msg.export.html_add_index") + "</p>";
   str += getBookOptions();
   return (str);
 }
Esempio n. 16
0
  @Override
  public void refresh() {
    MigLayout layout = new MigLayout("fill,flowy,insets 4", "[]", "[][grow]");
    setLayout(layout);
    setPreferredSize(new Dimension(size, size));
    setComponentPopupMenu(EntityUtil.createPopupMenu(mainFrame, scene));

    removeAll();

    // set dotted border for scenes of other parts
    setBorder(SwingUtil.getBorderDefault());
    if (scene.hasChapter()) {
      if (!scene.getChapter().getPart().getId().equals(mainFrame.getCurrentPart().getId())) {
        setBorder(SwingUtil.getBorderDot());
      }
    }

    // strand links
    StrandLinksPanel strandLinksPanel = new StrandLinksPanel(mainFrame, scene, true);

    // person links
    PersonLinksPanel personLinksPanel = new PersonLinksPanel(mainFrame, scene);

    // location links
    LocationLinksPanel locationLinksPanel = new LocationLinksPanel(mainFrame, scene);

    // location links
    ItemLinksPanel itemLinksPanel = new ItemLinksPanel(mainFrame, scene);

    // button new
    btNew = getNewButton();
    btNew.setSize20x20();
    // btNew.setName(COMP_NAME_BT_NEW);

    // button remove
    btDelete = getDeleteButton();
    btDelete.setSize20x20();
    // btDelete.setName(COMP_NAME_BT_REMOVE);

    // button edit
    btEdit = getEditButton();
    btEdit.setSize20x20();
    // btEdit.setName(COMP_NAME_BT_EDIT);

    // chapter and scene number
    lbSceneNo = new JLabel("", SwingConstants.CENTER);
    lbSceneNo.setText(scene.getChapterSceneNo(false));
    lbSceneNo.setToolTipText(scene.getChapterSceneToolTip());
    lbSceneNo.setOpaque(true);
    lbSceneNo.setBackground(Color.white);

    // status
    lbStatus = new SceneStateLabel(scene.getSceneState(), true);

    // informational
    lbInformational = new JLabel("");
    if (scene.getInformative()) {
      lbInformational.setIcon(I18N.getIcon("icon.small.info"));
      lbInformational.setToolTipText(I18N.getMsg("msg.common.informative"));
    }

    // scene time
    lbTime = new JLabel();
    if (scene.hasSceneTs()) {
      if (!DateUtil.isZeroTimeDate(scene.getSceneTs())) {
        lbTime.setText(DateUtil.simpleDateTimeToString(this.scene.getSceneTs()));
      }
    }

    // title
    taTitle = new UndoableTextArea();
    taTitle.setName(CN_TITLE);
    taTitle.setText(scene.getTitle());
    taTitle.setLineWrap(true);
    taTitle.setWrapStyleWord(true);
    taTitle.setDragEnabled(true);
    taTitle.setCaretPosition(0);
    taTitle.getUndoManager().discardAllEdits();
    taTitle.addFocusListener(this);
    SwingUtil.addCtrlEnterAction(taTitle, new EditEntityAction(mainFrame, scene, true));
    JScrollPane spTitle = new JScrollPane(taTitle);
    spTitle.setPreferredSize(new Dimension(50, 35));

    // text
    tcText = SwingUtil.createTextComponent(mainFrame);
    tcText.setName(CN_TEXT);
    tcText.setText(scene.getText());
    tcText.setDragEnabled(true);
    tcText.addFocusListener(this);
    SwingUtil.addCtrlEnterAction(tcText, new EditEntityAction(mainFrame, scene, true));
    JScrollPane spText = new JScrollPane(tcText);
    spText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    spText.setPreferredSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));

    // layout

    // button panel
    JPanel buttonPanel = new JPanel(new MigLayout("flowy,insets 0"));
    buttonPanel.setName("buttonpanel");
    buttonPanel.setOpaque(false);
    buttonPanel.add(btEdit);
    buttonPanel.add(btDelete);
    buttonPanel.add(btNew);

    upperPanel = new JPanel(new MigLayout("ins 0", "[][grow][]", "[top][top][top]"));
    upperPanel.setName(CN_UPPER_PANEL);
    upperPanel.setOpaque(false);
    upperPanel.add(lbSceneNo, "grow,width pref+10px,split 3");
    upperPanel.add(lbStatus);
    upperPanel.add(lbInformational);
    upperPanel.add(strandLinksPanel, "grow");
    upperPanel.add(buttonPanel, "spany 4,wrap");
    JScrollPane scroller =
        new JScrollPane(
            personLinksPanel,
            JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scroller.setMinimumSize(new Dimension(20, 16));
    scroller.setOpaque(false);
    scroller.getViewport().setOpaque(false);
    scroller.setBorder(null);
    upperPanel.add(scroller, "spanx 2,growx,wrap");
    upperPanel.add(locationLinksPanel, "spanx 2,grow,wrap");
    upperPanel.add(lbTime);

    // main panel
    add(upperPanel, "growx");
    add(spTitle, "growx, h 35!");
    add(spText, "grow");

    revalidate();
    repaint();

    tcText.setCaretPosition(0);
    taTitle.setCaretPosition(0);
  }
  @Override
  public void refresh() {
    MigLayout layout = new MigLayout("fill,flowy,insets 4", "[]", "[][grow]");
    setLayout(layout);
    setPreferredSize(new Dimension(size, size));
    setComponentPopupMenu(EntityUtil.createPopupMenu(mainFrame, scene));

    removeAll();

    // set dotted border for scenes of other parts
    setBorder(SwingUtil.getBorderDefault());
    if (scene.hasChapter()) {
      if (!scene.getChapter().getPart().getId().equals(mainFrame.getCurrentPart().getId())) {
        setBorder(SwingUtil.getBorderDot());
      }
    }

    // button new
    btNew = getNewButton();
    btNew.setSize20x20();
    // btNew.setName(COMP_NAME_BT_NEW);

    // button remove
    btDelete = getDeleteButton();
    btDelete.setSize20x20();
    // btDelete.setName(COMP_NAME_BT_REMOVE);

    // button edit
    btEdit = getEditButton();
    btEdit.setSize20x20();
    // btEdit.setName(COMP_NAME_BT_EDIT);

    // chapter and scene number
    lbSceneNo = new JLabel("", SwingConstants.CENTER);
    lbSceneNo.setText(scene.getChapterSceneNo(false));
    lbSceneNo.setToolTipText(scene.getChapterSceneToolTip());
    lbSceneNo.setOpaque(true);
    lbSceneNo.setBackground(Color.white);

    // status
    lbStatus = new SceneStateLabel(scene.getSceneState(), true);

    // informational
    lbInformational = new JLabel("");
    if (scene.getInformative()) {
      lbInformational.setIcon(I18N.getIcon("icon.small.info"));
      lbInformational.setToolTipText(I18N.getMsg("msg.common.informative"));
    }

    // scene time
    lbTime = addSceneTimeTextToPanel();

    // title
    JScrollPane spTitle = generateTitlePane();
    spTitle.setPreferredSize(new Dimension(50, 35));

    // text
    JScrollPane spText = generateTextPane();
    spText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    spText.setPreferredSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));

    // layout
    // button panel
    upperPanel = setupUpperPanel();

    // main panel
    add(upperPanel, "growx");
    add(spTitle, "growx, h 35!");
    add(spText, "grow");

    revalidate();
    repaint();

    tcText.setCaretPosition(0);
    taTitle.setCaretPosition(0);
  }