当前位置: 首页>>代码示例>>Java>>正文


Java AbstractLookup.Pair方法代码示例

本文整理汇总了Java中org.openide.util.lookup.AbstractLookup.Pair方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractLookup.Pair方法的具体用法?Java AbstractLookup.Pair怎么用?Java AbstractLookup.Pair使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.util.lookup.AbstractLookup的用法示例。


在下文中一共展示了AbstractLookup.Pair方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enhancedQueryMode

import org.openide.util.lookup.AbstractLookup; //导入方法依赖的package包/类
static void enhancedQueryMode(Lookup lookup, Class<?> clazz) {
    Object type = QUERY_MODE.get();
    if (type != clazz) {
        return;
    }
    Collection<? extends Lookup.Item<?>> items = lookup.lookupResult(clazz).allItems();
    if (items.size() == 0) {
        return;
    }
    AbstractLookup.Pair[] arr = new AbstractLookup.Pair[items.size()];
    Iterator<? extends Lookup.Item> it = items.iterator();
    for (int i = 0; i < arr.length; i++) {
        arr[i] = new PairWrap(it.next());
    }
    QUERY_MODE.set(arr);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CookieSet.java

示例2: exitQueryMode

import org.openide.util.lookup.AbstractLookup; //导入方法依赖的package包/类
/** Exits query mode.
 */
static Collection<AbstractLookup.Pair> exitQueryMode(Object prev) {
    Object cookie = QUERY_MODE.get();
    QUERY_MODE.set(prev);

    if (cookie instanceof CookieSet.CookieEntry) {
        return Collections.singleton((AbstractLookup.Pair)new CookieEntryPair((CookieSet.CookieEntry) cookie));
    } else if (cookie instanceof AbstractLookup.Pair[]) {
        return Arrays.asList((AbstractLookup.Pair[])cookie);
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:CookieSet.java

示例3: fillServiceInstance

import org.openide.util.lookup.AbstractLookup; //导入方法依赖的package包/类
private void fillServiceInstance(Item<T> li) {
    String className = getClassName(li);
    Object instance = null;
    synchronized(instanceCache) {
        instance = instanceCache.get (className);
        Object origInstance = origInstanceCache.get(className);
        Item lastItem = lookupItemsCache.get(className);
        if (origInstance != null && li instanceof AbstractLookup.Pair &&
            lastItem != null && lastItem.getId().equals(li.getId())) {
            // Check whether the cached original instance was created by this lookup item.
            // If yes, we can use it, if not, we should create a new instance.
            // Verify whether the item is from the same registry file,
            // since there can be several registrations for one class instance.
            try {
                java.lang.reflect.Method creatorOfMethod = AbstractLookup.Pair.class.getDeclaredMethod("creatorOf", Object.class);
                creatorOfMethod.setAccessible(true);
                Object isCreator = creatorOfMethod.invoke(li, origInstance);
                if (logger.isLoggable(Level.FINE)) {
                    logger.fine("fillServiceInstance("+li+" [HASH = "+System.identityHashCode(li)+"]):");
                    logger.fine("  className = \""+className+"\", orig instance = "+origInstance+", instance = "+instance+", is creator of = "+isCreator);
                    if (lastItem != null) {
                        logger.fine("  last item was "+lastItem+" [HASH = "+System.identityHashCode(lastItem)+"])");
                    }
                    if (!Boolean.TRUE.equals(isCreator)) {
                        logger.fine("\n!!!\n"+li+" is not a creator of "+origInstance+" !\nCreating a new instance...");
                    }
                }
                if (!Boolean.TRUE.equals(isCreator)) {
                    instance = null;
                    instanceCache.remove(className);
                    origInstanceCache.remove(className);
                    lookupItemsCache.remove(className);
                }
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
    // remember the instance position for merge purpose: li.fo.getAttribute("position")
    int position = getPosition(li);
    while (elementPositions.size() < size()) {
        elementPositions.add(Integer.MAX_VALUE);
    }
    elementPositions.add(position);
    if (instance != null) {
        try {
            add(service.cast(instance), className);
        } catch (ClassCastException cce) {
            logger.log(Level.WARNING, null, cce);
        }
        listenOn(instance.getClass().getClassLoader());
    } else {
        add(new LazyInstance<T>(service, li));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:56,代码来源:Lookup.java


注:本文中的org.openide.util.lookup.AbstractLookup.Pair方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。