Exemplo n.º 1
0
  /*
   * 刷新topNList
   */
  private void refreshiControl() {
    ChartUtil.clearListbox(topNList);
    TopNListitemModel model = new TopNListitemModel(topNReport);
    //		ChartUtil.makelistData(topNList, model, model);

    try {
      for (TopNBean m : model.getTopNData()) {
        Image image = null;
        if (m.getDeny().equals("允许")) {
          image = new Image("/main/images/button/ico/enable_bt.gif");
        } else {
          image = new Image("/main/images/button/ico/disable_bt.gif");
        }
        Listitem item =
            ChartUtil.addRow(
                topNList,
                m,
                m.getTitle(),
                m.getDescript(),
                m.getPeriod(),
                new Image("/main/images/filetype/" + m.getFiletype() + ".gif"),
                image,
                m.getEditImage());
        item.setId(m.getSection());
        item.addForward("onClick", topNReport, "onSelecttopNList");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    String section =
        (String) Executions.getCurrent().getDesktop().getSession().getAttribute("topNReportlit_id");

    if (null == section) return;

    Listitem selectedItem = null;
    for (Object obj : topNList.getItems()) {
      if (obj instanceof Listitem) {
        Listitem tmpItem = (Listitem) obj;
        if (tmpItem.getId().equals(section)) {
          selectedItem = tmpItem;
        }
      }
    }

    if (null != selectedItem) {
      selectedItem.setSelected(true);
      Events.sendEvent(new Event(Events.ON_SELECT, topNList));
      topNList.setActivePage(selectedItem);
    }
  }
Exemplo n.º 2
0
 /**
  * 取得设置的全部id值
  *
  * @return String 形如"id1,id2,id3,"的字符串
  */
 public String getAllSelectedIds() {
   StringBuffer sb = new StringBuffer();
   for (String obj : getSelectedIds()) {
     INode node = ChartUtil.getView().getNode(obj);
     if (sb.length() > 0) sb.append(";");
     sb.append(node.getName());
   }
   if (sb.length() == 0) {
     return null;
   }
   sb.append(";");
   return sb.toString();
 }
Exemplo n.º 3
0
  private void createStateGrid() throws Exception {
    try {
      View view = Toolkit.getToolkit().getSvdbView(getDesktop());
      INode node = this.getSelectedNode();
      if (node == null) {
        Messagebox.show(ErrorMessage.UNSELECT_MONITOR, "提示", Messagebox.OK, Messagebox.INFORMATION);
        return;
      }
      if (getBeginDatabox().getValue().after(getEndDatabox().getValue())) {
        Messagebox.show(ErrorMessage.TIME_ERROR, "提示", Messagebox.OK, Messagebox.INFORMATION);
        return;
      }
      Date begin_date = getBeginDatabox().getValue();
      Date end_date = getEndDatabox().getValue();
      getBeginLabel().setValue(Toolkit.getToolkit().formatDate(begin_date));
      getEndLabel().setValue(Toolkit.getToolkit().formatDate(end_date));
      Report report = new Report(node, begin_date, end_date);
      report.load();

      Map<Date, DstrItem> dstrMap = report.getDstr();
      if (dstrMap == null || dstrMap.size() == 0) {
        this.getBeginLabel().setValue("");
        this.getEndLabel().setValue("");
        ChartUtil.clearComponent(getStatePercentRows());
        getStatusImage().setSrc("");
        getSpectrumImage().setSrc("");
        ChartUtil.clearComponent(getStatePeriodRow());
        //				Messagebox.show("没有您要显示的数据!", "提示", Messagebox.OK,
        //						Messagebox.INFORMATION);
        return;
      }
      int ok = 0, warn = 0, error = 0, disable = 0, bad = 0;
      double size = dstrMap.size(); // 提高精度
      if (colorlist.size() > 0) colorlist.clear();
      if (stateItems.size() > 0) stateItems.clear();
      for (Date keyDate : dstrMap.keySet()) {
        DstrItem dstrItem = dstrMap.get(keyDate);
        if ("ok".equals(dstrItem.status)) {
          ok++;
          colorlist.add(MonitorType.getColor(MonitorType.OK));
        } else if ("warning".equals(dstrItem.status)) {
          warn++;
          colorlist.add(MonitorType.getColor(MonitorType.WARN));
        } else if ("error".equals(dstrItem.status)) {
          error++;
          colorlist.add(MonitorType.getColor(MonitorType.ERROR));
        } else if ("disable".equals(dstrItem.status)) {
          disable++;
          colorlist.add(MonitorType.getColor(MonitorType.DISABLE));
        } else {
          bad++;
          colorlist.add(MonitorType.getColor(MonitorType.BAD));
        }
      }
      stateBean =
          new StateBean(
              node.getSvId(),
              node.getName(),
              Toolkit.getToolkit().formatDate(begin_date),
              Toolkit.getToolkit().formatDate(end_date),
              ok / size * 100,
              warn / size * 100,
              error / size * 100,
              disable / size * 100,
              bad / size * 100);
      Row row =
          addRow(
              new Row(),
              stateBean,
              stateBean.getPercentOk(),
              stateBean.getPercentWarn(),
              stateBean.getPercentError(),
              stateBean.getPercentDisable(),
              stateBean.getPercentBad());
      ChartUtil.clearComponent(getStatePercentRows());
      getStatePercentRows().appendChild(row);
      getDesktop().getSession().setAttribute("colorlist", colorlist);
      getSpectrumImage().setSrc("/main/report/SpectrumImage?Id" + new Random().nextDouble());
      PieDataset dataSet = createDataset(stateBean);
      Image image = ChartUtil.create3DPieChart(node.getName(), dataSet, 600, 300);
      getStatusImage().setSrc(image.getSrc());

      int index = 0;
      List<Date> aliasKey = new ArrayList<Date>(dstrMap.keySet());
      ChartUtil.clearComponent(getStatePeriodRow());
      while (index < size) {
        Date startTime = null;
        Date endTime = null;
        String status = null;
        int count = 0;
        for (; index < size; index++) {
          DstrItem dstrItem = dstrMap.get(aliasKey.get(index));
          //					if (!"ok".equals(dstrItem.status) && !"error".equals(dstrItem.status))	continue;
          if (status == null) status = dstrItem.status;
          if (!status.equals(dstrItem.status)) break;
          if (startTime == null) startTime = aliasKey.get(index);
          count++;
          endTime = aliasKey.get(index);
        }
        if (startTime == null || endTime == null) {
          Row blankRow = new Row();
          blankRow.appendChild(new Label("无数据!"));
          getStatePeriodRow().appendChild(blankRow);
          continue;
        }
        String strTime = subtract2Date(startTime, endTime);
        StateItem sitem =
            new StateItem(
                Toolkit.getToolkit().formatDate(startTime), status, String.valueOf(count), strTime);
        stateItems.add(sitem);
        Row generatetime =
            addRow(
                new Row(),
                null,
                sitem.getBeginTime(),
                ChartUtil.getImage(sitem.getStatus()),
                sitem.getCount(),
                sitem.getPersistTime());
        getStatePeriodRow().appendChild(generatetime);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }