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

项目: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);
}
项目: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();
}
项目:javify    文件:JTree.java   
/**
 * Creates a new <code>JTree</code> object.
 *
 * @param model the model to use
 */
public JTree(TreeModel model)
{
  setRootVisible(true);
  setSelectionModel( new DefaultTreeSelectionModel() );

  // The root node appears expanded by default.
  nodeStates = new Hashtable();

  // The cell renderer gets set by the UI.
  cellRenderer = null;

  // Install the UI before installing the model. This way we avoid double
  // initialization of lots of UI and model stuff inside the UI and related
  // classes. The necessary UI updates are performed via property change
  // events to the UI.
  updateUI();
  setModel(model);
}
项目:vso-intellij    文件:PullRequestsTreeModel.java   
public PullRequestsTreeModel() {
    super(null);

    this.root = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_TITLE));
    setRoot(root);
    this.requestedByMeRoot = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_REQUESTED_BY_ME));
    root.insert(requestedByMeRoot, 0);
    this.assignedToMeRoot = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_ASSIGNED_TO_ME));
    root.insert(assignedToMeRoot, 1);

    allRequestedByMePullRequests = new ArrayList<GitPullRequest>();
    allAssignedToMePullRequests = new ArrayList<GitPullRequest>();

    selectionModel = new DefaultTreeSelectionModel();
    selectionModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
}
项目:jvm-stm    文件:JTree.java   
/**
 * Creates a new <code>JTree</code> object.
 * 
 * @param model the model to use
 */
public JTree(TreeModel model)
{
  setRootVisible(true);
  setSelectionModel( new DefaultTreeSelectionModel() );

  // The root node appears expanded by default.
  nodeStates = new Hashtable();

  // The cell renderer gets set by the UI.
  cellRenderer = null;

  // Install the UI before installing the model. This way we avoid double
  // initialization of lots of UI and model stuff inside the UI and related
  // classes. The necessary UI updates are performed via property change
  // events to the UI.
  updateUI();
  setModel(model);
}
项目:ireport-fork    文件:OlapBrowser.java   
/** Creates new form OlapBrowser */
public OlapBrowser() {
    initComponents();

    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    jTree1.setModel(new DefaultTreeModel(root));
    jTree1.setCellRenderer( new OlapTreeCellRenderer());

    jComboBoxType.addItem(new Tag("java.lang.String",I18n.getString("OlapBrowser.ComboBox.Text")));
    jComboBoxType.addItem(new Tag("java.lang.Number", I18n.getString("OlapBrowser.ComboBox.Numeric")));
    jComboBoxType.addItem(new Tag("java.util.Date", I18n.getString("Global.List.Date")));
    jComboBoxType.addItem(new Tag("java.util.Date", I18n.getString("OlapBrowser.ComboBox.Boolean")));

    jComboBoxType.setSelectedIndex(0);

    //applyI18n();

    ((DefaultTreeSelectionModel)jTree1.getSelectionModel()).setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION );
}
项目:crucian    文件:MappingPanel.java   
public MappingPanel(GraphPanel<?, ?> graphpanel) {
    super(graphpanel);

    // Allow multiple roots, the virtual networks.
    getTree().setRootVisible(false);
    getTree().setShowsRootHandles(true);

    listener = new MappingTreeChangeListener(this);

    // Add context menu.
    getTree().addMouseListener(new MappingPanelMouseAdapter());
    setToolTipText("Right click to open context menu");

    // Selection.
    getTree().getSelectionModel().setSelectionMode(
            DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    getTree().addTreeSelectionListener(
            new MappingTreeSelectionListener(this));

    // Color highlighting of current selection.
    getTree().setCellRenderer(new MappingTreeCellRenderer());
}
项目:JamVM-PH    文件:JTree.java   
/**
 * Creates a new <code>JTree</code> object.
 * 
 * @param model the model to use
 */
public JTree(TreeModel model)
{
  setRootVisible(true);
  setSelectionModel( new DefaultTreeSelectionModel() );

  // The root node appears expanded by default.
  nodeStates = new Hashtable();

  // The cell renderer gets set by the UI.
  cellRenderer = null;

  // Install the UI before installing the model. This way we avoid double
  // initialization of lots of UI and model stuff inside the UI and related
  // classes. The necessary UI updates are performed via property change
  // events to the UI.
  updateUI();
  setModel(model);
}
项目:processeditor    文件:WorkbenchFetchModelDialog.java   
/** Creates new form WorkbenchFetchModelDialog */
public WorkbenchFetchModelDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    resetModelList();
    resetVersions();
    // Set single selection for tree
    TreeSelectionModel selModel = new DefaultTreeSelectionModel();
    selModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    modelTree.setSelectionModel(selModel);
    // Set default server ip
    Configuration conf = Configuration.getInstance();
    serverUriTextField.setText(conf.getProperty(WorkbenchConnectToServerDialog.CONF_SERVER_URI, "http://localhost:1205"));
    userName.setText(conf.getProperty(WorkbenchConnectToServerDialog.CONF_SERVER_USER,"root"));
    userPassword.setText(conf.getProperty(WorkbenchConnectToServerDialog.CONF_SERVER_PASSWORD,"inubit"));
    connectToServerAction();
}
项目:processeditor    文件:XFormsWizard.java   
private void init() {
    editor = new ProcessEditor();
    editor.setModel(form);
    editor.setAnimationEnabled(true);
    editorPane.setLayout(new GridLayout(1,1));
    editorPane.add(editor);
    transferHandler = new XFormsWizardTransferHandler(editor);
    editor.setTransferHandler(transferHandler);
    XFormsWizardTreeCellRenderer cr = new XFormsWizardTreeCellRenderer();
    boTree.setCellRenderer(cr);
    boTree.setDragEnabled(true);
    boTree.setTransferHandler(transferHandler);
    DefaultTreeSelectionModel selModel = new DefaultTreeSelectionModel();
    selModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    boTree.setSelectionModel(selModel);
    actionTree.setCellRenderer(cr);
    actionTree.setDragEnabled(true);
    actionTree.setTransferHandler(transferHandler);
    actionTree.setRootVisible(false);
}
项目:classpath    文件:JTree.java   
/**
 * Creates a new <code>JTree</code> object.
 *
 * @param model the model to use
 */
