Java Code Examples for javax.swing.tree.DefaultTreeCellRenderer

The following examples show how to use javax.swing.tree.DefaultTreeCellRenderer. These examples are extracted from open source projects. 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 Project: darklaf   Source File: DarkTreeCellRendererDelegate.java    License: MIT License 6 votes vote down vote up
@Override
public Component getTreeCellRendererComponent(final JTree tree, final Object value,
                                              final boolean selected, final boolean expanded,
                                              final boolean leaf, final int row, final boolean hasFocus) {
    boolean isFocused = DarkUIUtil.hasFocus(tree);
    Object unwrapped = unwrapBooleanIfPossible(value);
    Component renderer;
    if (unwrapped instanceof Boolean && isBooleanRenderingEnabled(tree)) {
        Component comp = getBooleanRenderer(tree).getTreeCellRendererComponent(tree, value, selected, expanded,
                                                                               leaf, row, isFocused);
        rendererComponent.setComponentOrientation(tree.getComponentOrientation());
        comp.setComponentOrientation(tree.getComponentOrientation());
        comp.setFont(tree.getFont());
        rendererComponent.setRenderer(this);
        rendererComponent.setRenderComponent(comp);
        renderer = rendererComponent;
    } else {
        if (getDelegate() instanceof DefaultTreeCellRenderer) {
            ((DefaultTreeCellRenderer) getDelegate()).setIcon(null);
            ((DefaultTreeCellRenderer) getDelegate()).setDisabledIcon(null);
        }
        renderer = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, isFocused);
    }
    CellUtil.setupTreeForeground(renderer, tree, selected);
    return renderer;
}
 
Example 2
Source Project: uima-uimaj   Source File: AnnotationFeaturesViewer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Populate.
 *
 * @param analysisEngine the analysis engine
 * @param aeMetaData the ae meta data
 */
public void populate(AnalysisEngine analysisEngine, AnalysisEngineMetaData aeMetaData) {
  tree = generateTreeView(analysisEngine, aeMetaData);

  tree.setDragEnabled(true); // To allow drag to stylemap table.
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true); // Displays node expansion glyphs.

  TreeSelectionModel selectionModel = tree.getSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

  DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
  cellRenderer.setLeafIcon(null);
  cellRenderer.setClosedIcon(null);
  cellRenderer.setOpenIcon(null);
  tree.setCellRenderer(cellRenderer);

  scrollPane.getViewport().add(tree, null);
}
 
Example 3
Source Project: chipster   Source File: TreePanel.java    License: MIT License 6 votes vote down vote up
public Component getTreeCellRendererComponent(JTree tree,
        Object value, boolean selected, boolean expanded,
        boolean leaf, int row, boolean hasFocus) {
    
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    DataItem element = (DataItem) node.getUserObject();

    DefaultTreeCellRenderer renderer = 
    	(DefaultTreeCellRenderer)super.getTreeCellRendererComponent(tree, value, selected, 
    			expanded,leaf, row, hasFocus);
    
    renderer.setIcon(application.getIconFor(element));
    renderer.setText(element.toString() + " ");
   
  return this;
}
 
Example 4
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,boolean isLeaf, int row, boolean focused) {
	JLabel c = (JLabel)new DefaultTreeCellRenderer().getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused);

	if (((DefaultMutableTreeNode) value).getUserObject() instanceof MagicNews) {
		try {
			c.setIcon(((MagicNews) ((DefaultMutableTreeNode) value).getUserObject()).getProvider().getIcon());
		}
		catch(Exception e)
		{
			c.setIcon(null);
		}

	}

	if (((DefaultMutableTreeNode) value).getUserObject() instanceof String)
		c.setIcon(MTGConstants.ICON_NEWS);

	return c;
}
 
Example 5
Source Project: uima-uimaj   Source File: MainFrame.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Inits the IR tree.
 */
