コード例 #1
0
 @Override
 protected void updateItem(boolean accept, Object... params) {
   String function = param(null, 0, params);
   boolean refresh = function == null;
   if (refresh) function = getFunction();
   Element element = select(function);
   if (element != null) {
     String body = textArea.getText();
     if (accept) {
       NodeList nodes = evaluateXPath(element, "./BODY/text()");
       if (nodes != null && nodes.getLength() > 0) {
         Node node = nodes.item(0);
         CDATASection cdata = ProfileManager.transports.createCDATASection(body);
         node.getParentNode().replaceChild(cdata, node);
         updateModel(refresh, true, true);
       }
     } else if (refresh) setFunction(function);
   }
 }
コード例 #2
0
 @Override
 protected boolean addItem(boolean refresh, Object function) {
   if (ProfileManager.transportsLoaded()) {
     String body = textArea.getText();
     if (notNullOrEmpty(body)) {
       Element element = ProfileManager.transports.createElement("FUNCTION");
       element.setAttribute("name", stringValueOf(function));
       if (notNullOrEmpty(profile)) element.setAttribute("profile", profile);
       Element el = ProfileManager.transports.createElement("BODY");
       CDATASection cdata = ProfileManager.transports.createCDATASection(body);
       el.appendChild(cdata);
       element.appendChild(el);
       select().appendChild(element);
       updateModel(true, true, true, function);
       return true;
     }
   }
   return false;
 }