Java Code Examples for javax.swing.JTree#setCellRenderer()

The following examples show how to use javax.swing.JTree#setCellRenderer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectDialog.java    From quickfix-messenger with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void initComponents()
{
	setLayout(new BorderLayout());

	mainPanel = new JPanel();
	mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

	JScrollPane mainScrollPane = new JScrollPane();
	mainScrollPane.setPreferredSize(new Dimension(300, 400));
	add(mainScrollPane, BorderLayout.CENTER);

	projectTree = new JTree();
	projectTree.setEditable(true);
	projectTree.setModel(new ProjectTreeModel(xmlProjectType));
	projectTree.setCellRenderer(new ProjectTreeCellRenderer(frame));
	projectTree.setCellEditor(new ProjectTreeCellEditor(projectTree));
	projectTree.getSelectionModel().setSelectionMode(
			TreeSelectionModel.SINGLE_TREE_SELECTION);
	projectTree.addMouseListener(new ProjectTreeMouseListener(frame,
			projectTree));
	projectTree.expandRow(1);

	mainScrollPane.getViewport().add(projectTree);

	pack();
}
 
Example 2
Source File: ClassHierarchyPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ClassHierarchyPanel(boolean isView) {
    initComponents();
    if (!isView) {
        toolBar.remove(0);
        toolBar.remove(0);
        subtypeButton.setFocusable(true);
        supertypeButton.setFocusable(true);
    }
    setName(NbBundle.getMessage(getClass(), "CTL_ClassHierarchyTopComponent")); // NOI18N
    setToolTipText(NbBundle.getMessage(getClass(), "HINT_ClassHierarchyTopComponent")); // NOI18N
    tree = new JTree();
    treeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    tree.setModel(treeModel);
    tree.setToggleClickCount(0);
    tree.setCellRenderer(new TreeRenderer());
    tree.putClientProperty("JTree.lineStyle", "Angled");  //NOI18N
    tree.expandRow(0);
    tree.setShowsRootHandles(true);
    tree.setSelectionRow(0);
    tree.setRootVisible(false);
    hierarchyPane.add(tree);
    hierarchyPane.setViewportView(tree);
    tree.addMouseListener(mouseListener);
}
 
Example 3
Source File: ExplainDialogFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private JTree createExplanationTree() {
  DefaultMutableTreeNode top = createNode(explanation);
  traverse(top, explanation.getDetails());

  JTree tree = new JTree(top);
  tree.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
  renderer.setOpenIcon(null);
  renderer.setClosedIcon(null);
  renderer.setLeafIcon(null);
  tree.setCellRenderer(renderer);
  // expand all nodes
  for (int row = 0; row < tree.getRowCount(); row++) {
    tree.expandRow(row);
  }
  return tree;
}
 
Example 4
Source File: SimulationExplorer.java    From Logisim with GNU General Public License v3.0 6 votes vote down vote up
SimulationExplorer(Project proj, MenuListener menu) {
	super(new BorderLayout());
	this.project = proj;

	SimulationToolbarModel toolbarModel = new SimulationToolbarModel(proj, menu);
	Toolbar toolbar = new Toolbar(toolbarModel);
	add(toolbar, BorderLayout.NORTH);

	model = new SimulationTreeModel(proj.getSimulator().getCircuitState());
	model.setCurrentView(project.getCircuitState());
	tree = new JTree(model);
	tree.setCellRenderer(new SimulationTreeRenderer());
	tree.addMouseListener(this);
	tree.setToggleClickCount(3);
	add(new JScrollPane(tree), BorderLayout.CENTER);
	proj.addProjectListener(this);
}
 
