本文整理汇总了Java中org.openide.util.lookup.Lookups.singleton方法的典型用法代码示例。如果您正苦于以下问题:Java Lookups.singleton方法的具体用法?Java Lookups.singleton怎么用?Java Lookups.singleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.util.lookup.Lookups
的用法示例。
在下文中一共展示了Lookups.singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TreeNode
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public TreeNode(CompilationInfo info, TreePath tree, List<Node> nodes) {
super(nodes.isEmpty() ? Children.LEAF: new NodeChilren(nodes), Lookups.singleton(tree.getLeaf()));
this.tree = tree;
this.info = info;
this.synthetic = info.getTreeUtilities().isSynthetic(tree);
int start = (int) info.getTrees().getSourcePositions().getStartPosition(tree.getCompilationUnit(), tree.getLeaf());
int end = (int) info.getTrees().getSourcePositions().getEndPosition(tree.getCompilationUnit(), tree.getLeaf());
String text;
if (start >= 0 && end >= 0 && end > start) {
text = info.getText().substring(start, end);
} else {
text = tree.getLeaf().toString();
}
setDisplayName(tree.getLeaf().getKind().toString() + ":" + text); //NOI18N
setIconBaseWithExtension("org/netbeans/modules/java/debug/resources/tree.png"); //NOI18N
}
示例2: setUp
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
clearWorkDir();
DerbyDatabasesTest.SampleDatabaseLocator sdl = new DerbyDatabasesTest.SampleDatabaseLocator();
sampleDBLookup = new ProxyLookup(Lookup.getDefault(), Lookups.singleton(sdl));
Lookups.executeWith(sampleDBLookup, new Runnable() {
@Override
public void run() {
// Force initialization of JDBCDrivers
JDBCDriverManager jdm = JDBCDriverManager.getDefault();
JDBCDriver[] registeredDrivers = jdm.getDrivers();
}
});
}
示例3: node
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public Node node(final SourceGroup key) {
try {
Node nodeDelegate = DataObject.find(key.getRootFolder()).getNodeDelegate();
return new FilterNode(nodeDelegate,
null, new ProxyLookup(nodeDelegate.getLookup(), Lookups.singleton(new PathFinder(key)))) {
@Override
public String getName() {
return key.getName();
}
@Override
public String getDisplayName() {
return key.getDisplayName();
}
};
} catch (DataObjectNotFoundException ex) {
throw new AssertionError(ex);
}
}
示例4: testCreateMenu
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public void testCreateMenu() throws Exception {
TestFS fs = new TestFS();
FileObject fo = fs.getRoot();
// create menu for a lookup containg a node
Lookup lkp = Lookups.singleton(DataFolder.findFolder(fo).getNodeDelegate());
Method m = FileSystemAction.class.getDeclaredMethod("createMenu",
Boolean.TYPE, Lookup.class);
m.setAccessible(true);
JMenuItem[] item = (JMenuItem[])m.invoke(null, true, lkp);
assertTrue(item.length > 0);
// create menu for a lookup containg a DataObject
lkp = Lookups.singleton(DataFolder.findFolder(fo));
item = (JMenuItem[])m.invoke(null, true, lkp);
assertTrue(item.length > 0);
}
示例5: IntroduceLocalExtensionRefactoring
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
/**
* Create a new instance of IntroduceLocalExtensionRefactoring.
* Equality will be {@code DELEGATE}.
*
* @param handle Path to the type to refactor.
*/
public IntroduceLocalExtensionRefactoring(@NonNull TreePathHandle handle) {
super(Lookups.singleton(handle));
this.equality = Equality.DELEGATE;
this.wrap = false;
this.replace = false;
}
示例6: getEnvironment
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public Lookup getEnvironment(DataObject obj) {
if (obj == ComplexPair.obj) {
howManyTimesWeHandledRequestForEnvironmentOfOurObject++;
return Lookups.singleton(this);
} else {
return null;
}
}
示例7: DefaultEMLookup
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
/** Creates the lookup.
* @param tc component to work on
* @param map action map to add to the lookup
*/
public DefaultEMLookup(ExplorerManager tc, javax.swing.ActionMap map) {
super();
this.tc = tc;
this.listener = WeakListeners.create(LookupListener.class, this, null);
this.actionMap = Lookups.singleton(map);
tc.addPropertyChangeListener(WeakListeners.propertyChange(this, tc));
updateLookups(tc.getSelectedNodes());
}
示例8: LibraryNode
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
LibraryNode (@NonNull final Library lib) {
super(Children.LEAF, Lookups.singleton(lib));
setName(lib.getName());
setDisplayName(lib.getDisplayName());
setShortDescription(lib.getDescription());
setIconBaseWithExtension("org/netbeans/modules/project/libraries/resources/libraries.gif"); // NOI18N
}
示例9: HudsonInstanceNode
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public HudsonInstanceNode(final HudsonInstance instance) {
super(new InstanceNodeChildren(instance), Lookups.singleton(instance));
setName(instance.getUrl());
setDisplayName(instance.getName());
setShortDescription(instance.getUrl());
setIconBaseWithExtension(ICON_BASE);
setValue("customDelete", true); // NOI18N
this.instance = instance;
instance.addHudsonChangeListener(new HudsonChangeListener() {
@Override public void stateChanged() {
refreshState();
}
@Override public void contentChanged() {
refreshContent();
}
});
instance.prefs().addPreferenceChangeListener(new PreferenceChangeListener() {
@Override public void preferenceChange(PreferenceChangeEvent evt) {
refreshContent();
}
});
// Refresh
refreshState();
refreshContent();
}
示例10: SimpleObject
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public SimpleObject(SimpleLoader l,
FileObject fo,
boolean useSpecialEncoding)
throws DataObjectExistsException {
super(fo, l);
lookup = useSpecialEncoding
? Lookups.fixed(this, new TestEncoding())
: Lookups.singleton(this);
}
示例11: getImpls
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
@NonNull
private static Iterable<? extends ContextProvider> getImpls() {
Lookup.Result<ContextProvider> res = impls.get();
if (res == null) {
final Lookup lkp = new ProxyLookup(
Lookup.getDefault(),
Lookups.singleton(new DefaultContextProvider()));
res = lkp.lookupResult(ContextProvider.class);
if (!impls.compareAndSet(null, res)) {
res = impls.get();
}
}
return res.allInstances();
}
示例12: HudsonJobNode
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public HudsonJobNode(HudsonJob job) {
super(makeChildren(job), Lookups.singleton(job));
setName(job.getName());
setHudsonJob(job);
setWatchedListener();
}
示例13: InstantRefactoringUIImpl
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
private InstantRefactoringUIImpl(Set<MutablePositionRegion> usages, Set<MutablePositionRegion> comments, String oldName, DocTreePathHandle dtph) throws BadLocationException {
this(usages, comments, oldName, new RenameRefactoring(Lookups.singleton(dtph)), null, dtph);
}
示例14: YearNode
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
public YearNode(int year) {
super(Children.create(new MonthNodeFactory(year), true), Lookups.singleton(year));
setName("" + year);
setDisplayName("" + year);
}
示例15: createCloneableEditor
import org.openide.util.lookup.Lookups; //导入方法依赖的package包/类
@Override
public CloneableEditor createCloneableEditor() {
return new SQLCloneableEditor(Lookups.singleton(this));
}