Package devplugin

Examples of devplugin.Program


  private void addToPrograms(int indexFirst, int indexLast) {
    ListModel list = getModel();
    for (int i = indexFirst; i <= indexLast; i++) {
      Object element = list.getElementAt(i);
      if (element instanceof Program) {
        Program prg = (Program) element;
        prg.addChangeListener(this);
        mPrograms.add(prg);
      }
    }
  }
View Full Code Here


    int inx = locationToIndex(e.getPoint());
    setSelectedIndex(inx);

    if (getModel().getElementAt(inx) instanceof Program) {
      Program prog = (Program) getModel().getElementAt(inx);
      JPopupMenu menu = mng.createPluginContextMenu(prog, caller);
      menu.show(ProgramList.this, e.getX() - 15, e.getY() - 15);
    }
  }
View Full Code Here

    mTitleIcon = new TextAreaIcon(null, mTitleFont, WIDTH_RIGHT - 5);
    mDescriptionIcon = new TextAreaIcon(null, mNormalFont, WIDTH_RIGHT - 5);
    mDescriptionIcon.setMaximumLineCount(Settings.propProgramPanelMaxLines
        .getInt());
    mProgram.validateMarking();
    Program p = mProgram;
    mProgram = null;
    setProgram(p);
  }
View Full Code Here

   *          The program to show in this panel.
   * @param maxHeight
   *          The maximum height the program should have (in pixels).
   */
  public void setProgram(Program program, int maxHeight) {
    Program oldProgram = mProgram;
    mProgram = program;

    if (Settings.propProgramTableCutTitle.getBoolean()) {
      mTitleIcon.setMaximumLineCount(Settings.propProgramTableCutTitleLines
          .getInt());
    } else {
      mTitleIcon.setMaximumLineCount(-1);
    }
    mDescriptionIcon.setMaximumLineCount(-1);

    boolean programChanged = (oldProgram != program);
    if (programChanged) {
      // Get the start time, filter duplicate strings
      mProgramTimeAsString = StringPool.getString(program.getTimeString());

      // Set the new title
      mTitleIcon.setText(program.getTitle());

      if(mProgram.getProgramState() == Program.IS_VALID_STATE) {
        programHasChanged();
      }
    }

    boolean dontShow = true;

    if(mSettings.isShowingPictureForPlugins()) {
      String[] pluginIds = mSettings.getPluginIds();
      Marker[] markers = mProgram.getMarkerArr();

      if(markers != null && pluginIds != null) {
        for (Marker marker : markers) {
          for (String pluginId : pluginIds) {
            if(marker.getId().compareTo(pluginId) == 0) {
              dontShow = false;
              break;
            }
          }
        }
      }
    }

    // Create the picture area icon
    int length = program.getLength();
    if (!mSettings.isShowingOnlyDateAndTitle()
        && mProgram.hasFieldValue(ProgramFieldType.PICTURE_TYPE)
        && (
        mSettings.isShowingPictureEver() || !dontShow ||
        (mSettings.isShowingPictureInTimeRange() &&
         !ProgramUtilities.isNotInTimeRange(mSettings.getPictureTimeRangeStart(),mSettings.getPictureTimeRangeEnd(),program)) ||
         (mSettings
            .isShowingPictureForDuration() && mSettings.getDuration() <= length)
         )) {
      mPictureAreaIcon = new PictureAreaIcon(program,mNormalFont, WIDTH_RIGHT - 4, mSettings.isShowingPictureDescription(), true, false);
    } else {
      mPictureAreaIcon = new PictureAreaIcon();
    }

    // Calculate the maximum description lines
    int titleHeight = mTitleIcon.getIconHeight();
    int maxDescLines;
    if (Settings.propProgramPanelShortDurationActive.getBoolean()
        && length >= 0
        && length <= Settings.propProgramPanelShortDurationMinutes.getInt()) {
      maxDescLines = 0;
      mDescriptionIcon.setText("");
      mDescriptionIcon.setMaximumLineCount(0);
    } else {
      maxDescLines = Settings.propProgramPanelMaxLines.getInt();
    }
    int additionalHeight = Settings.propProgramPanelUsesExtraSpaceForMarkIcons.getBoolean() && program.getMarkerArr().length > 0 ? 16 : 0;

    if (maxHeight != -1) {
      maxDescLines = (maxHeight - titleHeight - mPictureAreaIcon.getIconHeight() - additionalHeight - V_GAP) / mNormalFont.getSize();
    }

    if (programChanged
        || (maxDescLines != mDescriptionIcon.getMaximumLineCount())) {
      int descHeight = 0;
      // (Re)set the description text
      if (!mSettings.isShowingOnlyDateAndTitle() && maxDescLines > 0) {
        mDescriptionIcon.setMaximumLineCount(maxDescLines);
        ProgramFieldType[] infoFieldArr = Settings.propProgramInfoFields
            .getProgramFieldTypeArray();
        Reader infoReader = new MultipleFieldReader(program, infoFieldArr);
        try {
          mDescriptionIcon.setText(infoReader);
        } catch (IOException exc) {
          mLog.log(Level.WARNING, "Reading program info failed for " + program,
              exc);
        }
        descHeight = mDescriptionIcon.getIconHeight();
      } else {
        descHeight = 0;
      }

      // Calculate the height
      mHeight = titleHeight + descHeight + mPictureAreaIcon.getIconHeight() + additionalHeight + V_GAP;
      setPreferredSize(new Dimension(WIDTH_TOTAL, mHeight));

      // Calculate the preferred height
      mPreferredHeight = titleHeight + (maxDescLines * mNormalFont.getSize()) + mPictureAreaIcon.getIconHeight() + additionalHeight + V_GAP;

      if (mHeight < mPreferredHeight) {
        mPreferredHeight = mHeight;
      }
    }

    if (isShowing()) {
      if (oldProgram != null) {
        oldProgram.removeChangeListener(this);
      }
      mProgram.addChangeListener(this);
      revalidate();
      repaint();
    }
View Full Code Here

    mTitleIcon = new TextAreaIcon(null, mTitleFont, textIconWidth);
    mDescriptionIcon = new TextAreaIcon(null, mNormalFont, textIconWidth);
    mDescriptionIcon.setMaximumLineCount(3);
    if (mProgram != null) {
      mProgram.validateMarking();
      Program p = mProgram;
      mProgram = null;
      setProgram(p);
    }
  }