Example 5
Source File: RepositoryTreeDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void init( final boolean addNewButtonPanel ) {

    setModal( true );
    setTitle( Messages.getInstance().getString( "SolutionRepositoryTreeDialog.Title" ) );

    this.addNewButtonPanel = addNewButtonPanel;

    this.repositoryTreeModel = new RepositoryTreeModel();

    repositoryBrowser = new JTree( repositoryTreeModel );
    repositoryBrowser.setCellRenderer( new RepositoryTreeCellRenderer() );
    repositoryBrowser.addMouseListener( new DoubleClickHandler() );
    repositoryBrowser.setRootVisible( true );
    repositoryBrowser.setShowsRootHandles( true );
    repositoryBrowser.setToggleClickCount( 1 );

    super.init();
    setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
  }
 
Example 6
Source File: HttpMessageSelectorPanel.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public HttpMessageSelectorPanel() {
    panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setAutoCreateGaps(true);

    SiteNode root =
            new SiteNode(
                    null,
                    -1,
                    Constant.messages.getString(
                            "fuzz.httpfuzzer.select.message.dialogue.rootNode"));
    SiteNode mainTreeRoot = Model.getSingleton().getSession().getSiteTree().getRoot();
    copyTree(mainTreeRoot, root);
    messagesTreeModel = new DefaultTreeModel(root);

    messagesTree = new JTree(messagesTreeModel);
    messagesTree.setVisibleRowCount(10);
    messagesTree.setShowsRootHandles(true);
    messagesTree.setName("HttpMessageSelectorTree");
    messagesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    messagesTree.setCellRenderer(
            new SiteMapTreeCellRenderer(Collections.<SiteMapListener>emptyList()));
    messagesTree.expandRow(0);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(messagesTree);

    layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(scrollPane));
    layout.setVerticalGroup(layout.createSequentialGroup().addComponent(scrollPane));
}
 
Example 7
Source File: ModelsPanel.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
private void init() {
    treeModel.setRoot(createRoot());

    tree = new JTree(treeModel) {
        @Override
        public TreeCellRenderer getCellRenderer() {
            TreeCellRenderer renderer = super.getCellRenderer();
            if (renderer == null)
                return null;
            ((DefaultTreeCellRenderer) renderer).setLeafIcon(new ImageIcon(
                    getClass().getResource("/images/function.png")));
            return renderer;
        }
    };

    tree.setCellRenderer(new Renderer());

    tree.setEditable(true);

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if ((e.getButton() == MouseEvent.BUTTON1)
                    && (e.getClickCount() == 2)) {
                openDiagram();
            }
        }

    });

    tree.setRootVisible(true);

    JScrollPane pane = new JScrollPane();
    pane.setViewportView(tree);
    this.add(pane, BorderLayout.CENTER);
}
 
Example 8
Source File: DependencyViewerStandalone.java    From gradle-view with Apache License 2.0 5 votes vote down vote up
public void updateView(GradleNode rootDependency, GradleNode selectedDependency) {
    // TODO replace this hack with something that populates the GradleNode graph

    DefaultMutableTreeNode fullRoot = new DefaultMutableTreeNode(new GradleNode("Project Dependencies"));
    if(rootDependency == null) {
        DefaultMutableTreeNode loading = new DefaultMutableTreeNode(new GradleNode("Loading..."));
        fullRoot.add(loading);
    } else {
        DefaultMutableTreeNode flattenedRoot = convertToSortedTreeNode(rootDependency);
        DefaultMutableTreeNode hierarchyRoot = convertToHierarchyTreeNode(rootDependency);
        fullRoot.add(flattenedRoot);
        fullRoot.add(hierarchyRoot);
    }

    TreeModel treeModel = new DefaultTreeModel(fullRoot);
    final JTree fullTree = new JTree(treeModel);
    fullTree.setCellRenderer(dependencyCellRenderer);

    // expand path for first level from root
    //fullTree.expandPath(new TreePath(hierarchyRoot.getNextNode().getPath()));

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            if(gradleBaseDir != null) {
                setTitle(TITLE + " - " + gradleBaseDir);
            }
            splitter.setLeftComponent(new JScrollPane(fullTree));
            splitter.setRightComponent(new JScrollPane(information));
            splitter.setDividerLocation(0.75);
        }
    });
}
 
Example 9
Source File: GUIBrowser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void addWindowTab() {
    if (compNode instanceof WindowNode
            && ((WindowNode) compNode).getWindows().length > 0) {
        winTree = new JTree(((WindowNode) compNode).getWindowModel());
        winTree.setCellRenderer(renderer);
        winTree.setEditable(false);
        winTree.addTreeSelectionListener(selManager);
        winSplit = createUnderPane(winTree);
        tbd.add(WINDOWS_TAB, winSplit);
    }

}
 
Example 10
Source File: DatasetTreeView.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
DatasetTreeView() {
  // the catalog tree
  tree = new JTree() {
    public JToolTip createToolTip() {
      return new MultilineTooltip();
    }
  };
  tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode(null, false)));
  tree.setCellRenderer(new MyTreeCellRenderer());

  tree.addMouseListener(new MouseAdapter() {
    public void mousePressed(MouseEvent e) {
      int selRow = tree.getRowForLocation(e.getX(), e.getY());
      if (selRow != -1) {
        TreeNode node = (TreeNode) tree.getLastSelectedPathComponent();
        if (node instanceof VariableNode) {
          Variable v = ((VariableNode) node).var;
          firePropertyChangeEvent(new PropertyChangeEvent(this, "Selection", null, v));
        }
      }
    }
  });

  tree.putClientProperty("JTree.lineStyle", "Angled");
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.setToggleClickCount(1);
  ToolTipManager.sharedInstance().registerComponent(tree);

  // layout
  setLayout(new BorderLayout());
  add(new JScrollPane(tree), BorderLayout.CENTER);
}
 
Example 11
Source File: TreeViewerUtil.java    From cst with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static DefaultTreeModel createTreeModelGUI(JScrollPane scrollPane, List<? extends Codelet> codelets, String title) {

        DefaultTreeModel treeCodelets = createTreeModel(codelets, title, TreeElement.ICON_CODELETS);

        JTree jtTree = new JTree(treeCodelets);
        jtTree.setCellRenderer(new RendererJTree());
        expandAllNodes(jtTree);
        scrollPane.setViewportView(jtTree);
        
        return treeCodelets;
    }
 
Example 12
Source File: XMLTree.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
public void activateTool(BrowserContext c, Element e) {
   context = c;
   element = e;

   String attr = element.getAttribute("showattributes");
   if (attr != null) {
     if (attr.equals("1")) {
showAttributes = true;
     }
   }

   filtered.add("tmp:refvalue");

   String filter = element.getAttribute("filter");
   if (filter != null) {
     String[] f = Strings.split(filter, ',');
     for (int i = 0; i < f.length; i++) {
filtered.add(f[i]);
     }
   }

   String start = element.getAttribute("start");
   if (start != null) {
     startElement = context.getSourceElementByReference(start);
   }

   JTree tree = new JTree(new DOMTreeModel(startElement));
   tree.setCellRenderer(new DOMTreeCellRenderer());
   selectionModel = new DOMTreeSelectionModel();
   tree.setSelectionModel(selectionModel);

   flag = context.flagger.addFlagListener(FlagManager.SELECTION, listener);

   window = context.getWindowCreator().createWindow("XML Tree");
   window.getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
   window.open();
 }
 
Example 13
Source File: FabricMainWindow.java    From fabric-loader with Apache License 2.0 5 votes vote down vote up
private static JPanel createTreePanel(FabricStatusNode rootNode, FabricTreeWarningLevel minimumWarningLevel,
	IconSet iconSet) {
	JPanel panel = new JPanel();
	panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

	TreeNode treeNode = new CustomTreeNode(null, rootNode, minimumWarningLevel);

	DefaultTreeModel model = new DefaultTreeModel(treeNode);
	JTree tree = new JTree(model);
	tree.setRootVisible(false);

	for (int row = 0; row < tree.getRowCount(); row++) {
		if (!tree.isVisible(tree.getPathForRow(row))) {
			continue;
		}

		CustomTreeNode node = ((CustomTreeNode) tree.getPathForRow(row).getLastPathComponent());

		if (node.node.expandByDefault || node.node.getMaximumWarningLevel().isAtLeast(FabricTreeWarningLevel.WARN)) {
			tree.expandRow(row);
		}
	}

	ToolTipManager.sharedInstance().registerComponent(tree);
	tree.setCellRenderer(new CustomTreeCellRenderer(iconSet));

	JScrollPane scrollPane = new JScrollPane(tree);
	panel.add(scrollPane);

	return panel;
}
 
