Java 类org.openide.util.WeakSet 实例源码

项目:incubator-netbeans    文件:BreakpointAnnotationProvider.java   
private void annotate (final FileObject fo) {
    synchronized (breakpointToAnnotations) {
        for (Breakpoint breakpoint : DebuggerManager.getDebuggerManager().getBreakpoints()) {
            if (isAnnotatable(breakpoint)) {
                JPDABreakpoint b = (JPDABreakpoint) breakpoint;
                int[] lines = getAnnotationLines(b, fo);
                if (lines != null && lines.length > 0) {
                    removeAnnotations(b);   // Remove any staled breakpoint annotations
                    breakpointToAnnotations.put(b, new WeakSet<Annotation>());
                    if (b instanceof LineBreakpoint) {
                        LineBreakpoint lb = (LineBreakpoint) b;
                        LineTranslations.getTranslations().unregisterFromLineUpdates(lb); // To be sure
                        LineTranslations.getTranslations().registerForLineUpdates(lb);
                    }
                    addAnnotationTo(b, fo, lines);
                }
            }
        }
        annotatedFiles.add(fo);
    }
}
项目:incubator-netbeans    文件:WhiteListTaskProvider.java   
@Override
public void setScope(TaskScanningScope scope, Callback callback) {
    cancelAllCurrent();
    if (scope == null || callback == null)
        return ;

    final Set<FileObject> files = new WeakSet<FileObject>();
    for (FileObject file : scope.getLookup().lookupAll(FileObject.class)) {
        files.add(file);
    }

    for (Project p : scope.getLookup().lookupAll(Project.class)) {
        for (SourceGroup javaSG : ProjectUtils.getSources(p).getSourceGroups("java")) {    //NOI18N
            files.add(javaSG.getRootFolder());
        }
    }
    for (FileObject fo : files) {
        enqueue(new Work(fo, callback));
    }
    synchronized (this) {
        currentFiles = files;
        currentCallback = callback;
    }
}
项目:incubator-netbeans    文件:NbInstrumentation.java   
static void unregisterAgent(NbInstrumentation instr) {
    synchronized (LOCK) {
        if (ACTIVE != null) {
            Collection<NbInstrumentation> clone = new WeakSet<NbInstrumentation>(ACTIVE);
            clone.remove(instr);
            ACTIVE = clone;
        }
    }
}
项目:incubator-netbeans    文件:PresenterUpdater.java   
private PresenterUpdater(int type, Action action) {
    if (action == null) {
        throw new IllegalArgumentException("action must not be null"); // NOI18N
    }
    this.type = type;
    this.actionName = (String) action.getValue(Action.NAME);
    this.action = action;
    if (type == TOOLBAR) {
        presenter = new JButton();
        useActionSelectedProperty = false;
    } else { // MENU or POPUP
        useActionSelectedProperty = (action.getValue(AbstractEditorAction.PREFERENCES_KEY_KEY) != null);
        if (useActionSelectedProperty) {
            presenter = new LazyJCheckBoxMenuItem();
            presenter.setSelected(isActionSelected());
        } else {
            presenter = new LazyJMenuItem();
        }
    }

    action.addPropertyChangeListener(WeakListeners.propertyChange(this, action));
    if (type == MENU) {
        listenedContextActions = new WeakSet<Action>();
        EditorRegistryWatcher.get().registerPresenterUpdater(this); // Includes notification of active component
    } else {
        listenedContextActions = null;
    }

    presenter.addActionListener(this);
    updatePresenter(null); // Not active yet => mark updates pending
}
项目:incubator-netbeans    文件:HudsonRemoteFileSystem.java   
private HudsonRemoteFileSystem(URL baseURL, String displayName, HudsonJob job) {
    this.baseURL = baseURL;
    this.displayName = displayName;
    this.job = job;
    attr = this;
    change = this;
    list = this;
    info = this;
    synchronized (Mapper.class) {
        if (Mapper.workspaces == null) {
            Mapper.workspaces = new WeakSet<HudsonRemoteFileSystem>();
        }
        Mapper.workspaces.add(this);
    }
}
项目:incubator-netbeans    文件:ShortcutManager.java   
public void registerAction(String command, Action action) {
    synchronized (this) {
        Set<Action> commandActions = actions.get(command);
        if (commandActions == null) {
            commandActions = new WeakSet<Action>();
            actions.put(command, commandActions);
        }
        commandActions.add(action);
    }
    Object shorcut = getShortcut(command);
    if (shorcut != null) {
        action.putValue(Action.ACCELERATOR_KEY, shorcut);
    }
}
项目:incubator-netbeans    文件:BreakpointAnnotationProvider.java   
private void refreshAnnotation(JPDABreakpoint b) {
    removeAnnotations(b);
    if (remove) {
        if (!add) {
            breakpointToAnnotations.remove(b);
        }
    }
    if (add) {
        breakpointToAnnotations.put(b, new WeakSet<Annotation>());
        for (FileObject fo : annotatedFiles) {
            addAnnotationTo(b, fo);
        }
    }
}
项目:incubator-netbeans    文件:DefaultTreeExpansionManager.java   
public synchronized void setExpanded(Object child) {
    if (currentChildren == null) throw new NullPointerException("Call setChildrenToActOn() before!!!");
    try {
        Set<Object> expanded = expandedNodes.get(currentChildren);
        if (expanded == null) {
            expanded = new WeakSet<Object>();
            expandedNodes.put(currentChildren, expanded);
        }
        expanded.add(child);
    } finally {
        currentChildren = null;
    }
}
项目:incubator-netbeans    文件:WhiteListTaskProvider.java   
private static Set<FileObject> getFilesWithAttachedErrors(FileObject root) {
    synchronized (root2FilesWithAttachedErrors) {
        Set<FileObject> result = root2FilesWithAttachedErrors.get(root);
        if (result == null) {
            root2FilesWithAttachedErrors.put(root, result = new WeakSet<FileObject>());
        }
        return result;
    }
}
项目:incubator-netbeans    文件:FilterNode.java   
public <T> Result<T> lookup(Template<T> template) {
    ProxyResult<T> p = new ProxyResult<T>(template);

    synchronized (this) {
        if (results == null) {
            results = new WeakSet<ProxyResult>();
        }

        results.add(p);
    }

    return p;
}
项目:incubator-netbeans    文件:TaskProvider.java   
private static Set<FileObject> getFilesWithAttachedErrors(FileObject root) {
    Set<FileObject> result = root2FilesWithAttachedErrors.get(root);

    if (result == null) {
        root2FilesWithAttachedErrors.put(root, result = new WeakSet<FileObject>());
    }

    return result;
}
项目:incubator-netbeans    文件:GlobalManager.java   
public final void registerListener(Object key, GeneralAction.BaseDelAction a) {
    if (key == null) {
        return;
    }
    synchronized (CACHE) {
        Set<GeneralAction.BaseDelAction> existing = listeners.get(key);
        if (existing == null) {
            existing = new WeakSet<GeneralAction.BaseDelAction>();
            listeners.put(key, existing);
        }
        existing.add(a);
        a.updateState(new ActionMap(), actionMap.get(), false);
    }
}
项目:incubator-netbeans    文件:AlwaysEnabledAction.java   
public AbstractButton getToolbarPresenter() {
    if(toolbarItems == null) {
        toolbarItems = new WeakSet<AbstractButton>(4);
    }
    AbstractButton b = new DefaultIconToggleButton();
    toolbarItems.add(b);
    b.setSelected(isPreferencesSelected());
    Actions.connect(b, this);
    return b;
}
项目:incubator-netbeans    文件:FormEditor.java   
void registerNodeWithPropertiesWindow(FormNode node) {
    if (nodesWithPropertiesWindows == null) {
        nodesWithPropertiesWindows = new WeakSet<FormNode>();
    }
    nodesWithPropertiesWindows.add(node);
}
项目:incubator-netbeans    文件:MyApp.java   
public static void main(String[] args) throws IOException {
    Set s = new WeakSet();
    s.add("hello");
    System.out.println("A WeakSet from lib1.jar: " + s);
    System.out.println("A NullInputStream.available from lib2.jar: " + new NullInputStream().available());
}
项目:incubator-netbeans    文件:DebugMainProjectAction.java   
private static synchronized void addAttachHistorySupport(AttachHistorySupport support) {
    if (ahs == null) {
        ahs = new WeakSet<AttachHistorySupport>();
    }
    ahs.add(support);
}
项目:incubator-netbeans    文件:Actions.java   
private RefreshAction(List<Refreshable> nodes) {
    super(NbBundle.getMessage(Actions.class, "CTL_Refresh"));
    putValue(ACCELERATOR_KEY, REFRESH_KEY);
    this.nodes = new WeakSet<Refreshable>(nodes);
}
项目:incubator-netbeans    文件:QueryAction.java   
public QueryAction(String name, QueryNode... queryNodes) {
    super(name);
    this.queryNodes = new WeakSet<QueryNode>(Arrays.asList(queryNodes));
}
项目:incubator-netbeans    文件:ExecutableFilesIndex.java   
public synchronized void addChangeListener(URL source, ChangeListener l) {
    String ext = source.toExternalForm();

    listener2File.put(l, ext);

    Set<ChangeListener> ls = file2Listener.get(ext);

    if (ls == null) {
        file2Listener.put(ext, ls = new WeakSet<ChangeListener>());
    }

    ls.add(l);

    file2Listener.put(ext, ls);
}