本文整理匯總了Java中org.openide.loaders.DataObject.getNodeDelegate方法的典型用法代碼示例。如果您正苦於以下問題:Java DataObject.getNodeDelegate方法的具體用法?Java DataObject.getNodeDelegate怎麽用?Java DataObject.getNodeDelegate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.loaders.DataObject
的用法示例。
在下文中一共展示了DataObject.getNodeDelegate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPopupPresenter
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
public JMenuItem getPopupPresenter() {
Lookup l = Utilities.actionsGlobalContext();
Collection<? extends MatchingObject> matchingObjects
= l.lookupAll(MatchingObject.class);
LinkedHashSet<Action> commonActions = new LinkedHashSet<Action>();
boolean first = true;
for (MatchingObject mo : matchingObjects) {
DataObject dob = mo.getDataObject();
if (dob != null) {
Node nodeDelegate = dob.getNodeDelegate();
Collection<Action> dobActions = Arrays.asList(
nodeDelegate.getActions(false));
if (first) {
commonActions.addAll(dobActions);
first = false;
} else {
commonActions.retainAll(dobActions);
}
}
}
return actionsToMenu(commonActions, l);
}
示例2: createNode
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
public Node createNode() {
// TODO there can be more manifests
AndroidManifestSource ams = p.getLookup().lookup(AndroidManifestSource.class);
FileObject manifestFO = ams != null ? ams.get() : null;
if (manifestFO != null) {
try {
DataObject dobj = DataObject.find(manifestFO);
return new AndroidResourceNode(dobj.getNodeDelegate(), p, AndroidConstants.ANDROID_MANIFEST_XML);
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
return null;
}
示例3: testRenameAction
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
public void testRenameAction() throws InterruptedException, InvocationTargetException, IOException {
DataObject testdo = DataObject.find(f);
final Node node = testdo.getNodeDelegate();
InstanceContent ic = new InstanceContent();
Lookup lookup = new AbstractLookup(ic);
ic.add(node);
final Action rename = RefactoringActionsFactory.renameAction().createContextAwareInstance(lookup);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (rename.isEnabled()) {
rename.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
if (!((RenameRefactoring) DD.rui.getRefactoring()).getRefactoringSource().lookup(FileObject.class).equals(f))
fail("Rename dialog was opened with wrong data");
} else {
fail("Action is not enabled.");
}
}
});
}
示例4: ShortcutAction
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/** Create a new presenter.
* @param obj XML file describing it
*/
public ShortcutAction(DataObject obj, String helpID, boolean showmaster) {
this.obj = obj;
this.helpID = helpID;
this.showmaster = showmaster;
putValue("noIconInMenu", true); // NOI18N
Installer.log.log(Level.FINE, "new ShortcutAction: {0} {1} showmaster={2}", new Object[] {obj, helpID, showmaster});
updateText();
updateIcon();
updateEnabled();
if (obj.isValid()) {
Node n = obj.getNodeDelegate();
n.addNodeListener(org.openide.nodes.NodeOp.weakNodeListener (this, n));
}
Help h = findHelp();
if (h != null) {
h.addChangeListener(WeakListeners.change(this, h));
}
}
示例5: updateDataObject
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/**
* Update data object. Can be called when a module is enabled and new data
* loader produces new data object.
*/
public void updateDataObject(DataObject updatedDataObject) {
FileObject updatedPF = updatedDataObject.getPrimaryFile();
if (dataObject == null
|| dataObject.getPrimaryFile().equals(updatedPF)) {
if (updatedPF.isValid()) {
this.invalidityStatus = null;
if (fileListener == null) {
this.fileListener = new FileListener();
updatedPF.addFileChangeListener(fileListener);
} else if (updatedPF != dataObject.getPrimaryFile()) {
dataObject.getPrimaryFile().removeFileChangeListener(
fileListener);
updatedPF.addFileChangeListener(fileListener);
}
this.dataObject = updatedDataObject;
this.nodeDelegate = updatedDataObject.getNodeDelegate();
this.valid = true;
for (TextDetail td : textDetails) {
td.updateDataObject(updatedDataObject);
}
}
} else {
throw new IllegalArgumentException(
"Expected data object for the same file"); //NOI18N
}
}
示例6: testCreateNodeForInvalidDataObject
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/**
* Test for bug 217984.
*/
public void testCreateNodeForInvalidDataObject() throws IOException {
ResultModel rm = SearchTestUtils.createResultModelWithOneMatch();
MatchingObject mo = rm.getMatchingObjects().get(0);
DataObject dob = mo.getDataObject();
FileObject fob = mo.getFileObject();
Node original = dob.getNodeDelegate();
fob.delete();
// No exception should be thrown from the constructor.
Node n = new MatchingObjectNode(original, Children.LEAF, mo, false);
assertEquals("test.txt", n.getDisplayName());
}
示例7: close
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
protected boolean close(boolean ask) {
boolean closed = super.close(ask);
DataObject dobj = getDataObject();
if(closed && dobj.isValid()) {
//set the original property sets
HtmlDataNode nodeDelegate = (HtmlDataNode)dobj.getNodeDelegate();
nodeDelegate.setPropertySets(null);
}
return closed;
}
示例8: prepareTemplates
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
public static List<TemplateItem> prepareTemplates(@NullAllowed Project project, @NonNull Lookup lookup) {
// check the action context for recommmended/privileged templates..
PrivilegedTemplates privs = lookup.lookup(PrivilegedTemplates.class);
final List<TemplateItem> items = new ArrayList<TemplateItem>();
for (DataObject template : OpenProjectList.getDefault().getTemplatesLRU(project, privs)) {
Node delegate = template.getNodeDelegate();
items.add(new TemplateItem(template, delegate.getDisplayName(), ImageUtilities.image2Icon(delegate.getIcon(BeanInfo.ICON_COLOR_16x16))));
}
return items;
}
示例9: createNodes
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
protected Node[] createNodes(DataObject dobj) {
if (dobj.isTemplate()) {
Node templateNode = new FilterNode(dobj.getNodeDelegate(), Children.LEAF);
if( null == filterText || templateNode.getDisplayName().toLowerCase().contains( filterText.toLowerCase() ) )
return new Node[] { templateNode };
}
return new Node[0];
}
示例10: getDisplayName
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
public String getDisplayName() {
String retValue = null;
DataFolder folder = (DataFolder)getCookie( DataFolder.class );
if( null != folder ) {
FileObject fob = folder.getPrimaryFile();
Object catName = fob.getAttribute( CAT_NAME );
if (catName instanceof String)
retValue = catName.toString();
}
if( null == retValue ) {
retValue = super.getDisplayName();
}
// XXX poor impl; should not depend on org.openide.loaders.Bundle#FMT_shadowName:
if( null != retValue && retValue.indexOf("\u2192") > 0 ) {
DataShadow shadow = (DataShadow)getCookie( DataShadow.class );
if( null != shadow ) {
DataObject dobj = shadow.getOriginal();
if( null != dobj ) {
Node origNode = dobj.getNodeDelegate();
if( null != origNode && null != origNode.getDisplayName() ) {
retValue = origNode.getDisplayName();
}
}
}
}
return retValue;
}
示例11: getCategoryNode
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
protected Node getCategoryNode( String catName ) throws DataObjectNotFoundException {
FileObject fo = getCategoryFile( catName );
DataObject dobj = DataObject.find( fo );
if( null == dobj ) {
fail( "Category data object '" + catName + "' not found." );
}
return dobj.getNodeDelegate();
}
示例12: getItemNode
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
protected Node getItemNode( String catName, String itemName ) throws DataObjectNotFoundException {
FileObject fo = getItemFile( catName, itemName );
DataObject dobj = DataObject.find( fo );
if( null == dobj ) {
fail( "Item data object '" + itemName + "' not found." );
}
return dobj.getNodeDelegate();
}
示例13: getIcon
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
public Icon getIcon() {
try {
DataObject d = DataObject.find(file);
Node n = d.getNodeDelegate();
return ImageUtilities.image2Icon(n.getIcon(BeanInfo.ICON_COLOR_16x16));
} catch (DataObjectNotFoundException ex) {
LOG.log(Level.FINE, null, ex);
return null;
}
}
示例14: testDisplayName
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
public void testDisplayName() throws Exception {
String res = "Settings/org-netbeans-modules-settings-convertors-testDisplayName.settings";
FileObject fo = FileUtil.getConfigFile(res);
assertNotNull(res, fo);
assertNull("name", fo.getAttribute("name"));
DataObject dobj = DataObject.find (fo);
Node n = dobj.getNodeDelegate();
assertNotNull(n);
assertEquals("I18N", n.getDisplayName());
// property sets have to be initialized otherwise the change name would be
// propagated to the node after some delay (~2s)
Object garbage = n.getPropertySets();
InstanceCookie ic = (InstanceCookie) dobj.getCookie(InstanceCookie.class);
assertNotNull (dobj + " does not contain instance cookie", ic);
FooSetting foo = (FooSetting) ic.instanceCreate();
String newName = "newName";
foo.setName(newName);
assertEquals(n.toString(), newName, n.getDisplayName());
newName = "newNameViaNode";
n.setName(newName);
assertEquals(n.toString(), newName, n.getDisplayName());
assertEquals(n.toString(), newName, foo.getName());
}
示例15: refreshPlatforms
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
private void refreshPlatforms() {
platformsList.clear();
FileObject storage = FileUtil.getConfigFile(STORAGE);
if (storage != null) {
java.util.Map<String, PlatformCategoriesDescriptor> categories = new HashMap<String, PlatformCategoriesDescriptor>();
for (FileObject child : storage.getChildren()) {
try {
final DataObject dobj = DataObject.find(child);
Node node = dobj.getNodeDelegate();
AndroidSdk platform = node.getLookup().lookup(AndroidSdk.class);
if (platform != null) {
platformsList.add(platform);
final String platformType = "Android";
final String platformTypeDisplayName = "Android";
PlatformCategoriesDescriptor platforms = categories.get(platformType);
if (platforms == null) {
platforms = new PlatformCategoriesDescriptor(platformTypeDisplayName);
categories.put(platformType, platforms);
}
platforms.add(node);
} else {
LOG.log(Level.WARNING, "Platform node for : {0} has no platform in its lookup.", node.getDisplayName()); //NOI18N
}
} catch (DataObjectNotFoundException e) {
Exceptions.printStackTrace(e);
}
}
List<PlatformCategoriesDescriptor> keys = new ArrayList<SdksCustomizer.PlatformCategoriesDescriptor>(categories.values());
Collections.sort(keys);
setKeys(keys);
}
}