org.openide.util.WeakSet Java Examples

The following examples show how to use org.openide.util.WeakSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BreakpointAnnotationProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #2
Source File: WhiteListTaskProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example #3
Source File: BreakpointAnnotationProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #4
Source File: WhiteListTaskProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example #5
Source File: NbInstrumentation.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void unregisterAgent(NbInstrumentation instr) {
    synchronized (LOCK) {
        if (ACTIVE != null) {
            Collection<NbInstrumentation> clone = new WeakSet<NbInstrumentation>(ACTIVE);
            clone.remove(instr);
            ACTIVE = clone;
        }
    }
}
 
Example #6
Source File: FilterNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: GlobalManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #8
Source File: AlwaysEnabledAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: TaskProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: PresenterUpdater.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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
}
 
Example #11
Source File: HudsonRemoteFileSystem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #12
Source File: ShortcutManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #13
Source File: DefaultTreeExpansionManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example #14
Source File: QueryAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public QueryAction(String name, QueryNode... queryNodes) {
    super(name);
    this.queryNodes = new WeakSet<QueryNode>(Arrays.asList(queryNodes));
}
 
Example #15
Source File: FormEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void registerNodeWithPropertiesWindow(FormNode node) {
    if (nodesWithPropertiesWindows == null) {
        nodesWithPropertiesWindows = new WeakSet<FormNode>();
    }
    nodesWithPropertiesWindows.add(node);
}
 
Example #16
Source File: Actions.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private RefreshAction(List<Refreshable> nodes) {
    super(NbBundle.getMessage(Actions.class, "CTL_Refresh"));
    putValue(ACCELERATOR_KEY, REFRESH_KEY);
    this.nodes = new WeakSet<Refreshable>(nodes);
}
 
Example #17
Source File: DebugMainProjectAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static synchronized void addAttachHistorySupport(AttachHistorySupport support) {
    if (ahs == null) {
        ahs = new WeakSet<AttachHistorySupport>();
    }
    ahs.add(support);
}
 
Example #18
Source File: AntProjectHelperImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public AntProjectHelperImpl(org.netbeans.spi.project.support.ant.AntProjectHelper delegate) {
    this.delegate = delegate;
    this.listener = new L();
    this.delegate.addAntProjectListener(listener);
    this.antListeners = Collections.synchronizedSet(new WeakSet<Callback>());
}
 
Example #19
Source File: MyApp.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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());
}
 
Example #20
Source File: ExecutableFilesIndex.java    From netbeans with Apache License 2.0 3 votes vote down vote up
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);
}