コード例 #1
0
 @Override
 public void mouseClicked(MouseEvent me) {
   Element el = doc.getCharacterElement(viewToModel(me.getPoint()));
   if (el == null) return;
   AttributeSet as = el.getAttributes();
   if (as.isDefined("ip")) {
     String ip = (String) as.getAttribute("ip");
     ScriptException se = (ScriptException) as.getAttribute("exception");
     Node node = net.getAtIP(ip);
     if (node == null) {
       Utility.displayError("Error", "Computer does not exist");
       return;
     }
     String errorString =
         "--ERROR--\n"
             + "Error at line number "
             + se.getLineNumber()
             + " and column number "
             + se.getColumnNumber()
             + "\n"
             + se.getMessage();
     new ScriptDialog(
             parentFrame,
             str -> {
               if (str != null) {
                 node.setScript(str);
               }
             },
             node.getScript(),
             errorString)
         .setVisible(true);
   }
 }
コード例 #2
0
 /** Is this image within a link? */
 boolean isLink() {
   // ! It would be nice to cache this but in an editor it can change
   // See if I have an HREF attribute courtesy of the enclosing A tag:
   AttributeSet anchorAttr = (AttributeSet) fElement.getAttributes().getAttribute(HTML.Tag.A);
   if (anchorAttr != null) {
     return anchorAttr.isDefined(HTML.Attribute.HREF);
   }
   return false;
 }
コード例 #3
0
 @Override
 public void mouseMoved(MouseEvent me) {
   Element el = doc.getCharacterElement(viewToModel(me.getPoint()));
   if (el == null) return;
   AttributeSet as = el.getAttributes();
   if (as.isDefined("ip")) {
     setCursor(handCursor);
   } else {
     setCursor(defaultCursor);
   }
 }
コード例 #4
0
 /** Look up an integer-valued attribute. <b>Not</b> recursive. */
 private int getIntAttr(HTML.Attribute name, int deflt) {
   AttributeSet attr = fElement.getAttributes();
   if (attr.isDefined(name)) { // does not check parents!
     int i;
     String val = (String) attr.getAttribute(name);
     if (val == null) i = deflt;
     else
       try {
         i = Math.max(0, Integer.parseInt(val));
       } catch (NumberFormatException x) {
         i = deflt;
       }
     return i;
   } else return deflt;
 }