Java 类javax.swing.tree.TreeSelectionModel 实例源码

项目:geoxygene    文件:OntologyBrowser.java   
public OntologyBrowser(OWLOntology ontology, Set<String> rootsToRemove) {
  super();
  this.ontology = ontology;
  this.rootConcept = "Thing";
  this.buildTreeModel();
  for (String concept : rootsToRemove) {
    DefaultMutableTreeNode node = getNodeFromName(concept);
    this.dtm.removeNodeFromParent(node);
  }

  this.setModel(this.dtm);
  // set the tree selection model
  DefaultTreeSelectionModel dtsm = new DefaultTreeSelectionModel();
  dtsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  this.setSelectionModel(dtsm);
  // set the tree renderer
  OntologyRenderer myRenderer = new OntologyRenderer();
  this.setCellRenderer(myRenderer);
  this.setRootVisible(false);
}
项目:geoxygene    文件:OntologyBrowser.java   
public OntologyBrowser(OWLOntology ontology, ImageIcon closedIcon,
    ImageIcon openedIcon) {
  super();
  this.ontology = ontology;
  this.buildTreeModel();
  this.setModel(this.dtm);
  // set the tree selection model
  DefaultTreeSelectionModel dtsm = new DefaultTreeSelectionModel();
  dtsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  this.setSelectionModel(dtsm);
  this.setRootVisible(false);
  // set the tree renderer
  OntologyRenderer myRenderer = new OntologyRenderer();
  // Change the icon for closed nodes.
  myRenderer.setClosedIcon(closedIcon);
  // Change the icon for opened nodes.
  myRenderer.setOpenIcon(openedIcon);
  this.setCellRenderer(myRenderer);
}
项目:incubator-netbeans    文件:CheckTreeView.java   
/** Creates a new instance of CheckTreeView */
public CheckTreeView() {

    setFocusable( false );

    CheckListener l = new CheckListener();
    tree.addMouseListener( l );
    tree.addKeyListener( l );

    CheckRenderer check = new CheckRenderer();
    tree.setCellRenderer( check );
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    tree.setShowsRootHandles(false);

    InputMap input = tree.getInputMap( JTree.WHEN_FOCUSED );
    if( null != input )
        input.remove( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) );

    setBorder( UIManager.getBorder("ScrollPane.border") );
}
项目:incubator-netbeans    文件:CheckTreeView.java   
/** Creates a new instance of CheckTreeView */
public CheckTreeView() {

    setFocusable( false );

    CheckListener l = new CheckListener();
    tree.addMouseListener( l );
    tree.addKeyListener( l );

    CheckRenderer check = new CheckRenderer();
    tree.setCellRenderer( check );
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    tree.setShowsRootHandles(false);

    InputMap input = tree.getInputMap( JTree.WHEN_FOCUSED );
    if( null != input )
        input.remove( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) );

    setBorder( UIManager.getBorder("ScrollPane.border") );
}
项目:rapidminer    文件:OperatorTree.java   
/** Creates a new operator tree. */
public OperatorTree(MainFrame mainFrame) {
    super();
    this.mainFrame = mainFrame;

    setCellRenderer(new OperatorTreeCellRenderer());
    addTreeSelectionListener(this);
    addTreeExpansionListener(this);
    addMouseListener(this);

    // forces the tree to ask the nodes for the correct row heights
    // must also be invoked after LaF changes...
    setRowHeight(0);

    getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
}
项目:rapidminer    文件:PlotConfigurationTree.java   
public PlotConfigurationTree(PlotConfiguration plotConfiguration, DataTable dataTable,
        DataTableColumnListTransferHandler aTH) {
    super();
    expandAll();

    // forces the tree to ask the nodes for the correct row heights
    // must also be invoked after LaF changes...
    setRowHeight(0);

    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    setExpandsSelectedPaths(true);

    // DnD support
    setDragEnabled(true);
    setDropMode(DropMode.INSERT);

    // Rendering
    setShowsRootHandles(false);
    setBackground(Colors.WHITE);
    setCellRenderer(new PlotConfigurationTreeCellRenderer(aTH));
    putClientProperty("JTree.lineStyle", "Horizontal");

    createNewTreeModel(plotConfiguration);
}
项目:routerapp    文件:NavigationView.java   
/**
 * 
 */
