Пример #1
0
 public void putInPioche(DragDropEvent ddEvent) {
   Map<String, String> params =
       FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
   String left = params.get("class");
   String[] sClass = left.split(" ");
   String idTmp = "";
   int colTmp = -1;
   int ligneTmp = 0;
   for (String s : sClass) {
     if (StringUtils.startsWith(s, "colonne_")) {
       String c = s.replace("colonne_", "");
       colTmp = Integer.valueOf(c);
     }
     if (StringUtils.startsWith(s, "ligne_")) {
       String c = s.replace("ligne_", "");
       ligneTmp = Integer.valueOf(c);
     }
     if (StringUtils.startsWith(s, "id_")) {
       idTmp = s.replace("id_", "");
     }
   }
   if (colTmp != -1) {
     Cell c = list.get(ligneTmp).get(colTmp);
     c.setType(Cell.CELL_EMPTY);
     c.setAngle(-1);
   }
   if (idTmp.equals(Cell.CELL_MIRROR) || idTmp.equals(Cell.CELL_SPLIT)) {
     Cell c = new Cell(idTmp);
     c.setAngle(0);
     pioche.add(c);
   }
 }
Пример #2
0
  public void dropObject(DragDropEvent ddEvent) {
    Map<String, String> params =
        FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
    String ligne = getParam("ligne");
    String colonne = getParam("colonne");
    String left = params.get("class");
    String[] sClass = left.split(" ");
    int colTmp = -1;
    int ligneTmp = 0;
    int item = -1;
    String idTmp = "";
    for (String s : sClass) {
      if (StringUtils.startsWith(s, "colonne_")) {
        String c = s.replace("colonne_", "");
        colTmp = Integer.valueOf(c);
      }
      if (StringUtils.startsWith(s, "ligne_")) {
        String c = s.replace("ligne_", "");
        ligneTmp = Integer.valueOf(c);
      }
      if (StringUtils.startsWith(s, "id_")) {
        idTmp = s.replace("id_", "");
      }

      if (StringUtils.startsWith(s, "position_")) {
        String c = s.replace("position_", "");
        item = Integer.valueOf(c);
      }
    }
    int x = Integer.valueOf(ligne);
    int y = Integer.valueOf(colonne);
    String id;
    if (StringUtils.isEmpty(idTmp)) {
      id = params.get("dragId");
      id = id.replaceAll("FormContent:", "");
    } else {
      id = idTmp;
      if (item != -1) pioche.remove(item);
    }
    if (colTmp == -1) {
      Cell newCell = list.get(x).get(y);
      newCell.setType(id);
      newCell.setAngle(0);
    } else {
      Cell c = list.get(ligneTmp).get(colTmp);
      Cell newCell = list.get(x).get(y);
      newCell.setType(c.getType());
      newCell.setAngle(c.getAngle());
      c.setType(Cell.CELL_EMPTY);
      c.setAngle(-1);
    }
  }
Пример #3
0
  public void releaseObject(DragDropEvent ddEvent) {
    Map<String, String> params =
        FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
    String left = params.get("class");
    String[] sClass = left.split(" ");
    int col = 0;
    int ligne = 0;
    int item = 0;
    for (String s : sClass) {
      if (StringUtils.startsWith(s, "colonne_")) {
        String c = s.replace("colonne_", "");
        col = Integer.valueOf(c);
      }
      if (StringUtils.startsWith(s, "ligne_")) {
        String c = s.replace("ligne_", "");
        ligne = Integer.valueOf(c);
      }
      if (StringUtils.startsWith(s, "position_")) {
        String c = s.replace("position_", "");
        item = Integer.valueOf(c);
      }
    }
    if (col == 0 && ligne == 0) {
      pioche.remove(item);
    } else {
      Cell c = list.get(ligne).get(col);
      c.setType(Cell.CELL_EMPTY);
      c.setAngle(-1);
    }

    System.out.println("drop");
  }