Example 14
Source File: CatalogTreeUtils.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public static void addCellRenderer(final JTree jTree) {
    final ImageIcon dapIcon = UIUtils.loadImageIcon("/org/esa/snap/opendap/images/icons/DRsProduct16.png", CatalogTree.class);
    final ImageIcon fileIcon = UIUtils.loadImageIcon("/org/esa/snap/opendap/images/icons/FRsProduct16.png", CatalogTree.class);
    final ImageIcon errorIcon = UIUtils.loadImageIcon("/org/esa/snap/opendap/images/icons/NoAccess16.png", CatalogTree.class);
    jTree.setToolTipText(null);
    jTree.setCellRenderer(new TreeCellRenderer(dapIcon, fileIcon, errorIcon));
}
 
Example 15
Source File: CommunityDialog.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private void createOrganizationsPanel(WorldObject playerCharacter, World world, int infoPanelWidth, int infoPanelHeight, JPanel infoPanel) {
	JPanel organizationsPanel = JPanelFactory.createJPanel("Organizations");
	organizationsPanel.setLayout(null);
	organizationsPanel.setBounds(510, 363, infoPanelWidth + 5, infoPanelHeight);
	infoPanel.add(organizationsPanel, ORGANIZATIONS_KEY);
	
	JTree tree = JTreeFactory.createJTree(createRootNode(playerCharacter, world));
	tree.setRootVisible(false);
	expandAllNodes(tree, 0, tree.getRowCount());
	tree.setCellRenderer(new OrganizationMemberRenderer());
	JScrollPane treeView = JScrollPaneFactory.createScrollPane(tree);
	treeView.setBounds(15, 30, 525, 420);
	organizationsPanel.add(treeView);
}
 
Example 16
Source File: TreeIconDemo2.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public TreeIconDemo2() {
    super(new GridLayout(1, 0));

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Enable tool tips.
    ToolTipManager.sharedInstance().registerComponent(tree);

    // Set the icon for leaf nodes.
    ImageIcon tutorialIcon = createImageIcon("images/middle.gif");
    if (tutorialIcon != null) {
        tree.setCellRenderer(new MyRenderer(tutorialIcon));
    } else {
        System.err.println("Tutorial icon missing; using default.");
    }

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); // XXX: ignored in some releases
                                       // of Swing. bug 4101306
    // workaround for bug 4101306:
    // treeView.setPreferredSize(new Dimension(100, 100));

    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
}
 