private void buildTree() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("user");
    tree = new JTree(root);
    tree.putClientProperty("JTree.lineStyle", "Angled");
    tree.setCellRenderer(new NavigationTreeCellRenderer());
    tree.setShowsRootHandles(true);

    DefaultTreeSelectionModel model = new DefaultTreeSelectionModel();
    model.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    graphsCategory = new DefaultMutableTreeNode("graphs");

    mouseAdapter = new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            itemSelected(e);
        }
    };
    tree.addMouseListener(mouseAdapter);

    root.add(graphsCategory);        
    loadGraphs();
}
项目:marathonv5    文件:RTreeTest.java   
public void noNodesSelected() throws Throwable, InvocationTargetException {
    final JTree tree = (JTree) ComponentUtils.findComponent(JTree.class, frame);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    siw(new Runnable() {
        @Override public void run() {
            tree.expandRow(0);
        }
    });
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            RTree rTree = new RTree(tree, null, null, lr);
            rTree.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("[]", call.getState());
}
项目:marathonv5    文件:RTreeTest.java   
public void singleNodeSelected() throws Throwable, InvocationTargetException {
    final JTree tree = (JTree) ComponentUtils.findComponent(JTree.class, frame);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    siw(new Runnable() {
        @Override public void run() {
            tree.expandRow(0);
            tree.setSelectionRow(0);
        }
    });
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            RTree rTree = new RTree(tree, null, null, lr);
            rTree.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("[/Root Node]", call.getState());
}
项目:marathonv5    文件:RTreeTest.java   
public void multpleNodesSelected() throws Throwable, InvocationTargetException {
    final JTree tree = (JTree) ComponentUtils.findComponent(JTree.class, frame);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    siw(new Runnable() {
        @Override public void run() {
            tree.expandRow(0);
            tree.setSelectionRows(new int[] { 0, 2 });
        }
    });
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            RTree rTree = new RTree(tree, null, null, lr);
            rTree.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("[/Root Node, /Root Node/Parent 2]", call.getState());
}
项目:marathonv5    文件:RTreeTest.java   
public void singleNodeWithSpecialChars() throws Throwable, InvocationTargetException {
    final JTree tree = (JTree) ComponentUtils.findComponent(JTree.class, frame);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    siw(new Runnable() {
        @Override public void run() {
            DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
            DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
            root.setUserObject("Root Node [] , / Special");
            tree.expandRow(0);
            tree.setSelectionRow(0);
        }
    });
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            RTree rTree = new RTree(tree, null, null, lr);
            rTree.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("[/Root Node [] \\, \\\\/ Special]", call.getState());
}
项目:jmeter-bzm-plugins    文件:ViewResultsFullVisualizer.java   
private synchronized Component createLeftPanel() {
    SampleResult rootSampleResult = new SampleResult();
    rootSampleResult.setSampleLabel("Root");
    rootSampleResult.setSuccessful(true);
    root = new SearchableTreeNode(rootSampleResult, null);

    treeModel = new DefaultTreeModel(root);
    jTree = new JTree(treeModel);
    jTree.setCellRenderer(new ResultsNodeRenderer());
    jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree.addTreeSelectionListener(this);
    jTree.setRootVisible(false);
    jTree.setShowsRootHandles(true);
    JScrollPane treePane = new JScrollPane(jTree);
    treePane.setPreferredSize(new Dimension(200, 300));

    VerticalPanel leftPane = new VerticalPanel();
    leftPane.add(treePane, BorderLayout.CENTER);
    leftPane.add(createComboRender(), BorderLayout.NORTH);
    autoScrollCB = new JCheckBox(JMeterUtils.getResString("view_results_autoscroll")); // $NON-NLS-1$
    autoScrollCB.setSelected(false);
    autoScrollCB.addItemListener(this);
    leftPane.add(autoScrollCB, BorderLayout.SOUTH);
    return leftPane;
}
项目:org.alloytools.alloy    文件:OurTree.java   
/** Construct a Tree object with the given font size. */
public OurTree(int fontSize) {
    Font font = OurUtil.getVizFont().deriveFont((float) fontSize);
    OurTreeRenderer renderer = new OurTreeRenderer(fontSize);
    renderer.setFont(font);
    renderer.invalidate();
    renderer.validate();
    setRowHeight(0); // To allow variable row height on Mac OS X
    setCellRenderer(renderer);
    setFont(font);
    setBorder(new EmptyBorder(8, 8, 2, 2));
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    putClientProperty("JTree.lineStyle", "Angled");
    setRootVisible(true);
    setForeground(Color.BLACK);
    setBackground(Color.WHITE);
    setOpaque(true);
    addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            TreePath path = OurTree.this.getSelectionPath();
            if (path != null)
                OurTree.this.listeners.fire(OurTree.this, Listener.Event.CLICK, path.getLastPathComponent());
        }
    });
}
项目:JavaGraph    文件:CheckboxTree.java   
/**
 * Constructs a tree, with cell renderer and editor set by
 * {@link #createRenderer()} and {@link #createEditor()}.
 */
