Beispiel #1
0
  public void renderMap() {
    Entity entity;
    PaintListener playerIcon = null;

    if (dp == null) return;

    setBoundaryScalers();

    clearMap(false);

    playerZPos = dp.getEntity(dp.playerObjectID).posZAxis;

    for (int i = dp.entityKeys.length - 1; i >= 0; i--) {
      entity = dp.entityList.get(dp.entityKeys[i]);
      if (entity.entityName.equals("")) {
        continue;
      }

      if (isEntityIgnorable(entity.entityType)) {
        // But don't skip them if they matches the custom text.,
        java.util.regex.Pattern p = java.util.regex.Pattern.compile(customString.toLowerCase());
        Matcher m = p.matcher(entity.entityName.toLowerCase());
        if (!useCustomString || customString.equals("")) {
          continue;
        } else if (!m.find()) {
          continue;
        }
      }

      if (entity.entityType != Entity.TYPE_PLAYER) {
        mapShell.addPaintListener(paintGraph(entity));
      } else {
        playerIcon = paintGraph(entity);
      }
    }
    if (playerIcon != null) {
      mapShell.addPaintListener(playerIcon);
    }

    mapShell.redraw();
  }
  // --------------------------------------------------------------------------------
  private void updateDocument() {
    int typeIndex = typeCombo.getSelectionIndex();
    if (typeIndex == -1) {
      return;
    }
    String value = valueText.getText();
    Object newValue = null;
    String updateStr = null;
    switch (typeIndex) {
      case 0: // Double
        newValue = new Double(value);
        break;
      case 1: // Integer
        newValue = new Integer(value);
        break;
      case 2: // Long
        newValue = new Long(value);
        break;
      case 3: // String
        newValue = value;
        break;
      case 4: // List
        newValue = dataManager.getDB().eval(value, null);
        break;
      case 5: // Map
        newValue = dataManager.getDB().eval(value, null);
        break;
      case 6: // Date
        try {
          SimpleDateFormat df = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy", Locale.ENGLISH);
          // df.set
          newValue = df.parse(value);
        } catch (Exception e) {
          // e.printStackTrace();
          return;
        }
        break;
      case 7: // ObjectId
        newValue = new ObjectId(value);
        break;
      case 8: // Code
        newValue = new Code(value);
        break;
      case 9: // Binary not implemented
        break;
      case 10: // Boolean
        newValue = new Boolean(value);
        break;
      case 11: // null
        newValue = null;
        break;
      case 12: // Regex
        newValue = java.util.regex.Pattern.compile(value + "");
        break;
      case 13: // Symbol
        // newValue = new Symbol( value );
        break;
      case 14: // Code with scope
        // newValue = new CodeWScope( value, new BasicDBObject() );
        break;
      case 15: // Timestamp
        break;
      case 16: // Minkey not supported yet
        break;
      case 17: // Maxkey not supported yet
        break;
    }

    dataManager.updateDocument(_id, editingFieldName, newValue);
  }
  // --------------------------------------------------------------------------------
  private void verifyData() {
    int typeIndex = typeCombo.getSelectionIndex();
    if (typeIndex == -1) {
      return;
    }
    String value = valueText.getText();
    boolean verified = false;
    switch (typeIndex) {
      case 0: // Double
        try {
          Double.parseDouble(value);
          verified = true;
        } catch (Exception e) {
        }
        break;
      case 1: // Integer
        try {
          Integer.parseInt(value);
          verified = true;
        } catch (Exception e) {
        }
        break;
      case 2: // Long
        try {
          Long.parseLong(value);
          verified = true;
        } catch (Exception e) {
        }
        break;
      case 3: // String
        verified = true;
        break;
      case 4: // List
        try {
          Object o = dataManager.getDB().eval(value, null);
          if (o instanceof BasicDBList) {
            verified = true;
          }
        } catch (Exception e) {
        }
        break;
      case 5: // Map
        try {
          Object o = dataManager.getDB().eval(value, null);
          if (o instanceof BasicDBObject) {
            verified = true;
          }
        } catch (Exception e) {
        }
        break;
      case 6: // Date
        try {
          DateFormat df = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy", Locale.ENGLISH);
          df.parse(value);
          verified = true;
        } catch (Exception e) {
          // e.printStackTrace();
        }
        break;
      case 7: // ObjectId
        try {
          new ObjectId(value);
          verified = true;
        } catch (Exception e) {
        }
        break;
      case 8: // Code
        verified = true;
        break;
      case 9: // Binary always false
        break;
      case 10: // Boolean
        if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) {
          verified = true;
        }
        break;
      case 11: // null
        if (value.equalsIgnoreCase("null")) {
          verified = true;
        }
        break;
      case 12: // Regex
        try {
          java.util.regex.Pattern.compile(value);
          verified = true;
        } catch (Exception e) {
        }
        break;
      case 13: // Symbol not supported yet
        break;
      case 14: // Code with scope not supported yet
        break;
      case 15: // Timestamp not supported yet
        break;
      case 16: // Minkey not supported yet
        break;
      case 17: // Maxkey not supported yet
        break;
    }

    updateButton.setEnabled(verified);
  }