Package devplugin

Examples of devplugin.PluginTreeNode


        mRootNode.removeAllActions();

        for (Object o : mConfig.getDevices()) {
            final DeviceIf device = (DeviceIf) o;

            PluginTreeNode node;
            if (mConfig.getDevices().size() > 1) {
              node = new PluginTreeNode(device.getName());
              mRootNode.add(node);
            }
            else {
              node = mRootNode;
            }

            if(device.isAbleToAddAndRemovePrograms()) {
              node.getMutableTreeNode().setProgramReceiveTarget(new ProgramReceiveTarget(this, device.getName() + " - " + mLocalizer.msg("record", "record"), device.getId() + RECORD));
            }

            Program[] programs = device.getProgramList();

            if (programs != null) {
              for (Program program : programs) {
                  node.addProgram(program);
              }
            }

            node.addAction(new AbstractAction(mLocalizer.msg("configure", "Configure '{0}'", device.getName())) {
              @Override
              public void actionPerformed(ActionEvent e) {
                device.configDevice(UiUtilities.getBestDialogParent(getParentFrame()));
                updateTreeNode();
              }
View Full Code Here


  }

  @Override
  public PluginTreeNode getRootNode() {
    if (mRootNode == null) {
      mRootNode = new PluginTreeNode(this);
    }
    return mRootNode;
  }
View Full Code Here

  synchronized private void updateRootNode(final boolean force) {
    if (!mStartFinished && !force) {
      return;
    }
    final PluginTreeNode root = getRootNode();
    root.removeAllActions();
    root.removeAllChildren();

    int progCount = 0;
    final HashMap<String, PluginTreeNode> genreNodes = new HashMap<String, PluginTreeNode>();
    currentGenres = new ArrayList<String>();
    final Channel[] channels = devplugin.Plugin.getPluginManager().getSubscribedChannels();
    Date date = Date.getCurrentDate();
    final int maxDays = mSettings.getDays();
    for (int days = 0; days < maxDays; days++) {
      for (int i = 0; i < channels.length; ++i) {
        for (Iterator<Program> iter = devplugin.Plugin.getPluginManager()
            .getChannelDayProgram(date, channels[i]); iter.hasNext();) {
          final Program prog = iter.next();
          String genreField = prog.getTextField(ProgramFieldType.GENRE_TYPE);
          if (genreField != null) {
            // some programs have buggy fields with brackets
            if (genreField.startsWith("(") && genreField.endsWith(")")) {
              genreField = genreField.substring(1, genreField.length() - 1);
            }
            // remove sub genres in braces
            if (mSettings.getUnifyBraceGenres()) {
              int brace = genreField.indexOf('(');
              if (brace > 0) {
                genreField = genreField.substring(0, brace).trim();
              }
            }
            // some programs have multiple genres in the field
            final String[] genres = genreField.split(",|/");
            for (int genreIndex = 0; genreIndex < genres.length; genreIndex++) {
              String genre = genres[genreIndex].trim();
              // fix genres ending in dash
              if (genre.endsWith("-")) {
                if (genreIndex < genres.length - 1) {
                  for (String suffix : GENRE_SUFFIX) {
                    if (genres[genreIndex + 1].endsWith(suffix)) {
                      genre = genre.substring(0, genre.length() - 1).trim() + suffix;
                      break;
                    }
                  }
                }
              }
              if (genre.length() >= MIN_GENRE_LENGTH && !hiddenGenres.contains(genre)) {
                PluginTreeNode node = genreNodes.get(genre);
                if (node == null) {
                  node = new PluginTreeNode(genre);
                  formatGenreNode(maxDays, node);
                  genreNodes.put(genre, node);
                  currentGenres.add(genre);
                }
                node.addProgramWithoutCheck(prog);
                progCount++;
              }
            }
          }
        }
      }
      date = date.addDays(1);
      // stop if there are to many nodes for the tree
      if (progCount > 10000) {
        break;
      }
    }
    Collections.sort(currentGenres, String.CASE_INSENSITIVE_ORDER);
    mergeSimilarGenres(genreNodes);
    for (String genre : currentGenres) {
      final PluginTreeNode genreNode = genreNodes.get(genre);
      // the node may be deleted because of merging
      if (genreNode != null) {
        root.add(genreNode);
      }
    }
View Full Code Here

      return;
    }
    if (finalGenre.equals(removedGenre)) {
      return;
    }
    final PluginTreeNode firstNode = genreNodes.get(finalGenre);
    final PluginTreeNode secondNode = genreNodes.get(removedGenre);
    for (Program program : secondNode.getPrograms()) {
      firstNode.addProgram(program);
    }
    // delete the node to mark the genre deleted
    genreNodes.remove(removedGenre);
  }
View Full Code Here

  }

  @Override
  public PluginTreeNode getRootNode() {
    if (mRootNode == null) {
      mRootNode = new PluginTreeNode(this);
      loadRootNode(mRootNode);
      final Node mutableTreeNode = mRootNode.getMutableTreeNode();
      mutableTreeNode.setIcon(
          new ImageIcon(ImageUtilities.createImageFromJar(
              "tvraterplugin/imgs/missingrating.png", TVRaterPlugin.class)));
View Full Code Here

      }
      date = date.addDays(1);
    }

    // now add the title nodes to the plugin tree
    PluginTreeNode topOverall = mRootNode.addNode(mLocalizer.msg("topOverall", "Top programs"));
    PluginTreeNode topAction = mRootNode.addNode(mLocalizer.msg("topAction", "Top action"));
    PluginTreeNode topFun = mRootNode.addNode(mLocalizer.msg("topFun", "Top fun"));
    PluginTreeNode topErotic = mRootNode.addNode(mLocalizer.msg("topErotic", "Top erotic"));
    PluginTreeNode topTension = mRootNode.addNode(mLocalizer.msg("topTension", "Top tension"));
    PluginTreeNode topEntitlement = mRootNode.addNode(mLocalizer.msg("topEntitlement", "Top entitlement"));
    addList(topOverall, listOverall);
    addList(topAction, listAction);
    addList(topFun, listFun);
    addList(topErotic, listErotic);
    addList(topTension, listTension);
    addList(topEntitlement, listEntitlement);

    // add unrated favorites
    PluginTreeNode favoritesNode = mRootNode.addNode(mLocalizer.msg(
        "unratedFavorites", "Unrated favorites"));
    favoritesNode.setGroupingByDateEnabled(false);
    Program[] programs = getPluginManager().getMarkedPrograms();

    // search all unrated favorites
    List<Program> unratedFavs = new ArrayList<Program>();
    for (Program program : programs) {
      if (program.isExpired()) {
        Marker[] markers = program.getMarkerArr();
        for (Marker marker : markers) {
          if (marker.getId()
              .equalsIgnoreCase(FAVORITES_PLUGIN_ID)) {
            if (getPersonalRating(program) == null) {
              unratedFavs.add(program);
            }
            break;
          }
        }
      }
    }
    favoritesNode.addPrograms(unratedFavs);
    mRootNode.update();
  }