public CheckboxTree() {
    setCellRenderer(createRenderer());
    setCellEditor(createEditor());
    setEditable(true);
    setRootVisible(false);
    setShowsRootHandles(true);
    // make sure the checkbox never selects the label
    // note that the BasicTreeUI may not be what is used in the current LAF,
    // but I don't know any other way to modify the selection behaviour
    BasicTreeUI ui = new BasicTreeUI() {
        @Override
        protected void selectPathForEvent(TreePath path, MouseEvent event) {
            if (!isOverCheckBox(path, event.getPoint().x)) {
                super.selectPathForEvent(path, event);
            }
        }
    };
    setUI(ui);
    // initialise the tree model
    this.topNode = new DefaultMutableTreeNode();
    this.treeModel = new DefaultTreeModel(this.topNode);
    setModel(this.treeModel);
    // set selection mode
    getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
}
项目:JavaGraph    文件:StateTree.java   
/**
 * Creates a new state list.
 */
public StateTree(Simulator simulator) {
    this.simulator = simulator;
    setEnabled(false);
    setLargeModel(true);
    setRootVisible(false);
    setShowsRootHandles(true);
    setEnabled(false);
    setToggleClickCount(0);
    setModel(getModel());
    getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    this.setCellRenderer(new DisplayTreeCellRenderer(this));
    installListeners();
    ToolTipManager.sharedInstance()
        .registerComponent(this);
}
项目:Equella    文件:WizardTree.java   
public MyTree(int wizardType, WizardModel model)
{
    super(model);

    // Some basic properties
    setEditable(true);
    setShowsRootHandles(true);
    setRootVisible(wizardType == WizardHelper.WIZARD_TYPE_CONTRIBUTION);
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Set the renderer and editor
    CellRenderer renderer = new CellRenderer(repository);
    CellEditor editor = new CellEditor(repository, this, renderer);

    setCellRenderer(renderer);
    setCellEditor(editor);
}
项目:WordnetLoom    文件:RelationTreePanel.java   
private void init() {

        setLayout(new BorderLayout());

        tree = new WebTree(root);
        tree.setToggleClickCount(2);
        tree.setScrollsOnExpand(true);
        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        tree.setRootVisible(true);
        tree.addTreeSelectionListener(this);

        WebScrollPane treeScrollWrapper = new WebScrollPane(tree);

        WebPanel wrapper = new WebPanel(treeScrollWrapper);
        wrapper.setMargin(5, 10, 10, 0);

        MButtonPanel buttonPanel = new MButtonPanel(moveUpButton, moveDownButton,
                addButton, addSubRelationButton, removeButton)
                .withVerticalLayout()
                .withAllButtonsEnabled(true)
                .withMargin(10);

        add(wrapper, BorderLayout.CENTER);
        add(buttonPanel, BorderLayout.EAST);

    }
