author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 20 Jun 2009 16:06:19 +0200 | |
changeset 336 | 219810ff3c72 |
parent 252 | 763bf709a318 |
permissions | -rw-r--r-- |
jtulach@229 | 1 |
package org.apidesign.anagram.app.lookup; |
jtulach@229 | 2 |
|
jtulach@229 | 3 |
import org.apidesign.anagram.api.Scrambler; |
jtulach@229 | 4 |
import org.apidesign.anagram.api.WordLibrary; |
jtulach@229 | 5 |
import org.apidesign.anagram.gui.Anagrams; |
jtulach@229 | 6 |
import org.openide.util.Lookup; |
jtulach@229 | 7 |
|
jtulach@246 | 8 |
// BEGIN: anagram.lookup.Anagrams |
jtulach@252 | 9 |
import org.openide.util.LookupEvent; |
jtulach@252 | 10 |
import org.openide.util.LookupListener; |
jtulach@229 | 11 |
class AnagramsWithLookup extends Anagrams { |
jtulach@229 | 12 |
|
jtulach@229 | 13 |
public AnagramsWithLookup() { |
jtulach@229 | 14 |
} |
jtulach@229 | 15 |
|
jtulach@229 | 16 |
@Override |
jtulach@229 | 17 |
protected WordLibrary getWordLibrary() { |
jtulach@229 | 18 |
return Lookup.getDefault().lookup(WordLibrary.class); |
jtulach@229 | 19 |
} |
jtulach@229 | 20 |
|
jtulach@229 | 21 |
@Override |
jtulach@229 | 22 |
protected Scrambler getScrambler() { |
jtulach@229 | 23 |
return Lookup.getDefault().lookup(Scrambler.class); |
jtulach@229 | 24 |
} |
jtulach@252 | 25 |
// FINISH: anagram.lookup.Anagrams |
jtulach@252 | 26 |
|
jtulach@252 | 27 |
private Lookup.Result<Scrambler> scramblers = Lookup.getDefault().lookupResult(Scrambler.class); |
jtulach@254 | 28 |
// BEGIN: anagram.lookup.Listeners |
jtulach@252 | 29 |
private Lookup.Result<WordLibrary> libraries |
jtulach@252 | 30 |
= Lookup.getDefault().lookupResult(WordLibrary.class); |
jtulach@252 | 31 |
private LookupListener listener = new LookupListener() { |
jtulach@252 | 32 |
public void resultChanged(LookupEvent ev) { |
jtulach@252 | 33 |
initWord(); |
jtulach@252 | 34 |
} |
jtulach@252 | 35 |
}; |
jtulach@252 | 36 |
{ |
jtulach@252 | 37 |
libraries.addLookupListener(listener); |
jtulach@254 | 38 |
// FINISH: anagram.lookup.Listeners |
jtulach@252 | 39 |
|
jtulach@252 | 40 |
scramblers.addLookupListener(listener); |
jtulach@252 | 41 |
// initialize the results for listening |
jtulach@252 | 42 |
libraries.allItems(); |
jtulach@252 | 43 |
scramblers.allItems(); |
jtulach@252 | 44 |
} |
jtulach@229 | 45 |
} |