Example 17
Source File: ElementTreePanel.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public ElementTreePanel(JTextComponent editor) {
    this.editor = editor;

    Document document = editor.getDocument();

    // Create the tree.
    treeModel = new ElementTreeModel(document);
    tree = new JTree(treeModel) {

        @Override
        public String convertValueToText(Object value, boolean selected,
                boolean expanded, boolean leaf,
                int row, boolean hasFocus) {
            // Should only happen for the root
            if (!(value instanceof Element)) {
                return value.toString();
            }

            Element e = (Element) value;
            AttributeSet as = e.getAttributes().copyAttributes();
            String asString;

            if (as != null) {
                StringBuilder retBuffer = new StringBuilder("[");
                Enumeration names = as.getAttributeNames();

                while (names.hasMoreElements()) {
                    Object nextName = names.nextElement();

                    if (nextName != StyleConstants.ResolveAttribute) {
                        retBuffer.append(" ");
                        retBuffer.append(nextName);
                        retBuffer.append("=");
                        retBuffer.append(as.getAttribute(nextName));
                    }
                }
                retBuffer.append(" ]");
                asString = retBuffer.toString();
            } else {
                asString = "[ ]";
            }

            if (e.isLeaf()) {
                return e.getName() + " [" + e.getStartOffset() + ", " + e.
                        getEndOffset() + "] Attributes: " + asString;
            }
            return e.getName() + " [" + e.getStartOffset() + ", " + e.
                    getEndOffset() + "] Attributes: " + asString;
        }
    };
    tree.addTreeSelectionListener(this);
    tree.setDragEnabled(true);
    // Don't show the root, it is fake.
    tree.setRootVisible(false);
    // Since the display value of every node after the insertion point
    // changes every time the text changes and we don't generate a change
    // event for all those nodes the display value can become off.
    // This can be seen as '...' instead of the complete string value.
    // This is a temporary workaround, increase the needed size by 15,
    // hoping that will be enough.
    tree.setCellRenderer(new DefaultTreeCellRenderer() {

        @Override
        public Dimension getPreferredSize() {
            Dimension retValue = super.getPreferredSize();
            if (retValue != null) {
                retValue.width += 15;
            }
            return retValue;
        }
    });
    // become a listener on the document to update the tree.
    document.addDocumentListener(this);

    // become a PropertyChangeListener to know when the Document has
    // changed.
    editor.addPropertyChangeListener(this);

    // Become a CaretListener
    editor.addCaretListener(this);

    // configure the panel and frame containing it.
    setLayout(new BorderLayout());
    add(new JScrollPane(tree), BorderLayout.CENTER);

    // Add a label above tree to describe what is being shown
    JLabel label = new JLabel("Elements that make up the current document",
            SwingConstants.CENTER);

    label.setFont(new Font("Dialog", Font.BOLD, 14));
    add(label, BorderLayout.NORTH);

    setPreferredSize(new Dimension(400, 400));
}
 
Example 18
Source File: RssGUI.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
public RssGUI() {
	

	model = new MagicNewsTableModel();
	table = new JXTable(model);
	tree = new JTree();
	JSplitPane splitNews = new JSplitPane();
	editorPane = MTGUIBrowserComponent.createBrowser();
	JSplitPane splitTreeTable = new JSplitPane();
	JPanel leftPanel = new JPanel();
	rootNode = new DefaultMutableTreeNode(MTGControler.getInstance().getLangService().getCapitalize("RSS_MODULE"));
	JPanel panelControl = new JPanel();
	btnNewButton = UITools.createBindableJButton(null,MTGConstants.ICON_NEW,KeyEvent.VK_N,"new news entry");
	btnSave = UITools.createBindableJButton(null,MTGConstants.ICON_SAVE,KeyEvent.VK_S,"save news entry");
	btnDelete =UITools.createBindableJButton(null,MTGConstants.ICON_DELETE,KeyEvent.VK_D,"delete news entry");
	lblLoading = AbstractBuzyIndicatorComponent.createLabelComponent();
	newsPanel = new NewsEditorPanel();
	
	setLayout(new BorderLayout(0, 0));
	tree.setPreferredSize(new Dimension(150, 64));
	splitNews.setOrientation(JSplitPane.VERTICAL_SPLIT);
	leftPanel.setLayout(new BorderLayout(0, 0));
	tree.setModel(new DefaultTreeModel(rootNode));
	tree.setCellRenderer(new NewsTreeCellRenderer());

	
	splitNews.setLeftComponent(new JScrollPane(table));
	splitNews.setRightComponent(new JScrollPane(editorPane));
	add(splitTreeTable, BorderLayout.CENTER);
	splitTreeTable.setRightComponent(splitNews);
	splitTreeTable.setLeftComponent(leftPanel);
	leftPanel.add(new JScrollPane(tree), BorderLayout.CENTER);
	
	leftPanel.add(panelControl, BorderLayout.NORTH);
	panelControl.add(btnNewButton);
	panelControl.add(btnSave);
	panelControl.add(btnDelete);
	panelControl.add(lblLoading);
	leftPanel.add(newsPanel, BorderLayout.SOUTH);
			

	initTree();

	initActions();


}
 