public JTree(TreeModel model)
{
  setRootVisible(true);
  setSelectionModel( new DefaultTreeSelectionModel() );

  // The root node appears expanded by default.
  nodeStates = new Hashtable();

  // The cell renderer gets set by the UI.
  cellRenderer = null;

  // Install the UI before installing the model. This way we avoid double
  // initialization of lots of UI and model stuff inside the UI and related
  // classes. The necessary UI updates are performed via property change
  // events to the UI.
  updateUI();
  setModel(model);
}
项目:com.nomagic.magicdraw.plugins.ifml    文件:TreeHelper.java   
private static void initTreeSelection(JTree tree, NamedElement tableElement, DefaultTreeModel treeModel)
{
    TreeSelectionModel treeSelectionModel = new DefaultTreeSelectionModel();

    List<Element> nodes = IfmlModelingHelper.getNodeElements(tableElement, new ArrayList<Element>(), true);

    for (Element node : nodes)
    {
        if (IfmlModelingHelper.isSelected(node))
        {
            IfmlTreeNode treeNode = getTreeNode(node, treeModel);

            if (treeNode != null)
            {
                treeSelectionModel.addSelectionPath(new TreePath(treeNode.getPath()));
            }
        }
    }

    tree.setSelectionModel(treeSelectionModel);
}
项目:org.datagr4m    文件:JTreeTable.java   
public void setModel(TreeTableModel treeTableModel){
    // Create the tree. It will be used as a renderer and editor.
    tree = new TreeTableCellRenderer(treeTableModel);

    setModel(new TreeTableModelAdapter(treeTableModel, tree));

 // Force the JTable and JTree to share their row selection models.
    tree.setSelectionModel(new DefaultTreeSelectionModel() {
        // Extend the implementation of the constructor, as if:
        /* public this() */{
            setSelectionModel(listSelectionModel);
        }
    });
    // Make the tree and table row heights the same.
    tree.setRowHeight(getRowHeight());

    // Install the tree editor renderer and editor.
    setDefaultRenderer(TreeTableModel.class, tree);
    setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());

    setShowGrid(false);
    setIntercellSpacing(new Dimension(0, 0));
}
项目:alevin-svn2    文件:MappingPanel.java   
public MappingPanel(GraphPanel<?, ?> graphpanel, Scenario scenario) {
    super(graphpanel);

    // createTreeModel requires this.scenario,
    // therefore it cannot be called from super constructor.
    this.scenario = scenario;
    _createTreeModel();

    // Allow multiple roots, the virtual networks.
    getTree().setRootVisible(false);
    getTree().setShowsRootHandles(true);

    listener = new MappingTreeChangeListener(this);

    // Add context menu.
    getTree().addMouseListener(new MappingPanelMouseAdapter());
    setToolTipText("Right click to open context menu");

    // Selection.
    getTree().getSelectionModel().setSelectionMode(
            DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    getTree().addTreeSelectionListener(
            new MappingTreeSelectionListener(this));

    // Color highlighting of current selection.
    getTree().setCellRenderer(new MappingTreeCellRenderer());
}
项目:javaportfolio    文件:JTreeTable.java   
public JTreeTable(TreeTableModel treeTableModel) {
    super();

    // Create the tree. It will be used as a renderer and editor.
    tree = new TreeTableCellRenderer(treeTableModel, this);

    // Install a tableModel representing the visible rows in the tree.
    super.setModel(new TreeTableModelAdapter(treeTableModel, tree));

    // Force the JTable and JTree to share their row selection models.
    tree.setSelectionModel(new DefaultTreeSelectionModel() {
        // Extend the implementation of the constructor, as if:
        /* public this() */{
            setSelectionModel(listSelectionModel);
        }
    });
    // Make the tree and table row heights the same.
    tree.setRowHeight(getRowHeight());

    // Install the tree editor renderer and editor.
    setDefaultRenderer(TreeTableModel.class, tree);
    setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());

    setShowGrid(false);
    setIntercellSpacing(new Dimension(0, 0));

    cellRendererRedLeft = new CellRenderer(java.awt.Color.RED, false, null);
    cellRendererGreenLeft = new CellRenderer(java.awt.Color.GREEN, false, null);
    cellRendererRedRight = new CellRenderer(java.awt.Color.RED, true, null);
    cellRendererGreenRight = new CellRenderer(java.awt.Color.GREEN, true, null);
    cellRendererYellowLeft = new CellRenderer(java.awt.Color.YELLOW, false, null);
    cellRendererYellowRight = new CellRenderer(java.awt.Color.YELLOW, true, null);

    setPreferredScrollableViewportSize(new Dimension(1000, 500));
    setFillsViewportHeight(true);
    setAutoCreateRowSorter(true);
}
项目:geoxygene    文件:OntologyBrowser.java   
public OntologyBrowser(OWLOntology ontology) {
  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);
  // set the tree renderer
  OntologyRenderer myRenderer = new OntologyRenderer();
  this.setCellRenderer(myRenderer);
  this.setRootVisible(false);
}
项目:geoxygene    文件:OntologyBrowser.java   
public OntologyBrowser(OWLOntology ontology, String rootConcept) {
  super();
  this.ontology = ontology;
  this.rootConcept = rootConcept;
  this.buildTreeModel();
  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);
}
项目:j2se_for_android    文件:JTree.java   
public JTree(TreeModel newModel) {
        super();
        visibleRowCount = 15;
        rootVisible = true;
        selectionModel = new DefaultTreeSelectionModel();
        cellRenderer = null;
//      {
//          LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
//          defaultLinearLayout.addView(rootScrollView, lp);
//      }
//      setPeerAdAPI(defaultLinearLayout);
        setModel(newModel);
        updateUI();
    }
