📄 globuswsdddialogstate.java
字号:
public void addActions(int i, String target) {
Element ActionPolicy = (Element)this.xmlED.DOM.getElementsByTagName("ActionPolicy").item(0);
String str = (String)wsdd.getWSDLFiles().get(i);
String wsdlFilePath = this.globusFilePath+"\\"+str.replace('/', '\\');
Document dom = loadDocument(wsdlFilePath);
NodeList operation = dom.getElementsByTagNameNS(WSDL_NS, "operation");
Node portType = dom.getElementsByTagNameNS(WSDL_NS, "portType").item(0);
for (int j=0; j<operation.getLength(); j++) {
Element e = (Element)operation.item(j);
if (e.getParentNode() == portType) {
Element child = this.xmlED.DOM.createElement("Action");
child.setAttribute("Name", e.getAttribute("name"));
child.setAttribute("Target", target);
child = addParameters(dom, child, (Element)e.getElementsByTagNameNS(WSDL_NS, "input").item(0));
this.xmlED.addItem(child, ActionPolicy);
}
}
}
/**
* Retrieves the parameters that are either stored directly in message nodes,
* or defined elsewhere in the WSDL, but pointed from message nodes.
*
* @param dom The WSDL containing the Actions & Paramaters.
* @param child The Action Element already with Name and Target Attribute.
* @param input The Input Tag, being a child of the Port Type.
*
* @return An Element containing the full Action Element. Containing the:
* Name, Types, Arguments, Target.
*/
public Element addParameters(Document dom, Element child, Element input) {
String types = "";
String names = "";
NodeList messages = dom.getElementsByTagNameNS(WSDL_NS, "message");
for (int i=0; i<messages.getLength(); i++) {
Element e = (Element)messages.item(i);
if (input.getAttribute("name") == null || input.getAttribute("name").equals("")) {
String inputMessage = removeColon(input.getAttribute("message"));
if (e.getAttribute("name").intern().equals(inputMessage)) {
NodeList parts = e.getElementsByTagNameNS(WSDL_NS, "part");
for (int j=0; j<parts.getLength(); j++) {
Element el = (Element)parts.item(j);
if (el.getAttribute("element") != null || !el.getAttribute("element").equals("")) {
NodeList elements = dom.getElementsByTagNameNS(XMLSCHEMA_NS, "element");
for (int k=0; k<elements.getLength(); k++) {
Element elem = (Element)elements.item(k);
String elemName = removeColon(el.getAttribute("element"));
if (elem.getAttribute("name").intern().equals(elemName)) {
// if (elem.getElementsByTagNameNS(XMLSCHEMA_NS, "element").getLength() > 0) {
// NodeList sequence = elem.getElementsByTagNameNS(XMLSCHEMA_NS, "element");
// for (int z=0;z<sequence.getLength(); z++) {
// names += ((Element)sequence.item(z)).getAttribute("name") + ", ";
// String type = removeColon(((Element)sequence.item(z)).getAttribute("type"));
// types += type + ", ";
// }
// child.setAttribute("Args", names.substring(0, names.lastIndexOf(", ")));
// child.setAttribute("Type", types.substring(0, types.lastIndexOf(", ")));
// } else
if (elem.getAttribute("type").equals("")) {
if (elem.getElementsByTagNameNS(XMLSCHEMA_NS, "complexType").getLength() == 1) {
child.setAttribute("Args", "1");
child.setAttribute("Type", "complexType");
}
} else { // else if (elem.getAttribute("type") != null || !elem.getAttribute("type").equals("")) {
child.setAttribute("Args", "1");
child.setAttribute("Type", removeColon(elem.getAttribute("type")));
}
}
}
}
}
}
} else {
if (e.getAttribute("name").intern().equals(input.getAttribute("name"))) {
NodeList parts = e.getElementsByTagNameNS(WSDL_NS, "part");
for (int j=0; j<parts.getLength(); j++) {
Element el = (Element)parts.item(j);
if (el.getAttribute("element") == null ||
el.getAttribute("element").equals("")) {
names += el.getAttribute("name") + ", ";
String type = el.getAttribute("type");
int indexColon = type.indexOf(":");
if (indexColon > -1) type = type.substring(indexColon+1);
types += type + ", ";
}
}
child.setAttribute("Args", names.substring(0, names.lastIndexOf(", ")));
child.setAttribute("Type", types.substring(0, types.lastIndexOf(", ")));
}
}
}
return child;
}
/**
* Removes the colon from the string, by returning a string with the stuff
* present after the colon.
*
* @param str A string that needs to be trimmed.
* @return the String Value after the first appearance of ":"
*/
public String removeColon(String str) {
int index = str.indexOf(":");
if (index > -1) str = str.substring(index+1);
return str;
}
/**
* Loads the WSDD file in a Document variable.
* <p>
* IMPORTANT NOTE: the DocumentBuilderFactory must be set NameSpaceAware
* to obtain data well from the WSDD, since WSDD uses alot
* of NameSpaces & prefixes...
*
* @param pathName The path of the WSDD File to load.
* @return A org.w3c.dom.document containing the loaded WSDD.
*/
public Document loadDocument(String pathName) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
Document document = null;
try {
FileInputStream pathStream = new FileInputStream(pathName);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(pathStream);
} catch (FileNotFoundException fnfe) { } catch (SAXException sxe) { } catch (ParserConfigurationException pce) { } catch (IOException ioe) { } catch (SecurityException se) { }
return document;
}
/**
* Centers the dialog position on the screen.
*/
protected void centerDialog() {
Dimension screenSize = this.getToolkit().getScreenSize();
Dimension size = this.getSize();
screenSize.height = screenSize.height / 2;
screenSize.width = screenSize.width / 2;
size.height = size.height / 2;
size.width = size.width / 2;
int y = screenSize.height - size.height;
int x = screenSize.width - size.width;
this.setLocation(x, y);
}
/**
* Checks if the globus file selected is a valid folder.
*
* @return true if the globusFilePath is a valid globus directory.
*/
public boolean isGlobusDirectory() {
File share = new File(globusFilePath+"\\share");
File etc = new File(globusFilePath+"\\etc\\globus_wsrf_core");
if (share.isDirectory() && etc.isDirectory()) return true;
else return false;
}
/**
* Specifies the functionality of this component.
* <p>
* Cursor is set to notify users that something is happening.
* The progress bar is set to the maximum number it can be.
* Adds the targets.
* Cursor is set to default.
*/
public void dialogFunction() {
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
setProgressBarMaximum();
addTargets();
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
/**
* Sets the component to be enabled or not. Will Grey all the components
* that make it up when disabed.
*
* @param enabled boolean value to set.
*/
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
progressBar.setEnabled(enabled);
bottomLabel.setEnabled(enabled);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -