- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用了 netbeans 网站(由于服务器问题而处于离线状态)上的教程来创建一个读取 XML 并输出一些信息的操作。一切都很好,但该操作不允许我在某些 XML 文件上调用它,而且我没有可用的资源来帮助解决此问题。例如,当我运行该程序时,它允许我在 list 文件(甚至不是 xml,并且相应地出错)上调用操作,但不能在 .xml 文件上调用操作。以下代码可能是我从教程中更改的罪魁祸首。我认为它会使“显示 XML”消息始终启用,但它在 xml 文件上仍然被禁用。
@ActionReferences({
@ActionReference(path = "Editors/Popup", position = 1100)
})
这是我的 SSCCE(原文如此):
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.versifit.udl.xml;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.io.InputStream;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.cookies.EditorCookie;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.windows.IOProvider;
import org.openide.windows.InputOutput;
import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@ActionID(category = "Edit",
id = "com.versifit.udl.xml.ShowXMLStructureAction")
@ActionRegistration(displayName = "#CTL_ShowXMLStructureAction")
@ActionReferences({
@ActionReference(path = "Editors/Popup", position = 1100)
})
@Messages("CTL_ShowXMLStructureAction=Show Xml Structure")
public final class ShowXMLStructureAction implements ActionListener {
private final EditorCookie context;
public ShowXMLStructureAction(EditorCookie context) {
this.context = context;
}
public void actionPerformed(ActionEvent ev) {
EditorCookie editorCookie = context;
//Get the tab name from the Bundle.prop file:
String tabName = NbBundle.getMessage(ShowXMLStructureAction.class, "LBL_tabName");
InputOutput io = IOProvider.getDefault().getIO(tabName, false);
io.select(); //"XML Structure" tab is selected
try {
//Get the InputStream from the EditorCookie:
InputStream is = ((org.openide.text.CloneableEditorSupport) editorCookie).getInputStream();
//Use the NetBeans org.openide.xml.XMLUtil class to create a org.w3c.dom.Document:
//"XML Structure" tab is created in Output Window for writing the list of tags:
Document doc = XMLUtil.parse(new InputSource(is),true,true,null,null);
//Create a list of nodes, for all hte elements:
NodeList list = doc.getElementsByTagName("*");
//Iterate through the list:
for (int i = 0; i < list.getLength(); i++) {
//For each node in the list, create a org.w3c.dom.Node:
org.w3c.dom.Node mainNode = list.item(i);
//Create a map for all the attributes of the org.w3c.dom.Node:
NamedNodeMap map = mainNode.getAttributes();
//Get the name of the node:
String nodeName = mainNode.getNodeName();
//Create a StringBuilder for the Attributes of the Node:
StringBuilder attrBuilder = new StringBuilder();
//Iterate through the map of attributes:
for (int j = 0; j < map.getLength(); j++) {
//Each iteration, create a new Node:
org.w3c.dom.Node attrNode = map.item(j);
//Get the name of the current Attribute:
String attrName = attrNode.getNodeName();
//Add the current Attribute to the StringBuilder:
attrBuilder.append("*").append(attrName).append(" ");
}
//Print the element and its attributes to the Output window:
io.getOut().println("ELEMENT: " + nodeName +
" --> ATTRIBUTES: " + attrBuilder.toString());
}
//Close the InputStream:
is.close();
} catch (SAXException ex) {
Exceptions.printStackTrace(ex);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
}
最佳答案
这就是您所需要的:
@ActionReferences({ @ActionReference(路径=“编辑器/文本/xml/弹出窗口”,位置= 1100)})
关于java - Netbeans平台行动困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6523842/
在 Catalyst我正在尝试转发一个私有(private)行动来做一些工作。这是函数定义: sub get_form :Private :Args(1) { my ($self, $c, $ty
public class SimpleHTTPRequest { String envelope1="" + ""+ ""+ ""+ "ghjghj"+
我有一些返回 Promise 的 JavaScript 函数。我使用 .then 来处理从这些函数返回的数据。但是,下面的代码是否保证了顺序? result2 会在 result 之后处理吗? con
我有这样的类层次结构 public abstract class CalendarEventBase{} public class TrainingEvent : CalendarEventBase{
我有一个问题:我需要创建一个可以从 javascript 调用的网络服务(在 C# 中),该服务返回一个在(它是一个 excel)中生成的文件,并且在 javascript 中返回一个新文件,打开一个
我正在向我的 UITableViewCell 添加自定义按钮。在该按钮的操作中,我想调用 showAlert: 函数并希望在该方法中传递单元格标签。 如何在 showAlert 方法中传递参数:act
我正在尝试推送到 harbor registry 2.2。它与 ssl 一起工作,并且存储在本地安装的 NFS 共享上。我得到的错误是:未经授权访问存储库:测试/ flask ,操作:推送:未经授权访
我正在尝试推送到 harbor registry 2.2。它与 ssl 一起工作,并且存储在本地安装的 NFS 共享上。我得到的错误是:未经授权访问存储库:测试/ flask ,操作:推送:未经授权访
无论我如何尝试编写 Action 测试,这个错误都会困扰我一段时间,它给了我这个: “操作可能没有未定义的“类型”属性。您是否拼错了常量?操作:{}" 但如果我控制台记录我正在尝试测试的操作,它会打印
我是一名优秀的程序员,十分优秀!