Package org.jallinone.system.customizations.java

Examples of org.jallinone.system.customizations.java.CustomColumnVO


   * @param row selected row index
   * @param attributeName attribute name that identifies the selected grid column
   * @return <code>true</code> if the selected cell is editable, <code>false</code> otherwise
   */
  public boolean isCellEditable(GridControl grid,int row,String attributeName) {
    CustomColumnVO colVO = (CustomColumnVO)grid.getVOListTableModel().getObjectForRow(row);

    if (attributeName.equals("columnTypeSYS22") &&
        colVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_DATE))
      // column type combo is not editable if the column is a date...
      return false;

    if (colVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_WHERE))
      // all row is not editable if the column is a where param...
      return false;

    if (attributeName.equals("defaultValueTextSYS22") &&
        !colVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_TEXT))
      // default value text is not editable if column type is NOT text...
      return false;

    if (attributeName.equals("defaultValueNumSYS22") &&
        !colVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_NUM))
      // default value num is not editable if column type is NOT num...
      return false;

    if (attributeName.equals("defaultValueDateSYS22") &&
        !colVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_DATE))
      // default value date is not editable if column type is NOT date...
      return false;

    if (attributeName.equals("constraintValuesSYS22") &&
        !colVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_ENUM))
      // enumeration cell is not editable if column type is NOT enum...
      return false;

    return super.isCellEditable(grid,row,attributeName);
  }