View Full Code Here

  private void addTitle(final HashMap<String, HashSet<PluginTreeNode>> titles,
      final ArrayList<PluginTreeNode> list, final Rating rating,
      final int ratingValue) {
    if (ratingValue >= 4) {
      PluginTreeNode titleNode = new PluginTreeNode(rating.getTitle());
      list.add(titleNode);
      titleNode.getMutableTreeNode().setIcon(RatingIconTextFactory.getImageIconForRating(ratingValue));
      HashSet<PluginTreeNode> nodes = titles.get(rating.getTitle());
      if (nodes == null) {
        nodes = new HashSet<PluginTreeNode>();
        titles.put(rating.getTitle(), nodes);
      }
View Full Code Here

   */
  protected void updateTree() {
    if (!mStartFinished) {
      return;
    }
    PluginTreeNode root = getRootNode();
    root.removeAllChildren();
    root.removeAllActions();
    root.getMutableTreeNode().setShowLeafCountEnabled(false);

    for (Program p : getPluginManager().getMarkedPrograms()) {
      if (!mMarkListVector.contains(p)) {
        p.unmark(this);
      } else {
        p.validateMarking();
      }
    }

    if (mMarkListVector.size() == 1) {
      mMarkListVector.getListAt(0).createNodes(root, false);
    } else {
      for (MarkList list : mMarkListVector) {
        PluginTreeNode listNode = root.addNode(list.getName());
        listNode.getMutableTreeNode().setShowLeafCountEnabled(false);
        listNode.getMutableTreeNode().setIcon(list.getMarkIcon());
        listNode.getMutableTreeNode().setProgramReceiveTarget(
            list.getReceiveTarget());
        list.createNodes(listNode, false);
      }
    }
    addGroupingActions(root);
View Full Code Here

    mRootNode = root;
    root.removeAllChildren();

    final SimpleMarkerSettings settings = SimpleMarkerPlugin.getInstance()
        .getSettings();
    PluginTreeNode programRoot = null;
    PluginTreeNode dateRoot = null;
    if (settings.isGroupingByBoth()) {
      programRoot = new PluginTreeNode(Localizer
          .getLocalization(Localizer.I18N_PROGRAMS));
      programRoot.setGroupingByDateEnabled(false);
      dateRoot = new PluginTreeNode(SimpleMarkerPlugin.getLocalizer().msg("days",
          "Days"));
    }

    updateTable();
    Hashtable<String, LinkedList<Program>> sortedPrograms = getSortedPrograms();

    synchronized (sortedPrograms) {
      if (!sortedPrograms.isEmpty()) {
        if (settings.isGroupingByBoth()) {
          dateRoot.addAction(getUnmarkAction(dateRoot));
          programRoot.addAction(getUnmarkAction(programRoot));
        }

        root.removeAllActions();
        root.addAction(getUnmarkAction(root));

        final Date currentDate = Date.getCurrentDate();
        for (Entry<String, LinkedList<Program>> entry : sortedPrograms.entrySet()) {
          String name = entry.getKey();
          LinkedList<Program> sameTitlePrograms = entry.getValue();

          PluginTreeNode titleNode = null;
          if (settings.isGroupingByBoth()) {
            titleNode = programRoot.addNode(name);
          } else if (settings.isGroupingByTitle()) {
            titleNode = root.addNode(name);
          }
          if (titleNode != null) {
            titleNode.addAction(getUnmarkAction(titleNode));
            titleNode.setGroupingByDateEnabled(false);
          }

          for (Program program : sameTitlePrograms) {
            if (titleNode != null) {
              PluginTreeNode prog = titleNode.addProgram(program);
              prog.setNodeFormatter(new NodeFormatter() {
                public String format(ProgramItem pitem) {
                  Program p = pitem.getProgram();
                  Date progDate = p.getDate();
                  String progDateText;
View Full Code Here

  private PluginTreeNode mArtificialRootNode = null;

  protected AbstractPluginProxy() {
    super();
    mArtificialRootNode = new PluginTreeNode(this, false);
  }
View Full Code Here

TOP

Related Classes of devplugin.PluginTreeNode

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.