Java Code Examples for javax.swing.tree.AbstractLayoutCache

The following examples show how to use javax.swing.tree.AbstractLayoutCache. 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: netbeans   Source File: DefaultOutlineModel.java    License: Apache License 2.0 6 votes vote down vote up
/** Creates a new instance of DefaultOutlineModel.  <strong><b>Note</b> 
 * Do not fire table structure changes from the wrapped TableModel (value
 * changes are okay).  Changes that affect the number of rows must come
 * from the TreeModel.
 * @param treeModel The tree model
 * @param tableModel The table model
 * @param largeModel <code>true</code> if it's a large model tree, <code>false</code> otherwise.
 * @param nodesColumnLabel Label of the node's column
 */
protected DefaultOutlineModel(TreeModel treeModel, TableModel tableModel, boolean largeModel, String nodesColumnLabel) {
    this.treeModel = treeModel;
    this.tableModel = tableModel;
    if (nodesColumnLabel != null) {
        this.nodesColumnLabel = nodesColumnLabel;
    }
    
    layout = largeModel ? (AbstractLayoutCache) new FixedHeightLayoutCache() 
        : (AbstractLayoutCache) new VariableHeightLayoutCache();
        
    broadcaster = new EventBroadcaster (this);
    
    layout.setRootVisible(true);
    layout.setModel(this);
    treePathSupport = new TreePathSupport(this, layout);
    treePathSupport.addTreeExpansionListener(broadcaster);
    treePathSupport.addTreeWillExpandListener(broadcaster);
    treeModel.addTreeModelListener(broadcaster);
    tableModel.addTableModelListener(broadcaster);
    if (tableModel instanceof ProxyTableModel) {
        ((ProxyTableModel) tableModel).setOutlineModel(this);
    }
}
 
Example 2
Source Project: JPPF   Source File: CustomTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractLayoutCache.NodeDimensions createNodeDimensions() {
  return new NodeDimensionsHandler() {
    @Override
    public Rectangle getNodeDimensions(final Object value, final int row, final int depth, final boolean expanded, final Rectangle size) {
      final JViewport port = (JViewport) treeTable.getParent();
      final Rectangle dimensions = super.getNodeDimensions(value, row, depth, expanded, size);
      if (port != null) dimensions.width = port.getWidth();
      return dimensions;
    }
  };
}
 
Example 3
Source Project: netbeans   Source File: NodeRenderDataProvider.java    License: Apache License 2.0 5 votes vote down vote up
public javax.swing.Icon getIcon(Object o) {
    if (!showIcons) {
        return emptyIcon;
    }
    Node n = Visualizer.findNode(o);
    if (n == null) {
        throw new IllegalStateException("TreeNode must be VisualizerNode but was: " + o + " of class " + o.getClass().getName());
    }
    boolean expanded = false;
    if (o instanceof TreeNode) {
        TreeNode tn = (TreeNode)o;
        ArrayList<TreeNode> al = new ArrayList<TreeNode> ();
        while (tn != null) {
            al.add(tn);
            tn = tn.getParent();
        }
        Collections.reverse(al);
        TreePath tp = new TreePath(al.toArray());
        AbstractLayoutCache layout = table.getLayoutCache();
        expanded = layout.isExpanded(tp);
    }
    java.awt.Image image = null;
    if (expanded) {
        image = n.getOpenedIcon(java.beans.BeanInfo.ICON_COLOR_16x16);
    } else {
        image = n.getIcon(java.beans.BeanInfo.ICON_COLOR_16x16);
    }
    return ImageUtilities.image2Icon(image);
}
 
Example 4
Source Project: netbeans   Source File: Outline.java    License: Apache License 2.0 5 votes vote down vote up
/** Get the layout cache which manages layout data for the Outline.
 * <strong>Under no circumstances directly call the methods on the
 * layout cache which change the expanded state - such changes will not
 * be propagated into the table model, and will leave the model and
 * its layout in inconsistent states.  Any calls that affect expanded
 * state must go through <code>getTreePathSupport()</code>.</strong> */
public final AbstractLayoutCache getLayoutCache () {
    OutlineModel mdl = getOutlineModel();
    if (mdl != null) {
        return mdl.getLayout();
    } else {
        return null;
    }
}
 
Example 5
Source Project: netbeans   Source File: Outline.java    License: Apache License 2.0 5 votes vote down vote up
/** Overridden to throw an exception if the passed model is not an instance
 * of <code>OutlineModel</code> (with the exception of calls from the 
 * superclass constructor) */
@Override
public void setModel (TableModel mdl) {
    if (initialized && (!(mdl instanceof OutlineModel))) {
        throw new IllegalArgumentException (
            "Table model for an Outline must be an instance of " +
            "OutlineModel"); //NOI18N
    }
    if (mdl instanceof OutlineModel) {
        AbstractLayoutCache layout = ((OutlineModel) mdl).getLayout();
        if (cachedRootVisible != null) {
            
            layout.setRootVisible(
                cachedRootVisible.booleanValue());
            
        }
        
        layout.setRowHeight(getRowHeight());
        
        if (((OutlineModel) mdl).isLargeModel()) {
            addComponentListener (getComponentListener());
            layout.setNodeDimensions(new ND());
        } else {
            if (componentListener != null) {
                removeComponentListener (componentListener);
                componentListener = null;
            }
        }
    }
    
    super.setModel(mdl);
}
 
Example 6
Source Project: netbeans   Source File: DefaultOutlineModel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public final AbstractLayoutCache getLayout() {
    return layout;
}
 
Example 7
Source Project: netbeans   Source File: EventBroadcaster.java    License: Apache License 2.0 4 votes vote down vote up
/** Convenience getter for the proxied model's layout cache */
private AbstractLayoutCache getLayout() {
    return getModel().getLayout();
}
 
Example 8
Source Project: netbeans   Source File: TreePathSupport.java    License: Apache License 2.0 4 votes vote down vote up
/** Creates a new instance of TreePathSupport */
public TreePathSupport(OutlineModel mdl, AbstractLayoutCache layout) {
    this.layout = layout;
}
 
Example 9
Source Project: netbeans   Source File: OutlineModel.java    License: Apache License 2.0 2 votes vote down vote up
/** Get the layout cache which is used to track the visual state of nodes.
 * This is typically one of the standard JDK layout cache classes, such
 * as <code>VariableHeightLayoutCache</code> or <code>
 * FixedHeightLayoutCache</code>.  */
public AbstractLayoutCache getLayout ();
 
Example 10
Source Project: weblaf   Source File: WTreeUI.java    License: GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns tree layout cache.
 *
 * @return tree layout cache
 */
@Nullable
public abstract AbstractLayoutCache getTreeLayoutCache ();