private void setupCentralPanel() {
    myCentralPanel.removeAll();
    if (myUsagePreviewPanel != null) {
      Disposer.dispose(myUsagePreviewPanel);
      myUsagePreviewPanel = null;
    }
    JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree);

    if (UsageViewSettings.getInstance().IS_PREVIEW_USAGES) {
      Splitter splitter =
          new Splitter(false, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
      pane.putClientProperty(UIUtil.KEEP_BORDER_SIDES, SideBorder.RIGHT);

      splitter.setFirstComponent(pane);
      myUsagePreviewPanel = new UsagePreviewPanel(myProject);
      myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
      Disposer.register(this, myUsagePreviewPanel);
      splitter.setSecondComponent(myUsagePreviewPanel);
      myCentralPanel.add(splitter, BorderLayout.CENTER);
    } else {
      myCentralPanel.add(pane, BorderLayout.CENTER);
    }
    myCentralPanel.add(myButtonPanel, BorderLayout.SOUTH);

    myRootPanel.revalidate();
  }
 protected JComponent createCenterPanel() {
   JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
   scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
   myCenterPanel.add(CARD_STATUS, scrollPane);
   myTreeBrowser =
       new CommittedChangesTreeBrowser(myProject, Collections.<CommittedChangeList>emptyList());
   Disposer.register(this, myTreeBrowser);
   myTreeBrowser.setHelpId(getHelpId());
   myCenterPanel.add(CARD_CHANGES, myTreeBrowser);
   return myCenterPanel;
 }
  @Override
  protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new BorderLayout());

    // Toolbar

    DefaultActionGroup group = new DefaultActionGroup();

    fillToolbarActions(group);

    group.addSeparator();

    ExpandAllAction expandAllAction = new ExpandAllAction();
    expandAllAction.registerCustomShortcutSet(
        new CustomShortcutSet(
            KeymapManager.getInstance()
                .getActiveKeymap()
                .getShortcuts(IdeActions.ACTION_EXPAND_ALL)),
        myTree);
    group.add(expandAllAction);

    CollapseAllAction collapseAllAction = new CollapseAllAction();
    collapseAllAction.registerCustomShortcutSet(
        new CustomShortcutSet(
            KeymapManager.getInstance()
                .getActiveKeymap()
                .getShortcuts(IdeActions.ACTION_COLLAPSE_ALL)),
        myTree);
    group.add(collapseAllAction);

    panel.add(
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.UNKNOWN, group, true)
            .getComponent(),
        BorderLayout.NORTH);

    // Tree
    expandFirst();
    defaultExpandTree();
    installSpeedSearch();

    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    scrollPane.setPreferredSize(new Dimension(350, 450));
    panel.add(scrollPane, BorderLayout.CENTER);

    return panel;
  }
 public void actionPerformed(final AnActionEvent e) {
   @NonNls final String delim = "&nbsp;-&gt;&nbsp;";
   final StringBuffer buf = new StringBuffer();
   processDependencies(
       getSelectedScope(myLeftTree),
       getSelectedScope(myRightTree),
       new Processor<List<PsiFile>>() {
         public boolean process(final List<PsiFile> path) {
           if (buf.length() > 0) buf.append("<br>");
           buf.append(
               StringUtil.join(
                   path,
                   new Function<PsiFile, String>() {
                     public String fun(final PsiFile psiFile) {
                       return psiFile.getName();
                     }
                   },
                   delim));
           return true;
         }
       });
   final JEditorPane pane =
       new JEditorPane(UIUtil.HTML_MIME, "<html>" + buf.toString() + "</html>");
   pane.setForeground(Color.black);
   pane.setBackground(HintUtil.INFORMATION_COLOR);
   pane.setOpaque(true);
   final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane);
   final Dimension dimension = pane.getPreferredSize();
   scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20));
   scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20));
   JBPopupFactory.getInstance()
       .createComponentPopupBuilder(scrollPane, pane)
       .setTitle("Dependencies")
       .setMovable(true)
       .createPopup()
       .showInBestPositionFor(e.getDataContext());
 }
  public JComponent createCenterPanel() {
    List<FileStructureFilter> fileStructureFilters = new ArrayList<FileStructureFilter>();
    List<FileStructureNodeProvider> fileStructureNodeProviders =
        new ArrayList<FileStructureNodeProvider>();
    if (myTreeActionsOwner != null) {
      for (Filter filter : myBaseTreeModel.getFilters()) {
        if (filter instanceof FileStructureFilter) {
          final FileStructureFilter fsFilter = (FileStructureFilter) filter;
          myTreeActionsOwner.setActionIncluded(fsFilter, true);
          fileStructureFilters.add(fsFilter);
        }
      }

      if (myBaseTreeModel instanceof ProvidingTreeModel) {
        for (NodeProvider provider : ((ProvidingTreeModel) myBaseTreeModel).getNodeProviders()) {
          if (provider instanceof FileStructureNodeProvider) {
            fileStructureNodeProviders.add((FileStructureNodeProvider) provider);
          }
        }
      }
    }
    final JPanel panel = new JPanel(new BorderLayout());
    JPanel comboPanel = new JPanel(new GridLayout(0, 2, 0, 0));

    final Shortcut[] F4 =
        ActionManager.getInstance()
            .getAction(IdeActions.ACTION_EDIT_SOURCE)
            .getShortcutSet()
            .getShortcuts();
    final Shortcut[] ENTER = CustomShortcutSet.fromString("ENTER").getShortcuts();
    final CustomShortcutSet shortcutSet = new CustomShortcutSet(ArrayUtil.mergeArrays(F4, ENTER));
    new AnAction() {
      public void actionPerformed(AnActionEvent e) {
        final boolean succeeded = navigateSelectedElement();
        if (succeeded) {
          unregisterCustomShortcutSet(panel);
        }
      }
    }.registerCustomShortcutSet(shortcutSet, panel);

    new AnAction() {
      public void actionPerformed(AnActionEvent e) {
        if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) {
          mySpeedSearch.hidePopup();
        } else {
          myPopup.cancel();
        }
      }
    }.registerCustomShortcutSet(CustomShortcutSet.fromString("ESCAPE"), myTree);

    new ClickListener() {
      @Override
      public boolean onClick(MouseEvent e, int clickCount) {
        navigateSelectedElement();
        return true;
      }
    }.installOn(myTree);

    for (FileStructureFilter filter : fileStructureFilters) {
      addCheckbox(comboPanel, filter);
    }

    for (FileStructureNodeProvider provider : fileStructureNodeProviders) {
      addCheckbox(comboPanel, provider);
    }
    myPreferredWidth = Math.max(comboPanel.getPreferredSize().width, 350);
    panel.add(comboPanel, BorderLayout.NORTH);
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myAbstractTreeBuilder.getTree());
    scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.BOTTOM));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(createSouthPanel(), BorderLayout.SOUTH);
    DataManager.registerDataProvider(
        panel,
        new DataProvider() {
          @Override
          public Object getData(@NonNls String dataId) {
            if (PlatformDataKeys.PROJECT.is(dataId)) {
              return myProject;
            }
            if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
              final Object node =
                  ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements());
              if (!(node instanceof FilteringTreeStructure.FilteringNode)) return null;
              return getPsi((FilteringTreeStructure.FilteringNode) node);
            }
            if (LangDataKeys.POSITION_ADJUSTER_POPUP.is(dataId)) {
              return myPopup;
            }
            if (PlatformDataKeys.TREE_EXPANDER.is(dataId)) {
              return myTreeExpander;
            }
            return null;
          }
        });

    return panel;
  }
