Example #1
0
        @Override
        public void handleEvent(TreePanelEvent<ModelData> event) {
          // ModelData data = tree.getSelectionModel().getSelectedItem();
          ModelData data = event.getItem();
          deviceType = data.get("name");
          if ("告警信息管理".equals(deviceType)) {
            return;
          }
          commonService.getAlarmLogInfoByDeviceType(
              deviceType,
              new AsyncCallback<List<AlarmLog>>() {
                @Override
                public void onFailure(Throwable caught) {
                  Window.alert("获取告警信息失败!!!");
                }

                @Override
                public void onSuccess(List<AlarmLog> result) {
                  if (result != null) {
                    alarmManagerTable.setAlarmInfoList(deviceType, result);
                  } else {
                    Window.alert("未获取到告警信息!!!");
                  }
                }
              });
        }
Example #2
0
  private void submitSearch() {
    List<ModelData> query = new ArrayList<ModelData>();

    for (Field<?> field : formFields) {
      ModelData md = new BaseModelData();
      MetaField mf = findField(field.getName());

      if (mf == null
          || !enabledFields.containsKey(mf.getName())
          || field.getValue() == null
          || field.getValue().toString().length() == 0
          || !field.isValid()) {
        GWT.log("Will not submit field " + field.getName() + ".", null);
        continue;
      }

      md.set("field", mf);
      md.set("value", field.getValue());

      query.add(md);
    }

    GWT.log("Submitting search with " + query.size() + " query elements.", null);

    AppEvent evt = new AppEvent(ApplicationEvents.SUBMIT_ADVANCED_SEARCH, query);
    evt.setData("asset", combo.getValue().getBean());
    Dispatcher.forwardEvent(evt);
  }
  public ListStore<ModelData> getGroupComboStore() {

    if (sourceGrid != null) return getGroupComboStore(sourceGrid);
    if (sourceStore != null) return getGroupComboStore(sourceStore);

    ListStore<ModelData> groupStore = new ListStore<ModelData>();

    ModelData model;

    model = new BaseModelData();
    model.set("value", "productCode");
    model.set("description", "Product");
    groupStore.add(model);

    model = new BaseModelData();
    model.set("value", "serviceCode");
    model.set("description", "Service");
    groupStore.add(model);

    model = new BaseModelData();
    model.set("value", "institution.institutionName");
    model.set("description", "Institution");
    groupStore.add(model);

    model = new BaseModelData();
    model.set("value", "institution.state");
    model.set("description", "State");
    groupStore.add(model);

    return groupStore;
  }
  public ListStore<ModelData> getGroupComboStore(Grid<BeanModel> sourceGrid) {

    if (sourceGrid.getColumnModel().getColumnCount() > 0) {
      ListStore<ModelData> groupStore = new ListStore<ModelData>();
      ModelData model;
      for (int i = 0; i < sourceGrid.getColumnModel().getColumnCount(); i++) {
        model = new BaseModelData();
        model.set("value", sourceGrid.getColumnModel().getColumn(i).getId());
        model.set("description", sourceGrid.getColumnModel().getColumn(i).getHeader());
        groupStore.add(model);
      }
      return groupStore;
    } else return getGroupComboStore();
  }
 public static boolean getResumingIsHidden(ModelData model) {
   String strDetailedStatus = model.get(TaskExecutionHistoryBeanDesc.detailedStatus.name());
   boolean isResumingLogExists =
       (Boolean) model.get(TaskExecutionHistoryBeanDesc.resumingLogExists.name());
   if (!PropertiesCache.getInstance().isResumingAllowed()
       || !isResumingLogExists
       || TaskExecutionDetailedStatus.WAITING_FOR_TRIGGERING.name().equals(strDetailedStatus)
       || TaskExecutionDetailedStatus.MISFIRED.name().equals(strDetailedStatus)
       || TaskExecutionDetailedStatus.REQUESTING_RUN.name().equals(strDetailedStatus)) {
     return true;
   } else {
     return false;
   }
 }
  @Override
  protected Field createColumnCell(
      final ModelData model,
      String property,
      ListStore<ModelData> store,
      int rowIndex,
      int colIndex,
      Grid<ModelData> grid) {
    final gkDateRangeField drf = (gkDateRangeField) createField();
    LayoutContainer lc = (LayoutContainer) drf.getWidget();

    for (int i = 0; i < lc.getItemCount(); i++) { // 取出layoutConatainer裡面的物件
      Object obj = lc.getItem(i);
      if (obj instanceof gkDateField) { // 需要是field才作監聽動作
        final gkDateField df = (gkDateField) obj;
        // 如果重新render的時候,原本的就有值,要把那個值寫回去
        if (model.get(df.getId()) != null && model.get(df.getId()).toString().length() != 0) {
          df.setUseDate(model.get(df.getId()).toString());
        } else {
          model.set(df.getId(), df.getUseDate());
        }
        // 監聽事件
        df.addListener(
            Events.Change,
            new Listener<BaseEvent>() {

              @Override
              public void handleEvent(BaseEvent be) {
                model.set(df.getId(), df.getUseDate());
              }
            });

        addListener(df, grid, rowIndex, colIndex, store);
      }
      if (obj instanceof gkTimeField) { // 需要是field才作監聽動作
        final gkTimeField tf = (gkTimeField) obj;
        // 如果重新render的時候,原本的就有值,要把那個值寫回去
        if (model.get(tf.getId()) != null && model.get(tf.getId()).toString().length() != 0) {
          tf.setTimeValue(model.get(tf.getId()).toString());
        } else {
          model.set(tf.getId(), tf.getTimeValue());
        }

        // 監聽事件
        tf.addListener(
            Events.Change,
            new Listener<BaseEvent>() {
              @Override
              public void handleEvent(BaseEvent be) {
                model.set(tf.getId(), tf.getTimeValue());
              }
            });
        addListener(tf, grid, rowIndex, colIndex, store);
      }
    }
    onField(drf);
    return drf;
  }
  public int compareMainGridItem(
      Store<ModelData> store, ModelData m1, ModelData m2, String property) {
    if (property != null) {
      if (property.equals("records")) {
        if (m1 instanceof DataProviderUI && m2 instanceof DataProviderUI) {
          DataProviderUI dp1 = (DataProviderUI) m1;
          DataProviderUI dp2 = (DataProviderUI) m2;
          int r1, r2;

          if (dp1.getDataSourceUIList().size() == 1 && dp2.getDataSourceUIList().size() == 1) {
            if (dp1.getDataSourceUIList().get(0).get(property) == null) r1 = 0;
            else
              r1 =
                  Integer.parseInt(
                      ((String) dp1.getDataSourceUIList().get(0).get(property)).replace(".", ""));

            if (dp2.getDataSourceUIList().get(0).get(property) == null) r2 = 0;
            else
              r2 =
                  Integer.parseInt(
                      ((String) dp2.getDataSourceUIList().get(0).get(property)).replace(".", ""));

            if (r1 > r2) return 1;
            else if (r1 < r2) return -1;
            else return 0;
          } else if (dp1.getChildCount() > 0 && dp2.getChildCount() > 0) {
            if (dp1.getChild(0).get(property) == null) r1 = 0;
            else r1 = Integer.parseInt(((String) dp1.getChild(0).get(property)).replace(".", ""));

            if (dp2.getChild(0).get(property) == null) r2 = 0;
            else r2 = Integer.parseInt(((String) dp2.getChild(0).get(property)).replace(".", ""));

            if (r1 > r2) return 1;
            else if (r1 < r2) return -1;
            else return 0;
          }
        }
        return 0;
      } else {
        Object v1 = m1.get(property);
        Object v2 = m2.get(property);
        DefaultComparator<Object> compr = new DefaultComparator<Object>();
        return compr.compare(v1, v2);
      }
    }
    return 0;
  }
  public ListStore<ModelData> getValueComboStore() {
    ListStore<ModelData> valueStore = new ListStore<ModelData>();

    ModelData model;

    model = new BaseModelData();
    model.set("value", "dollarValue");
    model.set("description", "Dollar Values");
    valueStore.add(model);

    model = new BaseModelData();
    model.set("value", "count");
    model.set("description", "Services");
    valueStore.add(model);

    return valueStore;
  }