项目:binnavi    文件:CTagsTree.java   
/**
 * Creates a new tree object.
 *
 * @param parent Parent window used for dialogs.
 * @param graph Graph shown in the window.
 * @param manager Provides tag information.
 */
public CTagsTree(final JFrame parent, final ZyGraph graph, final ITagManager manager) {
  m_parent = Preconditions.checkNotNull(parent, "IE02308: Perent argument can not be null");
  m_graph = Preconditions.checkNotNull(graph, "IE01776: Graph can not be null");
  m_tagManager = Preconditions.checkNotNull(manager, "IE01777: Manager argument can not be null");

  m_model = new CTagsTreeModel(this);
  setModel(m_model);
  getModel().addTreeModelListener(new InternalModelListener());
  addMouseListener(m_mouseListener);
  m_graph.addListener(m_graphSelectionListener);
  m_graph.addListener(m_graphVisibilityListener);

  setRootVisible(false);

  m_rootNode = new CRootTagTreeNode(parent, this, graph, m_tagManager);
  m_model.setRoot(m_rootNode);

  setCellRenderer(new CTagTreeCellRenderer()); // ATTENTION: UNDER NO CIRCUMSTANCES MOVE THIS LINE
                                               // ABOVE THE SETROOT LINE

  m_model.nodeStructureChanged(m_rootNode);

  final List<IDropHandler> handlers = new ArrayList<IDropHandler>();

  handlers.add(new CTagSortingHandler());

  new CDefaultTransferHandler(this, DnDConstants.ACTION_COPY_OR_MOVE, handlers);

  final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  setSelectionModel(selectionModel);

  final InputMap windowImap = getInputMap(JComponent.WHEN_FOCUSED);

  windowImap.put(HotKeys.DELETE_HK.getKeyStroke(), "DELETE");
  getActionMap().put("DELETE", CActionProxy.proxy(new DeleteAction()));
}
项目:binnavi    文件:TypesTree.java   
public TypesTree() {
  setRootVisible(false);
  setDragEnabled(true);
  setDropMode(DropMode.INSERT); // Dropped objects are inserted behind the drop location.
  setToggleClickCount(1); // Child nodes expand with a single click.
  final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  setSelectionModel(selectionModel);
  final IconNodeRenderer renderer = new IconNodeRenderer();
  renderer.setFont(GuiHelper.MONOSPACED_FONT);
  setCellRenderer(renderer);
}
项目:binnavi    文件:CSelectionHistoryChooser.java   
/**
 * Frees allocated resources.
 */