示例#6
0
  public RegistryUi() {
    myContent.setLayout(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));

    myModel = new MyTableModel();
    myTable = new JBTable(myModel);
    myTable.setCellSelectionEnabled(true);
    myTable.setEnableAntialiasing(true);
    final MyRenderer r = new MyRenderer();

    final TableColumn c0 = myTable.getColumnModel().getColumn(0);
    c0.setCellRenderer(r);
    c0.setMaxWidth(RESTART_ICON.getIconWidth() + 12);
    c0.setMinWidth(RESTART_ICON.getIconWidth() + 12);
    c0.setHeaderValue(null);

    final TableColumn c1 = myTable.getColumnModel().getColumn(1);
    c1.setCellRenderer(r);
    c1.setHeaderValue("Key");

    final TableColumn c2 = myTable.getColumnModel().getColumn(2);
    c2.setCellRenderer(r);
    c2.setHeaderValue("Value");
    c2.setCellEditor(new MyEditor());
    myTable.setStriped(true);

    myDescriptionLabel = new JTextArea(3, 50);
    myDescriptionLabel.setEditable(false);
    final JScrollPane label = ScrollPaneFactory.createScrollPane(myDescriptionLabel);
    final JPanel descriptionPanel = new JPanel(new BorderLayout());
    descriptionPanel.add(label, BorderLayout.CENTER);
    descriptionPanel.setBorder(
        IdeBorderFactory.createTitledBorder("Description", false, false, true));

    myContent.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
    myContent.add(descriptionPanel, BorderLayout.SOUTH);

    myTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) return;

                final int selected = myTable.getSelectedRow();
                if (selected != -1) {
                  final RegistryValue value = myModel.getRegistryValue(selected);
                  String desc = value.getDescription();
                  if (value.isRestartRequired()) {
                    String required = "Requires IDE restart.";
                    if (desc.endsWith(".")) {
                      desc += required;
                    } else {
                      desc += (". " + required);
                    }
                  }
                  myDescriptionLabel.setText(desc);
                } else {
                  myDescriptionLabel.setText(null);
                }
              }
            });

    myRestoreDefaultsAction = new RestoreDefaultsAction();

    final DefaultActionGroup tbGroup = new DefaultActionGroup();
    tbGroup.add(new EditAction());
    tbGroup.add(new RevertAction());

    final ActionToolbar tb =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, tbGroup, true);
    tb.setTargetComponent(myTable);

    myContent.add(tb.getComponent(), BorderLayout.NORTH);
    new TableSpeedSearch(myTable).setComparator(new SpeedSearchComparator(false));
  }
  public MavenArchetypesStep(MavenModuleBuilder builder, @Nullable StepAdapter step) {
    myBuilder = builder;
    myStep = step;
    Disposer.register(this, myLoadingIcon);

    myArchetypesTree = new Tree();
    myArchetypesTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
    JScrollPane archetypesScrollPane = ScrollPaneFactory.createScrollPane(myArchetypesTree);

    myArchetypesPanel.add(archetypesScrollPane, "archetypes");

    JPanel loadingPanel = new JPanel(new GridBagLayout());
    JPanel bp = new JPanel(new BorderLayout(10, 10));
    bp.add(new JLabel("Loading archetype list..."), BorderLayout.NORTH);
    bp.add(myLoadingIcon, BorderLayout.CENTER);

    loadingPanel.add(bp, new GridBagConstraints());

    myArchetypesPanel.add(ScrollPaneFactory.createScrollPane(loadingPanel), "loading");
    ((CardLayout) myArchetypesPanel.getLayout()).show(myArchetypesPanel, "archetypes");

    myUseArchetypeCheckBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            updateComponents();
            archetypeMayBeChanged();
          }
        });

    myAddArchetypeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doAddArchetype();
          }
        });

    myArchetypesTree.setRootVisible(false);
    myArchetypesTree.setShowsRootHandles(true);
    myArchetypesTree.setCellRenderer(new MyRenderer());
    myArchetypesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    myArchetypesTree
        .getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              public void valueChanged(TreeSelectionEvent e) {
                updateArchetypeDescription();
                archetypeMayBeChanged();
              }
            });

    new TreeSpeedSearch(
            myArchetypesTree,
            new Convertor<TreePath, String>() {
              public String convert(TreePath path) {
                MavenArchetype info =
                    getArchetypeInfoFromPathComponent(path.getLastPathComponent());
                return info.groupId + ":" + info.artifactId + ":" + info.version;
              }
            })
        .setComparator(new SpeedSearchComparator(false));

    myArchetypeDescriptionField.setEditable(false);
    myArchetypeDescriptionField.setBackground(UIUtil.getPanelBackground());

    requestUpdate();
    updateComponents();
  }
  public InspectionResultsView(
      @NotNull final Project project,
      final InspectionProfile inspectionProfile,
      @NotNull AnalysisScope scope,
      @NotNull GlobalInspectionContextImpl globalInspectionContext,
      @NotNull InspectionRVContentProvider provider) {
    setLayout(new BorderLayout());

    myProject = project;
    myInspectionProfile = inspectionProfile;
    myScope = scope;
    myGlobalInspectionContext = globalInspectionContext;
    myProvider = provider;

    myTree = new InspectionTree(project, globalInspectionContext);
    initTreeListeners();

    myOccurenceNavigator = initOccurenceNavigator();

    myBrowser = new Browser(this);

    mySplitter =
        new OnePixelSplitter(false, AnalysisUIOptions.getInstance(myProject).SPLITTER_PROPORTION);

    mySplitter.setFirstComponent(
        ScrollPaneFactory.createScrollPane(myTree, SideBorder.LEFT | SideBorder.RIGHT));
    mySplitter.setSecondComponent(myBrowser);

    mySplitter.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            if (Splitter.PROP_PROPORTION.equals(evt.getPropertyName())) {
              myGlobalInspectionContext.setSplitterProportion(
                  ((Float) evt.getNewValue()).floatValue());
            }
          }
        });
    add(mySplitter, BorderLayout.CENTER);

    myBrowser.addClickListener(
        new Browser.ClickListener() {
          @Override
          public void referenceClicked(final Browser.ClickEvent e) {
            if (e.getEventType() == Browser.ClickEvent.REF_ELEMENT) {
              final RefElement refElement = e.getClickedElement();
              final OpenFileDescriptor descriptor = getOpenFileDescriptor(refElement);
              if (descriptor != null) {
                FileEditorManager.getInstance(project).openTextEditor(descriptor, false);
              }
            } else if (e.getEventType() == Browser.ClickEvent.FILE_OFFSET) {
              final VirtualFile file = e.getFile();
              final OpenFileDescriptor descriptor =
                  new OpenFileDescriptor(project, file, e.getStartOffset());
              final Editor editor =
                  FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
              if (editor != null) {
                final TextAttributes selectionAttributes =
                    EditorColorsManager.getInstance()
                        .getGlobalScheme()
                        .getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
                HighlightManager.getInstance(project)
                    .addRangeHighlight(
                        editor,
                        e.getStartOffset(),
                        e.getEndOffset(),
                        selectionAttributes,
                        true,
                        null);
              }
            }
          }
        });

    createActionsToolbar();
    TreeUtil.selectFirstNode(myTree);
  }
  protected void reInitWholePanelIfNeeded() {
    if (!myToReInitWholePanel) return;

    myWholePanel =
        new JPanel(new BorderLayout()) {
          public void addNotify() {
            super.addNotify();
            MasterDetailsComponent.this.addNotify();

            TreeModel m = myTree.getModel();
            if (m instanceof DefaultTreeModel) {
              DefaultTreeModel model = (DefaultTreeModel) m;
              for (int eachRow = 0; eachRow < myTree.getRowCount(); eachRow++) {
                TreePath eachPath = myTree.getPathForRow(eachRow);
                Object component = eachPath.getLastPathComponent();
                if (component instanceof TreeNode) {
                  model.nodeChanged((TreeNode) component);
                }
              }
            }
          }
        };
    mySplitter.setHonorComponentsMinimumSize(true);
    myWholePanel.add(mySplitter, BorderLayout.CENTER);

    JPanel left =
        new JPanel(new BorderLayout()) {
          public Dimension getMinimumSize() {
            final Dimension original = super.getMinimumSize();
            return new Dimension(Math.max(original.width, 100), original.height);
          }
        };

    if (isNewProjectSettings()) {
      ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTree);
      DefaultActionGroup group = createToolbarActionGroup();
      if (group != null) {
        decorator.setActionGroup(group);
      }
      // left.add(myNorthPanel, BorderLayout.NORTH);
      myMaster =
          decorator.setAsUsualTopToolbar().setPanelBorder(JBUI.Borders.empty()).createPanel();
      myNorthPanel.setVisible(false);
    } else {
      left.add(myNorthPanel, BorderLayout.NORTH);
      myMaster = ScrollPaneFactory.createScrollPane(myTree);
    }
    left.add(myMaster, BorderLayout.CENTER);
    mySplitter.setFirstComponent(left);

    final JPanel right = new JPanel(new BorderLayout());
    right.add(myDetails.getComponent(), BorderLayout.CENTER);
    if (!isNewProjectSettings()) {
      myWholePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    }

    mySplitter.setSecondComponent(right);

    GuiUtils.replaceJSplitPaneWithIDEASplitter(myWholePanel);

    myToReInitWholePanel = false;
  }
  public DependenciesPanel(
      Project project, final List<DependenciesBuilder> builders, final Set<PsiFile> excluded) {
    super(new BorderLayout());
    myBuilders = builders;
    myExcluded = excluded;
    final DependenciesBuilder main = myBuilders.get(0);
    myForward = !main.isBackward();
    myScopeOfInterest = main.getScopeOfInterest();
    myTransitiveBorder = main.getTransitiveBorder();
    myDependencies = new HashMap<PsiFile, Set<PsiFile>>();
    myIllegalDependencies = new HashMap<PsiFile, Map<DependencyRule, Set<PsiFile>>>();
    for (DependenciesBuilder builder : builders) {
      myDependencies.putAll(builder.getDependencies());
      myIllegalDependencies.putAll(builder.getIllegalDependencies());
    }
    exclude(excluded);
    myProject = project;
    myUsagesPanel = new DependenciesUsagesPanel(myProject, myBuilders);
    Disposer.register(this, myUsagesPanel);

    final Splitter treeSplitter = new Splitter();
    Disposer.register(
        this,
        new Disposable() {
          public void dispose() {
            treeSplitter.dispose();
          }
        });
    treeSplitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myLeftTree));
    treeSplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myRightTree));

    final Splitter splitter = new Splitter(true);
    Disposer.register(
        this,
        new Disposable() {
          public void dispose() {
            splitter.dispose();
          }
        });
    splitter.setFirstComponent(treeSplitter);
    splitter.setSecondComponent(myUsagesPanel);
    add(splitter, BorderLayout.CENTER);
    add(createToolbar(), BorderLayout.NORTH);

    myRightTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myRightTree, myProject);
    myLeftTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myLeftTree, myProject);

    myRightTreeMarker =
        new Marker() {
          public boolean isMarked(VirtualFile file) {
            return myIllegalsInRightTree.contains(file);
          }
        };

    myLeftTreeMarker =
        new Marker() {
          public boolean isMarked(VirtualFile file) {
            return myIllegalDependencies.containsKey(file);
          }
        };

    updateLeftTreeModel();
    updateRightTreeModel();

    myLeftTree
        .getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              public void valueChanged(TreeSelectionEvent e) {
                updateRightTreeModel();
                final StringBuffer denyRules = new StringBuffer();
                final StringBuffer allowRules = new StringBuffer();
                final TreePath[] paths = myLeftTree.getSelectionPaths();
                if (paths == null) {
                  return;
                }
                for (TreePath path : paths) {
                  PackageDependenciesNode selectedNode =
                      (PackageDependenciesNode) path.getLastPathComponent();
                  traverseToLeaves(selectedNode, denyRules, allowRules);
                }
                if (denyRules.length() + allowRules.length() > 0) {
                  StatusBar.Info.set(
                      AnalysisScopeBundle.message(
                          "status.bar.rule.violation.message",
                          ((denyRules.length() == 0 || allowRules.length() == 0) ? 1 : 2),
                          (denyRules.length() > 0
                                  ? denyRules.toString() + (allowRules.length() > 0 ? "; " : "")
                                  : " ")
                              + (allowRules.length() > 0 ? allowRules.toString() : " ")),
                      myProject);
                } else {
                  StatusBar.Info.set(
                      AnalysisScopeBundle.message("status.bar.no.rule.violation.message"),
                      myProject);
                }
              }
            });

    myRightTree
        .getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              public void valueChanged(TreeSelectionEvent e) {
                SwingUtilities.invokeLater(
                    new Runnable() {
                      public void run() {
                        final Set<PsiFile> searchIn = getSelectedScope(myLeftTree);
                        final Set<PsiFile> searchFor = getSelectedScope(myRightTree);
                        if (searchIn.isEmpty() || searchFor.isEmpty()) {
                          myUsagesPanel.setToInitialPosition();
                          processDependencies(
                              searchIn,
                              searchFor,
                              new Processor<List<PsiFile>>() { // todo do not show too many usages
                                public boolean process(final List<PsiFile> path) {
                                  searchFor.add(path.get(1));
                                  return true;
                                }
                              });
                        } else {
                          myUsagesPanel.findUsages(searchIn, searchFor);
                        }
                      }
                    });
              }
            });

    initTree(myLeftTree, false);
    initTree(myRightTree, true);

    if (builders.size() == 1) {
      AnalysisScope scope = builders.get(0).getScope();
      if (scope.getScopeType() == AnalysisScope.FILE) {
        Set<PsiFile> oneFileSet = myDependencies.keySet();
        if (oneFileSet.size() == 1) {
          selectElementInLeftTree(oneFileSet.iterator().next());
          return;
        }
      }
    }
    TreeUtil.selectFirstNode(myLeftTree);
  }
  private ElementsChooser(@Nullable List<T> elements, boolean marked, boolean elementsCanBeMarked) {
    super(new BorderLayout());

    myTableModel = new MyTableModel(elementsCanBeMarked);
    myTable = new Table(myTableModel);
    myTable.setShowGrid(false);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    myTable.setTableHeader(null);
    myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    myTable.setColumnSelectionAllowed(false);
    JScrollPane pane = ScrollPaneFactory.createScrollPane(myTable);
    pane.setPreferredSize(new Dimension(100, 155));
    int width = new JCheckBox().getPreferredSize().width;
    TableColumnModel columnModel = myTable.getColumnModel();

    if (elementsCanBeMarked) {
      TableColumn checkMarkColumn = columnModel.getColumn(myTableModel.CHECK_MARK_COLUM_INDEX);
      checkMarkColumn.setPreferredWidth(width);
      checkMarkColumn.setMaxWidth(width);
      checkMarkColumn.setCellRenderer(
          new CheckMarkColumnCellRenderer(myTable.getDefaultRenderer(Boolean.class)));
    }
    columnModel
        .getColumn(myTableModel.ELEMENT_COLUMN_INDEX)
        .setCellRenderer(new MyElementColumnCellRenderer());

    add(pane, BorderLayout.CENTER);
    myTable.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            final int[] selectedRows = myTable.getSelectedRows();
            boolean currentlyMarked = true;
            for (int selectedRow : selectedRows) {
              currentlyMarked = myTableModel.isElementMarked(selectedRow);
              if (!currentlyMarked) {
                break;
              }
            }
            myTableModel.setMarked(selectedRows, !currentlyMarked);
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0),
        JComponent.WHEN_FOCUSED);

    final SpeedSearchBase<JBTable> speedSearch =
        new SpeedSearchBase<JBTable>(myTable) {
          public int getSelectedIndex() {
            return myTable.getSelectedRow();
          }

          @Override
          protected int convertIndexToModel(int viewIndex) {
            return myTable.convertRowIndexToModel(viewIndex);
          }

          public Object[] getAllElements() {
            final int count = myTableModel.getRowCount();
            Object[] elements = new Object[count];
            for (int idx = 0; idx < count; idx++) {
              elements[idx] = myTableModel.getElementAt(idx);
            }
            return elements;
          }

          public String getElementText(Object element) {
            return getItemText((T) element);
          }

          public void selectElement(Object element, String selectedText) {
            final int count = myTableModel.getRowCount();
            for (int row = 0; row < count; row++) {
              if (element.equals(myTableModel.getElementAt(row))) {
                final int viewRow = myTable.convertRowIndexToView(row);
                myTable.getSelectionModel().setSelectionInterval(viewRow, viewRow);
                TableUtil.scrollSelectionToVisible(myTable);
                break;
              }
            }
          }
        };
    speedSearch.setComparator(new SpeedSearchBase.SpeedSearchComparator(false));
    setElements(elements, marked);
    installActions(myTable);
  }