1 9 10 package org.enhydra.jawe.actions; 11 12 import org.enhydra.jawe.*; 13 import org.enhydra.jawe.misc.*; 14 import org.enhydra.jawe.graph.BlockActivityEditor; 15 import org.enhydra.jawe.graph.Start; 16 import org.enhydra.jawe.graph.End; 17 import org.enhydra.jawe.xml.*; 18 import org.enhydra.jawe.xml.elements.*; 19 import org.enhydra.jawe.xml.panels.*; 20 21 import javax.swing.*; 22 import java.util.*; 23 import java.net.*; 24 import java.awt.event.ActionEvent ; 25 26 29 public class CheckValidity extends ActionBase { 30 31 private static ImageIcon checkOKIcon; 32 33 public CheckValidity (AbstractEditor editor) { 34 super(editor); 35 } 36 37 public void actionPerformed(ActionEvent e) { 38 if (editor instanceof PackageEditor && !((PackageEditor)editor).isInitialized()) { 39 ((PackageEditor)editor).enterPackageID(); 40 } 41 43 boolean isSchemaValidationError=!editor.getGraph().validateAgainsXPDLSchema(); 44 boolean isConnectionError=!editor.getGraph().checkConnections(true); 45 boolean isGraphConformanceError=!editor.getGraph().checkGraphConformance(true); 46 boolean isLogicError=!editor.getGraph().checkLogic(true); 47 boolean isModelOK=!(isSchemaValidationError || isConnectionError || 48 isGraphConformanceError || isLogicError); 49 Map xpdlSchemaValidationErrors=editor.getGraph().getXPDLSchemaValidationErrorMessages(); 51 Map connectionErrors=editor.getGraph().getConnectionErrorMessages(); 52 List basicGraphConformanceErrors=editor.getGraph().getBasicGraphConformanceErrorMessages(); 53 Map graphConformanceErrors=editor.getGraph().getGraphConformanceErrorMessages(); 54 Map logicErrors=editor.getGraph().getLogicErrorMessages(); 55 String title=ResourceManager.getLanguageDependentString("DialogValidationReport"); 59 URL iconURL = ResourceManager.getResource("CheckOKImage"); 60 if (iconURL != null) checkOKIcon = new ImageIcon(iconURL); 61 62 if (editor.getWindow() instanceof JFrame) { 63 if (isModelOK){ 64 JOptionPane.showMessageDialog((JFrame)editor.getWindow(), 66 ResourceManager.getLanguageDependentString("InformationPackageIsValid"), 67 title, JOptionPane.INFORMATION_MESSAGE, checkOKIcon); 68 } else { 69 new ValidationErrorDisplay(xpdlSchemaValidationErrors,connectionErrors, 70 basicGraphConformanceErrors,graphConformanceErrors,logicErrors, 71 (JFrame)editor.getWindow(),title, false); 72 } 73 } else { 74 if (isModelOK) { 75 String OKMessage; 76 if (editor instanceof BlockActivityEditor) { 77 OKMessage=ResourceManager.getLanguageDependentString("InformationBlockIsValid"); 78 } else { 79 OKMessage=ResourceManager.getLanguageDependentString("InformationProcessIsValid"); 80 } 81 JOptionPane.showMessageDialog((JDialog)editor.getWindow(), 83 OKMessage, title, JOptionPane.INFORMATION_MESSAGE, checkOKIcon); 84 } else { 85 new ValidationErrorDisplay(xpdlSchemaValidationErrors,connectionErrors, 86 basicGraphConformanceErrors,graphConformanceErrors,logicErrors, 87 (JDialog)editor.getWindow(),title, false); 88 } 89 } 90 91 if (isModelOK) { 92 return; 93 } 94 editor.getGraph().clearSelection(); 96 Set wc=new HashSet(connectionErrors.keySet()); 98 wc.addAll(graphConformanceErrors.keySet()); 99 wc.addAll(logicErrors.keySet()); 100 WorkflowManager wm=editor.getGraph().getWorkflowManager(); 102 Set graphObjects=new HashSet(); 103 Iterator it=wc.iterator(); 104 while (it.hasNext()) { 105 Object obj=it.next(); 106 if (obj instanceof Activity) { 107 Object gAct=wm.getActivity(((Activity)obj).getID()); 108 if (gAct!=null) { 109 graphObjects.add(gAct); 110 } 111 } else if ((obj instanceof Start) || (obj instanceof End)) { 112 graphObjects.add(obj); 113 } else if (obj instanceof Transition) { 114 Object gTrans=wm.getTransition(((Transition)obj).getID()); 115 if (gTrans!=null) { 116 graphObjects.add(gTrans); 117 } 118 } else if (obj instanceof Participant) { 119 Object gPart=wm.getParticipant(((Participant)obj).getID()); 120 if (gPart!=null) { 121 graphObjects.add(gPart); 122 } 123 } 124 } 125 editor.getGraph().setSelectionCells(graphObjects.toArray()); 126 editor.valueChanged(null); 127 } 128 } 129 | Popular Tags |