Refine search
private OverFiles(String path, List<FOItem> items, AbstractLookup.Content cnt) { this(path, items, new AbstractLookup(cnt), cnt); }
@Override public final <T> Lookup.Item<T> lookupItem(Lookup.Template<T> template) { AbstractLookup.this.beforeLookup(template); ArrayList<Pair<T>> list = null; AbstractLookup.Storage<?> t = enterStorage(); try { Enumeration<Pair<T>> en; try { en = t.lookup(template.getType()); return findSmallest(en, template, false); } catch (AbstractLookup.ISE ex) { // not possible to enumerate the exception, ok, copy it // to create new list = new ArrayList<Pair<T>>(); en = t.lookup(null); // this should get all the items without any checks // the checks will be done out side of the storage while (en.hasMoreElements()) { list.add(en.nextElement()); } } } finally { exitStorage(); } return findSmallest(Collections.enumeration(list), template, true); }
/** The method to add a pair to the associated {@link AbstractLookup}. * Preferably call this method when lookup is already associated with * this <em>content</em> (association is done by passing this object to some * {@link AbstractLookup#AbstractLookup(org.openide.util.lookup.AbstractLookup.Content) AbstractLookup's constructor} * once). * * @param pair class/instance pair * @throws NullPointerException may throw NullPointerException if called * before association with {@link AbstractLookup} */ public final void addPair(Pair<?> pair) { AbstractLookup a = al; Executor e = getExecutor(); if (a != null || e != null) { if (a == null) { throw new NullPointerException( "Adding a pair to Content not connected to Lookup is not supported!" // NOI18N ); } a.addPair(pair, e); } else { if (notifyIn == null) { notifyIn = new ArrayList<Pair>(3); } getEarlyPairs().add(pair); } }
private final void writeObject(ObjectOutputStream oos) throws IOException { AbstractLookup.Storage s = enterStorage(); try { // #36830: Serializing only InheritanceTree no ArrayStorage s.beginTransaction(Integer.MAX_VALUE); // #32040: don't write half-made changes oos.defaultWriteObject(); } finally { exitStorage(); } }
private <Transaction> void removePairImpl(Pair<?> pair, Executor notifyIn) { HashSet<R> toNotify = new HashSet<R>(); AbstractLookup.Storage<Transaction> t = enterStorage(); Transaction transaction = null; try { transaction = t.beginTransaction(-1); t.remove(pair, transaction); t.endTransaction(transaction, toNotify); } finally { exitStorage(); } notifyIn(notifyIn, toNotify); }
CodeClipNodeFactory(XMLDataObject obj) { xmlDataObject = obj; InstanceContent content = new InstanceContent(); content.add(Node.class, this); lookup = new AbstractLookup(content); }
/** * Creates a new instance of ActivatedNodesMediator. * * @param delegate the Node delegate that must be excluded from Lookup * (may be null). */ public ActivatedNodesMediator(Node delegate) { nodesHack = new InstanceContent(); lookup = new AbstractLookup(nodesHack); this.delegate = delegate; }
private PaletteItemDataNode(PaletteItemDataObject obj, InstanceContent ic) { super(obj, Children.LEAF, new AbstractLookup(ic)); ic.add(obj); ic.add(this); this.obj = obj; lookup = Lookups.singleton(this); }
@Override protected Collection<? extends Item<T>> allItems(boolean callBeforeLookup) { if (callBeforeLookup) { reference.lookup.beforeLookup(reference.template); } return allItemsWithoutBeforeLookup(); }
/** Remove instance. * @param pair class/instance pair */ protected final void removePair (Pair pair) { HashSet toNotify = new HashSet (); Object transaction = null; AbstractLookup.Storage t = enterStorage (); try { transaction = t.beginTransaction(-1); t.remove (pair, transaction); t.endTransaction (transaction, toNotify); } finally { exitStorage (); } notifyListeners (toNotify); }
@Override public final <T> Lookup.Result<T> lookup(Lookup.Template<T> template) { beforeLookupResult(template); for (;;) { AbstractLookup.ISE toRun = null; AbstractLookup.Storage<?> t = enterStorage(); try { R<T> r = new R<T>(); ReferenceToResult<T> newRef = new ReferenceToResult<T>(r, this, template); newRef.next = t.registerReferenceToResult(newRef); return r; } catch (AbstractLookup.ISE ex) { toRun = ex; } finally { exitStorage(); } toRun.recover(this); // and try again } }
/** Cleans the reference. Implements Runnable interface, do not call * directly. */ public void run() { lookup.cleanUpResult(this.template); }
public AnimationDataObject(AnimationEditor controller, FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException { super(pf, loader); myController = controller; myInstance = new InstanceContent(); myLookup = new AbstractLookup(myInstance); myInstance.add(myController); setSaveCookie(); }
ProjectWebModule (WebProject project, UpdateHelper helper, ClassPathProviderImpl cpProvider) { this.project = project; this.helper = helper; this.cpProvider = cpProvider; myContent = new InstanceContent(); myLookup = new AbstractLookup( myContent ); //project.evaluator().addPropertyChangeListener(this); }
private RootNode(List<BundleNode> resourceBundleNodes, InstanceContent content) { super (new RootChildren(resourceBundleNodes), new AbstractLookup(content)); content.add(this); this.rootChildren = (RootChildren) getChildren(); }
/** Method to be called when a result is cleared to signal that the list * of all result should be checked for clearing. * @param template the template the result was for * @return true if the hash map with all items has been cleared */ <T> boolean cleanUpResult(Lookup.Template<T> template) { AbstractLookup.Storage<?> t = enterStorage(); try { return t.cleanUpResult(template) == null; } finally { exitStorage(); Thread.yield(); } }
/** Used by proxy results to synchronize before lookup. */ protected void beforeLookup(Lookup.Template t) { if (t.getType() == reference.template.getType()) { reference.lookup.beforeLookup(t); } }
private final <Transaction> void addPairImpl(Pair<?> pair, Executor notifyIn) { HashSet<R> toNotify = new HashSet<R>(); AbstractLookup.Storage<Transaction> t = enterStorage(); Transaction transaction = null; try { transaction = t.beginTransaction(-2); if (t.add(pair, transaction)) { try { pair.setIndex(t, count++); } catch (IllegalStateException ex) { // remove the pair t.remove(pair, transaction); // rethrow the exception throw ex; } // if the pair is newly added and was not there before t.endTransaction(transaction, toNotify); } else { // just finish the process by calling endTransaction t.endTransaction(transaction, new HashSet<R>()); } } finally { exitStorage(); } notifyIn(notifyIn, toNotify); }
/** Remove instance. * @param pair class/instance pair */ protected final void removePair (Pair pair) { HashSet toNotify = new HashSet (); Object transaction = null; AbstractLookup.Storage t = enterStorage (); try { transaction = t.beginTransaction(-1); t.remove (pair, transaction); t.endTransaction (transaction, toNotify); } finally { exitStorage (); } notifyListeners (toNotify); }
@Override public final <T> Lookup.Result<T> lookup(Lookup.Template<T> template) { beforeLookupResult(template); for (;;) { AbstractLookup.ISE toRun = null; AbstractLookup.Storage<?> t = enterStorage(); try { R<T> r = new R<T>(); ReferenceToResult<T> newRef = new ReferenceToResult<T>(r, this, template); newRef.next = t.registerReferenceToResult(newRef); return r; } catch (AbstractLookup.ISE ex) { toRun = ex; } finally { exitStorage(); } toRun.recover(this); // and try again } }