protected void build() {
   setTitle(tr("Conflicts in pasted tags"));
   allPrimitivesResolver = new TagConflictResolver();
   resolvers = new HashMap<OsmPrimitiveType, TagConflictResolver>();
   for (OsmPrimitiveType type : OsmPrimitiveType.values()) {
     resolvers.put(type, new TagConflictResolver());
     resolvers.get(type).getModel().addPropertyChangeListener(this);
   }
   tpResolvers = new JTabbedPane();
   getContentPane().setLayout(new GridBagLayout());
   mode = null;
   GridBagConstraints gc = new GridBagConstraints();
   gc.gridx = 0;
   gc.gridy = 0;
   gc.fill = GridBagConstraints.HORIZONTAL;
   gc.weightx = 1.0;
   gc.weighty = 0.0;
   getContentPane().add(buildSourceAndTargetInfoPanel(), gc);
   gc.gridx = 0;
   gc.gridy = 1;
   gc.fill = GridBagConstraints.BOTH;
   gc.weightx = 1.0;
   gc.weighty = 1.0;
   getContentPane().add(pnlTagResolver = new JPanel(), gc);
   gc.gridx = 0;
   gc.gridy = 2;
   gc.fill = GridBagConstraints.HORIZONTAL;
   gc.weightx = 1.0;
   gc.weighty = 0.0;
   getContentPane().add(buildButtonPanel(), gc);
 }
 protected final void build() {
   setTitle(tr("Conflicts in pasted tags"));
   for (OsmPrimitiveType type : OsmPrimitiveType.dataValues()) {
     resolvers.put(type, new TagConflictResolver());
     resolvers.get(type).getModel().addPropertyChangeListener(this);
   }
   getContentPane().setLayout(new GridBagLayout());
   mode = null;
   GridBagConstraints gc = new GridBagConstraints();
   gc.gridx = 0;
   gc.gridy = 0;
   gc.fill = GridBagConstraints.HORIZONTAL;
   gc.weightx = 1.0;
   gc.weighty = 0.0;
   getContentPane().add(buildSourceAndTargetInfoPanel(), gc);
   gc.gridx = 0;
   gc.gridy = 1;
   gc.fill = GridBagConstraints.BOTH;
   gc.weightx = 1.0;
   gc.weighty = 1.0;
   getContentPane().add(pnlTagResolver, gc);
   gc.gridx = 0;
   gc.gridy = 2;
   gc.fill = GridBagConstraints.HORIZONTAL;
   gc.weightx = 1.0;
   gc.weighty = 0.0;
   getContentPane().add(buildButtonPanel(), gc);
   InputMapUtils.addEscapeAction(getRootPane(), new CancelAction());
 }
Exemple #3
0
 private Set<OsmPrimitiveType> getTypesToDelete() {
   Set<OsmPrimitiveType> typesToDelete = EnumSet.noneOf(OsmPrimitiveType.class);
   for (OsmPrimitive osm : toDelete) {
     typesToDelete.add(OsmPrimitiveType.from(osm));
   }
   return typesToDelete;
 }
Exemple #4
0
 @Override
 public String getDescriptionText() {
   String msg;
   switch (OsmPrimitiveType.from(osm)) {
     case NODE:
       msg = marktr("Add node {0}");
       break;
     case WAY:
       msg = marktr("Add way {0}");
       break;
     case RELATION:
       msg = marktr("Add relation {0}");
       break;
     default: /* should not happen */
       msg = "";
       break;
   }
   return tr(msg, osm.getDisplayName(DefaultNameFormatter.getInstance()));
 }
Exemple #5
0
  @Override
  public String getDescriptionText() {
    if (toDelete.size() == 1) {
      OsmPrimitive primitive = toDelete.iterator().next();
      String msg = "";
      switch (OsmPrimitiveType.from(primitive)) {
        case NODE:
          msg = marktr("Delete node {0}");
          break;
        case WAY:
          msg = marktr("Delete way {0}");
          break;
        case RELATION:
          msg = marktr("Delete relation {0}");
          break;
      }

      return tr(msg, primitive.getDisplayName(DefaultNameFormatter.getInstance()));
    } else {
      Set<OsmPrimitiveType> typesToDelete = getTypesToDelete();
      String msg = "";
      if (typesToDelete.size() > 1) {
        msg = trn("Delete {0} object", "Delete {0} objects", toDelete.size(), toDelete.size());
      } else {
        OsmPrimitiveType t = typesToDelete.iterator().next();
        switch (t) {
          case NODE:
            msg = trn("Delete {0} node", "Delete {0} nodes", toDelete.size(), toDelete.size());
            break;
          case WAY:
            msg = trn("Delete {0} way", "Delete {0} ways", toDelete.size(), toDelete.size());
            break;
          case RELATION:
            msg =
                trn(
                    "Delete {0} relation",
                    "Delete {0} relations", toDelete.size(), toDelete.size());
            break;
        }
      }
      return msg;
    }
  }
Exemple #6
0
  private RelationMemberData parseRelationMember(Relation r) throws XMLStreamException {
    String role = null;
    OsmPrimitiveType type = null;
    long id = 0;
    String value = parser.getAttributeValue(null, "ref");
    if (value == null) {
      throwException(tr("Missing attribute ''ref'' on member in relation {0}.", r.getUniqueId()));
    }
    try {
      id = Long.parseLong(value);
    } catch (NumberFormatException e) {
      throwException(
          tr(
              "Illegal value for attribute ''ref'' on member in relation {0}. Got {1}",
              Long.toString(r.getUniqueId()), value));
    }
    value = parser.getAttributeValue(null, "type");
    if (value == null) {
      throwException(
          tr(
              "Missing attribute ''type'' on member {0} in relation {1}.",
              Long.toString(id), Long.toString(r.getUniqueId())));
    }
    try {
      type = OsmPrimitiveType.fromApiTypeName(value);
    } catch (IllegalArgumentException e) {
      throwException(
          tr(
              "Illegal value for attribute ''type'' on member {0} in relation {1}. Got {2}.",
              Long.toString(id), Long.toString(r.getUniqueId()), value));
    }
    value = parser.getAttributeValue(null, "role");
    role = value;

    if (id == 0) {
      throwException(tr("Incomplete <member> specification with ref=0"));
    }
    jumpToEnd();
    return new RelationMemberData(role, type, id);
  }
 /** Constructs a new {@code OsmPrimitiveTypesComboBox}. */
 public OsmPrimitiveTypesComboBox() {
   super(OsmPrimitiveType.dataValues().toArray());
 }
Exemple #8
0
 @Override
 public int hashCode() {
   return role.hashCode() + (int) rel_id + tags.hashCode() + type.hashCode() + coor.hashCode();
 }