/** Getter for a child at a given position. If child with such index * does not exists it returns null. * * @param index the index of a node we want to know (non negative) * @return the node at given index or null * @since org.openide.nodes 7.5 */ public final Node getNodeAt(int index) { checkSupport(); return entrySupport().getNodeAt(index); }
/** Get the number of nodes in the list * @param optimalResult whether to try to perform full initialization * or to simply delegate to {@link #getNodesCount()} * @return the count * @since org.openide.nodes 7.6 */ public int getNodesCount(boolean optimalResult) { checkSupport(); return entrySupport().getNodesCount(optimalResult); }
/** Method that can be used to test whether the children content has * ever been used or it is still not initalized. * @return true if children has been used before * @see #addNotify */ protected final boolean isInitialized() { return entrySupport().isInitialized(); }
List<Entry> entries = entrySupport().getEntries(); boolean init = entrySupport().isInitialized(); if (init && parent != null) { List<Node> snapshot = getEntrySupport().snapshot(); if (snapshot.size() > 0) { int[] idxs = getSnapshotIdxs(snapshot); entrySupport().notifySetEntries(); entrySupport().setEntries(entries); } finally { Children.PR.exitWriteAccess();
private void changeSupport(Node newOriginal) { final boolean LOG_ENABLED = LOGGER.isLoggable(Level.FINER); boolean init = entrySupport().isInitialized(); boolean changed = false; List<Node> snapshot = entrySupport().snapshot(); if (snapshot.size() > 0) { int[] idxs = getSnapshotIdxs(snapshot); entrySupport().notifySetEntries(); entrySupport().getNodesCount(false);
/** This method can be called by subclasses that * directly modify the nodes collection to update the * state of the nodes appropriatelly. * This method should be called under * MUTEX.writeAccess. */ final void refreshImpl() { if (isInitialized()) { Array.this.entrySupport().refreshEntry(getNodesEntry()); entrySupport().getNodes(false); } else if (nodes != null) { for (Node n : nodes) { n.assignTo(this, -1); } } }
/** Set whether new nodes should be added to the beginning or end of sublists for a given key. * Generally should not be used. * @param b <code>true</code> if the children should be added before */ protected final void setBefore(final boolean b) { try { PR.enterWriteAccess(); if (before != b && !lazySupport) { List<Entry> l = entrySupport().getEntries(); l.remove(getNodesEntry()); before = b; if (b) { l.add(0, getNodesEntry()); } else { l.add(getNodesEntry()); } entrySupport().setEntries(l); } } finally { PR.exitWriteAccess(); } }
abstract void setEntries(Collection<? extends Entry> entries, boolean noCheck);
/** Allows subclasses that directly modifies the * map with nodes to synchronize the state of the children. * This method should be called under * MUTEX.writeAccess. * * @param key the key that should be refreshed */ final void refreshKeyImpl(T key) { entrySupport().refreshEntry(new ME(key, null)); }
/** Get a (sorted) array of nodes in this list. * If the children object is not yet initialized, * it will be (using {@link #addNotify}) before * the nodes are returned. * <p><strong>Warning:</strong> not all children * implementations do a complete calculation at * this point, see {@link #getNodes(boolean)} * @return array of nodes */ // private static String off = ""; // NOI18N public final Node[] getNodes() { checkSupport(); return entrySupport().getNodes(false); }
/** Creates an immutable snapshot representing the current view of the nodes * in this children object. This is No attempt is made to extract incorrect or invalid * nodes from the list, as a result, the value may not be exactly the same * as returned by {@link #getNodes()}. * * @return immutable and unmodifiable list of nodes in this children object * @since 7.7 */ public final List<Node> snapshot() { return entrySupport().snapshot(); }
/** @return either nodes associated with this children or null if * they are not created */ private Node[] testNodes() { return getEntrySupport() == null ? null : entrySupport().testNodes(); }
public void run() { if (keysCheck(Keys.this, this)) { // no next request after me entrySupport().setEntries(l); // clear this runnable keysExit(Keys.this, this); } } };
public void run() { Keys.this.entrySupport().refreshEntry(createEntryForKey(key)); } }
return entrySupport().getNodes(optimalResult);
/** Allows subclasses that directly modifies the * map with nodes to synchronize the state of the children. * This method should be called under * MUTEX.writeAccess. */ final void refreshImpl() { entrySupport().setEntries(createEntries(getMap())); }
/** Get the number of nodes in the list. * @return the count */ public final int getNodesCount() { checkSupport(); return entrySupport().getNodesCount(false); }
FilterChildrenSupport support = null; synchronized (org.openide.nodes.Children.class) { if (getEntrySupport() != null && !getEntrySupport().isInitialized()) {
@Override void postInitializeEntrySupport(EntrySupport es) { if (!lazySupport) { if (getNodesEntry() == null) { nodesEntry = createNodesEntry(); } es.setEntries(Collections.singleton(getNodesEntry()), true); } else if (getNodesEntry() != null) { nodesEntry = null; } }
/** Called on first use. */ @Override final void callAddNotify() { entrySupport().setEntries(createEntries(getMap()), true); super.callAddNotify(); }