/** * Implements the <tt>ListCellRenderer</tt> method. Returns this panel that has been configured to * display bundle name, version and description. * * @param table the parent table * @param value the value of the rendered cell * @param isSelected indicates if the rendered cell is selected * @param hasFocus indicates if the rendered cell has the focus * @param rowIndex the row index of the rendered cell * @param vColIndex the column index of the rendered cell * @return the rendering component */ public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { Bundle bundle = (Bundle) value; Dictionary<?, ?> headers = bundle.getHeaders(); Object bundleName = headers.get(Constants.BUNDLE_NAME); Object bundleVersion = headers.get(Constants.BUNDLE_VERSION); Object bundleDescription = headers.get(Constants.BUNDLE_DESCRIPTION); Icon stateIcon = getStateIcon(bundle.getState()); if (bundleName != null) this.nameLabel.setText(bundleName.toString()); else this.nameLabel.setText("unknown"); if (bundleVersion != null) this.versionLabel.setText(bundleVersion.toString()); else this.versionLabel.setText(""); if (bundleDescription != null) this.descriptionLabel.setText(bundleDescription.toString()); else this.descriptionLabel.setText(""); if (stateIcon != null) this.stateLabel.setIcon(stateIcon); this.nameVersionPanel.remove(systemLabel); if (PluginManagerActivator.isSystemBundle(bundle)) this.nameVersionPanel.add(systemLabel); this.isSelected = isSelected; return this; }
/** * Updates the UIs for the labels in the label table by calling {@code updateUI} on each label. * The UIs are updated from the current look and feel. The labels are also set to their preferred * size. * * @see #setLabelTable * @see JComponent#updateUI */ protected void updateLabelUIs() { Dictionary labelTable = getLabelTable(); if (labelTable == null) { return; } Enumeration labels = labelTable.keys(); while (labels.hasMoreElements()) { JComponent component = (JComponent) labelTable.get(labels.nextElement()); component.updateUI(); component.setSize(component.getPreferredSize()); } }