コード例 #1
0
  private void assertTabCount(Content content) {
    //        PluginSettingsBean bean = (PluginSettingsBean)
    // SharedObjectPool.getUserData(SharedConstants.PLUGIN_SETTINGS);
    PluginSettingsBean bean = PluginKeys.PLUGIN_SETTINGS.getData();

    if (bean == null) {
      bean = new PluginSettingsBean();
    }

    int max = bean.getNumberOfTabs();

    if (max <= getTabComponent(content).getTabCount()) {
      // remove the oldest tab
      JTabbedPane tabbedPane = getTabComponent(content);
      long lastMin = Long.MAX_VALUE;
      int index = 0;
      for (int i = 0; i < tabbedPane.getTabCount(); i++) {
        JComponent tab = (JComponent) tabbedPane.getTabComponentAt(i);
        Long time = (Long) tab.getClientProperty(CREATE_TIME);
        if (time != null && lastMin < time) {
          lastMin = time;
          index = i;
        }
      }

      tabbedPane.remove(index);
    }
  }
コード例 #2
0
  public void showFrame(Editor editor, ContributionType contributionType) {
    this.editor = editor;

    // Calculating index to switch to the required tab
    int index = getIndex(contributionType);
    if (dialog == null) {
      makeFrame(editor);
      // done before as downloadAndUpdateContributionListing()
      // requires the current selected tab
      tabbedPane.setSelectedIndex(index);
      downloadAndUpdateContributionListing(editor.getBase());
      if (index != 4) {
        Component selected = tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex());
        selected.setBackground(new Color(0xe0fffd));
        selected.setForeground(Color.BLACK);
      } else {
        updateTabPanel.setBackground(new Color(0xe0fffd));
        updateTabLabel.setForeground(Color.BLACK);
      }
    }
    tabbedPane.setSelectedIndex(index);
    dialog.setVisible(true);
  }