Beispiel #1
0
 public JobStatusBar(JobManager jobManager, boolean alwaysVisible) {
   super(new GridBagLayout());
   this.jobManager = jobManager;
   this.alwaysVisible = alwaysVisible;
   jobManager.addChangeListener(managerListener);
   updateComponents();
 }
Beispiel #2
0
  protected void updateComponents() {
    setVisible(alwaysVisible || jobManager.isActive());
    Job[] jobs = jobManager.getActiveJobs();
    List<JobPanel> toKeep = new ArrayList<JobPanel>();
    int toRemoveCtr = 0;
    for (int a = 0; a < getComponentCount(); a++) {
      Component c = getComponent(a);
      if (c instanceof JobPanel) {
        JobPanel jp = (JobPanel) c;
        int i = getIndex(jobs, jp.job);
        if (i != -1) {
          toKeep.add(jp);
          jobs[i] = null;
        } else {
          toRemoveCtr++;
        }
      }
    }
    if (toKeep.size() == jobs.length && toRemoveCtr == 0) return;

    removeAll();
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    for (JobPanel jp : toKeep) {
      add(jp, c);
      c.gridy++;
    }
    for (int a = 0; a < jobs.length; a++) {
      if (jobs[a] != null) {
        add(new JobPanel(jobs[a]), c);
        c.gridy++;
      }
    }
    c.weighty = 1;
    fluff.setOpaque(false);
    add(fluff, c);
    revalidate();
  }