private void initIRTree() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode(noIndexReposLabel);
  DefaultTreeModel model = new DefaultTreeModel(root);
  this.indexTree = new JTree(model);
  this.indexTree.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 2));
  // Only one node can be selected at any one time.
  this.indexTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  this.indexTree.addTreeSelectionListener(new IndexTreeSelectionListener(this));
  // No icons.
  DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
  cellRenderer.setLeafIcon(null);
  // cellRenderer.setIcon(null);
  cellRenderer.setClosedIcon(null);
  cellRenderer.setOpenIcon(null);
  this.indexTree.setCellRenderer(cellRenderer);
}
 
Example 6
Source Project: lucene-solr   Source File: ExplainDialogFactory.java    License: 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 7
Source Project: pcgen   Source File: JTreeTable.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * updateUI is overridden to set the colors
 * of the Trees renderer to match that of the table.
 **/
@Override
public void updateUI()
{
	super.updateUI();

	// Make the tree's cell renderer use the
	// table's cell selection colors.
	TreeCellRenderer tcr = getCellRenderer();

	if (tcr instanceof DefaultTreeCellRenderer)
	{
		DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
		dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground")); //$NON-NLS-1$
		dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground")); //$NON-NLS-1$
	}
}
 
Example 8
Source Project: DiskBrowser   Source File: TreeBuilder.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void setDiskIcon (String iconName)
// ---------------------------------------------------------------------------------//
{
  URL url = this.getClass ().getResource (iconName);
  if (url != null)
  {
    ImageIcon icon = new ImageIcon (url);
    DefaultTreeCellRenderer renderer =
        (DefaultTreeCellRenderer) tree.getCellRenderer ();
    renderer.setLeafIcon (icon);
    tree.setCellRenderer (renderer);
    tree.setRowHeight (18);
  }
  else
    System.out.println ("Failed to set the disk icon : " + iconName);
}
 
Example 9
Source Project: audiveris   Source File: JTreeTable.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
@Override
public void updateUI ()
{
    super.updateUI();

    // Make the tree's cell renderer use the table's cell selection
    // colors.
    TreeCellRenderer tcr = getCellRenderer();

    if (tcr instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);

        // For 1.1 uncomment this, 1.2 has a bug that will cause an
        // exception to be thrown if the border selection color is
        // null.
        dtcr.setBorderSelectionColor(null);
        dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
        dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
    }
}
 
Example 10
Source Project: CQL   Source File: CodeEditor.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
protected DefaultTreeCellRenderer makeRenderer() {
	DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
	renderer.setLeafIcon(null);
	renderer.setOpenIcon(null);
	renderer.setClosedIcon(null);
	return renderer;
}
 
Example 11
/**
 * Ensure white background for this tree.
 */
private void setBackgroundWhite() {
	setBackground(Colors.WHITE);
	setCellRenderer(new DefaultTreeCellRenderer() {

		private static final long serialVersionUID = 1L;

		@Override
		public Color getBackgroundNonSelectionColor() {
			return Colors.WHITE;
		}
	});
}
 
Example 12
Source Project: cstc   Source File: OperationsTree.java    License: GNU General Public License v3.0 5 votes vote down vote up
public OperationsTree() {
	super();
	
	this.model = (DefaultTreeModel) this.getModel();
	this.model.setRoot(this.createTree());
	this.setToolTipText("");
	DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) this.getCellRenderer();
	renderer.setLeafIcon(nodeIcon);
	renderer.setClosedIcon(closedIcon);
	renderer.setOpenIcon(openIcon);
}
 
Example 13
Source Project: jdk1.8-source-analysis   Source File: SynthTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example 14
Source Project: consulo   Source File: TreeTableTree.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void updateUI() {
  super.updateUI();
  TreeCellRenderer tcr = super.getCellRenderer();
  if (tcr instanceof DefaultTreeCellRenderer) {
    DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer)tcr;
    dtcr.setTextSelectionColor(UIUtil.getTableSelectionForeground());
    dtcr.setBackgroundSelectionColor(UIUtil.getTableSelectionBackground());
  }
}
 