View Full Code Here

          out.println("BEGIN:VCALENDAR");
          out.println("PRODID:-//TV-Browser//Calendar Export Plugin");
          printVersion(out);

          for (int i = 0; i < list.length; i++) {
            Program p = list[i];

            out.println();
            out.println("BEGIN:VEVENT");

            Calendar c = Calendar.getInstance();

            printCreated(out, mDate.format(c.getTime()) + "T"
                + mTime.format(c.getTime()), i);

            if (settings.isClassificationPrivate()) {
              out.println("CLASS:PRIVATE");
            }
            else if (settings.isClassificationConfidential()) {
              out.println("CLASS:CONFIDENTIAL");
            }
            else if (settings.isClassificationPublic()) {
              out.println("CLASS:PUBLIC");
            }

            out.println("PRIORITY:3");

            String category = settings.getCategory().trim();
            if (category.length() > 0) {
              out.println("CATEGORIES:" + category);
            }

            c = CalendarToolbox.getStartAsCalendar(p);

            out.println("UID:" + mDate.format(c.getTime()) + "-" + p.getID());

            String summary = parser.analyse(formatting.getTitleValue(), p);

            out.println("SUMMARY:" + CalendarToolbox.noBreaks(summary));
View Full Code Here

      boolean cellHasFocus) {
    JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

    if (value instanceof Program) {

      Program program = (Program) value;
      Insets borderInsets = label.getBorder().getBorderInsets(label);
      mProgramPanel.setWidth(list.getWidth() - borderInsets.left - borderInsets.right);
      mProgramPanel.setProgram(program);
      mProgramPanel.setPaintExpiredProgramsPale(!isSelected);
      mProgramPanel.setTextColor(label.getForeground());
      mProgramPanel.setBackground(label.getBackground());

      if (!mProgramSet.contains(program)) {
        mProgramSet.add(program);
        program.addChangeListener(new ProgramListChangeListener(list));
      }

      StringBuilder labelString = new StringBuilder();
      int days = program.getDate().getNumberOfDaysSince(Date.getCurrentDate());

      switch (days) {
      case -1: {
        labelString.append(Localizer.getLocalization(Localizer.I18N_YESTERDAY));
        labelString.append(", ").append(program.getDateString());
        break;
      }
      case 0: {
        labelString.append(Localizer.getLocalization(Localizer.I18N_TODAY));
        labelString.append(", ").append(program.getDateString());
        break;
      }
      case 1: {
        labelString.append(Localizer.getLocalization(Localizer.I18N_TOMORROW));
        labelString.append(", ").append(program.getDateString());
        break;
      }
      default: {
        labelString.append(program.getDate().toString());
      }
      }

      labelString.append(" - ").append(program.getChannel().getName());
      mHeaderLb.setText(labelString.toString());

      if (program.isExpired() && !isSelected) {
        mHeaderLb.setForeground(Color.gray);
      } else {
        mHeaderLb.setForeground(label.getForeground());
      }

      mMainPanel.setBackground(label.getBackground());

      if (isSelected) {
        mMainPanel.setForeground(label.getForeground());
      }

      mMainPanel.setEnabled(label.isEnabled());
      mMainPanel.setBorder(label.getBorder());

      if (((index & 1) == 1) && (!isSelected) && program.getMarkPriority() < Program.MIN_MARK_PRIORITY) {
        mMainPanel.setBackground(program.isExpired() ? SECOND_ROW_COLOR_EXPIRED : SECOND_ROW_COLOR);
      }

      return mMainPanel;
    }
View Full Code Here

    public void stateChanged(ChangeEvent e) {
      if (mList != null) {
        Object source = e.getSource();
        if (source instanceof Program) {
          Program program = (Program) source;
          AbstractListModel model = (AbstractListModel) mList.getModel();
          ListDataListener[] listeners = model.getListDataListeners();
          int itemIndex = -1;
          for (int i = 0; i < model.getSize(); i++) {
            if (model.getElementAt(i) == program) {
View Full Code Here

          for (int i = 0; i <= days; i++) {
            Iterator<Program> it = Plugin.getPluginManager().getChannelDayProgram(new Date(runner), tvbchannel);
            boolean found = false;

            while (it.hasNext() && !found) {
              Program prog = it.next();
              int progTime = prog.getHours() * 60 + prog.getMinutes() + (i * 24 * 60);

              if (progTime >= beginMinutes - 15 && progTime <= endMinutes + 15
                  && prog.getTitle().trim().equalsIgnoreCase(timer.get("e2name").trim())) {

                found = true;
                programs.add(new ProgramTime(prog, begin.getTime(), end.getTime()));
              }
            }
View Full Code Here

    public Component getTableCellRendererComponent(final JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
       
        if (value instanceof Program) {
            Program program = (Program) value;
            Insets borderInsets = label.getBorder().getBorderInsets(label);
            mProgramPanel.setWidth(table.getCellRect(row, column, false).width - borderInsets.left - borderInsets.right);
            mProgramPanel.setProgram(program);
           
            program.addChangeListener(new ChangeListener() {
              public void stateChanged(ChangeEvent e) {
                table.repaint();
              }
            });
           
            mProgramPanel.setPaintExpiredProgramsPale(!isSelected);
            mProgramPanel.setTextColor(label.getForeground());
            mProgramPanel.setBackground(label.getBackground());
           
            String dateString;
           
            if(program.getDate().equals(Date.getCurrentDate().addDays(-1))) {
              dateString = Localizer.getLocalization(Localizer.I18N_YESTERDAY);
            }
            else if(program.getDate().equals(Date.getCurrentDate())) {
              dateString = Localizer.getLocalization(Localizer.I18N_TODAY);
            }
            else if(program.getDate().equals(Date.getCurrentDate().addDays(1))) {
              dateString = Localizer.getLocalization(Localizer.I18N_TOMORROW);
            }
            else {
              dateString = program.getDate().toString();
            }
           
            mHeaderLb.setText(dateString + " - " + program.getChannel().getName());
           
            if(program.isExpired() && !isSelected) {
              mHeaderLb.setForeground(Color.gray);
            }
            else {
              mHeaderLb.setForeground(label.getForeground());
            }
View Full Code Here

TOP

Related Classes of devplugin.Program

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.