public void totalExport() { File expf = new File("export"); if (expf.exists()) rmrf(expf); expf.mkdirs(); for (int sto = 0; sto < storeLocs.size(); sto++) { try { String sl = storeLocs.get(sto).getAbsolutePath().replaceAll("/", "-").replaceAll("\\\\", "-"); File estore = new File(expf, sl); estore.mkdir(); File log = new File(estore, LIBRARY_NAME); PrintWriter pw = new PrintWriter(log); for (int i = 0; i < store.getRowCount(); i++) if (store.curStore(i) == sto) { File enc = store.locate(i); File dec = sec.prepareMainFile(enc, estore, false); pw.println(dec.getName()); pw.println(store.getValueAt(i, Storage.COL_DATE)); pw.println(store.getValueAt(i, Storage.COL_TAGS)); synchronized (jobs) { jobs.addLast(expJob(enc, dec)); } } pw.close(); } catch (IOException exc) { exc.printStackTrace(); JOptionPane.showMessageDialog(frm, "Exporting Failed"); return; } } JOptionPane.showMessageDialog(frm, "Exporting to:\n " + expf.getAbsolutePath()); }
// Add/Insert public int add(Script script) { // Find the correct spot to add it alphabetically int i, limit; for (i = 0, limit = scripts.size(); i < limit; i++) { Script scriptTemp = (Script) scripts.get(i); if (scriptTemp.getName().compareTo(script.getName()) >= 0) { break; } } scripts.add(i, script); // Update the table fireTableRowsInserted(i, i); return i; }
public void secureMove() { int rw = tblItems.getSelectedRow(); if (rw == -1) { JOptionPane.showMessageDialog(frm, "No item selected", "Error", JOptionPane.ERROR_MESSAGE); return; } int idx = tblItems.convertRowIndexToModel(rw); String[] opts = new String[storeLocs.size()]; for (int i = 0; i < opts.length; i++) opts[i] = storeLocs.get(i).getAbsolutePath(); JComboBox cmbMove = new JComboBox(opts); cmbMove.setSelectedIndex(store.curStore(idx)); if (JOptionPane.showConfirmDialog(frm, cmbMove, "Move item", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION) return; File newLoc = store.move(idx, cmbMove.getSelectedIndex()); if (newLoc == null) System.err.println("move " + store.plainName(idx) + " unsuccessful"); else needsSave = true; }
public void removeMessages(Message[] removedMessages) { try { // Translate the array of removed Message instances into a list of all the row indexes to be // removed from the model. // Assumes the list of removed messages is small. ArrayList<Integer> deadIndexes = new ArrayList<Integer>(); for (Message message : removedMessages) { int deadIndex = messages.indexOf(message); if (deadIndex != -1) { deadIndexes.add(deadIndex); } } // Actually remove the rows, notifying the listeners as we go (rather than bother trying to // coalesce). for (int i = deadIndexes.size() - 1; i >= 0; --i) { int deadIndex = deadIndexes.get(i); messages.remove(deadIndex); fireTableRowsDeleted(deadIndex, deadIndex); } } catch (Exception ex) { ex.printStackTrace(); } }
// Getters public Script get(int i) { return (Script) scripts.get(i); }
public String getColumnName(int column) { return headers.get(column); }