Example 15
Source Project: dragonwell8_jdk   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example 16
Source Project: dragonwell8_jdk   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void configureRenderer(SynthContext context) {
    TreeCellRenderer renderer = tree.getCellRenderer();

    if (renderer instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer r = (DefaultTreeCellRenderer)renderer;
        SynthStyle style = context.getStyle();

        context.setComponentState(ENABLED | SELECTED);
        Color color = r.getTextSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setTextSelectionColor(style.getColor(
                                 context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setBackgroundSelectionColor(style.getColor(
                                    context, ColorType.TEXT_BACKGROUND));
        }

        context.setComponentState(ENABLED);
        color = r.getTextNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setTextNonSelectionColor(style.getColorForState(
                                    context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setBackgroundNonSelectionColor(style.getColorForState(
                              context, ColorType.TEXT_BACKGROUND));
        }
    }
}
 
Example 17
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 5 votes vote down vote up
private static TreeCellEditor makeLeafTreeCellEditor(JTree tree) {
  return new DefaultTreeCellEditor(tree, (DefaultTreeCellRenderer) tree.getCellRenderer()) {
    @Override public boolean isCellEditable(EventObject e) {
      Object o = tree.getLastSelectedPathComponent();
      return super.isCellEditable(e) && o instanceof TreeNode && ((TreeNode) o).isLeaf();
    }
  };
}
 
Example 18
Source Project: TencentKona-8   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example 19
Source Project: TencentKona-8   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void configureRenderer(SynthContext context) {
    TreeCellRenderer renderer = tree.getCellRenderer();

    if (renderer instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer r = (DefaultTreeCellRenderer)renderer;
        SynthStyle style = context.getStyle();

        context.setComponentState(ENABLED | SELECTED);
        Color color = r.getTextSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setTextSelectionColor(style.getColor(
                                 context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setBackgroundSelectionColor(style.getColor(
                                    context, ColorType.TEXT_BACKGROUND));
        }

        context.setComponentState(ENABLED);
        color = r.getTextNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setTextNonSelectionColor(style.getColorForState(
                                    context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setBackgroundNonSelectionColor(style.getColorForState(
                              context, ColorType.TEXT_BACKGROUND));
        }
    }
}
 
Example 20
Source Project: jdk8u-dev-jdk   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void configureRenderer(SynthContext context) {
    TreeCellRenderer renderer = tree.getCellRenderer();

    if (renderer instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer r = (DefaultTreeCellRenderer)renderer;
        SynthStyle style = context.getStyle();

        context.setComponentState(ENABLED | SELECTED);
        Color color = r.getTextSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setTextSelectionColor(style.getColor(
                                 context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setBackgroundSelectionColor(style.getColor(
                                    context, ColorType.TEXT_BACKGROUND));
        }

        context.setComponentState(ENABLED);
        color = r.getTextNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setTextNonSelectionColor(style.getColorForState(
                                    context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setBackgroundNonSelectionColor(style.getColorForState(
                              context, ColorType.TEXT_BACKGROUND));
        }
    }
}
 
Example 21
Source Project: opensim-gui   Source File: JPlotterPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form JPlotterPanel
 */
public JPlotterPanel() {
   initComponents();
 
   domainFormatter.setValueClass(java.lang.Double.class);
   rangeFormatter.setValueClass(java.lang.Double.class);
   jDomainStartTextField.setValue(0.0);   jDomainStartTextField.addActionListener(new handleReturnAction(jDomainStartTextField));
   jDomainEndTextField.setValue(1.0);   jDomainEndTextField.addActionListener(new handleReturnAction(jDomainEndTextField));
   jFormattedTextFieldYmin.setValue(-10000.0);   jFormattedTextFieldYmin.addActionListener(new handleReturnAction(jFormattedTextFieldYmin));
   jFormattedTextFieldYmax.setValue(10000.0);   jFormattedTextFieldYmax.addActionListener(new handleReturnAction(jFormattedTextFieldYmax));
   jActivationValueFormattedTextField.setValue(1.0);   jActivationValueFormattedTextField.addActionListener(new handleReturnAction(jActivationValueFormattedTextField));

   jTopChartingPanel.setLayout(new BorderLayout());
   xSelector = new JPlotterQuantitySelector(jXQtyTextField, this, true);
   jPlotsTree.addTreeSelectionListener(this);
   jPlotsTree.setEditable(true);
   jPlotsTree.setCellEditor(new UserTreeCellEditor(jPlotsTree, new DefaultTreeCellRenderer()));
   jPlotterDeletePlotButton.setEnabled(false);
   jPlotterAddPlotButton.setEnabled(validateXY());
   // Add in blank figure by default
   jTopChartingPanel.add(plotterModel.getCurrentPlot().getChartPanel());
   jPropertiesButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
             plotterModel.getCurrentPlot().getChartPanel().doEditChartProperties();
         }
   });
   processCurrentModel();
   useMuscles(false);
   jPlotsTree.setRootVisible(false);
   //printPlotDescriptor();
   PlotterDB.getInstance().registerPlotterPanel(this);
   
   populateQNameSet();
 }
 
Example 22
Source Project: jdk8u60   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void configureRenderer(SynthContext context) {
    TreeCellRenderer renderer = tree.getCellRenderer();

    if (renderer instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer r = (DefaultTreeCellRenderer)renderer;
        SynthStyle style = context.getStyle();

        context.setComponentState(ENABLED | SELECTED);
        Color color = r.getTextSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setTextSelectionColor(style.getColor(
                                 context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setBackgroundSelectionColor(style.getColor(
                                    context, ColorType.TEXT_BACKGROUND));
        }

        context.setComponentState(ENABLED);
        color = r.getTextNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setTextNonSelectionColor(style.getColorForState(
                                    context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setBackgroundNonSelectionColor(style.getColorForState(
                              context, ColorType.TEXT_BACKGROUND));
        }
    }
}
 
Example 23
Source Project: openjdk-8   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example 24
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 5 votes vote down vote up
private MainPanel() {
  super(new BorderLayout());
  JTree tree = new JTree();

  // UIManager.put("PopupMenu.consumeEventOnClose", Boolean.FALSE);
  // tree.addMouseListener(new MouseAdapter() {
  //   @Override public void mousePressed(MouseEvent e) {
  //     JTree tree = (JTree) e.getSource();
  //     TreePath path = tree.getPathForLocation(e.getX(), e.getY());
  //     if (!tree.getSelectionModel().isPathSelected(path)) {
  //       tree.getSelectionModel().setSelectionPath(path);
  //     }
  //   }
  // });

  tree.setCellEditor(new DefaultTreeCellEditor(tree, (DefaultTreeCellRenderer) tree.getCellRenderer()) {
    // @Override protected boolean shouldStartEditingTimer(EventObject e) {
    //   return false;
    // }
    // @Override protected boolean canEditImmediately(EventObject e) {
    //   // ((MouseEvent) e).getClickCount() - 2 >= 0
    //   return !(e instanceof MouseEvent) && super.canEditImmediately(e);
    // }

    @Override public boolean isCellEditable(EventObject e) {
      return !(e instanceof MouseEvent) && super.isCellEditable(e);
    }
  });
  tree.setEditable(true);
  tree.setComponentPopupMenu(new TreePopupMenu());

  add(new JScrollPane(tree));
  setPreferredSize(new Dimension(320, 240));
}
 
Example 25
Source Project: JDKSourceCode1.8   Source File: SynthTreeUI.java    License: MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example 26
Source Project: sc2gears   Source File: MainFrame.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a custom tree cell renderer for the navigation tree which sets custom leaf icons.
 * @return a custom tree cell renderer
 */
private TreeCellRenderer createTreeCellRenderer() {
	return new DefaultTreeCellRenderer() {
		public Component getTreeCellRendererComponent( final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus ) {
			super.getTreeCellRendererComponent( tree, value, selected, expanded, leaf, row, hasFocus );
			final DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
			if ( node != newRepAnalNode && node != newMultiRepAnalNode && node != newRepSearchNode && node != emptyRepSourceNode && node != emptyRepListNode && node != pluginsInfoNode ) {
				if ( node == sc2AutoRepsRepSourceNode || node == autoSavedRepsRepSourceNode )
					setIcon( Icons.FOLDER_BOOKMARK );
				else if ( node == startPageNode )
					setIcon( Icons.NEWSPAPER );
				else {
					final TreeNode parentNode = node.getParent();
					if ( parentNode == repAnalNode )
						setIcon( Icons.CHART );
					else if ( parentNode == multiRepAnalNode )
						setIcon( Icons.CHART_UP_COLOR );
					else if ( parentNode == repSearchNode )
						setIcon( Icons.BINOCULAR );
					else if ( parentNode == repSourcesNode )
						setIcon( Icons.FOLDERS_STACK );
					else if ( parentNode == repListsNode )
						setIcon( Icons.TABLE_EXCEL );
					else if ( parentNode == pluginsNode )
						setIcon( Icons.PUZZLE );
				}
			}
			return this;
		};
	};
}
 
Example 27
Source Project: jdk8u-jdk   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example 28
Source Project: JsDroidCmd   Source File: SwingGui.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Initializes a tree for this tree table.
 */
public JTree resetTree(TreeTableModel treeTableModel) {
    tree = new TreeTableCellRenderer(treeTableModel);

    // 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.
    ListToTreeSelectionModelWrapper selectionWrapper = new
        ListToTreeSelectionModelWrapper();
    tree.setSelectionModel(selectionWrapper);
    setSelectionModel(selectionWrapper.getListSelectionModel());

    // Make the tree and table row heights the same.
    if (tree.getRowHeight() < 1) {
        // Metal looks better like this.
        setRowHeight(18);
    }

    // Install the tree editor renderer and editor.
    setDefaultRenderer(TreeTableModel.class, tree);
    setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor());
    setShowGrid(true);
    setIntercellSpacing(new Dimension(1,1));
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    DefaultTreeCellRenderer r = (DefaultTreeCellRenderer)tree.getCellRenderer();
    r.setOpenIcon(null);
    r.setClosedIcon(null);
    r.setLeafIcon(null);
    return tree;
}
 
Example 29
Source Project: openjdk-jdk8u   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected TreeCellEditor createDefaultCellEditor() {
    TreeCellRenderer renderer = tree.getCellRenderer();
    DefaultTreeCellEditor editor;

    if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
        editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
                                         renderer);
    }
    else {
        editor = new SynthTreeCellEditor(tree, null);
    }
    return editor;
}
 
Example 30
private void refreshFrameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshFrameActionPerformed
    componentHierarchy.setModel(new ComponentTreeModel(Display.getInstance().getCurrent()));
    componentHierarchy.setCellRenderer(new DefaultTreeCellRenderer() {

        @Override
        public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            String s = value.toString();
            if(value instanceof Component) {
                s = ((Component)value).getUIID() + ": " + s;
            }
            return super.getTreeCellRendererComponent(tree, s, sel, expanded, leaf, row, hasFocus); //To change body of generated methods, choose Tools | Templates.
        }
        
    });
    
    Display.getInstance().callSerially(new Runnable() {
        public void run() {
            trackDrawing = true;
            Display.getInstance().getCurrent().repaint();
            Display.getInstance().callSerially(new Runnable() {
                public void run() {
                    // data collected
                    trackDrawing = false;
                    renderedItems.setModel(createTableModel());
                }
            });
        }
    });
}