Beispiel #1
0
 public Object getTransferData(DataFlavor flavor)
     throws UnsupportedFlavorException, IOException {
   if (!isDataFlavorSupported(flavor)) {
     return null;
   }
   String link = _linkName.getText().trim();
   PositionableLabel l;
   if (link.length() == 0) {
     // return this.deepClone();
     l = new PositionableLabel(getText(), _editor);
   } else {
     l = new LinkingLabel(getText(), _editor, link);
   }
   _decorator.getText(l);
   PositionablePopupUtil util = _decorator.getPositionablePopupUtil();
   l.setPopupUtility(util);
   //            l.setPopupUtility(_decorator.getPositionablePopupUtil().clone(l,
   // l.getTextComponent()));
   if (util.hasBackground()) { // unrotated
     l.setOpaque(true);
   }
   l.setLevel(this.getDisplayLevel());
   return l;
   //           return this.deepClone();
 }
  /**
   * Load, starting with the memoryInputIcon element, then all the value-icon pairs
   *
   * @param element Top level Element to unpack.
   * @param o an Editor as an Object
   */
  public void load(Element element, Object o) {
    // create the objects
    Editor p = (Editor) o;

    int nCol = 2;
    try {
      nCol = element.getAttribute("colWidth").getIntValue();
    } catch (org.jdom2.DataConversionException e) {
      log.error("failed to convert colWidth attribute");
    }

    MemoryInputIcon l = new MemoryInputIcon(nCol, p);

    loadTextInfo(l, element);
    String name;
    Attribute attr = element.getAttribute("memory");
    if (attr == null) {
      log.error("incorrect information for a memory location; must use memory name");
      p.loadFailed();
      return;
    } else {
      name = attr.getValue();
    }

    Memory m = jmri.InstanceManager.memoryManagerInstance().getMemory(name);

    if (m != null) {
      l.setMemory(name);
    } else {
      log.error("Memory named '" + attr.getValue() + "' not found.");
      p.loadFailed();
      return;
    }

    p.putItem(l);
    // load individual item's option settings after editor has set its global settings
    loadCommonAttributes(l, Editor.MEMORIES, element);

    javax.swing.JComponent textField = l.getTextComponent();
    jmri.jmrit.display.PositionablePopupUtil util = l.getPopupUtility();
    if (util.hasBackground()) {
      textField.setBackground(util.getBackground());
    } else {
      textField.setBackground(null);
      textField.setOpaque(false);
    }
  }