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


Java WeakListeners类代码示例

本文整理汇总了Java中org.openide.util.WeakListeners的典型用法代码示例。如果您正苦于以下问题:Java WeakListeners类的具体用法?Java WeakListeners怎么用?Java WeakListeners使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: findActivePlatform

import org.openide.util.WeakListeners; //导入依赖的package包/类
@NonNull
JavaPlatform findActivePlatform() {
    synchronized (LOCK) {
        activePlatformValid = true;
        if (platformManager == null) {
            platformManager = JavaPlatformManager.getDefault();
            platformManager.addPropertyChangeListener(WeakListeners.propertyChange(this, platformManager));
            NbMavenProject watch = project.getProjectWatcher();
            watch.addPropertyChangeListener(this);
        }
        //TODO ideally we would handle this by toolchains in future.
        //only use the default auximpl otherwise we get recursive calls problems.
        String val = project.getAuxProps().get(Constants.HINT_JDK_PLATFORM, true);
        JavaPlatform plat = getActivePlatform(val);
        if (plat == null) {
            //TODO report how?
            Logger.getLogger(BootClassPathImpl.class.getName()).log(Level.FINE, "Cannot find java platform with id of ''{0}''", val); //NOI18N
            plat = platformManager.getDefaultPlatform();
            activePlatformValid = false;
        }
        //Invalid platform ID or default platform
        return plat;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:AbstractBootPathImpl.java

示例2: initOptionsListener

import org.openide.util.WeakListeners; //导入依赖的package包/类
private void initOptionsListener() {
    optionsListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Lines lines = getDocumentLines();
            if (lines != null) {
                String pn = evt.getPropertyName();
                OutputOptions opts = io.getOptions();
                updateOptionsProperty(pn, lines, opts);
                OutputTab.this.repaint();
            }
        }
    };
    this.io.getOptions().addPropertyChangeListener(
            WeakListeners.propertyChange(optionsListener, io.getOptions()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:OutputTab.java

示例3: TagNode

import org.openide.util.WeakListeners; //导入依赖的package包/类
public TagNode (File repository, GitTag tag) {
    super(Children.LEAF, repository, Lookups.singleton(new Revision(tag.getTaggedObjectId(), tag.getTagName())));
    tagName = tag.getTagName();
    message = tag.getMessage();
    revisionId = tag.getTaggedObjectId();
    setIconBaseWithExtension("org/netbeans/modules/git/resources/icons/tag.png"); //NOI18N
    RepositoryInfo info = RepositoryInfo.getInstance(repository);
    if (info == null) {
        LOG.log(Level.INFO, "TagNode() : Null info for {0}", repository); //NOI18N
        list = null;
    } else {
        info.addPropertyChangeListener(WeakListeners.propertyChange(list = new PropertyChangeListener() {
            @Override
            public void propertyChange (PropertyChangeEvent evt) {
                if (RepositoryInfo.PROPERTY_ACTIVE_BRANCH.equals(evt.getPropertyName()) || RepositoryInfo.PROPERTY_HEAD.equals(evt.getPropertyName())) {
                    refreshActiveBranch((GitBranch) evt.getNewValue());
                }
            }
        }, info));
        refreshActiveBranch(info.getActiveBranch());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:RepositoryBrowserPanel.java

示例4: ModulesChildFactory

import org.openide.util.WeakListeners; //导入依赖的package包/类
ModulesChildFactory(NbMavenProjectImpl proj) {
    project = proj;
    NbMavenProject watcher = project.getProjectWatcher();
    listener = new PropertyChangeListener() {
                               @Override
                               public void propertyChange(PropertyChangeEvent evt) {
                                   if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) {
                                       refresh(false);
                                   }
                               }
                           };
     
    watcher.addPropertyChangeListener(WeakListeners.propertyChange(listener, watcher));                       
    
 
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ModulesNode.java

示例5: setActiveAction

import org.openide.util.WeakListeners; //导入依赖的package包/类
public void setActiveAction(Action a) {
    if (a == action) { // In this case there is in fact no extra context
        a = null;
    }
    synchronized (this) {
        if (a != contextAction) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("setActiveAction(): from " + contextAction + " to " + a + "\n"); // NOI18N
            }
            contextAction = a;
            if (a != null && !listenedContextActions.contains(a)) {
                listenedContextActions.add(a);
                a.addPropertyChangeListener(WeakListeners.propertyChange(this, a));
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("setActiveAction(): started listening on " + a + "\n"); // NOI18N
                }
            }
            updatePresenter(null); // Update presenter completely
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:PresenterUpdater.java

示例6: annotateWithProjectName

import org.openide.util.WeakListeners; //导入依赖的package包/类
/** #25793 fix - adds project name to given ant script name if needed.
 * @return ant script name annotated with project name or ant script name unchanged
 */
private String annotateWithProjectName (String name) {
    DataObject d = getDataObject();
    if (d.getPrimaryFile().getNameExt().equals("build.xml")) { // NOI18N
        // #25793: show project name in case the script name does not suffice
        AntProjectCookie cookie = d.getCookie(AntProjectCookie.class);
        Element pel = cookie.getProjectElement();
        if (pel != null) {
            String projectName = pel.getAttribute("name"); // NOI18N
            if (!projectName.equals("")) { // NOI18N
                name = NbBundle.getMessage(AntProjectDataEditor.class,
                    "LBL_editor_tab", name, projectName);
            }
        }
        if (!addedChangeListener) {
            cookie.addChangeListener(WeakListeners.change(this, cookie));
            addedChangeListener = true;
        }
    }
    return name;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:AntProjectDataEditor.java

示例7: getToolbarPresenter

import org.openide.util.WeakListeners; //导入依赖的package包/类
public Component getToolbarPresenter () {
    class AntButton extends JButton implements PropertyChangeListener {
        public AntButton() {
            super(AntActionInstance.this);
            // XXX setVisible(false) said to be poor on GTK L&F; consider using #26338 instead
            setVisible(isEnabled());
            AntActionInstance.this.addPropertyChangeListener(WeakListeners.propertyChange(this, AntActionInstance.this));
        }
        public void propertyChange(PropertyChangeEvent evt) {
            if ("enabled".equals(evt.getPropertyName())) { // NOI18N
                setVisible(isEnabled());
            }
        }
    }
    return new AntButton();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:AntActionInstance.java

示例8: getHighlights

import org.openide.util.WeakListeners; //导入依赖的package包/类
@Override
public HighlightsSequence getHighlights(int startOffset, int endOffset) {
    synchronized (this) {
        if (rubyBackground != null) {
            if (hierarchy == null) {
                hierarchy = TokenHierarchy.get(document);
                if (hierarchy != null) {
                    hierarchy.addTokenHierarchyListener(WeakListeners.create(TokenHierarchyListener.class, this, hierarchy));
                }
            }

            if (hierarchy != null) {
                return new Highlights(version, hierarchy, startOffset, endOffset);
            }
        }
        return HighlightsSequence.EMPTY;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:EmbeddedSectionsHighlighting.java

示例9: updateCandidates

import org.openide.util.WeakListeners; //导入依赖的package包/类
private synchronized boolean updateCandidates() {
    boolean affected = false;
    final JavaPlatform[] newPlatforms = jpm.getInstalledPlatforms();
    final Map<JavaPlatform, PropertyChangeListener> oldPlatforms = new HashMap<>(platforms);
    final Map<JavaPlatform, PropertyChangeListener> newState = new LinkedHashMap<>(newPlatforms.length);
    for (JavaPlatform jp : newPlatforms) {
        PropertyChangeListener l;
        if ((l=oldPlatforms.remove(jp))!=null) {
            newState.put(jp,l);
        } else if (contains(jp,artifact)) {
            affected = true;
            l = WeakListeners.propertyChange(this, this.jpm);
            jp.addPropertyChangeListener(l);
            newState.put(jp,l);
        }
    }
    for (Map.Entry<JavaPlatform,PropertyChangeListener> e : oldPlatforms.entrySet()) {
        affected = true;
        e.getKey().removePropertyChangeListener(e.getValue());
    }
    platforms = newState;
    return affected;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:PlatformSourceForBinaryQuery.java

示例10: getUnsubmittedTasksContainer

import org.openide.util.WeakListeners; //导入依赖的package包/类
private UnsubmittedTasksContainer getUnsubmittedTasksContainer () throws CoreException {
    synchronized (this) {
        if (unsubmittedTasksContainer == null) {
            unsubmittedTasksContainer = MylynSupport.getInstance().getUnsubmittedTasksContainer(getTaskRepository());
            unsubmittedTasksContainer.addPropertyChangeListener(WeakListeners.propertyChange(unsubmittedTasksListener = new PropertyChangeListener() {
                @Override
                public void propertyChange (PropertyChangeEvent evt) {
                    if (UnsubmittedTasksContainer.EVENT_ISSUES_CHANGED.equals(evt.getPropertyName())) {
                        fireUnsubmittedIssuesChanged();
                    }
                }
            }, unsubmittedTasksContainer));
        }
        return unsubmittedTasksContainer;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:BugzillaRepository.java

示例11: MetaInf

import org.openide.util.WeakListeners; //导入依赖的package包/类
MetaInf (String rootFolder) {
    if (rootFolder != null && rootFolder.length() == 0) {
        rootFolder = null;
    }
    this.rootFolder = rootFolder;
    moduleLookupResult = org.openide.util.Lookup.getDefault().lookupResult(ModuleInfo.class);
    //System.err.println("\nModules = "+moduleLookupResult.allInstances().size()+"\n");
    modulesChangeListener = new ModuleChangeListener(null);
    moduleLookupResult.addLookupListener(
            WeakListeners.create(org.openide.util.LookupListener.class,
                                 modulesChangeListener,
                                 moduleLookupResult));
    listenOnDisabledModulesTask = RP.create(new Runnable() {
        @Override
        public void run() {
            // This may take a while...
            listenOnDisabledModules();
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Lookup.java

示例12: CosAction

import org.openide.util.WeakListeners; //导入依赖的package包/类
private CosAction(
        @NonNull final J2SEActionProvider owner,
        @NonNull final PropertyEvaluator eval,
        @NonNull final SourceRoots src,
        @NonNull final SourceRoots tests) {
    this.owner = owner;
    this.eval = eval;
    this.src = src;
    this.tests = tests;
    this.mapper = new BuildArtifactMapper();
    this.currentListeners = new HashMap<>();
    this.cs = new ChangeSupport(this);
    this.importantFilesCache = new AtomicReference<>(Pair.of(null,null));
    this.eval.addPropertyChangeListener(WeakListeners.propertyChange(this, this.eval));
    this.src.addPropertyChangeListener(WeakListeners.propertyChange(this, this.src));
    this.tests.addPropertyChangeListener(WeakListeners.propertyChange(this, this.tests));
    updateRootsListeners();
    instances.put(owner.getProject(), new WeakReference<>(this));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:J2SEActionProvider.java

示例13: getWhiteLists

import org.openide.util.WeakListeners; //导入依赖的package包/类
private Iterable<WhiteListImplementation> getWhiteLists() {
    synchronized (this) {
        if (cache != null) {
            return cache.keySet();
        }
    }
    final Map<WhiteListImplementation,ChangeListener> map = new IdentityHashMap<WhiteListImplementation,ChangeListener>();
    for (WhiteListQueryImplementation wlq : lr.allInstances()) {
        final WhiteListImplementation wl = wlq.getWhiteList(file);
        if (wl != null) {
            final ChangeListener cl = WeakListeners.change(this, wl);
            wl.addChangeListener(cl);
            map.put(wl, cl);
        }
    }
    synchronized (this) {
        if (cache == null) {
            cache = map;
        }
        return cache.keySet();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:WhiteListQueryImplementationMerged.java

示例14: addListener

import org.openide.util.WeakListeners; //导入依赖的package包/类
private void addListener(PropertiesDataObject dataObj) {
    PropertyChangeListener l =weakEnvPropListeners.get(dataObj);
    VetoableChangeListener v = weakEnvVetoListeners.get(dataObj);
    if (l != null) {
        dataObj.removePropertyChangeListener(l);
    } else {
        l = WeakListeners.propertyChange(this, dataObj);
        weakEnvPropListeners.put(dataObj, l);
    }
    if (v != null) {
        dataObj.removeVetoableChangeListener(v);
    } else {
        v = WeakListeners.vetoableChange(this, dataObj);
        weakEnvVetoListeners.put(dataObj, v);
    }
    dataObj.addPropertyChangeListener(l);
    dataObj.addVetoableChangeListener(v);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:PropertiesOpen.java

示例15: MainProjectAction

import org.openide.util.WeakListeners; //导入依赖的package包/类
@SuppressWarnings("LeakingThisInConstructor")
MainProjectAction(String command, ProjectActionPerformer performer, String name, Icon icon, Lookup lookup) {
    super(icon, lookup, new Class<?>[] {Project.class, DataObject.class});
    this.command = command;
    this.performer = performer;
    this.name = name;

    String presenterName = "";
    if (name != null) {
        presenterName = MessageFormat.format(name, -1);
    }
    setDisplayName(presenterName);
    if ( icon != null ) {
        setSmallIcon( icon );
    }

    // Start listening on open projects list to correctly enable the action
    OpenProjectList.getDefault().addPropertyChangeListener( WeakListeners.propertyChange( this, OpenProjectList.getDefault() ) );
    // XXX #47160: listen to changes in supported commands on current project, when that becomes possible
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MainProjectAction.java


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