public ConnectionColumn() {
        super(_GUI._.ConnectionColumn_ConnectionColumn(), null);
        panel = new RendererMigPanel("ins 0 0 0 0", "[]", "[grow,fill]");
        labels = new RenderLabel[DEFAULT_ICON_COUNT + 1];

        // panel.add(Box.createGlue(), "pushx,growx");
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i <= DEFAULT_ICON_COUNT; i++) {
            labels[i] = new RenderLabel();
            // labels[i].setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1,
            // Color.RED));
            labels[i].setOpaque(false);
            labels[i].setBackground(null);
            if (sb.length() > 0) sb.append("1");
            sb.append("[18!]");
            panel.add(labels[i]);

        }
        dlWatchdog = DownloadWatchDog.getInstance();
        skipped = NewTheme.I().getIcon("skipped", 16);
        forced = NewTheme.I().getIcon("media-playback-start_forced", 16);
        resumeIndicator = NewTheme.I().getIcon("refresh", 16);
        directConnection = NewTheme.I().getIcon("modem", 16);
        proxyConnection = NewTheme.I().getIcon("proxy_rotate", 16);
        accountInUse = NewTheme.I().getIcon("users", 16);
        connections = NewTheme.I().getIcon("paralell", 16);
        panel.setLayout(new MigLayout("ins 0 0 0 0", sb.toString(), "[]"));
        // panel.add(Box.createGlue(), "pushx,growx");
        this.setRowSorter(new ExtDefaultRowSorter<AbstractNode>() {

            @Override
            public int compare(final AbstractNode o1, final AbstractNode o2) {
                final long l1 = getDownloads(o1);
                final long l2 = getDownloads(o2);
                if (l1 == l2) { return 0; }
                if (this.getSortOrderIdentifier() == ExtColumn.SORT_ASC) {
                    return l1 > l2 ? -1 : 1;
                } else {
                    return l1 < l2 ? -1 : 1;
                }
            }

        });

        resetRenderer();
    }
示例#2
0
 @Override
 public synchronized void removeMouseListener(final MouseListener l) {
   this.txt.removeMouseListener(l);
   this.bt.removeMouseListener(l);
   super.removeMouseListener(l);
 }
示例#3
0
 @Override
 public synchronized void addMouseListener(final MouseListener l) {
   this.txt.addMouseListener(l);
   this.bt.addMouseListener(l);
   super.addMouseListener(l);
 }
示例#4
0
 @Override
 public void setEnabled(final boolean b) {
   editor.setEnabled(b);
   renderer.setEnabled(b);
   super.setEnabled(b);
 }
  public AbstractOverviewPanel(PackageControllerTableModel tableModel) {
    super("ins 0", "[][grow,fill][]", "[grow,fill]");
    this.tableModel = tableModel;
    LAFOptions.getInstance().applyPanelBackground(this);
    GUIEventSender.getInstance().addListener(this, true);
    final MigPanel info = new MigPanel("ins 2 0 0 0", "[grow]10[grow]", "[grow,fill]2[grow,fill]");
    info.setOpaque(false);
    relayoutListener =
        new GenericConfigEventListener<Boolean>() {

          @Override
          public void onConfigValueModified(KeyHandler<Boolean> keyHandler, Boolean newValue) {
            new EDTRunner() {

              @Override
              protected void runInEDT() {
                layoutInfoPanel(info);
                update();

                revalidate();
              }
            };
          }

          @Override
          public void onConfigValidatorError(
              KeyHandler<Boolean> keyHandler,
              Boolean invalidValue,
              ValidationException validateException) {}
        };
    layoutInfoPanel(info);
    add(info, "pushy,growy");
    slowDelayer =
        new DelayedRunnable(SERVICE, 500, 5000) {

          @Override
          public void delayedrun() {
            update();
          }
        };
    fastDelayer =
        new DelayedRunnable(SERVICE, 50, 200) {

          @Override
          public void delayedrun() {
            update();
          }
        };
    CFG_GUI.OVERVIEW_PANEL_TOTAL_INFO_VISIBLE.getEventSender().addListener(this, true);
    CFG_GUI.OVERVIEW_PANEL_SELECTED_INFO_VISIBLE.getEventSender().addListener(this, true);
    CFG_GUI.OVERVIEW_PANEL_VISIBLE_ONLY_INFO_VISIBLE.getEventSender().addListener(this, true);

    CFG_GUI.OVERVIEW_PANEL_SMART_INFO_VISIBLE.getEventSender().addListener(this, true);

    this.addHierarchyListener(this);
    onConfigValueModified(null, null);

    SecondLevelLaunch.GUI_COMPLETE.executeWhenReached(
        new Runnable() {

          public void run() {
            visible.set(isViewActive());
            fastDelayer.run();
          }
        });
    onConfigValueModified(null, null);
  }
  protected void layoutInfoPanel(MigPanel info) {
    info.removeAll();
    HashMap<String, Position> map = CFG_GUI.CFG.getOverviewPositions();
    boolean save = false;
    if (map == null) {
      map = new HashMap<String, Position>();
      save = true;
    }
    HashMap<String, DataEntry<T>> idMap = new HashMap<String, DataEntry<T>>();
    this.dataEntries = new ArrayList<DataEntry<T>>();
    for (DataEntry<T> s : createDataEntries()) {
      Position ret = map.get(s.getId());
      if (ret == null) {
        ret = new Position();
        map.put(s.getId(), ret);
        save = true;
      }
      idMap.put(s.getId(), s);
      if (s.getVisibleKeyHandler() == null || s.getVisibleKeyHandler().isEnabled()) {
        dataEntries.add(s);
      }
      if (s.getVisibleKeyHandler() != null) {
        s.getVisibleKeyHandler().getEventSender().addListener(relayoutListener);
      }
    }
    // selected
    // filtered
    // speed
    // eta

    ArrayList<DataEntry<T>> row1 = new ArrayList<DataEntry<T>>();
    ArrayList<DataEntry<T>> row2 = new ArrayList<DataEntry<T>>();

    for (Entry<String, Position> es : map.entrySet()) {
      DataEntry<T> v = idMap.get(es.getKey());
      if (v == null) {
        continue;
      }
      int x = es.getValue().getX();
      int y = es.getValue().getY();
      ArrayList<DataEntry<T>> row;
      if (y == 0) {
        row = row1;
      } else {
        row = row2;
      }
      while (x >= 0 && y >= 0) {
        while (x >= row.size()) {
          row.add(null);
        }
        if (row.get(x) != null) {
          x++;
          continue;
        }

        row.set(x, v);
        idMap.remove(v.getId());
        break;
      }
    }

    addloop:
    for (int i = 0; i < dataEntries.size(); i++) {
      DataEntry<T> v = dataEntries.get(i);
      if (!idMap.containsKey(v.getId())) {
        continue;
      }

      if (i % 2 == 0) {
        int index = 0;
        while (true) {
          while (index >= row1.size()) {
            row1.add(null);
          }
          if (row1.get(index) == null) {
            row1.set(index, v);
            continue addloop;
          } else {
            index++;
          }
        }

      } else {
        int index = 0;
        while (true) {
          while (index >= row2.size()) {
            row2.add(null);
          }
          if (row2.get(index) == null) {
            row2.set(index, v);
            continue addloop;
          } else {
            index++;
          }
        }
      }
    }

    if (save) {
      CFG_GUI.CFG.setOverviewPositions(map);
    }

    for (DataEntry<T> de : row1) {
      if (de == null) {
        continue;
      }
      de.addTo(info);
    }

    boolean first = true;
    for (DataEntry<T> de : row2) {
      if (de == null) {
        continue;
      }
      if (first) {
        de.addTo(info, ",newline");
      } else {
        de.addTo(info);
      }

      first = false;
    }
  }