Пример #1
0
  private static void printActions(ZCView zcView) {
    System.out.println("\n\nType one of these view actions");
    if (zcView.isAddAllowed()) {
      System.out.println("Add");
    }
    if (zcView.isBulkEditAllowed()) {
      System.out.println("Edit");
    }
    if (zcView.isDeleteAllowed()) {
      System.out.println("Delete");
    }
    if (zcView.isDuplicateAllowed()) {
      System.out.println("Duplicate");
    }
    List<ZCCustomAction> customActions = zcView.getHeaderCustomActions();
    for (int i = 0; i < customActions.size(); i++) {
      ZCCustomAction zcCustomAction = customActions.get(i);
      System.out.println(zcCustomAction.getName());
    }
    String inp = getInput("");
    if (inp.equals("Add")) {

    } else if (inp.equals("Edit")) {

    } else if (inp.equals("Delete")) {
      zcView.deleteRecords(getRecordIdsInput());
      printView();
    } else if (inp.equals("Duplicate")) {
      zcView.duplicateRecords(getRecordIdsInput());
    } else {
      for (int i = 0; i < customActions.size(); i++) {
        ZCCustomAction zcCustomAction = customActions.get(i);
        if (inp.equals(zcCustomAction.getName())) {
          Long custId = zcCustomAction.getId();
          zcView.customAction(custId, getRecordIdsInput());
        }
      }
    }
  }
Пример #2
0
  private static void printRecords(ZCView zcView) {
    List<ZCFilter> filters = zcView.getFilters();
    // System.out.println(filters);

    if (zcView.isGrouped()) {
      List<ZCGroup> groups = zcView.getGroups();
      for (int i = 0; i < groups.size(); i++) {
        ZCGroup group = groups.get(i);
        System.out.println("************** " + group.getGroupHeaderValues() + " **************");
        List<ZCRecord> records = group.getGroupRecords();
        printRecords(records);
      }
    } else {
      List<ZCRecord> records = zcView.getRecords();
      printRecords(records);
    }

    if (zcView.getType().equals(ZCComponent.CALENDAR)) {
      String inp =
          getInput(
              "\n\nType 1 to load Next Month.... 2 for Previous month.... -1 to quit.... 0 to go back to "
                  + ZOHOCreator.getCurrentApplication().getAppName());
      int inpValue = -1;
      try {
        inpValue = Integer.parseInt(inp);
      } catch (Exception ee) {
      }
      if (inpValue == 1) {
        cal.add(Calendar.MONTH, 1);
      } else if (inpValue == 2) {
        cal.add(Calendar.MONTH, -1);
      } else if (inpValue == 0) {
        printCompsList();
        return;
      } else if (inpValue == -1) {
        return;
      }
      zcView.loadCalendarRecords(cal.get(Calendar.MONTH), cal.get(Calendar.YEAR));
      printRecords(zcView);
    } else {
      // System.out.println("isLastReached: " + zcView.isLastReached());
      if (!zcView.isLastReached()) {
        String inp =
            getInput(
                "\n\nType 1 to load more.... 2 for actions.... -1 to quit.... 0 to go back to "
                    + ZOHOCreator.getCurrentApplication().getAppName());
        int inpValue = -1;
        try {
          inpValue = Integer.parseInt(inp);
        } catch (Exception ee) {
        }
        if (inpValue == 1) {
          zcView.loadMore();
          printRecords(zcView);
        } else if (inpValue == 2) {
          printActions(zcView);
          //				} else if(inpValue == 3) {
          //					printRecord(zcView);
        } else if (inpValue == 0) {
          printCompsList();
          return;
        } else if (inpValue == -1) {
          return;
        }
      }
    }
  }