protected @Override void addNotify() { active = true; factory.addNotify(); refresh(true); }
public void refresh(boolean immediate) { if (active) { List <T> toPopulate = new LinkedList<T>(); while (!factory.createKeys(toPopulate)) {} setKeys(toPopulate); } } }
/** * Create Nodes for a given key object (one from the <code>List</code> * passed to createKeys(List <T>)). The default implementation simply * delegates to <code>createNodeForKey</code> and returns the result of * that call in an array of nodes. * <p> * Most Children objects have a 1:1 mapping between keys and nodes. For * convenience in that situation, simply override createNodeForKey(T). * * @param key An object from the list returned by * <code>asynchCreateKeys()</code> * @return null if no nodes, or zero or more Nodes to represent this key */ protected Node[] createNodesForKey(T key) { Node n = createNodeForKey(key); return n == null ? null : new Node[] { n }; } /**
@SuppressWarnings("unchecked") // Union2<T,Node> undesirable since refresh could not use raw keys list protected Node[] createNodes(Object key) { if (ChildFactory.isWaitNode(key)) { return new Node[] { (Node) key }; } else { return factory.createNodesForKey ((T) key); } }
if (!notified) { notified = true; factory.addNotify(); done = factory.createKeys(keys); } catch (Stop stop) { done = true; Node n = factory.getWaitNode(); if (n != null) { newKeys.add(n);
public void refresh() { super.refresh(false); }
@Override public boolean add(T e) { if (cancelled || Thread.interrupted()) { throw new Stop(); } super.add(e); LinkedList<Object> newKeys = new LinkedList<Object>(this); Node n = factory.getWaitNode(); if (n != null) { newKeys.add(n); } newKeys.removeAll(Collections.singleton(null)); // #206958 if (newKeys.size() > minimalCount) { setKeys(newKeys); } return true; } // #206556 Y02 - could override other mutator methods if ever needed
protected @Override void removeNotify() { active = false; setKeys(Collections.<T>emptyList()); factory.removeNotify(); }
protected Node[] createNodes(T key) { return factory.createNodesForKey(key); }
Node getWaitNode() { Node n = createWaitNode(); return n == null ? null : new WaitFilterNode(n); }
if (asynchronous) { AsynchChildren<T> ch = new AsynchChildren <T> (factory); factory.setObserver(ch); return ch; } else { SynchChildren<T> ch = new SynchChildren <T> (factory); factory.setObserver(ch); return ch;
/******************************************************************************************************************* * * ******************************************************************************************************************/ public void retry() { if (node != null) { node.getChildren().add(new Node[] {createWaitNode()}); } super.refresh(false); }
protected @Override void addNotify() { logger.log (Level.FINER, "addNotify on {0}", new Object[] { this }); if ((!initialized && task.isFinished()) || cancelled) { cancelled = false; Node n = factory.getWaitNode(); if (n != null) { setKeys (new Object[] { n }); } task.schedule(0); } }
protected @Override void removeNotify() { logger.log (Level.FINER, "removeNotify on {0}", new Object[] { this }); try { cancelled = true; task.cancel(); initialized = false; setKeys (Collections.<Object>emptyList()); } finally { synchronized (notifyLock) { //#170794 ensure setting of flag and call to add/removeNotify() are atomic if (notified) { factory.removeNotify(); } } } }
/** * Notify this AsynchChildren that it should reconstruct its children, * calling <code>provider.asynchCreateKeys()</code> and setting the * keys to that. Call this method if the list of child objects is known * or likely to have changed. * @param immediate If true, the keys are updated synchronously from the * calling thread. Set this to true only if you know that updating * the keys will <i>not</i> be an expensive or time-consuming operation. */ public void refresh(boolean immediate) { immediate &= !EventQueue.isDispatchThread(); logger.log (Level.FINE, "Refresh on {0} immediate {1}", new Object[] //NOI18N { this, immediate }); if (logger.isLoggable(Level.FINEST)) { logger.log (Level.FINEST, "Refresh: ", new Exception()); //NOI18N } if (immediate) { boolean done; List <T> keys = new LinkedList <T> (); do { done = factory.createKeys(keys); } while (!done); setKeys (keys); } else { task.schedule (0); } }