/** Set what actions are available depending on state */
 private void setAvailableActions() {
   int sel = table.getSelectedRow();
   if (sel != -1) {
     PluginDefinition def = model.getPluginDefinitionAt(sel);
     info.setText(def.getInformation());
     url.setText(def.getURL());
     removeAction.setEnabled(def.getStatus() != NOT_INSTALLED);
     installAction.setEnabled(def.getStatus() == NOT_INSTALLED);
     updateAction.setEnabled(def.getStatus() == UPDATE_AVAILABLE);
     configureAction.setEnabled(
         def.getStatus() != NOT_INSTALLED && def.getPlugin() instanceof ConfigurablePlugin);
   } else {
     info.setText(" ");
     url.setText(" ");
     removeAction.setEnabled(false);
     installAction.setEnabled(false);
     updateAction.setEnabled(false);
     configureAction.setEnabled(false);
   }
   refresh.setEnabled(!updating);
 }
  /**
   * Creates a new PluginManagerPane object.
   *
   * @param manager the plugin mananager
   * @param context context
   */
  public PluginManagerPane(
      PluginManager manager, PluginHostContext context, boolean showBuiltInPlugins) {
    super(new BorderLayout());

    // Initialise
    this.context = context;
    this.showBuiltInPlugins = showBuiltInPlugins;
    this.manager = manager;

    // Connection state
    JPanel sp = new JPanel(new BorderLayout());
    sp.setOpaque(false);
    sp.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Plugin updates"),
            BorderFactory.createEmptyBorder(4, 4, 4, 4)));
    status = new JLabel("Click on Refresh to check for new plugins and updates", JLabel.LEFT);
    status.setIcon(IDLE_ICON);
    sp.add(status, BorderLayout.CENTER);
    refresh = new JButton("Refresh");
    refresh.setMnemonic('r');
    refresh.addActionListener(this);
    sp.add(refresh, BorderLayout.EAST);

    // Create the toolbar
    JToolBar toolBar = new JToolBar("Plugin manager tools");
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
    toolBar.setBorder(null);
    toolBar.setFloatable(false);
    toolBar.add(new ToolButton(installAction = new InstallAction(), false));
    toolBar.add(new ToolButton(updateAction = new UpdateAction(), false));
    toolBar.add(new ToolButton(removeAction = new RemoveAction(), false));
    toolBar.add(new ToolButton(configureAction = new ConfigureAction(), false));

    // Create the text area
    table =
        new PluginManagerTable(model = new PluginManagerTableModel()) {
          public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, 180);
          }
        };
    table.setBorder(null);
    table.getSelectionModel().addListSelectionListener(this);

    // Information panel
    JPanel ip = new JPanel(new BorderLayout());
    ip.setOpaque(false);
    // ip.setBorder(BorderFactory.createTitledBorder("Information"));
    ip.add(new JLabel(INFORMATION_ICON), BorderLayout.WEST);
    JPanel tp =
        new JPanel(new BorderLayout()) {
          public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, 72);
          }
        };
    tp.setOpaque(false);
    tp.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    url = new JLabel(" ", JLabel.CENTER);
    url.setFont(url.getFont().deriveFont(Font.BOLD).deriveFont(12f));
    url.setForeground(Color.blue);
    url.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    url.setBorder(BorderFactory.createEmptyBorder(4, 0, 4, 0));
    url.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent evt) {
            try {
              PluginManagerPane.this.context.openURL(new URL(url.getText()));
            } catch (Exception e) {
            }
          }
        });
    tp.add(url, BorderLayout.SOUTH);
    info =
        new JTextArea(" ") {
          public Dimension getPreferredSize() {
            return new Dimension(400, 130);
          }
        };
    info.setOpaque(false);
    info.setWrapStyleWord(true);
    info.setLineWrap(true);
    info.setEditable(false);
    info.setFont(UIManager.getFont("Label.font"));
    tp.add(info, BorderLayout.CENTER);
    ip.add(tp, BorderLayout.CENTER);

    // Build this
    add(sp, BorderLayout.NORTH);
    add(
        new ToolBarTablePane(toolBar, table) {
          public Dimension getPreferredSize() {
            return new Dimension(480, 260);
          }
        },
        BorderLayout.CENTER);
    add(ip, BorderLayout.SOUTH);

    // Create the progress dialog
    JPanel progressPanel = new JPanel(new BorderLayout());
    progressPanel.setOpaque(false);
    Window parentWindow = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
    if (parentWindow instanceof JFrame)
      progressDialog = new JDialog((JFrame) parentWindow, "Downloading", true);
    else if (parentWindow instanceof JDialog)
      progressDialog = new JDialog((JDialog) parentWindow, "Downloading", true);
    else progressDialog = new JDialog((JFrame) null, "Downloading", true);
    JPanel progressDetailPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    jGridBagAdd(progressDetailPanel, status1Text = new JLabel(), gbc, GridBagConstraints.REMAINDER);
    jGridBagAdd(progressDetailPanel, status2Text = new JLabel(), gbc, GridBagConstraints.REMAINDER);
    jGridBagAdd(
        progressDetailPanel, progress = new JProgressBar(), gbc, GridBagConstraints.REMAINDER);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 1.0;
    jGridBagAdd(
        progressDetailPanel,
        cancelDownload = new JButton("Cancel"),
        gbc,
        GridBagConstraints.REMAINDER);
    cancelDownload.addActionListener(this);
    cancelDownload.setMnemonic('c');
    progressPanel.add(statusIcon = new JLabel(), BorderLayout.WEST);
    progressPanel.add(progressDetailPanel, BorderLayout.CENTER);
    progressDialog.getContentPane().setLayout(new GridLayout(1, 1));
    progressDialog.getContentPane().add(progressPanel);
    progressDialog.setSize(220, 160);
    progressDialog.setResizable(false);
    centerComponent(progressDialog);

    // Set the intially available actions
    setAvailableActions();
  }