コード例 #1
0
ファイル: SchemaBox.java プロジェクト: KenaDess/limewire
  /**
   * Adds the given NamedMediaType.
   *
   * <p>Marks the 'Any Type' as selected.
   */
  private void addMediaType(NamedMediaType type, String toolTip) {
    Icon icon = type.getIcon();
    Icon disabledIcon = null;
    Icon rolloverIcon = null;
    AbstractButton button = new JRadioButton(type.getName());
    button.putClientProperty(MEDIA, type);
    button.putClientProperty(SELECTED, icon);
    if (icon != null) {
      disabledIcon = ImageManipulator.darken(icon);
      rolloverIcon = ImageManipulator.brighten(icon);
    }
    button.putClientProperty(DESELECTED, disabledIcon);
    button.setIcon(disabledIcon);
    button.setRolloverIcon(rolloverIcon);
    button.addItemListener(HIGHLIGHTER);
    button.setBorderPainted(false);
    button.setFocusPainted(false);
    button.setContentAreaFilled(false);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setOpaque(false);
    button.addMouseListener(CLICK_FORWARDER);
    button.setPreferredSize(new Dimension(100, 22));
    if (toolTip != null) {
      button.setToolTipText(toolTip);
    }
    GROUP.add(button);

    DitherPanel panel = new DitherPanel(DITHERER);
    panel.setDithering(false);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT, 7, 1));
    panel.add(button);
    panel.addMouseListener(CLICK_FORWARDER);
    panel.setBackground(UIManager.getColor("TabbedPane.background"));
    SCHEMAS.add(panel);

    if (type.getMediaType() == MediaType.getAnyTypeMediaType()) button.setSelected(true);
    else button.setSelected(false);
  }
コード例 #2
0
  /** Initializes this line with the specified search result. */
  public void initialize(UISearchResult sr) {
    super.initialize(sr);

    RESULT = sr;
    _mediaType = NamedMediaType.getFromExtension(getExtension());
    addedOn = sr.getCreationTime() > 0 ? new Date(sr.getCreationTime()) : null;
    actionsHolder = new SearchResultActionsHolder(sr);
    name = new SearchResultNameHolder(sr);
    seeds =
        RESULT.getSeeds() <= 0 || !(RESULT instanceof TorrentUISearchResult)
            ? ""
            : String.valueOf(RESULT.getSeeds());
    icon = getIcon();
    size = new SizeHolder(getSize());
    source = new SourceHolder(RESULT);
  }
コード例 #3
0
ファイル: SchemaBox.java プロジェクト: KenaDess/limewire
  /** Constructs the SchemaBox. */
  SchemaBox() {
    List<NamedMediaType> allSchemas = NamedMediaType.getAllNamedMediaTypes();
    int cols, rows;
    cols = 2;
    rows = (int) Math.ceil(allSchemas.size() / 2.0);
    SCHEMAS.setBackground(ThemeFileHandler.SEARCH_GRID_COLOR.getValue());
    SCHEMAS.setLayout(new GridLayout(rows, cols, 1, 1));
    SCHEMAS.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    addSchemas(allSchemas);

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(new JLabel(SELECT_TYPE));
    add(panel);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JPanel p = new BoxPanel(BoxPanel.X_AXIS);
    p.add(SCHEMAS);
    p.add(Box.createHorizontalStrut(1));
    add(p);
  }
コード例 #4
0
ファイル: SchemaBox.java プロジェクト: KenaDess/limewire
  /** Adds the given schemas as radio buttons. */
  private void addSchemas(List<? extends NamedMediaType> schemas) {
    // We first add specific ones in a certain order.
    // After that, leave it to random chance.
    NamedMediaType current;

    // First add 'Any Type'
    current = NamedMediaType.getFromDescription(MediaType.SCHEMA_ANY_TYPE);
    schemas.remove(current);
    addMediaType(current);

    // Then add 'Audio'
    current = NamedMediaType.getFromDescription(MediaType.SCHEMA_AUDIO);
    schemas.remove(current);
    addMediaType(current, I18n.tr("Search For Audio Files, Including mp3, wav, ogg, and More"));

    // Then add 'Images'
    current = NamedMediaType.getFromDescription(MediaType.SCHEMA_IMAGES);
    schemas.remove(current);
    addMediaType(current, I18n.tr("Search For Image Files, Including jpg, gif, png and More"));

    // Then add 'Video'
    current = NamedMediaType.getFromDescription(MediaType.SCHEMA_VIDEO);
    schemas.remove(current);
    addMediaType(current, I18n.tr("Search For Video Files, Including avi, mpg, wmv, and More"));

    // Then add 'Documents'
    current = NamedMediaType.getFromDescription(MediaType.SCHEMA_DOCUMENTS);
    schemas.remove(current);
    addMediaType(current, I18n.tr("Search for Document Files, Including html, txt, pdf, and More"));

    // Then add 'Programs'
    current = NamedMediaType.getFromDescription(MediaType.SCHEMA_PROGRAMS);
    schemas.remove(current);
    addMediaType(current, I18n.tr("Search for Program Files, Including exe, zip, gz, and More"));

    // Then add anything that was left.
    for (NamedMediaType nmt : schemas) addMediaType(nmt);
  }
コード例 #5
0
ファイル: SchemaBox.java プロジェクト: KenaDess/limewire
 /** Returns the selected item's media type. */
 public MediaType getSelectedMediaType() {
   NamedMediaType nmt = getSelectedMedia();
   if (nmt == null) return null;
   return nmt.getMediaType();
 }
コード例 #6
0
ファイル: SchemaBox.java プロジェクト: KenaDess/limewire
 /** Returns the description of the selected item. */
 public String getSelectedItem() {
   NamedMediaType nmt = getSelectedMedia();
   if (nmt == null) return null;
   return nmt.getName();
 }
コード例 #7
0
ファイル: SchemaBox.java プロジェクト: KenaDess/limewire
  /** Returns the selected schema, or null if the selected item has no schema. */
  public LimeXMLSchema getSelectedSchema() {
    NamedMediaType nmt = getSelectedMedia();
    if (nmt == null) return null;

    return nmt.getSchema();
  }
コード例 #8
0
ファイル: SchemaBox.java プロジェクト: KenaDess/limewire
  /** Returns the selected icon, or null if the selection has no icon. */
  public Icon getSelectedIcon() {
    NamedMediaType nmt = getSelectedMedia();
    if (nmt == null) return null;

    return nmt.getIcon();
  }