@Override public void updateUI() { super.updateUI(); // putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, null); if (UIUtil.isMotifLookAndFeel()) { setBorder(BorderFactory.createEtchedBorder()); } else if (!UIUtil.isUnderGTKLookAndFeel()) { setBorder(UIUtil.getButtonBorder()); } }
protected JComponent createCenterPanel() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); myModel = new DefaultTreeModel(new DefaultMutableTreeNode()); createTreeModel(); myTree = new Tree(myModel); UIUtil.setLineStyleAngled(myTree); myTree.setCellRenderer( new DefaultTreeCellRenderer() { public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); setIcon(expanded ? Icons.PACKAGE_OPEN_ICON : Icons.PACKAGE_ICON); if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; Object object = node.getUserObject(); if (object instanceof PsiPackage) { String name = ((PsiPackage) object).getName(); if (name != null && name.length() > 0) { setText(name); } else { setText(IdeBundle.message("node.default")); } } } return this; } }); myTree.setBorder(BorderFactory.createEtchedBorder()); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree); scrollPane.setPreferredSize(new Dimension(500, 300)); new TreeSpeedSearch( myTree, new Convertor<TreePath, String>() { public String convert(TreePath path) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object object = node.getUserObject(); if (object instanceof PsiPackage) return ((PsiPackage) object).getName(); else return ""; } }); myTree .getSelectionModel() .addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { PsiPackage selection = getTreeSelection(); if (selection != null) { String name = selection.getQualifiedName(); setTitle( myTitle + " - " + ("".equals(name) ? IdeBundle.message("node.default.package") : name)); } else { setTitle(myTitle); } } }); panel.add(scrollPane, BorderLayout.CENTER); DefaultActionGroup group = createActionGroup(myTree); ActionToolbar toolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); panel.add(toolBar.getComponent(), BorderLayout.NORTH); toolBar.getComponent().setAlignmentX(JComponent.LEFT_ALIGNMENT); return panel; }