Simplify plugin-cell rendering to avoid clipping the description text

cusax-fix
Ingo Bauersachs 12 years ago
parent 8b09d84210
commit bd105ca4a9

@ -46,19 +46,9 @@ public class PluginListCellRenderer
= new Color(Resources.getColor("service.gui.GRADIENT_LIGHT_COLOR")); = new Color(Resources.getColor("service.gui.GRADIENT_LIGHT_COLOR"));
/** /**
* The panel containing name and version information. * The name and version label.
*/ */
private JPanel nameVersionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); private JLabel nameVersionLabel = new JLabel();
/**
* The name label.
*/
private JLabel nameLabel = new JLabel();
/**
* The version label.
*/
private JLabel versionLabel = new JLabel();
/** /**
* The description label. * The description label.
@ -70,18 +60,6 @@ public class PluginListCellRenderer
*/ */
private JLabel stateLabel = new JLabel(); private JLabel stateLabel = new JLabel();
/**
* The icon label.
*/
private JLabel iconLabel = new JLabel();
/**
* The system label indicating that a bundle is system (i.e. not optional).
*/
private JLabel systemLabel
= new JLabel("( " + Resources.getString("plugin.pluginmanager.SYSTEM")
+ " )");
/** /**
* Indicates if a skin is selected. * Indicates if a skin is selected.
*/ */
@ -101,33 +79,13 @@ public class PluginListCellRenderer
*/ */
public PluginListCellRenderer() public PluginListCellRenderer()
{ {
super(new BorderLayout(8, 8)); super(new BorderLayout(8, 0));
this.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
JPanel mainPanel = new JPanel(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
this.setBackground(Color.WHITE); this.setBackground(Color.WHITE);
this.setOpaque(true); JPanel mainPanel = new TransparentPanel(new GridLayout(2, 1));
mainPanel.add(nameVersionLabel);
mainPanel.setOpaque(false); mainPanel.add(descriptionLabel);
this.nameVersionPanel.setOpaque(false);
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
this.nameLabel.setIconTextGap(2);
this.nameLabel.setFont(this.getFont().deriveFont(Font.BOLD));
this.systemLabel.setFont(this.getFont().deriveFont(Font.BOLD));
this.nameVersionPanel.add(nameLabel);
this.nameVersionPanel.add(versionLabel);
mainPanel.add(nameVersionPanel, BorderLayout.NORTH);
mainPanel.add(descriptionLabel, BorderLayout.CENTER);
this.add(iconLabel, BorderLayout.WEST);
this.add(mainPanel, BorderLayout.CENTER); this.add(mainPanel, BorderLayout.CENTER);
this.add(stateLabel, BorderLayout.WEST); this.add(stateLabel, BorderLayout.WEST);
@ -157,15 +115,20 @@ public Component getTableCellRendererComponent(JTable table, Object value,
Icon stateIcon = getStateIcon(bundle.getState()); Icon stateIcon = getStateIcon(bundle.getState());
if(bundleName != null) StringBuilder sb = new StringBuilder();
this.nameLabel.setText(bundleName.toString()); sb.append("<html><nobr><b>");
else sb.append(bundleName != null ? bundleName.toString() : "unknown");
this.nameLabel.setText("unknown"); sb.append("</b> ");
sb.append(bundleVersion != null ? bundleVersion.toString() : "");
if (PluginManagerActivator.isSystemBundle(bundle))
{
sb.append(" <b>(");
sb.append(Resources.getString("plugin.pluginmanager.SYSTEM"));
sb.append(")</b>");
}
if(bundleVersion != null) sb.append("</nobr></html>");
this.versionLabel.setText(bundleVersion.toString()); this.nameVersionLabel.setText(sb.toString());
else
this.versionLabel.setText("");
if(bundleDescription != null) if(bundleDescription != null)
this.descriptionLabel.setText(bundleDescription.toString()); this.descriptionLabel.setText(bundleDescription.toString());
@ -175,11 +138,6 @@ public Component getTableCellRendererComponent(JTable table, Object value,
if(stateIcon != null) if(stateIcon != null)
this.stateLabel.setIcon(stateIcon); this.stateLabel.setIcon(stateIcon);
this.nameVersionPanel.remove(systemLabel);
if(PluginManagerActivator.isSystemBundle(bundle))
this.nameVersionPanel.add(systemLabel);
this.isSelected = isSelected; this.isSelected = isSelected;
return this; return this;

Loading…
Cancel
Save