Package unify.data

Examples of unify.data.Show


            numEpisodes++;
          }
        }
      }
      for(Show dbShow : showDao.queryForAll()) {
        Show myShow = ShowLibrary.getInstance().getShow(dbShow.getTitle());
        if(myShow==null) {
          for(Season season : dbShow.seasons) {
            episodeDao.delete(season.getEpisodes());
          }
          seasonDao.delete(dbShow.seasons);
View Full Code Here


      LOGGER.finest("Initializing shows file input...");
    } catch (FileNotFoundException e) {
      LOGGER.severe("File " + this.showFile.getName() + " does not exist.");
      System.exit(1);
    }
    Show s1;
    while (showscanner.hasNext()) {
      String show = showscanner.nextLine();
      s1 = new Show(show.split(" :: ")[0]);
      try {
        s1.setCurSeason(Integer.parseInt(show.split(" :: ")[1]));
        s1.setLastEpisode(Integer.parseInt(show.split(" :: ")[2]));
      } catch (NumberFormatException e) {
        LOGGER.severe("Invalid number format for " + show.split(" :: ")[1]
            + " or " + show.split(" :: ")[2]);
        System.exit(1);
      }
View Full Code Here

      LOGGER.finest("Initializing available file input...");
    } catch (FileNotFoundException e) {
      LOGGER.warning("File " + this.availableFile.getName() + " does not exist.");
      return;
    }
    Show show;
    int availCount = 0;
    while (showscanner.hasNext()) {
      String showLine = showscanner.nextLine();
      String myShowTitle = showLine.split(" :: ")[0];
      show = showLib.getShow(myShowTitle);
      if(show!=null) {
        availCount++;
        try {
          int seasonNum = (Integer.parseInt(showLine.split(" :: ")[1]));
          int episodeNum = (Integer.parseInt(showLine.split(" :: ")[2]));
          String link = showLine.split(" :: ")[3];
          String label = showLine.split(" :: ")[4];
          Season season = show.findSeason(seasonNum);
          if(season==null) {
            season = show.addSeason(seasonNum);
          }
          season.addEpisode(episodeNum, link, label);
        } catch (NumberFormatException e) {
          LOGGER.severe("Invalid number format for " + showLine.split(" :: ")[1]
              + " or " + showLine.split(" :: ")[2]);
View Full Code Here

  }

  public void updateShowFile() {
    boolean append = false;
    for (int i = 0; i < showLib.shows.size(); i++) {
      Show s1 = showLib.shows.get(i);
      try {
        String data = s1.getTitle() + " :: " + s1.getCurSeason() + " :: "
            + s1.getLastEpisode() + "\n";
        FileWriter fileWritter = new FileWriter(this.showFile.getName(), append);
        BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
        bufferWritter.write(data);
        bufferWritter.close();
      } catch (IOException e) {
View Full Code Here

  }

  public void updateAvailableFile() {
    boolean append = false;
    for(int i = 0; i < showLib.shows.size(); i++) {
      Show s1 = showLib.shows.get(i);
      for(Season season : s1.seasons) {
        for(Episode myEp : season.getEpisodes()) {
          try {
            String link = myEp.getLink();
            String linkLabel = myEp.getLinkLabel();
            if(link.equals("")) {
              link = " ";
              linkLabel = " ";
            }
            String data = s1.getTitle() + " :: " + season.getNumber() + " :: "
                + myEp.getNumber() + " :: " + link + " :: " + linkLabel + "\n";
            FileWriter fileWritter = new FileWriter(this.availableFile.getName(), append);
            BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
            bufferWritter.write(data);
            bufferWritter.close();
View Full Code Here

    doneParsing(title, 1, episodeInt, link);
  }

  private void doneParsing(String title, int seasonInt, int episodeInt, String link) {
    LOGGER.finest(myFeed.getLabel() + " has " + title + " season " + seasonInt + " episode " + episodeInt);
    Show show = null;
    for(int i=0;i<this.rssShows.size();i++) {
      if(rssShows.get(i).getTitle().equals(title)) {
        show = rssShows.get(i);
      }
    }
    if(show==null) {
      show = new Show(title);
      rssShows.add(show);
    }
    Season season = show.findSeason(seasonInt);
    if(season==null) {
      season = show.addSeason(seasonInt);
    }
    season.addEpisode(episodeInt, link, myFeed.getLabel());
  }
View Full Code Here

        if(row==-1) {
          JOptionPane.showMessageDialog(frame, "Please select a show in the above table first.", "Error", JOptionPane.ERROR_MESSAGE);
        }
        else {
          ShowLibrary showLib = ShowLibrary.getInstance();
          Show show = showLib.shows.get(row);
          int result = JOptionPane.showConfirmDialog(frame,"Are you sure you want to delete " + show.getTitle(), "Delete " + show.getTitle() + "?", JOptionPane.YES_NO_OPTION);
          if(result==0) {
            LOGGER.info("Deleted " + show.getTitle() + ".");
            showLib.shows.remove(show);
            updateShowTable(true);
          }
        }
      }
    });
    bottomPanel.add(btnDeleteShow);

    JButton btnAddAltTitle = new JButton("Add Alternate Title");
    btnAddAltTitle.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
        int row = showTable.getSelectedRow();
        if(row==-1) {
          JOptionPane.showMessageDialog(frame, "Please select a show in the above table first.", "Error", JOptionPane.ERROR_MESSAGE);
        }
        else {
          ShowLibrary showLib = ShowLibrary.getInstance();
          Show show = showLib.shows.get(row);
          String altTitle = JOptionPane.showInputDialog(frame,"Enter the alternate title you want to add to " + show.getTitle());
          if(!(altTitle==null || altTitle.isEmpty() || altTitle.startsWith("No alternate")) ) {
            show.addAltTitle(altTitle);
            updateShowTable(true);
          }
        }
      }
    });
    bottomPanel.add(btnAddAltTitle);

    JButton btnRemoveAltTitle = new JButton("Remove Alternate Title");
    btnRemoveAltTitle.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
        int row = showTable.getSelectedRow();
        if(row==-1) {
          JOptionPane.showMessageDialog(frame, "Please select a show in the above table first.", "Error", JOptionPane.ERROR_MESSAGE);
        }
        else {
          ShowLibrary showLib = ShowLibrary.getInstance();
          Show show = showLib.shows.get(row);
          String[] altTitles = show.getAltTitles().split("<br>");
          String altTitle = (String) JOptionPane.showInputDialog(frame,"Selecte the alternate title you want to remove from " + show.getTitle(), "Remove alternate title from " + show.getTitle(), JOptionPane.INFORMATION_MESSAGE, null, altTitles, altTitles[0]);
          if(!(altTitle==null || altTitle.isEmpty())) {
            show.removeAltTitle(altTitle);
            updateShowTable(true);
          }
        }
      }
    });