项目:Tarski    文件:OurTree.java   
/** Construct a Tree object with the given font size. */
public OurTree(int fontSize) {
   Font font = OurUtil.getVizFont().deriveFont((float)fontSize);
   OurTreeRenderer renderer = new OurTreeRenderer(fontSize);
   renderer.setFont(font);
   renderer.invalidate();
   renderer.validate();
   setRowHeight(0); // To allow variable row height on Mac OS X
   setCellRenderer(renderer);
   setFont(font);
   setBorder(new EmptyBorder(8, 8, 2, 2));
   getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
   putClientProperty("JTree.lineStyle", "Angled");
   setRootVisible(true);
   setForeground(Color.BLACK);
   setBackground(Color.WHITE);
   setOpaque(true);
   addTreeSelectionListener(new TreeSelectionListener() {
      public void valueChanged(TreeSelectionEvent e) {
         TreePath path = OurTree.this.getSelectionPath();
         if (path!=null) OurTree.this.listeners.fire(OurTree.this, Listener.Event.CLICK, path.getLastPathComponent());
      }
   });
}
项目:Tarski    文件:OurTree.java   
/** Construct a Tree object with the given font size. */
public OurTree(int fontSize) {
   Font font = OurUtil.getVizFont().deriveFont((float)fontSize);
   OurTreeRenderer renderer = new OurTreeRenderer(fontSize);
   renderer.setFont(font);
   renderer.invalidate();
   renderer.validate();
   setRowHeight(0); // To allow variable row height on Mac OS X
   setCellRenderer(renderer);
   setFont(font);
   setBorder(new EmptyBorder(8, 8, 2, 2));
   getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
   putClientProperty("JTree.lineStyle", "Angled");
   setRootVisible(true);
   setForeground(Color.BLACK);
   setBackground(Color.WHITE);
   setOpaque(true);
   addTreeSelectionListener(new TreeSelectionListener() {
      public void valueChanged(TreeSelectionEvent e) {
         TreePath path = OurTree.this.getSelectionPath();
         if (path!=null) OurTree.this.listeners.fire(OurTree.this, Listener.Event.CLICK, path.getLastPathComponent());
      }
   });
}
项目:SudokuExplainer    文件:SudokuFrame.java   
private JTree getHintsTree() {
    if (hintsTree == null) {
        hintsTree = new JTree();
        hintsTree.setShowsRootHandles(true);
        hintsTree.getSelectionModel().setSelectionMode(
                TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
        hintsTree.setCellRenderer(new HintsTreeCellRenderer());
        hintsTree.setExpandsSelectedPaths(true);
        hintsTree
        .addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {

            public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
                if (hintsTree.isEnabled()) {
                    Collection<HintNode> selection = new ArrayList<HintNode>();
                    TreePath[] pathes = hintsTree.getSelectionPaths();
                    if (pathes != null) {
                        for (TreePath path : pathes)
                            selection.add((HintNode)path.getLastPathComponent());
                    }
                    engine.hintsSelected(selection);
                }
            }
        });
    }
    return hintsTree;
}
项目:semtool    文件:InsightManagerPanel.java   
/**
 * Creates new form InsightManagerPanel
 */
public InsightManagerPanel() {
    initComponents();
    privateImBtn.setIcon( DbAction.getIcon( "privacy" ) );

    propChangeListener = new PropertyChangeListener() {

        @Override
        public void propertyChange( PropertyChangeEvent evt ) {
            if ( null != currentCard ) {
                applybtn.setEnabled( currentCard.hasChanges() );
                commitbtn.setEnabled( !applybtn.isEnabled() );
            }
        }
    };

    tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
    tree.setCellRenderer( new PerspectiveTreeCellRenderer( DIHelper.getInstance().getOutputTypeRegistry() ) );

    setupTreeListeners();
}
项目:modeller    文件:BagTree.java   
/**
 * BagTree.
 *
 * @param bagView BagView
 * @param path    String
 */
