KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > JaWEStatusBar


1 /* JaWE.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe;
12
13 import org.enhydra.jawe.graph.*;
14
15 import java.util.*;
16 import java.awt.*;
17 import javax.swing.*;
18
19 /**
20  * Status bar to show the information of graphs (in)validity.
21  */

22 public class JaWEStatusBar extends JPanel {
23
24    private AbstractEditor editor;
25
26    private JLabel message;
27
28    public JaWEStatusBar(AbstractEditor editor) {
29       super();
30       this.editor=editor;
31       setLayout(new BorderLayout());
32       message = new JLabel(" ");
33       message.setBorder(BorderFactory.createLoweredBevelBorder());
34       add(message,BorderLayout.CENTER);
35    }
36
37    public void updateMessage () {
38       if (!JaWEConfig.getInstance().getStatusBarStatus()) {
39          return;
40       }
41       if (!JaWEConfig.getInstance().getValidationStatus()) {
42          message.setText(ResourceManager.getLanguageDependentString("MessageValidationIsTurnedOff"));
43          return;
44       }
45       boolean isSchemaValidationError=!editor.getGraph().validateAgainsXPDLSchema();
46       boolean isConnectionError=false;
47       boolean isGraphConformanceError=false;
48       boolean isLogicError=false;
49       if (!isSchemaValidationError) {
50          isConnectionError=!editor.getGraph().checkConnections(false);
51       }
52       if (!isConnectionError) {
53          isGraphConformanceError=!editor.getGraph().checkGraphConformance(false);
54       }
55       if (!(isConnectionError || isGraphConformanceError)) {
56          isLogicError=!editor.getGraph().checkLogic(false);
57       }
58       boolean isModelOK=!(isSchemaValidationError || isConnectionError ||
59             isGraphConformanceError || isLogicError);
60       String JavaDoc msg="";
61       if (editor instanceof PackageEditor) {
62          if (isModelOK) {
63             msg=ResourceManager.getLanguageDependentString("InformationPackageIsValid");
64          } else {
65             if (isSchemaValidationError) {
66                msg=editor.getGraph().getBasicXPDLSchemaValidationErrorMessage();
67             } else if (isConnectionError) {
68                msg=editor.getGraph().getBasicConnectionErrorMessage();
69             } else if (isGraphConformanceError) {
70                msg=editor.getGraph().getBasicGraphConformanceErrorMessages().get(0).toString();
71                if (msg.length()==0) {
72                   msg="SWR1";
73                }
74             } else {
75                msg=editor.getGraph().getBasicLogicErrorMessage();
76             }
77          }
78       } else {
79          if (isModelOK) {
80             if (editor instanceof BlockActivityEditor) {
81                msg=ResourceManager.getLanguageDependentString("InformationBlockIsValid");
82             } else {
83                msg=ResourceManager.getLanguageDependentString("InformationProcessIsValid");
84             }
85          } else {
86             if (isSchemaValidationError) {
87                msg=editor.getGraph().getBasicXPDLSchemaValidationErrorMessage();
88             } else if (isConnectionError) {
89                msg=editor.getGraph().getBasicConnectionErrorMessage();
90             } else if (isGraphConformanceError) {
91                msg=editor.getGraph().getBasicGraphConformanceErrorMessages().get(0).toString();
92                if (msg.length()==0) {
93                   msg="SWR2";
94                }
95             } else {
96                msg=editor.getGraph().getBasicLogicErrorMessage();
97             }
98          }
99       }
100
101       message.setText(msg);
102    }
103
104    /**
105     * Returns the statusbar message.
106     */

107    public String JavaDoc getMessage() {
108       return message.getText() ;
109    }
110
111    /**
112     * Sets the statusbar message.
113     */

114    public void setMessage (String JavaDoc message) {
115       this.message.setText(message);
116    }
117
118 }
119
Popular Tags