View Full Code Here

        switch (e.getType()) {
        case TableModelEvent.INSERT:
          //Unused
          break;
        case TableModelEvent.UPDATE:
          Show show = ShowLibrary.getInstance().shows.get(row);
          String value = (String) showTableModel.getValueAt(row, col);
          if(col==0 && !value.isEmpty()) {
            show.setTitle(value);
          }
          else if(col==1) {
            try {
              show.setCurSeason(Integer.parseInt(value));
            }
            catch (NumberFormatException exception) {
              JOptionPane.showMessageDialog(frame, value + " is not an integer, please try again.", "Warning: Not an integer", JOptionPane.ERROR_MESSAGE);
            }
          }
          else if(col==2) {
            try {
              show.setLastEpisode(Integer.parseInt(value));
            }
            catch (NumberFormatException exception) {
              JOptionPane.showMessageDialog(frame, value + " is not an integer, please try again.", "Warning: Not an integer", JOptionPane.ERROR_MESSAGE);
            }
          }
View Full Code Here

    trayIcon.setPopupMenu(popup);
  }

  private void createMenu(Menu menu, ArrayList<Show> shows) {
    for(int i=0;i<shows.size();i++) {
      Show show = shows.get(i);
      Season season = show.getSeason();
      for(Episode episode : season.getEpisodes()) {
        final Menu showMenu = new Menu(show.getTitle() + " (" + season.getNumber() + "x" + episode.getNumber() + ")");
        menu.add(showMenu);
        final MenuItem linkItem = new MenuItem(episode.getLinkLabel());       
        final URI myURL = URI.create(episode.getLink());
        linkItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              Desktop.getDesktop().browse(myURL);
            } catch (IOException e1) {
              LOGGER.warning("IO error " + e1.toString());
            }
          }
        });
        showMenu.add(linkItem);

        addSearchItems(showMenu, season.formatSeasonEp(episode.getNumber()), show.getTitle());
      }
    }
  }
View Full Code Here

    }
  }

  private void createNewShowsMenu(Menu newShows) {
    for(int i=0;i<ShowLibrary.getInstance().newShows.size();i++) {
      final Show show = ShowLibrary.getInstance().newShows.get(i);
      final String title = show.getTitle();
      final Menu showMenu = new Menu(title);
      newShows.add(showMenu);
      final Season season = show.getSeason();
      final Episode episode = season.getEpisode();
      String linkLabel = episode.getLinkLabel();
      String link = episode.getLink();
      //Add menu items add, remove, and link
      final MenuItem addItem = new MenuItem("Move to Shows");
      final MenuItem removeItem = new MenuItem("Remove & Ignore");
      final MenuItem linkItem = new MenuItem(linkLabel);
      showMenu.add(addItem);
      showMenu.add(removeItem);
      showMenu.add(linkItem);

      //Add menu item functionality
      addItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          Show newShow = ShowLibrary.getInstance().addShow(show);
          Season season = newShow.addSeason(1);
          Episode episode = show.findSeason(1).findEpisode(1);
          season.addEpisode(1, episode.getLink(), episode.getLinkLabel());
          ShowLibrary.getInstance().newShows.remove(show);
          ShowLibrary.getInstance().doUpdates();
          GUI.getInstance().refresh();
View Full Code Here

TOP

Related Classes of unify.data.Show

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.