public void dispose() {
  m_selectionHistory.removeHistoryListener(m_selectionHistoryListener);

  m_graph.removeListener(m_graphSelectionListener);
  m_tree.removeMouseListener(m_treeMouseListener);
  m_tree.removeTreeSelectionListener(m_treeSelectionListener);

  m_tree.setSelectionModel(new DefaultTreeSelectionModel());
}
项目:tug_qt_unit_testing_fw    文件:JTreeTable.java   
public JTreeTable(TreeTableModel treeTableModel) {
    super();

    // Create the tree. It will be used as a renderer and editor. 
    tree = new TreeTableCellRenderer(treeTableModel); 

    // Install a tableModel representing the visible rows in the tree. 
    setModel(new TreeTableModelAdapter(treeTableModel, tree));

    // Force the JTable and JTree to share their row selection models. 
    tree.setSelectionModel(new DefaultTreeSelectionModel() { 
        // Extend the implementation of the constructor, as if: 
        /* public this() */ {
            setSelectionModel(listSelectionModel); 
        } 
    }); 
    // Make the tree and table row heights the same. 
    tree.setRowHeight(getRowHeight());

    // Install the tree editor renderer and editor. 
    setDefaultRenderer(TreeTableModel.class, tree); 
    setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor()); 

    // Install the boolean editor renderer and editor. 
    //setDefaultEditor(Boolean.class, new BooleanTableCellEditor()); 

    // look options
    setShowGrid(false);
    setIntercellSpacing(new Dimension(0, 0));           
}
项目:NJULily    文件:MyTree.java   
public MyTree(DefaultMutableTreeNode _root){

    root = _root;

    Color foreColor = Color.WHITE;
    Color backColor = MyColor.getColor();

    toggleClickCount = 2;     
       setLayout(null);
       rowHeight = 16;
       visibleRowCount = 20;
       rootVisible = true;
       selectionModel = new DefaultTreeSelectionModel();
       cellRenderer = null;
       scrollsOnExpand = true;
       setOpaque(true);
       //  expandsSelectedPaths = true;
       updateUI();

       controller = new CommoditySortController();

       initTree(root, controller.show().get(0).ID);

       DefaultTreeModel model = new DefaultTreeModel(root, true);
       model.reload();
       setModel(model);

       this.setForeground(foreColor);
    this.setBackground(backColor);

    DefaultTreeCellRenderer cellRender = new DefaultTreeCellRenderer();
    cellRender.setBackgroundNonSelectionColor(backColor);
    cellRender.setBackgroundSelectionColor(Color.BLACK);
    cellRender.setBorderSelectionColor(Color.WHITE);
    cellRender.setTextSelectionColor(Color.WHITE);
    cellRender.setTextNonSelectionColor(Color.WHITE);

    this.setCellRenderer(cellRender);
}
项目:development-tools-incubation    文件:SelectionInTree.java   
/**
 * Constructs a SelectionInTree on the given tree model.
 * 
 * @param model - the initial tree model
 * @param selectionHolder - the selection holder
 */
