Java Code Examples for org.openide.nodes.Node#addPropertyChangeListener()

The following examples show how to use org.openide.nodes.Node#addPropertyChangeListener() . 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: PropertiesRowModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Object getValueFor(Object node, int column) {
    Node n = Visualizer.findNode(node);
    if (n == null) {
        throw new IllegalStateException("TreeNode must be VisualizerNode but was: " + node + " of class " + node.getClass().getName());
    }
    PropertyChangeListener cacheEntry = nodesListenersCache.get (n);
    if (cacheEntry == null) {
        PropertyChangeListener p = WeakListeners.propertyChange(pcl, n);
        nodesListenersCache.put(n, p);
        n.addPropertyChangeListener(p);
        NodeListener l = WeakListeners.create(NodeListener.class, nl, n);
        n.addNodeListener(l);
    }
    Node.Property theRealProperty = getPropertyFor(n, prop[column]);
    return theRealProperty;
}
 
Example 2
Source File: PropertySheet.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Attach to a node, detaching from the last one if non-null.  */
public void attach(Node n) {
    if (currNode != n) {
        if (currNode != null) {
            detach();
        }

        if (n != null) {
            n.addPropertyChangeListener(inner);
            n.addNodeListener(this);

            if (PropUtils.isLoggable(PropertySheet.class)) {
                PropUtils.log(PropertySheet.class, "Now listening for changes on " + n);
            }
        }

        currNode = n;
    }
}
 
Example 3
Source File: Tab.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Initialize this top component properly with information
* obtained from specified root context node */
private void initializeWithRootContext (Node rc) {
    // update TC's attributes
    setToolTipText(rc.getDisplayName());
    setName(rc.getDisplayName());
    updateTitle();
    // attach listener
    if (weakRcL == null) {
        weakRcL = WeakListeners.propertyChange(
            rcListener(), rc
        );
    }
    rc.addPropertyChangeListener(weakRcL);

    if (weakNRcL == null) {
        weakNRcL = NodeOp.weakNodeListener (
            rcListener(), rc
        );
    }
    rc.addNodeListener(weakNRcL);
}
 
Example 4
Source File: NodeTableModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void insertNode(Node node) {
    Node[] nodes;
    if(nodeRows == null) {
        nodes = new Node[1];
    } else {
        nodes = new Node[nodeRows.length + 1];
        System.arraycopy(nodeRows, 0, nodes, 0, nodeRows.length);
    }
    nodes[nodes.length - 1] = node;
    node.addPropertyChangeListener(pcl);
    nodeRows = nodes;
    fireTableDataChanged();
}
 
Example 5
Source File: IndexedEditorPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Creates new form IndexedEditorPanel */
public IndexedEditorPanel(Node node, Node.Property[] props) {
    treeTableView1 = new TreeTableView();

    // install proper border
    setBorder((Border) UIManager.get("Nb.ScrollPane.border")); // NOI18N
    initComponents();
    propertiesLabel.setLabelFor(treeTableView1);

    jPanel2.setLayout(new java.awt.BorderLayout());
    jPanel2.add(treeTableView1);

    detailsPanel.setLayout(new java.awt.BorderLayout());
    getExplorerManager().setRootContext(node);

    rootNode = node;
    prop = props[0];
    getExplorerManager().addPropertyChangeListener(this);
    treeTableView1.setProperties(props);
    treeTableView1.setRootVisible(false);
    treeTableView1.setDefaultActionAllowed(false);
    treeTableView1.setTreePreferredWidth(200);

    node.addPropertyChangeListener(this);

    try {
        ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
        if (l == null) {
            l = Thread.currentThread().getContextClassLoader();
        }
        if (l == null) {
            l = getClass().getClassLoader();
        }
        
        selectedLookup = org.openide.util.lookup.Lookups.proxy(this);

        NodeAction globalMoveUp = SystemAction.get(Class.forName("org.openide.actions.MoveUpAction", true, l).asSubclass(NodeAction.class)); // NOI18N
        NodeAction globalMoveDown = SystemAction.get(Class.forName("org.openide.actions.MoveDownAction", true, l).asSubclass(NodeAction.class)); // NOI18N
        NodeAction globalNewAction = SystemAction.get(Class.forName("org.openide.actions.NewAction", true, l).asSubclass(NodeAction.class)); // NOI18N

        // Get context aware instances.
        moveUp = globalMoveUp.createContextAwareInstance(selectedLookup);
        moveDown = globalMoveDown.createContextAwareInstance(selectedLookup);
        newAction = globalNewAction.createContextAwareInstance(selectedLookup);
    } catch (ClassNotFoundException cnfe) {
        LOG.log(Level.INFO, "Maybe missing openide.actions module?", cnfe);
    }

    java.util.ResourceBundle bundle = NbBundle.getBundle(IndexedEditorPanel.class);
    treeTableView1.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Properties"));
    newButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_New"));
    deleteButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Delete"));
    upButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_MoveUp"));
    downButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_MoveDown"));
    getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_IndexedEditorPanel"));
}