Package com.projity.dialog

Examples of com.projity.dialog.FieldDialog


      }

      public void keyTyped(KeyEvent arg0) {
        JTextComponent textComponent = (JTextComponent)arg0.getComponent();
        textComponent.setForeground(Color.BLUE);
        FieldDialog parentFieldDialog = getParentFieldDialog(textComponent);
        if (parentFieldDialog != null)
          parentFieldDialog.setDirtyComponent(textComponent);
      }});

    }
    if (!(component instanceof JCheckBox))
      setValueOfComponent(component,value,readOnly);
View Full Code Here


  public boolean verify(JComponent component) {
    if (updating) {
      return true;
    }

    FieldDialog parentFieldDialog = ComponentFactory.getParentFieldDialog(component);
    if (parentFieldDialog != null)
      parentFieldDialog.setDirtyComponent(null);
   
   
    JComponent c = component;
    component = valueHoldingComponent(component);
   
    component.setForeground(Color.BLACK);
    c.setForeground(Color.BLACK);
   
    Object newValue = ComponentFactory.getValueFromComponent(component, field);
//System.out.println("new value " + newValue + " " + (newValue != null ?newValue.getClass():""));
   
    // avoid validating unchanged controls
    if (newValue == value || (newValue != null && newValue.equals(value))) { //unchanged
      if (component instanceof JSpinner || component instanceof ExtDateField) { // if a spinner, check for modified text
        String text = ((JTextField)c).getText();
        try {
          if (!(component instanceof ExtDateField) || text.trim().length() > 0)
            newValue = field.getFormat().parseObject(text);
          else {
            ((JTextField)c).setText(""); // put in empty text
            newValue = null;
          }
        } catch (ParseException e1) {
          exception = new FieldParseException(field.syntaxErrorForField());
          component.setForeground(Color.RED);
          c.setForeground(Color.RED);
          if (parentFieldDialog != null)
            parentFieldDialog.setDirtyComponent(c);

          return false;
        }
      } else {
        return true;
      }
    }
    if (newValue != null && value != null && newValue.toString().equals(value.toString()))
      return true;
   
    exception = null;
    try {
      if (field.hasOptions())  {
        if (newValue == null)
          newValue = Select.EMPTY;
       
        field.setText(objectRef,newValue.toString(),context);
      } else {
        if (field.isDate()) {
          if (newValue != null && newValue instanceof String) {
            try {
              newValue = EditOption.getInstance().getDateFormat().parseObject((String) newValue);
            } catch (ParseException e) {
            }
          }
          if (newValue == null || newValue.toString().trim().equals("")) // empty text on date is a null date
            newValue = DateTime.getZeroDate();
        }
        if (newValue != value){
          Object oldValue=field.getValue(objectRef, context);
          if (field.isMoney())
            field.setText(objectRef,""+newValue,context);
          else   
            field.setValue(objectRef,source,newValue,context);
          UndoableEditSupport undoableEditSupport=objectRef.getDataFactory().getUndoController().getEditSupport();
          if (undoableEditSupport!=null){
            undoableEditSupport.postEdit(new FieldEdit(field,objectRef,value,oldValue,this,context));
          }
        }
       
      }
    } catch (FieldParseException e) {
      exception = e;
      component.setForeground(Color.RED);
      c.setForeground(Color.RED);
      if (parentFieldDialog != null)
        parentFieldDialog.setDirtyComponent(c);
      return false;
    }
    setValue(newValue); // set to new value for next time
    return true;
  }
View Full Code Here

TOP

Related Classes of com.projity.dialog.FieldDialog

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.