Example #9
0
  /**
   * Updates the field's value and original value with the model value. Updating the original value
   * will reset the field to a non-dirty state.
   *
   * @param updateOriginalValue true to update the original value
   */
  public void updateField(boolean updateOriginalValue) {
    Object val = onConvertModelValue(model.get(property));

    if (updateOriginalValue) {
      field.setOriginalValue(val);
    }

    field.setValue(val);
  }
Example #10
0
 protected String getText(ModelData model, String valueProperty) {
   String text = null;
   if (textProperty != null) {
     Object o = model.<Object>get(textProperty);
     text = o != null ? o.toString() : null;
   } else if (textProvider != null) {
     text = textProvider.getStringValue(model, valueProperty);
   }
   return text == null ? "" : text;
 }
Example #11
0
 protected String getLabel(ModelData model, String valueProperty) {
   String label = null;
   if (labelProperty != null) {
     Object o = model.<Object>get(labelProperty);
     label = o != null ? o.toString() : null;
   } else if (labelProvider != null) {
     label = labelProvider.getStringValue(model, valueProperty);
   }
   return label == null ? "" : label;
 }
Example #12
0
 /** Updates the model's value with the field value. */
 public void updateModel() {
   Object val = onConvertFieldValue(field.getValue());
   if (store != null) {
     Record r = store.getRecord(model);
     if (r != null) {
       r.setValid(property, field.isValid());
       r.set(property, val);
     }
   } else {
     model.set(property, val);
   }
 }