Example 19
Source File: OverviewInfoTreeUI.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Constructs new overview info tree.
 * 
 * @param inFrame The application frame in which this exists.
 */
public OverviewInfoTreeUI(ApplicationFrame inFrame) {
	// Create the top node.
	_topNode = new DefaultMutableTreeNode("EA Overview");
	_theFrame = inFrame;

	// Create a tree that allows one selection at a time.
	_infoTreeModel = new DefaultTreeModel(_topNode);
	_infoTree = new JTree(_infoTreeModel);

	_infoTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	_infoTree.setRootVisible(false); // Hides root node
	_infoTree.setShowsRootHandles(true); // Shows nodes off root

	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();

	renderer.setOpenIcon(null);
	renderer.setClosedIcon(null);
	renderer.setLeafIcon(null);
	_infoTree.setCellRenderer(renderer);

	// Add tree into scroll pane and then to this pane
	this.setViewportView(_infoTree);
	this.setMinimumSize(new Dimension(150, 200));

	_popupMenu = new JPopupMenu();
	_newPosition = new Point(50, 50);

	buildPopupMenu();

	// Create Category Heads
	_tree_sketches = new DefaultMutableTreeNode("Sketches");

	_topNode.add(_tree_sketches);

	_tree_views = new DefaultMutableTreeNode("Views");

	_topNode.add(_tree_views);

	// Initialize ArrayList of expansion state information
	expanState = new ArrayList<>();
}
 
Example 20
Source File: ModelInfoTreeUI.java    From CQL with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Default constructor
 *
 * @param inFrame
 */
public ModelInfoTreeUI(F inFrame) {
	// Create the top node.
	_topNode = new DefaultMutableTreeNode("EA Sketch");
	_theFrame = inFrame;
	_newPosition = new Point(50, 50);

	// Create a tree that allows one selection at a time.
	_infoTreeModel = new DefaultTreeModel(_topNode);
	_infoTree = new JTree(_infoTreeModel);

	_infoTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	_infoTree.setRootVisible(false); // Hides root node
	_infoTree.setShowsRootHandles(true); // Shows nodes off root

	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();

	renderer.setOpenIcon(null);
	renderer.setClosedIcon(null);
	renderer.setLeafIcon(null);
	_infoTree.setCellRenderer(renderer);

	// Add tree into scroll pane and then to this pane
	this.setViewportView(_infoTree);
	this.setMinimumSize(new Dimension(150, 200));

	_popupMenu = new JPopupMenu();

	buildPopupMenu();

	// Create Category Heads
	_tree_entities = new DefaultMutableTreeNode("Entities");

	_topNode.add(_tree_entities);

	_tree_constraints = new DefaultMutableTreeNode("Constraints");

	_topNode.add(_tree_constraints);

	_tree_constraints_commutative = new DefaultMutableTreeNode("Commutative Diagrams");

	_tree_constraints.add(_tree_constraints_commutative);

	_tree_constraints_product = new DefaultMutableTreeNode("Product Constraints");

	_tree_constraints.add(_tree_constraints_product);

	_tree_constraints_pullback = new DefaultMutableTreeNode("Pullback Constraints");

	_tree_constraints.add(_tree_constraints_pullback);

	_tree_constraints_equalizer = new DefaultMutableTreeNode("Equalizer Constraints");

	_tree_constraints.add(_tree_constraints_equalizer);

	_tree_constraints_sum = new DefaultMutableTreeNode("Sum Constraints");

	_tree_constraints.add(_tree_constraints_sum);

	_tree_constraints_limit = new DefaultMutableTreeNode("Limit Constraints");

	_tree_constraints.add(_tree_constraints_limit);

	// Initialize ArrayList of expansion state information
	expanState = new ArrayList<>();
}