本文整理匯總了Java中org.openide.util.LookupEvent類的典型用法代碼示例。如果您正苦於以下問題:Java LookupEvent類的具體用法?Java LookupEvent怎麽用?Java LookupEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LookupEvent類屬於org.openide.util包,在下文中一共展示了LookupEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resultChanged
import org.openide.util.LookupEvent; //導入依賴的package包/類
@Override
public void resultChanged(LookupEvent ev) {
synchronized (PathLookupResult.this) {
items = null;
}
List<LookupListener> lls;
synchronized (listeners) {
if (listeners.isEmpty()) {
return;
} else {
lls = new ArrayList<LookupListener>(listeners);
}
}
LookupEvent lev = new LookupEvent(PathLookupResult.this);
for (LookupListener ll : lls) {
ll.resultChanged(lev);
}
}
示例2: ensureTaskListLoaded
import org.openide.util.LookupEvent; //導入依賴的package包/類
private synchronized void ensureTaskListLoaded () throws CoreException {
if (!taskListInitialized) {
if (result == null) {
LookupListener lookupListener = new LookupListener() {
@Override
public void resultChanged (LookupEvent ev) {
registerConnectors();
}
};
result = Lookup.getDefault().lookupResult(RepositoryConnectorProvider.class);
result.addLookupListener(lookupListener);
}
registerConnectors();
try {
if (taskListStorageFile.length() > 0) {
taskListWriter.readTaskList(taskList, taskListStorageFile);
}
} catch (CoreException ex) {
LOG.log(Level.INFO, null, ex);
throw new CoreException(new Status(ex.getStatus().getSeverity(), ex.getStatus().getPlugin(), "Cannot deserialize tasklist"));
} finally {
taskListInitialized = true;
}
}
}
示例3: resultChanged
import org.openide.util.LookupEvent; //導入依賴的package包/類
public void resultChanged(LookupEvent ev) {
synchronized (listeners) {
Collection current = allInstances();
boolean equal = lastResults != null && current != null && current.containsAll(lastResults) && lastResults.containsAll(current);
if (equal) {
// the merged list is the same, ignore...
return ;
}
lastResults = current;
}
LookupEvent ev2 = new LookupEvent(this);
LookupListener[] ls;
synchronized (listeners) {
ls = (LookupListener[])listeners.toArray(new LookupListener[listeners.size()]);
}
for (int i = 0; i < ls.length; i++) {
ls[i].resultChanged(ev2);
}
}
示例4: ComponentBreakpointActionProvider
import org.openide.util.LookupEvent; //導入依賴的package包/類
public ComponentBreakpointActionProvider() {
final Result<Node> nodeLookupResult = Utilities.actionsGlobalContext().lookupResult(Node.class);
LookupListener ll = new LookupListener() {
@Override
public void resultChanged(LookupEvent ev) {
Collection<? extends Node> nodeInstances = nodeLookupResult.allInstances();
for (Node n : nodeInstances) {
JavaComponentInfo ci = n.getLookup().lookup(JavaComponentInfo.class);
if (ci != null) {
setEnabled(ActionsManager.ACTION_TOGGLE_BREAKPOINT, true);
return ;
}
}
setEnabled(ActionsManager.ACTION_TOGGLE_BREAKPOINT, false);
}
};
nodeLookupResult.addLookupListener(ll);
ll.resultChanged(null); // To initialize
}
示例5: initGroups
import org.openide.util.LookupEvent; //導入依賴的package包/類
private void initGroups() {
synchronized( this ) {
if( null == name2group ) {
if( null == lookupRes ) {
lookupRes = initLookup();
lookupRes.addLookupListener( new LookupListener() {
public void resultChanged(LookupEvent ev) {
synchronized( TaskGroupFactory.this ) {
name2group = null;
groups = null;
}
}
});
}
int index = 0;
groups = new ArrayList<TaskGroup>( lookupRes.allInstances() );
name2group = new HashMap<String,TaskGroup>(groups.size());
for( TaskGroup tg : groups) {
name2group.put( tg.getName(), tg );
tg.setIndex( index++ );
}
}
}
}
示例6: resultChanged
import org.openide.util.LookupEvent; //導入依賴的package包/類
@Override
public void resultChanged(LookupEvent ev) {
if (TopComponent.getRegistry().getActivated() == ProjectTab.this) {
// Do not want to go into a loop.
return;
}
if (synchronizeViews) {
Collection<? extends FileObject> fos = foSelection.allInstances();
if (fos.size() == 1) {
selectNodeAsyncNoSelect(fos.iterator().next(), false);
} else {
Collection<? extends DataObject> dos = doSelection.allInstances();
if (dos.size() == 1) {
selectNodeAsyncNoSelect((dos.iterator().next()).getPrimaryFile(), false);
}
}
}
}
示例7: resultChanged
import org.openide.util.LookupEvent; //導入依賴的package包/類
public void resultChanged(LookupEvent ev) {
synchronized (lookupListener) {
descriptorRef = new WeakReference<DialogDescriptor>(null);
// #156947 - close dialog when categories change
if (dialog != null) {
Mutex.EVENT.readAccess(new Runnable() {
@Override
public void run() {
if (dialog != null) {
log.log(Level.FINE, "Options Dialog - closing dialog when categories change."); //NOI18N
dialog.setVisible(false);
dialog = null;
}
}
});
}
}
}
示例8: resultChanged
import org.openide.util.LookupEvent; //導入依賴的package包/類
@Override
final public void resultChanged(LookupEvent lookupEvent) {
boolean isNowSelected = false;
Lookup.Result selected = (Lookup.Result)lookupEvent.getSource();
for (Object selectedEntity : selected.allInstances()) {
if (agent.equals(selectedEntity)) {
isNowSelected = true;
}
}
if (isNowSelected != selectedFlag) {
selectedFlag = isNowSelected;
fireDisplayNameChange(null, null);
}
}
示例9: collectFires
import org.openide.util.LookupEvent; //導入依賴的package包/類
@Override
protected void collectFires(Collection<Object> evAndListeners) {
LookupListenerList l = this.getListeners(null, null);
if (l == null) {
return;
}
Object[] listeners = l.getListenerList();
if (listeners.length == 0) {
return;
}
LookupEvent ev = new LookupEvent(this);
AbstractLookup.notifyListeners(listeners, ev, evAndListeners);
}
示例10: getHelpSets
import org.openide.util.LookupEvent; //導入依賴的package包/類
/** Get all available help sets.
* Pay attention to {@link #helpSetsChanged} to see
* when this set will change.
* @return a collection of HelpSet
*/
protected final Collection<? extends HelpSet> getHelpSets() {
if (helpsets == null) {
Installer.log.fine("searching for instances of HelpSet...");
helpsets = Lookup.getDefault().lookupResult(HelpSet.class);
helpsets.addLookupListener(new LookupListener() {
public void resultChanged(LookupEvent ev) {
helpSetsChanged();
}
});
fireChangeEvent(); // since someone may be listening to whether they are ready
}
Collection<? extends HelpSet> c = helpsets.allInstances();
if (Installer.log.isLoggable(Level.FINE)) {
List<String> l = new ArrayList<String>(Math.min(1, c.size()));
for (HelpSet hs: c) {
l.add(hs.getTitle());
}
Installer.log.fine("listing helpsets: " + l);
}
return c;
}
示例11: resultChanged
import org.openide.util.LookupEvent; //導入依賴的package包/類
/** Invokes navigator data context change upon current nodes change or
* current navigator hints change,
* performs coalescing of fast coming changes.
*/
@Override
public void resultChanged(LookupEvent ev) {
if (!navigatorTC.getTopComponent().equals(WindowManager.getDefault().getRegistry().getActivated())
// #117089: allow node change when we are empty
|| (curNodes == null || curNodes.isEmpty())) {
Lookup globalContext = Utilities.actionsGlobalContext();
NavigatorLookupPanelsPolicy panelsPolicy = globalContext.lookup(NavigatorLookupPanelsPolicy.class);
Collection<? extends NavigatorLookupHint> lkpHints = globalContext.lookupAll(NavigatorLookupHint.class);
ActNodeSetter nodeSetter = new ActNodeSetter(panelsPolicy, lkpHints);
if (navigatorTC.allowAsyncUpdate()) {
synchronized (NODE_SETTER_LOCK) {
if (nodeSetterTask != null) {
nodeSetterTask.cancel();
}
// wait some time before propagating the change further
nodeSetterTask = RequestProcessor.getDefault().post(nodeSetter, COALESCE_TIME);
nodeSetterTask.addTaskListener(nodeSetter);
}
} else {
nodeSetter.run();
}
}
}
示例12: resultChanged
import org.openide.util.LookupEvent; //導入依賴的package包/類
public void resultChanged(LookupEvent ev) {
synchronized (CACHE) {
ArrayList<JTextComponent> toRemove = new ArrayList<JTextComponent>();
for(JTextComponent jtc : CACHE.keySet()) {
String mimeType = NbEditorUtilities.getMimeType(jtc);
if (mimeType.equals(this.mimeType)) {
toRemove.add(jtc);
}
}
CACHE.keySet().removeAll(toRemove);
}
fireChange(mimeType);
}
示例13: collectFires
import org.openide.util.LookupEvent; //導入依賴的package包/類
protected void collectFires(Collection<Object> evAndListeners) {
LookupListener[] arr;
synchronized (this) {
if (listeners == null) {
return;
}
if (listeners instanceof LookupListener) {
arr = new LookupListener[] { (LookupListener) listeners };
} else {
ArrayList<?> l = (ArrayList<?>) listeners;
arr = l.toArray(new LookupListener[l.size()]);
}
}
final LookupListener[] ll = arr;
final org.openide.util.LookupEvent newev = new org.openide.util.LookupEvent(this);
AbstractLookup.notifyListeners(ll, newev, evAndListeners);
}
示例14: defaultJavadoc
import org.openide.util.LookupEvent; //導入依賴的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);
}
示例15: defaultSources
import org.openide.util.LookupEvent; //導入依賴的package包/類
@NonNull
private List<URL> defaultSources(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 J2SEPlatformDefaultSources> res = getJ2SEPlatformDefaultSources();
if (listen) {
synchronized (this) {
if (sourcesListener == null) {
sourcesListener = new LookupListener[2];
sourcesListener[0] = new LookupListener() {
@Override
public void resultChanged(LookupEvent ev) {
sources = null;
}
};
sourcesListener[1] = WeakListeners.create(LookupListener.class, sourcesListener[0], res);
res.addLookupListener(sourcesListener[1]);
}
}
}
for (J2SEPlatformDefaultSources src : res.allInstances()) {
roots.addAll(src.getDefaultSources(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);
}