public BagTree(final BagView bagView, final String path) {
    super();
    this.setShowsRootHandles(true);
    basePath = path;
    parentNode = new DefaultMutableTreeNode(basePath);
    initialize();
    initListeners();
    final JTextField nameTextField = new JTextField();
    bagtreeRowModifier = nameTextField.getFontMetrics(nameTextField.getFont()).getHeight() + 5;
    this.setDragEnabled(true);
    this.setDropMode(DropMode.ON_OR_INSERT);
    this.setTransferHandler(new BagTreeTransferHandler());
    this.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
    bagView.registerTreeListener(path, this);
}
项目:mtg-desktop-okhttp    文件:ViewChecklist.java   
private void createView() {

        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        tree.addTreeSelectionListener(new TreeSelectionListener() {

            @Override
            public void valueChanged(TreeSelectionEvent e) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
                if (node == null) {
                    return;
                }
                Object nodeInfo = node.getUserObject();
                if (node.isLeaf()) {
                    switchView(nodeInfo.toString());
                }
            }
        });

        windowPane = new JPanel();
        windowPane.add(new TaskScreenPanel());
        JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tree, windowPane);
        getContentPane().add(pane);
    }
项目:pumpernickel    文件:AquaLocationSourceList.java   
public AquaLocationSourceList(LocationHistory directoryStack,GraphicCache graphicCache) {
    super(new DefaultTreeModel(new DefaultMutableTreeNode("root")));

    treeModel = (DefaultTreeModel)getModel();
    root = (DefaultMutableTreeNode)treeModel.getRoot();

    this.directoryStack = directoryStack;
    this.graphicCache = graphicCache;

    treeModel.insertNodeInto(devices, root, 0);
    treeModel.insertNodeInto(places, root, 1);
    addTreeSelectionListener(treeSelectionListener);
    directoryStack.addChangeListener(directoryStackListener);
    setExpandsSelectedPaths(true);
    setCellRenderer(new SourceListLocationRenderer( graphicCache, this));
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    setUI(new SourceListTreeUI(this));

    expandPath( new TreePath(devices.getPath()) );
    expandPath( new TreePath(places.getPath()) );
}
项目:taxonaut    文件:TreeTableSelectionModel.java   
public Object put(NameTree tree)
   {
if(treeSelectionModels == null)
    treeSelectionModels = new HashMap<NameTree, TreeSelectionModel>();

TreeSelectionModel previousModel = treeSelectionModels.get(tree);

if(previousModel != null)
    previousModel.removeTreeSelectionListener(this);

TreeSelectionModel model = tree.getSelectionModel();
treeSelectionModels.put(tree, model);
model.addTreeSelectionListener(this);

return previousModel;
   }
项目:j2se_for_android    文件:JTree.java   
public void setSelectionModel(TreeSelectionModel selectionModel) {
        if (selectionModel == null)
            return;

        TreeSelectionModel oldValue = this.selectionModel;

        if (accessibleContext != null) {
            this.selectionModel
                    .removeTreeSelectionListener((TreeSelectionListener) accessibleContext);
            selectionModel
                    .addTreeSelectionListener((TreeSelectionListener) accessibleContext);
        }

        this.selectionModel = selectionModel;
//      firePropertyChange(SELECTION_MODEL_PROPERTY, oldValue, this.selectionModel);
    }
项目:j2se_for_android    文件:JTree.java   
private TreePath[] getDescendantSelectedPaths(TreePath path,
        boolean includePath) {
    TreeSelectionModel sm = getSelectionModel();
    TreePath[] selPaths = (sm != null) ? sm.getSelectionPaths() : null;

    if (selPaths != null) {
        boolean shouldRemove = false;

        for (int counter = selPaths.length - 1; counter >= 0; counter--) {
            if (selPaths[counter] != null
                    && path.isDescendant(selPaths[counter])
                    && (!path.equals(selPaths[counter]) || includePath))
                shouldRemove = true;
            else
                selPaths[counter] = null;
        }
        if (!shouldRemove) {
            selPaths = null;
        }
        return selPaths;
    }
    return null;
}
项目:LS-jsampler    文件:JSDestEffectChooser.java   
public
JSDestEffectChooser(AudioDeviceModel audioDev) {
    super(SHF.getMainFrame(), i18n.getLabel("JSDestEffectChooser.title"));
    setName("JSDestEffectChooser");



    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    tree = new JTree(new DestEffectTreeModel(audioDev));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    p.add(new JScrollPane(tree));
    p.setPreferredSize(new java.awt.Dimension(500, 300));
    setMainPane(p);

    setSavedSize();

    setResizable(true);

    tree.getSelectionModel().addTreeSelectionListener(this);
    btnOk.setEnabled(false);
}
项目:LS-jsampler    文件:JSSamplerTree.java   
/**
 * Creates a new instance of <code>JSSamplerTree</code>.
 */
public
JSSamplerTree(SamplerTreeModel model) {
    super(model);
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    addMouseListener(new MouseAdapter() {
        public void
        mousePressed(MouseEvent e) {
            if(e.getButton() != e.BUTTON3) return;
            setSelectionPath(getClosestPathForLocation(e.getX(), e.getY()));
        }
    });

    addMouseListener(new SamplerBrowser.ContextMenu(this));
}
项目:CVForge    文件:CVForgeFrame.java   
/**
 * Initialize tree properties and add listener.
 */
public void setupTreeListener(){
    libTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    libTree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)
                    libTree.getLastSelectedPathComponent();
            if (node == null)
                return;

            if (!node.children().hasMoreElements()) {
                Method m = methodCache.get(node.getUserObject());
                if (m != null){
                    callFrame.createParameterList(m);
                    callFrame.setVisible(true);
                }
            }
        }
    });
}
项目:javify    文件:JTree.java   
public void setRootVisible(boolean flag)
{
  if (rootVisible == flag)
    return;

  // If the root is currently selected, unselect it
  if (rootVisible && !flag)
    {
      TreeSelectionModel model = getSelectionModel();
      // The root is always shown in the first row
      TreePath rootPath = getPathForRow(0);
      model.removeSelectionPath(rootPath);
    }

  boolean oldValue = rootVisible;
  rootVisible = flag;
  firePropertyChange(ROOT_VISIBLE_PROPERTY, oldValue, flag);

}
项目:javify    文件:JTree.java   
public void setSelectionModel(TreeSelectionModel model)
{
  if (selectionModel == model)
    return;

  if( model == null )
    model = EmptySelectionModel.sharedInstance();

  if (selectionModel != null)
    selectionModel.removeTreeSelectionListener(selectionRedirector);

  TreeSelectionModel oldValue = selectionModel;
  selectionModel = model;

  selectionModel.addTreeSelectionListener(selectionRedirector);

  firePropertyChange(SELECTION_MODEL_PROPERTY, oldValue, model);
  revalidate();
  repaint();
}
项目:intellij-ce-playground    文件:CyclicDependenciesPanel.java   
private void initTree(final MyTree tree) {
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.setCellRenderer(new MyTreeCellRenderer(tree == myLeftTree));
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(tree);

  TreeUtil.installActions(tree);
  SmartExpander.installOn(tree);
  EditSourceOnDoubleClickHandler.install(tree);
  new TreeSpeedSearch(tree);

  PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(), ActionManager.getInstance());


}
项目:intellij-ce-playground    文件:AnalyzeDependenciesComponent.java   
/**
 * Initialize components
 */
