private JPanel createToolPanel() {
    configurationOverrideCombo.setModel(configurationOverrideModel);
    final int preferredHeight = configurationOverrideCombo.getPreferredSize().height;
    configurationOverrideCombo.setPreferredSize(new Dimension(250, preferredHeight));
    configurationOverrideCombo.setMaximumSize(new Dimension(350, preferredHeight));

    treeModel = new ResultTreeModel();

    resultsTree = new Tree(treeModel);
    resultsTree.setRootVisible(false);

    final TreeSelectionListener treeSelectionListener = new ToolWindowSelectionListener();
    resultsTree.addTreeSelectionListener(treeSelectionListener);
    final MouseListener treeMouseListener = new ToolWindowMouseListener();
    resultsTree.addMouseListener(treeMouseListener);
    resultsTree.setCellRenderer(new ResultTreeRenderer());

    progressLabel = new JLabel(" ");
    progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setMinimum(0);
    final Dimension progressBarSize = new Dimension(100, progressBar.getPreferredSize().height);
    progressBar.setMinimumSize(progressBarSize);
    progressBar.setPreferredSize(progressBarSize);
    progressBar.setMaximumSize(progressBarSize);

    progressPanel = new JToolBar(JToolBar.HORIZONTAL);
    progressPanel.add(Box.createHorizontalStrut(4));
    progressPanel.add(new JLabel(CheckStyleBundle.message("plugin.toolwindow.override")));
    progressPanel.add(Box.createHorizontalStrut(4));
    progressPanel.add(configurationOverrideCombo);
    progressPanel.add(Box.createHorizontalStrut(4));
    progressPanel.addSeparator();
    progressPanel.add(Box.createHorizontalStrut(4));
    progressPanel.add(progressLabel);
    progressPanel.add(Box.createHorizontalGlue());
    progressPanel.setFloatable(false);
    progressPanel.setBackground(UIManager.getColor("Panel.background"));
    progressPanel.setBorder(null);

    final JPanel toolPanel = new JPanel(new BorderLayout());
    toolPanel.add(new JBScrollPane(resultsTree), BorderLayout.CENTER);
    toolPanel.add(progressPanel, BorderLayout.NORTH);

    ToolTipManager.sharedInstance().registerComponent(resultsTree);

    return toolPanel;
  }
示例#2
0
  public ProgressComponent(Window dialog) {
    setFloatable(false);
    setBorderPainted(false);

    bar.setStringPainted(true);
    bar.setMaximumSize(new Dimension(60, 60));

    addSeparator();
    add(bar);
    setVisible(false);

    this.trackerDialog = dialog;

    dialog.addComponentListener(
        new ComponentListener() {
          @Override
          public void componentResized(ComponentEvent e) {}

          @Override
          public void componentMoved(ComponentEvent e) {}

          @Override
          public void componentShown(ComponentEvent e) {
            setVisible(false);
          }

          @Override
          public void componentHidden(ComponentEvent e) {
            if (lastState == ProgressState.Start || lastState == ProgressState.Work) {
              setVisible(true);
            }
          }
        });
    bar.addMouseListener(
        new PopupMouseAdapter() {
          @Override
          protected void triggerDoubleClick(MouseEvent e) {
            trackerDialog.setVisible(true);
          }

          @Override
          protected void triggerPopup(MouseEvent e) {}
        });
  }