public static void deleteFilter(MySeries m) {
   String title = "";
   title = String.valueOf(m.combobox_filters.getSelectedItem());
   FilterRecord f;
   MySeriesLogger.logger.log(Level.INFO, "Delete filter {0}", title);
   int answ =
       MyMessages.confirm(
           "Delete Filter?", "Are you sure that you want to delete the filter?", true);
   if (answ == JOptionPane.YES_OPTION) {
     try {
       f = DBHelper.getFilterByTitle(title);
       if (f != null) {
         f.delete();
         MySeriesLogger.logger.log(Level.FINE, "Filter was deleted");
         MyMessages.message("Filter deleted", "Filter was deleted");
       } else {
         MySeriesLogger.logger.log(Level.WARNING, "Filter not found");
         MyMessages.warning("Error", "Filter not found", true);
       }
       m.comboBoxModel_filters = new DefaultComboBoxModel(DBHelper.getFiltersTitlesList());
       m.combobox_filters.setModel(m.comboBoxModel_filters);
     } catch (SQLException ex) {
       MySeriesLogger.logger.log(Level.SEVERE, "Error while deleting filter", ex);
       MyMessages.error("SQL Error", "There was an error when deleting the filter", true);
     }
   } else {
     MySeriesLogger.logger.log(Level.INFO, "Delete filter aborted by user");
   }
 }
 public static void saveFilter(MySeries m) {
   String title = "";
   title = String.valueOf(m.combobox_filters.getSelectedItem());
   FilterRecord f;
   MySeriesLogger.logger.log(Level.INFO, "Saaving filter action");
   if (title.trim().equals("") || title.equals("null")) {
     MySeriesLogger.logger.log(Level.WARNING, "Empty title");
     MyMessages.warning("Empty title", "Please specify a save name", true);
   } else {
     try {
       f = DBHelper.getFilterByTitle(title);
       if (f == null) {
         f = new FilterRecord();
       }
       f.setDownloaded(m.combobox_downloaded.getSelectedIndex());
       f.setSeen(m.comboBox_seen.getSelectedIndex());
       f.setSubtitles(m.comboBox_filterSubtitles.getSelectedIndex());
       f.setTitle(title);
       f.save();
       MyMessages.message("Filter saved", "Filter was saved");
       MySeriesLogger.logger.log(Level.FINE, "Filter {0} was saved", title);
       m.comboBoxModel_filters = new DefaultComboBoxModel(DBHelper.getFiltersTitlesList());
       m.combobox_filters.setModel(m.comboBoxModel_filters);
     } catch (SQLException ex) {
       MySeriesLogger.logger.log(Level.SEVERE, "Error while saving filter", ex);
       MyMessages.error("SQL Error", "There was an error when saving the filter", true);
     }
   }
 }
Esempio n. 3
0
 public static void main(String[] args) {
   DBHelper helper = new DBHelper("databases/timeline.db");
   TLEvent event1 = new Atomic("one", "", new Date(((long) 1000) * 60 * 60 * 24));
   TLEvent event2 =
       new Duration(
           "two",
           "",
           new Date(((long) 1000) * 60 * 60 * 24),
           new Date(((long) 1000) * 60 * 60 * 24 * 2));
   Timeline test1 = new Timeline("Test1", 0);
   Timeline test2 = new Timeline("Test2", 2);
   test1.addEvent(event1);
   test1.addEvent(event2);
   helper.removeTimeline(test1);
   helper.removeTimeline(test2);
   helper.writeTimeline(test1);
   helper.writeTimeline(test2);
   helper.removeTimeline(test1);
   helper.changeTimeline(test2, test1);
   Timeline[] timelines = helper.getTimelines();
   for (Timeline timeline : timelines) {
     System.out.println("-----" + timeline.getName() + "-----");
     TLEvent[] events = timeline.getEvents();
     for (TLEvent event : events) {
       System.out.println(event.getName());
     }
   }
   System.out.println("Finished!");
 }
 public static void applyFilter(MySeries m) {
   try {
     String title = "";
     title = String.valueOf(m.combobox_filters.getSelectedItem());
     FilterRecord f = DBHelper.getFilterByTitle(title);
     if (f != null) {
       MySeriesLogger.logger.log(Level.INFO, "Applying filter {0}", f.getTitle());
       m.combobox_downloaded.setSelectedIndex(f.getDownloaded());
       m.comboBox_seen.setSelectedIndex(f.getSeen());
       m.comboBox_filterSubtitles.setSelectedIndex(f.getSubtitles());
     }
   } catch (SQLException ex) {
     MySeriesLogger.logger.log(Level.SEVERE, "Error while applying the  filter", ex);
     MyMessages.error("SQL Error", "There was an error when applying the filter", true);
   }
 }