Example #13
0
  public boolean Compare() {
    if (modeldata == null) return false;
    boolean b = false;
    switch (rule) {
      case String_equals:
        b = modeldata.get(columnname).equals(comparevalue);
        break;
      case String_More_than:
        b = modeldata.get(columnname).toString().compareTo(comparevalue) > 0;

        break;

      case String_Less_than:
        b = modeldata.get(columnname).toString().compareTo(comparevalue) < 0;

        break;
      default:
        // TODO
        b = false;
    }
    return b;
  }
  public ListStore<ModelData> getGroupComboStore(ListStore<BeanModel> sourceStore) {

    if (sourceGrid != null && groupCombo != null) return groupCombo.getStore();

    if (sourceStore.getCount() > 0) {

      ListStore<ModelData> groupStore = new ListStore<ModelData>();
      ModelData model;

      SortedSet<String> properties = new TreeSet<String>();
      for (String property : sourceStore.getAt(0).getPropertyNames()) properties.add(property);

      for (String property : properties) {
        model = new BaseModelData();
        model.set("value", property);
        model.set("description", getPropertyHeader(property));
        groupStore.add(model);
      }

      return groupStore;

    } else return getGroupComboStore();
  }
Example #15
0
 @Override
 protected void onRemove(ListStore<ModelData> ds, ModelData m, int index, boolean isUpdate) {
   super.onRemove(ds, m, index, isUpdate);
   String groupField = getGroupField();
   if (enableGrouping) {
     String id =
         getGroupId(
             grid.getId(),
             groupField,
             getGroup(m.get(groupField), m, index, cm.findColumnIndex(groupField), ds));
     Element g = XDOM.getElementById(id);
     if (g != null && !g.getChildNodes().getItem(1).hasChildNodes()) {
       fly(g).removeFromParent();
       removeGroupId(id);
     }
   }
   // apply empty text
 }
Example #16
0
 private ModelData newItem(String text, String iconStyle) {
   ModelData m = new BaseModelData();
   m.set("name", text);
   m.set("icon", iconStyle);
   return m;
 }
Example #17
0
  @Override
  protected String doRender(
      List<ColumnData> cs, List<ModelData> rows, int startRow, int colCount, boolean stripe) {
    if (rows.size() < 1) {
      return "";
    }

    String groupField = getGroupField();
    int colIndex = cm.findColumnIndex(groupField);

    enableGrouping = groupField != null;

    if (!enableGrouping || isUpdating) {
      return super.doRender(cs, rows, startRow, colCount, stripe);
    }

    String gstyle = "width:" + getTotalWidth() + "px;";
    String gidPrefix = grid.getId();

    ColumnConfig cfg = cm.getColumn(colIndex);

    String prefix = showGroupName ? cfg.getHeader() + ": " : "";

    GroupColumnData curGroup = null;
    String gid = null;

    List<GroupColumnData> groups = new ArrayList<GroupColumnData>();

    for (int j = 0; j < rows.size(); j++) {
      ModelData model = (ModelData) rows.get(j);

      int rowIndex = (j + startRow);

      // the value for the group field
      Object gvalue = model.get(groupField);

      // the rendered group value
      String g = getGroup(gvalue, model, rowIndex, colIndex, ds);

      if (curGroup == null || !curGroup.group.equals(g)) {
        gid = getGroupId(gidPrefix, groupField, g);

        boolean isCollapsed = state.get(gid) != null ? !state.get(gid) : startCollapsed;
        String gcls = isCollapsed ? "x-grid-group-collapsed" : "";

        curGroup = new GroupColumnData();
        curGroup.group = g;
        curGroup.field = groupField;
        curGroup.gvalue = gvalue;
        curGroup.text = prefix + g;
        curGroup.groupId = gid;
        curGroup.startRow = rowIndex;
        curGroup.style = gstyle;
        curGroup.css = gcls;
        curGroup.models.add(model);
        groups.add(curGroup);

      } else {
        curGroup.models.add(model);
      }
      // model.set("_groupId", gid);

    }

    for (GroupColumnData group : groups) {
      if (groupRenderer != null) {
        String g = groupRenderer.render(group);
        if (g == null || g.equals("")) {
          g = "&nbsp;";
        }
        group.group = g;
      }
    }

    StringBuilder buf = new StringBuilder();

    for (int i = 0, len = groups.size(); i < len; i++) {
      GroupColumnData g = groups.get(i);
      doGroupStart(buf, g, cs, colCount);
      buf.append(super.doRender(cs, g.models, g.startRow, colCount, stripe));
      doGroupEnd(buf, g, cs, colCount);
    }

    return buf.toString();
  }