private void init() {
  myTree.setCellRenderer(new ColoredTreeCellRenderer() {
    @Override
    public void customizeCellRenderer(JTree tree,
                                      Object value,
                                      boolean selected,
                                      boolean expanded,
                                      boolean leaf,
                                      int row,
                                      boolean hasFocus) {
      //if(getBackground() == null) {
      //  setBackground(UIUtil.getTreeTextBackground());
      //}
      if (value instanceof MyNode && !(value instanceof MyRootNode)) {
        final MyNode node = (MyNode)value;
        PathNode<?> n = (PathNode<?>)node.getUserObject();
        CellAppearanceEx a = n.getAppearance(selected, node.isDisplayInBold());
        a.customize(this);
      }
    }
  });
  myTree.setShowsRootHandles(false);
  myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  reloadTree();
}
项目:intellij-ce-playground    文件:ChooseActionsDialog.java   
public ChooseActionsDialog(Component parent, Keymap keymap, QuickList[] quicklists) {
  super(parent, true);
  myKeymap = keymap;
  myQuicklists = quicklists;

  myActionsTree = new ActionsTree();
  myActionsTree.reset(keymap, quicklists);
  myActionsTree.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      doOKAction();
      return true;
    }
  }.installOn(myActionsTree.getTree());


  myTreeExpansionMonitor = TreeExpansionMonitor.install(myActionsTree.getTree());

  setTitle("Add Actions to Quick List");
  init();
}
项目:intellij-ce-playground    文件:ModulesDependenciesPanel.java   
private static void initTree(Tree tree, boolean isRightTree) {
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.setCellRenderer(new MyTreeCellRenderer());
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  UIUtil.setLineStyleAngled(tree);

  TreeUtil.installActions(tree);
  new TreeSpeedSearch(tree, new Convertor<TreePath, String>() {
    @Override
    public String convert(TreePath o) {
      return o.getLastPathComponent().toString();
    }
  }, true);
  PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(isRightTree, tree), ActionManager.getInstance());
}
项目:intellij-ce-playground    文件:DisposerDebugger.java   
private DisposerTree(Disposable parent) {
  myModificationToFilter = -1;

  final DisposerStructure structure = new DisposerStructure(this);
  final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
  final Tree tree = new Tree(model);
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  myTreeBuilder = new FilteringTreeBuilder(tree, DisposerTree.this, structure, AlphaComparator.INSTANCE) {
    @Override
    public boolean isAutoExpandNode(NodeDescriptor nodeDescriptor) {
      return structure.getRootElement() == getOriginalNode(nodeDescriptor);
    }
  };
  myTreeBuilder.setFilteringMerge(200, MergingUpdateQueue.ANY_COMPONENT);
  Disposer.register(this, myTreeBuilder);
  myTree = tree;

  setLayout(new BorderLayout());
  add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER);

  Disposer.getTree().addListener(this);

  Disposer.register(parent, this);
}
项目:intellij-ce-playground    文件:StructureViewComponent.java   
private void installTree() {
  getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  myAutoScrollToSourceHandler.install(getTree());
  myAutoScrollFromSourceHandler.install();

  TreeUtil.installActions(getTree());

  new TreeSpeedSearch(getTree(), new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath treePath) {
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)treePath.getLastPathComponent();
      final Object userObject = node.getUserObject();
      if (userObject != null) {
        return FileStructurePopup.getSpeedSearchText(userObject);
      }
      return null;
    }
  });

  addTreeKeyListener();
  addTreeMouseListeners();
  restoreState();
}
项目:intellij-ce-playground    文件:CheckoutWizard.java   
public CheckoutWizard(final Project project) {
  super(CvsBundle.message("dialog.tittle.check.out.from.cvs.repository"), project);
  mySelectCVSConfigurationStep = new SelectCVSConfigurationStep(project, this);
  mySelectCvsElementStep = new SelectCvsElementStep(CvsBundle.message("dialog.title.select.cvs.element.to.check.out"),
                                                    this, project, mySelectCVSConfigurationStep, false,
                                                    TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, true, true);

  mySelectLocationStep = new MySelectLocationStep(project);
  myChooseModeStep = new ChooseCheckoutMode(project, this);

  addStep(mySelectCVSConfigurationStep);
  addStep(mySelectCvsElementStep);
  addStep(mySelectLocationStep);
  addStep(myChooseModeStep);

  init();
}
项目:intellij-ce-playground    文件:ModuleChooser.java   
public ModuleChooser(Project project, 
                     boolean allowFileSelection,
                     boolean allowMultipleSelection,
                     boolean allowRootSelection,
                     String expertTitle,
                     String selectModulePageTitle) {
  super(expertTitle, project);
  mySelectCVSConfigurationStep = new SelectCVSConfigurationStep(project, this);
  mySelectCvsElementStep = new SelectCvsElementStep(selectModulePageTitle,
                                                    this,
                                                    project,
                                                    mySelectCVSConfigurationStep, allowRootSelection, allowMultipleSelection ?
                                                                        TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION :
                                                                        TreeSelectionModel.SINGLE_TREE_SELECTION, true,
                                                    allowFileSelection);

  addStep(mySelectCVSConfigurationStep);
  addStep(mySelectCvsElementStep);

  init();
}