FOZCIL: A FRAMEWORK FOR CONVERTING FORMAL SPECIFICATIONS IN

advertisement
FOZCIL: A FRAMEWORK FOR CONVERTING FORMAL SPECIFICATIONS IN
OBJECT-Z TO DESIGN CONTRACTS IN OO PROGRAMMING LANGUAGES
Nixon Sunny George
B.E, University of Mumbai 1996
PROJECT
Submitted in partial satisfaction of
the requirements for the degree of
MASTER OF SCIENCE
in
COMPUTER SCIENCE
at
CALIFORNIA STATE UNIVERSITY, SACRAMENTO
FALL
2009
FOZCIL: A FRAMEWORK FOR CONVERTING FORMAL SPECIFICATIONS IN
OBJECT-Z TO DESIGN CONTRACTS IN OO PROGRAMMING LANGUAGES
A Project
by
Nixon Sunny George
Approved by:
__________________________________, Committee Chair
Dr. Cui Zhang
__________________________________, Second Reader
Dr. Anne-Louise Radimsky
____________________________
Date
ii
Student: Nixon Sunny George
I certify that this student has met the requirements for format contained in the University format
manual, and that this Project is suitable for shelving in the Library and credit is to be awarded for
the Project.
__________________________, Graduate Coordinator
Dr. Cui Zhang
Department of Computer Science
iii
________________
Date
Abstract
of
FOZCIL: A FRAMEWORK FOR CONVERTING FORMAL SPECIFICATIONS IN
OBJECT-Z TO DESIGN CONTRACTS IN OO PROGRAMMING LANGUAGES
by
Nixon Sunny George
Formal languages use mathematical notations to capture the software specifications
precisely. Design by Contract is a technique used during software implementation to
ensure that the software conforms to the specifications. However, there is a semantic gap
in the development process between the specifications written in a formal language and
the design contracts written in an implementation language.
Automated conversion of formal specifications to the design contracts in object-oriented
implementation languages can help bridge this gap. Prior work has been done by
Sowmiya Ramkarthik and Sherri Sanders to develop such tools for the automated
conversions from the Object-Z formal language to the Java and Object PERL
implementation languages. However, each tool was custom built to work with only one
iv
or two such OO languages. Moreover, there has been significant redundant efforts in the
development of each of these tools.
FOZCIL (Framework for Object Z Conversion to Implementation Language) is a
framework that captures and implements these redundant language-independent features
as frozen spots (i.e., the fixed part of the framework) and the language-dependent
properties as hot spots (i.e., the extensible part of the framework). When the framework
accepts the language-dependent features for a target object-oriented language, it
generates a FOZCIL tool instance which, in turn, is capable of accepting Object-Z
specifications and converting the specifications to skeletal code with dynamicallycheckable design contracts written in that target language.
_______________________, Committee Chair
Dr. Cui Zhang
_______________________
Date
v
TABLE OF CONTENTS
Page
List of Tables ………………………………………………………………………………...viii
List of Figures………………………………………………………………………………….ix
Chapter
1. INTRODUCTION……………… ………………………….………………………….… 1
2. BACKGROUND………………….……………………………………………………….4
2.1
Formal languages and methodologies…………….……………………………4
2.2
Z and Object-Z…………………………………………………………………6
2.3
Design Contract and its various implementations……………………..………8
2.4
Automated conversion of Object-Z to skeletal code with design contracts…..12
2.5
Motivation for FOZCIL framework…………………………………………..13
3. FOZCIL ARCHITECTURE & DESIGN………………………………………………...16
4.
3.1
Process diagram…………….………………………………………………....16
3.2
Architecture……………………………………………………………………18
3.3
Language-independent frozen-spot of framework……………………..……...20
3.4
Language-dependent hot-spot of framework………………………………….22
3.5
OZ-to-IL converter………………………....…………………………………24.
IMPLEMENTATION………………………………………………………………….27
4.1
High-level implementation…………………….………………………………27
4.2
Detailed implementation……………………………..………………………...29
5. EXAMPLE USING FOZCIL …………………………………………………………….36
5.1
Framework GUI…………………….………………………………………….36
5.2
Language-dependent XML……………………………..……………………....43
vi
5.3
Tool Instance GUI…………………….………………………………………44
5.4
Conversion examples…………………………………………………………51
6. CONCLUSION AND FUTURE ENHANCEMENTS….………..……………………...58
APPENDICES ………………………..……………………………………………………..60
Appendix A. Language-dependent XML for Java language ………………………..……..61
Appendix B. Language-dependent XML for C# language…………………………………63
Appendix C. Project source code……………………………………………………..….....65
References……………………………………………………………………………….......201
vii
LIST OF TABLES
Page
Table 1: FOZCIL frozen-spot – Correspondence between Object-Z and OOPL…….21
Table 2: FOZCIL hot-spot – Language specific syntax…. …………………………..22
Table 3: Conversion in OZ-to-IL converter…………………………………………..26
Table 4: Description of Framework GUI classes……………..……………………....29
Table 5: Description of Framework model classes…………………………………...30
Table 6: Description of Tool GUI classes…………………………………………….31
Table 7: Description of Tool model classes…………………………………………..32
Table 8: Description of common model classes………………………………………33
Table 9: Description of helper classes………………………………………………...34
Table 10: Description of validator classes…………………………………………….35
Table 11: Description of configuration files…………………………………………..35
viii
LIST OF FIGURES
Page
Figure 1: Graphical representation of an Object-Z class……………………………………7
Figure 2: Precondition & postcondition in Design by Contract…………………………….9
Figure 3: Automated conversion approach………………………………………………....12
Figure 4: FOZCIL solution………………………………………………………………....15
Figure 5: Process diagram…………………………………………………………………..16
Figure 6: Architecture………………………………………………………………………18
Figure 7: Sample class template…………………………………………………………....24
Figure 8: Converted Java code for the sample class template……………………………...24
Figure 9: Oz-to-IL converter……………………………………………………………….25
Figure 10: MVC implementation in FOZCIL……………………………………………...27
Figure 11: Class diagram of FOZCIL……………………………………………………....28
Figure 12: Framework GUI – General pane………………………………………………..37
Figure 13: Framework GUI – File menu…………………………………………………....38
Figure 14: Framework GUI – Action menu………………………………………………...38
Figure 15: Framework GUI – Structure pane……………………………………………….39
Figure 16: Framework GUI – Type & type value pane (part 1)…………………………….41
Figure 17: Framework GUI – Type & type value pane (part 2)…………………………….42
Figure 18: Language-dependent XML………………… …………………………………..43
Figure 19: Tool GUI – Panel 1……………………………………………………………...45
Figure 20: Tool GUI – File menu…………………………………………………………...45
Figure 21: Tool GUI – Action menu………………………………………………………..45
Figure 22: Tool GUI – Panel 2……………………………………………………………...46
ix
Figure 23: Tool GUI – Expression Builder………………………………………………..47
Figure 24: Tool GUI – Panel 3 (part 1)…………………………………………………....48
Figure 25: Tool GUI – Panel 3 (part 2)…………………………………………………....49
Figure 26: Tool GUI – Panel 3 (part 3)…………………………………………………....50
Figure 27: Credit Card example – Object-Z specification………………………………...52
Figure 28: Credit Card example – Java skeletal code……………………………………..53
Figure 29: Credit Card example – C# skeletal code……………………………………….54
Figure 30: Library example – Object-Z specification……………………………………..55
Figure 31: Library example – Java skeletal code………………………………………….56
Figure 32: Library example – C# skeletal code……………………………………………57
x
1
Chapter 1
INTRODUCTION
Unlike the functional requirements that define the set of inputs, behaviors and outputs of
the system, the quality of software is often an unstated implicit requirement in software
engineering. The users of the software, irrespective of the problem domain, expect the
implemented software to adhere to a certain level of quality. However, for safety-critical
software systems like life-support systems and space application the software quality can
make all the difference between life and death or success and failure of a mission. In such
systems, software quality means that the software is correct with respect to its
specifications along with the other properties like reliability and performance.
Formal languages and methodologies are widely used in the engineering of such safety
critical systems. Formal languages with their precise mathematical notations are used to
specify the requirements and formal methodologies are used to verify the specifications
and iteratively refine them to implementations. Object-Z [5] is one such formal language
and is an object-oriented extension to the much popular Z notation.
Design by Contract™ (DbC) [1] is a term coined by Bertrand Meyer and is another
approach to designing quality software systems. This approach prescribes the use of
contracts among the various software components described as a set of invariants,
preconditions and postconditions. Dynamically and automatically checking the adherence
to these contracts ensures that the software as a whole adheres to its specifications. DbC
2
is incorporated in the design phase of software and is implemented using the target
language. DbC is inbuilt into the Eiffel™ programming language [7] but is not readily
available in most other object-oriented programming languages like Java and C#.
On one end of the spectrum, there exist the formal method languages like Object-Z that
do an excellent job in accurately capturing the specifications during the specification
phase of the software and on the other end are techniques such as DbC that are effective
in enforcing adherence to the design contract during the implementation phase.
Nevertheless, there still exists a disconnect between these two phases because the
specifications have to be manually and carefully converted to the corresponding design
contracts in the programming language. This manual step can introduce errors in the
engineering process and eventually jeopardize the quality of the software. Automated
conversion of Object-Z specifications to design contracts in the target implementation
language can help bridge this gap.
In the past, various tools were developed to do this automated conversion from Object-Z
to design contracts expressed at the programming language level. However, each of these
tools was custom built for one or maybe up to two target implementation languages. As a
result, there has been huge overlap in these independent efforts and as such, a framework
to create these automated tool instances for any target object-oriented programming
language could alleviate these concerns. FOZCIL (Framework for Object Z Conversion
to Implementation Language) is precisely such a framework developed to address this
3
concern. The language expert can use the framework to enter the language-dependent
features and the framework generates the tool instance for that target language. The user
can then use this tool instance for automated conversion of any Object-Z specification to
skeletal code with dynamically-checkable design contracts written in that target objectoriented language.
4
Chapter 2
BACKGROUND
The FOZCIL framework uses many ideas and concepts from the formal methods
landscape. Here we will look at some of the key ones.
2.1
Formal languages and methodologies
2.1.1 Why use formal languages?
As the size and complexity of software systems keep growing larger, ensuring key quality
characteristics like correctness and reliability is becoming a formidable challenge. The
old ad hoc method of programming is just not enough to address these ever growing and
pragmatic concerns. In cases where the software could cause life-endangering situation, a
more rigorous methodology for specifying and designing software systems is required.
The most obvious way of describing requirements is to use natural language; it is easily
readable and widely understood. However, as mentioned in [8] there are specific
problems we face when we describe computer systems in a natural language:

Ambiguity: Many words in natural language have multiple meanings and
interpretations depending on their context. In software development, this
ambiguity becomes a drawback.

Incompleteness: Natural language allows us to leave the details unspecified and
incomplete.
5

Contradiction: A set of requirements may contain statements at odds with each
other.
Thus, software requirements specified in natural language are often ambiguous,
incomplete and contradictory.
2.1.2 What are formal languages and methods?
Formal methods are based on the idea that computer programming is built upon a
relatively small number of fundamental concepts (for example; equality, arithmetic
operation etc.). It is therefore possible that specifications for programs can be given in a
formal mathematical notation [8].
The main characteristics of a formal language, in contrast to natural languages, are that it
is unambiguous, complete and non-contradictory (or sound).
Formal methodologies (or languages) can broadly be classified into two main categories:
 Constructive: where a mathematical model is constructed of the system.
 Behavioral: where a system is expresses in terms of properties of its inputs and
outputs
2.2
Z and Object-Z
6
Z is a formal notation based on standard set theory. It uses a stylized mathematical
notation to express the properties of a system [8]. It is a model-based specification that
uses implicit method for expressing the operations. Z specifications are structured using
Schemas.
The formal text of a Z specification is usually divided into a number of units, or blocks:

Basic type definitions: defining the values which constants and variables may
take,

Global constants and state variables: declaring the state and any constraints on it,

Schemas: defining the state and operations of the system.
There are four kinds of types in the language:

Basic types including predefined, given, and free types

Set types

Product types

Schema types
Object-Z is an extension of Z to facilitate specifications in an object-oriented style.
Object orientation emerged as a major programming paradigm due to the need for
handling complexity in large-scale software systems. It helped fulfill this need through a
combination of sound modular design and software reusability. In the same way, object
7
orientation can solve some of the scalability and structural problems of formal languages
[5]. Figure 1 that has been borrowed from [4] shows a graphical representation of an
Object-Z class and its various components.
Classname (generic parameters)
Visibility Lists (attributes, operations)
Inherited classes
Type definitions
Constants
State variables
State
State variables
Invariants
INIT
Initial state
Operation Schema
Modifier List (state variables)
In?: type
Out!: type
Preconditions
Postconditions
Statemements
Figure 1: Graphical representation of an Object-Z class
8
2.3
Design Contract and its various implementations
2.3.1 Design contracts
In 1969, the British computer scientist and logician C. A. R. Hoare proposed a formal
system for reasoning rigorously about the correctness of computer programs [9]. One of
the central features of this system of logic was the Hoare triple, which describes how the
execution of a piece of code changes the state of the system. A Hoare triple is of the form
{P} C {Q} where P and Q are assertions and C is a command. P is called the precondition
and Q the postcondition. If the precondition is met, then the command needs to establish
the postcondition. In 1986, Bertrand Meyer integrated parts of this logic theory into a
design approach for object-oriented programming languages and termed it Design By
Contract™ (DbC) [2].
According to the Design By Contract™ approach, if the execution of a certain task relies
on calling a subroutine to perform the sub-task, it is necessary to specify the relationship
between the caller and the callee. The mechanism for expressing such conditions is called
design contracts. The contract entitles both the caller and the callee to certain benefits and
obligations. The caller is obligated to satisfy certain conditions on calling the callee,
wherein the callee becomes obligated to guarantee the resulting condition. These design
contracts are defined in terms of preconditions and postconditions. As illustrated in
Figure 2, in any routine, its precondition expresses requirements that any call must satisfy
and the postcondition expresses properties that are ensured in return by the execution of
the call.
9
Routine_name(argument declaration)
<<precondition>>
Routine body
<<Postcondition>>
End Routine
Figure 2: Precondition & postcondition in Design by Contract
Another important element of DbC is the Invariant that describes the unchanging
property of a program or class. As a result, it must be satisfied after the creation of every
instance of the class and guaranteed at the entry and exit of every routine.
2.3.2 Various implementations of design contract
A number of programming languages allow programmers to specify the design contracts
using keywords that are built into the language. Most prominent of which is the Eiffel
language but also includes other languages such as Euclid [10], Alphard [11], Anna [12]
and SR 0 [13]. Unfortunately, most of the languages that have built-in design contracts
are not widely used. While built-in support would have been the easiest for the
programmer to adopt design contracts in their day-to-day programming, to so drastically
change the language would require considerable time and efforts to rewrite the compiler.
The fact that few languages include design contracts is evidence of the significant effort
needed to provide this built-in support. In the absence of such a built-in support for
10
design contracts among the popular languages, various other approaches have been tried
[14].
Code library approaches use a library of functions needed to support design contracts and
prescribes a pattern for using the library. The developer calls the functions at the
appropriate locations in the program to enforce the check of precondition, postcondition
and invariants. McFarlane [15] has used this approach for the C# language. This
approach has the advantage of allowing programmers to use standard language syntax.
No changes to the development, test, or deployment environments are needed nor are any
modifications required for the compilers. However, the major disadvantage of this
approach is that the programmers have to manually write the assertions and remember to
call the library functions.
Preprocessor approaches use a preprocessor to transform code containing formal
comments, comments or macros into the corresponding code with design contracts. The
iContract tool [16] for Java language uses this approach where the programmers use
JavaDoc comments to add the special contract directives. There are a couple of distinct
advantages to this technique. First, the compiler need not be rewritten. Secondly, the
design contracts remain separated from the code keeping these distinct concerns apart.
But, the major disadvantage to this approach is that because the original source code is
modified after translation, the line numbers of the compiler errors, debugging output and
exceptions do not correspond with the line numbers of the original program [17].
11
Behind-the-scenes approaches use dynamically-linked libraries (DLL) to incorporate the
contract-checking code into the source code at load-time, in a behind-the-scenes manner,
so that the programmer never sees the actual contract-checking code. JMSAssert [18]
uses this technique by including contract tags in the code. A preprocessor then converts
this tag into a special contract file written in JMScript. A special extension DLL
containing the JMScript interpreter enforces the contract by executing the “triggers”
contained within this contract file. A benefit to this approach is that only the contract tags
are visible in the code whereas the contract translation and enforcement are done out-ofband without affecting the compiler output or the debugging. This approach does have its
drawbacks though, primarily being that the programmers have to learn some proprietary
tag language.
Automatic conversion of specification approaches automatically derive the design
contracts from the formal specification for the software. The skeletal target code is
automatically generated which along with the design elements of the program
additionally contains the contract-related assertions. One of the advantages of this
approach is that the compiler need not be rewritten since we are not augmenting the
language in any way. The other distinct advantage is that since the design contracts are
automatically derived from the formal specification any inadvertent errors in writing the
design contract assertions are completely avoided. By providing a one-to-one relationship
between the formal specification and the design contracts of the implementation code,
12
this approach is very effective in helping the programmer bridge the semantic gap
between the formal specification and the executable code.
2.4
Automated conversion of Object-Z to skeletal code with design contracts
Formal specifications written in Object-Z are a perfect candidate for the automated
conversion approach. Because Object-Z follows the object-oriented style, it is
straightforward to convert it to any OO programming language as illustrated in Figure 3.
Formal
specifications
Automatic
Conversion
Skeletal code
With
Dynamically-checkable
Design contracts
Figure 3: Automated conversion approach
Sowmiya Ramkartik et al [3] have used this approach to develop a tool to do the
automated conversion from a subset of Object-Z to skeletal code in the Java
programming language. Sherri Sanders [4] has enhanced this tool to do the automated
conversion from a larger subset of Object-Z, including the Set data type, to both the Java
and the PERL programming languages. Both of these tools allow the users to enter the
Object-Z specification using a GUI, which further assists them with their understanding
13
of Object-Z schema calculus and the relationship between formal methods and OO
programming languages.
2.5
Motivation for FOZCIL framework
2.5.1 What is a framework?
A software framework, in computer programming, is an abstraction in which common
code providing generic functionality can be selectively overridden or specialized by user
code to provide specific functionality [6].
As mentioned by the authors in [6], software frameworks have distinguishing features
that separate them from libraries or normal user applications:

default behavior - A framework has a default behavior. This default behavior
must actually be some useful behavior and not a series of no-ops.

extensibility - A framework can be extended by the user usually by selective
overriding or specialized by user code providing specific functionality

non-modifiable framework code - The framework code, in general, is not allowed
to be modified. Users can extend the framework, but not modify its code.
According to Pree [19], software frameworks consist of frozen spots and hot spots.
Frozen spots define the overall architecture of a software system including its basic
components and the relationships between them. These remain unchanged (frozen) in any
instantiation of the application framework. Hot spots represent those parts where the
14
programmers using the framework add their own code in order to add the functionality
specific to their own project.
2.5.2 Problem with current automated conversion tools
As mentioned before, Sowmiya Ramkartik et al [3] and Sherri Sanders et al [4] have
created separate tools to do the automated conversion from Object-Z to skeletal code with
dynamically-checkable design contracts written in programming languages. Both these
tools had to be developed from scratch by each of them although the tools shared many
common features and functionality. Some of these common features are:
 GUI presentation logic to capture the Object-Z schema specification,
 Conversion rules from Object-Z to design contracts in the target language.
2.5.3 Solution with FOZCIL
These common, language-independent features, as mentioned in the preceding section,
need not be re-developed each time and it is rather convenient for a developer to instead
start with a framework that captures these language-independent features as the frozenspot of the framework. The developer then uses the framework to enter only the
language-dependent features of the target programming language that becomes the
extensible, hot-spot of the framework. The tool instance thus generated is able to handle
the automated conversion from Object-Z to skeletal code with dynamically-checkable
design contracts in that particular target programming language. Driven by this need,
15
FOZCIL framework has been developed. Figure 4 shows how the FOZCIL framework
provides the solution.
FOZCIL
Tool Instance 1
(OZ to C#)
languagedependant
features
FOZCIL
framework
FOZCIL
Tool Instance 2
(OZ to PERL)
FOZCIL
Tool Instance 3
(OZ to Java)
Figure 4: FOZCIL solution
16
Chapter 3
FOZCIL ARCHITECTURE & DESIGN
In this chapter, we will take an in depth look at the FOZCIL framework. More
specifically, we will look at its process flow and its system architecture. We will also take
a detailed look at the frozen-spot and the hot-spot of the FOZCIL framework.
3.1
Process diagram
Figure 5 depicts the various actors and the steps involved in using FOZCIL.
1
2
3
Enters Languagedependent
features
Language
expert
4
Saves Languagedependent
features
5
6
Languagedependent
XML
Generate FOZCIL
Tool Instance
Framework
GUI
FOZCIL
Tool
Instance
7
OZ to IL
user
8
Enters Object-Z
Schemas
Saves Object-Z
Object-Z
XML
11
12
Tool (Object-Z)
GUI
9
Figure 5: Process diagram
10
Convert Object-Z to
Implementation
Language (w/
dynamically-checkable
design contracts)
13
Skeletal
code w/
dynamicallycheckable
Design
Contracts
14
17
Each of the steps is further described here:
1) The Language expert initiates the interaction with the FOZCIL framework. This
user has a sound knowledge of both the Object-Z language and the target
programming language features.
2) The expert enters the language-dependent features.
3) The language-dependent features are entered through the Framework GUI
provided by the framework. This is a series of screen panels.
4) The expert saves the language-dependent features.
5) The language-dependent features are saved into an internal XML file.
6) The expert after entering all the data generates the FOZCIL tool instance.
7) This tool instance is a Java Archive (JAR) package file that can be executed on
any computer that has the Java SE runtime.
8) The OZ-to-IL user now uses this generated tool instance. This is a user who has
access to the requirements of the software system being specified and with
sufficient knowledge of Object-Z specification language.
9) OZ-to-IL user enters the Object-Z schema specification into the tool.
10) The specification is entered using the Tool GUI provided by the tool. This is a
series of screen panels.
11) The user saves the Object-Z specification.
12) The Object-Z specification is saved into a XML file.
13) The user finally selects the action to do the automated conversion.
18
14) The tool writes the converted, skeletal code with dynamically-checkable design
contracts.
The FOZIL tool instance generated in step #6 is a standalone tool. The OZ-to-IL user
performs the automated conversion of several Object-Z specifications using the same tool
instance. For each conversion, the OZ-to-IL user repeats the steps from #8 to #14
mentioned before.
3.2
Architecture
The architecture diagram in Figure 6 describes the various components of the FOZCIL
framework and the relationship between those components.
6
Framework
GUI
7
Tool
Builder
Framework
Control System
4
Tool instance
JAR
DOM
XML Writer
Languagedependent
XML
1
2
Tool
Instance
GUI
8
3
XML Factory
SAX
XML Reader
10
Language
independent
13
9
Oz-to-IL
Converter
Language
dependent
Figure 6: Architecture
Object-Z
Specification
XML
Tool
Control System
12
5
14
Skeletal code
w/
Design
contracts in
programming
language
11
15
19
Here is a brief description of each of the numbered components:
1) The framework GUI is a set of Java Swing screen panels used to capture the
language-dependent features. There are also menu options to load the existing
language-dependent internal XML file, save the screen data to the internal XML
file and create tool instance.
2) The framework Control System is the controller for the framework. It manages
the display of the GUI presentation layer, flow of data within the framework and
coordination of the other components.
3) The XML Factory is a factory for various XML processors like the XML Reader
and XML Writer.
4) The XML Writer handles the creation and writing of XML files. It uses a DOM
builder to do the writing of XML content.
5) The Language-dependent XML is the persistent representation of the languagedependent features entered through the Framework GUI. It is an internal file and
is not visible outside of FOZCIL.
6) The Tool Builder is the component that generates the tool instance as a JAR file.
It uses build.xml for the building instructions.
7) The Tool instance JAR is an executable file that can be run to exercise the tool
instance.
20
8) The Tool GUI is a set of Java Swing screen panels used to capture the Object-Z
specification. Additionally, it has menu options to save this data and convert it to
the skeletal code.
9) The Tool Control System is the controller for the tool instance. It manages display
of the Tool GUI, handles data flow within the tool sub-system and coordinates the
other components.
10) The XML Reader handles the reading of XML content. It uses a SAX reader to
achieve this.
11) The Object-Z specification on save is persisted into a XML file.
12) The OZ-to-IL converter is the component that handles the conversion of Object-Z
specification to the skeletal code with dynamically-checkable design contracts
written in the programming language. It has code logic to handle conversion of
both the language-independent and the language-dependent features.
13) The language independent component is described in detail in Section 3.3.
14) The language dependent component is described in detail in Section 3.4.
15) Skeletal code is the output of the tool that contains the skeletal code with
dynamically-checkable design contracts written in the target programming
language.
3.3
Language-independent frozen-spot of framework
As mentioned before, the frozen spot is the part of the framework that does not change. In
case of FOZCIL, the frozen spot comprises of:
21

Object-Z gathering logic including the Tool Instance GUI

Object-Z persisting logic including the XML Factory and other XML components

Language-independent component of the OZ-to-IL converter module.
The language-independent component of the OZ-to-IL converter module encapsulates the
conversion rules for the general object-oriented constructs of the Object-Z formal
language. Table 1 lists the conversion rules for the various OO constructs from Object-Z
to any OO implementation programming language.
Object-Z Language
Schema/Class
OO Implementation Programming
Language
Class
Operation
Method
Visibility list
Visibility of individual construct
State variable
Class property
Constants
Class property
Free types
Enumeration
Init operation
Class constructor
Input variable
Method argument
Output variable
Method return type
Class Invariant
Precondition
ClassInvariant method with corresponding
calls from the methods to it
Conditional (If) logic
Postcondition
Conditional (If) logic
Table 1: FOZCIL frozen-spot – Correspondence between Object-Z and OOPL
22
3.4
Language-dependent hot-spot of framework
This is the part of the framework that can be extended by the user. In case of FOZCIL,
the language-dependent hot-spot of the framework comprises:

Language-dependent XML gathered by the Framework GUI

Language-dependent component of the OZ-to-IL converter module.
This language-dependent component of the OZ-to-IL converter module encapsulates the
conversion rules for language-specific syntax of the target programming language. Table
2 enumerates the various language-specific syntax with Java language as the example.
OO Programming Language Syntax
Java Equivalent
Output file extension
Class template
.java
<VISIBILITY> class <NAME>
{
<BODY>
}
<VISIBILITY> <RETURNTYPE>
<NAME>(<ARGS>)
{
<BODY>
}
, (comma)
<VISIBILITY> <TYPE> <NAME>
<VISIBILITY> enum <NAME>
{<VALS>}
; (semicolon)
System.out.println(\"<COMMENT>\")
Method template
Method argument separator
Variable declaration template
Enumeration declaration template
Statement end symbol
Print statement template
Table 2: FOZCIL hot-spot – Language specific syntax
23
OO Programming Language Syntax
Java Equivalent
If-condition template
If (<CONDITION>)
{
<BODY>
}
return <EXPRESSION>
Int
Int
Conditional (If) logic
+
/
*
==
!=
<
<=
>
>=
True
False
Return statement template
Integer type: N equivalent
Integer type: Z equivalent
Integer type: Arithmetic operator
+
/
*
=
≠
<
≤
>
≥
Boolean type: true equivalent
Boolean type: false equivalent
Boolean type: Operator
¬
v
^
Set type: operator templates
Is-member-of
Set equal
Union
Intersection
Cardinality
Subset
!
||
&&
<NAME2>.contains(<NAME1>)
<NAME1>.equals(<NAME2>)
<NAME1>.addAll(<NAME2>)
<NAME1>.retainAll(<NAME2>)
<NAME1>.size()
<NAME2>.containsAll(<NAME1>
Table 2: FOZCIL hot-spot – Language specific syntax (continued)
24
The templates used in the language-dependant features use tokens as placeholders. For
example in Figure 7, the class template is:
<VISIBILITY> class <NAME>
{
<BODY>
}
Figure 7: Sample class template
Here VISIBILITY, NAME, BODY are the tokens delimited by ‘<’ and ‘>’. This template
when converted to a Java class looks as shown in Figure 8:
Public class CreditCard
{
/*
*
Classbody goes here
*
*/
}
Figure 8: Converted Java code for the sample class template
3.5
OZ-to-IL converter
The OZ-to-IL converter, as indicated before, has both a language-independent component
and a language-dependent component. Both the components contribute to the conversion
of the Object-Z specification to skeletal code written in the implementation language.
Figure 9 illustrates this concept.
25
Languagedependent
data XML
Languagedependent
component
Object-Z
specifications
Lang
uage
-s
synt pecific
ax
OZ-to-IL
Converter
Languageindependent
component
e cla
s lik
truct etc.
s
n
o
c
od
OO
meth
ss ,
Skeletal code
with
dynamicallycheckable
design contracts
Figure 9: Oz-to-IL converter
As shown above, the language-dependent component reads in the language-specific
syntax from the language-dependent XML file and uses that information to generate the
language-specific parts of the skeletal code. On the other hand, the language-independent
component generates the general object-oriented constructs like the class, method, statement etc.
of the skeletal code. Together, they compose the skeletal code as further illustrated in Table 3
using various examples:
26
Object Z
specification
Snippet
Converted
objectoriented
semantic
Converted language-specific
syntax
Generated code for Java
programming language
Class Schema
|-- Library—
|
|------------
Class
Class template:
Public class Library
{
/** body here **/
}
Operation
Method
<VISIBILITY> class <NAME>
{
<BODY>
}
|--Checkout—
| book?BOOK
|---------------|----------------
State variable
Method template:
<VISIBILITY>
<NAME>(<ARGS>)
{
<BODY>
}
public Checkout(BOOK
book?)
{
/* method body */
}
Class
Property
Declaration
Variable declaration template:
N type
Variable
type
N-type equivalent: int
int
Boolean type:
NOT (¬)
operator
operator
Boolean operator NOT
equivalent: !
!
Set type Ismember-of
operator
operator
Set Is-member-of template:
library.contains(book?)
| count: Z
private int count
VISIBILITY> <TYPE>
<NAME>
<NAME2>.contains(<NAME1>)
book?
(IsMemberOf)
library
Table 3: Conversion in OZ-to-IL converter
27
Chapter 4
IMPLEMENTATION
This chapter outlines the various implementation details of the FOZCIL framework.
4.1
High-level implementation
FOZCIL is implemented as a Swing desktop application that runs on the Java SE [17]
platform. It uses MVC design pattern [21] as shown in Figure 10. This pattern isolates
domain logic (model) from input and presentation (view), permitting independent
development, testing and maintenance of each layer.
View
Languagedependent
GUI
Object-Z
GUI
Controller
Framework
Control System
Tool
Control System
OzSpecificationBean
Model
LanguageDependentBean
OZtoILconverter
XMLFactory
FOZCIL
Common
Classes
Configuration
XMLReader
XMLWriter
Helper classes
Swing
DOM & SAX
JRE Library
JavaBean
I/O
Java JVM
Figure 10: MVC implementation in FOZCIL
28
The class diagram in Figure 11 describes the implementation code structure of FOZCIL
by showing its classes and the relationships between the classes.
Figure 11: Class diagram of FOZCIL
29
4.2
Detailed implementation
Table 4 is a detailed description of the classes that comprise the FOZCIL Framework
GUI. These classes in the edu.csus.fozcil.framework package define the functionality for
the screens that capture the language-dependent features.
Class Name
Functionality
Framework GUI (edu.csus.fozcil.framework package)
MainFrmkJFrame
GeneralFrmkJPanel
StructureFrmkJPanel
TypeFrmkJPanel
Main JFrame container for the framework
GUI screens. It manages switching of
child JPanels, holds the menu options for
Save, Load, Generate Tool Instance and
initializes the controller.
Calls GeneralFrmkJPanel.
JPanel that captures the general languagedependent properties.
Calls StructureFrmkJPanel.
JPanel that captures the structural
templates for the class, method and
various statements.
Calls TypeFrmkJPanel.
JPanel that captures the type and type
values for the Integer, Boolean and Set
data types. On OK, it prompts the
MainFrmkJFrame to display appropriate
dialog boxes.
Table 4: Description of Framework GUI classes
30
Table 5 is a detailed description of the classes that comprise the FOZCIL Framework
model. These classes in the edu.csus.fozcil.framework package define the framework’s
control system and the classes for the XML conversion of the language dependent
features.
Class Name
Functionality
Framework model (edu.csus.fozcil.framework package)
FrmkControlSystem
Controller for the framework sub-system.
It controls the GUI and all the other data
and service components in the framework
model. It also reads in the configuration
files on initialization.
LanguageDependentDomBuilder
DOM builder for the language-dependent
features.
LanguageDependentContentHandler
SAX content handler for the languagedependent XML.
Table 5: Description of Framework model classes
31
Table 6 is a detailed description of the classes that comprise the FOZCIL Tool GUI.
These classes in the edu.csus.fozcil.tool package define the functionality for the screens
that capture the Object-Z specification.
Class Name
Functionality
Tool GUI (edu.csus.fozcil.tool package)
MainToolJFrame
TypeToolJPanel
StateToolJPanel
OperationToolJPanel
ExpressionBuilderToolJDialog
Table 6: Description of Tool GUI classes
Main JFrame container for the tool GUI
screens. It manages switching of child
JPanels, holds the menu options for Save,
Load, Convert OZ-to-IL, Generate OZ
docs and initializes the tool controller.
Calls TypeToolJPanel.
JPanel that captures the user, constant and
free types of the Object-Z specification.
Calls StateToolJPanel.
JPanel that captures the state variable,
invariant and Init operation of the ObjectZ specification.
Calls OperationToolJPanel.
JPanel that captures the operations of the
Object-Z specification along with the
modifiers list, input, output, preconditions
and postconditions of each operation. On
OK it prompts the MainToolJFrame to
display appropriate dialog boxes.
JDialog that builds the expression for the
invariant, precondition and postcondition.
It provides an editing area where only the
appropriate variable options along with the
operators are available.
32
Table 7 is a detailed description of the classes that comprise the FOZCIL Tool model.
These classes in the edu.csus.fozcil.tool package define the tool instance’s control system
and the classes for XML conversion of the Object-Z specification.
Class Name
Functionality
Tool model (edu.csus.fozcil.tool package)
ToolControlSystem
Controller for the tool sub-system. It
controls the GUI and all the other data and
service components in the tool
model. It also reads in the configuration
files on initialization.
OzSpecificationDomBuilder
DOM builder for the Object-Z
specification.
OzSpecificationContentHandler
SAX content handler for the Object-Z
specification.
OZtoILconverter
Table 7: Description of Tool model classes
Converter for the language-independent
and language-dependent features of the
framework. It reads in the languagedependent file, does the conversion and
provides the converted skeletal code with
design contracts written in the target
programming language.
33
Table 8 is a detailed description of the classes that comprise the FOZCIL common model.
These classes in the edu.csus.fozcil.bean package define the various JavaBeans that
represent the language-dependent features and the Object-Z specification.
Class Name
Functionality
Common model(edu.csus.fozcil.bean package)
LanguageDependentBean
In-memory representation of the languagedependent features.
OzSpecificationBean
In-memory representation of the Object-Z
specification. It is composed of
OzOperationBean and OzVariable.
OzOperationBean
In-memory representation of the Object-Z
Operations data.
OzVariable
In-memory representation of the variable
data.
Table 8: Description of common model classes
34
Table 9 is a detailed description of the various helper classes. These classes in the
edu.csus.fozcil and edu.csus.fozcil.helper packages define the various helper classes used
throughout the FOZCIL framework for writing XML, reading XML, generating tool
instance JAR, defining constants and defining exception.
Class Name
Functionality
Helpers (edu.csus.fozcil.helper & edu.csus.fozcil package)
XmlFactory
Factory class for XmlReader, XmlWriter
and XmlTransformer objects.
XmlWriter
Interface representing the XML writerelated service methods.
DomXmlWriter
XmlTransformer
BuildFileExecutor
Concrete class implementing the
XmlWriter interface. It uses DOM for
writing.
Class that encapsulates the Java XSLT. It
is used for writing the DOM object.
Generator of the tool instance as an
executable JAR file. Its uses ANT’s [22]
API along with the
build_create_fozcil_tool.xml to execute
ANT instructions.
Constants
Class encapsulating all the constants used
in the framework.
FozcilException
Generic framework exception class.
Table 9: Description of helper classes
35
Table 10 is a detailed description of the validator classes used by the GUI. These classes
in the edu.csus.fozcil.validator package are used for handling validation of the various
GUI elements.
Class Name
Functionality
GUI validators (edu.csus.fozcil.validator package)
AbstractValidator
Generic validator abstract class that
implements the InputVerifier [23].
NotEmptyValidator
Concrete validation class that validates an
empty JTextfield.
Table 10: Description of validator classes
Table 11 is a detailed description of the configuration files. These files in the
edu.csus.fozcil.config package are used to configure the FOZCIL framework.
Class Name
Functionality
Configuration files (edu.csus.fozcil.config package)
App.properties
Application configuration file
Log4j.properties
Log4J [24] logger configuration file.
Table 11: Description of configuration files
36
Chapter 5
EXAMPLE USING FOZCIL
In this chapter, we will present the FOZCIL framework in action. We will walk through
examples of using the framework to create instances of the tool for the Java and C#
programming languages. We will then exercise the tool instances to do automated
conversion of two sample Object-Z specifications. We will explain the details at each
step using screenshots that will help clarify the usage pattern of the FOZCIL framework.
5.1
Framework GUI
The following screen shots show the series of Framework GUI screens used for entering
the language-dependent features.
37
Figure 12: Framework GUI – General pane
Figure 12 is the starting panel used to enter general information of the language like the
language name and the file extension for the generated skeletal code.
38
Figure 13: Framework GUI – File menu
As shown in Figure 13, the File menu has an option to load previously entered languagedependent features from the internal language-dependent XML file. There is also an
option to save the newly entered features.
Figure 14: Framework GUI – Action menu
As shown in Figure 14, the Action menu has a single menu option to generate the tool
instance. This creates a packaged executable JAR file that is portable and deployable as a
single code unit.
39
Figure 15: Framework GUI – Structure pane
Figure 15 is the next panel that gathers the various structural templates pertaining to the
programming language. Here is a list of the various language dependent features gathered
here:
40
 Class template to convert the schema to a class,
 Method template to convert the INIT and operations to methods,
 If template to convert the preconditions and postconditions to design contract
conditional checks,
 Variable declaration and Object constructor template to convert constant types and
state variables to class properties and local variables, and
 Enumeration template to convert free types to enumeration.
41
Figure 16: Framework GUI – Type & type value pane (part 1)
Figure 16 is the next panel that gathers the type and type value equivalents for the
language. It is scrollable to fit the user’s computer screen and it has sections for the
Integer, Boolean and Set data types. The above screen shot, in particular, shows the
Integer data type elements.
42
Figure 17: Framework GUI – Type & type value pane (part 2)
Figure 17 is a screen shot that shows the same Type panel scrolled down to display the
Boolean and Set data type elements. The Set type operators are made up of templates
where NAME1 and NAME2 are tokens.
43
5.2
Language-dependent XML
Figure 18 below shows an abbreviated version of the language-dependent XML file
generated and saved by the FOZCIL framework. It contains the language-dependent
features entered using the Framework GUI.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<languageDependent>
<generalData>
<languageName>Java</languageName>
<languageFileExtension>java</languageFileExtension>
</generalData>
<structuralData>
<classTemplate><![CDATA[
<VISIBILITY> class <NAME>
{
<BODY>
}
]]></classTemplate>
<variableDeclTemplate><![CDATA[
<VISIBILITY> <TYPE> <NAME>
]]></variableDeclTemplate>
:
:
</structuralData>
<typeData>
<typeIntegerData>
<typeOzNEquivalent><![CDATA[int]]></typeOzNEquivalent>
<typeOzZEquivalent><![CDATA[int]]></typeOzZEquivalent>
<operatorAssignment><![CDATA[=]]></operatorAssignment>
:
:
</typeIntegerData>
<typeBooleanData>
<typeIlBoolEquivalent><![CDATA[boolean]]></typeIlBoolEquivalent>
:
:
</typeBooleanData>
<typeSetData>
<setTypeEquivalent><![CDATA[HashSet]]></setTypeEquivalent>
<isMemberTemplate><![CDATA[<NAME2>.contains(<NAME1>)]]></isMemberTemplate>
:
:
</typeSetData>
</typeData>
</languageDependent>
Figure 18: Language-dependent XML
All the data is saved in either text or CDATA XML element types. Appendix A lists the
entire language-dependent XML file for the Java language and Appendix B lists the file
for the C# language.
44
5.3
Tool Instance GUI
The following screen shots show the various screens used by the Tool GUI to capture the
Object-Z specification.
Figure 19: Tool GUI – Panel 1
Figure 19 shows the panel of the Tool GUI used to enter the schema name, user types,
constant types and free types. The example shows a schema called Library with one user
type called BOOK, one constant type called MAX with a value of 10 and one free type
called Status.
45
Figure 20: Tool GUI – File menu
As shown in Figure 20, the File menu has options to load an existing Object-Z
specification file, save the newly entered Object Z specification or exit the tool GUI.
Figure 21: Tool GUI – Action menu
As shown in Figure 21, the Action menu has options to do the automated conversion of
the Object-Z specification to skeletal code and an option to generate documentation that
displays the Object-Z specification in a readable format.
46
Figure 22: Tool GUI – Panel 2
Figure 22 shows the panel that gathers the state variables, class invariant and INIT
operation. The example shows one state variable called lib that is a Set of type BOOK.
Also are shown two class invariant constraints and one INIT statement.
47
Figure 23: Tool GUI – Expression Builder
Figure 23 is the Expression Builder dialog for building the various expressions for the
invariant, INIT operation, preconditions and postconditions. The variable dropdown lists
all the variable names that are applicable in the current context. The operator dropdown
lists the complete list of Integer, Boolean and Set operators.
48
Figure 24: Tool GUI – Panel 3 (part 1)
Figure 24 shows the panel that gathers the Operation information. On editing an
operation, the data belonging to that operation is loaded in the ‘Add/Update Operation’
sub-section. This example shows two already added operations called AddBook and
RemoveBook.
49
Figure 25: Tool GUI – Panel 3 (part 2)
Figure 25 shows the Add/Update Operation section. This screen shot shows the fields
used to capture the modifiers and input variables of an Operation. In this example, the
AddBook operation is shown with one delta modifier called lib and an input variable
called oneBook? of the type BOOK.
50
Figure 26: Tool GUI – Panel 3 (part 3)
Figure 26 shows the fields used to capture the output variables, precondition and
postcondition of the operation. In the example shown there is no output variable, one
precondition and two postconditions. The precondition and postcondition are composed
using the Expression Builder.
51
5.4
Conversion examples
We will look at two examples of automated conversions of Object Z specifications to
skeletal code with dynamically checkable design contracts written in the Java and C#
programming languages. The two examples are the Credit Card system and the Library
system. For each example, we will first look at the Object-Z specification of the system.
We will then look at the converted skeletal code for the Java and C# languages.
52
5.4.1
Example 1: Credit Card system
Figure 27 shows the Object-Z specification of the Credit Card system.
Class Schema Name:
CreditCard
User Type:
Constant Type:
| LIMIT : N
|----------------------------------------| LIMIT = 5000
State Variable:
|----------------------------------------| balance : Z
|----------------------------------------| Pre: balance + LIMIT (>=) 0
|----------------------------------------INIT (constructor):
|-----------INIT-------------------------| Pre: balance (=) 0
|----------------------------------------Operation Schema(s):
|-----------WithdrawAvail----------------------|
| Delta (balance)
| amount! : N
|----------------------------------------| Pre: amount! = balance + LIMIT
| Pre: balance' = 0 - LIMIT
|----------------------------------------|-----------Deposit----------------------|
| Delta (balance)
| amount? : N
|----------------------------------------| Pre: balance' = balance + amount?
|----------------------------------------|-----------Withdraw----------------------|
| Delta (balance)
| amount? : N
|----------------------------------------| Pre: amount? (<=) balance + LIMIT
| Post: balance' = balance - amount?
|-----------------------------------------
Figure 27: Credit Card example – Object-Z specification
53
Figure 28 shows the automatically converted skeletal code output of the Credit Card
system generated by the FOZCIL Tool instance and written in Java language.
public class CreditCard {
public int LIMIT = 5000;
public int balance;
public CreditCard() {
balance = 0;
if (!(ClassInvariant()))
{
System.out.println("Postcondition failed");
}
}
public boolean ClassInvariant() {
if ((balance + LIMIT >= 0))
{
return true;
}
System.out.println("ClassInvariant failed");
return false;
}
public Withdraw( int amount?) {
int old_balance = balance;
if (!(ClassInvariant() && (amount? <= balance + LIMIT)))
{
System.out.println("Withdraw method:Precondition failed");
}
System.out.println("Withdraw method:Precondition passed");
System.out.println("Method body goes here");
if (!(ClassInvariant() && (balance != old_balance - amount?)))
{
System.out.println("Withdraw method:Postcondition failed");
}
System.out.println("Withdraw method:Postcondition passed ");
}
public Deposit( int amount?) {
int old_balance = balance;
if (!(ClassInvariant()))
{
System.out.println("Deposit method:Precondition failed");
}
System.out.println("Deposit method:Precondition passed ");
System.out.println("Method body goes here");
if (!(ClassInvariant() && (balance != old_balance + amount?)))
{("AddBook method:
System.out.println("Deposit method:Postcondition failed");
}
System.out.println("Deposit method:Postcondition passed ");
}
public
WithdrawAvail( int amount!) {
int old_balance = balance;
if (!(ClassInvariant()))
{
System.out.println("WithdrawAvail:Precondition failed");
}
System.out.println("WithdrawAvail method:Precondition passed ")
System.out.println("Method body goes here");
if (!(ClassInvariant() && (amount! != old_balance + LIMIT) &&
(balance != 0 - LIMIT)))
{
System.out.println("WithdrawAvail:Postcondition failed");
}
System.out.println("WithdrawAvail method:Postcondition passed ");
}
}
Figure 28: Credit Card example – Java skeletal code
54
Figure 29 shows the automatically converted skeletal code output of the Credit Card
system generated by the FOZCIL Tool instance and written in C# language.
public class CreditCard
{
public int LIMIT = 5000;
public int balance;
public CreditCard() {
balance = 0;
if (!(ClassInvariant())) {
Console.WriteLine("Postcondition failed");
}
}
public boolean ClassInvariant() {
if ((balance + LIMIT >= 0))
{
return true;
}
Console.WriteLine("ClassInvariant failed");
return false;
}
public Deposit( int amount?) {
int old_balance = balance;
if (!(ClassInvariant()))
{
Console.WriteLine("Deposit method:Precondition failed");
}
Console.WriteLine("Deposit method:Precondition passed");
Console.WriteLine("Method body goes here");
if (!(ClassInvariant() && (balance == old_balance + amount?)))
{
Console.WriteLine("Deposit method:Postcondition failed");
}
Console.WriteLine("Deposit method:Postcondition passed ");
}
public WithdrawAvail( int amount!) {
int old_balance = balance;
if (!(ClassInvariant()))
{
Console.WriteLine("WithdrawAvail method:Precondition
failed");
}
Console.WriteLine("WithdrawAvail method:Precondition passed ");
Console.WriteLine("Method body goes here");
if (!(ClassInvariant() && (amount! == old_balance + LIMIT) &&
(balance == 0 - LIMIT)))
{
Console.WriteLine("WithdrawAvail:Postcondition failed");
}
Console.WriteLine("WithdrawAvail:Postcondition passed ");
}
public Withdraw( int amount?) {
int old_balance = balance;
if (!(ClassInvariant() && (amount? <= balance + LIMIT)))
{
Console.WriteLine("Withdraw method:Precondition failed");
}
Console.WriteLine("Withdraw method:Precondition passed ");
Console.WriteLine("Method body goes here");
if (!(ClassInvariant() && (balance == old_balance - amount?)))
{
Console.WriteLine("Withdraw method:Postcondition failed");
}
Console.WriteLine("Withdraw method:Postcondition passed ");
}
}
Figure 29: Credit Card example – C# skeletal code
55
5.4.2
Example 2: Library system
Figure 30 shows the Object-Z specification of the Library system.
Class Schema Name:
Library
User Type:
[BOOK]
Free Type:
status := CHECKEDIN|CHECKEDOUT
Constant Type:
| MAX : Z
|----------------------------------------| MAX = 10
State Variable:
|----------------------------------------| lib : Fset BOOK
|----------------------------------------| Pre: #lib > 0
| Pre: #lib (<=) MAX
|----------------------------------------INIT (constructor):
|-----------INIT-------------------------| Pre: lib (=) {}
|----------------------------------------Operation Schema(s):
|-----------AddBook----------------------|
| Delta (lib)
| oneBook? : BOOK
|----------------------------------------| Pre: oneBook? (IsNotMemberOf) lib
| Post: lib' (=) ( lib (Union) oneBook? )
| Post: #lib' = #lib + 1
|----------------------------------------|-----------RemoveBook----------------------|
| Delta (lib)
| oneBook? : BOOK
|----------------------------------------| Post: oneBook? (IsMemberOf) lib
| Post: lib (=) ( lib' (Union) oneBook? )
| Post: #lib' = #lib - 1
|-----------------------------------------
Figure 30: Library example – Object-Z specification
56
Figure 31 shows the automatically converted skeletal code output of the Library system
generated by the FOZCIL Tool instance and written in Java language.
public class Library
{
public int MAX = 10;
public enum status { CHECKEDIN,CHECKEDOUT };
public HashSet lib;
public
{
Library()
lib = new HashSet();
if (!(ClassInvariant()))
{
System.out.println("Postcondition failed");
}
}
public boolean ClassInvariant()
{
if ((lib.size() > 0) && (lib.size() <= MAX))
{
return true;
}
System.out.println("ClassInvariant failed");
return false;
}
public
{
AddBook( BOOK oneBook?)
HashSet old_lib = lib.clone();
if (!(ClassInvariant() && (!(lib.contains(oneBook?)))))
{
System.out.println("AddBook method:Precondition failed");
}
System.out.println("AddBook method:Precondition passed");
System.out.println("Method body goes here");
if (!(ClassInvariant() && (lib.equals((old_lib.addAll(oneBook?)))) &&
(lib.size() != old_lib.size() + 1)))
{
System.out.println("AddBook method:Postcondition failed");
}
System.out.println("AddBook method:Postcondition passed");
}
public
{
RemoveBook( BOOK oneBook?)
HashSet old_lib = lib.clone();
if (!(ClassInvariant() && (lib.contains(oneBook?))))
{
System.out.println("RemoveBook method:Precondition failed");
}
System.out.println("RemoveBook method:Precondition passed");
System.out.println("Method body goes here");
if (!(ClassInvariant() && (old_lib.equals((lib.addAll(oneBook?)))) &&
(lib.size() != old_lib.size() - 1)))
{
System.out.println("RemoveBook method:Postcondition failed");
}
System.out.println("RemoveBook method: Postcondition passed");
}
}
Figure 31: Library example – Java skeletal code
57
Figure 32 shows the automatically converted skeletal code output of the Library system
generated by the FOZCIL Tool instance and written in C# language.
public class Library
{
public int MAX = 10;
public enum status { CHECKEDIN,CHECKEDOUT };
public HashSet lib;
public
{
Library()
lib = new HashSet();
if (!(ClassInvariant()))
{
Console.WriteLine("Postcondition failed");
}
}
public boolean ClassInvariant()
{
if ((lib.Count() > 0) && (lib.Count() <= MAX))
{
return true;
}
}
public
{
Console.WriteLine("ClassInvariant failed");
return false;
AddBook( BOOK oneBook?)
HashSet old_lib = lib.MemberwiseClone();
if (!(ClassInvariant() && (!(lib.Contains(oneBook?)))))
{
Console.WriteLine("AddBook method:Precondition failed");
}
Console.WriteLine("AddBook method:Precondition passed");
Console.WriteLine("Method body goes here");
if (!(ClassInvariant() &&
(lib.SetEquals((old_lib.UnionWith(oneBook?)))) && (lib.Count() == old_lib.Count() + 1)))
{
Console.WriteLine("AddBook method:Postcondition failed");
}
Console.WriteLine("AddBook method:Postcondition passed");
}
public
{
RemoveBook( BOOK oneBook?)
HashSet old_lib = lib.MemberwiseClone();
if (!(ClassInvariant() && (lib.Contains(oneBook?))))
{
Console.WriteLine("RemoveBook method:Precondition failed");
}
Console.WriteLine("RemoveBook method:Precondition passed");
Console.WriteLine("Method body goes here");
if (!(ClassInvariant() &&
(old_lib.SetEquals((lib.UnionWith(oneBook?)))) && (lib.Count() == old_lib.Count() - 1)))
{
Console.WriteLine("RemoveBook method:Postcondition failed");
}
Console.WriteLine("RemoveBook method:Postcondition passed");
}
}
Figure 32: Library example – C# skeletal code
58
Chapter 6
CONCLUSION AND FUTURE ENHANCEMENTS
The existing systems that automatically convert Object-Z specifications to skeletal code
with dynamically-checkable design contracts written in object-oriented programming
languages [3] [4] were successful in bridging the gap between the formal specifications
and the implementation code. By automatically converting the specifications into the
corresponding skeletal code along with dynamically-checkable design contracts that
assert adherence to the specifications has been a huge step towards increasing the quality
of the software. Further, the use of such lightweight formal techniques promotes a wider
application of formal methods to the day-to-day software engineering process.
This project has been a step forward in making this automated conversion technique more
acceptable by both the end users and the tool builders. By capturing most of the common,
redundant logic in the frozen-spot of the framework, FOZCIL makes it easy for a tool
builder to extend the framework for any target programming language by just entering
the required language-dependent features. Having captured the language-dependent
features, FOZCIL generates the tool instance that has the same functionality as the
existing “Object-Z to skeletal code” tools but with much lesser effort for the tool builder.
The tool GUI has also been redesigned to make it easer to enter the Object-Z
specifications.
59
There are a number of future enhancements that can be made to this framework. One
would be to increase the Object-Z language features that can be automatically converted
by the framework including adding data types like product and sequence. Inclusion of
additional language features would make the framework usable for the specification of
more sophisticated systems. In addition, FOZCIL currently uses imperative code to do
the conversion of both the language-dependent and language-independent properties.
Another option to experiment would be to use a declarative, open-source parser generator
such as ANTLR [25] to create the OZ-to-IL converter by feeding in the appropriate
language grammar. This approach could make the framework more flexible for further
language extensions in the future.
While mapping the language-dependent features, FOZCIL expects the target language to
have the equivalent types and operators for each of the Object-Z types and operators.
This may not always be the case since some implementation languages may not have all
the equivalent types and operators. In such a circumstance, an alternative conversion
technique could be provided. One such option would be to implement a utility Assertion
class as done by Sherri Sanders [4] to supplant the functionality of those missing
operators.
60
APPENDICES
61
APPENDIX A
Language-dependent XML for Java language
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<languageDependent>
<generalData>
<languageName>Java</languageName>
<languageFileExtension>java</languageFileExtension>
</generalData>
<structuralData>
<classTemplate><![CDATA[
<VISIBILITY> class <NAME>
{
<BODY>
}
]]></classTemplate>
<variableDeclTemplate><![CDATA[
<VISIBILITY> <TYPE> <NAME>
]]></variableDeclTemplate>
<objectConstructorTemplate><![CDATA[new <TYPE>()]]></objectConstructorTemplate>
<methodTemplate><![CDATA[
<VISIBILITY> <RETURNTYPE> <NAME>(<ARGS>)
{
<BODY>
}
]]></methodTemplate>
<methodArgumentSeparator><![CDATA[,]]></methodArgumentSeparator>
<printTemplate><![CDATA[System.out.println(\"<COMMENT>\")]]></printTemplate>
<ifTemplate><![CDATA[
if (<CONDITION>)
{
<BODY>
}
]]></ifTemplate>
<returnTemplate><![CDATA[return <EXPRESSION>]]></returnTemplate>
<statementEndSymbol><![CDATA[;]]></statementEndSymbol>
<enumTemplate><![CDATA[<VISIBILITY> enum <NAME> { <VALS> }]]></enumTemplate>
<enumValueSeparator><![CDATA[,]]></enumValueSeparator>
</structuralData>
<typeData>
<typeIntegerData>
<typeOzNEquivalent><![CDATA[int]]></typeOzNEquivalent>
<typeOzZEquivalent><![CDATA[int]]></typeOzZEquivalent>
<operatorAssignment><![CDATA[=]]></operatorAssignment>
<operatorArithmeticPlus><![CDATA[+]]></operatorArithmeticPlus>
<operatorArithmeticMinus><![CDATA[-]]></operatorArithmeticMinus>
<operatorArithmeticMultiply><![CDATA[*]]></operatorArithmeticMultiply>
<operatorArithmeticDivide><![CDATA[/]]></operatorArithmeticDivide>
<operatorRelationalEqual><![CDATA[!=]]></operatorRelationalEqual>
<operatorRelationalNotEqual><![CDATA[==]]></operatorRelationalNotEqual>
<operatorRelationalLess><![CDATA[<]]></operatorRelationalLess>
<operatorRelationalLessEqual><![CDATA[<=]]></operatorRelationalLessEqual>
<operatorRelationalGreater><![CDATA[>]]></operatorRelationalGreater>
<operatorRelationalGreaterEqual>
<![CDATA[>=]]>
</operatorRelationalGreaterEqual>
<operatorLogicalNot><![CDATA[!]]></operatorLogicalNot>
<operatorLogicalOr><![CDATA[||]]></operatorLogicalOr>
<operatorLogicalAnd><![CDATA[&&]]></operatorLogicalAnd>
</typeIntegerData>
<typeBooleanData>
<typeIlBoolEquivalent><![CDATA[boolean]]></typeIlBoolEquivalent>
<typeValueBoolTrueEquivalent>
<![CDATA[true]]>
</typeValueBoolTrueEquivalent>
<typeValueBoolFalseEquivalent>
<![CDATA[false]]>
</typeValueBoolFalseEquivalent>
</typeBooleanData>
<typeSetData>
<setTypeEquivalent><![CDATA[HashSet]]></setTypeEquivalent>
62
<isMemberTemplate><![CDATA[<NAME2>.contains(<NAME1>)]]></isMemberTemplate>
<cloneTemplate>>
<![CDATA[<NAME1>.clone()]]>
</cloneTemplate>
<isNotMemberTemplate>
<![CDATA[!(<NAME2>.contains(<NAME1>))]]>
</isNotMemberTemplate>
<equalsTemplate><![CDATA[<NAME1>.equals(<NAME2>)]]></equalsTemplate>
<unionTemplate><![CDATA[<NAME1>.addAll(<NAME2>)]]></unionTemplate>
<intersectTemplate>
<![CDATA[<NAME1>.retainAll(<NAME2>)]]>
</intersectTemplate>
<cardinalityTemplate><![CDATA[<NAME1>.size()]]></cardinalityTemplate>
<subsetTemplate><![CDATA[<NAME2>.containsAll(<NAME1>]]></subsetTemplate>
</typeSetData>
</typeData>
</languageDependent>
63
APPENDIX B
Language-dependent XML for C# language
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<languageDependent>
<generalData>
<languageName>C#</languageName>
<languageFileExtension>cs</languageFileExtension>
</generalData>
<structuralData>
<classTemplate><![CDATA[
<VISIBILITY> class <NAME>
{
<BODY>
}
]]></classTemplate>
<variableDeclTemplate><![CDATA[
<VISIBILITY> <TYPE> <NAME>
]]></variableDeclTemplate>
<objectConstructorTemplate><![CDATA[new <TYPE>()]]></objectConstructorTemplate>
<methodTemplate><![CDATA[
<VISIBILITY> <RETURNTYPE> <NAME>(<ARGS>)
{
<BODY>
}
]]></methodTemplate>
<methodArgumentSeparator><![CDATA[,]]></methodArgumentSeparator>
<printTemplate><![CDATA[Console.WriteLine(\"<COMMENT>\")]]></printTemplate>
<ifTemplate><![CDATA[
if (<CONDITION>)
{
<BODY>
}
]]></ifTemplate>
<returnTemplate><![CDATA[return <EXPRESSION>]]></returnTemplate>
<statementEndSymbol><![CDATA[;]]></statementEndSymbol>
<enumTemplate><![CDATA[<VISIBILITY> enum <NAME> { <VALS> }]]></enumTemplate>
<enumValueSeparator><![CDATA[,]]></enumValueSeparator>
</structuralData>
<typeData>
<typeIntegerData>
<typeOzNEquivalent><![CDATA[int]]></typeOzNEquivalent>
<typeOzZEquivalent><![CDATA[int]]></typeOzZEquivalent>
<operatorAssignment><![CDATA[=]]></operatorAssignment>
<operatorArithmeticPlus><![CDATA[+]]></operatorArithmeticPlus>
<operatorArithmeticMinus><![CDATA[-]]></operatorArithmeticMinus>
<operatorArithmeticMultiply><![CDATA[*]]></operatorArithmeticMultiply>
<operatorArithmeticDivide><![CDATA[/]]></operatorArithmeticDivide>
<operatorRelationalEqual><![CDATA[==]]></operatorRelationalEqual>
<operatorRelationalNotEqual><![CDATA[!=]]></operatorRelationalNotEqual>
<operatorRelationalLess><![CDATA[<]]></operatorRelationalLess>
<operatorRelationalLessEqual><![CDATA[<=]]></operatorRelationalLessEqual>
<operatorRelationalGreater><![CDATA[>]]></operatorRelationalGreater>
<operatorRelationalGreaterEqual>
<![CDATA[>=]]>
</operatorRelationalGreaterEqual>
<operatorLogicalNot><![CDATA[!]]></operatorLogicalNot>
<operatorLogicalOr><![CDATA[||]]></operatorLogicalOr>
<operatorLogicalAnd><![CDATA[&&]]></operatorLogicalAnd>
</typeIntegerData>
<typeBooleanData>
<typeIlBoolEquivalent><![CDATA[boolean]]></typeIlBoolEquivalent>
<typeValueBoolTrueEquivalent>
<![CDATA[true]]>
</typeValueBoolTrueEquivalent>
<typeValueBoolFalseEquivalent>
<![CDATA[false]]>
</typeValueBoolFalseEquivalent>
</typeBooleanData>
<typeSetData>
64
<setTypeEquivalent><![CDATA[HashSet]]></setTypeEquivalent>
<cloneTemplate>>
<![CDATA[<NAME1>.MemberwiseClone()]]>
</cloneTemplate>
<isMemberTemplate><![CDATA[<NAME2>.Contains(<NAME1>)]]></isMemberTemplate>
<isNotMemberTemplate>
<![CDATA[!(<NAME2>.Contains(<NAME1>))]]>
</isNotMemberTemplate>
<equalsTemplate><![CDATA[<NAME1>.SetEquals(<NAME2>)]]></equalsTemplate>
<unionTemplate><![CDATA[<NAME1>.UnionWith(<NAME2>)]]></unionTemplate>
<intersectTemplate>
<![CDATA[<NAME1>.IntersectWith(<NAME2>)]]>
</intersectTemplate>
<cardinalityTemplate><![CDATA[<NAME1>.Count()]]></cardinalityTemplate>
<subsetTemplate><![CDATA[<NAME2>.IsSubsetOf(<NAME1>]]></subsetTemplate>
</typeSetData>
</typeData>
</languageDependent>
65
APPENDIX C
Project source code
package edu.csus.fozcil;
/**
*
* @author GeorgeN
*/
public class Constants {
public static final String CONFIG_FOLDER_PATH = "/edu/csus/fozcil/config/";
public static final String XML_FOLDER_PATH = "/edu/csus/fozcil/data/";
public static final String APP_PROPERTIES_KEY_LOG4J_CONFIG_FILE =
"config.file.log4j";
public static final String APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_HOME=
"binding.dependent.language.dir";
public static final String APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_HOME_INTERNAL=
"binding.dependent.language.dir.internal";
public static final String APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_TOOL_CLASSPATH=
"binding.dependent.language.tool.classpath";
public static final String APP_PROPERTIES_KEY_BINDING_LANG_INDEPEND_HOME=
"binding.independent.language.dir";
public static final String APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_FILE=
"binding.dependent.language.file";
public static final String APP_PROPERTIES_KEY_BINDING_LANG_INDEPEND_FILE=
"binding.independent.language.file";
public static final String APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_TMPL_TKN_OPEN=
"binding.dependent.language.template.token.opener";
public static final String APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_TMPL_TKN_CLOSE=
"binding.dependent.language.template.token.closer";
public static final String APP_PROPERTIES_KEY_OZ_SPEC_HOME = "oz.spec.dir";
public static final String APP_PROPERTIES_KEY_IL_CODE_HOME = "il.skeletal.code.dir";
public static final String APP_PROPERTIES_KEY_BUILD_FILE = "build.file";
public static final String APP_PROPERTIES_KEY_BUILD_FILE_CREATETOOL_TASK =
"build.file.task.createtool";
}
package edu.csus.fozcil;
/**
*
* @author GeorgeN
*/
public class FozcilException extends Exception {
public static final int EXCEP_SEVERITY_LOW = 100;
public static final int EXCEP_SEVERITY_MEDIUM = 200;
public static final int EXCEP_SEVERITY_HIGH = 999;
private int severity;
public FozcilException(int severity) {
}
public FozcilException(String errmsg, int severity) {
super(errmsg);
this.severity = severity;
}
public FozcilException(Exception e, int severity) {
super(e);
this.severity = severity;
}
public FozcilException(String errmsg, Exception err, int severity) {
super(errmsg, err);
this.severity = severity;
}
66
}
package edu.csus.fozcil.bean;
import java.io.Serializable;
import java.util.HashMap;
/**
*
* @author GeorgeN
*/
public class LanguageDependentBean implements Serializable {
public static final String PRNTCOMMENTTEMPLATE_TEXT = "COMMENT";
public static final String VARDECLTEMPLATE_VISIBILITY = "VISIBILITY";
public static final String VARDECLTEMPLATE_TYPE = "TYPE";
public static final String VARDECLTEMPLATE_NAME = "NAME";
public static final String ENUMDECLTEMPLATE_VISIBILITY = "VISIBILITY";
public static final String ENUMDECLTEMPLATE_NAME = "NAME";
public static final String ENUMDECLTEMPLATE_VALUES = "VALS";
public static final String CLASSTEMPLATE_VISIBILITY = "VISIBILITY";
public static final String CLASSTEMPLATE_NAME = "NAME";
public static final String CLASSTEMPLATE_BODY = "BODY";
public
public
public
public
public
static
static
static
static
static
final
final
final
final
final
String
String
String
String
String
METHODTEMPLATE_VISIBILITY = "VISIBILITY";
METHODTEMPLATE_RETURNTYPE = "RETURNTYPE";
METHODTEMPLATE_NAME = "NAME";
METHODTEMPLATE_ARGUMENTS = "ARGS";
METHODTEMPLATE_BODY = "BODY";
public static final String IF_STMT_TEMPLATE_CONDITION = "CONDITION";
public static final String IF_STMT_TEMPLATE_BODY = "BODY";
public static final String RETURN_STMT_TEMPLATE_EXPRESSION = "EXPRESSION";
public static final String OBJCONSTRUCTORTEMPLATE_TYPE = "TYPE";
public static final String SETTEMPLATE_NAME1 = "NAME1";
public static final String SETTEMPLATE_NAME2 = "NAME2";
//general
private String languageName;
private String languageFileExtension;
//structural
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
statementEndSymbol;
printCommentTemplate;
variableDeclarationTemplate;
objectConstructorTemplate;
classTemplate;
methodTemplate;
ifStatementTemplate;
methodArgumentSeparator;
returnStatementTemplate;
enumTemplate;
enumValueSeparator;
//boolean type
private String extrinsic_type_boolean_equivalent;
//needed by converter for the
ClassInvariant method return type
private String extrinsic_typeValue_boolean_true_equivalent; //needed by converter
for the ClassInvariant return statement
private String extrinsic_typeValue_boolean_false_equivalent; //needed by converter
for the ClassInvariant return statement
//Integer type
private String intrinsic_type_N_equivalent;
private String intrinsic_type_Z_equivalent;
private HashMap<String,String> intrinsicOperator_equivalent = new
HashMap<String,String>();
67
//set type
private String
private String
private String
private String
private String
private String
private String
private String
private String
setType_equivalent;
setTypeCloneTemplate;
setTypeIsMemberOfTemplate;
setTypeIsNotMemberOfTemplate;
setTypeEqualsTemplate;
setTypeUnionTemplate;
setTypeIntersectTemplate;
setTypeCardinalityTemplate;
setTypeSubsetTemplate;
public LanguageDependentBean() {
}
public String getLanguageFileExtension() {
return languageFileExtension;
}
public void setLanguageFileExtension(String languageFileExtension) {
this.languageFileExtension = languageFileExtension;
}
public String getLanguageName() {
return languageName;
}
public void setLanguageName(String languageName) {
this.languageName = languageName;
}
public String getIntrinsic_type_N_equivalent() {
return intrinsic_type_N_equivalent;
}
public void setIntrinsic_type_N_equivalent(String intrinsicType_N_equivalent) {
this.intrinsic_type_N_equivalent = intrinsicType_N_equivalent;
}
public String getIntrinsic_type_Z_equivalent() {
return intrinsic_type_Z_equivalent;
}
public void setIntrinsic_type_Z_equivalent(String intrinsicType_Z_equivalent) {
this.intrinsic_type_Z_equivalent = intrinsicType_Z_equivalent;
}
public HashMap<String, String> getIntrinsicOperator_equivalent() {
return intrinsicOperator_equivalent;
}
public String getExtrinsic_typeValue_boolean_false_equivalent() {
return extrinsic_typeValue_boolean_false_equivalent;
}
public void setExtrinsic_typeValue_boolean_false_equivalent(String
extrinsic_booleanValue_false_equivalent) {
this.extrinsic_typeValue_boolean_false_equivalent =
extrinsic_booleanValue_false_equivalent;
}
public String getExtrinsic_typeValue_boolean_true_equivalent() {
return extrinsic_typeValue_boolean_true_equivalent;
}
public void setExtrinsic_typeValue_boolean_true_equivalent(String
extrinsic_booleanValue_true_equivalent) {
this.extrinsic_typeValue_boolean_true_equivalent =
extrinsic_booleanValue_true_equivalent;
}
public void setIntrinsicOperator_equivalent(HashMap<String, String>
intrinsicOperator_equivalent) {
this.intrinsicOperator_equivalent = intrinsicOperator_equivalent;
68
}
public void addIntrinsicOperator_equivalent(String ozOperator, String ldOperator) {
this.intrinsicOperator_equivalent.put(ozOperator, ldOperator);
}
public String getClassTemplate() {
return classTemplate;
}
public void setClassTemplate(String classTemplate) {
this.classTemplate = classTemplate;
}
public String getMethodTemplate() {
return methodTemplate;
}
public void setMethodTemplate(String methodTemplate) {
this.methodTemplate = methodTemplate;
}
/**
* @return the variableDeclarationTemplate
*/
public String getVariableDeclarationTemplate() {
return variableDeclarationTemplate;
}
/**
* @param variableDeclarationTemplate the variableDeclarationTemplate to set
*/
public void setVariableDeclarationTemplate(String variableDeclarationTemplate) {
this.variableDeclarationTemplate = variableDeclarationTemplate;
}
public String getObjectConstructorTemplate() {
return objectConstructorTemplate;
}
public void setObjectConstructorTemplate(String objectConstructorTemplate) {
this.objectConstructorTemplate = objectConstructorTemplate;
}
/**
* @return the methodArgumentSeparator
*/
public String getMethodArgumentSeparator() {
return methodArgumentSeparator;
}
/**
* @param methodArgumentSeparator the methodArgumentSeparator to set
*/
public void setMethodArgumentSeparator(String methodArgumentSeparator) {
this.methodArgumentSeparator = methodArgumentSeparator;
}
/**
* @return the statementEndSymbol
*/
public String getStatementEndSymbol() {
return statementEndSymbol;
}
/**
* @param statementEndSymbol the statementEndSymbol to set
*/
public void setStatementEndSymbol(String statementEndSymbol) {
this.statementEndSymbol = statementEndSymbol;
}
public String getPrintCommentTemplate() {
return printCommentTemplate;
69
}
public void setPrintCommentTemplate(String printCommentTemplate) {
this.printCommentTemplate = printCommentTemplate;
}
public String getIfStatementTemplate() {
return ifStatementTemplate;
}
public void setIfStatementTemplate(String ifStatementTemplate) {
this.ifStatementTemplate = ifStatementTemplate;
}
public String getEnumTemplate() {
return enumTemplate;
}
public void setEnumTemplate(String enumTemplate) {
this.enumTemplate = enumTemplate;
}
public String getEnumValueSeparator() {
return enumValueSeparator;
}
public void setEnumValueSeparator(String enumValueSeparator) {
this.enumValueSeparator = enumValueSeparator;
}
public String getExtrinsic_type_boolean_equivalent() {
return extrinsic_type_boolean_equivalent;
}
public void setExtrinsic_type_boolean_equivalent(String
intrinsicType_booleanType_equivalent) {
this.extrinsic_type_boolean_equivalent = intrinsicType_booleanType_equivalent;
}
public String getReturnStatementTemplate() {
return returnStatementTemplate;
}
public void setReturnStatementTemplate(String returnStatementTemplate) {
this.returnStatementTemplate = returnStatementTemplate;
}
public String getSetTypeCloneTemplate() {
return setTypeCloneTemplate;
}
public void setSetTypeCloneTemplate(String setTypeCloneTemplate) {
this.setTypeCloneTemplate = setTypeCloneTemplate;
}
public String getSetTypeCardinalityTemplate() {
return setTypeCardinalityTemplate;
}
public void setSetTypeCardinalityTemplate(String setTypeCardinalityTemplate) {
this.setTypeCardinalityTemplate = setTypeCardinalityTemplate;
}
public String getSetTypeEqualsTemplate() {
return setTypeEqualsTemplate;
}
public void setSetTypeEqualsTemplate(String setTypeEqualsTemplate) {
this.setTypeEqualsTemplate = setTypeEqualsTemplate;
}
public String getSetTypeIntersectTemplate() {
return setTypeIntersectTemplate;
}
70
public void setSetTypeIntersectTemplate(String setTypeIntersectTemplate) {
this.setTypeIntersectTemplate = setTypeIntersectTemplate;
}
public String getSetTypeIsMemberOfTemplate() {
return setTypeIsMemberOfTemplate;
}
public void setSetTypeIsMemberOfTemplate(String setTypeIsMemberOfTemplate) {
this.setTypeIsMemberOfTemplate = setTypeIsMemberOfTemplate;
}
public String getSetTypeIsNotMemberOfTemplate() {
return setTypeIsNotMemberOfTemplate;
}
public void setSetTypeIsNotMemberOfTemplate(String setTypeIsNotMemberOfTemplate) {
this.setTypeIsNotMemberOfTemplate = setTypeIsNotMemberOfTemplate;
}
public String getSetTypeSubsetTemplate() {
return setTypeSubsetTemplate;
}
public void setSetTypeSubsetTemplate(String setTypeSubsetTemplate) {
this.setTypeSubsetTemplate = setTypeSubsetTemplate;
}
public String getSetTypeUnionTemplate() {
return setTypeUnionTemplate;
}
public void setSetTypeUnionTemplate(String setTypeUnionTemplate) {
this.setTypeUnionTemplate = setTypeUnionTemplate;
}
public String getSetType_equivalent() {
return setType_equivalent;
}
public void setSetType_equivalent(String setType_equivalent) {
this.setType_equivalent = setType_equivalent;
}
}
package edu.csus.fozcil.bean;
import java.util.ArrayList;
import java.util.HashMap;
/**
*
* @author GeorgeN
*/
public class OzOperationBean {
public static final String OPERATOR_ASSIGNMENT = "\u2254";
public
public
public
public
static
static
static
static
final
final
final
final
String
String
String
String
OPERATOR_PLUS = "+";
OPERATOR_MINUS = "-";
OPERATOR_MULTIPLY = "*";
OPERATOR_DIVIDE = "/";
public
public
public
public
public
public
static
static
static
static
static
static
final
final
final
final
final
final
String
String
String
String
String
String
OPERATOR_EQUAL = "=";
OPERATOR_NOT_EQUAL = "\u2260";
OPERATOR_LESS = "<";
OPERATOR_LESS_EQUAL = "\u2264";//2264
OPERATOR_GREATER = ">";
OPERATOR_GREATER_EQUAL = "\u2265";//2265
public static final String OPERATOR_NOT = "\u00AC";
public static final String OPERATOR_OR = "\u2228";
71
public static final String OPERATOR_AND = "\u2227";
public
public
public
public
public
public
public
public
static
static
static
static
static
static
static
static
private
private
private
private
private
private
private
final
final
final
final
final
final
final
final
String
String
String
String
String
String
String
String
OPERATOR_VALUE_SET_EMPTY = "\u2205";
OPERATOR_SET_IS_MEMBER_OF = "\u2208";
OPERATOR_SET_IS_NOT_MEMBER_OF = "\u2209";
OPERATOR_SET_EQUALS = "\u2261";
OPERATOR_SET_UNION = "\u222A";
OPERATOR_SET_INTERSECT = "\u2229";
OPERATOR_SET_CARDINALITY = "#";
OPERATOR_SET_SUBSET = "\u2282";
String name;
String visibility;
String returnType;
HashMap<String,String> stateModifiers = new HashMap<String,String>();
HashMap<String,String> arguments = new HashMap<String,String>();
ArrayList<String> preconditions = new ArrayList<String>();
ArrayList<String> postconditions = new ArrayList<String>();
public OzOperationBean() {
}
public OzOperationBean(String name) {
this.name = name;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the visibility
*/
public String getVisibility() {
return visibility;
}
/**
* @param visibility the visibility to set
*/
public void setVisibility(String visibility) {
this.visibility = visibility;
}
/**
* @return the returnType
*/
public String getReturnType() {
return returnType;
}
/**
* @param returnType the returnType to set
*/
public void setReturnType(String returnType) {
this.returnType = returnType;
}
public HashMap<String, String> getStateModifiers() {
return stateModifiers;
}
public void setStateModifiers(HashMap<String, String> stateModifiers) {
this.stateModifiers = stateModifiers;
72
}
public void addStateModifier(String stateName, String modifier) {
this.stateModifiers.put(stateName, modifier);
}
/**
* @return the arguments
*/
public HashMap<String, String> getArguments() {
return arguments;
}
/**
* @param arguments the arguments to set
*/
public void setArguments(HashMap<String, String> arguments) {
this.arguments = arguments;
}
public void addArgument(String argName, String argType) {
this.arguments.put(argName, argType);
}
public ArrayList<String> getPostconditions() {
return postconditions;
}
public void setPostconditions(ArrayList<String> postconditions) {
this.postconditions = postconditions;
}
public void addPostcondition(String postcondition) {
this.postconditions.add(postcondition);
}
public ArrayList<String> getPreconditions() {
return preconditions;
}
public void setPreconditions(ArrayList<String> preconditions) {
this.preconditions = preconditions;
}
public void addPrecondition(String precondition) {
this.preconditions.add(precondition);
}
}
package edu.csus.fozcil.bean;
import
import
import
import
java.io.Serializable;
java.util.ArrayList;
java.util.HashMap;
java.util.HashSet;
/**
*
* @author GeorgeN
*/
public class OzSpecificationBean implements Serializable {
public static final String OZ_INTRINSIC_TYPE_Z = "Z";
public static final String OZ_INTRINSIC_TYPE_N = "N";
public static final String OZ_INTRINSIC_TYPE_SET = "Fset";
public static final String OZ_INIT_METHOD_NAME = "INIT";
public static final String OZ_DELTA_OUTPUT_VARIABLE_MARKER = "'";
public final static String OZ_STATE_MODIFIER_THETA = "Theta";
public final static String OZ_STATE_MODIFIER_DELTA = "Delta";
private String schemaName;
private String schemaVisibility;
private HashSet<OzVariable> userDataTypes = new HashSet<OzVariable>();
73
private HashMap<String,OzVariable> constantDataTypes = new
HashMap<String,OzVariable>();
private HashMap<String,OzVariable> freeDataTypes = new HashMap<String,OzVariable>();
private HashMap<String,OzVariable> stateVariables = new HashMap<String,OzVariable>();
private ArrayList<String> classInvariants = new ArrayList<String>();
private HashSet<OzOperationBean> operations = new HashSet<OzOperationBean>();
public OzSpecificationBean() {}
/**
* @return the schemaName
*/
public String getSchemaName() {
return schemaName;
}
/**
* @param schemaName the schemaName to set
*/
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
/**
* @return the schemaVisibility
*/
public String getSchemaVisibility() {
return schemaVisibility;
}
/**
* @param schemaName the schemaName to set
*/
public void setSchemaVisibility(String schemaVisibility) {
this.schemaVisibility = schemaVisibility;
}
/**
* @return the userDataTypes
*/
public HashSet<OzVariable> getUserDataTypes() {
return userDataTypes;
}
/**
* @param userDataTypes the userDataTypes to set
*/
public void setUserDataTypes(HashSet<OzVariable> userDataTypes) {
this.userDataTypes = userDataTypes;
}
public void addUserDataType(OzVariable newDataType) {
this.userDataTypes.add(newDataType);
}
public HashMap<String, OzVariable> getConstantDataTypes() {
return constantDataTypes;
}
public void setConstantDataTypes(HashMap<String, OzVariable> constantDataTypes) {
this.constantDataTypes = constantDataTypes;
}
public void addConstantDataType(OzVariable constantDataType) {
this.constantDataTypes.put(constantDataType.getName(), constantDataType);
}
public HashMap<String, OzVariable> getFreeDataTypes() {
return freeDataTypes;
}
public void setFreeDataTypes(HashMap<String, OzVariable> freeDataTypes) {
this.freeDataTypes = freeDataTypes;
}
74
public void addFreeDataType(OzVariable freeDataType) {
this.freeDataTypes.put(freeDataType.getName(), freeDataType);
}
public HashMap<String, OzVariable> getStateVariables() {
return stateVariables;
}
public void setStateVariables(HashMap<String, OzVariable> stateVariables) {
this.stateVariables = stateVariables;
}
public void addStateVariable(OzVariable stateVariable) {
this.stateVariables.put(stateVariable.getName(), stateVariable);
}
public ArrayList<String> getClassInvariants() {
return classInvariants;
}
public void setClassInvariants(ArrayList<String> classInvariants) {
this.classInvariants = classInvariants;
}
public void addClassInvariant(String classInvariant) {
this.classInvariants.add(classInvariant);
}
/**
* @return the operations
*/
public HashSet<OzOperationBean> getOperations() {
return operations;
}
/**
* @param operations the operations to set
*/
public void setOperations(HashSet<OzOperationBean> operations) {
this.operations = operations;
}
public void addOperation(OzOperationBean newOperation) {
this.operations.add(newOperation);
}
public OzOperationBean getInitOperation() {
OzOperationBean initOper = null;
}
for (OzOperationBean ozOperationBean : this.operations) {
if (ozOperationBean.getName().equals(OZ_INIT_METHOD_NAME)) {
initOper = ozOperationBean;
break;
}
}
return initOper;
public void removeOperation(String operationName) {
for (OzOperationBean ozOperationBean : this.operations) {
if (ozOperationBean.getName().equals(OZ_INIT_METHOD_NAME)) {
this.operations.remove(ozOperationBean);
break;
}
}
}
}
package edu.csus.fozcil.bean;
import java.util.ArrayList;
75
/**
*
* @author georgen
*/
public class OzVariable {
private String name;
private String type;
private String visibility;
private ArrayList<String> values = new ArrayList<String>();
public OzVariable(String name) {
this.name = name;
}
public OzVariable(String name, String type) {
this.name = name;
this.type = type;
}
public OzVariable(String name, String type, String visibility) {
this.name = name;
this.type = type;
this.visibility = visibility;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the visibility
*/
public String getVisibility() {
return visibility;
}
/**
* @param visibility the visibility to set
*/
public void setVisibility(String visibility) {
this.visibility = visibility;
}
public ArrayList<String> getValues() {
return values;
}
public void setValues(ArrayList<String> values) {
this.values = values;
76
}
}
public void addValue(String value) {
this.values.add(value);
}
App.properties
#------- App-related configuration ----------config.file.log4j=log4j.properties
#------- OZ-IL Bindings ------------binding.dependent.language.dir=src\\edu\\csus\\fozcil\\data\\
binding.dependent.language.dir.internal=/edu/csus/fozcil/data/
binding.dependent.language.tool.classpath=/src/edu/csus/fozcil/data/
binding.independent.language.dir=src\\edu\\csus\\fozcil\\data\\
binding.dependent.language.file=languagedependent.fozcil.xml
binding.independent.language.file=languageindependent.fozcil.xsl
binding.dependent.language.template.token.opener=<
binding.dependent.language.template.token.closer=>
#binding.ozil.java=java.fozcil.xsl
#------- OZ Specification (input by user) ------------oz.spec.dir=c:\\temp\\fozcil\\input
#------- IL Skeletal code (generated by tool) ------------il.skeletal.code.dir=c:\\temp\\fozcil\\output
#------- Build file ------------build.file=build_create_fozcil_tool.xml
build.file.task.createtool=createtool
Log4j.properties
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
/*
* MainFrmkJFrame.java
*
* Created on Apr 9, 2009, 9:31:15 AM
*/
package edu.csus.fozcil.framework;
import javax.swing.*;
import java.awt.*;
import edu.csus.fozcil.FozcilException;
import org.apache.log4j.Logger;
/**
*
* @author GeorgeN
*/
public class MainFrmkJFrame extends javax.swing.JFrame {
public final static String CLASS_VIEW = "Class View";
public final static String METHOD_VIEW = "Method View";
public final static String STATEMENT_VIEW = "Statement View";
private static Logger LOG = Logger.getLogger(MainFrmkJFrame.class.getName());
77
private
private
private
private
FrmkControlSystem controlsystem;
GeneralFrmkJPanel generalFrmkJPanel;
StructureFrmkJPanel structureFrmkJPanel;
TypeFrmkJPanel typeFrmkJPanel;
/** Creates new form MainFrmkJFrame */
public MainFrmkJFrame() {
initComponents();
//initialize the Model
try {
controlsystem = new FrmkControlSystem();
} catch (FozcilException ex) {
LOG.error(ex);
//throw error message to user
}
//initialize all sub-views (by adding the JpPanels to the CardLayout Manager)
this.generalFrmkJPanel = new GeneralFrmkJPanel(this, controlsystem);
this.jCardPanel.add(this.generalFrmkJPanel, CLASS_VIEW);
this.structureFrmkJPanel = new StructureFrmkJPanel(this, controlsystem);
this.jCardPanel.add(this.structureFrmkJPanel, METHOD_VIEW);
this.typeFrmkJPanel = new TypeFrmkJPanel(this, controlsystem);
this.jCardPanel.add(this.typeFrmkJPanel, STATEMENT_VIEW);
//finally show the Class panel for starters
switchView(CLASS_VIEW);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jCardPanel = new javax.swing.JPanel();
jMenuBar1 = new javax.swing.JMenuBar();
jmenuFile = new javax.swing.JMenu();
jmenuitemLoad = new javax.swing.JMenuItem();
jmenuitemSave = new javax.swing.JMenuItem();
jmenuitemExit = new javax.swing.JMenuItem();
jmenuAction = new javax.swing.JMenu();
jmenuitemActionCreateTool = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("FOZCIL Framework");
jCardPanel.setBackground(new java.awt.Color(255, 255, 255));
jCardPanel.setLayout(new java.awt.CardLayout());
jmenuFile.setText("File");
jmenuitemLoad.setText("Load");
jmenuitemLoad.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmenuitemLoadActionPerformed(evt);
}
});
jmenuitemLoad.addAncestorListener(new javax.swing.event.AncestorListener() {
public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
}
public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
jmenuitemLoadAncestorAdded(evt);
}
public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
}
});
jmenuFile.add(jmenuitemLoad);
jmenuitemSave.setText("Save");
jmenuitemSave.addActionListener(new java.awt.event.ActionListener() {
78
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmenuitemSaveActionPerformed(evt);
}
});
jmenuitemSave.addAncestorListener(new javax.swing.event.AncestorListener() {
public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
}
public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
jmenuitemSaveAncestorAdded(evt);
}
public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
}
});
jmenuFile.add(jmenuitemSave);
jmenuitemExit.setText("Exit");
jmenuitemExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmenuitemExitActionPerformed(evt);
}
});
jmenuFile.add(jmenuitemExit);
jMenuBar1.add(jmenuFile);
jmenuAction.setText("Action");
jmenuitemActionCreateTool.setText("Create tool");
jmenuitemActionCreateTool.setEnabled(false);
jmenuitemActionCreateTool.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmenuitemActionCreateToolActionPerformed(evt);
}
});
jmenuAction.add(jmenuitemActionCreateTool);
jMenuBar1.add(jmenuAction);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jCardPanel, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jCardPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 689,
Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void jmenuitemActionCreateToolActionPerformed(java.awt.event.ActionEvent evt)
{
try {
//call the Control System
LOG.debug("Calling ControlSystem.createTool...");
controlsystem.createTool();
showCreateToolDialogConfirmation();
} catch (FozcilException ex) {
LOG.error(ex);
//throw error message to user
}
}
private void jmenuitemExitActionPerformed(java.awt.event.ActionEvent evt) {
LOG.debug("Exiting application...");
System.exit(0);
}
79
private void jmenuitemSaveActionPerformed(java.awt.event.ActionEvent evt) {
processSaveFileDialog();
}
private void jmenuitemSaveAncestorAdded(javax.swing.event.AncestorEvent evt) {
// TODO add your handling code here:
}
private void jmenuitemLoadActionPerformed(java.awt.event.ActionEvent evt) {
//get LDB data
try {
this.controlsystem.loadLanguageDependentData();
} catch (FozcilException ex) {
LOG.error(ex);
//throw error message to user
}
//load LDB data into the child panels
this.generalFrmkJPanel.loadLanguageDependentData();
this.structureFrmkJPanel.loadLanguageDependentData();
this.typeFrmkJPanel.loadLanguageDependentData();
//enable other menu items appropriately
jmenuitemActionCreateTool.setEnabled(true);
}
}
private void jmenuitemLoadAncestorAdded(javax.swing.event.AncestorEvent evt) {
// TODO add your handling code here:
public void switchView(String newview) {
CardLayout cl = (CardLayout) this.jCardPanel.getLayout();
cl.show(this.jCardPanel, newview);
}
public void showSaveFileDialog() {
int n = JOptionPane.showConfirmDialog(
this, "Do you want to save the Language Dependent data?",
"An Inane Question",
JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.YES_OPTION) {
processSaveFileDialog();
} else if (n == JOptionPane.NO_OPTION) {
//do nothing
} else {
//do nothing
}
}
private void processSaveFileDialog() {
//save the LanguageDependentBean
try {
//call the Control System
LOG.debug("Calling ControlSystem.saveLanguageDependentData...");
controlsystem.saveLanguageDependentData();
//show dialog box
showSaveFileDialogConfirmation();
//enable other menu items appropriately
jmenuitemActionCreateTool.setEnabled(true);
} catch (FozcilException ex) {
LOG.error(ex);
//throw error message to user
}
}
private void showSaveFileDialogConfirmation() {
JOptionPane.showMessageDialog(this, "Language Dependent data was saved
successfully.");
}
private void showCreateToolDialogConfirmation() {
JOptionPane.showMessageDialog(this, "FOZCIL Tool instance is now available in the
/dist folder.");
}
/**
80
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainFrmkJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JPanel jCardPanel;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenu jmenuAction;
private javax.swing.JMenu jmenuFile;
private javax.swing.JMenuItem jmenuitemActionCreateTool;
private javax.swing.JMenuItem jmenuitemExit;
private javax.swing.JMenuItem jmenuitemLoad;
private javax.swing.JMenuItem jmenuitemSave;
// End of variables declaration
}
/*
* GeneralFrmkJPanel.java
*
* Created on Oct 1, 2009, 3:32:10 PM
*/
package edu.csus.fozcil.framework;
import edu.csus.fozcil.bean.LanguageDependentBean;
import edu.csus.fozcil.FozcilException;
import org.apache.log4j.Logger;
/**
*
* @author georgen
*/
public class GeneralFrmkJPanel extends javax.swing.JPanel {
private static Logger LOG = Logger.getLogger(GeneralFrmkJPanel.class.getName());
MainFrmkJFrame parentWindow;
FrmkControlSystem controlsystem;
/** Creates new form GeneralFrmkJPanel */
public GeneralFrmkJPanel(MainFrmkJFrame parent, FrmkControlSystem controlsystem) {
this.parentWindow = parent;
this.controlsystem = controlsystem;
initComponents();
}
public void loadLanguageDependentData() {
LanguageDependentBean ldb = this.controlsystem.getLanguageDependentBean();
jtfLangName.setText(ldb.getLanguageName());
jtfLangFileExtension.setText(ldb.getLanguageFileExtension());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jtfLangFileExtension = new javax.swing.JTextField();
jbnClear = new javax.swing.JButton();
jbtnNext = new javax.swing.JButton();
81
jtfLangName = new javax.swing.JTextField();
setBackground(new java.awt.Color(140, 176, 222));
jLabel1.setText("Target language");
jLabel2.setText("<html>Language File<br/>extension</html>");
jbnClear.setText("Clear");
jbnClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbnClearActionPerformed(evt);
}
});
jbtnNext.setText("Next");
jbtnNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnNextActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addGap(49, 49, 49)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfLangName,
javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)
.addComponent(jtfLangFileExtension,
javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jbnClear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnNext)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jtfLangName, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jtfLangFileExtension,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 326,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbnClear)
.addComponent(jbtnNext))
.addContainerGap())
);
82
}// </editor-fold>
private void jbtnNextActionPerformed(java.awt.event.ActionEvent evt) {
//set the bean properties
LanguageDependentBean ldb = this.controlsystem.getLanguageDependentBean();
ldb.setLanguageName(jtfLangName.getText());
ldb.setLanguageFileExtension(jtfLangFileExtension.getText());
this.parentWindow.switchView(MainFrmkJFrame.METHOD_VIEW);
}
}
private void jbnClearActionPerformed(java.awt.event.ActionEvent evt) {
jtfLangName.setText("");
jtfLangFileExtension.setText("");
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JButton jbnClear;
private javax.swing.JButton jbtnNext;
private javax.swing.JTextField jtfLangFileExtension;
private javax.swing.JTextField jtfLangName;
// End of variables declaration
}
/*
* StructureFrmkJPanel.java
*
* Created on Sep 30, 2009, 2:38:35 PM
*/
package edu.csus.fozcil.framework;
import edu.csus.fozcil.bean.LanguageDependentBean;
import edu.csus.fozcil.FozcilException;
import org.apache.log4j.Logger;
/**
*
* @author georgen
*/
public class StructureFrmkJPanel extends javax.swing.JPanel {
private static Logger LOG = Logger.getLogger(StructureFrmkJPanel.class.getName());
MainFrmkJFrame parentWindow;
FrmkControlSystem controlsystem;
/** Creates new form StructureFrmkJPanel */
public StructureFrmkJPanel(MainFrmkJFrame parent, FrmkControlSystem controlsystem) {
this.parentWindow = parent;
this.controlsystem = controlsystem;
initComponents();
}
public void loadLanguageDependentData() {
LanguageDependentBean ldb = this.controlsystem.getLanguageDependentBean();
jtfClassTpl.setText(ldb.getClassTemplate());
jtfVarDeclTpl.setText(ldb.getVariableDeclarationTemplate());
jtfObjConstructTpl.setText(ldb.getObjectConstructorTemplate());
jtfMethodTpl.setText(ldb.getMethodTemplate());
jtfMethodArgSeparator.setText(ldb.getMethodArgumentSeparator());
jtfPrintTpl.setText(ldb.getPrintCommentTemplate());
jtfIfTpl.setText(ldb.getIfStatementTemplate());
jtfReturnTpl.setText(ldb.getReturnStatementTemplate());
jtfStatementEndSymbol.setText(ldb.getStatementEndSymbol());
jtfEnumTpl.setText(ldb.getEnumTemplate());
83
jtfEnumValSep.setText(ldb.getEnumValueSeparator());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jbtnClear = new javax.swing.JButton();
jbtnNext = new javax.swing.JButton();
jbutPrev = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jtfMethodTpl = new javax.swing.JTextArea();
jtfMethodArgSeparator = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jtfPrintTpl = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jtfIfTpl = new javax.swing.JTextArea();
jLabel5 = new javax.swing.JLabel();
jtfReturnTpl = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
jtfStatementEndSymbol = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jtfClassTpl = new javax.swing.JTextArea();
jtfVarDeclTpl = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jtfObjConstructTpl = new javax.swing.JTextField();
jPanel4 = new javax.swing.JPanel();
jLabel9 = new javax.swing.JLabel();
jtfEnumTpl = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jtfEnumValSep = new javax.swing.JTextField();
setBackground(new java.awt.Color(140, 176, 222));
jbtnClear.setText("Clear");
jbtnClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnClearActionPerformed(evt);
}
});
jbtnNext.setText("Next");
jbtnNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnNextActionPerformed(evt);
}
});
jbutPrev.setText("Prev");
jbutPrev.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPrevActionPerformed(evt);
}
});
jPanel1.setBackground(new java.awt.Color(189, 208, 233));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Method",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
84
jLabel1.setText("Method Template");
jtfMethodTpl.setColumns(20);
jtfMethodTpl.setRows(5);
jScrollPane1.setViewportView(jtfMethodTpl);
jLabel2.setText("<html>Method Argument<br/>Separator</html>");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE,
336, Short.MAX_VALUE)
.addComponent(jtfMethodArgSeparator,
javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 79,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jtfMethodArgSeparator,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 68,
Short.MAX_VALUE)
.addComponent(jLabel2))
);
jPanel2.setBackground(new java.awt.Color(189, 208, 233));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Statement",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel3.setText("<html>Print Stmt<br/>Template</html>");
jLabel4.setText("<html>If Stmt<br/>Template</html>");
jtfIfTpl.setColumns(20);
jtfIfTpl.setRows(5);
jScrollPane2.setViewportView(jtfIfTpl);
jLabel5.setText("<html>Return Stmt<br/>Template</html>");
jLabel15.setText("<html>Stmt End<br/>Symbol</html>");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel4)
85
.addComponent(jLabel5)
.addComponent(jLabel15))
.addGap(58, 58, 58)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfReturnTpl,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 337,
Short.MAX_VALUE)
.addComponent(jtfPrintTpl,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 337,
Short.MAX_VALUE)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 337,
Short.MAX_VALUE)
.addComponent(jtfStatementEndSymbol,
javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jtfPrintTpl,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jtfReturnTpl, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel15))
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jtfStatementEndSymbol,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(15, 15, 15))
);
jPanel3.setBackground(new java.awt.Color(189, 208, 233));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Class",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel6.setText("Class template");
jtfClassTpl.setColumns(20);
jtfClassTpl.setRows(5);
jScrollPane3.setViewportView(jtfClassTpl);
jLabel7.setText("<html>Variable decl<br/>template</html>");
jLabel8.setText("<html>Object constr<br/>template</html>");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
86
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel8))
.addGap(50, 50, 50)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfVarDeclTpl,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 333,
Short.MAX_VALUE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE,
333, Short.MAX_VALUE)
.addComponent(jtfObjConstructTpl,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 333,
Short.MAX_VALUE))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE,
82, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7)
.addComponent(jtfVarDeclTpl, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8)
.addComponent(jtfObjConstructTpl,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11))
);
jPanel4.setBackground(new java.awt.Color(189, 208, 233));
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
"Enumeration", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel9.setText("Enum template");
jLabel10.setText("Enum separator");
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel10)
.addComponent(jLabel9))
.addGap(45, 45, 45)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfEnumValSep, javax.swing.GroupLayout.PREFERRED_SIZE,
50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jtfEnumTpl, javax.swing.GroupLayout.DEFAULT_SIZE, 332,
Short.MAX_VALUE))
.addContainerGap())
87
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfEnumTpl, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfEnumValSep, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jbtnClear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutPrev)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnNext)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 197,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbtnNext)
.addComponent(jbutPrev)
.addComponent(jbtnClear))
.addContainerGap())
);
}// </editor-fold>
private void jbtnClearActionPerformed(java.awt.event.ActionEvent evt) {
jtfClassTpl.setText("");
jtfVarDeclTpl.setText("");
jtfObjConstructTpl.setText("");
88
jtfMethodTpl.setText("");
jtfMethodArgSeparator.setText("");
jtfPrintTpl.setText("");
jtfIfTpl.setText("");
jtfReturnTpl.setText("");
jtfStatementEndSymbol.setText("");
jtfEnumTpl.setText("");
jtfEnumValSep.setText("");
}
private void jbtnNextActionPerformed(java.awt.event.ActionEvent evt) {
//set the bean properties
LanguageDependentBean ldb = this.controlsystem.getLanguageDependentBean();
ldb.setClassTemplate(jtfClassTpl.getText());
ldb.setVariableDeclarationTemplate(jtfVarDeclTpl.getText());
ldb.setObjectConstructorTemplate(jtfObjConstructTpl.getText());
ldb.setMethodTemplate(jtfMethodTpl.getText());
ldb.setMethodArgumentSeparator(jtfMethodArgSeparator.getText());
ldb.setPrintCommentTemplate(jtfPrintTpl.getText());
ldb.setIfStatementTemplate(jtfIfTpl.getText());
ldb.setReturnStatementTemplate(jtfReturnTpl.getText());
ldb.setStatementEndSymbol(jtfStatementEndSymbol.getText());
ldb.setEnumTemplate(jtfEnumTpl.getText());
ldb.setEnumValueSeparator(jtfEnumValSep.getText());
this.parentWindow.switchView(MainFrmkJFrame.STATEMENT_VIEW);
}
private void jbutPrevActionPerformed(java.awt.event.ActionEvent evt) {
this.parentWindow.switchView(MainFrmkJFrame.CLASS_VIEW);
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JButton jbtnClear;
private javax.swing.JButton jbtnNext;
private javax.swing.JButton jbutPrev;
private javax.swing.JTextArea jtfClassTpl;
private javax.swing.JTextField jtfEnumTpl;
private javax.swing.JTextField jtfEnumValSep;
private javax.swing.JTextArea jtfIfTpl;
private javax.swing.JTextField jtfMethodArgSeparator;
private javax.swing.JTextArea jtfMethodTpl;
private javax.swing.JTextField jtfObjConstructTpl;
private javax.swing.JTextField jtfPrintTpl;
private javax.swing.JTextField jtfReturnTpl;
private javax.swing.JTextField jtfStatementEndSymbol;
private javax.swing.JTextField jtfVarDeclTpl;
// End of variables declaration
}
89
/*
* TypeFrmkJPanel.java
*
* Created on Oct 4, 2009, 7:52:20 PM
*/
package edu.csus.fozcil.framework;
import
import
import
import
import
edu.csus.fozcil.bean.LanguageDependentBean;
edu.csus.fozcil.FozcilException;
edu.csus.fozcil.bean.OzOperationBean;
java.util.HashMap;
org.apache.log4j.Logger;
/**
*
* @author GeorgeN
*/
public class TypeFrmkJPanel extends javax.swing.JPanel {
private static Logger LOG = Logger.getLogger(TypeFrmkJPanel.class.getName());
MainFrmkJFrame parentWindow;
FrmkControlSystem controlsystem;
/** Creates new form TypeFrmkJPanel */
public TypeFrmkJPanel(MainFrmkJFrame parent, FrmkControlSystem controlsystem) {
this.parentWindow = parent;
this.controlsystem = controlsystem;
initComponents();
}
public void loadLanguageDependentData() {
LanguageDependentBean ldb = this.controlsystem.getLanguageDependentBean();
jtfNtype.setText(ldb.getIntrinsic_type_N_equivalent());
jtfZtype.setText(ldb.getIntrinsic_type_Z_equivalent());
HashMap<String,String> operators = ldb.getIntrinsicOperator_equivalent();
jtfPlusOper.setText(operators.get(OzOperationBean.OPERATOR_PLUS));
jtfMinusOper.setText(operators.get(OzOperationBean.OPERATOR_MINUS));
jtfMultiplyOper.setText(operators.get(OzOperationBean.OPERATOR_MULTIPLY));
jtfDivideOper.setText(operators.get(OzOperationBean.OPERATOR_DIVIDE));
jtfEqualOper.setText(operators.get(OzOperationBean.OPERATOR_NOT_EQUAL));
jtfNotEqualOper.setText(operators.get(OzOperationBean.OPERATOR_EQUAL));
jtfLessOper.setText(operators.get(OzOperationBean.OPERATOR_LESS));
jtfLessEqualOper.setText(operators.get(OzOperationBean.OPERATOR_LESS_EQUAL));
jtfGreaterOper.setText(operators.get(OzOperationBean.OPERATOR_GREATER));
jtfGreaterEqualOper.setText(operators.get(OzOperationBean.OPERATOR_GREATER_EQUAL));
jtfNotOper.setText(operators.get(OzOperationBean.OPERATOR_NOT));
jtfOrOper.setText(operators.get(OzOperationBean.OPERATOR_OR));
jtfAndOper.setText(operators.get(OzOperationBean.OPERATOR_AND));
jtfBoolType.setText(ldb.getExtrinsic_type_boolean_equivalent());
jtfBoolTrueValue.setText(ldb.getExtrinsic_typeValue_boolean_true_equivalent());
jtfBoolFalseValue.setText(ldb.getExtrinsic_typeValue_boolean_false_equivalent());
jtfSetType.setText(ldb.getSetType_equivalent());
jtfSetCloneTpl.setText(ldb.getSetTypeCloneTemplate());
jtfSetIsMemberTpl.setText(ldb.getSetTypeIsMemberOfTemplate());
jtfSetIsNotMemberTpl.setText(ldb.getSetTypeIsNotMemberOfTemplate());
jtfSetIsEqualTpl.setText(ldb.getSetTypeEqualsTemplate());
jtfSetUnionTpl.setText(ldb.getSetTypeUnionTemplate());
jtfSetIntersectTpl.setText(ldb.getSetTypeIntersectTemplate());
jtfSetSizeTpl.setText(ldb.getSetTypeCardinalityTemplate());
jtfSetIsSubsetTpl.setText(ldb.getSetTypeSubsetTemplate());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
90
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jbutClear = new javax.swing.JButton();
jbutOK = new javax.swing.JButton();
jbutPrev = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jPanel7 = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jtfNtype = new javax.swing.JTextField();
jtfZtype = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jtfPlusOper = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jtfMinusOper = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jtfMultiplyOper = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jtfDivideOper = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
jtfEqualOper = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
jtfNotEqualOper = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jtfLessOper = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jtfLessEqualOper = new javax.swing.JTextField();
jLabel16 = new javax.swing.JLabel();
jtfGreaterOper = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel();
jtfGreaterEqualOper = new javax.swing.JTextField();
jPanel6 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jtfSetType = new javax.swing.JTextField();
jPanel9 = new javax.swing.JPanel();
jtfSetIsMemberTpl = new javax.swing.JTextField();
jLabel21 = new javax.swing.JLabel();
jtfSetIsSubsetTpl = new javax.swing.JTextField();
jLabel22 = new javax.swing.JLabel();
jtfSetIsEqualTpl = new javax.swing.JTextField();
jtfSetUnionTpl = new javax.swing.JTextField();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
jtfSetIntersectTpl = new javax.swing.JTextField();
jtfSetSizeTpl = new javax.swing.JTextField();
jLabel25 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jtfSetIsNotMemberTpl = new javax.swing.JTextField();
jLabel26 = new javax.swing.JLabel();
jLabel27 = new javax.swing.JLabel();
jtfSetCloneTpl = new javax.swing.JTextField();
jPanel8 = new javax.swing.JPanel();
jLabel18 = new javax.swing.JLabel();
jtfBoolType = new javax.swing.JTextField();
jtfBoolTrueValue = new javax.swing.JTextField();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jtfBoolFalseValue = new javax.swing.JTextField();
jPanel4 = new javax.swing.JPanel();
jLabel12 = new javax.swing.JLabel();
jtfNotOper = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
jtfOrOper = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
jtfAndOper = new javax.swing.JTextField();
setBackground(new java.awt.Color(140, 176, 222));
91
jbutClear.setText("Clear");
jbutClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutClearActionPerformed(evt);
}
});
jbutOK.setText("OK");
jbutOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutOKActionPerformed(evt);
}
});
jbutPrev.setText("Prev");
jbutPrev.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPrevActionPerformed(evt);
}
});
jScrollPane1.setBackground(new java.awt.Color(140, 176, 222));
jPanel7.setBackground(new java.awt.Color(140, 176, 222));
jPanel5.setBackground(new java.awt.Color(189, 208, 233));
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Integer
type", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel3.setText("N type");
jLabel15.setText("Z type");
jPanel1.setBackground(new java.awt.Color(189, 208, 233));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Operator",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jPanel2.setBackground(new java.awt.Color(189, 208, 233));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
"Arithmetic", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel4.setText("Plus");
jLabel5.setText("Minus");
jLabel6.setText("Multiply");
jLabel7.setText("Divide");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7))
.addGap(85, 85, 85)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jtfDivideOper)
.addComponent(jtfMultiplyOper)
.addComponent(jtfMinusOper)
92
.addComponent(jtfPlusOper, javax.swing.GroupLayout.PREFERRED_SIZE,
145, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(135, Short.MAX_VALUE))
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jtfDivideOper, jtfMinusOper, jtfMultiplyOper, jtfPlusOper});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addGap(12, 12, 12)
.addComponent(jLabel6)
.addGap(12, 12, 12)
.addComponent(jLabel7))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jtfPlusOper,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfMinusOper,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfMultiplyOper,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfDivideOper,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(5, Short.MAX_VALUE))
);
jPanel3.setBackground(new java.awt.Color(193, 212, 232));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
"Relational", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel8.setText("Equal To");
jLabel9.setText("Not Equal To");
jLabel10.setText("Less Than");
jLabel11.setText("Less Than Or Equal To");
jLabel16.setText("Greater Than");
jLabel17.setText("Greater Than or Equal To");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(jLabel10)
.addComponent(jLabel11)
93
.addComponent(jLabel16)
.addComponent(jLabel17))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jtfLessEqualOper)
.addComponent(jtfLessOper)
.addComponent(jtfNotEqualOper)
.addComponent(jtfEqualOper, javax.swing.GroupLayout.DEFAULT_SIZE,
145, Short.MAX_VALUE)
.addComponent(jtfGreaterOper)
.addComponent(jtfGreaterEqualOper))
.addContainerGap(131, Short.MAX_VALUE))
);
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jtfEqualOper, jtfGreaterEqualOper, jtfGreaterOper,
jtfLessEqualOper, jtfLessOper, jtfNotEqualOper});
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9)
.addGap(12, 12, 12)
.addComponent(jLabel10)
.addGap(12, 12, 12)
.addComponent(jLabel11)
.addGap(12, 12, 12)
.addComponent(jLabel16)
.addGap(12, 12, 12)
.addComponent(jLabel17))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jtfEqualOper, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfNotEqualOper, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfLessOper, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfLessEqualOper, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfGreaterOper, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfGreaterEqualOper,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 129,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
94
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel15))
.addGap(100, 100, 100)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jtfZtype)
.addComponent(jtfNtype,
javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(16, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfNtype, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfZtype, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel15))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel6.setBackground(new java.awt.Color(193, 212, 232));
jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Set type",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel1.setText("Set type declaration");
jPanel9.setBackground(new java.awt.Color(193, 212, 232));
jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Operator",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel21.setText("Is-subset template");
jLabel22.setText("Is-equal template");
jLabel23.setText("Union template");
jLabel24.setText("Intersect template");
jLabel25.setText("Cardinality remplate");
jLabel2.setText("Is-member-of template");
jLabel26.setText("Is-not-member-of templ");
95
jLabel27.setText("Clone template");
javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
jPanel9.setLayout(jPanel9Layout);
jPanel9Layout.setHorizontalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel21)
.addComponent(jLabel22)
.addComponent(jLabel23)
.addComponent(jLabel24)
.addComponent(jLabel25)
.addComponent(jLabel26)
.addComponent(jLabel2)
.addComponent(jLabel27))
.addGap(9, 9, 9)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfSetIsNotMemberTpl,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 284,
Short.MAX_VALUE)
.addComponent(jtfSetSizeTpl, javax.swing.GroupLayout.DEFAULT_SIZE,
284, Short.MAX_VALUE)
.addComponent(jtfSetIntersectTpl,
javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
.addComponent(jtfSetUnionTpl, javax.swing.GroupLayout.DEFAULT_SIZE,
284, Short.MAX_VALUE)
.addComponent(jtfSetIsEqualTpl, javax.swing.GroupLayout.DEFAULT_SIZE,
284, Short.MAX_VALUE)
.addComponent(jtfSetIsSubsetTpl,
javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
.addGroup(jPanel9Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfSetCloneTpl,
javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
.addComponent(jtfSetIsMemberTpl,
javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE))))
.addContainerGap())
);
jPanel9Layout.setVerticalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel9Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfSetCloneTpl, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel27))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel26)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfSetIsMemberTpl,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfSetIsNotMemberTpl,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
96
.addComponent(jtfSetIsSubsetTpl,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel21))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel22)
.addComponent(jtfSetIsEqualTpl,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel23)
.addComponent(jtfSetUnionTpl, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel24)
.addComponent(jtfSetIntersectTpl,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel25)
.addComponent(jtfSetSizeTpl, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel6Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel6Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(41, 41, 41)
.addComponent(jtfSetType, javax.swing.GroupLayout.PREFERRED_SIZE,
144, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(167, 167, 167))))
);
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jtfSetType, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, 250,
javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel8.setBackground(new java.awt.Color(189, 208, 233));
jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Boolean
type", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel18.setText("Boolean type");
97
jtfBoolTrueValue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jtfBoolTrueValueActionPerformed(evt);
}
});
jLabel19.setText("Boolean TRUE-value");
jLabel20.setText("Boolean False-value");
jPanel4.setBackground(new java.awt.Color(193, 212, 232));
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Operator",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel12.setText("Not");
jLabel13.setText("Or");
jLabel14.setText("And");
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12)
.addComponent(jLabel13)
.addComponent(jLabel14))
.addGap(107, 107, 107)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jtfAndOper)
.addComponent(jtfOrOper)
.addComponent(jtfNotOper, javax.swing.GroupLayout.PREFERRED_SIZE,
145, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(138, Short.MAX_VALUE))
);
jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jtfAndOper, jtfNotOper, jtfOrOper});
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel13)
.addGap(12, 12, 12)
.addComponent(jLabel14))
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jtfNotOper, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfOrOper, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jtfAndOper, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(11, Short.MAX_VALUE))
);
98
javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
jPanel8.setLayout(jPanel8Layout);
jPanel8Layout.setHorizontalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel20)
.addComponent(jLabel19)
.addComponent(jLabel18))
.addGap(38, 38, 38)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(jtfBoolType,
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfBoolTrueValue,
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfBoolFalseValue,
javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 147,
Short.MAX_VALUE))))
.addContainerGap())
);
jPanel8Layout.setVerticalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel8Layout.createSequentialGroup()
.addContainerGap(13, Short.MAX_VALUE)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(56, 56, 56)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel20)
.addComponent(jtfBoolFalseValue,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel8Layout.createSequentialGroup()
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfBoolType,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel18))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfBoolTrueValue,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel19))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, 0,
463, Short.MAX_VALUE)
99
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap(285, Short.MAX_VALUE))
);
jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 428,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(867, Short.MAX_VALUE))
);
jScrollPane1.setViewportView(jPanel7);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(321, Short.MAX_VALUE)
.addComponent(jbutClear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutPrev)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutOK)
.addContainerGap())
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 508,
Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 615,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutPrev)
.addComponent(jbutClear)
.addComponent(jbutOK))
.addContainerGap())
);
}// </editor-fold>
private void jbutClearActionPerformed(java.awt.event.ActionEvent evt) {
jtfNtype.setText("");
jtfZtype.setText("");
jtfPlusOper.setText("");
jtfMinusOper.setText("");
jtfMultiplyOper.setText("");
jtfDivideOper.setText("");
jtfEqualOper.setText("");
jtfNotEqualOper.setText("");
jtfLessOper.setText("");
jtfLessEqualOper.setText("");
jtfGreaterOper.setText("");
jtfGreaterEqualOper.setText("");
jtfNotOper.setText("");
jtfOrOper.setText("");
100
jtfAndOper.setText("");
jtfBoolType.setText("");
jtfBoolTrueValue.setText("");
jtfBoolFalseValue.setText("");
jtfSetType.setText("");
jtfSetCloneTpl.setText("");
jtfSetIsMemberTpl.setText("");
jtfSetIsNotMemberTpl.setText("");
jtfSetIsEqualTpl.setText("");
jtfSetUnionTpl.setText("");
jtfSetIntersectTpl.setText("");
jtfSetSizeTpl.setText("");
jtfSetIsSubsetTpl.setText("");
}
private void jbutPrevActionPerformed(java.awt.event.ActionEvent evt) {
this.parentWindow.switchView(MainFrmkJFrame.METHOD_VIEW);
}
private void jbutOKActionPerformed(java.awt.event.ActionEvent evt) {
//set the bean properties
LanguageDependentBean ldb = this.controlsystem.getLanguageDependentBean();
ldb.setIntrinsic_type_N_equivalent(jtfNtype.getText());
ldb.setIntrinsic_type_Z_equivalent(jtfZtype.getText());
HashMap<String,String> operators = ldb.getIntrinsicOperator_equivalent();
operators.put(OzOperationBean.OPERATOR_ASSIGNMENT,"="); //this is hardcoded
operators.put(OzOperationBean.OPERATOR_PLUS,jtfPlusOper.getText());
operators.put(OzOperationBean.OPERATOR_MINUS,jtfMinusOper.getText());
operators.put(OzOperationBean.OPERATOR_MULTIPLY,jtfMultiplyOper.getText());
operators.put(OzOperationBean.OPERATOR_DIVIDE,jtfDivideOper.getText());
operators.put(OzOperationBean.OPERATOR_EQUAL,jtfEqualOper.getText());
operators.put(OzOperationBean.OPERATOR_NOT_EQUAL,jtfNotEqualOper.getText());
operators.put(OzOperationBean.OPERATOR_LESS,jtfLessOper.getText());
operators.put(OzOperationBean.OPERATOR_LESS_EQUAL,jtfLessEqualOper.getText());
operators.put(OzOperationBean.OPERATOR_GREATER,jtfGreaterOper.getText());
operators.put(OzOperationBean.OPERATOR_GREATER_EQUAL,jtfGreaterEqualOper.getText());
operators.put(OzOperationBean.OPERATOR_NOT,jtfNotOper.getText());
operators.put(OzOperationBean.OPERATOR_OR,jtfOrOper.getText());
operators.put(OzOperationBean.OPERATOR_AND,jtfAndOper.getText());
ldb.setExtrinsic_type_boolean_equivalent(jtfBoolType.getText());
ldb.setExtrinsic_typeValue_boolean_true_equivalent(jtfBoolTrueValue.getText());
ldb.setExtrinsic_typeValue_boolean_false_equivalent(jtfBoolFalseValue.getText());
ldb.setSetType_equivalent(jtfSetType.getText());
ldb.setSetTypeCloneTemplate(jtfSetCloneTpl.getText());
ldb.setSetTypeIsMemberOfTemplate(jtfSetIsMemberTpl.getText());
ldb.setSetTypeIsNotMemberOfTemplate(jtfSetIsNotMemberTpl.getText());
ldb.setSetTypeEqualsTemplate(jtfSetIsEqualTpl.getText());
ldb.setSetTypeUnionTemplate(jtfSetUnionTpl.getText());
ldb.setSetTypeIntersectTemplate(jtfSetIntersectTpl.getText());
ldb.setSetTypeCardinalityTemplate(jtfSetSizeTpl.getText());
ldb.setSetTypeSubsetTemplate(jtfSetIsSubsetTpl.getText());
}
this.parentWindow.showSaveFileDialog();
private void jtfBoolTrueValueActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
// Variables declaration private javax.swing.JLabel
private javax.swing.JLabel
private javax.swing.JLabel
private javax.swing.JLabel
private javax.swing.JLabel
private javax.swing.JLabel
private javax.swing.JLabel
do not modify
jLabel1;
jLabel10;
jLabel11;
jLabel12;
jLabel13;
jLabel14;
jLabel15;
101
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JPanel jPanel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton jbutClear;
private javax.swing.JButton jbutOK;
private javax.swing.JButton jbutPrev;
private javax.swing.JTextField jtfAndOper;
private javax.swing.JTextField jtfBoolFalseValue;
private javax.swing.JTextField jtfBoolTrueValue;
private javax.swing.JTextField jtfBoolType;
private javax.swing.JTextField jtfDivideOper;
private javax.swing.JTextField jtfEqualOper;
private javax.swing.JTextField jtfGreaterEqualOper;
private javax.swing.JTextField jtfGreaterOper;
private javax.swing.JTextField jtfLessEqualOper;
private javax.swing.JTextField jtfLessOper;
private javax.swing.JTextField jtfMinusOper;
private javax.swing.JTextField jtfMultiplyOper;
private javax.swing.JTextField jtfNotEqualOper;
private javax.swing.JTextField jtfNotOper;
private javax.swing.JTextField jtfNtype;
private javax.swing.JTextField jtfOrOper;
private javax.swing.JTextField jtfPlusOper;
private javax.swing.JTextField jtfSetCloneTpl;
private javax.swing.JTextField jtfSetIntersectTpl;
private javax.swing.JTextField jtfSetIsEqualTpl;
private javax.swing.JTextField jtfSetIsMemberTpl;
private javax.swing.JTextField jtfSetIsNotMemberTpl;
private javax.swing.JTextField jtfSetIsSubsetTpl;
private javax.swing.JTextField jtfSetSizeTpl;
private javax.swing.JTextField jtfSetType;
private javax.swing.JTextField jtfSetUnionTpl;
private javax.swing.JTextField jtfZtype;
// End of variables declaration
}
package edu.csus.fozcil.framework;
import
import
import
import
import
import
import
edu.csus.fozcil.bean.LanguageDependentBean;
edu.csus.fozcil.Constants;
edu.csus.fozcil.FozcilException;
edu.csus.fozcil.helper.BuildFileExecutor;
edu.csus.fozcil.helper.XmlFactory;
edu.csus.fozcil.helper.XmlTransformer;
java.io.File;
102
import
import
import
import
import
import
import
import
import
import
import
import
import
java.io.FileNotFoundException;
java.io.IOException;
java.util.Properties;
java.util.logging.Level;
javax.xml.parsers.ParserConfigurationException;
javax.xml.parsers.SAXParser;
javax.xml.transform.TransformerConfigurationException;
javax.xml.transform.TransformerException;
org.apache.log4j.Logger;
org.apache.log4j.PropertyConfigurator;
org.w3c.dom.Document;
org.xml.sax.SAXException;
org.xml.sax.XMLReader;
/**
*
* @author GeorgeN
*/
public class FrmkControlSystem {
private static Logger LOG;
private Properties appProps;
private LanguageDependentBean languageDependentBean;
public FrmkControlSystem() throws FozcilException {
//read application properties file
appProps = new Properties();
try {
appProps.load(FrmkControlSystem.class.getResourceAsStream(Constants.CONFIG_FOLDER_PATH +
"app.properties"));
} catch (IOException ex) {
throw new FozcilException("Error loading app.properties file", ex,
FozcilException.EXCEP_SEVERITY_HIGH);
}
//init Log4J
String log4jConfigFileName =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_LOG4J_CONFIG_FILE);
if ((log4jConfigFileName == null) || (log4jConfigFileName.equals("")))
System.out.println("Missing app property: " +
Constants.APP_PROPERTIES_KEY_LOG4J_CONFIG_FILE);
Properties log4jProps = new Properties();
try {
log4jProps.load(FrmkControlSystem.class.getResourceAsStream(Constants.CONFIG_FOLDER_PATH
+ log4jConfigFileName));
} catch (IOException ex) {
throw new FozcilException("Error initializing logger. Please configure.", ex,
FozcilException.EXCEP_SEVERITY_LOW);
}
PropertyConfigurator.configure(log4jProps);
LOG = Logger.getLogger(FrmkControlSystem.class.getName());
LOG.debug("Logger initialized.");
}
//init LanguageDependent bean
languageDependentBean = new LanguageDependentBean();
/*
* We write to an XML file and save it to the the file system
*/
public void saveLanguageDependentData() throws FozcilException {
//build DOM
Document document =
LanguageDependentDomBuilder.buildDocument(this.languageDependentBean);
//get XmlTransformer
XmlTransformer xmltranformer = XmlFactory.getXmlTranformer();
//set XML o/p
String langDependPath =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_HOME);
if ((langDependPath == null) || (langDependPath.equals(""))) {
103
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_HOME;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String langDependFileName =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_FILE);
if ((langDependFileName == null) || (langDependFileName.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_FILE;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String filePath = System.getProperty("user.dir") + File.separator +
langDependPath + File.separator + langDependFileName;
try {
xmltranformer.tranformXML(null, document, filePath);
LOG.debug("Language Dependent XML written successfully.");
} catch (TransformerConfigurationException ex) {
String errMsg = "XMLTransformer has not been configured properly";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (TransformerException ex) {
String errMsg = "Error transforming DOM to XML data";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (FileNotFoundException ex) {
String errMsg = "Error while saving XML data";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (IOException ex) {
String errMsg = "General IO error";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
}
}
public LanguageDependentBean loadLanguageDependentData() throws FozcilException {
//read LD file properties
String langDependPath =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_HOME);
if ((langDependPath == null) || (langDependPath.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_HOME;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String langDependFileName =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_FILE);
if ((langDependFileName == null) || (langDependFileName.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_FILE;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String filePath = System.getProperty("user.dir") + File.separator +
langDependPath + File.separator + langDependFileName;
File infile = new File(filePath);
//parse the LD file
try {
LanguageDependentContentHandler ch = new
LanguageDependentContentHandler(this.languageDependentBean);
SAXParser parser = XmlFactory.getXmlReader(XmlFactory.SAX_READER);
parser.parse(infile, ch);
} catch (IOException ex) {
String errMsg = "Error reading Language Dependent file";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (ParserConfigurationException ex) {
String errMsg = "Parser configuration error";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (SAXException ex) {
104
String errMsg = "General SAX error";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
}
LOG.debug("LanguageDependentData loaded successfully.");
return this.languageDependentBean;
}
/*
* Run ANT task to create the distributable tool
*/
public void createTool() throws FozcilException {
//read properties
String buildFileName =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BUILD_FILE);
if ((buildFileName == null) || (buildFileName.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BUILD_FILE;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String buildTaskName =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BUILD_FILE_CREATETOOL_TASK);
if ((buildTaskName == null) || (buildTaskName.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BUILD_FILE_CREATETOOL_TASK;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
//create tool distributable
BuildFileExecutor.executeTaskCreateTool(buildFileName, buildTaskName);
LOG.debug("FOZCIL Tool instance is now available in the /dist folder");
}
public LanguageDependentBean getLanguageDependentBean() {
return languageDependentBean;
}
}
package edu.csus.fozcil.framework;
import
import
import
import
import
import
edu.csus.fozcil.bean.LanguageDependentBean;
edu.csus.fozcil.bean.OzOperationBean;
org.apache.log4j.Logger;
org.xml.sax.Attributes;
org.xml.sax.SAXException;
org.xml.sax.helpers.DefaultHandler;
/**
* @author GeorgeN
*/
public class LanguageDependentContentHandler extends DefaultHandler {
private static Logger LOG =
Logger.getLogger(LanguageDependentContentHandler.class.getName());
LanguageDependentBean ldbean = null;
StringBuffer content_buffer = null;
public LanguageDependentContentHandler(LanguageDependentBean ldbean) {
super();
this.ldbean = ldbean;
}
@Override
public void startElement(String namespaceURI, String localName, String
qualifiedName, Attributes atts) throws SAXException {
//LOG.debug("LanguageDependentrContentHandler>startElement - " + localName);
//initialize new buffer to handle characters
content_buffer = new StringBuffer();
105
}
@Override
public void endElement(String namespaceURI, String localName, String qualifiedName)
throws SAXException {
//LOG.debug("LanguageDependentrContentHandler>endElement - " +
qualifiedName);
//take action as necessary
if (qualifiedName.equals("languageName")) {
ldbean.setLanguageName(content_buffer.toString());
} else if (qualifiedName.equals("languageFileExtension")) {
ldbean.setLanguageFileExtension(content_buffer.toString());
} else if (qualifiedName.equals("classTemplate")) {
ldbean.setClassTemplate(content_buffer.toString());
} else if (qualifiedName.equals("variableDeclTemplate")) {
ldbean.setVariableDeclarationTemplate(content_buffer.toString());
} else if (qualifiedName.equals("objectConstructorTemplate")) {
ldbean.setObjectConstructorTemplate(content_buffer.toString());
} else if (qualifiedName.equals("methodTemplate")) {
ldbean.setMethodTemplate(content_buffer.toString());
} else if (qualifiedName.equals("methodArgumentSeparator")) {
ldbean.setMethodArgumentSeparator(content_buffer.toString());
} else if (qualifiedName.equals("printTemplate")) {
ldbean.setPrintCommentTemplate(content_buffer.toString());
} else if (qualifiedName.equals("ifTemplate")) {
ldbean.setIfStatementTemplate(content_buffer.toString());
} else if (qualifiedName.equals("returnTemplate")) {
ldbean.setReturnStatementTemplate(content_buffer.toString());
} else if (qualifiedName.equals("statementEndSymbol")) {
ldbean.setStatementEndSymbol(content_buffer.toString());
} else if (qualifiedName.equals("enumTemplate")) {
ldbean.setEnumTemplate(content_buffer.toString());
} else if (qualifiedName.equals("enumValueSeparator")) {
ldbean.setEnumValueSeparator(content_buffer.toString());
} else if (qualifiedName.equals("typeOzNEquivalent")) {
ldbean.setIntrinsic_type_N_equivalent(content_buffer.toString());
} else if (qualifiedName.equals("typeOzZEquivalent")) {
ldbean.setIntrinsic_type_Z_equivalent(content_buffer.toString());
} else if (qualifiedName.equals("operatorAssignment")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_ASSIGNMENT,
content_buffer.toString());
} else if (qualifiedName.equals("operatorArithmeticPlus")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_PLUS,
content_buffer.toString());
} else if (qualifiedName.equals("operatorArithmeticMinus")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_MINUS,
content_buffer.toString());
} else if (qualifiedName.equals("operatorArithmeticMultiply")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_MULTIPLY,
content_buffer.toString());
} else if (qualifiedName.equals("operatorArithmeticDivide")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_DIVIDE,
content_buffer.toString());
} else if (qualifiedName.equals("operatorRelationalEqual")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_EQUAL,
content_buffer.toString());
} else if (qualifiedName.equals("operatorRelationalNotEqual")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_NOT_EQUAL,
content_buffer.toString());
} else if (qualifiedName.equals("operatorRelationalLess")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_LESS,
content_buffer.toString());
} else if (qualifiedName.equals("operatorRelationalLessEqual")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_LESS_EQUAL,
content_buffer.toString());
} else if (qualifiedName.equals("operatorRelationalGreater")) {
106
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_GREATER,
content_buffer.toString());
} else if (qualifiedName.equals("operatorRelationalGreaterEqual")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_GREATER_EQUAL,
content_buffer.toString());
} else if (qualifiedName.equals("operatorLogicalNot")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_NOT,
content_buffer.toString());
} else if (qualifiedName.equals("operatorLogicalOr")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_OR,
content_buffer.toString());
} else if (qualifiedName.equals("operatorLogicalAnd")) {
ldbean.addIntrinsicOperator_equivalent(OzOperationBean.OPERATOR_AND,
content_buffer.toString());
} else if (qualifiedName.equals("typeIlBoolEquivalent")) {
ldbean.setExtrinsic_type_boolean_equivalent(content_buffer.toString());
} else if (qualifiedName.equals("typeValueBoolTrueEquivalent")) {
ldbean.setExtrinsic_typeValue_boolean_true_equivalent(content_buffer.toString());
} else if (qualifiedName.equals("typeValueBoolFalseEquivalent")) {
ldbean.setExtrinsic_typeValue_boolean_false_equivalent(content_buffer.toString());
} else if (qualifiedName.equals("setTypeEquivalent")) {
ldbean.setSetType_equivalent(content_buffer.toString());
} else if (qualifiedName.equals("cloneTemplate")) {
ldbean.setSetTypeCloneTemplate(content_buffer.toString());
} else if (qualifiedName.equals("isMemberTemplate")) {
ldbean.setSetTypeIsMemberOfTemplate(content_buffer.toString());
} else if (qualifiedName.equals("isNotMemberTemplate")) {
ldbean.setSetTypeIsNotMemberOfTemplate(content_buffer.toString());
} else if (qualifiedName.equals("equalsTemplate")) {
ldbean.setSetTypeEqualsTemplate(content_buffer.toString());
} else if (qualifiedName.equals("unionTemplate")) {
ldbean.setSetTypeUnionTemplate(content_buffer.toString());
} else if (qualifiedName.equals("intersectTemplate")) {
ldbean.setSetTypeIntersectTemplate(content_buffer.toString());
} else if (qualifiedName.equals("cardinalityTemplate")) {
ldbean.setSetTypeCardinalityTemplate(content_buffer.toString());
} else if (qualifiedName.equals("subsetTemplate")) {
ldbean.setSetTypeSubsetTemplate(content_buffer.toString());
}
}
//reset the buffer
content_buffer = null;
@Override
public void characters(char[] text, int start, int length) throws SAXException {
//LOG.debug("LanguageDependentrContentHandler>characters - " + new
String(text, start, length));
//logic to handle split content
if (content_buffer != null) {
content_buffer.append(text, start, length);
}
}
}
package edu.csus.fozcil.framework;
import
import
import
import
edu.csus.fozcil.bean.LanguageDependentBean;
edu.csus.fozcil.bean.OzOperationBean;
edu.csus.fozcil.bean.OzSpecificationBean;
java.io.StringWriter;
import java.util.HashMap;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.log4j.Logger;
107
import org.w3c.dom.Document;
import org.w3c.dom.Element;
//import org.w3c.dom.bootstrap.DOMImplementationRegistry;
//import org.w3c.dom.ls.DOMImplementationLS;
//import org.w3c.dom.ls.LSOutput;
//import org.w3c.dom.ls.LSSerializer;
/**
*
* @author GeorgeN
*/
public class LanguageDependentDomBuilder {
private static Logger LOG =
Logger.getLogger(LanguageDependentDomBuilder.class.getName());
public static Document buildDocument(LanguageDependentBean ldbean) {
Document doc = null;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.newDocument();
Element
Element root = doc.createElementNS(null, "languageDependent"); // Create Root
//General level
Element generalData= doc.createElementNS(null, "generalData");
root.appendChild( generalData );
Element item = doc.createElementNS(null, "languageName");
item.appendChild( doc.createTextNode(ldbean.getLanguageName()) );
generalData.appendChild( item );
item = doc.createElementNS(null, "languageFileExtension");
item.appendChild( doc.createTextNode(ldbean.getLanguageFileExtension()) );
generalData.appendChild( item );
//Structural level
Element structuralData = doc.createElementNS(null, "structuralData");
root.appendChild( structuralData );
item = doc.createElementNS(null, "classTemplate");
item.appendChild( doc.createCDATASection(ldbean.getClassTemplate()) );
structuralData.appendChild( item );
item = doc.createElementNS(null, "variableDeclTemplate");
item.appendChild(
doc.createCDATASection(ldbean.getVariableDeclarationTemplate()) );
structuralData.appendChild( item );
item = doc.createElementNS(null, "objectConstructorTemplate");
item.appendChild(
doc.createCDATASection(ldbean.getObjectConstructorTemplate()) );
structuralData.appendChild( item );
item = doc.createElementNS(null, "methodTemplate");
item.appendChild( doc.createCDATASection(ldbean.getMethodTemplate()) );
structuralData.appendChild( item );
item = doc.createElementNS(null, "methodArgumentSeparator");
item.appendChild( doc.createCDATASection(ldbean.getMethodArgumentSeparator())
);
structuralData.appendChild( item );
item = doc.createElementNS(null, "printTemplate");
item.appendChild( doc.createCDATASection(ldbean.getPrintCommentTemplate()) );
structuralData.appendChild( item );
item = doc.createElementNS(null, "ifTemplate");
item.appendChild( doc.createCDATASection(ldbean.getIfStatementTemplate()) );
structuralData.appendChild( item );
item = doc.createElementNS(null, "returnTemplate");
108
item.appendChild( doc.createCDATASection(ldbean.getReturnStatementTemplate())
);
structuralData.appendChild( item );
item = doc.createElementNS(null, "statementEndSymbol");
item.appendChild( doc.createCDATASection(ldbean.getStatementEndSymbol()) );
structuralData.appendChild( item );
item = doc.createElementNS(null, "enumTemplate");
item.appendChild( doc.createCDATASection(ldbean.getEnumTemplate()) );
structuralData.appendChild( item );
item = doc.createElementNS(null, "enumValueSeparator");
item.appendChild( doc.createCDATASection(ldbean.getEnumValueSeparator()) );
structuralData.appendChild( item );
//Type level
Element typeData = doc.createElementNS(null, "typeData");
root.appendChild( typeData );
//Type level - integer
Element typeIntegerData = doc.createElementNS(null, "typeIntegerData");
typeData.appendChild( typeIntegerData );
item = doc.createElementNS(null, "typeOzNEquivalent");
item.appendChild(
doc.createCDATASection(ldbean.getIntrinsic_type_N_equivalent()) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "typeOzZEquivalent");
item.appendChild(
doc.createCDATASection(ldbean.getIntrinsic_type_Z_equivalent()) );
typeIntegerData.appendChild( item );
HashMap<String,String> operators = ldbean.getIntrinsicOperator_equivalent();
item = doc.createElementNS(null, "operatorAssignment");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_ASSIGNMENT)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorArithmeticPlus");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_PLUS)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorArithmeticMinus");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_MINUS)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorArithmeticMultiply");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_MULTIPLY)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorArithmeticDivide");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_DIVIDE)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorRelationalEqual");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_EQUAL)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorRelationalNotEqual");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_NOT_EQUAL)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorRelationalLess");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_LESS)) );
109
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorRelationalLessEqual");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_LESS_EQUAL)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorRelationalGreater");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_GREATER)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorRelationalGreaterEqual");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_GREATER_EQUAL)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorLogicalNot");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_NOT)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorLogicalOr");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_OR)) );
typeIntegerData.appendChild( item );
item = doc.createElementNS(null, "operatorLogicalAnd");
item.appendChild(
doc.createCDATASection(operators.get(OzOperationBean.OPERATOR_AND)) );
typeIntegerData.appendChild( item );
//Type level - integer
Element typeBooleanData = doc.createElementNS(null, "typeBooleanData");
typeData.appendChild( typeBooleanData );
item = doc.createElementNS(null, "typeIlBoolEquivalent");
item.appendChild(
doc.createCDATASection(ldbean.getExtrinsic_type_boolean_equivalent()) );
typeBooleanData.appendChild( item );
item = doc.createElementNS(null, "typeValueBoolTrueEquivalent");
item.appendChild(
doc.createCDATASection(ldbean.getExtrinsic_typeValue_boolean_true_equivalent()) );
typeBooleanData.appendChild( item );
item = doc.createElementNS(null, "typeValueBoolFalseEquivalent");
item.appendChild(
doc.createCDATASection(ldbean.getExtrinsic_typeValue_boolean_false_equivalent()) );
typeBooleanData.appendChild( item );
//Type level - integer
Element typeSetData = doc.createElementNS(null, "typeSetData");
typeData.appendChild( typeSetData );
item = doc.createElementNS(null, "setTypeEquivalent");
item.appendChild( doc.createCDATASection(ldbean.getSetType_equivalent()) );
typeSetData.appendChild( item );
item = doc.createElementNS(null, "cloneTemplate");
item.appendChild( doc.createCDATASection(ldbean.getSetTypeCloneTemplate()) );
typeSetData.appendChild( item );
item = doc.createElementNS(null, "isMemberTemplate");
item.appendChild(
doc.createCDATASection(ldbean.getSetTypeIsMemberOfTemplate()) );
typeSetData.appendChild( item );
item = doc.createElementNS(null, "isNotMemberTemplate");
item.appendChild(
doc.createCDATASection(ldbean.getSetTypeIsNotMemberOfTemplate()) );
typeSetData.appendChild( item );
item = doc.createElementNS(null, "equalsTemplate");
110
item.appendChild( doc.createCDATASection(ldbean.getSetTypeEqualsTemplate())
);
typeSetData.appendChild( item );
item = doc.createElementNS(null, "unionTemplate");
item.appendChild( doc.createCDATASection(ldbean.getSetTypeUnionTemplate()) );
typeSetData.appendChild( item );
item = doc.createElementNS(null, "intersectTemplate");
item.appendChild(
doc.createCDATASection(ldbean.getSetTypeIntersectTemplate()) );
typeSetData.appendChild( item );
item = doc.createElementNS(null, "cardinalityTemplate");
item.appendChild(
doc.createCDATASection(ldbean.getSetTypeCardinalityTemplate()) );
typeSetData.appendChild( item );
);
item = doc.createElementNS(null, "subsetTemplate");
item.appendChild( doc.createCDATASection(ldbean.getSetTypeSubsetTemplate())
typeSetData.appendChild( item );
doc.appendChild( root );
//
DOMImplementationRegistry registry =
DOMImplementationRegistry.newInstance();
//
DOMImplementationLS domImplLS =
(DOMImplementationLS)registry.getDOMImplementation("LS");
//
LSSerializer ser = domImplLS.createLSSerializer();
for the DOM
//
LSOutput out = domImplLS.createLSOutput();
//
StringWriter stringOut = new StringWriter();
String
//
out.setCharacterStream(stringOut);
//
ser.write(doc, out);
//
System.out.println( "STRXML = "
//
+ stringOut.toString() );
a String
} catch ( Exception ex ) {
ex.printStackTrace();
}
return doc;
}
// Create a serializer
// Writer will be a
// Serialize the DOM
// Spit out the DOM as
}
package edu.csus.fozcil.helper;
import java.io.File;
import org.apache.tools.ant.*;
/**
*
* @author GeorgeN
*/
public class BuildFileExecutor {
//
private static final String BUILD_FILE_NAME = "build_create_fozcil_tool.xml";
//
public static final String BUILD_FILE_TASK = "createtool";
{
public static void executeTaskCreateTool(String buildFileName, String buildTaskName)
//new ANT project
Project project = new Project();
project.init();
//populate Project from build file
File buildFile = new File(System.getProperty("user.dir"), buildFileName);
ProjectHelper.configureProject(project, buildFile);
//add listener to determine end of task
//project.addBuildListener( new DefaultLogger());
111
}
//execute task
project.executeTarget(buildTaskName);
}
package edu.csus.fozcil.helper;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
import
import
import
import
java.io.OutputStream;
java.io.OutputStreamWriter;
java.io.PrintWriter;
java.io.UnsupportedEncodingException;
java.lang.reflect.Method;
import
import
import
import
import
org.w3c.dom.Attr;
org.w3c.dom.Document;
org.w3c.dom.DocumentType;
org.w3c.dom.NamedNodeMap;
org.w3c.dom.Node;
/**
* A sample DOM writer. This sample program illustrates how to
* traverse a DOM tree in order to print a document that is parsed.
*
* @author Andy Clark, IBM
*
* @version $Id: Writer.java 447683 2006-09-19 02:36:31Z mrglavas $
*/
public class DomXmlWriter implements XmlWriter {
//
// Constants
//
// feature ids
/** Namespaces feature id (http://xml.org/sax/features/namespaces). */
protected static final String NAMESPACES_FEATURE_ID =
"http://xml.org/sax/features/namespaces";
/** Validation feature id (http://xml.org/sax/features/validation). */
protected static final String VALIDATION_FEATURE_ID =
"http://xml.org/sax/features/validation";
*/
/** Schema validation feature id (http://apache.org/xml/features/validation/schema).
protected static final String SCHEMA_VALIDATION_FEATURE_ID =
"http://apache.org/xml/features/validation/schema";
/** Schema full checking feature id
(http://apache.org/xml/features/validation/schema-full-checking). */
protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
"http://apache.org/xml/features/validation/schema-full-checking";
/** Honour all schema locations feature id (http://apache.org/xml/features/honourall-schemaLocations). */
112
protected static final String HONOUR_ALL_SCHEMA_LOCATIONS_ID =
"http://apache.org/xml/features/honour-all-schemaLocations";
/** Validate schema annotations feature id (http://apache.org/xml/features/validateannotations). */
protected static final String VALIDATE_ANNOTATIONS_ID =
"http://apache.org/xml/features/validate-annotations";
/** Generate synthetic schema annotations feature id
(http://apache.org/xml/features/generate-synthetic-annotations). */
protected static final String GENERATE_SYNTHETIC_ANNOTATIONS_ID =
"http://apache.org/xml/features/generate-synthetic-annotations";
/** Dynamic validation feature id
(http://apache.org/xml/features/validation/dynamic). */
protected static final String DYNAMIC_VALIDATION_FEATURE_ID =
"http://apache.org/xml/features/validation/dynamic";
/** Load external DTD feature id (http://apache.org/xml/features/nonvalidating/loadexternal-dtd). */
protected static final String LOAD_EXTERNAL_DTD_FEATURE_ID =
"http://apache.org/xml/features/nonvalidating/load-external-dtd";
/** XInclude feature id (http://apache.org/xml/features/xinclude). */
protected static final String XINCLUDE_FEATURE_ID =
"http://apache.org/xml/features/xinclude";
/** XInclude fixup base URIs feature id
(http://apache.org/xml/features/xinclude/fixup-base-uris). */
protected static final String XINCLUDE_FIXUP_BASE_URIS_FEATURE_ID =
"http://apache.org/xml/features/xinclude/fixup-base-uris";
/** XInclude fixup language feature id
(http://apache.org/xml/features/xinclude/fixup-language). */
protected static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE_ID =
"http://apache.org/xml/features/xinclude/fixup-language";
// default settings
/** Default parser name. */
protected static final String DEFAULT_PARSER_NAME = "dom.wrappers.Xerces";
/** Default namespaces support (true). */
protected static final boolean DEFAULT_NAMESPACES = true;
/** Default validation support (false). */
protected static final boolean DEFAULT_VALIDATION = false;
/** Default load external DTD (true). */
protected static final boolean DEFAULT_LOAD_EXTERNAL_DTD = true;
/** Default Schema validation support (false). */
protected static final boolean DEFAULT_SCHEMA_VALIDATION = false;
/** Default Schema full checking support (false). */
protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
/** Default honour all schema locations (false). */
protected static final boolean DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS = false;
/** Default validate schema annotations (false). */
protected static final boolean DEFAULT_VALIDATE_ANNOTATIONS = false;
/** Default generate synthetic schema annotations (false). */
protected static final boolean DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS = false;
/** Default dynamic validation support (false). */
protected static final boolean DEFAULT_DYNAMIC_VALIDATION = false;
/** Default XInclude processing support (false). */
protected static final boolean DEFAULT_XINCLUDE = false;
/** Default XInclude fixup base URIs support (true). */
protected static final boolean DEFAULT_XINCLUDE_FIXUP_BASE_URIS = true;
113
/** Default XInclude fixup language support (true). */
protected static final boolean DEFAULT_XINCLUDE_FIXUP_LANGUAGE = true;
/** Default canonical output (false). */
protected static final boolean DEFAULT_CANONICAL = false;
//
// Data
//
/** Print writer. */
protected PrintWriter fOut;
/** Canonical output. */
protected boolean fCanonical;
/** Processing XML 1.1 document. */
protected boolean fXML11;
//
// Constructors
//
/** Default constructor. */
public DomXmlWriter() {
} // <init>()
public DomXmlWriter(boolean canonical) {
fCanonical = canonical;
} // <init>(boolean)
//
// Public methods
//
/** Sets whether output is canonical. */
public void setCanonical(boolean canonical) {
fCanonical = canonical;
} // setCanonical(boolean)
/** Sets the output stream for printing. */
public void setOutput(OutputStream stream, String encoding)
throws UnsupportedEncodingException {
if (encoding == null) {
encoding = "UTF8";
}
java.io.Writer writer = new OutputStreamWriter(stream, encoding);
fOut = new PrintWriter(writer);
} // setOutput(OutputStream,String)
/** Sets the output writer. */
public void setOutput(java.io.Writer writer) {
fOut = writer instanceof PrintWriter
? (PrintWriter)writer : new PrintWriter(writer);
} // setOutput(java.io.Writer)
/** Writes the specified node, recursively. */
public void write(Node node) {
// is there anything to do?
if (node == null) {
return;
}
short type = node.getNodeType();
switch (type) {
case Node.DOCUMENT_NODE: {
Document document = (Document)node;
114
fXML11 = "1.1".equals(getVersion(document));
if (!fCanonical) {
if (fXML11) {
fOut.println("<?xml version=\"1.1\" encoding=\"UTF-8\"?>");
}
else {
fOut.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
}
fOut.flush();
write(document.getDoctype());
}
write(document.getDocumentElement());
break;
}
case Node.DOCUMENT_TYPE_NODE: {
DocumentType doctype = (DocumentType)node;
fOut.print("<!DOCTYPE ");
fOut.print(doctype.getName());
String publicId = doctype.getPublicId();
String systemId = doctype.getSystemId();
if (publicId != null) {
fOut.print(" PUBLIC '");
fOut.print(publicId);
fOut.print("' '");
fOut.print(systemId);
fOut.print('\'');
}
else if (systemId != null) {
fOut.print(" SYSTEM '");
fOut.print(systemId);
fOut.print('\'');
}
String internalSubset = doctype.getInternalSubset();
if (internalSubset != null) {
fOut.println(" [");
fOut.print(internalSubset);
fOut.print(']');
}
fOut.println('>');
break;
}
case Node.ELEMENT_NODE: {
fOut.print('<');
fOut.print(node.getNodeName());
Attr attrs[] = sortAttributes(node.getAttributes());
for (int i = 0; i < attrs.length; i++) {
Attr attr = attrs[i];
fOut.print(' ');
fOut.print(attr.getNodeName());
fOut.print("=\"");
normalizeAndPrint(attr.getNodeValue(), true);
fOut.print('"');
}
fOut.print('>');
fOut.flush();
Node child = node.getFirstChild();
while (child != null) {
write(child);
child = child.getNextSibling();
}
break;
}
case Node.ENTITY_REFERENCE_NODE: {
if (fCanonical) {
Node child = node.getFirstChild();
while (child != null) {
write(child);
child = child.getNextSibling();
}
}
115
else {
fOut.print('&');
fOut.print(node.getNodeName());
fOut.print(';');
fOut.flush();
}
break;
}
case Node.CDATA_SECTION_NODE: {
if (fCanonical) {
normalizeAndPrint(node.getNodeValue(), false);
}
else {
fOut.print("<![CDATA[");
fOut.print(node.getNodeValue());
fOut.print("]]>");
}
fOut.flush();
break;
}
case Node.TEXT_NODE: {
normalizeAndPrint(node.getNodeValue(), false);
fOut.flush();
break;
}
case Node.PROCESSING_INSTRUCTION_NODE: {
fOut.print("<?");
fOut.print(node.getNodeName());
String data = node.getNodeValue();
if (data != null && data.length() > 0) {
fOut.print(' ');
fOut.print(data);
}
fOut.print("?>");
fOut.flush();
break;
}
case Node.COMMENT_NODE: {
if (!fCanonical) {
fOut.print("<!--");
String comment = node.getNodeValue();
if (comment != null && comment.length() > 0) {
fOut.print(comment);
}
fOut.print("-->");
fOut.flush();
}
}
}
if (type == Node.ELEMENT_NODE) {
fOut.print("</");
fOut.print(node.getNodeName());
fOut.print('>');
fOut.flush();
}
} // write(Node)
/** Returns a sorted list of attributes. */
protected Attr[] sortAttributes(NamedNodeMap attrs) {
int len = (attrs != null) ? attrs.getLength() : 0;
Attr array[] = new Attr[len];
for (int i = 0; i < len; i++) {
array[i] = (Attr)attrs.item(i);
}
for (int i = 0; i < len - 1; i++) {
String name = array[i].getNodeName();
int index = i;
116
for (int j = i + 1; j < len; j++) {
String curName = array[j].getNodeName();
if (curName.compareTo(name) < 0) {
name = curName;
index = j;
}
}
if (index != i) {
Attr temp = array[i];
array[i] = array[index];
array[index] = temp;
}
}
return array;
} // sortAttributes(NamedNodeMap):Attr[]
//
// Protected methods
//
/** Normalizes and prints the given string. */
protected void normalizeAndPrint(String s, boolean isAttValue) {
int len = (s != null) ? s.length() : 0;
for (int i = 0; i < len; i++) {
char c = s.charAt(i);
normalizeAndPrint(c, isAttValue);
}
} // normalizeAndPrint(String,boolean)
/** Normalizes and print the given character. */
protected void normalizeAndPrint(char c, boolean isAttValue) {
switch (c) {
case '<': {
fOut.print("<");
break;
}
case '>': {
fOut.print(">");
break;
}
case '&': {
fOut.print("&");
break;
}
case '"': {
// A '"' that appears in character data
// does not need to be escaped.
if (isAttValue) {
fOut.print(""");
}
else {
fOut.print("\"");
}
break;
}
case '\r': {
// If CR is part of the document's content, it
// must not be printed as a literal otherwise
// it would be normalized to LF when the document
// is reparsed.
fOut.print("
");
break;
}
case '\n': {
if (fCanonical) {
fOut.print("
");
break;
}
// else, default print char
117
}
default: {
// In XML 1.1, control chars in the ranges [#x1-#x1F, #x7F-#x9F] must be
escaped.
//
// Escape space characters that would be normalized to #x20 in attribute
values
//
//
//
//
//
if
when the document is reparsed.
Escape NEL (0x85) and LSEP (0x2028) that appear in content
if the document is XML 1.1, since they would be normalized to LF
when the document is reparsed.
(fXML11 && ((c >= 0x01 && c <= 0x1F && c != 0x09 && c != 0x0A)
|| (c >= 0x7F && c <= 0x9F) || c == 0x2028)
|| isAttValue && (c == 0x09 || c == 0x0A)) {
fOut.print("&#x");
fOut.print(Integer.toHexString(c).toUpperCase());
fOut.print(";");
}
else {
fOut.print(c);
}
}
}
} // normalizeAndPrint(char,boolean)
/** Extracts the XML version from the Document. */
protected String getVersion(Document document) {
if (document == null) {
return null;
}
String version = null;
Method getXMLVersion = null;
try {
getXMLVersion = document.getClass().getMethod("getXmlVersion", new
Class[]{});
// If Document class implements DOM L3, this method will exist.
if (getXMLVersion != null) {
version = (String) getXMLVersion.invoke(document, (Object[]) null);
}
}
catch (Exception e) {
// Either this locator object doesn't have
// this method, or we're on an old JDK.
}
return version;
} // getVersion(Document)
//
// Private static methods
//
/** Prints the usage. */
private static void printUsage() {
System.err.println("usage: java dom.Writer (options) uri ...");
System.err.println();
System.err.println("options:");
System.err.println(" -p name
System.err.println(" -n | -N
System.err.println(" -v | -V
System.err.println(" -xd | -XD
System.err.println("
supported by all parsers.");
System.err.println(" -s | -S
System.err.println("
System.err.println(" -f | -F
System.err.println("
all parsers.");
System.err.println(" -hs | -HS
locations.");
System.err.println("
all parsers.");
Select parser by name.");
Turn on/off namespace processing.");
Turn on/off validation.");
Turn on/off loading of external DTDs.");
NOTE: Always on when -v in use and not
Turn on/off Schema validation support.");
NOTE: Not supported by all parsers.");
Turn on/off Schema full checking.");
NOTE: Requires use of -s and not supported by
Turn on/off honouring of all schema
NOTE: Requires use of -s and not supported by
118
System.err.println("
annotations.");
System.err.println("
all parsers.");
System.err.println("
annotations.");
System.err.println("
all parsers.");
System.err.println("
System.err.println("
System.err.println("
System.err.println("
System.err.println("
processing.");
System.err.println("
all parsers.");
System.err.println("
processing.");
System.err.println("
all parsers.");
System.err.println("
System.err.println("
System.err.println("
System.err.println();
-va | -VA
Turn on/off validation of schema
NOTE: Requires use of -s and not supported by
-ga | -GA
Turn on/off generation of synthetic schema
NOTE: Requires use of -s and not supported by
-dv | -DV
-xi | -XI
-xb | -XB
Turn on/off dynamic validation.");
NOTE: Not supported by all parsers.");
Turn on/off XInclude processing.");
NOTE: Not supported by all parsers.");
Turn on/off base URI fixup during XInclude
NOTE: Requires use of -xi and not supported by
-xl | -XL
Turn on/off language fixup during XInclude
NOTE: Requires use of -xi and not supported by
-c | -C
-h
Turn on/off Canonical XML output.");
NOTE: This is not W3C canonical output.");
This help screen.");
System.err.println("defaults:");
System.err.println(" Parser:
"+DEFAULT_PARSER_NAME);
System.err.print(" Namespaces: ");
System.err.println(DEFAULT_NAMESPACES ? "on" : "off");
System.err.print(" Validation: ");
System.err.println(DEFAULT_VALIDATION ? "on" : "off");
System.err.print(" Load External DTD: ");
System.err.println(DEFAULT_LOAD_EXTERNAL_DTD ? "on" : "off");
System.err.print(" Schema:
");
System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
System.err.print(" Schema full checking:
");
System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
System.err.print(" Dynamic:
");
System.err.println(DEFAULT_DYNAMIC_VALIDATION ? "on" : "off");
System.err.print(" Canonical: ");
System.err.println(DEFAULT_CANONICAL ? "on" : "off");
System.err.print(" Honour all schema locations:
");
System.err.println(DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS ? "on" : "off");
System.err.print(" Validate Annotations:
");
System.err.println(DEFAULT_VALIDATE_ANNOTATIONS ? "on" : "off");
System.err.print(" Generate Synthetic Annotations:
");
System.err.println(DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS ? "on" : "off");
System.err.print(" XInclude:
");
System.err.println(DEFAULT_XINCLUDE ? "on" : "off");
System.err.print(" XInclude base URI fixup: ");
System.err.println(DEFAULT_XINCLUDE_FIXUP_BASE_URIS ? "on" : "off");
System.err.print(" XInclude language fixup: ");
System.err.println(DEFAULT_XINCLUDE_FIXUP_LANGUAGE ? "on" : "off");
} // printUsage()
}
// class Writer
package edu.csus.fozcil.helper;
import
import
import
import
import
javax.xml.parsers.ParserConfigurationException;
javax.xml.parsers.SAXParser;
javax.xml.parsers.SAXParserFactory;
org.apache.log4j.Logger;
org.xml.sax.SAXException;
/**
*
* @author GeorgeN
*/
public final class XmlFactory {
private static Logger LOG = Logger.getLogger(XmlFactory.class.getName());
119
public static final int DOM_READER = 1;
public static final int SAX_READER = 2;
public static final int DOM_WRITER = 3;
private XmlFactory() {};
public static SAXParser getXmlReader(int type) throws ParserConfigurationException,
SAXException {
SAXParser xr = null;
switch (type) {
case DOM_READER:
System.out.println("DOM XML Reader is not implemented yet!");
break;
case SAX_READER:
try {
SAXParserFactory fact = SAXParserFactory.newInstance();
xr = fact.newSAXParser();
} catch (ParserConfigurationException ex) {
LOG.error("Error reating SAX reader", ex);
throw ex;
} catch (SAXException ex) {
LOG.error("Error reating SAX reader", ex);
throw ex;
}
break;
default:
System.out.println("XML Reader type" + type + " is not supported.");
}
return xr;
}
public static XmlWriter getXmlWriter(int type) {
XmlWriter xw = null;
switch (type) {
case DOM_WRITER:
xw = new DomXmlWriter();
break;
default:
System.out.println("XML Writer type" + type + " is not supported.");
}
return xw;
}
public static XmlTransformer getXmlTranformer() {
XmlTransformer xt = new XmlTransformer();
return xt;
}
}
package edu.csus.fozcil.helper;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
/**
java.io.File;
java.io.FileNotFoundException;
java.io.FileReader;
java.io.FileWriter;
java.io.IOException;
javax.xml.transform.OutputKeys;
javax.xml.transform.Result;
javax.xml.transform.Source;
javax.xml.transform.Templates;
javax.xml.transform.Transformer;
javax.xml.transform.TransformerConfigurationException;
javax.xml.transform.TransformerException;
javax.xml.transform.TransformerFactory;
javax.xml.transform.dom.DOMSource;
javax.xml.transform.stream.StreamResult;
javax.xml.transform.stream.StreamSource;
org.apache.log4j.Logger;
org.w3c.dom.Document;
120
* XmlTransformer for managing all XML and XSL related operations.
* @author GeorgeN
*/
public class XmlTransformer {
private static final Logger LOG = Logger.getLogger(XmlTransformer.class);
/**
* Applies XSL tranformation to an XML file to produce a target (XML?) file.
* @param xslFileName
* @param xmlSourceFileName
* @param xmlTargetFileName
* @throws edu.csus.fozcil.app.FozcilException
*/
public void tranformXML(String xslFileName, String xmlSourceFileName, String
xmlTargetFileName) throws FileNotFoundException, TransformerConfigurationException,
IOException, TransformerException {
//create an XSL factory
TransformerFactory factory = TransformerFactory.newInstance();
//create XSL object
Source xsl = new StreamSource(new FileReader(new File(xslFileName)));
//create a new XSL transformer
Templates template = factory.newTemplates(xsl);
Transformer transformer = template.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
//create XML Source object (Object Z)
Source xml = new StreamSource(new FileReader(new File(xmlSourceFileName)));
//create XML Target object (Implementation Language)
Result result = new StreamResult(new FileWriter(new
File(xmlTargetFileName)));
//do tranform
transformer.transform(xml, result);
LOG.debug("XSL tranformation is successful.");
}
public void tranformXML(String xslFileName, Document domSource, String
xmlTargetFileName) throws TransformerConfigurationException, TransformerException,
FileNotFoundException {
//create an XSL factory
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = null;
if ((xslFileName == null) || (xslFileName.equals(""))) {
//create a new XSL transformer
transformer = factory.newTransformer();
} else {
//create XSL object
Source xsl = new StreamSource(new FileReader(new File(xslFileName)));
//create a new XSL transformer
Templates template = factory.newTemplates(xsl);
transformer = template.newTransformer();
}
Result result = new StreamResult(new File(xmlTargetFileName));
Source source = new DOMSource(domSource);
//do tranform
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
"5");
transformer.transform(source, result);
LOG.debug("DOM tranformation is successful.");
}
}
package edu.csus.fozcil.helper;
import
import
import
import
/**
*
org.w3c.dom.Node;
java.io.OutputStream;
java.io.UnsupportedEncodingException;
java.io.Writer;
121
* @author GeorgeN
*/
public interface XmlWriter {
public void setOutput(Writer writer);
public void setOutput(OutputStream stream, String encoding) throws
UnsupportedEncodingException;
public void write(Node node);
}
/*
* MainToolJFrame.java
*
* Created on Apr 10, 2009, 10:23:24 AM
*/
package edu.csus.fozcil.tool;
import
import
import
import
import
import
import
javax.swing.*;
java.awt.*;
edu.csus.fozcil.FozcilException;
edu.csus.fozcil.bean.*;
java.awt.CardLayout;
javax.swing.JFileChooser;
org.apache.log4j.Logger;
/**
*
* @author GeorgeN
*/
public class MainToolJFrame extends javax.swing.JFrame {
private static Logger LOG = Logger.getLogger(MainToolJFrame.class.getName());
public final static String TYPE_VIEW = "Type View";
public final static String STATE_VIEW = "State View";
public final static String OPERATION_VIEW = "Operation View";
public
public
public
public
public
public
public
public
static
static
static
static
static
static
static
static
private
private
private
private
final
final
final
final
final
final
final
final
String
String
String
String
String
String
String
String
VISIBILITY_PUBLIC = "public";
VISIBILITY_PRIVATE = "private";
BUTTON_ADD_TEXT = "Add";
BUTTON_UPDATE_TEXT = "Update";
SEP_VISIBILITY_NAME = ">";
SEP_NAME_VALUE = "=";
SEP_NAME_TYPE = ":";
SEP_VALUE_VALUE = "|";
ToolControlSystem controlsystem;
TypeToolJPanel typeToolJPanel;
StateToolJPanel stateToolJPanel;
OperationToolJPanel operationToolJPanel;
/** Creates new form MainToolJFrame */
public MainToolJFrame() {
initComponents();
try {
this.controlsystem = new ToolControlSystem();
} catch (FozcilException ex) {
LOG.error(ex);
//throw error message to user
}
//initialize all sub-views (by adding the JpPanels to the CardLayout Manager)
this.typeToolJPanel = new TypeToolJPanel(this, controlsystem);
this.jCardPanel.add(this.typeToolJPanel, TYPE_VIEW);
this.stateToolJPanel = new StateToolJPanel(this, controlsystem);
this.jCardPanel.add(this.stateToolJPanel, STATE_VIEW);
this.operationToolJPanel = new OperationToolJPanel(this, controlsystem);
this.jCardPanel.add(this.operationToolJPanel, OPERATION_VIEW);
122
}
//finally show the Class panel for starters
switchView(TYPE_VIEW);
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jCardPanel = new javax.swing.JPanel();
jMenuBar1 = new javax.swing.JMenuBar();
jmenuFile = new javax.swing.JMenu();
jmenuItemLoad = new javax.swing.JMenuItem();
jmenuitemSave = new javax.swing.JMenuItem();
jmenuitemExit = new javax.swing.JMenuItem();
jmenuAction = new javax.swing.JMenu();
jmenuitemConvertOZtoIL = new javax.swing.JMenuItem();
jmenuitemGenerateDoc = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("FOZCIL Tool");
setBackground(new java.awt.Color(140, 176, 222));
jCardPanel.setBackground(new java.awt.Color(140, 176, 222));
jCardPanel.setLayout(new java.awt.CardLayout());
jmenuFile.setText("File");
jmenuItemLoad.setText("Load ..");
jmenuItemLoad.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmenuItemLoadActionPerformed(evt);
}
});
jmenuFile.add(jmenuItemLoad);
jmenuitemSave.setText("Save ..");
jmenuitemSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmenuitemSaveActionPerformed(evt);
}
});
jmenuFile.add(jmenuitemSave);
jmenuitemExit.setText("Exit");
jmenuitemExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmenuitemExitActionPerformed(evt);
}
});
jmenuFile.add(jmenuitemExit);
jMenuBar1.add(jmenuFile);
jmenuAction.setText("Action");
jmenuitemConvertOZtoIL.setText("Convert OZ to IL ..");
jmenuitemConvertOZtoIL.setEnabled(false);
jmenuitemConvertOZtoIL.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmenuitemConvertOZtoILActionPerformed(evt);
}
});
jmenuAction.add(jmenuitemConvertOZtoIL);
jmenuitemGenerateDoc.setText("Generate docs ..");
jmenuitemGenerateDoc.setEnabled(false);
jmenuitemGenerateDoc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmenuitemGenerateDocActionPerformed(evt);
123
}
});
jmenuAction.add(jmenuitemGenerateDoc);
jMenuBar1.add(jmenuAction);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jCardPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 566,
Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jCardPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 727,
Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void jmenuitemExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void jmenuitemConvertOZtoILActionPerformed(java.awt.event.ActionEvent evt) {
String filePath = getFileNameFromFileChooser(true);
try {
this.controlsystem.doOZtoILBinding(filePath);
showConvertOZtoILDialogConfirmation();
} catch (FozcilException ex) {
LOG.error(ex);
ex.printStackTrace(System.out);
//throw error message to user
}
}
private void jmenuitemGenerateDocActionPerformed(java.awt.event.ActionEvent evt) {
String filePath = getFileNameFromFileChooser(true);
try {
this.controlsystem.doOZtoDocBinding(filePath);
showGenerateDocsDialogConfirmation();
} catch (FozcilException ex) {
LOG.error(ex);
ex.printStackTrace(System.out);
//throw error message to user
}
}
private void jmenuitemSaveActionPerformed(java.awt.event.ActionEvent evt) {
String filePath = getFileNameFromFileChooser(true);
try {
controlsystem.saveOzSpecificationData(filePath);
} catch (FozcilException ex) {
LOG.error(ex);
//throw error message to user
}
}
private void jmenuItemLoadActionPerformed(java.awt.event.ActionEvent evt) {
String filePath = getFileNameFromFileChooser(false);
try {
controlsystem.loadOzSpecificationData(filePath);
} catch (FozcilException ex) {
LOG.error(ex);
//throw error message to user
}
//load LDB data into the child panels
this.typeToolJPanel.loadOzSpecificationData();
124
}
this.stateToolJPanel.loadOzSpecificationData();
this.operationToolJPanel.loadOzSpecificationData();
//enable other menu items appropriately
jmenuitemConvertOZtoIL.setEnabled(true);
jmenuitemGenerateDoc.setEnabled(true);
private String getFileNameFromFileChooser(boolean isChooseDirOnly) {
String userSelectedOutputPath = "";
final JFileChooser jFileChooser = new JFileChooser();
if (isChooseDirOnly)
jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
else
jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = jFileChooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
userSelectedOutputPath = jFileChooser.getSelectedFile().getAbsolutePath();
} else {
//do nothing
}
return userSelectedOutputPath;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainToolJFrame().setVisible(true);
}
});
}
public void switchView(String newview) {
CardLayout cl = (CardLayout) this.jCardPanel.getLayout();
cl.show(this.jCardPanel, newview);
if (newview.equals(STATE_VIEW)) {
this.stateToolJPanel.refreshComponents();
} else if (newview.equals(OPERATION_VIEW)) {
this.operationToolJPanel.refreshComponents();
}
}
public void showSaveFileDialog() {
int n = JOptionPane.showConfirmDialog(
this, "Do you want to save the Object-Z specification?",
"An Inane Question",
JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.YES_OPTION) {
processSaveFileDialog();
} else if (n == JOptionPane.NO_OPTION) {
//do nothing
} else {
//do nothing
}
}
private void processSaveFileDialog() {
//save the LanguageDependentBean
try {
//call the Control System
LOG.debug("Calling ControlSystem.saveLanguageDependentData...");
String filePath = getFileNameFromFileChooser(true);
controlsystem.saveOzSpecificationData(filePath);
//show dialog box
showSaveFileDialogConfirmation();
//enable other menu items appropriately
jmenuitemConvertOZtoIL.setEnabled(true);
jmenuitemGenerateDoc.setEnabled(true);
} catch (FozcilException ex) {
LOG.error(ex);
//throw error message to user
125
}
}
private void showSaveFileDialogConfirmation() {
JOptionPane.showMessageDialog(this, "Object-Z specification was saved
successfully.");
}
private void showConvertOZtoILDialogConfirmation() {
JOptionPane.showMessageDialog(this, "Skeletal code successfully written.");
}
private void showGenerateDocsDialogConfirmation() {
JOptionPane.showMessageDialog(this, "Object-Z documentation successfully
written.");
}
// Variables declaration - do not modify
private javax.swing.JPanel jCardPanel;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenu jmenuAction;
private javax.swing.JMenu jmenuFile;
private javax.swing.JMenuItem jmenuItemLoad;
private javax.swing.JMenuItem jmenuitemConvertOZtoIL;
private javax.swing.JMenuItem jmenuitemExit;
private javax.swing.JMenuItem jmenuitemGenerateDoc;
private javax.swing.JMenuItem jmenuitemSave;
// End of variables declaration
}
/*
* TypeToolJPanel.java
*
* Created on Oct 12, 2009, 10:38:18 AM
*/
package edu.csus.fozcil.tool;
import
import
import
import
import
java.util.StringTokenizer;
javax.swing.DefaultListModel;
edu.csus.fozcil.bean.*;
edu.csus.fozcil.validator.NotEmptyValidator;
javax.swing.DefaultComboBoxModel;
/**
*
* @author GeorgeN
*/
public class TypeToolJPanel extends javax.swing.JPanel {
private
private
private
private
private
private
private
MainToolJFrame parentWindow;
ToolControlSystem controlsystem;
DefaultListModel modelUserTypes;
DefaultListModel modelConstantTypes;
DefaultComboBoxModel modelConstantTypeTypes;
DefaultListModel modelFreeTypes;
DefaultListModel modelFreeTypeValues;
/** Creates new form TypeToolJPanel */
public TypeToolJPanel(MainToolJFrame parent, ToolControlSystem controlsystem) {
this.parentWindow = parent;
this.controlsystem = controlsystem;
modelUserTypes = new DefaultListModel();
modelConstantTypes = new DefaultListModel();
modelConstantTypeTypes = new DefaultComboBoxModel ();
modelFreeTypes = new DefaultListModel();
modelFreeTypeValues = new DefaultListModel();
initComponents();
refreshComponents();
//add validators
126
//
jtfSchemaName.setInputVerifier(new NotEmptyValidator(this.parentWindow,
jtfSchemaName, "Field cannot be null."));
}
public void refreshComponents() {
//add Constant variable types
modelConstantTypeTypes.removeAllElements();
modelConstantTypeTypes.addElement("");
modelConstantTypeTypes.addElement("N");
modelConstantTypeTypes.addElement("Z");
}
public void loadOzSpecificationData() {
OzSpecificationBean ozbean = this.controlsystem.getOzSpecificationBean();
jtfSchemaName.setText(ozbean.getSchemaName());
if (ozbean.getSchemaVisibility().equals(MainToolJFrame.VISIBILITY_PUBLIC))
jradSchemaVisiblePublic.setSelected(true);
else
jradSchemaVisiblePublic.setSelected(true);
for (OzVariable ozvar : ozbean.getUserDataTypes()) {
modelUserTypes.addElement(ozvar.getVisibility() +
MainToolJFrame.SEP_VISIBILITY_NAME +
ozvar.getName());
}
for (OzVariable ozvar : ozbean.getConstantDataTypes().values()) {
modelConstantTypes.addElement(ozvar.getVisibility() +
MainToolJFrame.SEP_VISIBILITY_NAME +
ozvar.getName() +
MainToolJFrame.SEP_NAME_TYPE + ozvar.getType() +
MainToolJFrame.SEP_NAME_VALUE + ozvar.getValues().get(0));
}
for (OzVariable ozvar : ozbean.getFreeDataTypes().values()) {
String freeDatatTypeString = ozvar.getVisibility() +
MainToolJFrame.SEP_VISIBILITY_NAME +
ozvar.getName() +
MainToolJFrame.SEP_NAME_VALUE;
for (String val : ozvar.getValues()) {
freeDatatTypeString += val + MainToolJFrame.SEP_VALUE_VALUE;
}
freeDatatTypeString = freeDatatTypeString.substring(0,
freeDatatTypeString.length()-1);
//remove the last '|'
modelFreeTypes.addElement(freeDatatTypeString);
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jrgUserTypeVisible = new javax.swing.ButtonGroup();
jrgConstantTypeVisible = new javax.swing.ButtonGroup();
jrgSchemaVisible = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jtfUserTypeName = new javax.swing.JTextField();
jbutUserTypeAdd = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jbutUserTypeDelete = new javax.swing.JButton();
jScrollPane3 = new javax.swing.JScrollPane();
jlistUserTypes = new javax.swing.JList();
jSeparator1 = new javax.swing.JSeparator();
jLabel7 = new javax.swing.JLabel();
jradUserTypeVisiblePublic = new javax.swing.JRadioButton();
jradUserTypeVisiblePrivate = new javax.swing.JRadioButton();
jPanel2 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jtfConstTypeName = new javax.swing.JTextField();
jbutConstTypeAdd = new javax.swing.JButton();
127
jLabel4 = new javax.swing.JLabel();
jbutConstTypeEdit = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jtfConstTypeValue = new javax.swing.JTextField();
jbutConstTypeDelete = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jlistConstantTypes = new javax.swing.JList();
jSeparator2 = new javax.swing.JSeparator();
jLabel8 = new javax.swing.JLabel();
jradConstantTypeVisiblePublic = new javax.swing.JRadioButton();
jradConstantTypeVisiblePrivate = new javax.swing.JRadioButton();
jLabel9 = new javax.swing.JLabel();
jcbConstTypeTypes = new javax.swing.JComboBox();
jbutNext = new javax.swing.JButton();
jbutClearAll = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
jtfSchemaName = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jradSchemaVisiblePublic = new javax.swing.JRadioButton();
jradSchemaVisiblePrivate = new javax.swing.JRadioButton();
jPanel3 = new javax.swing.JPanel();
jLabel11 = new javax.swing.JLabel();
jtfFreeTypeName = new javax.swing.JTextField();
jbutFreeTypeAdd = new javax.swing.JButton();
jLabel12 = new javax.swing.JLabel();
jbutFreeTypeEdit = new javax.swing.JButton();
jLabel13 = new javax.swing.JLabel();
jbutFreeTypeDelete = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jlistFreeTypes = new javax.swing.JList();
jSeparator3 = new javax.swing.JSeparator();
jLabel14 = new javax.swing.JLabel();
jradFreeTypeVisiblePublic = new javax.swing.JRadioButton();
jradFreeTypeVisiblePrivate = new javax.swing.JRadioButton();
jScrollPane4 = new javax.swing.JScrollPane();
jlistFreeTypeValues = new javax.swing.JList();
jbutFreeTypeAddValue = new javax.swing.JButton();
jLabel15 = new javax.swing.JLabel();
jtfFreeTypeValue = new javax.swing.JTextField();
jbutFreeTypeDeleteValue = new javax.swing.JButton();
setBackground(new java.awt.Color(140, 176, 222));
jPanel1.setBackground(new java.awt.Color(189, 208, 233));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "User Type",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel1.setText("Name");
jbutUserTypeAdd.setText("Add");
jbutUserTypeAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutUserTypeAddActionPerformed(evt);
}
});
jLabel2.setText("<html>Added<br/>User<br/>Types</html>");
jbutUserTypeDelete.setText("Delete");
jbutUserTypeDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutUserTypeDeleteActionPerformed(evt);
}
});
jlistUserTypes.setModel(modelUserTypes);
jScrollPane3.setViewportView(jlistUserTypes);
jLabel7.setText("Visibility");
jradUserTypeVisiblePublic.setBackground(new java.awt.Color(189, 208, 233));
jrgUserTypeVisible.add(jradUserTypeVisiblePublic);
128
jradUserTypeVisiblePublic.setText("public");
jradUserTypeVisiblePrivate.setBackground(new java.awt.Color(189, 208, 233));
jrgUserTypeVisible.add(jradUserTypeVisiblePrivate);
jradUserTypeVisiblePrivate.setText("private");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel7))
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jradUserTypeVisiblePublic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jradUserTypeVisiblePrivate)
.addGap(183, 183, 183)
.addComponent(jbutUserTypeAdd))
.addComponent(jtfUserTypeName,
javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(51, 51, 51))
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 480,
Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(34, 34, 34)
.addComponent(jScrollPane3,
javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutUserTypeDelete)
.addGap(51, 51, 51)))
.addContainerGap())
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutUserTypeAdd, jbutUserTypeDelete});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jtfUserTypeName,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jradUserTypeVisiblePublic)
.addComponent(jradUserTypeVisiblePrivate)
.addComponent(jLabel7)
.addComponent(jbutUserTypeAdd))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutUserTypeDelete)
.addComponent(jLabel2)
129
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE,
50, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
jPanel2.setBackground(new java.awt.Color(189, 208, 233));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Constant
Type", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel3.setText("Name");
jbutConstTypeAdd.setText("Add");
jbutConstTypeAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutConstTypeAddActionPerformed(evt);
}
});
jLabel4.setText("<html>Added<br/>Constant<br/>Types</html>");
jbutConstTypeEdit.setText("Edit");
jbutConstTypeEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutConstTypeEditActionPerformed(evt);
}
});
jLabel5.setText("Value");
jbutConstTypeDelete.setText("Delete");
jbutConstTypeDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutConstTypeDeleteActionPerformed(evt);
}
});
jlistConstantTypes.setModel(modelConstantTypes);
jScrollPane1.setViewportView(jlistConstantTypes);
jLabel8.setText("Visibility");
jradConstantTypeVisiblePublic.setBackground(new java.awt.Color(189, 208, 233));
jrgConstantTypeVisible.add(jradConstantTypeVisiblePublic);
jradConstantTypeVisiblePublic.setText("public");
jradConstantTypeVisiblePrivate.setBackground(new java.awt.Color(189, 208, 233));
jrgConstantTypeVisible.add(jradConstantTypeVisiblePrivate);
jradConstantTypeVisiblePrivate.setText("private");
jLabel9.setText("Type");
jcbConstTypeTypes.setModel(modelConstantTypeTypes);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutConstTypeDelete)
.addComponent(jbutConstTypeEdit))
.addGap(57, 57, 57))
130
.addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 480,
Short.MAX_VALUE))
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel8))
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel9))
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3))
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel5)))
.addGap(28, 28, 28)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jtfConstTypeValue)
.addComponent(jcbConstTypeTypes, 0,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jtfConstTypeName,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 284,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jradConstantTypeVisiblePublic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jradConstantTypeVisiblePrivate)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 182,
Short.MAX_VALUE)
.addComponent(jbutConstTypeAdd)
.addGap(66, 66, 66))))
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutConstTypeAdd, jbutConstTypeDelete, jbutConstTypeEdit});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(jLabel9))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfConstTypeName,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jcbConstTypeTypes,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtfConstTypeValue,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
131
.addComponent(jLabel5))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jradConstantTypeVisiblePublic)
.addComponent(jradConstantTypeVisiblePrivate)
.addComponent(jbutConstTypeAdd))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jbutConstTypeEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutConstTypeDelete)
.addContainerGap())
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel2Layout.createSequentialGroup()
.addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE)
.addContainerGap())
.addComponent(jLabel4,
javax.swing.GroupLayout.Alignment.LEADING))))
);
jbutNext.setText("Next");
jbutNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutNextActionPerformed(evt);
}
});
jbutClearAll.setText("Clear All");
jbutClearAll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutClearAllActionPerformed(evt);
}
});
jLabel6.setText("Schema Name");
jLabel10.setText("Visibility");
jradSchemaVisiblePublic.setBackground(new java.awt.Color(140, 176, 222));
jrgSchemaVisible.add(jradSchemaVisiblePublic);
jradSchemaVisiblePublic.setText("public");
jradSchemaVisiblePrivate.setBackground(new java.awt.Color(140, 176, 222));
jrgSchemaVisible.add(jradSchemaVisiblePrivate);
jradSchemaVisiblePrivate.setText("private");
jradSchemaVisiblePrivate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jradSchemaVisiblePrivateActionPerformed(evt);
}
});
jPanel3.setBackground(new java.awt.Color(189, 208, 233));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Free Type",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel11.setText("Name");
jbutFreeTypeAdd.setText("Add");
jbutFreeTypeAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutFreeTypeAddActionPerformed(evt);
132
}
});
jLabel12.setText("<html>Added<br/>Free<br/>Types</html>");
jbutFreeTypeEdit.setText("Edit");
jbutFreeTypeEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutFreeTypeEditActionPerformed(evt);
}
});
jLabel13.setText("<html>Added<br/>values</html>");
jbutFreeTypeDelete.setText("Delete");
jbutFreeTypeDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutFreeTypeDeleteActionPerformed(evt);
}
});
jlistFreeTypes.setModel(modelFreeTypes);
jScrollPane2.setViewportView(jlistFreeTypes);
jLabel14.setText("Visibility");
jradFreeTypeVisiblePublic.setBackground(new java.awt.Color(189, 208, 233));
jrgConstantTypeVisible.add(jradFreeTypeVisiblePublic);
jradFreeTypeVisiblePublic.setText("public");
jradFreeTypeVisiblePrivate.setBackground(new java.awt.Color(189, 208, 233));
jrgConstantTypeVisible.add(jradFreeTypeVisiblePrivate);
jradFreeTypeVisiblePrivate.setText("private");
jlistFreeTypeValues.setModel(modelFreeTypeValues);
jScrollPane4.setViewportView(jlistFreeTypeValues);
jbutFreeTypeAddValue.setText("Add Value");
jbutFreeTypeAddValue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutFreeTypeAddValueActionPerformed(evt);
}
});
jLabel15.setText("Value");
jbutFreeTypeDeleteValue.setText("Delete Value");
jbutFreeTypeDeleteValue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutFreeTypeDeleteValueActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel11)
.addComponent(jLabel15)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel14)
.addComponent(jLabel13))
.addGap(28, 28, 28)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
133
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(jScrollPane4,
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfFreeTypeValue,
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfFreeTypeName,
javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 284,
Short.MAX_VALUE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jradFreeTypeVisiblePublic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jradFreeTypeVisiblePrivate)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutFreeTypeAdd)
.addComponent(jbutFreeTypeAddValue)
.addComponent(jbutFreeTypeDeleteValue))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40,
Short.MAX_VALUE))
.addComponent(jSeparator3,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 490,
Short.MAX_VALUE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel12)
.addGap(32, 32, 32)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutFreeTypeEdit)
.addComponent(jbutFreeTypeDelete))
.addGap(67, 67, 67)))
.addContainerGap())))
);
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutFreeTypeAdd, jbutFreeTypeDelete, jbutFreeTypeEdit});
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(jtfFreeTypeName,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel15)
.addComponent(jtfFreeTypeValue,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jbutFreeTypeAddValue))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel13)
.addComponent(jScrollPane4,
javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
134
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(jPanel3Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jbutFreeTypeDeleteValue)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(jradFreeTypeVisiblePublic)
.addComponent(jradFreeTypeVisiblePrivate)
.addComponent(jbutFreeTypeAdd))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutFreeTypeEdit)
.addComponent(jLabel12)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
56, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addContainerGap(188, Short.MAX_VALUE)
.addComponent(jbutFreeTypeDelete)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(jLabel10))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(jradSchemaVisiblePublic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jradSchemaVisiblePrivate))
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jtfSchemaName,
javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jbutNext)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutClearAll)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
135
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jtfSchemaName,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jradSchemaVisiblePrivate)
.addComponent(jLabel10)
.addComponent(jradSchemaVisiblePublic))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 209,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 240,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutClearAll)
.addComponent(jbutNext))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>
private void jbutUserTypeAddActionPerformed(java.awt.event.ActionEvent evt) {
String publicOrprivate = (jradUserTypeVisiblePrivate.isSelected())?
MainToolJFrame.VISIBILITY_PRIVATE :
MainToolJFrame.VISIBILITY_PUBLIC;
modelUserTypes.addElement(publicOrprivate + MainToolJFrame.SEP_VISIBILITY_NAME +
jtfUserTypeName.getText());
jtfUserTypeName.setText("");
}
private void jbutUserTypeDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistUserTypes.getSelectedIndex();
modelUserTypes.removeElementAt(pos);
}
private void jbutConstTypeAddActionPerformed(java.awt.event.ActionEvent evt) {
String publicOrprivate = (jradConstantTypeVisiblePrivate.isSelected())?
MainToolJFrame.VISIBILITY_PRIVATE :
MainToolJFrame.VISIBILITY_PUBLIC;
String nameTypeValue = jtfConstTypeName.getText() +
MainToolJFrame.SEP_NAME_TYPE +
jcbConstTypeTypes.getSelectedItem() +
MainToolJFrame.SEP_NAME_VALUE + jtfConstTypeValue.getText();
//is this Add or Update?
if (jbutConstTypeAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelConstantTypes.setElementAt(publicOrprivate +
MainToolJFrame.SEP_VISIBILITY_NAME + nameTypeValue,
jlistConstantTypes.getSelectedIndex());
//change button's text
jbutConstTypeAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jlistConstantTypes.clearSelection();
} else {
modelConstantTypes.addElement(publicOrprivate +
MainToolJFrame.SEP_VISIBILITY_NAME + nameTypeValue);
}
//clear the text fields
jtfConstTypeName.setText("");
jtfConstTypeValue.setText("");
}
private void jbutConstTypeEditActionPerformed(java.awt.event.ActionEvent evt) {
136
//get NV to be edited and set the appropriate textboxes
int pos = jlistConstantTypes.getSelectedIndex();
String visibilityNameValue = modelConstantTypes.getElementAt(pos).toString();
StringTokenizer stk = new StringTokenizer(visibilityNameValue,
MainToolJFrame.SEP_VISIBILITY_NAME + MainToolJFrame.SEP_NAME_TYPE +
MainToolJFrame.SEP_NAME_VALUE, false);
String visibility = stk.nextToken();
if (visibility.equals(MainToolJFrame.VISIBILITY_PUBLIC))
jradConstantTypeVisiblePublic.setSelected(true);
else
jradConstantTypeVisiblePrivate.setSelected(true);
String name = stk.nextToken();
jtfConstTypeName.setText(name);
String type = stk.nextToken();
jcbConstTypeTypes.setSelectedItem(type);
String value = stk.nextToken();
jtfConstTypeValue.setText(value);
}
//change button's text
jbutConstTypeAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
private void jbutConstTypeDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistConstantTypes.getSelectedIndex();
modelConstantTypes.removeElementAt(pos);
}
}
private void jbutClearAllActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
private void jbutNextActionPerformed(java.awt.event.ActionEvent evt) {
OzSpecificationBean ozbean = this.controlsystem.getOzSpecificationBean();
ozbean.setSchemaName(jtfSchemaName.getText());
if (jradSchemaVisiblePrivate.isSelected())
ozbean.setSchemaVisibility(MainToolJFrame.VISIBILITY_PRIVATE);
else
ozbean.setSchemaVisibility(MainToolJFrame.VISIBILITY_PUBLIC);
ozbean.getUserDataTypes().clear();
for (int i=0;i<modelUserTypes.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelUserTypes.getElementAt(i).toString(),
MainToolJFrame.SEP_VISIBILITY_NAME, false);
String visibility = stk.nextToken();
String name = stk.nextToken();
OzVariable ozvar = new OzVariable(name, "", visibility);
ozbean.addUserDataType(ozvar);
}
ozbean.getConstantDataTypes().clear();
for (int i=0;i<modelConstantTypes.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelConstantTypes.getElementAt(i).toString(),
MainToolJFrame.SEP_VISIBILITY_NAME + MainToolJFrame.SEP_NAME_TYPE +
MainToolJFrame.SEP_NAME_VALUE, false);
String visibility = stk.nextToken();
String name = stk.nextToken();
String type = stk.nextToken();
String value = stk.nextToken();
OzVariable ozvar = new OzVariable(name, type, visibility);
ozvar.addValue(value);
ozbean.addConstantDataType(ozvar);
}
ozbean.getFreeDataTypes().clear();
for (int i=0;i<modelFreeTypes.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelFreeTypes.getElementAt(i).toString(),
MainToolJFrame.SEP_VISIBILITY_NAME + MainToolJFrame.SEP_NAME_VALUE +
MainToolJFrame.SEP_VALUE_VALUE, false);
String visibility = stk.nextToken();
String name = stk.nextToken();
OzVariable ozvar = new OzVariable(name, "", visibility);
while (stk.hasMoreTokens()) {
ozvar.addValue(stk.nextToken());
137
}
ozbean.addFreeDataType(ozvar);
}
this.parentWindow.switchView(MainToolJFrame.STATE_VIEW);
}
private void jradSchemaVisiblePrivateActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
}
private void jbutFreeTypeAddActionPerformed(java.awt.event.ActionEvent evt) {
String publicOrprivate = (jradFreeTypeVisiblePrivate.isSelected())?
MainToolJFrame.VISIBILITY_PRIVATE :
MainToolJFrame.VISIBILITY_PUBLIC;
String nameValues = jtfFreeTypeName.getText() + MainToolJFrame.SEP_NAME_VALUE;
for (int i=0;i<modelFreeTypeValues.getSize();i++) {
nameValues += modelFreeTypeValues.getElementAt(i).toString() +
MainToolJFrame.SEP_VALUE_VALUE;
}
nameValues = nameValues.substring(0, nameValues.length()-1);
//remove the last
'|'
//is this Add or Update?
if (jbutFreeTypeAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelFreeTypes.setElementAt(publicOrprivate +
MainToolJFrame.SEP_VISIBILITY_NAME + nameValues,
jlistFreeTypes.getSelectedIndex());
//change button's text
jbutFreeTypeAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jlistFreeTypes.clearSelection();
} else {
modelFreeTypes.addElement(publicOrprivate +
MainToolJFrame.SEP_VISIBILITY_NAME + nameValues);
}
//clear the text fields
jtfFreeTypeName.setText("");
jtfFreeTypeValue.setText("");
modelFreeTypeValues.removeAllElements();
}
private void jbutFreeTypeEditActionPerformed(java.awt.event.ActionEvent evt) {
//get NV to be edited and set the appropriate textboxes
int pos = jlistFreeTypes.getSelectedIndex();
String visibilityNameValues = modelFreeTypes.getElementAt(pos).toString();
StringTokenizer stk = new StringTokenizer(visibilityNameValues,
MainToolJFrame.SEP_VISIBILITY_NAME + MainToolJFrame.SEP_NAME_VALUE +
MainToolJFrame.SEP_VALUE_VALUE, false);
String visibility = stk.nextToken();
if (visibility.equals(MainToolJFrame.VISIBILITY_PUBLIC))
jradFreeTypeVisiblePublic.setSelected(true);
else
jradFreeTypeVisiblePrivate.setSelected(true);
String name = stk.nextToken();
jtfFreeTypeName.setText(name);
while (stk.hasMoreTokens()) {
modelFreeTypeValues.addElement(stk.nextToken());
}
//change button's text
jbutFreeTypeAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
}
}
private void jbutFreeTypeDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistFreeTypes.getSelectedIndex();
modelFreeTypes.removeElementAt(pos);
private void jbutFreeTypeAddValueActionPerformed(java.awt.event.ActionEvent evt) {
modelFreeTypeValues.addElement(jtfFreeTypeValue.getText());
jtfFreeTypeValue.setText("");
}
private void jbutFreeTypeDeleteValueActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistFreeTypeValues.getSelectedIndex();
138
modelFreeTypeValues.removeElementAt(pos);
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JButton jbutClearAll;
private javax.swing.JButton jbutConstTypeAdd;
private javax.swing.JButton jbutConstTypeDelete;
private javax.swing.JButton jbutConstTypeEdit;
private javax.swing.JButton jbutFreeTypeAdd;
private javax.swing.JButton jbutFreeTypeAddValue;
private javax.swing.JButton jbutFreeTypeDelete;
private javax.swing.JButton jbutFreeTypeDeleteValue;
private javax.swing.JButton jbutFreeTypeEdit;
private javax.swing.JButton jbutNext;
private javax.swing.JButton jbutUserTypeAdd;
private javax.swing.JButton jbutUserTypeDelete;
private javax.swing.JComboBox jcbConstTypeTypes;
private javax.swing.JList jlistConstantTypes;
private javax.swing.JList jlistFreeTypeValues;
private javax.swing.JList jlistFreeTypes;
private javax.swing.JList jlistUserTypes;
private javax.swing.JRadioButton jradConstantTypeVisiblePrivate;
private javax.swing.JRadioButton jradConstantTypeVisiblePublic;
private javax.swing.JRadioButton jradFreeTypeVisiblePrivate;
private javax.swing.JRadioButton jradFreeTypeVisiblePublic;
private javax.swing.JRadioButton jradSchemaVisiblePrivate;
private javax.swing.JRadioButton jradSchemaVisiblePublic;
private javax.swing.JRadioButton jradUserTypeVisiblePrivate;
private javax.swing.JRadioButton jradUserTypeVisiblePublic;
private javax.swing.ButtonGroup jrgConstantTypeVisible;
private javax.swing.ButtonGroup jrgSchemaVisible;
private javax.swing.ButtonGroup jrgUserTypeVisible;
private javax.swing.JTextField jtfConstTypeName;
private javax.swing.JTextField jtfConstTypeValue;
private javax.swing.JTextField jtfFreeTypeName;
private javax.swing.JTextField jtfFreeTypeValue;
private javax.swing.JTextField jtfSchemaName;
private javax.swing.JTextField jtfUserTypeName;
// End of variables declaration
}
/*
* StateToolJPanel.java
*
* Created on Oct 12, 2009, 10:38:48 AM
*/
139
package edu.csus.fozcil.tool;
import
import
import
import
import
import
import
import
edu.csus.fozcil.bean.OzOperationBean;
edu.csus.fozcil.bean.OzSpecificationBean;
edu.csus.fozcil.bean.OzVariable;
java.util.ArrayList;
java.util.HashMap;
java.util.StringTokenizer;
javax.swing.DefaultComboBoxModel;
javax.swing.DefaultListModel;
/**
*
* @author GeorgeN
*/
public class StateToolJPanel extends javax.swing.JPanel {
private
private
private
private
private
private
MainToolJFrame parentWindow;
ToolControlSystem controlsystem;
DefaultListModel modelStateVariables;
DefaultComboBoxModel modelStateVariableTypes;
DefaultListModel modelInvariants;
DefaultListModel modelInits;
/** Creates new form StateToolJPanel */
public StateToolJPanel(MainToolJFrame parent, ToolControlSystem controlsystem) {
this.parentWindow = parent;
this.controlsystem = controlsystem;
modelStateVariables = new DefaultListModel();
modelStateVariableTypes = new DefaultComboBoxModel ();
modelInvariants = new DefaultListModel();
modelInits = new DefaultListModel();
}
initComponents();
public void refreshComponents() {
//add state variable types
modelStateVariableTypes.removeAllElements();
modelStateVariableTypes.addElement("");
modelStateVariableTypes.addElement(OzSpecificationBean.OZ_INTRINSIC_TYPE_N);
modelStateVariableTypes.addElement(OzSpecificationBean.OZ_INTRINSIC_TYPE_Z);
for (OzVariable userType :
this.controlsystem.getOzSpecificationBean().getUserDataTypes()) {
modelStateVariableTypes.addElement(userType.getName());
}
modelStateVariableTypes.addElement(OzSpecificationBean.OZ_INTRINSIC_TYPE_SET + "
" +
OzSpecificationBean.OZ_INTRINSIC_TYPE_N);
modelStateVariableTypes.addElement(OzSpecificationBean.OZ_INTRINSIC_TYPE_SET + "
" +
OzSpecificationBean.OZ_INTRINSIC_TYPE_Z);
for (OzVariable userType :
this.controlsystem.getOzSpecificationBean().getUserDataTypes()) {
modelStateVariableTypes.addElement(OzSpecificationBean.OZ_INTRINSIC_TYPE_SET
+ " " +
userType.getName());
}
}
public void loadOzSpecificationData() {
OzSpecificationBean ozbean = this.controlsystem.getOzSpecificationBean();
for (OzVariable ozvar : ozbean.getStateVariables().values()) {
modelStateVariables.addElement(ozvar.getVisibility() +
MainToolJFrame.SEP_VISIBILITY_NAME +
ozvar.getName() + MainToolJFrame.SEP_NAME_TYPE +
ozvar.getType());
}
for (String invariants : ozbean.getClassInvariants()) {
modelInvariants.addElement(invariants);
}
OzOperationBean initOper = ozbean.getInitOperation();
140
}
if (initOper != null) {
for (String postcondition : initOper.getPostconditions()) {
modelInits.addElement(postcondition);
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jrgStateVisible = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jtfStateName = new javax.swing.JTextField();
jcbStateType = new javax.swing.JComboBox();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jradStateVisiblePublic = new javax.swing.JRadioButton();
jradStateVisiblePrivate = new javax.swing.JRadioButton();
jbutStateAdd = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
jLabel4 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jlistStates = new javax.swing.JList();
jbutStateEdit = new javax.swing.JButton();
jbutStateDelete = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jtfInvariantExpr = new javax.swing.JTextField();
jbutExprBuilder = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jlistInvariants = new javax.swing.JList();
jbutInvariantEdit = new javax.swing.JButton();
jbutInvariantDelete = new javax.swing.JButton();
jbutInvariantAdd = new javax.swing.JButton();
jbutClearAll = new javax.swing.JButton();
jbutNext = new javax.swing.JButton();
jbutPrev = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
jtfInitExpr = new javax.swing.JTextField();
jbutinitExprBuilder = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jlistInits = new javax.swing.JList();
jbutInitEdit = new javax.swing.JButton();
jbutInitDelete = new javax.swing.JButton();
jbutInitAdd = new javax.swing.JButton();
setBackground(new java.awt.Color(140, 176, 222));
setPreferredSize(new java.awt.Dimension(427, 475));
setRequestFocusEnabled(false);
jPanel1.setBackground(new java.awt.Color(189, 208, 233));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "State
Variable", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel1.setText("Name");
jcbStateType.setModel(modelStateVariableTypes);
jLabel2.setText("Type");
jLabel3.setText("Visibility");
jradStateVisiblePublic.setBackground(new java.awt.Color(189, 208, 233));
jrgStateVisible.add(jradStateVisiblePublic);
141
jradStateVisiblePublic.setText("public");
jradStateVisiblePrivate.setBackground(new java.awt.Color(189, 208, 233));
jrgStateVisible.add(jradStateVisiblePrivate);
jradStateVisiblePrivate.setText("private");
jbutStateAdd.setText("Add");
jbutStateAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutStateAddActionPerformed(evt);
}
});
jLabel4.setText("<html>Added State<br/>Variables</html>");
jlistStates.setModel(modelStateVariables);
jScrollPane1.setViewportView(jlistStates);
jbutStateEdit.setText("Edit");
jbutStateEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutStateEditActionPerformed(evt);
}
});
jbutStateDelete.setText("Delete");
jbutStateDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutStateDeleteActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator1,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 477,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutStateDelete)
.addComponent(jbutStateEdit))
.addGap(57, 57, 57))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(27, 27, 27)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jradStateVisiblePublic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jradStateVisiblePrivate)
.addGap(176, 176, 176)
.addComponent(jbutStateAdd))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(2, 2, 2)
142
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(jtfStateName,
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jcbStateType,
javax.swing.GroupLayout.Alignment.LEADING, 0, 282, Short.MAX_VALUE))))
.addGap(8, 8, 8)))
.addContainerGap())
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutStateAdd, jbutStateDelete, jbutStateEdit});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(26, 26, 26)
.addComponent(jLabel2))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jtfStateName,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jcbStateType,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jradStateVisiblePrivate)
.addComponent(jradStateVisiblePublic)
.addComponent(jLabel3)
.addComponent(jbutStateAdd))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jbutStateEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutStateDelete))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
91, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2.setBackground(new java.awt.Color(189, 208, 233));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Class
Invariant", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jtfInvariantExpr.setEditable(false);
jtfInvariantExpr.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jtfInvariantExprActionPerformed(evt);
}
});
jbutExprBuilder.setText("Expression Wizard");
jbutExprBuilder.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutExprBuilderActionPerformed(evt);
143
}
});
jLabel6.setText("<html>Added<br/> Invariants</html>");
jlistInvariants.setModel(modelInvariants);
jScrollPane2.setViewportView(jlistInvariants);
jbutInvariantEdit.setText("Edit");
jbutInvariantEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutInvariantEditActionPerformed(evt);
}
});
jbutInvariantDelete.setText("Delete");
jbutInvariantDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutInvariantDeleteActionPerformed(evt);
}
});
jbutInvariantAdd.setText("Add");
jbutInvariantAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutInvariantAddActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(jtfInvariantExpr,
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel2Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jbutExprBuilder))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutInvariantAdd,
javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutInvariantDelete)
.addComponent(jbutInvariantEdit)))))
.addContainerGap(66, Short.MAX_VALUE))
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutInvariantAdd, jbutInvariantDelete, jbutInvariantEdit});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jtfInvariantExpr, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
144
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutInvariantAdd)
.addComponent(jbutExprBuilder))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jbutInvariantEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutInvariantDelete))
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
92, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jbutClearAll.setText("Clear All");
jbutClearAll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutClearAllActionPerformed(evt);
}
});
jbutNext.setText("Next");
jbutNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutNextActionPerformed(evt);
}
});
jbutPrev.setText("Prev");
jbutPrev.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPrevActionPerformed(evt);
}
});
jPanel3.setBackground(new java.awt.Color(189, 208, 233));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Init
Operation", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jtfInitExpr.setEditable(false);
jtfInitExpr.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jtfInitExprActionPerformed(evt);
}
});
jbutinitExprBuilder.setText("Expression Wizard");
jbutinitExprBuilder.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutinitExprBuilderActionPerformed(evt);
}
});
jLabel7.setText("<html>Added<br/>Init</html>");
jlistInits.setModel(modelInits);
jScrollPane3.setViewportView(jlistInits);
jbutInitEdit.setText("Edit");
jbutInitEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutInitEditActionPerformed(evt);
}
});
jbutInitDelete.setText("Delete");
jbutInitDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
145
jbutInitDeleteActionPerformed(evt);
});
}
jbutInitAdd.setText("Add");
jbutInitAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutInitAddActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfInitExpr, javax.swing.GroupLayout.PREFERRED_SIZE,
421, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jbutinitExprBuilder)
.addComponent(jScrollPane3,
javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutInitAdd,
javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutInitDelete)
.addComponent(jbutInitEdit)))))
.addContainerGap(66, Short.MAX_VALUE))
);
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutInitAdd, jbutInitDelete, jbutInitEdit});
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jtfInitExpr, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jLabel7))
.addGroup(jPanel3Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutInitAdd)
.addComponent(jbutinitExprBuilder))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jbutInitEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutInitDelete))
.addComponent(jScrollPane3,
javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))))
146
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jbutPrev)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutNext)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutClearAll))
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutClearAll)
.addComponent(jbutNext)
.addComponent(jbutPrev))
.addContainerGap())
);
}// </editor-fold>
}
private void jbutClearAllActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
private void jbutStateAddActionPerformed(java.awt.event.ActionEvent evt) {
String publicOrprivate = (jradStateVisiblePrivate.isSelected())?
MainToolJFrame.VISIBILITY_PRIVATE :
MainToolJFrame.VISIBILITY_PUBLIC;
String nameType = jtfStateName.getText() + MainToolJFrame.SEP_NAME_TYPE +
jcbStateType.getSelectedItem();
//is this Add or Update?
if (jbutStateAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelStateVariables.setElementAt(publicOrprivate +
MainToolJFrame.SEP_VISIBILITY_NAME + nameType,
jlistStates.getSelectedIndex());
//change button's text
jbutStateAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jlistStates.clearSelection();
} else {
147
modelStateVariables.addElement(publicOrprivate +
MainToolJFrame.SEP_VISIBILITY_NAME + nameType);
}
//clear the text fields
jtfStateName.setText("");
jcbStateType.setSelectedIndex(0);
}
private void jbutStateEditActionPerformed(java.awt.event.ActionEvent evt) {
//get NV to be edited and set the appropriate textboxes
int pos = jlistStates.getSelectedIndex();
String visibilityNameType = modelStateVariables.getElementAt(pos).toString();
StringTokenizer stk = new StringTokenizer(visibilityNameType,
MainToolJFrame.SEP_VISIBILITY_NAME + MainToolJFrame.SEP_NAME_TYPE,
false);
String visibility = stk.nextToken();
if (visibility.equals(MainToolJFrame.VISIBILITY_PUBLIC))
jradStateVisiblePublic.setSelected(true);
else
jradStateVisiblePrivate.setSelected(true);
String name = stk.nextToken();
jtfStateName.setText(name);
String type = stk.nextToken();
jcbStateType.setSelectedItem(type);
//change button's text
jbutStateAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
}
private void jbutStateDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistStates.getSelectedIndex();
modelStateVariables.removeElementAt(pos);
}
private void jbutNextActionPerformed(java.awt.event.ActionEvent evt) {
//save state variables
OzSpecificationBean ozbean = this.controlsystem.getOzSpecificationBean();
ozbean.getStateVariables().clear();
for (int i=0;i<modelStateVariables.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelStateVariables.getElementAt(i).toString(),
MainToolJFrame.SEP_VISIBILITY_NAME +
MainToolJFrame.SEP_NAME_TYPE, false);
String visibility = stk.nextToken();
String name = stk.nextToken();
String type = stk.nextToken();
OzVariable ozvar = new OzVariable(name, type, visibility);
ozbean.addStateVariable(ozvar);
}
//save Invariant
ozbean.getClassInvariants().clear();//first clean up before storing
//since adds are not keyed
for (int i=0;i<modelInvariants.getSize();i++) {
ozbean.addClassInvariant(modelInvariants.getElementAt(i).toString());
}
//save Inits (operation)
this.controlsystem.getOzSpecificationBean().removeOperation(OzSpecificationBean.OZ_INIT_M
ETHOD_NAME);
OzOperationBean operbean = new
OzOperationBean(OzSpecificationBean.OZ_INIT_METHOD_NAME);
operbean.setVisibility("public");//TODO get value from LanguageBean
for (int i=0;i<modelInits.getSize();i++) {
operbean.addPostcondition(modelInits.getElementAt(i).toString());
}
this.controlsystem.getOzSpecificationBean().addOperation(operbean);
}
this.parentWindow.switchView(MainToolJFrame.OPERATION_VIEW);
private void jbutExprBuilderActionPerformed(java.awt.event.ActionEvent evt) {
148
//call builder
ExpressionBuilderToolJDialog jdiagExpressionBuilder = new
ExpressionBuilderToolJDialog(this.parentWindow, this.jtfInvariantExpr,
getInvariantVariableList(), true);
jdiagExpressionBuilder.setVisible(true);
}
private void jbutInvariantAddActionPerformed(java.awt.event.ActionEvent evt) {
if (jbutInvariantAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelInvariants.setElementAt(jtfInvariantExpr.getText(),
jlistInvariants.getSelectedIndex());
jbutInvariantAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
} else {
modelInvariants.addElement(jtfInvariantExpr.getText());
}
jtfInvariantExpr.setText("");
}
private void jbutInvariantEditActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistInvariants.getSelectedIndex();
String expr = modelInvariants.getElementAt(pos).toString();
jtfInvariantExpr.setText(expr);
jbutInvariantAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
}
private void jbutInvariantDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistInvariants.getSelectedIndex();
modelInvariants.removeElementAt(pos);
}
private void jbutPrevActionPerformed(java.awt.event.ActionEvent evt) {
this.parentWindow.switchView(MainToolJFrame.TYPE_VIEW);
}
private void jtfInvariantExprActionPerformed(java.awt.event.ActionEvent evt) {
jbutInvariantAddActionPerformed(evt);
}
private void jtfInitExprActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jbutinitExprBuilderActionPerformed(java.awt.event.ActionEvent evt) {
//call builder
ExpressionBuilderToolJDialog jdiagExpressionBuilder = new
ExpressionBuilderToolJDialog(this.parentWindow, this.jtfInitExpr,
getInvariantVariableList(), true);
jdiagExpressionBuilder.setVisible(true);
}
private void jbutInitEditActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistInits.getSelectedIndex();
String expr = modelInits.getElementAt(pos).toString();
jtfInitExpr.setText(expr);
jbutInitAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
}
private void jbutInitDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistInits.getSelectedIndex();
modelInits.removeElementAt(pos);
}
private void jbutInitAddActionPerformed(java.awt.event.ActionEvent evt) {
if (jbutInitAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelInits.setElementAt(jtfInitExpr.getText(),
jlistInits.getSelectedIndex());
jbutInitAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
} else {
modelInits.addElement(jtfInitExpr.getText());
}
jtfInitExpr.setText("");
}
private ArrayList<String> getInvariantVariableList() {
149
ArrayList<String> variableList = new ArrayList<String>();
//add static values
variableList.add("0");
variableList.add(OzOperationBean.OPERATOR_VALUE_SET_EMPTY);
//add constant types (from prevoius screen)
HashMap<String, OzVariable> constantTypes =
this.controlsystem.getOzSpecificationBean().getConstantDataTypes();
for (OzVariable constantType : constantTypes.values()) {
variableList.add(constantType.getName());
}
//add free types (from prevoius screen)
HashMap<String, OzVariable> freeTypes =
this.controlsystem.getOzSpecificationBean().getFreeDataTypes();
for (OzVariable freeType : freeTypes.values()) {
for (String value : freeType.getValues()) {
variableList.add(value);
}
}
//add state variables (from this screen)
for (int i=0;i<modelStateVariables.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelStateVariables.getElementAt(i).toString(),
MainToolJFrame.SEP_VISIBILITY_NAME +
MainToolJFrame.SEP_NAME_TYPE, false);
String visibility = stk.nextToken();
String name = stk.nextToken();
variableList.add(name);
}
}
return variableList;
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JButton jbutClearAll;
private javax.swing.JButton jbutExprBuilder;
private javax.swing.JButton jbutInitAdd;
private javax.swing.JButton jbutInitDelete;
private javax.swing.JButton jbutInitEdit;
private javax.swing.JButton jbutInvariantAdd;
private javax.swing.JButton jbutInvariantDelete;
private javax.swing.JButton jbutInvariantEdit;
private javax.swing.JButton jbutNext;
private javax.swing.JButton jbutPrev;
private javax.swing.JButton jbutStateAdd;
private javax.swing.JButton jbutStateDelete;
private javax.swing.JButton jbutStateEdit;
private javax.swing.JButton jbutinitExprBuilder;
private javax.swing.JComboBox jcbStateType;
private javax.swing.JList jlistInits;
private javax.swing.JList jlistInvariants;
private javax.swing.JList jlistStates;
private javax.swing.JRadioButton jradStateVisiblePrivate;
private javax.swing.JRadioButton jradStateVisiblePublic;
private javax.swing.ButtonGroup jrgStateVisible;
public javax.swing.JTextField jtfInitExpr;
public javax.swing.JTextField jtfInvariantExpr;
private javax.swing.JTextField jtfStateName;
// End of variables declaration
150
}
/*
* OperationToolJPanel.java
*
* Created on Oct 12, 2009, 10:39:00 AM
*/
package edu.csus.fozcil.tool;
import
import
import
import
import
import
import
import
import
edu.csus.fozcil.bean.OzOperationBean;
edu.csus.fozcil.bean.OzSpecificationBean;
edu.csus.fozcil.bean.OzVariable;
java.util.ArrayList;
java.util.HashMap;
java.util.HashSet;
java.util.StringTokenizer;
javax.swing.DefaultComboBoxModel;
javax.swing.DefaultListModel;
/**
*
* @author GeorgeN
*/
public class OperationToolJPanel extends javax.swing.JPanel {
private
private
private
private
private
private
private
private
private
private
private
private
MainToolJFrame parentWindow;
ToolControlSystem controlsystem;
DefaultListModel modelOperations;
DefaultListModel modelPreconds;
DefaultListModel modelPostconds;
DefaultComboBoxModel modelStateNames;
DefaultComboBoxModel modelStateModifiers;
DefaultListModel modelStates;
DefaultComboBoxModel modelInputTypes;
DefaultListModel modelInputs;
DefaultComboBoxModel modelOutputTypes;
DefaultListModel modelOutputs;
/** Creates new form OperationToolJPanel */
public OperationToolJPanel(MainToolJFrame parent, ToolControlSystem controlsystem) {
this.parentWindow = parent;
this.controlsystem = controlsystem;
modelOperations = new DefaultListModel();
modelPreconds = new DefaultListModel();
modelPostconds = new DefaultListModel();
modelStateNames = new DefaultComboBoxModel ();
modelStateModifiers = new DefaultComboBoxModel ();
modelStates = new DefaultListModel();
modelInputTypes = new DefaultComboBoxModel ();
modelInputs = new DefaultListModel();
modelOutputTypes = new DefaultComboBoxModel ();
modelOutputs = new DefaultListModel();
initComponents();
}
public void refreshComponents() {
HashMap<String,OzVariable> constantDataTypes =
this.controlsystem.getOzSpecificationBean().getConstantDataTypes();
//state names
HashMap<String,OzVariable> stateVariables =
this.controlsystem.getOzSpecificationBean().getStateVariables();
for (OzVariable stateVariable : stateVariables.values()) {
this.modelStateNames.addElement(stateVariable.getName());
}
151
//state modifiers
modelStateModifiers.removeAllElements();
modelStateModifiers.addElement("");
modelStateModifiers.addElement(OzSpecificationBean.OZ_STATE_MODIFIER_THETA);
modelStateModifiers.addElement(OzSpecificationBean.OZ_STATE_MODIFIER_DELTA);
//input types
modelInputTypes.removeAllElements();
modelInputTypes.addElement("");
modelInputTypes.addElement("N");
modelInputTypes.addElement("Z");
for (OzVariable userDataType :
this.controlsystem.getOzSpecificationBean().getUserDataTypes()) {
this.modelInputTypes.addElement(userDataType.getName());
}
for (OzVariable constantDataType : constantDataTypes.values()) {
this.modelInputTypes.addElement(constantDataType.getName());
}
//output types
modelOutputTypes.removeAllElements();
modelOutputTypes.addElement("");
modelOutputTypes.addElement("N");
modelOutputTypes.addElement("Z");
for (OzVariable userDataType :
this.controlsystem.getOzSpecificationBean().getUserDataTypes()) {
this.modelOutputTypes.addElement(userDataType.getName());
}
for (OzVariable constantDataType : constantDataTypes.values()) {
this.modelOutputTypes.addElement(constantDataType.getName());
}
}
public void loadOzSpecificationData() {
OzSpecificationBean ozbean = this.controlsystem.getOzSpecificationBean();
for (OzOperationBean ozOperationBean : ozbean.getOperations()) {
if
(!(ozOperationBean.getName().equals(OzSpecificationBean.OZ_INIT_METHOD_NAME))) {
modelOperations.addElement(ozOperationBean.getName());
}
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jrgOperationVisible = new javax.swing.ButtonGroup();
jScrollPane5 = new javax.swing.JScrollPane();
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jtfPrecondExpr = new javax.swing.JTextField();
jbutPrecondAdd = new javax.swing.JButton();
jbutPrecondBuilder = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jlistPreconds = new javax.swing.JList();
jbutPrecondEdit = new javax.swing.JButton();
jbutPrecondDelete = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jcbStateNames = new javax.swing.JComboBox();
jcbStateModifiers = new javax.swing.JComboBox();
jSeparator1 = new javax.swing.JSeparator();
jLabel4 = new javax.swing.JLabel();
152
jScrollPane2 = new javax.swing.JScrollPane();
jlistStates = new javax.swing.JList();
jbutStateAdd = new javax.swing.JButton();
jbutStateEdit = new javax.swing.JButton();
jbutStateDelete = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jcbInputType = new javax.swing.JComboBox();
jSeparator2 = new javax.swing.JSeparator();
jLabel7 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jlistInputs = new javax.swing.JList();
jbutInputAdd = new javax.swing.JButton();
jbutInputEdit = new javax.swing.JButton();
jbutInputDelete = new javax.swing.JButton();
jtfInputName = new javax.swing.JTextField();
jPanel5 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jcbOutputType = new javax.swing.JComboBox();
jSeparator3 = new javax.swing.JSeparator();
jLabel10 = new javax.swing.JLabel();
jScrollPane4 = new javax.swing.JScrollPane();
jlistOutputs = new javax.swing.JList();
jbutOutputAdd = new javax.swing.JButton();
jbutOutputEdit = new javax.swing.JButton();
jbutOutputDelete = new javax.swing.JButton();
jtfOutputName = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jtfOperationName = new javax.swing.JTextField();
jPanel6 = new javax.swing.JPanel();
jtfPostcondExpr = new javax.swing.JTextField();
jbutPostcondAdd = new javax.swing.JButton();
jbutPostcondBuilder = new javax.swing.JButton();
jLabel12 = new javax.swing.JLabel();
jScrollPane6 = new javax.swing.JScrollPane();
jlistPostconds = new javax.swing.JList();
jbutPostcondEdit = new javax.swing.JButton();
jbutPostcondDelete = new javax.swing.JButton();
jbutAddOperation = new javax.swing.JButton();
jLabel14 = new javax.swing.JLabel();
jradOperationVisiblePublic = new javax.swing.JRadioButton();
jradOperationVisiblePrivate = new javax.swing.JRadioButton();
jLabel13 = new javax.swing.JLabel();
jScrollPane7 = new javax.swing.JScrollPane();
jlistOperations = new javax.swing.JList();
jbutEditOperation = new javax.swing.JButton();
jbutDeleteOperation = new javax.swing.JButton();
jbutOK = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
setBackground(new java.awt.Color(140, 176, 222));
jPanel1.setBackground(new java.awt.Color(189, 208, 233));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Add/Update
Operation", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12)));
// NOI18N
jPanel1.setAutoscrolls(true);
jPanel2.setBackground(new java.awt.Color(189, 208, 233));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
"Precondition", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jbutPrecondAdd.setText("Add");
jbutPrecondAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPrecondAddActionPerformed(evt);
}
});
153
jbutPrecondBuilder.setText("Expression Builder");
jbutPrecondBuilder.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPrecondBuilderActionPerformed(evt);
}
});
jLabel1.setText("<html>Added<br/>Preconditions</html?");
jlistPreconds.setModel(modelPreconds);
jScrollPane1.setViewportView(jlistPreconds);
jbutPrecondEdit.setText("Edit");
jbutPrecondEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPrecondEditActionPerformed(evt);
}
});
jbutPrecondDelete.setText("Delete");
jbutPrecondDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPrecondDeleteActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfPrecondExpr, javax.swing.GroupLayout.DEFAULT_SIZE,
441, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel2Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE))
.addComponent(jbutPrecondBuilder))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutPrecondDelete)
.addComponent(jbutPrecondEdit)
.addComponent(jbutPrecondAdd))))
.addContainerGap())
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutPrecondAdd, jbutPrecondDelete, jbutPrecondEdit});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jtfPrecondExpr, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutPrecondAdd)
.addComponent(jbutPrecondBuilder))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
154
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jbutPrecondEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutPrecondDelete)))
.addContainerGap())
);
jPanel3.setBackground(new java.awt.Color(189, 208, 233));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "State
Modifier", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel2.setText("Name");
jLabel3.setText("Modifier");
jcbStateNames.setModel(modelStateNames);
jcbStateModifiers.setModel(modelStateModifiers);
jLabel4.setText("Existing State");
jlistStates.setModel(modelStates);
jScrollPane2.setViewportView(jlistStates);
jbutStateAdd.setText("Add");
jbutStateAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutStateAddActionPerformed(evt);
}
});
jbutStateEdit.setText("Edit");
jbutStateEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutStateEditActionPerformed(evt);
}
});
jbutStateDelete.setText("Delete");
jbutStateDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutStateDeleteActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 441,
Short.MAX_VALUE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(45, 45, 45)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jcbStateNames, 0,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
155
.addComponent(jcbStateModifiers, 0, 266, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutStateAdd))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutStateDelete)
.addComponent(jbutStateEdit))))
.addContainerGap())
);
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutStateAdd, jbutStateDelete, jbutStateEdit});
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jcbStateNames, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jcbStateModifiers,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jbutStateAdd))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jbutStateEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutStateDelete))
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
87, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel4.setBackground(new java.awt.Color(189, 208, 233));
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input
variables", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel5.setText("Name");
jLabel6.setText("Type");
jcbInputType.setModel(modelInputTypes);
jLabel7.setText("<html>Added<br/>Variables</html>");
jlistInputs.setModel(modelInputs);
jScrollPane3.setViewportView(jlistInputs);
jbutInputAdd.setText("Add");
jbutInputAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
156
jbutInputAddActionPerformed(evt);
});
}
jbutInputEdit.setText("Edit");
jbutInputEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutInputEditActionPerformed(evt);
}
});
jbutInputDelete.setText("Delete");
jbutInputDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutInputDeleteActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 441,
Short.MAX_VALUE)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(56, 56, 56)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jtfInputName)
.addComponent(jcbInputType, 0, 269, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutInputAdd))
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel7)
.addGap(39, 39, 39)
.addComponent(jScrollPane3,
javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutInputDelete)
.addComponent(jbutInputEdit))))
.addContainerGap())
);
jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutInputAdd, jbutInputDelete, jbutInputEdit});
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jtfInputName, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jcbInputType, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jbutInputAdd))
157
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jbutInputEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutInputDelete))
.addComponent(jLabel7)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE,
87, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel5.setBackground(new java.awt.Color(189, 208, 233));
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Output
variables", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jLabel8.setText("Name");
jLabel9.setText("Type");
jcbOutputType.setModel(modelOutputTypes);
jLabel10.setText("<html>Added<br/>Variables</html>");
jlistOutputs.setModel(modelOutputs);
jScrollPane4.setViewportView(jlistOutputs);
jbutOutputAdd.setText("Add");
jbutOutputAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutOutputAddActionPerformed(evt);
}
});
jbutOutputEdit.setText("Edit");
jbutOutputEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutOutputEditActionPerformed(evt);
}
});
jbutOutputDelete.setText("Delete");
jbutOutputDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutOutputDeleteActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 441,
Short.MAX_VALUE)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel9))
.addGap(56, 56, 56)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
158
.addComponent(jtfOutputName)
.addComponent(jcbOutputType, 0, 267, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutOutputAdd))
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jLabel10)
.addGap(39, 39, 39)
.addComponent(jScrollPane4,
javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutOutputDelete)
.addComponent(jbutOutputEdit))))
.addContainerGap())
);
jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutOutputAdd, jbutOutputDelete, jbutOutputEdit});
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jtfOutputName, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(jcbOutputType, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jbutOutputAdd))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jbutOutputEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutOutputDelete))
.addComponent(jLabel10)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE,
87, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jLabel11.setText("Operation name");
jPanel6.setBackground(new java.awt.Color(189, 208, 233));
jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
"Postcondition", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
// NOI18N
jbutPostcondAdd.setText("Add");
jbutPostcondAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPostcondAddActionPerformed(evt);
}
});
jbutPostcondBuilder.setText("Expression Builder");
jbutPostcondBuilder.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPostcondBuilderActionPerformed(evt);
}
159
});
jLabel12.setText("<html>Added<br/>Preconditions</html?");
jlistPostconds.setModel(modelPostconds);
jScrollPane6.setViewportView(jlistPostconds);
jbutPostcondEdit.setText("Edit");
jbutPostcondEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPostcondEditActionPerformed(evt);
}
});
jbutPostcondDelete.setText("Delete");
jbutPostcondDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutPostcondDeleteActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jtfPostcondExpr, javax.swing.GroupLayout.DEFAULT_SIZE,
441, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel6Layout.createSequentialGroup()
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel6Layout.createSequentialGroup()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane6,
javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE))
.addComponent(jbutPostcondBuilder))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutPostcondDelete)
.addComponent(jbutPostcondEdit)
.addComponent(jbutPostcondAdd))))
.addContainerGap())
);
jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new
java.awt.Component[] {jbutPostcondAdd, jbutPostcondDelete, jbutPostcondEdit});
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(jtfPostcondExpr, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutPostcondAdd)
.addComponent(jbutPostcondBuilder))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE,
90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(jbutPostcondEdit)
160
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutPostcondDelete)))
.addContainerGap())
);
jbutAddOperation.setText("Add Operation");
jbutAddOperation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutAddOperationActionPerformed(evt);
}
});
jLabel14.setText("Visibility");
jradOperationVisiblePublic.setBackground(new java.awt.Color(189, 208, 233));
jrgOperationVisible.add(jradOperationVisiblePublic);
jradOperationVisiblePublic.setText("public");
jradOperationVisiblePrivate.setBackground(new java.awt.Color(189, 208, 233));
jrgOperationVisible.add(jradOperationVisiblePrivate);
jradOperationVisiblePrivate.setText("private");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jbutAddOperation,
javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel11)
.addComponent(jLabel14))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jradOperationVisiblePublic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jradOperationVisiblePrivate))
.addComponent(jtfOperationName,
javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel11)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(26, 26, 26)
.addComponent(jLabel14))
.addComponent(jtfOperationName,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
161
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jradOperationVisiblePublic)
.addComponent(jradOperationVisiblePrivate))))
.addGap(7, 7, 7)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jbutAddOperation)
.addContainerGap(81, Short.MAX_VALUE))
);
jScrollPane5.setViewportView(jPanel1);
jLabel13.setText("<html>Added<br/>Operations</html>");
jlistOperations.setModel(modelOperations);
jScrollPane7.setViewportView(jlistOperations);
jbutEditOperation.setText("Edit");
jbutEditOperation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutEditOperationActionPerformed(evt);
}
});
jbutDeleteOperation.setText("Delete");
jbutDeleteOperation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutDeleteOperationActionPerformed(evt);
}
});
jbutOK.setText("OK");
jbutOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutOKActionPerformed(evt);
}
});
jButton3.setText("Clear All");
jButton4.setText("Prev");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane5,
javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 509,
Short.MAX_VALUE)
162
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(18, 18, 18)
.addComponent(jScrollPane7,
javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jbutDeleteOperation)
.addComponent(jbutEditOperation)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jButton4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel13)
.addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE,
100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jbutEditOperation)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutDeleteOperation)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 541,
Short.MAX_VALUE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutOK)
.addComponent(jButton3)
.addComponent(jButton4))
.addContainerGap())
);
}// </editor-fold>
private void jbutPrecondBuilderActionPerformed(java.awt.event.ActionEvent evt) {
//call builder
ExpressionBuilderToolJDialog jdiagExpressionBuilder =
new ExpressionBuilderToolJDialog(this.parentWindow,
this.jtfPrecondExpr,
getPrePostConditionVariableList(true),
true);
jdiagExpressionBuilder.setVisible(true);
}
private void jbutPrecondAddActionPerformed(java.awt.event.ActionEvent evt) {
if (jbutPrecondAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelPreconds.setElementAt(jtfPrecondExpr.getText(),
jlistPreconds.getSelectedIndex());
jbutPrecondAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
} else {
modelPreconds.addElement(jtfPrecondExpr.getText());
}
jtfPrecondExpr.setText("");
}
private void jbutPrecondEditActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistPreconds.getSelectedIndex();
String expr = modelPreconds.getElementAt(pos).toString();
jtfPrecondExpr.setText(expr);
163
jbutPrecondAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
}
private void jbutPrecondDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistPreconds.getSelectedIndex();
modelPreconds.removeElementAt(pos);
}
private void jbutStateAddActionPerformed(java.awt.event.ActionEvent evt) {
String modifierName = jcbStateModifiers.getSelectedItem() +
MainToolJFrame.SEP_VISIBILITY_NAME +
jcbStateNames.getSelectedItem();
//is this Add or Update?
if (jbutStateAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelStates.setElementAt(modifierName, jlistStates.getSelectedIndex());
//change button's text
jbutStateAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jlistStates.clearSelection();
} else {
modelStates.addElement(modifierName);
}
//clear the text fields
jcbStateNames.setSelectedIndex(0);
jcbStateModifiers.setSelectedIndex(0);
}
private void jbutStateEditActionPerformed(java.awt.event.ActionEvent evt) {
//get NV to be edited and set the appropriate textboxes
int pos = jlistStates.getSelectedIndex();
String modifierName = modelStates.getElementAt(pos).toString();
StringTokenizer stk = new StringTokenizer(modifierName,
MainToolJFrame.SEP_VISIBILITY_NAME, false);
String modifier = stk.nextToken();
jcbStateModifiers.setSelectedItem(modifier);
String name = stk.nextToken();
jcbStateNames.setSelectedItem(name);
//change button's text
jbutStateAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
}
private void jbutStateDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistStates.getSelectedIndex();
modelStates.removeElementAt(pos);
}
private void jbutInputAddActionPerformed(java.awt.event.ActionEvent evt) {
String modfdName = jtfInputName.getText().endsWith("?") ?
jtfInputName.getText():
jtfInputName.getText() + "?";
String nameType = modfdName + MainToolJFrame.SEP_NAME_TYPE +
jcbInputType.getSelectedItem();
//is this Add or Update?
if (jbutInputAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelInputs.setElementAt(nameType, jlistInputs.getSelectedIndex());
//change button's text
jbutInputAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jlistInputs.clearSelection();
} else {
modelInputs.addElement(nameType);
}
//clear the text fields
jtfInputName.setText("");
jcbInputType.setSelectedIndex(0);
}
private void jbutInputEditActionPerformed(java.awt.event.ActionEvent evt) {
//get NV to be edited and set the appropriate textboxes
int pos = jlistInputs.getSelectedIndex();
String nameType = modelInputs.getElementAt(pos).toString();
StringTokenizer stk = new StringTokenizer(nameType,
MainToolJFrame.SEP_NAME_TYPE, false);
String name = stk.nextToken();
jtfInputName.setText(name);
164
String type = stk.nextToken();
jcbInputType.setSelectedItem(type);
}
//change button's text
jbutInputAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
private void jbutInputDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistInputs.getSelectedIndex();
modelInputs.removeElementAt(pos);
}
private void jbutOutputAddActionPerformed(java.awt.event.ActionEvent evt) {
String modfdName = jtfOutputName.getText().endsWith("!") ?
jtfOutputName.getText():
jtfOutputName.getText() + "!";
String nameType = modfdName + MainToolJFrame.SEP_NAME_TYPE +
jcbOutputType.getSelectedItem();
//is this Add or Update?
if (jbutOutputAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelOutputs.setElementAt(nameType, jlistOutputs.getSelectedIndex());
//change button's text
jbutOutputAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jlistOutputs.clearSelection();
} else {
modelOutputs.addElement(nameType);
}
//clear the text fields
jtfOutputName.setText("");
jcbOutputType.setSelectedIndex(0);
}
private void jbutOutputEditActionPerformed(java.awt.event.ActionEvent evt) {
//get NV to be edited and set the appropriate textboxes
int pos = jlistOutputs.getSelectedIndex();
String nameType = modelOutputs.getElementAt(pos).toString();
StringTokenizer stk = new StringTokenizer(nameType,
MainToolJFrame.SEP_NAME_TYPE, false);
String name = stk.nextToken();
jtfOutputName.setText(name);
String type = stk.nextToken();
jcbOutputType.setSelectedItem(type);
//change button's text
jbutOutputAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
}
}
private void jbutOutputDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistOutputs.getSelectedIndex();
modelOutputs.removeElementAt(pos);
private void jbutPostcondAddActionPerformed(java.awt.event.ActionEvent evt) {
if (jbutPostcondAdd.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
modelPostconds.setElementAt(jtfPostcondExpr.getText(),
jlistPostconds.getSelectedIndex());
jbutPostcondAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
} else {
modelPostconds.addElement(jtfPostcondExpr.getText());
}
jtfPostcondExpr.setText("");
}
}
private void jbutPostcondBuilderActionPerformed(java.awt.event.ActionEvent evt) {
//call builder
ExpressionBuilderToolJDialog jdiagExpressionBuilder =
new ExpressionBuilderToolJDialog(this.parentWindow,
this.jtfPostcondExpr,
getPrePostConditionVariableList(false),
true);
jdiagExpressionBuilder.setVisible(true);
private void jbutPostcondEditActionPerformed(java.awt.event.ActionEvent evt) {
165
int pos = jlistPostconds.getSelectedIndex();
String expr = modelPostconds.getElementAt(pos).toString();
jtfPostcondExpr.setText(expr);
jbutPostcondAdd.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
}
private void jbutPostcondDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistPostconds.getSelectedIndex();
modelPostconds.removeElementAt(pos);
}
private void jbutAddOperationActionPerformed(java.awt.event.ActionEvent evt) {
//update the screen
if (jbutAddOperation.getText().equals(MainToolJFrame.BUTTON_UPDATE_TEXT)) {
//remove the old OzOperation bean
//we will just add a new operation whether ADD or UPDATE
this.controlsystem.getOzSpecificationBean().getOperations().remove(
findOperation(jtfOperationName.getText(),
this.controlsystem.getOzSpecificationBean().getOperations()
)
);
modelOperations.setElementAt(jtfOperationName.getText(),
jlistOperations.getSelectedIndex());
jbutAddOperation.setText(MainToolJFrame.BUTTON_ADD_TEXT);
//aslo reset all other "Add" buttons
jbutStateAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jbutInputAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jbutOutputAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jbutPrecondAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
jbutPostcondAdd.setText(MainToolJFrame.BUTTON_ADD_TEXT);
} else {
modelOperations.addElement(jtfOperationName.getText());
}
//add oper name & visibility
OzOperationBean operbean = new OzOperationBean(jtfOperationName.getText());
String publicOrprivate = (jradOperationVisiblePrivate.isSelected())?
MainToolJFrame.VISIBILITY_PRIVATE :
MainToolJFrame.VISIBILITY_PUBLIC;
operbean.setVisibility(publicOrprivate);
//state modifiers added as not needed by Converter
for (int i=0;i<modelStates.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelStates.getElementAt(i).toString(),
MainToolJFrame.SEP_VISIBILITY_NAME, false);
String modifier = stk.nextToken();
String name = stk.nextToken();
operbean.addStateModifier(name,modifier);
}
//add input variables
for (int i=0;i<modelInputs.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelInputs.getElementAt(i).toString(),
MainToolJFrame.SEP_NAME_TYPE, false);
String name = stk.nextToken();
String type = stk.nextToken();
operbean.addArgument(name,type);
}
//add output variables
for (int i=0;i<modelOutputs.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelOutputs.getElementAt(i).toString(),
MainToolJFrame.SEP_NAME_TYPE, false);
String name = stk.nextToken();
String type = stk.nextToken();
operbean.addArgument(name,type);
}
//add preconds
for (int i=0;i<modelPreconds.getSize();i++) {
operbean.addPrecondition(modelPreconds.getElementAt(i).toString());
}
166
//add postconds
for (int i=0;i<modelPostconds.getSize();i++) {
operbean.addPostcondition(modelPostconds.getElementAt(i).toString());
}
//add oper to the temporary HashSet
this.controlsystem.getOzSpecificationBean().addOperation(operbean);
}
//clear all the elements
clearOperationElements();
private void jbutOKActionPerformed(java.awt.event.ActionEvent evt) {
this.parentWindow.showSaveFileDialog();
}
private void jbutEditOperationActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistOperations.getSelectedIndex();
String operName = modelOperations.getElementAt(pos).toString();
//clear all elements, initially
clearOperationElements();
//load operation
loadOperation(operName,
this.controlsystem.getOzSpecificationBean().getOperations());
}
jbutAddOperation.setText(MainToolJFrame.BUTTON_UPDATE_TEXT);
private void jbutDeleteOperationActionPerformed(java.awt.event.ActionEvent evt) {
int pos = jlistOperations.getSelectedIndex();
String operName = modelOperations.getElementAt(pos).toString();
modelOperations.removeElementAt(pos);
this.controlsystem.getOzSpecificationBean().getOperations().remove(
findOperation(operName,
this.controlsystem.getOzSpecificationBean().getOperations()
)
);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
this.parentWindow.switchView(MainToolJFrame.STATE_VIEW);
}
private OzOperationBean loadOperation(String operName, HashSet<OzOperationBean>
operations) {
OzOperationBean loadedOperation = null;
//find the operation
loadedOperation = findOperation(operName, operations);
//load oper name & visibility
jtfOperationName.setText(loadedOperation.getName());
if (loadedOperation.getVisibility().equals(MainToolJFrame.VISIBILITY_PUBLIC))
jradOperationVisiblePublic.setSelected(true);
else
jradOperationVisiblePrivate.setSelected(true);
//no state modifiers added as not needed by Converter
//this is only used by the Pre- and the Post- expression builders
for (String stateName : loadedOperation.getStateModifiers().keySet()) {
modelStates.addElement(loadedOperation.getStateModifiers().get(stateName) +
MainToolJFrame.SEP_VISIBILITY_NAME +
stateName);
}
//add input & output variables
for (String argName : loadedOperation.getArguments().keySet()) {
if (argName.endsWith("?")) {
modelInputs.addElement(argName + MainToolJFrame.SEP_NAME_TYPE +
loadedOperation.getArguments().get(argName));
} else if (argName.endsWith("!")) {
modelOutputs.addElement(argName + MainToolJFrame.SEP_NAME_TYPE +
167
loadedOperation.getArguments().get(argName));
}
}
//add preconds
for (String precondition : loadedOperation.getPreconditions()) {
modelPreconds.addElement(precondition);
}
//add postconds
for (String postcondition : loadedOperation.getPostconditions()) {
modelPostconds.addElement(postcondition);
}
}
//add this loaded operation into collection
return loadedOperation;
private OzOperationBean findOperation(String operName, HashSet<OzOperationBean>
operations) {
OzOperationBean foundOperation = null;
for (OzOperationBean ozOperationBean : operations) {
if (ozOperationBean.getName().equals(operName)) {
foundOperation = ozOperationBean;
break;
}
}
return foundOperation;
}
private void clearOperationElements() {
jtfOperationName.setText("");
jradOperationVisiblePublic.setSelected(false);
jradOperationVisiblePrivate.setSelected(false);
jcbStateNames.setSelectedIndex(0);
jcbStateModifiers.setSelectedIndex(0);
modelStates.removeAllElements();
jtfInputName.setText("");
jcbInputType.setSelectedIndex(0);
modelInputs.removeAllElements();
jtfOutputName.setText("");
jcbOutputType.setSelectedIndex(0);
modelOutputs.removeAllElements();
jtfPrecondExpr.setText("");
modelPreconds.removeAllElements();
jtfPostcondExpr.setText("");
modelPostconds.removeAllElements();
}
private ArrayList<String> getPrePostConditionVariableList(boolean isPrecondition) {
ArrayList<String> variableList = new ArrayList<String>();
//add static values
variableList.add("0");
variableList.add(OzOperationBean.OPERATOR_VALUE_SET_EMPTY);
//add constant types (from prevoius screen)
HashMap<String, OzVariable> constantTypes =
this.controlsystem.getOzSpecificationBean().getConstantDataTypes();
for (OzVariable constantType : constantTypes.values()) {
variableList.add(constantType.getName());
}
//add free types (from prevoius screen)
HashMap<String, OzVariable> freeTypes =
this.controlsystem.getOzSpecificationBean().getFreeDataTypes();
168
for (OzVariable freeType : freeTypes.values()) {
for (String value : freeType.getValues()) {
variableList.add(value);
}
}
//add state variables (from this screen)
for (int i=0;i<modelStates.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelStates.getElementAt(i).toString(),
MainToolJFrame.SEP_VISIBILITY_NAME , false);
String modifier = stk.nextToken();
String name = stk.nextToken();
variableList.add(name);
if ((!isPrecondition) &&
(modifier.equals(OzSpecificationBean.OZ_STATE_MODIFIER_DELTA))) {
variableList.add(name +
OzSpecificationBean.OZ_DELTA_OUTPUT_VARIABLE_MARKER);
}
}
//add in variables
for (int i=0;i<modelInputs.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelInputs.getElementAt(i).toString(),
MainToolJFrame.SEP_NAME_TYPE, false);
String name = stk.nextToken();
variableList.add(name);
}
//add output variables
if (!isPrecondition) {
for (int i=0;i<modelOutputs.getSize();i++) {
StringTokenizer stk = new
StringTokenizer(modelOutputs.getElementAt(i).toString(),
MainToolJFrame.SEP_NAME_TYPE, false);
String name = stk.nextToken();
String type = stk.nextToken();
variableList.add(name);
}
}
return variableList;
}
// Variables declaration - do not modify
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
169
private javax.swing.JScrollPane jScrollPane7;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JButton jbutAddOperation;
private javax.swing.JButton jbutDeleteOperation;
private javax.swing.JButton jbutEditOperation;
private javax.swing.JButton jbutInputAdd;
private javax.swing.JButton jbutInputDelete;
private javax.swing.JButton jbutInputEdit;
private javax.swing.JButton jbutOK;
private javax.swing.JButton jbutOutputAdd;
private javax.swing.JButton jbutOutputDelete;
private javax.swing.JButton jbutOutputEdit;
private javax.swing.JButton jbutPostcondAdd;
private javax.swing.JButton jbutPostcondBuilder;
private javax.swing.JButton jbutPostcondDelete;
private javax.swing.JButton jbutPostcondEdit;
private javax.swing.JButton jbutPrecondAdd;
private javax.swing.JButton jbutPrecondBuilder;
private javax.swing.JButton jbutPrecondDelete;
private javax.swing.JButton jbutPrecondEdit;
private javax.swing.JButton jbutStateAdd;
private javax.swing.JButton jbutStateDelete;
private javax.swing.JButton jbutStateEdit;
private javax.swing.JComboBox jcbInputType;
private javax.swing.JComboBox jcbOutputType;
private javax.swing.JComboBox jcbStateModifiers;
private javax.swing.JComboBox jcbStateNames;
private javax.swing.JList jlistInputs;
private javax.swing.JList jlistOperations;
private javax.swing.JList jlistOutputs;
private javax.swing.JList jlistPostconds;
private javax.swing.JList jlistPreconds;
private javax.swing.JList jlistStates;
private javax.swing.JRadioButton jradOperationVisiblePrivate;
private javax.swing.JRadioButton jradOperationVisiblePublic;
private javax.swing.ButtonGroup jrgOperationVisible;
private javax.swing.JTextField jtfInputName;
private javax.swing.JTextField jtfOperationName;
private javax.swing.JTextField jtfOutputName;
public javax.swing.JTextField jtfPostcondExpr;
public javax.swing.JTextField jtfPrecondExpr;
// End of variables declaration
}
/*
* ExpressionBuilderToolJDialog.java
*
* Created on Oct 12, 2009, 7:57:50 PM
*/
package edu.csus.fozcil.tool;
import
import
import
import
edu.csus.fozcil.bean.OzOperationBean;
java.util.ArrayList;
javax.swing.DefaultComboBoxModel;
javax.swing.JTextField;
/**
*
* @author GeorgeN
*/
public class ExpressionBuilderToolJDialog extends javax.swing.JDialog {
private
private
private
private
private
MainToolJFrame parentWindow;
JTextField hostExprTextfield;
ArrayList<String> variableList;
DefaultComboBoxModel modelVariables;
DefaultComboBoxModel modelOperators;
/** Creates new form ExpressionBuilderToolJDialog */
170
public ExpressionBuilderToolJDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
public ExpressionBuilderToolJDialog(java.awt.Frame parent, JTextField
hostExpressionTextfield, ArrayList<String> variableList, boolean modal) {
super(parent, modal);
this.parentWindow = (MainToolJFrame) parent;
this.hostExprTextfield = hostExpressionTextfield;
this.variableList = variableList;
this.modelVariables = new DefaultComboBoxModel();
this.modelOperators = new DefaultComboBoxModel();
initComponents();
this.jtfExpression.setText(hostExpressionTextfield.getText());
host text
refreshVariablesComponents();
refreshOperatorComponents();
}
//initialize with
private void refreshVariablesComponents() {
for (String variable : variableList) {
modelVariables.addElement(variable);
}
}
private void refreshOperatorComponents() {
modelOperators.addElement(OzOperationBean.OPERATOR_ASSIGNMENT);
modelOperators.addElement(OzOperationBean.OPERATOR_PLUS);
modelOperators.addElement(OzOperationBean.OPERATOR_MINUS);
modelOperators.addElement(OzOperationBean.OPERATOR_MULTIPLY);
modelOperators.addElement(OzOperationBean.OPERATOR_DIVIDE);
modelOperators.addElement(OzOperationBean.OPERATOR_EQUAL);
modelOperators.addElement(OzOperationBean.OPERATOR_NOT_EQUAL);
modelOperators.addElement(OzOperationBean.OPERATOR_LESS);
modelOperators.addElement(OzOperationBean.OPERATOR_LESS_EQUAL);
modelOperators.addElement(OzOperationBean.OPERATOR_GREATER);
modelOperators.addElement(OzOperationBean.OPERATOR_GREATER_EQUAL);
modelOperators.addElement(OzOperationBean.OPERATOR_NOT);
modelOperators.addElement(OzOperationBean.OPERATOR_OR);
modelOperators.addElement(OzOperationBean.OPERATOR_AND);
modelOperators.addElement(OzOperationBean.OPERATOR_SET_IS_MEMBER_OF);
modelOperators.addElement(OzOperationBean.OPERATOR_SET_IS_NOT_MEMBER_OF);
modelOperators.addElement(OzOperationBean.OPERATOR_SET_EQUALS);
modelOperators.addElement(OzOperationBean.OPERATOR_SET_UNION);
modelOperators.addElement(OzOperationBean.OPERATOR_SET_INTERSECT);
modelOperators.addElement(OzOperationBean.OPERATOR_SET_SUBSET);
modelOperators.addElement(OzOperationBean.OPERATOR_SET_CARDINALITY);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jtfExpression = new javax.swing.JTextField();
jbutParentheses = new javax.swing.JButton();
jcbVariables = new javax.swing.JComboBox();
jbutAddVariable = new javax.swing.JButton();
jcbOperators = new javax.swing.JComboBox();
jbutAddOperator = new javax.swing.JButton();
jbutDelete = new javax.swing.JButton();
jbutOK = new javax.swing.JButton();
jbutCancel = new javax.swing.JButton();
171
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setBackground(new java.awt.Color(153, 153, 255));
jPanel1.setBackground(new java.awt.Color(140, 176, 222));
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
jPanel2.setBackground(new java.awt.Color(189, 208, 233));
jPanel2.setForeground(new java.awt.Color(204, 204, 255));
jbutParentheses.setText("( )");
jbutParentheses.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutParenthesesActionPerformed(evt);
}
});
jcbVariables.setModel(modelVariables);
jbutAddVariable.setText("Add Variable");
jbutAddVariable.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutAddVariableActionPerformed(evt);
}
});
jcbOperators.setModel(modelOperators);
jbutAddOperator.setText("Add Operator");
jbutAddOperator.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutAddOperatorActionPerformed(evt);
}
});
jbutDelete.setText("Delete");
jbutDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutDeleteActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addComponent(jtfExpression,
javax.swing.GroupLayout.DEFAULT_SIZE, 577, Short.MAX_VALUE)
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jbutParentheses)
.addGap(29, 29, 29)
.addComponent(jcbVariables,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutAddVariable)
.addGap(27, 27, 27)
.addComponent(jcbOperators,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbutAddOperator)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
.addComponent(jbutDelete)
172
.addGap(82, 82, 82))))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jtfExpression, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutParentheses)
.addComponent(jbutAddVariable)
.addComponent(jcbVariables, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jcbOperators, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jbutAddOperator)
.addComponent(jbutDelete))
.addContainerGap(29, Short.MAX_VALUE))
);
jbutOK.setText("OK");
jbutOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutOKActionPerformed(evt);
}
});
jbutCancel.setText("Cancel");
jbutCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbutCancelActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jbutCancel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jbutOK)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbutOK)
.addComponent(jbutCancel))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
173
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jbutParenthesesActionPerformed(java.awt.event.ActionEvent evt) {
alterExpression(" () ");
}
private void jbutDeleteActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jbutAddVariableActionPerformed(java.awt.event.ActionEvent evt) {
alterExpression(" " + jcbVariables.getSelectedItem() + " ");
}
}
private void jbutAddOperatorActionPerformed(java.awt.event.ActionEvent evt) {
alterExpression(" " + jcbOperators.getSelectedItem() + " ");
private void jbutCancelActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
}
private void jbutOKActionPerformed(java.awt.event.ActionEvent evt) {
this.hostExprTextfield.setText(jtfExpression.getText());
this.dispose();
private void alterExpression(String addText) {
int caretPosition = jtfExpression.getCaretPosition();
String oldExpression = jtfExpression.getText();
String newExpression = oldExpression.substring(0, caretPosition);
newExpression += addText;
newExpression += oldExpression.substring(caretPosition);
jtfExpression.setText(newExpression);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
ExpressionBuilderToolJDialog dialog = new
ExpressionBuilderToolJDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JButton jbutAddOperator;
private javax.swing.JButton jbutAddVariable;
private javax.swing.JButton jbutCancel;
private javax.swing.JButton jbutDelete;
private javax.swing.JButton jbutOK;
private javax.swing.JButton jbutParentheses;
private javax.swing.JComboBox jcbOperators;
174
private javax.swing.JComboBox jcbVariables;
private javax.swing.JTextField jtfExpression;
// End of variables declaration
}
package edu.csus.fozcil.tool;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
edu.csus.fozcil.Constants;
edu.csus.fozcil.FozcilException;
edu.csus.fozcil.bean.LanguageDependentBean;
edu.csus.fozcil.framework.LanguageDependentContentHandler;
edu.csus.fozcil.helper.XmlFactory;
edu.csus.fozcil.helper.XmlTransformer;
edu.csus.fozcil.bean.OzSpecificationBean;
java.io.File;
java.io.FileNotFoundException;
java.io.IOException;
java.io.InputStream;
java.util.Properties;
java.util.logging.Level;
javax.xml.parsers.ParserConfigurationException;
javax.xml.parsers.SAXParser;
javax.xml.transform.TransformerConfigurationException;
javax.xml.transform.TransformerException;
org.apache.log4j.Logger;
org.apache.log4j.PropertyConfigurator;
org.w3c.dom.Document;
org.xml.sax.SAXException;
/**
* Application Controller
* UI talks to the model via this controller
* @author GeorgeN
*/
public class ToolControlSystem {
private static Logger LOG;
private Properties appProps;
//
private String userSelectedOutputPath = System.getProperty ("user.dir");
//default
private OzSpecificationBean ozSpecificationBean;
private LanguageDependentBean languageDependentBean;
/**
* Default constructor
*/
public ToolControlSystem() throws FozcilException {
//read application properties file
appProps = new Properties();
try {
appProps.load(ToolControlSystem.class.getResourceAsStream(Constants.CONFIG_FOLDER_PATH +
"app.properties"));
} catch (IOException ex) {
throw new FozcilException("Error loading app.properties file", ex,
FozcilException.EXCEP_SEVERITY_HIGH);
}
//init Log4J
String log4jConfigFileName =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_LOG4J_CONFIG_FILE);
if ((log4jConfigFileName == null) || (log4jConfigFileName.equals("")))
System.out.println("Missing app property: " +
Constants.APP_PROPERTIES_KEY_LOG4J_CONFIG_FILE);
Properties log4jProps = new Properties();
try {
log4jProps.load(ToolControlSystem.class.getResourceAsStream(Constants.CONFIG_FOLDER_PATH
+ log4jConfigFileName));
} catch (IOException ex) {
throw new FozcilException("Error initializing logger. Please configure.", ex,
FozcilException.EXCEP_SEVERITY_LOW);
}
175
PropertyConfigurator.configure(log4jProps);
LOG = Logger.getLogger(ToolControlSystem.class.getName());
LOG.debug("Logger initialized.");
//initialize the beans
ozSpecificationBean = new OzSpecificationBean();
languageDependentBean = new LanguageDependentBean();
}
public void doOZtoILBinding(String filePath) throws FozcilException {
LanguageDependentBean ldbean = loadLanguageDependentBean();
//also get token opener and closer
String a = Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_TMPL_TKN_OPEN;
String propTokenOpener =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_TMPL_TKN_OPEN);
if ((propTokenOpener == null) || (propTokenOpener.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_TMPL_TKN_OPEN;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String propTokenCloser =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_TMPL_TKN_CLOSE);
if ((propTokenCloser == null) || (propTokenCloser.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_TMPL_TKN_CLOSE;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
try {
OZtoILconverter oZtoILconverter = new OZtoILconverter(ozSpecificationBean,
ldbean, filePath, propTokenOpener, propTokenCloser);
oZtoILconverter.convert();
} catch (FileNotFoundException ex) {
java.util.logging.Logger.getLogger(ToolControlSystem.class.getName()).log(Level.SEVERE,
null, ex);
} catch (IOException ex) {
java.util.logging.Logger.getLogger(ToolControlSystem.class.getName()).log(Level.SEVERE,
null, ex);
}
}
/**
* Business method for OZ to IL binding
* @param OZfilename
* @param ILtype
* @param ILfilename
* @throws edu.csus.fozcil.app.FozcilException
*/
public void doOZtoILBinding_NOT_USED(String OZfilename, String ILtype, String
ILfilename) throws FozcilException {
//read app properties
String propIndependBindingHome =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_INDEPEND_HOME);
if ((propIndependBindingHome == null) || (propIndependBindingHome.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_INDEPEND_HOME;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String propOZHome =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_OZ_SPEC_HOME);
if ((propOZHome == null) || (propOZHome.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_OZ_SPEC_HOME;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String propILHome =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_IL_CODE_HOME);
if ((propILHome == null) || (propILHome.equals(""))) {
176
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_IL_CODE_HOME;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
//get binding file name
String propIndependBindingFilename =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_INDEPEND_FILE);
if ((propIndependBindingFilename == null) ||
(propIndependBindingFilename.equals("")))
LOG.error("Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_INDEPEND_FILE);
String xslFileName = System.getProperty("user.dir") + File.separator +
propIndependBindingHome +
File.separator + propIndependBindingFilename;
String xmlSourceFileName = propOZHome + OZfilename;
String xmlTargetFileName = propILHome+ILfilename;
try {
XmlTransformer xmltransform = XmlFactory.getXmlTranformer();
xmltransform.tranformXML(xslFileName, xmlSourceFileName, xmlTargetFileName);
} catch (TransformerConfigurationException ex) {
String errMsg = "Error confguring XSL file: " + xslFileName;
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (FileNotFoundException ex) {
String errMsg = "Error configuring XSL file: " + xslFileName;
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (TransformerException ex) {
String errMsg = "Error applying XSL tranformation -:" + xslFileName + ":- to
XML file -:" + xmlSourceFileName + ":-";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (IOException ex) {
String errMsg = "Error opening file.";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
}
}
public void doOZtoDocBinding(String filePath) throws FozcilException {
try {
OZtoDocConverter oZtoDocConverter = new OZtoDocConverter(ozSpecificationBean,
filePath);
oZtoDocConverter.convert();
} catch (FileNotFoundException ex) {
java.util.logging.Logger.getLogger(ToolControlSystem.class.getName()).log(Level.SEVERE,
null, ex);
} catch (IOException ex) {
java.util.logging.Logger.getLogger(ToolControlSystem.class.getName()).log(Level.SEVERE,
null, ex);
}
}
/*
* We write to an XML file and save it to the the file system
*/
public void saveOzSpecificationData(String filePath) throws FozcilException {
OzSpecificationBean ozsb = this.ozSpecificationBean;
//build DOM
Document document = OzSpecificationDomBuilder.buildDocument(ozsb);
//get XmlTransformer
XmlTransformer xmltranformer = XmlFactory.getXmlTranformer();
String completefilePath = filePath + File.separator + ozsb.getSchemaName() +
".fozcil.xml";
try {
177
}
}
}
}
xmltranformer.tranformXML(null, document, completefilePath);
LOG.debug("OzSpecification file written successfully.");
catch (TransformerConfigurationException ex) {
String errMsg = "XMLTransformer has not been configured properly";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
catch (TransformerException ex) {
String errMsg = "Error transforming DOM to XML data";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
catch (FileNotFoundException ex) {
String errMsg = "Error while saving XML data";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
catch (IOException ex) {
String errMsg = "General IO error";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
}
}
public LanguageDependentBean loadLanguageDependentBean() throws FozcilException {
//read LD file properties
String langDependPathInternal =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_HOME_INTERNAL);
if ((langDependPathInternal == null) || (langDependPathInternal.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_HOME_INTERNAL;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String langDependFileName =
appProps.getProperty(Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_FILE);
if ((langDependFileName == null) || (langDependFileName.equals(""))) {
String errMsg = "Missing app property: " +
Constants.APP_PROPERTIES_KEY_BINDING_LANG_DEPEND_FILE;
LOG.error(errMsg);
throw new FozcilException(errMsg, FozcilException.EXCEP_SEVERITY_HIGH);
}
String filePathForStream = langDependPathInternal + langDependFileName;
//parse the LD file
try {
InputStream infilestream = (InputStream)
ToolControlSystem.class.getResource(filePathForStream).openStream();
LanguageDependentContentHandler ch = new
LanguageDependentContentHandler(this.languageDependentBean);
SAXParser parser = XmlFactory.getXmlReader(XmlFactory.SAX_READER);
parser.parse(infilestream, ch);
} catch (IOException ex) {
String errMsg = "Error reading Language Dependent file";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (ParserConfigurationException ex) {
String errMsg = "Parser configuration error";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (SAXException ex) {
String errMsg = "General SAX error";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
}
}
LOG.debug("LanguageDependentData loaded successfully.");
return this.languageDependentBean;
public OzSpecificationBean loadOzSpecificationData(String filePath) throws
FozcilException {
File infile = new File(filePath);
//parse the LD file
try {
178
OzSpecificationContentHandler ch = new
OzSpecificationContentHandler(this.ozSpecificationBean);
SAXParser parser = XmlFactory.getXmlReader(XmlFactory.SAX_READER);
parser.parse(infile, ch);
} catch (IOException ex) {
String errMsg = "Error reading OzSpecification file";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (ParserConfigurationException ex) {
String errMsg = "Parser configuration error";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
} catch (SAXException ex) {
String errMsg = "General SAX error";
LOG.error(errMsg);
throw new FozcilException(errMsg, ex, FozcilException.EXCEP_SEVERITY_MEDIUM);
}
}
LOG.debug("OzSpecificationData loaded successfully.");
return this.ozSpecificationBean;
/**
* @return the languageDependentBean
*/
public OzSpecificationBean getOzSpecificationBean() {
return ozSpecificationBean;
}
}
package edu.csus.fozcil.tool;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
edu.csus.fozcil.bean.LanguageDependentBean;
edu.csus.fozcil.bean.OzOperationBean;
edu.csus.fozcil.bean.OzSpecificationBean;
edu.csus.fozcil.bean.OzVariable;
java.io.File;
java.io.FileNotFoundException;
java.io.IOException;
java.io.PrintWriter;
java.util.ArrayList;
java.util.HashMap;
java.util.HashSet;
java.util.Iterator;
java.util.Stack;
java.util.StringTokenizer;
org.apache.log4j.Logger;
/**
*
* @author GeorgeN
*/
public class OZtoILconverter {
private static Logger LOG = Logger.getLogger(OZtoILconverter.class.getName());
public static final String CLASSINVARIANT_METHOD_NAME = "ClassInvariant";
public static final String DELTA_VARIABLE_PREFIX = "old_";
private enum ConditionType {
Constructor_Post,
Method_Pre,
Method_Post,
Other
}
private enum ReturnStmtBooleanType {
True,
False
}
private OzSpecificationBean ozSpecificationBean;
private LanguageDependentBean ldbean;
private String ilCodePath;
179
private String langDependTemplTokenOpener;
private String langDependTemplTokenCloser;
public OZtoILconverter() {}
public OZtoILconverter(OzSpecificationBean ozSpecificationBean, LanguageDependentBean
ldbean, String ilCodePath,
String langDependTemplTokenOpener, String langDependTemplTokenCloser) {
this.ozSpecificationBean = ozSpecificationBean;
this.ldbean = ldbean;
this.ilCodePath = ilCodePath;
this.langDependTemplTokenOpener = langDependTemplTokenOpener;
this.langDependTemplTokenCloser = langDependTemplTokenCloser;
}
public void convert() throws FileNotFoundException, IOException {
//convert USERTYPE schema(s)
for (OzVariable userType : ozSpecificationBean.getUserDataTypes()) {
File outfileUT = new File(ilCodePath + File.separator +
ozSpecificationBean.getSchemaName() + "." +
userType.getName() + "." + this.ldbean.getLanguageFileExtension());
PrintWriter pwUT = new PrintWriter(outfileUT);
convertUserType(userType,pwUT);
pwUT.flush();
pwUT.close();
}
}
//convert MAIN schema
File outfile = new File(ilCodePath + File.separator +
ozSpecificationBean.getSchemaName() +
"." + this.ldbean.getLanguageFileExtension());
PrintWriter pw = new PrintWriter(outfile);
convertSchema(pw);
pw.flush();
pw.close();
private void convertUserType(OzVariable ozVariable, PrintWriter pw) {
LOG.debug("Processing: " + ozVariable.getName());
String INDENT = "";
StringTokenizer stk = new StringTokenizer(ldbean.getClassTemplate(),
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
while (stk.hasMoreElements()) {
String aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.CLASSTEMPLATE_NAME)) {
pw.write(INDENT + ozVariable.getName());
} else if (aToken.equals(LanguageDependentBean.CLASSTEMPLATE_VISIBILITY)) {
pw.write(INDENT + ozVariable.getVisibility());
} else if (aToken.equals(LanguageDependentBean.CLASSTEMPLATE_BODY)) {
//do nothing
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
if (aToken.equals("\n")) pw.write(INDENT);
}
}
private void convertSchema(PrintWriter pw) {
LOG.debug("Processing: " + ozSpecificationBean.getSchemaName());
String INDENT = "";
StringTokenizer stk = new StringTokenizer(ldbean.getClassTemplate(),
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
while (stk.hasMoreElements()) {
String aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.CLASSTEMPLATE_NAME)) {
pw.write(INDENT + ozSpecificationBean.getSchemaName());
} else if (aToken.equals(LanguageDependentBean.CLASSTEMPLATE_VISIBILITY)) {
pw.write(INDENT + ozSpecificationBean.getSchemaVisibility());
} else if (aToken.equals(LanguageDependentBean.CLASSTEMPLATE_BODY)) {
180
//convert constant type
convertConstantType(pw, INDENT);
//convert free type
convertFreeType(pw, INDENT);
//convert stat variables
convertStateVariables(pw, INDENT);
//convert INIT operation
for (OzOperationBean ozOperationBean :
ozSpecificationBean.getOperations()) {
if
(ozOperationBean.getName().equals(OzSpecificationBean.OZ_INIT_METHOD_NAME)) {
convertInit(ozOperationBean, pw, INDENT);
convertClassInvariant(ozOperationBean, pw, INDENT);
}
}
//convert operations (excluding Init)
for (OzOperationBean ozOperationBean :
ozSpecificationBean.getOperations()) {
if
(ozOperationBean.getName().equals(OzSpecificationBean.OZ_INIT_METHOD_NAME)) {
continue;
} else {
convertMethod(ozOperationBean, pw, INDENT);
}
}
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
if (aToken.equals("\n")) pw.write(INDENT);
}
}
private void convertConstantType(PrintWriter pw, String indent) {
String INDENT = indent + "\t";
HashMap<String, OzVariable> constantTypes =
this.ozSpecificationBean.getConstantDataTypes();
for (OzVariable constantType : constantTypes.values()) {
LOG.debug("Processing: " + constantType.getName());
String varname = "";
//DECLARATION
StringTokenizer stk = new
StringTokenizer(ldbean.getVariableDeclarationTemplate(),
"\n" + this.langDependTemplTokenOpener +
this.langDependTemplTokenCloser, true);
String aToken = "";
pw.write("\n" + INDENT);
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_VISIBILITY)) {
pw.write(constantType.getVisibility());
} else if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_NAME)) {
varname = constantType.getName();
pw.write(varname);
} else if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_TYPE)) {
convertType(constantType.getType(), pw);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
}
//ASSIGNMENT
pw.write(" = " + constantType.getValues().get(0)); //will always be the first
index
pw.write(this.ldbean.getStatementEndSymbol());
}
}
private void convertFreeType(PrintWriter pw, String indent) {
String INDENT = indent + "\t";
HashMap<String, OzVariable> freeTypes =
this.ozSpecificationBean.getFreeDataTypes();
181
for (OzVariable freeType : freeTypes.values()) {
LOG.debug("Processing: " + freeType.getName());
String varname = "";
//DECLARATION
StringTokenizer stk = new StringTokenizer(ldbean.getEnumTemplate(),
"\n" + this.langDependTemplTokenOpener +
this.langDependTemplTokenCloser, true);
String aToken = "";
pw.write("\n" + INDENT);
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.ENUMDECLTEMPLATE_VISIBILITY)) {
pw.write(freeType.getVisibility());
} else if (aToken.equals(LanguageDependentBean.ENUMDECLTEMPLATE_NAME)) {
varname = freeType.getName();
pw.write(varname);
} else if (aToken.equals(LanguageDependentBean.ENUMDECLTEMPLATE_VALUES))
{
String tempStr = "";
for (String value : freeType.getValues()) {
tempStr += value + ldbean.getEnumValueSeparator();
}
tempStr = tempStr.substring(0, tempStr.length()-1);
//trim out the
last separator
pw.write(tempStr);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
}
pw.write(this.ldbean.getStatementEndSymbol());
}
}
private void convertStateVariables(PrintWriter pw, String indent) {
String INDENT = indent + "\t";
HashMap<String, OzVariable> stateVariables =
this.ozSpecificationBean.getStateVariables();
for (OzVariable stateVariable : stateVariables.values()) {
LOG.debug("Processing: " + stateVariable.getName());
//DECLARATION
StringTokenizer stk = new
StringTokenizer(ldbean.getVariableDeclarationTemplate(),
"\n" + this.langDependTemplTokenOpener +
this.langDependTemplTokenCloser, true);
String aToken = "";
pw.write("\n" + INDENT);
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_VISIBILITY)) {
pw.write(stateVariable.getVisibility());
} else if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_NAME)) {
pw.write(stateVariable.getName());
} else if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_TYPE)) {
convertType(stateVariable.getType(), pw);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
}
pw.write(this.ldbean.getStatementEndSymbol());
}
}
private void convertDeltaOutputVariables(String varname, String vartype, PrintWriter
pw, String indent) {
LOG.debug("Processing: " + varname);
String INDENT = indent + "\t";
//DECLARATION
StringTokenizer stk = new
StringTokenizer(ldbean.getVariableDeclarationTemplate(),
182
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
String aToken = "";
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_VISIBILITY)) {
//do nothing
} else if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_NAME)) {
pw.write(DELTA_VARIABLE_PREFIX + varname);
} else if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_TYPE)) {
convertType(vartype, pw);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
}
//now assign value
pw.write(" = ");
if (vartype.startsWith(OzSpecificationBean.OZ_INTRINSIC_TYPE_SET)) {
StringTokenizer stk1 = new StringTokenizer(ldbean.getSetTypeCloneTemplate(),
"\n" + this.langDependTemplTokenOpener +
this.langDependTemplTokenCloser, true);
String aToken1 = "";
while (stk1.hasMoreElements()) {
aToken1 = stk1.nextToken();
if (aToken1.equals(LanguageDependentBean.SETTEMPLATE_NAME1)) {
pw.write(varname);
} else if ((!aToken1.equals(this.langDependTemplTokenOpener)) &&
(!aToken1.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken1);
}
}
} else {
pw.write(varname);
}
}
pw.write(this.ldbean.getStatementEndSymbol());
private void convertMethod(OzOperationBean ozOperationBean, PrintWriter pw, String
indent) {
LOG.debug("Processing: " + ozOperationBean.getName());
String INDENT = indent + "\t";
pw.write("\n\n" + INDENT);
StringTokenizer stk = new StringTokenizer(ldbean.getMethodTemplate(),
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
String aToken = "";
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_VISIBILITY)) {
pw.write(ozOperationBean.getVisibility());
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_RETURNTYPE)) {
String type = ozOperationBean.getReturnType();
convertType(type, pw);
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_NAME)) {
pw.write(ozOperationBean.getName());
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_ARGUMENTS)) {
convertMethodArguments(ozOperationBean, pw);
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_BODY)) {
//DECLARE DELTA OUTPUT VARIABLES
HashMap<String, String> deltaOutputVariables =
getDeltaStateVariables(ozOperationBean);
//..now process each of the identified delta variable
for (String deltaStateName : deltaOutputVariables.keySet()) {
convertDeltaOutputVariables(deltaStateName,
deltaOutputVariables.get(deltaStateName), pw, INDENT);
}
//PRECONDITION
convertPrePostcondition(ConditionType.Method_Pre, ozOperationBean, pw,
INDENT);
//BODY
pw.write("\n\n" + INDENT + "\t");
183
convertPrintComment("Method body goes here", pw, INDENT);
//POSTCONDITION
convertPrePostcondition(ConditionType.Method_Post, ozOperationBean, pw,
INDENT);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
if (aToken.equals("\n")) pw.write(INDENT);
}
}
private void convertInit(OzOperationBean ozOperationBean, PrintWriter pw, String
indent) {
LOG.debug("Processing: " + "INIT");
String INDENT = indent + "\t";
pw.write("\n\n" + INDENT);
StringTokenizer stk = new StringTokenizer(ldbean.getMethodTemplate(),
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
String aToken = "";
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_VISIBILITY)) {
pw.write(ozOperationBean.getVisibility());
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_RETURNTYPE)) {
//do nothing
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_NAME)) {
pw.write(this.ozSpecificationBean.getSchemaName());
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_ARGUMENTS)) {
//do nothing
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_BODY)) {
for (String postcondition : ozOperationBean.getPostconditions()) {
convertExpressions(ConditionType.Other, postcondition, null, pw);
pw.write(this.ldbean.getStatementEndSymbol());
pw.write("\n" + "\t" + INDENT);
}
convertPrePostcondition(ConditionType.Constructor_Post, ozOperationBean,
pw, INDENT);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
if (aToken.equals("\n")) pw.write(INDENT);
}
}
private void convertClassInvariant(OzOperationBean ozOperationBean, PrintWriter pw,
String indent) {
LOG.debug("Processing: " + "ClassInvariant");
String INDENT = indent + "\t";
pw.write("\n\n" + INDENT);
StringTokenizer stk = new StringTokenizer(ldbean.getMethodTemplate(),
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
String aToken = "";
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_VISIBILITY)) {
pw.write(ozOperationBean.getVisibility());
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_RETURNTYPE)) {
pw.write(ldbean.getExtrinsic_type_boolean_equivalent());
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_NAME)) {
pw.write(CLASSINVARIANT_METHOD_NAME);
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_ARGUMENTS)) {
//do nothing
} else if (aToken.equals(LanguageDependentBean.METHODTEMPLATE_BODY)) {
convertClassInvariantBody(ozOperationBean, pw, INDENT);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
if (aToken.equals("\n")) pw.write(INDENT);
}
184
}
private void convertMethodArguments(OzOperationBean ozOperationBean, PrintWriter pw)
{
LOG.debug("Processing: " + "MethodArgs for :" + ozOperationBean.getName());
HashMap<String, String> arguments = ozOperationBean.getArguments();
boolean skipStart = true;
for (String argName : arguments.keySet()) {
LOG.debug("Processing: " + "Arg :" +argName);
if (!skipStart) {
pw.write(this.ldbean.getMethodArgumentSeparator());
}
skipStart = false;
StringTokenizer stk = new
StringTokenizer(ldbean.getVariableDeclarationTemplate(),
"\n" + this.langDependTemplTokenOpener +
this.langDependTemplTokenCloser, true);
String aToken = "";
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_VISIBILITY)) {
//do nothing
} else if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_NAME)) {
pw.write(argName);
} else if (aToken.equals(LanguageDependentBean.VARDECLTEMPLATE_TYPE)) {
String type = arguments.get(argName);
convertType(type, pw);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
}
}
}
private void convertPrePostcondition(ConditionType conditionType, OzOperationBean
ozOperationBean, PrintWriter pw, String indent) {
LOG.debug("Processing: " + "PrePost Condition");
String INDENT = indent + "\t";
pw.write("\n\n" + INDENT);
StringTokenizer stk = new StringTokenizer(ldbean.getIfStatementTemplate(),
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
String aToken = "";
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.IF_STMT_TEMPLATE_CONDITION)) {
//is this PRE or POST
ArrayList<String> prepostConditions = null;
if (conditionType.equals(ConditionType.Method_Pre)) {
LOG.debug("Processing: " + "PRE Condition");
prepostConditions = ozOperationBean.getPreconditions();
} else if (conditionType.equals(ConditionType.Method_Post)) {
LOG.debug("Processing: " + "POST Condition");
prepostConditions = ozOperationBean.getPostconditions();
}
pw.write(ldbean.getIntrinsicOperator_equivalent().get(OzOperationBean.OPERATOR_NOT) +
"("); //open for NOT condition
//call to classinvariant expression
pw.write(CLASSINVARIANT_METHOD_NAME + "()");
// other expressions
if (!conditionType.equals(ConditionType.Constructor_Post)) {
for (String prepostcondExpression: prepostConditions) {
pw.write(" " +
this.ldbean.getIntrinsicOperator_equivalent().get(OzOperationBean.OPERATOR_AND) + " ");
pw.write("(");//open for each expression
convertExpressions(conditionType, prepostcondExpression,
ozOperationBean, pw);
pw.write(")");//close for each expression
}
}
pw.write(")"); //close for NOT condition
} else if (aToken.equals(LanguageDependentBean.IF_STMT_TEMPLATE_BODY)) {
185
if (conditionType.equals(ConditionType.Method_Pre))
convertPrintComment("Precondition failed", pw, INDENT);
else
convertPrintComment("Postcondition failed", pw, INDENT);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
if (aToken.equals("\n")) pw.write(INDENT);
}
}
private void convertClassInvariantBody(OzOperationBean ozOperationBean, PrintWriter
pw, String indent) {
String INDENT = indent + "\t";
pw.write("\n\n" + INDENT);
StringTokenizer stk = new StringTokenizer(ldbean.getIfStatementTemplate(),
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
String aToken = "";
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.IF_STMT_TEMPLATE_CONDITION)) {
ArrayList<String> classInvariants =
this.ozSpecificationBean.getClassInvariants();
boolean skipStart = true;
for (String classInvariant: classInvariants) {
if (!skipStart) {
pw.write(" " +
this.ldbean.getIntrinsicOperator_equivalent().get(OzOperationBean.OPERATOR_AND) + " ");
}
skipStart = false;
pw.write("(");//open for each expression
convertExpressions(ConditionType.Other, classInvariant, null, pw);
pw.write(")");//close for each expression
}
} else if (aToken.equals(LanguageDependentBean.IF_STMT_TEMPLATE_BODY)) {
//return true
convertClassInvariantReturnStmt(ReturnStmtBooleanType.True, pw,
INDENT);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
if (aToken.equals("\n")) pw.write(INDENT);
}
//return false
pw.write("\n\n" + INDENT);
convertPrintComment("ClassInvariant failed", pw, INDENT);
pw.write("\n" + INDENT);
convertClassInvariantReturnStmt(ReturnStmtBooleanType.False, pw, INDENT);
}
private void convertClassInvariantReturnStmt(ReturnStmtBooleanType
returnStmtBooleanType, PrintWriter pw, String indent) {
String INDENT = indent + "\t";
StringTokenizer stk = new StringTokenizer(ldbean.getReturnStatementTemplate(),
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
String aToken = "";
while (stk.hasMoreElements()) {
aToken = stk.nextToken();
if (aToken.equals(this.ldbean.RETURN_STMT_TEMPLATE_EXPRESSION)) {
if (returnStmtBooleanType.equals(ReturnStmtBooleanType.True)) {
pw.write(this.ldbean.getExtrinsic_typeValue_boolean_true_equivalent());
} else {
pw.write(this.ldbean.getExtrinsic_typeValue_boolean_false_equivalent());
}
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
186
}
}
pw.write(this.ldbean.getStatementEndSymbol());
}
private void convertExpressions(ConditionType conditionType, String
precondExpression, OzOperationBean ozOperationBean, PrintWriter pw) {
LOG.debug("Processing: " + precondExpression);
//needed for processing Postcondition expression, to translate the old_state
HashMap<String,String> deltaStateVariables = null;
if (conditionType.equals(ConditionType.Method_Post)) {
deltaStateVariables = getDeltaStateVariables(ozOperationBean);
}
pw.write(convertExprToken(precondExpression, conditionType,
deltaStateVariables));
}
public String convertExprToken(String token, ConditionType conditionType, HashMap
deltaStateVariables) {
String trimtoken = token.trim();
String result = "";
String temp = "",
lexpr = "",
rexpr = "",
operator = "";
//if token is empty, return immediately;
System.out.println("** translating token:" + trimtoken);
if (trimtoken.isEmpty()) return "";
//process the token
StringTokenizer stk = new StringTokenizer(trimtoken, " ", true);
temp = stk.nextToken();
//test whether subexpression
if (temp.equals("(")) {
//if yes, extract the sub-expression
System.out.println("processing sub-expression");
String subexpr = "";
String tail = "";
boolean done = false;
//flag to indicate end of sub-expression extraction
//and begining of tail extraction
//we use stack to keep track of sub-sub-expressions
//basically we have to capture all the sub-sub-expressions within this subexpression
Stack stack = new Stack();
//process one token at a time
while (stk.hasMoreTokens()) {
temp = stk.nextToken();
if ((!done) && (temp.equals("("))) {
//start of sub-sub-expression
stack.push(temp);
subexpr += temp;
} else if ((!done) && (temp.equals(")"))) {
//end of sub-sub-expression
if (!stack.empty()) {
stack.pop();
subexpr += temp;
} else {
done = true;
}
} else if (!done) {
//body of sub-expression
subexpr += temp;
} else {
//tail outside the sub-expression
tail += temp;
}
}
System.out.println("sub-expr:" + subexpr);
System.out.println("tail:" + tail);
//we now translate the sub-expression
187
lexpr = convertExprToken(subexpr, conditionType, deltaStateVariables);
lexpr = "(" + lexpr + ")";
System.out.println("lexpr:" + lexpr);
rexpr = tail.trim();
System.out.println("rexpr:" + rexpr);
} else {
//processing for NON sub-expression
lexpr = temp;
System.out.println("lexpr:" + lexpr);
rexpr = trimtoken.substring(trimtoken.indexOf(lexpr)+lexpr.length()).trim();
lexpr = convertSingleExprToken(lexpr, conditionType, deltaStateVariables);
System.out.println("lexpr (post conversion):" + lexpr);
System.out.println("rexpr:" + rexpr);
}
//if more left
if (!rexpr.isEmpty()) {
//then we know it has to be of form "<oper> <expression>"
StringTokenizer stkRexpr = new StringTokenizer(rexpr, " ", false);
//get the operator
operator = stkRexpr.nextToken();
//translate the Rexpr
String new_rexpr = "";
int countToken = stkRexpr.countTokens(); //REMOVE
//is the last operand in this expression?
if (stkRexpr.countTokens() == 1) {
System.out.println("solitary token");
//accumulate result and end
new_rexpr = stkRexpr.nextToken();
new_rexpr = convertSingleExprToken(new_rexpr, conditionType,
deltaStateVariables);
} else {
//but if !end, extract and translate the Rexpr
String tail = rexpr.substring(rexpr.indexOf(operator)+1);
String new_tail = convertExprToken(tail, conditionType,
deltaStateVariables);
//accumulate result and end
new_rexpr = new_tail;
}
//translate operator
String new_operator = "**UNMAPPED**";
if (!isTranslationNeededOperator(operator)) {
if (this.ldbean.getIntrinsicOperator_equivalent().containsKey(operator))
{
new_operator =
this.ldbean.getIntrinsicOperator_equivalent().get(operator);
}
//assemble the translated expression
result = lexpr + " " + new_operator + " " + new_rexpr;
} else {
String template = getTranslationNeededOperatorTemplate(operator);
result = convertTranslationNeededOperatorTemplate(template, lexpr,
new_rexpr);
}
} else {
result = lexpr;
}
}
System.out.println("result:" + result);
return result;
private String convertSingleExprToken(String variable, ConditionType conditionType,
HashMap deltaStateVariables) {
String convertedVariable = variable;
if (variable.startsWith(OzOperationBean.OPERATOR_SET_CARDINALITY)) {
String variablename = variable.substring(1);
variablename = convertPostConditionDeltaStateVariables(variablename,
conditionType, deltaStateVariables);
String template =
getTranslationNeededOperatorTemplate(OzOperationBean.OPERATOR_SET_CARDINALITY);
188
convertedVariable = convertTranslationNeededOperatorTemplate(template,
variablename, "");
} else if (variable.equals(OzOperationBean.OPERATOR_VALUE_SET_EMPTY)) {
String template =
getTranslationNeededOperatorTemplate(OzOperationBean.OPERATOR_VALUE_SET_EMPTY);
convertedVariable = convertTranslationNeededOperatorTemplate(template,
ldbean.getSetType_equivalent(), "");
} else {
convertedVariable = convertPostConditionDeltaStateVariables(variable,
conditionType, deltaStateVariables);
}
return convertedVariable;
}
private String convertTranslationNeededOperatorTemplate(String template, String
name1, String name2) {
StringBuffer tplOutput = new StringBuffer();
StringTokenizer stkTpl = new StringTokenizer(template,
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
String aToken = "";
while (stkTpl.hasMoreElements()) {
aToken = stkTpl.nextToken();
if (aToken.equals(LanguageDependentBean.SETTEMPLATE_NAME1)) {
tplOutput.append(name1);
} else if (aToken.equals(LanguageDependentBean.OBJCONSTRUCTORTEMPLATE_TYPE))
{
tplOutput.append(name1);
} else if (aToken.equals(LanguageDependentBean.SETTEMPLATE_NAME2)) {
tplOutput.append(name2);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
tplOutput.append(aToken);
}
}
}
return tplOutput.toString();
private String convertPostConditionDeltaStateVariables(String variable, ConditionType
conditionType, HashMap deltaStateVariables) {
String convertedVariable = variable;
if (conditionType.equals(ConditionType.Method_Post)) {
if (deltaStateVariables.containsKey(variable)) {
convertedVariable = DELTA_VARIABLE_PREFIX + variable;
} else if (deltaStateVariables.containsKey(variable.substring(0,
variable.length()-1))) {
convertedVariable = variable.substring(0, variable.length()-1);
}
}
return convertedVariable;
}
private void convertType(String type, PrintWriter pw) {
if (type == null) return;
LOG.debug("Processing: " + type);
if (type.startsWith(OzSpecificationBean.OZ_INTRINSIC_TYPE_SET))
pw.write(this.ldbean.getSetType_equivalent());
else if (type.equals(OzSpecificationBean.OZ_INTRINSIC_TYPE_N))
pw.write(this.ldbean.getIntrinsic_type_N_equivalent());
else if (type.equals(OzSpecificationBean.OZ_INTRINSIC_TYPE_Z))
pw.write(this.ldbean.getIntrinsic_type_Z_equivalent());
else
pw.write(type);
}
private void convertPrintComment(String comment, PrintWriter pw, String indent) {
LOG.debug("Processing: " + comment);
StringTokenizer stk = new StringTokenizer(this.ldbean.getPrintCommentTemplate(),
"\n" + this.langDependTemplTokenOpener + this.langDependTemplTokenCloser,
true);
while (stk.hasMoreElements()) {
189
String aToken = stk.nextToken();
if (aToken.equals(LanguageDependentBean.PRNTCOMMENTTEMPLATE_TEXT)) {
pw.write(comment);
} else if ((!aToken.equals(this.langDependTemplTokenOpener)) &&
(!aToken.equals(this.langDependTemplTokenCloser))) {
pw.write(aToken);
}
}
pw.write(this.ldbean.getStatementEndSymbol());
}
private HashMap<String, String> getDeltaStateVariables(OzOperationBean
ozOperationBean) {
HashMap<String, String> deltaStateVariables = new HashMap<String, String>();
HashSet<String> dsvNames = new HashSet<String>();
for (String stateName : ozOperationBean.getStateModifiers().keySet()) {
if
(ozOperationBean.getStateModifiers().get(stateName).equals(OzSpecificationBean.OZ_STATE_M
ODIFIER_DELTA)) {
dsvNames.add(stateName);
}
}
//..now process each of the identified delta variable
Iterator<String> iterDsv = dsvNames.iterator();
while (iterDsv.hasNext()) {
String dsvName = iterDsv.next();
OzVariable dsv = new OzVariable("**undeclared**");
//..but first we need to identify the DOV's type
if (this.ozSpecificationBean.getConstantDataTypes().containsKey(dsvName))
dsv = this.ozSpecificationBean.getConstantDataTypes().get(dsvName);
else if (this.ozSpecificationBean.getFreeDataTypes().containsKey(dsvName))
dsv = this.ozSpecificationBean.getFreeDataTypes().get(dsvName);
else if (this.ozSpecificationBean.getStateVariables().containsKey(dsvName))
dsv = this.ozSpecificationBean.getStateVariables().get(dsvName);
deltaStateVariables.put(dsvName, dsv.getType());
}
return deltaStateVariables;
}
private boolean isTranslationNeededOperator(String operator) {
boolean result = true;
if (
(operator.equals(OzOperationBean.OPERATOR_ASSIGNMENT)) ||
(operator.equals(OzOperationBean.OPERATOR_PLUS)) ||
(operator.equals(OzOperationBean.OPERATOR_MINUS)) ||
(operator.equals(OzOperationBean.OPERATOR_MULTIPLY)) ||
(operator.equals(OzOperationBean.OPERATOR_DIVIDE)) ||
(operator.equals(OzOperationBean.OPERATOR_EQUAL)) ||
(operator.equals(OzOperationBean.OPERATOR_NOT_EQUAL)) ||
(operator.equals(OzOperationBean.OPERATOR_LESS)) ||
(operator.equals(OzOperationBean.OPERATOR_LESS_EQUAL)) ||
(operator.equals(OzOperationBean.OPERATOR_GREATER)) ||
(operator.equals(OzOperationBean.OPERATOR_GREATER_EQUAL)) ||
(operator.equals(OzOperationBean.OPERATOR_NOT)) ||
(operator.equals(OzOperationBean.OPERATOR_OR)) ||
(operator.equals(OzOperationBean.OPERATOR_AND))
) {
result = false;
}
return result;
}
private String getTranslationNeededOperatorTemplate(String operator) {
String template = "";
String trimOperator = operator.trim();
if (trimOperator.equals(OzOperationBean.OPERATOR_SET_IS_MEMBER_OF)) {
template = this.ldbean.getSetTypeIsMemberOfTemplate();
} else if
(trimOperator.trim().equals(OzOperationBean.OPERATOR_SET_IS_NOT_MEMBER_OF)) {
template = this.ldbean.getSetTypeIsNotMemberOfTemplate();
190
} else if (trimOperator.trim().equals(OzOperationBean.OPERATOR_SET_EQUALS)) {
template = this.ldbean.getSetTypeEqualsTemplate();
} else if (trimOperator.equals(OzOperationBean.OPERATOR_SET_UNION)) {
template = this.ldbean.getSetTypeUnionTemplate();
} else if (trimOperator.equals(OzOperationBean.OPERATOR_SET_INTERSECT)) {
template = this.ldbean.getSetTypeIntersectTemplate();
} else if (trimOperator.equals(OzOperationBean.OPERATOR_SET_CARDINALITY)) {
template = this.ldbean.getSetTypeCardinalityTemplate();
} else if (trimOperator.equals(OzOperationBean.OPERATOR_SET_SUBSET)) {
template = this.ldbean.getSetTypeSubsetTemplate();
} else if (trimOperator.equals(OzOperationBean.OPERATOR_VALUE_SET_EMPTY)) {
template = this.ldbean.getObjectConstructorTemplate();
}
return template;
}
}
package edu.csus.fozcil.tool;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
edu.csus.fozcil.bean.LanguageDependentBean;
edu.csus.fozcil.bean.OzOperationBean;
edu.csus.fozcil.bean.OzSpecificationBean;
edu.csus.fozcil.bean.OzVariable;
java.io.File;
java.io.FileNotFoundException;
java.io.IOException;
java.io.PrintWriter;
java.util.ArrayList;
java.util.HashMap;
java.util.HashSet;
java.util.Iterator;
java.util.Stack;
java.util.StringTokenizer;
org.apache.log4j.Logger;
/**
*
* @author GeorgeN
*/
public class OZtoDocConverter {
private static Logger LOG = Logger.getLogger(OZtoDocConverter.class.getName());
public static final String ENUM_ASSIGNMENT = "\u2254";
private OzSpecificationBean ozSpecificationBean;
private String ilCodePath;
public OZtoDocConverter() {}
public OZtoDocConverter(OzSpecificationBean ozSpecificationBean,
{
String ilCodePath)
this.ozSpecificationBean = ozSpecificationBean;
this.ilCodePath = ilCodePath;
}
public void convert() throws FileNotFoundException, IOException {
File outfile = new File(ilCodePath + File.separator +
ozSpecificationBean.getSchemaName() +
"." + "fozcil.txt");
PrintWriter pw = new PrintWriter(outfile);
String temp = "";
pw.write("Class Schema Name:\n\n");
pw.write("\t" + ozSpecificationBean.getSchemaName() + "\n");
pw.write("\n");
pw.write("User Type:\n\n");
pw.write("\t" + "[");
Iterator<OzVariable> iter = ozSpecificationBean.getUserDataTypes().iterator();
temp = "";
while (iter.hasNext()) {
OzVariable ozvar = iter.next();
191
temp += ozvar.getName() + ",";
}
if (temp.length() > 0)
temp = temp.substring(0, temp.length()-1);
pw.write(temp + "]" + "\n");
pw.write("\n");
//trim out the last separator
pw.write("Free Type:\n\n");
for (OzVariable ozvar : ozSpecificationBean.getFreeDataTypes().values()) {
pw.write("\t" + ozvar.getName());
pw.write(" := ");
temp = "";
for (String value : ozvar.getValues()) {
temp += value;
temp += MainToolJFrame.SEP_VALUE_VALUE;
}
temp = temp.substring(0, temp.length()-1);
//trim out the last separator
pw.write(temp + "\n");
}
pw.write("\n");
pw.write("Constant Type:\n\n");
for (OzVariable ozvar : ozSpecificationBean.getConstantDataTypes().values()) {
pw.write("\t" + "| " + ozvar.getName() + " : " + ozvar.getType() + "\n");
}
pw.write("\t" + "|-----------------------------------------" + "\n");
for (OzVariable ozvar : ozSpecificationBean.getConstantDataTypes().values()) {
pw.write("\t" + "| " + ozvar.getName() + " = " + ozvar.getValues().get(0) +
"\n");
}
pw.write("\n");
pw.write("State Variable:\n\n");
pw.write("\t" + "|-----------------------------------------" + "\n");
for (OzVariable ozvar : ozSpecificationBean.getStateVariables().values()) {
pw.write("\t" + "| " + ozvar.getName() + " : " + ozvar.getType() + "\n");
}
pw.write("\t" + "|-----------------------------------------" + "\n");
for (String ci : ozSpecificationBean.getClassInvariants()) {
pw.write("\t" + "| Pre: ");
StringTokenizer stk = new StringTokenizer(ci, " ", true);
while (stk.hasMoreTokens()) {
String token = stk.nextToken();
if (isNeedsTranslationOperator(token)) {
pw.write(translateOperator(token));
} else {
pw.write(token);
}
}
pw.write("\n");
}
pw.write("\t" + "|-----------------------------------------" + "\n");
pw.write("\n");
pw.write("INIT (constructor):\n\n");
pw.write("\t" + "|-----------INIT--------------------------" + "\n");
OzOperationBean initoper = findOperation(OzSpecificationBean.OZ_INIT_METHOD_NAME,
ozSpecificationBean.getOperations());
for (String cond : initoper.getPostconditions()) {
pw.write("\t" + "| Pre: ");
StringTokenizer stk = new StringTokenizer(cond, " ", true);
while (stk.hasMoreTokens()) {
String token = stk.nextToken();
if (isNeedsTranslationOperator(token)) {
pw.write(translateOperator(token));
} else {
pw.write(token);
}
}
pw.write("\n");
}
pw.write("\t" + "|-----------------------------------------" + "\n");
pw.write("\n");
192
pw.write("Operation Schema(s):\n\n");
for (OzOperationBean ozoper : ozSpecificationBean.getOperations()) {
if (ozoper.getName().equals(OzSpecificationBean.OZ_INIT_METHOD_NAME))
continue;
pw.write("\t" + "|-----------" + ozoper.getName() + "-----------------------"
+ "\n");
pw.write("\t" + "| " + "\n");
for (String stateName : ozoper.getStateModifiers().keySet()) {
pw.write("\t" + "| " + ozoper.getStateModifiers().get(stateName) + " (" +
stateName + ")" + "\n");
}
for (String argName : ozoper.getArguments().keySet()) {
pw.write("\t" + "| " + argName + " : " +
ozoper.getArguments().get(argName) + "\n");
}
pw.write("\t" + "|-----------------------------------------" + "\n");
for (String cond : ozoper.getPreconditions()) {
pw.write("\t" + "| Pre: ");
StringTokenizer stk = new StringTokenizer(cond, " ", true);
while (stk.hasMoreTokens()) {
String token = stk.nextToken();
if (isNeedsTranslationOperator(token)) {
pw.write(translateOperator(token));
} else {
pw.write(token);
}
}
pw.write("\n");
}
for (String cond : ozoper.getPostconditions()) {
pw.write("\t" + "| Pre: ");
StringTokenizer stk = new StringTokenizer(cond, " ", true);
while (stk.hasMoreTokens()) {
String token = stk.nextToken();
if (isNeedsTranslationOperator(token)) {
pw.write(translateOperator(token));
} else {
pw.write(token);
}
}
pw.write("\n");
}
pw.write("\t" + "|-----------------------------------------" + "\n");
pw.write("\n");
}
pw.flush();
pw.close();
}
private OzOperationBean findOperation(String operName, HashSet<OzOperationBean>
operations) {
OzOperationBean foundOperation = null;
}
for (OzOperationBean ozOperationBean : operations) {
if (ozOperationBean.getName().equals(operName)) {
foundOperation = ozOperationBean;
break;
}
}
return foundOperation;
private boolean isNeedsTranslationOperator(String token) {
if (
token.equals(OzOperationBean.OPERATOR_ASSIGNMENT) ||
token.equals(OzOperationBean.OPERATOR_NOT_EQUAL) ||
token.equals(OzOperationBean.OPERATOR_LESS_EQUAL) ||
token.equals(OzOperationBean.OPERATOR_GREATER_EQUAL) ||
token.equals(OzOperationBean.OPERATOR_NOT) ||
token.equals(OzOperationBean.OPERATOR_OR) ||
token.equals(OzOperationBean.OPERATOR_AND) ||
token.equals(OzOperationBean.OPERATOR_VALUE_SET_EMPTY) ||
193
token.equals(OzOperationBean.OPERATOR_SET_IS_MEMBER_OF) ||
token.equals(OzOperationBean.OPERATOR_SET_IS_NOT_MEMBER_OF) ||
token.equals(OzOperationBean.OPERATOR_SET_EQUALS) ||
token.equals(OzOperationBean.OPERATOR_SET_UNION) ||
token.equals(OzOperationBean.OPERATOR_SET_INTERSECT) ||
token.equals(OzOperationBean.OPERATOR_SET_SUBSET)
)
{
return true;
}
return false;
}
private String translateOperator(String oper) {
if (oper.equals(OzOperationBean.OPERATOR_ASSIGNMENT))
return "(=)";
else if (oper.equals(OzOperationBean.OPERATOR_NOT_EQUAL))
return "(<>)";
else if (oper.equals(OzOperationBean.OPERATOR_LESS_EQUAL))
return "(<=)";
else if (oper.equals(OzOperationBean.OPERATOR_GREATER_EQUAL))
return "(>=)";
else if (oper.equals(OzOperationBean.OPERATOR_NOT))
return "(not)";
else if (oper.equals(OzOperationBean.OPERATOR_OR))
return "(or)";
else if (oper.equals(OzOperationBean.OPERATOR_AND))
return "(and)";
else if (oper.equals(OzOperationBean.OPERATOR_VALUE_SET_EMPTY))
return "{}";
else if (oper.equals(OzOperationBean.OPERATOR_SET_IS_MEMBER_OF))
return "(IsMemberOf)";
else if (oper.equals(OzOperationBean.OPERATOR_SET_IS_NOT_MEMBER_OF))
return "(IsNotMemberOf)";
else if (oper.equals(OzOperationBean.OPERATOR_SET_EQUALS))
return "(=)";
else if (oper.equals(OzOperationBean.OPERATOR_SET_UNION))
return "(Union)";
else if (oper.equals(OzOperationBean.OPERATOR_SET_INTERSECT))
return "(Intersect)";
else if (oper.equals(OzOperationBean.OPERATOR_SET_SUBSET))
return "(SubsetOf)";
return "**unmapped**";
}
}
package edu.csus.fozcil.tool;
import
import
import
import
import
import
import
import
import
import
import
import
edu.csus.fozcil.framework.*;
edu.csus.fozcil.bean.LanguageDependentBean;
edu.csus.fozcil.bean.OzOperationBean;
edu.csus.fozcil.bean.OzSpecificationBean;
edu.csus.fozcil.bean.OzVariable;
java.util.ArrayList;
java.util.HashMap;
java.util.HashSet;
org.apache.log4j.Logger;
org.xml.sax.Attributes;
org.xml.sax.SAXException;
org.xml.sax.helpers.DefaultHandler;
/**
* @author GeorgeN
*/
public class OzSpecificationContentHandler extends DefaultHandler {
private static Logger LOG =
Logger.getLogger(OzSpecificationContentHandler.class.getName());
OzSpecificationBean ozbean = null;
StringBuffer content_buffer = null;
194
OzVariable ozvar;
OzOperationBean ozoper;
String name = "";
public OzSpecificationContentHandler(OzSpecificationBean ozbean) {
super();
this.ozbean = ozbean;
}
@Override
public void startElement(String namespaceURI, String localName, String
qualifiedName, Attributes atts) throws SAXException {
LOG.debug("OzSpecificationContentHandler>startElement - " + qualifiedName);
if (qualifiedName.equals("userDataType")) {
ozvar = new OzVariable("");
} else if (qualifiedName.equals("constantDataType")) {
ozvar = new OzVariable("");
} else if (qualifiedName.equals("freeDataType")) {
ozvar = new OzVariable("");
} else if (qualifiedName.equals("stateVariable")) {
ozvar = new OzVariable("");
} else if (qualifiedName.equals("operation")) {
ozoper = new OzOperationBean();
} else {
//initialize new buffer to handle characters
content_buffer = new StringBuffer();
}
}
@Override
public void endElement(String namespaceURI, String localName, String qualifiedName)
throws SAXException {
LOG.debug("OzSpecificationContentHandler>endElement - " + qualifiedName);
//take action as necessary
if (qualifiedName.equals("schemaName")) {
ozbean.setSchemaName(content_buffer.toString());
} else if (qualifiedName.equals("schemaVisibility")) {
ozbean.setSchemaVisibility(content_buffer.toString());
} else if (qualifiedName.equals("userDataType")) {
ozbean.addUserDataType(this.ozvar);
} else if (qualifiedName.equals("userDataTypeName")) {
this.ozvar.setName(content_buffer.toString());
} else if (qualifiedName.equals("userDataTypeVisibility")) {
this.ozvar.setVisibility(content_buffer.toString());
} else if (qualifiedName.equals("constantDataType")) {
ozbean.addConstantDataType(this.ozvar);
} else if (qualifiedName.equals("constantDataTypeName")) {
this.ozvar.setName(content_buffer.toString());
} else if (qualifiedName.equals("constantDataTypeVisibility")) {
this.ozvar.setVisibility(content_buffer.toString());
} else if (qualifiedName.equals("constantDataTypeType")) {
this.ozvar.setType(content_buffer.toString());
} else if (qualifiedName.equals("constantDataTypeValue")) {
this.ozvar.addValue(content_buffer.toString());
} else if (qualifiedName.equals("freeDataType")) {
ozbean.addFreeDataType(this.ozvar);
} else if (qualifiedName.equals("freeDataTypeName")) {
this.ozvar.setName(content_buffer.toString());
} else if (qualifiedName.equals("freeDataTypeVisibility")) {
this.ozvar.setVisibility(content_buffer.toString());
} else if (qualifiedName.equals("freeDataTypeValue")) {
this.ozvar.addValue(content_buffer.toString());
} else if (qualifiedName.equals("stateVariable")) {
ozbean.addStateVariable(this.ozvar);
} else if (qualifiedName.equals("stateVariableName")) {
this.ozvar.setName(content_buffer.toString());
} else if (qualifiedName.equals("stateVariableVisibility")) {
this.ozvar.setVisibility(content_buffer.toString());
} else if (qualifiedName.equals("stateVariableType")) {
this.ozvar.setType(content_buffer.toString());
} else if (qualifiedName.equals("invariant")) {
ozbean.addClassInvariant(content_buffer.toString());
} else if (qualifiedName.equals("operationName")) {
195
ozoper.setName(content_buffer.toString());
} else if (qualifiedName.equals("operationVisibility")) {
ozoper.setVisibility(content_buffer.toString());
} else if (qualifiedName.equals("operationStateModifierName")) {
name = content_buffer.toString();
} else if (qualifiedName.equals("operationStateModifierType")) {
ozoper.addStateModifier(name, content_buffer.toString());
} else if (qualifiedName.equals("operationArgumentName")) {
name = content_buffer.toString();
} else if (qualifiedName.equals("operationArgumentType")) {
ozoper.addArgument(name, content_buffer.toString());
} else if (qualifiedName.equals("operationPrecondition")) {
ozoper.addPrecondition(content_buffer.toString());
} else if (qualifiedName.equals("operationPostcondition")) {
ozoper.addPostcondition(content_buffer.toString());
} else if (qualifiedName.equals("operation")) {
ozbean.addOperation(ozoper);
}
//reset the buffer
content_buffer = null;
}
@Override
public void characters(char[] text, int start, int length) throws SAXException {
//LOG.debug("LanguageDependentrContentHandler>characters - " + new
String(text, start, length));
//logic to handle split content
if (content_buffer != null) {
content_buffer.append(text, start, length);
}
}
}
package edu.csus.fozcil.tool;
import
import
import
import
import
edu.csus.fozcil.bean.OzOperationBean;
edu.csus.fozcil.bean.OzSpecificationBean;
edu.csus.fozcil.bean.OzVariable;
javax.xml.parsers.DocumentBuilder;
javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author GeorgeN
*/
public class OzSpecificationDomBuilder {
public static Document buildDocument(OzSpecificationBean ozsbean) {
Document doc = null;
Element root, item, subitem, sub2item, sub3item, sub4item;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.newDocument();
root = doc.createElementNS(null, "OzSpecification"); // Create Root Element
doc.appendChild( root );
//schema
item = doc.createElementNS(null, "schemaName");
item.appendChild(doc.createTextNode(ozsbean.getSchemaName()) );
root.appendChild(item );
item = doc.createElementNS(null, "schemaVisibility");
item.appendChild(doc.createTextNode(ozsbean.getSchemaVisibility()) );
196
root.appendChild(item );
);
//user type
item = doc.createElementNS(null, "userDataTypes");
if (ozsbean.getUserDataTypes().size() > 0) {
for (OzVariable userDataType : ozsbean.getUserDataTypes()) {
subitem = doc.createElementNS(null, "userDataType");
item.appendChild(subitem);
sub2item = doc.createElementNS(null, "userDataTypeName");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(userDataType.getName()) );
sub2item = doc.createElementNS(null, "userDataTypeVisibility");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(userDataType.getVisibility())
}
}
root.appendChild(item );
//constant type
item = doc.createElementNS(null, "constantDataTypes");
if (ozsbean.getConstantDataTypes().size() > 0) {
for (String key : ozsbean.getConstantDataTypes().keySet()) {
OzVariable constDataType = ozsbean.getConstantDataTypes().get(key);
subitem = doc.createElementNS(null, "constantDataType");
item.appendChild(subitem);
sub2item = doc.createElementNS(null, "constantDataTypeName");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(constDataType.getName()) );
sub2item = doc.createElementNS(null, "constantDataTypeVisibility");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(constDataType.getVisibility()) );
sub2item = doc.createElementNS(null, "constantDataTypeType");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(constDataType.getType()) );
if (constDataType.getValues().size() > 0) {
sub2item = doc.createElementNS(null, "constantDataTypeValues");
subitem.appendChild(sub2item);
for (String value : constDataType.getValues()) {
sub3item = doc.createElementNS(null,
"constantDataTypeValue");
sub2item.appendChild(sub3item);
sub3item.appendChild(doc.createTextNode(value) );
}
}
}
}
root.appendChild(item );
//free type
item = doc.createElementNS(null, "freeDataTypes");
if (ozsbean.getFreeDataTypes().size() > 0) {
for (String key : ozsbean.getFreeDataTypes().keySet()) {
OzVariable freeDataType = ozsbean.getFreeDataTypes().get(key);
subitem = doc.createElementNS(null, "freeDataType");
item.appendChild(subitem);
sub2item = doc.createElementNS(null, "freeDataTypeName");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(freeDataType.getName()) );
sub2item = doc.createElementNS(null, "freeDataTypeVisibility");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(freeDataType.getVisibility())
);
if (freeDataType.getValues().size() > 0) {
sub2item = doc.createElementNS(null, "freeDataTypeValues");
subitem.appendChild(sub2item);
for (String value : freeDataType.getValues()) {
sub3item = doc.createElementNS(null, "freeDataTypeValue");
sub2item.appendChild(sub3item);
sub3item.appendChild(doc.createTextNode(value) );
}
}
}
197
}
root.appendChild(item );
//state variables
item = doc.createElementNS(null, "stateVariables");
if (ozsbean.getStateVariables().size() > 0) {
for (String key : ozsbean.getStateVariables().keySet()) {
OzVariable stateVariable = ozsbean.getStateVariables().get(key);
subitem = doc.createElementNS(null, "stateVariable");
item.appendChild(subitem);
sub2item = doc.createElementNS(null, "stateVariableName");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(stateVariable.getName()) );
sub2item = doc.createElementNS(null, "stateVariableVisibility");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(stateVariable.getVisibility()) );
sub2item = doc.createElementNS(null, "stateVariableType");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(stateVariable.getType()) );
}
}
root.appendChild(item );
//invariants
item = doc.createElementNS(null, "invariants");
if (ozsbean.getClassInvariants().size() > 0) {
for (String classInvariant : ozsbean.getClassInvariants()) {
subitem = doc.createElementNS(null, "invariant");
item.appendChild(subitem);
subitem.appendChild(doc.createCDATASection(classInvariant) );
}
}
root.appendChild(item );
//operations including INIT
item = doc.createElementNS(null, "operations");
if (ozsbean.getOperations().size() > 0) {
for (OzOperationBean ozOper : ozsbean.getOperations()) {
subitem = doc.createElementNS(null, "operation");
item.appendChild(subitem);
sub2item = doc.createElementNS(null, "operationName");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(ozOper.getName()) );
sub2item = doc.createElementNS(null, "operationVisibility");
subitem.appendChild(sub2item);
sub2item.appendChild(doc.createTextNode(ozOper.getVisibility()) );
sub2item = doc.createElementNS(null, "operationStateModifiers");
subitem.appendChild(sub2item);
for (String key : ozOper.getStateModifiers().keySet()) {
sub3item = doc.createElementNS(null, "operationStateModifier");
sub2item.appendChild(sub3item);
sub4item = doc.createElementNS(null,
"operationStateModifierName");
sub3item.appendChild(sub4item);
sub4item.appendChild(doc.createTextNode(key) );
sub4item = doc.createElementNS(null,
"operationStateModifierType");
sub3item.appendChild(sub4item);
sub4item.appendChild(doc.createTextNode(ozOper.getStateModifiers().get(key)));
}
sub2item = doc.createElementNS(null, "operationArguments");
subitem.appendChild(sub2item);
for (String key : ozOper.getArguments().keySet()) {
sub3item = doc.createElementNS(null, "operationArgument");
sub2item.appendChild(sub3item);
sub4item = doc.createElementNS(null, "operationArgumentName");
sub3item.appendChild(sub4item);
sub4item.appendChild(doc.createTextNode(key) );
sub4item = doc.createElementNS(null, "operationArgumentType");
sub3item.appendChild(sub4item);
sub4item.appendChild(doc.createTextNode(ozOper.getArguments().get(key)));
198
}
sub2item = doc.createElementNS(null, "operationPreconditions");
subitem.appendChild(sub2item);
for (String precondition : ozOper.getPreconditions()) {
sub3item = doc.createElementNS(null, "operationPrecondition");
sub2item.appendChild(sub3item);
sub3item.appendChild(doc.createCDATASection(precondition) );
}
sub2item = doc.createElementNS(null, "operationPostconditions");
subitem.appendChild(sub2item);
for (String postcondition : ozOper.getPostconditions()) {
sub3item = doc.createElementNS(null, "operationPostcondition");
sub2item.appendChild(sub3item);
sub3item.appendChild(doc.createCDATASection(postcondition) );
}
}
}
root.appendChild(item );
} catch ( Exception ex ) {
ex.printStackTrace();
}
return doc;
}
}
package edu.csus.fozcil.validator;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* This class handles most of the details of validating a component, including
* all display elements such as popup help boxes and color changes.
*
* @author Michael Urban
* @version Beta 1
* @see WantsValidationStatus
*/
public abstract class AbstractValidator extends InputVerifier implements KeyListener {
private JDialog popup;
private Object parent;
private JLabel messageLabel;
private JLabel image;
private Point point;
private Dimension cDim;
private Color color;
private AbstractValidator() {
color = new Color(243, 255, 159);
}
private AbstractValidator(JComponent c, String message) {
this();
c.addKeyListener(this);
messageLabel = new JLabel(message + " ");
image = new JLabel(new ImageIcon("exception_16x16.png"));
}
/**
* @param parent A JDialog that implements the ValidationCapable interface.
* @param c The JComponent to be validated.
* @param message A message to be displayed in the popup help tip if validation
fails.
*/
public AbstractValidator (JDialog parent, JComponent c, String message) {
this(c, message);
this.parent = parent;
popup = new JDialog(parent);
initComponents();
199
}
/**
* @param parent A JFrame that implements the ValidationCapable interface.
* @param c The JComponent to be validated.
* @param message A message to be displayed in the popup help tip if validation
fails.
*/
public AbstractValidator (JFrame parent, JComponent c, String message) {
this(c, message);
this.parent = parent;
popup = new JDialog(parent);
initComponents();
}
/**
* Implement the actual validation logic in this method. The method should
* return false if data is invalid and true if it is valid. It is also possible
* to set the popup message text with setMessage() before returning, and thus
* customize the message text for different types of validation problems.
*
* @param c The JComponent to be validated.
* @return false if data is invalid. true if it is valid.
*/
protected abstract boolean validationCriteria(JComponent c);
/**
* This method is called by Java when a component needs to be validated.
* It should not be called directly. Do not override this method unless
* you really want to change validation behavior. Implement
* validationCriteria() instead.
*/
public boolean verify(JComponent c) {
if (!validationCriteria(c)) {
if(parent instanceof WantsValidationStatus)
((WantsValidationStatus)parent).validateFailed();
c.setBackground(Color.PINK);
popup.setSize(0, 0);
popup.setLocationRelativeTo(c);
point = popup.getLocation();
cDim = c.getSize();
popup.setLocation(point.x-(int)cDim.getWidth()/2,
point.y+(int)cDim.getHeight()/2);
popup.pack();
popup.setVisible(true);
return false;
}
c.setBackground(Color.WHITE);
if(parent instanceof WantsValidationStatus)
((WantsValidationStatus)parent).validatePassed();
return true;
}
/**
* Changes the message that appears in the popup help tip when a component's
* data is invalid. Subclasses can use this to provide context sensitive help
* depending on what the user did wrong.
*
* @param message
*/
protected void setMessage(String message) {
messageLabel.setText(message);
}
200
/**
* @see KeyListener
*/
public void keyPressed(KeyEvent e) {
popup.setVisible(false);
}
/**
* @see KeyListener
*/
public void keyTyped(KeyEvent e) {}
/**
* @see KeyListener
*/
public void keyReleased(KeyEvent e) {}
private void initComponents() {
popup.getContentPane().setLayout(new FlowLayout());
popup.setUndecorated(true);
popup.getContentPane().setBackground(color);
popup.getContentPane().add(image);
popup.getContentPane().add(messageLabel);
popup.setFocusableWindowState(false);
}
}
package edu.csus.fozcil.validator;
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.JFrame;
/**
* A class for performing basic validation on text fields. All it does is make
* sure that they are not null.
*
* @author Michael Urban
*/
public class NotEmptyValidator extends AbstractValidator {
public NotEmptyValidator(JFrame parent, JTextField c, String message) {
super(parent, c, message);
}
protected boolean validationCriteria(JComponent c) {
if (((JTextField)c).getText().equals(""))
return false;
return true;
}
}
201
REFERENCES
[1]
Wikipedia Contributors. (November 2009). “Formal language”. Wikipedia, The
Free Encyclopedia. [Online]. Available:
http://en.wikipedia.org/wiki/Formal_language
[2]
Bertrand Meyer, Object-Oriented Software Construction, Prentice Hall, 1997.
[3]
Sowmiya Ramkarthik, Cui Zhang. (2006). “Generating Java Skeletal Code with
Design Contracts from Specifications in a Subset of Object Z”, 5th IEEE/ACIS
International Conference on Computer and Information Sciences (ICIS 2006).
[Online]. pp. 405-411, Available
http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=1652025
[4]
Sherri Sanders and Cui Zhang. (2008). “Object-Z to Java/Perl”: A Conversion from
Object-Z to Executable Skeletal Code with Dynamically Checkable Design
Contracts”, Proceedings of the 2008 International Conference on Software
Engineering and Knowledge Engineering. pp. 824-829, San Francisco.
[5]
Graeme Smith, The Object-Z Specification Language. Kluwer Academic
Publishers, 2000.
[6]
Wikipedia Contributors. (November 2009). “Software framework”. Wikipedia, The
Free Encyclopedia. [Online]. Available:
http://en.wikipedia.org/wiki/Software_framework
[7]
Bertrand Meyer. Eiffel: The Language. Prentice Hall, 1992.
[8]
Andrew Harry, Formal Methods Fact File, VDM and Z. John Wilet & Sons, 1996.
[9]
Wikipedia Contributors. (November 2009). “Hoare logic”. Wikipedia, The Free
Encyclopedia. [Online]. Available: http://en.wikipedia.org/wiki/Hoare_logic
[10] B. Lampson W. J. J. Horning, R. L. London, J. G. Mitchell, and G.L. Popek,
“Report on the Programming Language Euclid,” SIGPLAN Notice, vol. 12, number
2, pp. 1-79, 1977.
[11] M. Shaw, Alphard: Form and Content. New York: Springer-Verlag, 1981.
[12] D. Luckham and F. W. von Henke, “An Overview of Anna, A Specification
Language for Ada.” IEEE Software, vol. 2, number 2, pp. 9-22, 1985.
202
[13] “Contracts.” Digital Mars: The D Programming Language, March 28, 2003,
http://www.digitalmars.com/d/dbc.html
[14] Rachel Henne-Wu, William Mitchell, Cui Zhang. (September-October 2004).
“Support for Design by Contract in the C# Programming Language”. Journal of
Object Technology, vol. 4, no. 7. [Online]. pp. 65-82. Available:
http://www.jot.fm/issues/issue_2005_09/article2
[15] Kevin McFarlane, “Design by Contract Framework,” The Code Project, July 13,
2002, http://www.codeproject.com/csharp/designbycontract.asp
[16] Reto Kramer, “iContract – The Java™ Design by Contract™ Tool,” Proceedings of
Technology of Object-Oriented Languages, TOOLS 26, IEEE Computer Society,
1998, http://www.reliable-systems.com/tools
[17] Reinhold Plosh, “Evaluation of Assertion Support for the Java Programming
Language.” Journal of Object Technology, vol. 1, no. 3, special issue: TOOLS USA
2002 proceedings, pp. 5-17, August, 2002,
http://www.jot.fm/issues/issue_2002_08/article1
[18] “Design by Contract™ for Java™ Using JMSAssert™,”
http://www.mmsindia.com/DBCForJava.html
[19] W. Pree, "Meta Patterns-A Means For Capturing the Essentials of Reusable ObjectOriented Design", Proceedings of the 8th European Conference on Object-Oriented
Programming, Springer-Verlag, pp. 150-162, 1994.
[20] Wikipedia Contributors. (November 2009). “Model Java Platform, Standard
Edition”. Wikipedia, The Free Encyclopedia. [Online]. Available:
http://en.wikipedia.org/wiki/Java_Platform,_Standard_Edition
[21] Wikipedia Contributors. (November 2009). “Model View Controller”. Wikipedia,
The Free Encyclopedia. [Online]. Available:
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
[22] Wikipedia Contributors. (November 2009). “Apache ANT”. Wikipedia, The Free
Encyclopedia. [Online]. Available: http://en.wikipedia.org/wiki/Apache_Ant
[23] Michael Urban, “Building a Swing Validation Package with InputVerifier“.
[Online]. Available: http://www.javalobby.org/java/forums/t20551.html
[24] Wikipedia Contributors. (November 2009). “Log4J”. Wikipedia, The Free
Encyclopedia. [Online]. Available: http://en.wikipedia.org/wiki/Log4j
203
[25] Wikipedia Contributors. (November 2009). “ANTLR”. Wikipedia, The Free
Encyclopedia. [Online]. Available: http://en.wikipedia.org/wiki/ANTLR
Download