Exemplo n.º 1
0
  @Override
  public void setAttributeValue(Component com, Object value) {
    if (com instanceof gkGridIC) {
      gkGridIC grid = (gkGridIC) com;
      // 如果傳Collection表示要選擇指定的row (可以是數字或字串)
      if (value instanceof Collection) {
        grid.setSelectRowItem((Collection) value);
      } else if (value instanceof TreeMap) {
        TreeMap tm = (TreeMap) value;
        if (tm.size() == 1) {
          grid.setSelectRowItem((Map) tm.get(tm.firstKey()));
        }
      } else if (value instanceof String
          && grid.getGrid().getSelectionModel() instanceof gkCheckBoxSelectionModel) {
        // for select all
        if ("all".equalsIgnoreCase((String) value)) {
          grid.getGrid().getSelectionModel().selectAll();
        }
      }
    } else if (com instanceof ComboBox) {
      ComboBox combo = (ComboBox) com;
      if (value instanceof String) {
        combo.setValue(combo.getPropertyEditor().convertStringValue(value + ""));
      } else {
        combo.setValue((gkMap) value);
      }
      combo.fireEvent(Events.Change);
    } else if (com instanceof TabPanel) {
      TabPanel tp = (TabPanel) com;
      tp.setSelection(tp.getItemByItemId(value + ""));
    } else if (com instanceof gkXMLTreePanelIC) {
      gkXMLTreePanelIC tree = (gkXMLTreePanelIC) com;
      String[] nodeIds;
      if (value instanceof Map) {
        nodeIds = ((String) ((Map) value).get(gkXMLTreePanelIC.ID)).split(",");
      } else {
        nodeIds = ((String) value).split(",");
      }

      tree.getTree().getSelectionModel().deselectAll();
      for (String nodeId : nodeIds) {
        ModelData md = tree.getTree().getStore().findModel(nodeId);
        tree.getTree().getSelectionModel().select(md, true);
        tree.getTree().scrollIntoView(md);
      }
    }
  }
Exemplo n.º 2
0
 @Override
 public Object getAttributeValue(Component com) {
   Object value = null;
   if (com instanceof gkGridIC) {
     gkGridIC grid = (gkGridIC) com;
     // 取得所有勾選列資料,並重組成map
     value = grid.getSelectedRowItems();
   } else if (com instanceof ComboBox) {
     ComboBox combo = (ComboBox) com;
     value = combo.getValue();
   } else if (com instanceof TabPanel) {
     TabPanel tp = (TabPanel) com;
     value = tp.getSelectedItem().getId();
   } else if (com instanceof gkXMLTreePanelIC) {
     gkXMLTreePanelIC xtp = (gkXMLTreePanelIC) com;
     value = xtp.getTree().getSelectionModel().getSelectedItem();
   } else if (com instanceof gkTreeDirPanelIC) {
     gkTreeDirPanelIC xtp = (gkTreeDirPanelIC) com;
     value = xtp.getSelectionModel().getSelectedItem();
   }
   return value;
 }