public SelectionInTree(TreeModel model, ValueModel selectionHolder)
{
   this.selectionHolder = selectionHolder;
   this.selectionModel = new DefaultTreeSelectionModel();

   setTree(model);

   selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

   selectionModel.addTreeSelectionListener(treeSelectionHandler);
   selectionHolder.addValueChangeListener(selectionChangeHandler);
}
项目:Alevin    文件:MappingPanel.java   
public MappingPanel(GraphPanel<?, ?> graphpanel, Scenario scenario) {
    super(graphpanel);

    // createTreeModel requires this.scenario,
    // therefore it cannot be called from super constructor.
    this.scenario = scenario;
    _createTreeModel();

    // Allow multiple roots, the virtual networks.
    getTree().setRootVisible(false);
    getTree().setShowsRootHandles(true);

    listener = new MappingTreeChangeListener(this);

    // Add context menu.
    getTree().addMouseListener(new MappingPanelMouseAdapter());
    setToolTipText("Right click to open context menu");

    // Selection.
    getTree().getSelectionModel().setSelectionMode(
            DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
    getTree().addTreeSelectionListener(
            new MappingTreeSelectionListener(this));

    // Color highlighting of current selection.
    getTree().setCellRenderer(new MappingTreeCellRenderer());
}
项目:cn1    文件:JTreeTest.java   
public void testTreeSelectionRedirector() throws Exception {
    assertNull(tree.selectionRedirector);
    DefaultTreeSelectionModel model = (DefaultTreeSelectionModel) tree.getSelectionModel();
    assertFalse(hasListener(model.getTreeSelectionListeners(),
            JTree.TreeSelectionRedirector.class));
    final Marker marker = new Marker();
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(final TreeSelectionEvent e) {
            marker.setAuxiliary(e);
        }
    });
    assertNotNull(tree.selectionRedirector);
    assertTrue(hasListener(model.getTreeSelectionListeners(),
            JTree.TreeSelectionRedirector.class));
    TreePath path = new TreePath("root");
    TreePath oldLead = new TreePath("old_lead");
    TreePath newLead = new TreePath("new_lead");
    tree.selectionRedirector.valueChanged(new TreeSelectionEvent("any_source", path, true,
            oldLead, newLead));
    assertNotNull(marker.getAuxiliary());
    TreeSelectionEvent redirectedEvent = (TreeSelectionEvent) marker.getAuxiliary();
    assertSame(tree, redirectedEvent.getSource());
    assertSame(path, redirectedEvent.getPath());
    assertTrue(redirectedEvent.isAddedPath());
    assertSame(oldLead, redirectedEvent.getOldLeadSelectionPath());
    assertSame(newLead, redirectedEvent.getNewLeadSelectionPath());
    DefaultTreeSelectionModel newModel = new DefaultTreeSelectionModel();
    tree.setSelectionModel(newModel);
    assertTrue(hasListener(newModel.getTreeSelectionListeners(),
            JTree.TreeSelectionRedirector.class));
    tree.setSelectionModel(null);
    assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getTreeSelectionListeners(), JTree.TreeSelectionRedirector.class));
}
项目:cn1    文件:BasicTreeUITest.java   
public void testSetGetSelectionModel() {
    assertTrue(ui.getSelectionModel() instanceof DefaultTreeSelectionModel);
    DefaultTreeSelectionModel m = new DefaultTreeSelectionModel();
    ui.setSelectionModel(m);
    assertSame(m, ui.getSelectionModel());
    assertSame(m, ui.treeSelectionModel);
}
项目:cn1    文件:BasicTreeUITest.java   
public void testInstallUninstallListeners() {
    if (!isHarmony()) {
        return;
    }
    assertTrue(hasListener(tree.getFocusListeners(), BasicTreeUI.FocusHandler.class));
    assertTrue(hasListener(tree.getKeyListeners(), BasicTreeUI.KeyHandler.class));
    assertTrue(hasListener(tree.getMouseListeners(), BasicTreeUI.MouseHandler.class));
    assertTrue(hasListener(tree.getMouseMotionListeners(), BasicTreeUI.MouseHandler.class));
    assertTrue(hasListener(tree.getPropertyChangeListeners(),
            BasicTreeUI.PropertyChangeHandler.class));
    assertTrue(hasListener(tree.getTreeExpansionListeners(),
            BasicTreeUI.TreeExpansionHandler.class));
    assertTrue(hasListener(((DefaultTreeModel) tree.getModel()).getTreeModelListeners(),
            BasicTreeUI.TreeModelHandler.class));
    assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getTreeSelectionListeners(), BasicTreeUI.TreeSelectionHandler.class));
    assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getPropertyChangeListeners(),
            BasicTreeUI.SelectionModelPropertyChangeHandler.class));
    ui.uninstallListeners();
    assertFalse(hasListener(tree.getFocusListeners(), BasicTreeUI.FocusHandler.class));
    assertFalse(hasListener(tree.getKeyListeners(), BasicTreeUI.KeyHandler.class));
    assertFalse(hasListener(tree.getMouseListeners(), BasicTreeUI.MouseHandler.class));
    assertFalse(hasListener(tree.getMouseMotionListeners(), BasicTreeUI.MouseHandler.class));
    assertFalse(hasListener(tree.getPropertyChangeListeners(),
            BasicTreeUI.PropertyChangeHandler.class));
    assertFalse(hasListener(tree.getTreeExpansionListeners(),
            BasicTreeUI.TreeExpansionHandler.class));
    assertFalse(hasListener(tree.getTreeSelectionListeners(),
            BasicTreeUI.TreeSelectionHandler.class));
    assertFalse(hasListener(((DefaultTreeModel) tree.getModel()).getTreeModelListeners(),
            BasicTreeUI.TreeModelHandler.class));
    assertFalse(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getTreeSelectionListeners(), BasicTreeUI.TreeSelectionHandler.class));
    assertFalse(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getPropertyChangeListeners(),
            BasicTreeUI.SelectionModelPropertyChangeHandler.class));
}
项目:OneCMDBwithMaven    文件:JTreeTable.java   
public JTreeTable(TreeTableModel paramTreeTableModel)
{
  this.tree = new TreeTableCellRenderer(paramTreeTableModel);
  super.setModel(new TreeTableModelAdapter(paramTreeTableModel, this.tree));
  this.tree.setSelectionModel(new DefaultTreeSelectionModel()
  {
  });
  this.tree.setRowHeight(getRowHeight());
  setDefaultRenderer(TreeTableModel.class, this.tree);
  setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());
  setShowGrid(false);
  setIntercellSpacing(new Dimension(0, 0));
}
项目:polydes    文件:DTreeSelectionModel.java   
@Override
public void setSelectionMode(int mode)
{
    int oldMode = this.mode;
    this.mode = mode;

    if(oldMode != mode)
        propertyChanges.firePropertyChange(DefaultTreeSelectionModel.SELECTION_MODE_PROPERTY, oldMode, mode);
}
项目:SORCER    文件:AttributePanel.java   
public AttributePanel(Provider prv, int visibleRows) {
    provider = prv;
    try {
        attributes = provider.getAttributes();
    } catch (Exception pe) {
        pe.printStackTrace();
    }
    setLayout(new GridLayout(1, 1));
    // Init tree node and model (attribute tree nodes)
    root = new AttributeRootNode();
    model = new DefaultTreeModel(root);

    // Init tree view
    tree = new JTree(model);
    if (visibleRows != 0)
        tree.setVisibleRowCount(visibleRows);
    tree.putClientProperty("JTree.lineStyle", "Angled");
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    smodel = new DefaultTreeSelectionModel();
    smodel
            .setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    smodel
            .addTreeSelectionListener(slistener = new AttributeSelectionListener());
    tree.setSelectionModel(smodel);
    tree.setCellRenderer(new AttributeCellRenderer());
    tree.addMouseListener(new AttributePopup());

    scrollPane = new JScrollPane(tree);
    scrollPane.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    add(scrollPane, BorderLayout.CENTER);

    // validate components
    tree.validate();
    scrollPane.validate();
}
项目:freeVM    文件:JTreeTest.java   
public void testTreeSelectionRedirector() throws Exception {
    assertNull(tree.selectionRedirector);
    DefaultTreeSelectionModel model = (DefaultTreeSelectionModel) tree.getSelectionModel();
    assertFalse(hasListener(model.getTreeSelectionListeners(),
            JTree.TreeSelectionRedirector.class));
    final Marker marker = new Marker();
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(final TreeSelectionEvent e) {
            marker.setAuxiliary(e);
        }
    });
    assertNotNull(tree.selectionRedirector);
    assertTrue(hasListener(model.getTreeSelectionListeners(),
            JTree.TreeSelectionRedirector.class));
    TreePath path = new TreePath("root");
    TreePath oldLead = new TreePath("old_lead");
    TreePath newLead = new TreePath("new_lead");
    tree.selectionRedirector.valueChanged(new TreeSelectionEvent("any_source", path, true,
            oldLead, newLead));
    assertNotNull(marker.getAuxiliary());
    TreeSelectionEvent redirectedEvent = (TreeSelectionEvent) marker.getAuxiliary();
    assertSame(tree, redirectedEvent.getSource());
    assertSame(path, redirectedEvent.getPath());
    assertTrue(redirectedEvent.isAddedPath());
    assertSame(oldLead, redirectedEvent.getOldLeadSelectionPath());
    assertSame(newLead, redirectedEvent.getNewLeadSelectionPath());
    DefaultTreeSelectionModel newModel = new DefaultTreeSelectionModel();
    tree.setSelectionModel(newModel);
    assertTrue(hasListener(newModel.getTreeSelectionListeners(),
            JTree.TreeSelectionRedirector.class));
    tree.setSelectionModel(null);
    assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getTreeSelectionListeners(), JTree.TreeSelectionRedirector.class));
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testSetGetSelectionModel() {
    assertTrue(ui.getSelectionModel() instanceof DefaultTreeSelectionModel);
    DefaultTreeSelectionModel m = new DefaultTreeSelectionModel();
    ui.setSelectionModel(m);
    assertSame(m, ui.getSelectionModel());
    assertSame(m, ui.treeSelectionModel);
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testInstallUninstallListeners() {
    if (!isHarmony()) {
        return;
    }
    assertTrue(hasListener(tree.getFocusListeners(), BasicTreeUI.FocusHandler.class));
    assertTrue(hasListener(tree.getKeyListeners(), BasicTreeUI.KeyHandler.class));
    assertTrue(hasListener(tree.getMouseListeners(), BasicTreeUI.MouseHandler.class));
    assertTrue(hasListener(tree.getMouseMotionListeners(), BasicTreeUI.MouseHandler.class));
    assertTrue(hasListener(tree.getPropertyChangeListeners(),
            BasicTreeUI.PropertyChangeHandler.class));
    assertTrue(hasListener(tree.getTreeExpansionListeners(),
            BasicTreeUI.TreeExpansionHandler.class));
    assertTrue(hasListener(((DefaultTreeModel) tree.getModel()).getTreeModelListeners(),
            BasicTreeUI.TreeModelHandler.class));
    assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getTreeSelectionListeners(), BasicTreeUI.TreeSelectionHandler.class));
    assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getPropertyChangeListeners(),
            BasicTreeUI.SelectionModelPropertyChangeHandler.class));
    ui.uninstallListeners();
    assertFalse(hasListener(tree.getFocusListeners(), BasicTreeUI.FocusHandler.class));
    assertFalse(hasListener(tree.getKeyListeners(), BasicTreeUI.KeyHandler.class));
    assertFalse(hasListener(tree.getMouseListeners(), BasicTreeUI.MouseHandler.class));
    assertFalse(hasListener(tree.getMouseMotionListeners(), BasicTreeUI.MouseHandler.class));
    assertFalse(hasListener(tree.getPropertyChangeListeners(),
            BasicTreeUI.PropertyChangeHandler.class));
    assertFalse(hasListener(tree.getTreeExpansionListeners(),
            BasicTreeUI.TreeExpansionHandler.class));
    assertFalse(hasListener(tree.getTreeSelectionListeners(),
            BasicTreeUI.TreeSelectionHandler.class));
    assertFalse(hasListener(((DefaultTreeModel) tree.getModel()).getTreeModelListeners(),
            BasicTreeUI.TreeModelHandler.class));
    assertFalse(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getTreeSelectionListeners(), BasicTreeUI.TreeSelectionHandler.class));
    assertFalse(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getPropertyChangeListeners(),
            BasicTreeUI.SelectionModelPropertyChangeHandler.class));
}
项目:freeVM    文件:JTreeTest.java   
public void testTreeSelectionRedirector() throws Exception {
    assertNull(tree.selectionRedirector);
    DefaultTreeSelectionModel model = (DefaultTreeSelectionModel) tree.getSelectionModel();
    assertFalse(hasListener(model.getTreeSelectionListeners(),
            JTree.TreeSelectionRedirector.class));
    final Marker marker = new Marker();
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(final TreeSelectionEvent e) {
            marker.setAuxiliary(e);
        }
    });
    assertNotNull(tree.selectionRedirector);
    assertTrue(hasListener(model.getTreeSelectionListeners(),
            JTree.TreeSelectionRedirector.class));
    TreePath path = new TreePath("root");
    TreePath oldLead = new TreePath("old_lead");
    TreePath newLead = new TreePath("new_lead");
    tree.selectionRedirector.valueChanged(new TreeSelectionEvent("any_source", path, true,
            oldLead, newLead));
    assertNotNull(marker.getAuxiliary());
    TreeSelectionEvent redirectedEvent = (TreeSelectionEvent) marker.getAuxiliary();
    assertSame(tree, redirectedEvent.getSource());
    assertSame(path, redirectedEvent.getPath());
    assertTrue(redirectedEvent.isAddedPath());
    assertSame(oldLead, redirectedEvent.getOldLeadSelectionPath());
    assertSame(newLead, redirectedEvent.getNewLeadSelectionPath());
    DefaultTreeSelectionModel newModel = new DefaultTreeSelectionModel();
    tree.setSelectionModel(newModel);
    assertTrue(hasListener(newModel.getTreeSelectionListeners(),
            JTree.TreeSelectionRedirector.class));
    tree.setSelectionModel(null);
    assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getTreeSelectionListeners(), JTree.TreeSelectionRedirector.class));
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testSetGetSelectionModel() {
    assertTrue(ui.getSelectionModel() instanceof DefaultTreeSelectionModel);
    DefaultTreeSelectionModel m = new DefaultTreeSelectionModel();
    ui.setSelectionModel(m);
    assertSame(m, ui.getSelectionModel());
    assertSame(m, ui.treeSelectionModel);
}
项目:freeVM    文件:BasicTreeUITest.java   
public void testInstallUninstallListeners() {
    if (!isHarmony()) {
        return;
    }
    assertTrue(hasListener(tree.getFocusListeners(), BasicTreeUI.FocusHandler.class));
    assertTrue(hasListener(tree.getKeyListeners(), BasicTreeUI.KeyHandler.class));
    assertTrue(hasListener(tree.getMouseListeners(), BasicTreeUI.MouseHandler.class));
    assertTrue(hasListener(tree.getMouseMotionListeners(), BasicTreeUI.MouseHandler.class));
    assertTrue(hasListener(tree.getPropertyChangeListeners(),
            BasicTreeUI.PropertyChangeHandler.class));
    assertTrue(hasListener(tree.getTreeExpansionListeners(),
            BasicTreeUI.TreeExpansionHandler.class));
    assertTrue(hasListener(((DefaultTreeModel) tree.getModel()).getTreeModelListeners(),
            BasicTreeUI.TreeModelHandler.class));
    assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getTreeSelectionListeners(), BasicTreeUI.TreeSelectionHandler.class));
    assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getPropertyChangeListeners(),
            BasicTreeUI.SelectionModelPropertyChangeHandler.class));
    ui.uninstallListeners();
    assertFalse(hasListener(tree.getFocusListeners(), BasicTreeUI.FocusHandler.class));
    assertFalse(hasListener(tree.getKeyListeners(), BasicTreeUI.KeyHandler.class));
    assertFalse(hasListener(tree.getMouseListeners(), BasicTreeUI.MouseHandler.class));
    assertFalse(hasListener(tree.getMouseMotionListeners(), BasicTreeUI.MouseHandler.class));
    assertFalse(hasListener(tree.getPropertyChangeListeners(),
            BasicTreeUI.PropertyChangeHandler.class));
    assertFalse(hasListener(tree.getTreeExpansionListeners(),
            BasicTreeUI.TreeExpansionHandler.class));
    assertFalse(hasListener(tree.getTreeSelectionListeners(),
            BasicTreeUI.TreeSelectionHandler.class));
    assertFalse(hasListener(((DefaultTreeModel) tree.getModel()).getTreeModelListeners(),
            BasicTreeUI.TreeModelHandler.class));
    assertFalse(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getTreeSelectionListeners(), BasicTreeUI.TreeSelectionHandler.class));
    assertFalse(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
            .getPropertyChangeListeners(),
            BasicTreeUI.SelectionModelPropertyChangeHandler.class));
}
项目:cagrid-core    文件:QueryTree.java   
public QueryTree() {
    rootNode = new DefaultMutableTreeNode();
    // cause each row to be queried for its height
    setRowHeight(-1);
    setModel(new DefaultTreeModel(rootNode));       
    setRootVisible(false);
    setEditable(false);
    setSelectionModel(new DefaultTreeSelectionModel());
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    setCellRenderer(new QueryTreeRenderer());
}
项目:qtaste    文件:DebugTreeTable.java   
public DebugTreeTable(TreeTableModel treeTableModel) {
    super();
    mTreeTableModel = treeTableModel;

    // Create the tree. It will be used as a renderer and editor.
    tree = new TreeTableCellRenderer(treeTableModel);
    //tree = new DebugTreeCellRenderer();

    // Install a tableModel representing the visible rows in the tree.
    super.setModel(new TreeTableModelAdapter(treeTableModel, tree));

    // Force the JTable and JTree to share their row selection models.
    tree.setSelectionModel(new DefaultTreeSelectionModel() {
        {
            setSelectionModel(listSelectionModel);
        }
    });
    // Make the tree and table row heights the same.
    tree.setRowHeight(getRowHeight());
    // Install the tree editor renderer and editor.
    setDefaultRenderer(TreeTableModel.class, tree);
    this.setFont(SMALL_FONT);
    getColumnModel().getColumn(0).setPreferredWidth(50);
    getColumnModel().getColumn(0).setMinWidth(100);

    setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());

    setShowGrid(false);
    setIntercellSpacing(new Dimension(0, 0));
}