예제 #1
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;
 }
예제 #2
0
 @SuppressWarnings("unchecked")
 private JTable createTable() {
   Part part = mainFrame.getCurrentPart();
   BookModel model = mainFrame.getBookModel();
   Session session = model.beginTransaction();
   PersonDAOImpl personDAO = new PersonDAOImpl(session);
   List persons = personDAO.findByCategories(selectedCategories);
   SceneDAOImpl sceneDAO = new SceneDAOImpl(session);
   List scenes = sceneDAO.findByPart(part);
   model.commit();
   String[] string1 = new String[scenes.size() + 1];
   string1[0] = "";
   int i = 1;
   Object scenesIterator = scenes.iterator();
   while (((Iterator) scenesIterator).hasNext()) {
     Scene scene = (Scene) ((Iterator) scenesIterator).next();
     string1[i] = ((Scene) scene).getChapterSceneNo(false);
     i++;
   }
   scenesIterator = new ArrayList();
   String[] string2 = new String[scenes.size() + 1];
   Iterator personsIterator = persons.iterator();
   Object localObject6;
   while (personsIterator.hasNext()) {
     Person person = (Person) personsIterator.next();
     int j = 0;
     Object[] string3 = new Object[scenes.size() + 1];
     string3[(j++)] = person.getAbbreviation();
     int n = 0;
     localObject6 = scenes.iterator();
     while (((Iterator) localObject6).hasNext()) {
       Scene localScene = (Scene) ((Iterator) localObject6).next();
       if (localScene.getPersons().contains(person)) {
         n = 1;
         string3[j] = ColorUtil.darker(localScene.getStrand().getJColor(), 0.05D);
       } else {
         string3[j] = null;
       }
       string2[j] = HtmlUtil.wrapIntoTable(localScene.getTitleText(true, 500));
       j++;
     }
     if ((cbShowUnusedPersons == null) || (cbShowUnusedPersons.isSelected()) || (n != 0)) {
       ((List) scenesIterator).add(string3);
     }
   }
   Object[][] localObject31 = new Object[((List) scenesIterator).size()][];
   i = 0;
   Iterator localObject4 = ((List) scenesIterator).iterator();
   while (((Iterator) localObject4).hasNext()) {
     Object[] arrayOfObject1 = (Object[]) ((Iterator) localObject4).next();
     localObject31[(i++)] = arrayOfObject1;
   }
   JTable ntable = new ReadOnlyTable((Object[][]) localObject31, string1);
   if (ntable.getModel().getRowCount() == 0) {
     return ntable;
   }
   ntable.getColumnModel().getColumn(0).setPreferredWidth(200);
   ntable.getColumnModel().getColumn(0).setCellRenderer(new HeaderTableCellRenderer());
   for (int k = 1; k < ntable.getColumnCount(); k++) {
     int m = ntable.getColumnModel().getColumn(k).getModelIndex();
     Object localObject5 = ntable.getModel().getValueAt(0, m);
     localObject6 = ntable.getColumnModel().getColumn(k);
     if ((localObject5 == null) || ((localObject5 instanceof Color))) {
       ((TableColumn) localObject6).setPreferredWidth(colWidth);
       ((TableColumn) localObject6).setCellRenderer(new ColorTableCellRenderer(false));
     }
   }
   ntable.setAutoResizeMode(0);
   ntable.getTableHeader().setReorderingAllowed(false);
   ToolTipHeader localToolTipHeader = new ToolTipHeader(ntable.getColumnModel());
   localToolTipHeader.setToolTipStrings((String[]) string2);
   localToolTipHeader.setToolTipText("Default ToolTip TEXT");
   ntable.setTableHeader(localToolTipHeader);
   return ntable;
 }