Changeset 1884
- Timestamp:
- 05/14/09 16:05:13 (3 years ago)
- Files:
-
- jmatter-complet/trunk/demo-apps/ContactMgr (modified) (1 prop)
- jmatter-complet/trunk/demo-apps/ContactMgr/src/com/u2d/contactmgr/NewPersonWizard.java (modified) (3 diffs)
- jmatter-complet/trunk/modules/ds-wizard/src/com/u2d/validation (added)
- jmatter-complet/trunk/modules/ds-wizard/src/com/u2d/validation/ValidationEvent.java (moved) (moved from jmatter-complet/trunk/jmatter/src/com/u2d/validation/ValidationEvent.java) (1 prop)
- jmatter-complet/trunk/modules/ds-wizard/src/com/u2d/validation/ValidationListener.java (moved) (moved from jmatter-complet/trunk/jmatter/src/com/u2d/validation/ValidationListener.java) (1 prop)
- jmatter-complet/trunk/modules/ds-wizard/src/com/u2d/validation/ValidationNotifier.java (moved) (moved from jmatter-complet/trunk/jmatter/src/com/u2d/validation/ValidationNotifier.java) (1 prop)
- jmatter-complet/trunk/modules/ds-wizard/src/com/u2d/wizard/details/BasicStep.java (modified) (2 diffs)
- jmatter-complet/trunk/modules/swingvm/src/com/u2d/view/swing/ValidationNoticePanel.java (modified) (2 diffs)
- jmatter-complet/trunk/modules/swingvm/src/com/u2d/wizard/ui/CenterPane.java (modified) (7 diffs)
- jmatter-complet/trunk/modules/swingvm/src/com/u2d/wizard/ui/WizardPane.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
jmatter-complet/trunk/demo-apps/ContactMgr
- Property svn:ignore changed from
db
build
dist
jws-dist
run.sh
jetty
tempKeystore
appbundle
to
db
build
dist
jws-dist
run.sh
jetty
tempKeystore
appbundle
*.log
- Property svn:ignore changed from
jmatter-complet/trunk/demo-apps/ContactMgr/src/com/u2d/contactmgr/NewPersonWizard.java
r1883 r1884 4 4 import com.u2d.view.swing.FormView; 5 5 import com.u2d.model.ComplexType; 6 import com.u2d.validation.ValidationNotifier; 6 7 7 8 import javax.swing.*; … … 32 33 // ==================================================================== 33 34 35 private int attempts = 0; 36 34 37 class NameStep extends BasicStep 35 38 { … … 39 42 { 40 43 return new FormView(pc.getName()); 44 } 45 46 /* 47 testing new validation hook added to wizard implementation 48 */ 49 @Override 50 public int validate(ValidationNotifier notifier) 51 { 52 attempts++; 53 switch (attempts) 54 { 55 case 1: 56 { 57 notifier.fireValidationException("Try again."); 58 return 1; 59 } 60 case 2: 61 { 62 notifier.fireValidationException("Not yet. One more time please."); 63 return 1; 64 } 65 default: 66 { 67 return 0; 68 } 69 } 41 70 } 42 71 } jmatter-complet/trunk/modules/ds-wizard/src/com/u2d/validation/ValidationEvent.java
- Property svn:mergeinfo set
jmatter-complet/trunk/modules/ds-wizard/src/com/u2d/validation/ValidationListener.java
- Property svn:mergeinfo set
jmatter-complet/trunk/modules/ds-wizard/src/com/u2d/validation/ValidationNotifier.java
- Property svn:mergeinfo set
jmatter-complet/trunk/modules/ds-wizard/src/com/u2d/wizard/details/BasicStep.java
r1 r1884 2 2 3 3 import com.u2d.wizard.abstractions.Step; 4 import com.u2d.validation.ValidationNotifier; 5 4 6 import javax.swing.*; 5 7 … … 26 28 public boolean viewDirty() { return false; } 27 29 30 /** 31 * @param notifier use this object to send validation messages to the ui 32 * @return number of validation errors (should return 0 if validation passed) 33 */ 34 public int validate(ValidationNotifier notifier) 35 { 36 return 0; // default implementation. overriding optional. 37 } 38 28 39 public String toString() { return title(); } 29 40 } jmatter-complet/trunk/modules/swingvm/src/com/u2d/view/swing/ValidationNoticePanel.java
r1647 r1884 22 22 private ValidationNotifier _target; 23 23 private boolean _listening = false; 24 24 25 public ValidationNoticePanel() 26 { 27 setText(""); 28 ComponentStyle.addClass(this, "validation-msg"); 29 } 25 30 public ValidationNoticePanel(ValidationNotifier target, boolean startListening) 26 31 { 32 this(); 27 33 _target = target; 28 29 setText(""); 30 ComponentStyle.addClass(this, "validation-msg"); 31 32 if (startListening) 33 startListening(); 34 if (startListening) startListening(); 34 35 } 35 36 public ValidationNoticePanel(ValidationNotifier target, ComplexEObject ceo) 36 37 { 37 38 this(target, ceo.isEditableState()); 39 } 40 41 public void setTarget(ValidationNotifier notifier) 42 { 43 stopListening(); 44 _target = notifier; 45 startListening(); 38 46 } 39 47 … … 47 55 public synchronized void stopListening() 48 56 { 49 _target.removeValidationListener(this); 57 if (_target != null) 58 { 59 _target.removeValidationListener(this); 60 } 50 61 _listening = false; 51 62 } jmatter-complet/trunk/modules/swingvm/src/com/u2d/wizard/ui/CenterPane.java
r1660 r1884 3 3 import com.u2d.wizard.abstractions.Step; 4 4 import com.u2d.view.EView; 5 import com.u2d.view.swing.ValidationNoticePanel; 5 6 import com.u2d.ui.UIUtils; 7 import com.u2d.model.EObject; 6 8 7 9 import javax.swing.*; … … 9 11 import java.util.Map; 10 12 import java.util.HashMap; 11 import java.util.Iterator;12 13 13 14 /** … … 22 23 private Map<String,JComponent> _stepViewMap = new HashMap<String,JComponent>(); 23 24 private JComponent _currentView; 25 private ValidationNoticePanel _validationPnl; 26 private JPanel _stepsPnl; 24 27 25 28 public CenterPane(Dimension preferredSize) 26 29 { 30 setLayout(new BorderLayout()); 31 32 _stepsPnl = new JPanel(); 27 33 _cardLayout = new CardLayout(); 28 setLayout(_cardLayout); 29 setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); 30 setPreferredSize(preferredSize); 34 _stepsPnl.setLayout(_cardLayout); 35 _stepsPnl.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); 36 _stepsPnl.setPreferredSize(preferredSize); 37 38 _validationPnl = new ValidationNoticePanel(); 39 add(_validationPnl, BorderLayout.NORTH); 40 add(_stepsPnl, BorderLayout.CENTER); 31 41 } 32 42 33 43 public void updateStep(Step step) 34 44 { 35 _cardLayout.show(this, viewName(step)); 45 _cardLayout.show(_stepsPnl, viewName(step)); 46 47 if (_currentView instanceof EView) 48 { 49 EObject eo = ((EView) _currentView).getEObject(); 50 _validationPnl.setTarget(eo); 51 } 52 36 53 // must delay this otherwise may not have any effect.. 37 54 SwingUtilities.invokeLater(new Runnable() … … 46 63 private String viewName(Step step) 47 64 { 48 JComponent view = (JComponent)_stepViewMap.get(step.title());65 JComponent view = _stepViewMap.get(step.title()); 49 66 if ( (view!=null) && (step.viewDirty()) ) 50 67 { 51 remove(view);68 _stepsPnl.remove(view); 52 69 _stepViewMap.remove(step.title()); 53 70 if (view instanceof EView) … … 61 78 view = step.getView(); 62 79 _stepViewMap.put(step.title(), view); 63 add(view, step.title());80 _stepsPnl.add(view, step.title()); 64 81 } 65 82 _currentView = view; … … 71 88 public void detach() 72 89 { 73 for ( Iterator views = _stepViewMap.values().iterator(); views.hasNext();)90 for (Object next : _stepViewMap.values()) 74 91 { 75 Object next = views.next();76 92 if (next instanceof EView) 77 93 { … … 79 95 } 80 96 } 97 _validationPnl.stopListening(); 81 98 } 82 99 jmatter-complet/trunk/modules/swingvm/src/com/u2d/wizard/ui/WizardPane.java
r1660 r1884 3 3 import com.u2d.wizard.abstractions.Step; 4 4 import com.u2d.wizard.details.Wizard; 5 import com.u2d.wizard.details.BasicStep; 5 6 import com.u2d.model.Editor; 6 7 import com.u2d.model.EObject; … … 130 131 errorCount = eo.field().validate(eo.parentObject()); 131 132 } 132 133 133 134 if (errorCount > 0) 134 135 { … … 136 137 eo.fireValidationException("["+errorCount+" validation error"+plural+".]", true); 137 138 return false; 139 } 140 141 if (_wizard.currentStep() instanceof BasicStep) 142 { 143 BasicStep bstep = (BasicStep) _wizard.currentStep(); 144 errorCount = bstep.validate(eo); 145 if (errorCount > 0) 146 { 147 return false; 148 } 138 149 } 139 150 … … 159 170 160 171 StepLabel label = null; 161 Step step = null;172 Step step; 162 173 for (int i=0; i<flattenedSteps.size(); i++) 163 174 {