View Full Code Here


   * @param oldValue old cell value (before cell editing)
   * @param newValue new cell value (just edited)
   * @return <code>true</code> if cell value is valid, <code>false</code> otherwise
   */
  public boolean validateCell(int rowNumber,String attributeName,Object oldValue,Object newValue) {
    CustomColumnVO colVO = (CustomColumnVO)grid.getVOListTableModel().getObjectForRow(rowNumber);

    if (attributeName.equals("columnNameSYS22") &&
        newValue!=null &&
        newValue.toString().length()>0 &&
        !Character.isLetter(newValue.toString().charAt(0)))
      return false;

    if (attributeName.equals("columnTypeSYS22") &&
        oldValue.equals(ApplicationConsts.TYPE_TEXT) &&
        !newValue.equals(ApplicationConsts.TYPE_ENUM))
      // column type is NOT valid if it has been changed from text to a value different from enum
      return false;

    if (attributeName.equals("columnTypeSYS22") &&
        oldValue.equals(ApplicationConsts.TYPE_ENUM) &&
        !newValue.equals(ApplicationConsts.TYPE_TEXT))
      // column type is NOT valid if it has been changed from enum to a value different from text
      return false;

    if (attributeName.equals("columnTypeSYS22") &&
        oldValue.equals(ApplicationConsts.TYPE_NUM) &&
        !newValue.equals(ApplicationConsts.TYPE_PROG))
      // column type is NOT valid if it has been changed from num to a value different from prog
      return false;

    if (attributeName.equals("columnTypeSYS22") &&
        oldValue.equals(ApplicationConsts.TYPE_PROG) &&
        !newValue.equals(ApplicationConsts.TYPE_NUM))
      // column type is NOT valid if it has been changed from prog to a value different from num
      return false;

    if (attributeName.equals("columnTypeSYS22") &&
        oldValue.equals(ApplicationConsts.TYPE_NUM) &&
        newValue.equals(ApplicationConsts.TYPE_PROG))
      // column type has been changed from num to prog: default value num must be reset...
      colVO.setDefaultValueNumSYS22(null);

    if (attributeName.equals("columnTypeSYS22") &&
        oldValue.equals(ApplicationConsts.TYPE_TEXT) &&
        newValue.equals(ApplicationConsts.TYPE_ENUM))
      // column type has been changed from text to enum: default value text must be reset...
      colVO.setDefaultValueTextSYS22(null);

    if (attributeName.equals("columnTypeSYS22") &&
        oldValue.equals(ApplicationConsts.TYPE_ENUM) &&
        newValue.equals(ApplicationConsts.TYPE_TEXT))
      // column type has been changed from enum to text: enumeration must be reset...
      colVO.setConstraintValuesSYS22(null);

    if (attributeName.equals("constraintValuesSYS22") && newValue!=null) {
      // enumeration cell has been changed: parse it and check its correctness...
      try {
        StringTokenizer st = new StringTokenizer(newValue.toString(), ",");
View Full Code Here

        );
        return;
      }
      tableVO = (TableVO)((VOResponse)res).getVo();
      ColumnVO colVO = null;
      CustomColumnVO customColVO = null;
      boolean found;
      Hashtable whereParamColNames = new Hashtable(); // collection of <columnname,index in where> related to where params...
      boolean paramsRequired = false; // flag used to disable auto data loading...
      ArrayList paramsDefined = new ArrayList(); // input controls defined in filter panel; used to auto set filter panel height into the split pane...
      int count = 0;
      for(int i=0;i<customCols.size();i++) {
        customColVO = (CustomColumnVO)customCols.get(i);

        found = false;
        for(int j=0;j<tableVO.getColumns().size();j++) {
          colVO = (ColumnVO)tableVO.getColumns().get(j);
          if (customColVO.getColumnNameSYS22().equals(colVO.getColumnName())) {
            found = true;
            break;
          }
        }

        if (!found && customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_WHERE)) {
          // parameter in where clause...
          colVO = new ColumnVO(tableVO);
          colVO.setColumnName(customColVO.getColumnNameSYS22());
          colVO.setAttributeName(customColVO.getColumnNameSYS22());
          colVO.setColumnHeaderName(customColVO.getColumnNameSYS22());
          colVO.setColumnType(ApplicationConsts.TYPE_TEXT);
          colVO.setColumnSize(new BigDecimal(255));
          whereParamColNames.put(colVO.getAttributeName(),new Integer(count));
          whereParamsFilled.put(new Integer(count),new Boolean(false));
          count++;
          found = true;
        }

        if (!found)
          continue;

        if (customColVO.isIsParamRequiredSYS22())
          paramsRequired = true;
        if (customColVO.isIsParamSYS22()) {
          if (paramsDefined.size()==0) {
            // add filter panel title...
            TitledBorder titledBorder1 = new TitledBorder(ClientSettings.getInstance().getResources().getResource("filter conditions"));
            titledBorder1.setTitleColor(Color.blue);
            filterPanel.setBorder(titledBorder1);
          }

          // define label + input control for filter panel...
          LabelControl label = new LabelControl();
          label.setText(colVO.getColumnHeaderName());
          InputControl inputControl = null;
          if (customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_TEXT) ||
              customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_WHERE)) {
            inputControl = new TextControl();
            inputControl.setAttributeName(colVO.getAttributeName());
            if (colVO.getColumnSize().intValue()>10)
              ((TextControl)inputControl).setColumns(Math.min(30,colVO.getColumnSize().intValue()));
            ((TextControl)inputControl).setRequired(customColVO.isIsParamRequiredSYS22());
            ((TextControl)inputControl).setValue(customColVO.getDefaultValueTextSYS22());
            ((TextControl)inputControl).setMaxCharacters(colVO.getColumnSize().intValue());
          }
          else if (customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_NUM)) {
            inputControl = new NumericControl();
            inputControl.setAttributeName(colVO.getAttributeName());
            if (colVO.getColumnSize().intValue()>10)
              ((NumericControl)inputControl).setColumns(Math.min(30,colVO.getColumnSize().intValue()));
            ((NumericControl)inputControl).setRequired(customColVO.isIsParamRequiredSYS22());
            ((NumericControl)inputControl).setValue(customColVO.getDefaultValueNumSYS22());
            ((NumericControl)inputControl).setMaxValue(Math.pow(10d,colVO.getColumnSize().doubleValue()));
            if (colVO.getColumnDec()!=null)
              ((NumericControl)inputControl).setDecimals(colVO.getColumnDec().intValue());
          }
          else if (customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_DATE)) {
            inputControl = new DateControl();
            inputControl.setAttributeName(colVO.getAttributeName());
            ((DateControl)inputControl).setRequired(customColVO.isIsParamRequiredSYS22());
            ((DateControl)inputControl).setValue(customColVO.getDefaultValueNumSYS22());
            if (customColVO.getDefaultValueDateSYS22()!=null &&
                customColVO.getDefaultValueDateSYS22().equals(Boolean.TRUE))
              ((DateControl)inputControl).setValue(new java.sql.Date(System.currentTimeMillis()));
          }
          else if (customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_ENUM) &&
                   customColVO.getConstraintValuesSYS22()!=null &&
                   customColVO.getConstraintValuesSYS22().length()>0) {
            inputControl = new ComboBoxControl();
            inputControl.setAttributeName(colVO.getAttributeName());
            ((ComboBoxControl)inputControl).setRequired(customColVO.isIsParamRequiredSYS22());
            ((ComboBoxControl)inputControl).setValue(customColVO.getDefaultValueNumSYS22());
            ArrayList domainValues = new ArrayList();
            StringTokenizer stt = new StringTokenizer(customColVO.getConstraintValuesSYS22(),",");
            String token = null;
            Domain domain = new Domain(colVO.getColumnName());
            while(stt.hasMoreTokens()) {
              token = stt.nextToken();
              domain.addDomainPair(token,token);
            }
            ((ComboBoxControl)inputControl).setDomain(domain);
          }

          // add label + input control to filter panel...
          filterPanel.add(label,       new GridBagConstraints(0, paramsDefined.size(), 1, 1, 0.0, 0.0
                  ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
          filterPanel.add((JComponent)inputControl,       new GridBagConstraints(1, paramsDefined.size(), 1, 1, 1.0, 0.0
                  ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));

          paramsDefined.add(inputControl);
        }
        colVO.setColumnVisible(customColVO.isColumnVisibleSYS22());
        if (customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_PROG)) {
          colVO.setProgressive(true);
          colVO.setColumnRequired(false);
        }
        if (customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_TEXT))
          colVO.setDefaultValue(customColVO.getDefaultValueTextSYS22());
        else if (customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_NUM))
          colVO.setDefaultValue(customColVO.getDefaultValueNumSYS22());
        else if (customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_DATE) &&
                 customColVO.getDefaultValueDateSYS22()!=null &&
                 customColVO.getDefaultValueDateSYS22().equals(Boolean.TRUE))
          colVO.setDefaultValue(new java.sql.Date(System.currentTimeMillis()));
        else if (customColVO.getColumnTypeSYS22().equals(ApplicationConsts.TYPE_ENUM) &&
                 customColVO.getConstraintValuesSYS22()!=null &&
                 customColVO.getConstraintValuesSYS22().length()>0) {
          ArrayList domainValues = new ArrayList();
          StringTokenizer stt = new StringTokenizer(customColVO.getConstraintValuesSYS22(),",");
          while(stt.hasMoreTokens())
            domainValues.add(stt.nextToken());
          colVO.setColumnValues(domainValues);
        }
      }
View Full Code Here

TOP

Related Classes of org.jallinone.system.customizations.java.CustomColumnVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.