本文整理汇总了Java中org.openide.util.WeakListeners.create方法的典型用法代码示例。如果您正苦于以下问题:Java WeakListeners.create方法的具体用法?Java WeakListeners.create怎么用?Java WeakListeners.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.util.WeakListeners
的用法示例。
在下文中一共展示了WeakListeners.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateActiveCaret
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
private void updateActiveCaret() {
if (visible) {
setVisible(false);
}
if (editorCaret != null) {
editorCaret.removeEditorCaretListener(weakEditorCaretListener);
weakEditorCaretListener = null;
editorCaret = null;
docText = null;
}
Caret caret = component.getCaret();
if (caret instanceof EditorCaret) { // Only work for editor caret
editorCaret = (EditorCaret) caret;
}
if (editorCaret != null) {
updateDocText();
weakEditorCaretListener = WeakListeners.create(EditorCaretListener.class, this, editorCaret);
editorCaret.addEditorCaretListener(weakEditorCaretListener);
}
}
示例2: init
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
/** Called when there may be a need for initialization.
*
* @return true if subclasses shall initialize themselves
*/
protected boolean init () {
synchronized (RESULTS_LOCK) {//synchronized == issue 215335
if (initialized) {
return false;
}
this.results = new Lookup.Result[watch.length];
// Needs to listen on changes in results
for ( int i = 0; i < watch.length; i++ ) {
results[i] = lookup.lookupResult(watch[i]);
results[i].allItems();
LookupListener resultListener = WeakListeners.create(LookupListener.class, this, results[i]);
results[i].addLookupListener( resultListener );
}
initialized = true;
return true;
}
}
示例3: defaultJavadoc
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
private List<URL> defaultJavadoc(final boolean listen) {
final JavaPlatform safePlatform = new ForwardingJavaPlatform(this) {
@Override
public List<URL> getJavadocFolders() {
return Collections.<URL>emptyList();
}
};
final Set<URI> roots = new LinkedHashSet<>();
final Lookup.Result<? extends J2SEPlatformDefaultJavadoc> res = getJ2SEPlatformDefaultJavadoc();
if (listen) {
synchronized (this) {
if (jdocListener == null) {
jdocListener = new LookupListener[2];
jdocListener[0] = new LookupListener() {
@Override
public void resultChanged(LookupEvent ev) {
javadoc = null;
}
};
jdocListener[1] = WeakListeners.create(LookupListener.class, jdocListener[0], res);
res.addLookupListener(jdocListener[1]);
}
}
}
for (J2SEPlatformDefaultJavadoc jdoc : res.allInstances()) {
roots.addAll(jdoc.getDefaultJavadoc(safePlatform));
}
final List<URL> result = new ArrayList<>(roots.size());
for (URI root : roots) {
try {
result.add(root.toURL());
} catch (MalformedURLException ex) {
Exceptions.printStackTrace(ex);
}
}
return Collections.unmodifiableList(result);
}
示例4: FoldViewFactory
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
public FoldViewFactory(View documentView) {
super(documentView);
foldHierarchy = FoldHierarchy.get(textComponent());
// the view factory may get eventually GCed, but the FoldHierarchy can survive, snce it is tied to the component.
weakL = WeakListeners.create(FoldHierarchyListener.class, this, foldHierarchy);
foldHierarchy.addFoldHierarchyListener(weakL);
// Go through folds and search for collapsed fold.
foldHierarchy.lock();
try {
@SuppressWarnings("unchecked")
Iterator<Fold> it = FoldUtilities.collapsedFoldIterator(foldHierarchy, 0, Integer.MAX_VALUE);
collapsedFoldEncountered = it.hasNext();
} finally {
foldHierarchy.unlock();
}
displayAllFoldsExpanded = Boolean.TRUE.equals(textComponent().getClientProperty(DISPLAY_ALL_FOLDS_EXPANDED_PROPERTY));
String mime = DocumentUtilities.getMimeType(document());
Lookup lkp = MimeLookup.getLookup(mime);
colorSource = lkp.lookupResult(FontColorSettings.class);
colorSource.addLookupListener(WeakListeners.create(LookupListener.class, this, colorSource));
colorSettings = (FontColorSettings)colorSource.allInstances().iterator().next();
prefs = lkp.lookup(Preferences.class);
prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs));
initViewFlags();
}
示例5: setDefaultPreferences
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
@Override
public void setDefaultPreferences(Preferences pref) {
if (this.defaultPrefs != null) {
defaultPrefs.removePreferenceChangeListener(weakL);
}
// anomaly: if the local Preference contains 'removedKey' for a preference
// which has been turned to default, it blocks all change propagations.
this.defaultPrefs = pref;
if (pref != null) {
weakL = WeakListeners.create(PreferenceChangeListener.class, this, pref);
pref.addPreferenceChangeListener(weakL);
}
}
示例6: setMimeType
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
private void setMimeType(String mimeType) {
if (!this.mimeType.equals(mimeType)) {
// String oldMimeType = this.mimeType;
this.mimeType = mimeType;
// new Throwable("~~~ setMimeType: '" + oldMimeType + "' -> '" + mimeType + "'").printStackTrace(System.out);
//
if (prefs != null && weakPrefsListener != null) {
try {
prefs.removePreferenceChangeListener(weakPrefsListener);
// System.out.println("~~~ setMimeType: " + s2s(prefs) + " removing " + s2s(weakPrefsListener));
} catch (IllegalArgumentException e) {
// System.out.println("~~~ IAE: doc=" + s2s(this) + ", '" + oldMimeType + "' -> '" + this.mimeType + "', prefs=" + s2s(prefs) + ", wpl=" + s2s(weakPrefsListener));
}
weakPrefsListener = null;
}
prefs = MimeLookup.getLookup(this.mimeType).lookup(Preferences.class);
prefsListener.preferenceChange(null);
// System.out.println("~~~ setMimeType: '" + this.mimeType + "' -> " + s2s(prefs));
// reinitialize the document
EditorKit kit = getEditorKit();
if (kit instanceof BaseKit) {
// careful here!! some kits set document's mime type from initDocument
// even worse, the new mime type can be different from the one passed to the constructor,
// which will result in recursive call to this method
((BaseKit) kit).initDocument(this);
}
if (weakPrefsListener == null) {
weakPrefsListener = WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs);
prefs.addPreferenceChangeListener(weakPrefsListener);
// System.out.println("~~~ setMimeType: " + s2s(prefs) + " adding " + s2s(weakPrefsListener));
}
}
}
示例7: listenToReferencedModel
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
public void listenToReferencedModel(AXIModel model) {
if(listenerMap.get(model) == null) {
ComponentListener listener = (ComponentListener)WeakListeners.
create(ComponentListener.class, axiModelListener, model);
model.addComponentListener(listener);
listenerMap.put(model, listener);
}
}
示例8: attachListenerToChangesInMap
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
/** Adds itself as a listener for changes in current ActionMap.
* If the lookup is null then it means to listen on TopComponent
* otherwise to listen on the lookup itself.
*
* @param lookup lookup to listen on or null
*/
private void attachListenerToChangesInMap(Lookup lookup) {
if (lookup == null) {
TopComponent.getRegistry().addPropertyChangeListener(WeakListeners.propertyChange(this, TopComponent.getRegistry()));
} else {
result = lookup.lookupResult(ActionMap.class);
weakLookup = WeakListeners.create(LookupListener.class, this, result);
result.addLookupListener(weakLookup);
}
checkStateChanged(false);
}
示例9: setLineHandler
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
public void setLineHandler(EditorLineHandler line) {
dispose();
EditorLineHandler oldLine = this.line;
this.line = line;
lineChangesWeak = WeakListeners.propertyChange(lineChangeslistener, line);
line.addPropertyChangeListener(lineChangesWeak);
FileObject fileObject = line.getFileObject();
if (fileObject != null) {
myWeakListener = WeakListeners.create(
FileChangeListener.class, myListener, fileObject);
fileObject.addFileChangeListener(myWeakListener);
}
firePropertyChange(PROP_FILE, oldLine.getFileObject(), line.getFileObject());
firePropertyChange(PROP_LINE_NUMBER, oldLine.getLineNumber(), line.getLineNumber());
}
示例10: checkInitPrefs
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
private void checkInitPrefs() {
if (weakListener == null) {
String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(doc);
if (mimeType != null) {
prefs = MimeLookup.getLookup(mimeType).lookup(Preferences.class);
weakListener = WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs);
prefs.addPreferenceChangeListener(weakListener);
prefsListener.preferenceChange(null);
}
}
}
示例11: registerListener
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
private void registerListener() {
if (flavL == null) {
Clipboard c = getClipboard();
if (c != null) {
flavL = WeakListeners.create(FlavorListener.class, this, c);
c.addFlavorListener(flavL);
}
}
}
示例12: DefaultTopComponentLookup
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
/** Creates the lookup.
* @param tc component to work on
*/
public DefaultTopComponentLookup(TopComponent tc) {
super();
this.tc = new WeakReference<TopComponent>(tc);
this.listener = WeakListeners.create(LookupListener.class, this, null);
this.actionMap = Lookups.singleton(new DelegateActionMap(tc));
updateLookups(tc.getActivatedNodes());
}
示例13: JSLineBreakpoint
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
public JSLineBreakpoint(EditorLineHandler line) {
this.line = line;
lineChangesWeak = WeakListeners.propertyChange(lineChangeslistener, line);
line.addPropertyChangeListener(lineChangesWeak);
FileObject fileObject = line.getFileObject();
if( fileObject != null ){
myWeakListener = WeakListeners.create(
FileChangeListener.class, myListener, fileObject);
fileObject.addFileChangeListener( myWeakListener );
}
}
示例14: SearchScopeNodeSelection
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
public SearchScopeNodeSelection() {
Lookup lookup = Utilities.actionsGlobalContext();
lookupResult = lookup.lookupResult(Node.class);
lookupListener = WeakListeners.create(LookupListener.class,
this,
lookupResult);
lookupResult.addLookupListener(lookupListener);
}
示例15: ProxyPreferences
import org.openide.util.WeakListeners; //导入方法依赖的package包/类
private ProxyPreferences(ProxyPreferences parent, MemoryPreferences memoryPref, Preferences delegate) {
this.parent = parent;
this.delegateRoot = memoryPref;
this.delegate = delegate == null ? memoryPref.getPreferences() : delegate;
weakPrefListener = WeakListeners.create(PreferenceChangeListener.class, this, delegate);
this.delegate.addPreferenceChangeListener(weakPrefListener);
weakNodeListener = WeakListeners.create(NodeChangeListener.class, this, delegate);
this.delegate.addNodeChangeListener(weakNodeListener);
}