|
Letzte
Bearbeitung dieses Dokuments: |
Code
Erklärungen
und Anwendungsbeispiele
Verwandte
Dokumentation
package
js_base.xml;
/*
*
de:
* Packages mit den Klassen für die Bearbeitung von
verschiedenen GUI-Elementen.
* en:
* Packages
with the classes to manipulate GUI-Elements. */
import
java.awt.*;
import
javax.swing.*;
import
javax.swing.border.*;
import
javax.swing.event.*;
import
javax.swing.table.*;
/*
*
de:
* Packages mit den Klassen für weitere Java-Funktionalität.
* en:
* Packages
with the classes for additional Java-functionality. */
import
java.math.*;
import
java.util.*;
/*
*
de:
* Package mit den Klassen für das Bearbeiten von XML-Strukturen.
* en:
* Package
with the classes to process XML-structures. */
import
org.jdom.*;
/*
*
de:
* Package mit den JavaScout BasisSystem-Klassen für das Verarbeiten von GUI-Elemente.
* en:
* Package
with the JavaScout BaseSystem-classes to process GUI-Elements. */
import
js_base.frame.*;
/*
*
de:
* Basisklasse mit Parametern für das JavaScout Fat-Client-Framework.
* en:
* Base-class with parameters for the JavaScout Fat-Client-Framework. */
import
js_base.structures.JSBS_UniversalParameters;
/*
*
de:
* Basisklasse mit Methoden zum Umwandeln numerischen Variablen in Zeichenketten.
* en:
* Base-class with methods to convert numeric variables into strings. */
import
js_base.utilities.JSBS_Formatter;
/**
*
* @author kurt(at)javascout[dot]biz
* @date
2006-05-19
*
* @description
* de:
*
Klasse mit spezialisierten Methoden zum Bearbeiten von
GUI-Elementen
* (mit Ausnahme von JButtons).
*
Diese Klasse erbt die Methoden zum Lesen einer Datei mit
einer
* XML-Struktur
von
JSBS_XML_Base.
* en:
* Class with
specialized methods for processing GUI-elements (except
JButton).
* This class inherits JSBS_XML_Base and
uses its methods to read a file
* containing a
XML-structure.
*
* @change-log
*
when who why
*
--------------------------------------------------------
*
2008-05-18 KG Constructor with a FileName as
Parameter
*
2010-05-12 KG Constructor with Start-Frame
* Major rework of processJTable
*
*/
public
class
JSBS_XML_DisplayStrings
extends
JSBS_XML_Base
{
/*
*
-------------------------------
* de:
* CONSTRUCTOR
der Klasse
* Parameter ist die Struktur mit den
Universal-Parametern. Diese Struktur enthält
* die als
Standard festgelegten Namen für das Verzeichnis und die Datei
mit der
* XML-Struktur, die die Sprach-spezifischen
Text-Elemente und Formatierungs-
* Informationen
festlegt.
* en:
*
CONSTRUCTOR of the class
* Parameter is the structure with
the Universal-Parameters. This structure contains
* the
standard-directory- and file-name where the XML-structure with the
*
language-dependant text-elements and the formatting-specifications.
*/
public
JSBS_XML_DisplayStrings(JSBS_StartFrame parmCC) {
/*
de: Code der geerbten Klasse ausführen.
* en: Perform
the code in the constructor of the inherited class.
*/
super
(parmCC);
/*
de:
* Verzeichnis- und Datei-Namen aus den Werten in den
Universal-Parametern
* zusammensetzen. Diese geben die
Standard-Werte an, wo die Datei mit der
* XML-Struktur zu
finden ist.
* en:
* Get the filename for the
XML-structure with the language dependant display-strings.
* This
is done by concatenating the directory with the language dependant
files
* and the filename for the file with the
XML-structure. */
String
locstrFileName
=
parmCC.structJSBS_UniversalParameters.
strTextElementsDirectoryName
+
JSBS_UniversalParameters.
CONST_DISPLAYSTRINGS_FILE_NAME
;
/*
de:
* Lesen des RootElement der XML-Struktur.
* Die
Methode dazu ist in der Superklasse (die geerbte Klasse)
enthalten.
* en:
* Read the RootElement (method
implemented in the superclass -
* i.e. the class
inherited). */
readXMLFile(locstrFileName);
/*
de:
* Wenn das Lesen der XML-Struktur fehlerfrei beendet
wurde dann werden die
* Farb-Informationen für die
verschiedenen Arten von Rändern
verschiedener
* GUI-Elemente (Borders) aus der
XML-Struktur gelesen und die gebildeten
* Informationen für
die Border in die entsprechenden
Variablen
der
* Struktur JSBS_UniversalParameters übertragen.
*
en:
* If
the read of the XML-structure was error-free, then the border-colors
are read
* out of the XML-structure and the borders
hold within the JSBS_UniversalParameters
* are
created. */
if
(
StatusCode
==
CONST_OK
)
processJSBS_UniversalParameters(
parmCC.structJSBS_UniversalParameters
);
}
/*
*
-------------------------------
* de:
* CONSTRUCTOR
der Klasse
* Parameter ist ein Namen für das
Verzeichnis und die Datei mit der
* XML-Struktur, die die
Sprach-spezifischen Text-Elemente und Formatierungs-
*
Informationen festlegt.
* en:
*
CONSTRUCTOR of the class
* Parameter is a directory- and
file-name where the XML-structure with the
*
language-dependant text-elements and the formatting-specifications.
*/
public
JSBS_XML_DisplayStrings(
String
parmDirectoryAndFileName) {
/*
de: Code der geerbten Klasse ausführen.
* en: Perform
the code in the constructor of the inherited class.
*/
super
(
null
);
/*
de:
* Lesen des RootElement der XML-Struktur.
* Die
Methode dazu ist in der Superklasse (die geerbte Klasse)
enthalten.
* en:
* Read the RootElement (method
implemented in the superclass -
* i.e. the class
inherited).
*/
readXMLFile(parmDirectoryAndFileName);
}
/*
*
************************************************** */
/*
*
de:
* Methode zum Durchsuchen der XML-Struktur nach dem
Title-Text
* für einen JDialog (das als
Parameter übergeben wurde) und 'setzen' des
* Textes
in die Title-Bar.
* en:
*
Method to search the XML-structure for the Title-Text
for a JDialog
* (passed as parameter) and set the
Title-Text */
public
int
processJDialog(JDialog
parmJDialog) {
/*
de: Name der Klasse, die als Parameter übergeben wurde,
ermitteln.
* en: Get the name of the class that is passed as
parameter. */
String
strSearchedFrameClassName =
parmJDialog.getClass().getName().trim();
/*
de: Status-Code auf OK setzen um später prüfen zu können
ob ein Fehler aufgetreten ist.
* en:
Set
the status to OK to see later, if the called method returned an
error. */
StatusCode
=
CONST_OK
;
/*
de: Methode aufrufen, die den Text für die Title-Bar aus der
XML-Struktur holt.
* en: Call the method to get the
Title-Text out of the XML-structure. */
String
strTitle = getFrameTitle(strSearchedFrameClassName);
/*
de:
* Wenn die aufgerufenen Methode ohne Fehler geendet hat
dann ist die zurückgelieferte
* Zeichenkette der Text
für die Title-Bar den JDialog.
* en:
* If the
called method ended without an error then set the returned
String
* as Title for the JDialog. */
if
(
StatusCode
==
CONST_OK
)
parmJDialog.setTitle(strTitle);
/*
de: Bei Auftreten eines Fehlers wird der Status-Code
zurückgeliefert.
* en: In case of an error return the
Status-Code. */
return
StatusCode
;
}
/*
*
************************************************** */
/*
*
de:
* Methode zum Durchsuchen der XML-Struktur nach dem
Title-Text und dem Icon
* für ein JFrame (das als
Parameter übergeben wurde) und 'setzen' des
* Textes
und des Icons in die Title-Bar.
* en:
*
Method to search the XML-structure for the Title-Text and the Icon
for
* a JFrame (passed as parameter) and set the
Title-Text and Icon. */
private
int
processJFrame(JFrame
parmJFrame,
JSBS_UniversalParameters
parmJSBS_UniversalParameters) {
/*
de: Name der Klasse, die als Parameter übergeben wurde,
ermitteln.
* en: Get the name of the class that is passed as
parameter. */
String
strSearchedFrameClassName =
parmJFrame.getClass().getName().trim();
/*
de: Status-Code auf OK setzen um später prüfen zu können
ob ein Fehler aufgetreten ist.
* en:
Set
the status to OK to see later, if the called method returned an
error. */
StatusCode
=
CONST_OK
;
/*
de: Methode aufrufen, die den Text für die Title-Bar aus der
XML-Struktur holt.
* en: Call the method to get the
Title-Text out of the XML-structure. */
String
strTitle = getFrameTitle(strSearchedFrameClassName);
/*
de:
* Wenn die aufgerufenen Methode ohne Fehler geendet hat
dann ist die zurückgelieferte
* Zeichenkette der Text
für die Title-Bar des JFrame.
* en:
* If the
called method ended without an error then set the returned
String
* as Title for the JFrame. */
if
(
StatusCode
==
CONST_OK
)
parmJFrame.setTitle(strTitle);
/*
de: Bei Auftreten eines Fehlers wird der Status-Code
zurückgeliefert.
* en: In case of an error return the
Status-Code. */
else
return
StatusCode
;
/*
* de: Methode aufrufen, die den Namen für die
Icon-Datei aus der XML-Struktur holt.
* en: Call the method
to get the name for the Icon-file out of the XML-structure.
*/
String
strIconFileName = getFrameIconFileName(strSearchedFrameClassName);
/*
de:
* Wenn die aufgerufenen Methode ohne Fehler geendet hat
dann ist die zurückgelieferte
* Zeichenkette der
Datei-Name für das Icon des JFrame.
* en:
* If
the called method ended without an error then the returned String
contains
* the file-name for the icon for the JFrame.
*/
if
(
StatusCode
==
CONST_OK
)
{
/*
de:
* Passenden Datei-Namen gefunden;
* die
Zeichenkette auf das komplette Verzeichnis erweitern.
*
en:
* Fitting file-name found; expand the String to the
complete dircetory- and file-name. */
strIconFileName
=
parmJSBS_UniversalParameters.
strGraphicElementsDirectoryName
+
strIconFileName;
/*
de:
Ein
'Image' aus der Datei erstellen.
* en:
Build
an Image out of the file. */
Image
imgIcon = Toolkit.getDefaultToolkit().getImage(strIconFileName);
/*
de:
D
'Image' aus der Datei erstellen.
* en:
Build
an Image out of the file. */
parmJFrame.setIconImage(imgIcon);
}
/*
de: Zuletzt noch den Status-Code zurückliefern.
* en:
Finally return the Status-Code. */
return
StatusCode
;
}
/*
*
de:
Wrapper-METHODEN
für die obige Methode.
* en:
Wrapper-METHODS
for the above methods. */
public
int
processJFrame(JSBS_StartFrame
parmJSBS_StartFrame) {
return
processJFrame(parmJSBS_StartFrame,
parmJSBS_StartFrame.
structJSBS_UniversalParameters
);
}
public
int
processJFrame(JSBS_TaskFrame
parmJSBS_TaskFrame) {
return
processJFrame(parmJSBS_TaskFrame,
parmJSBS_TaskFrame.
frmCC
.
structJSBS_UniversalParameters
);
}
/*
*
************************************************** */
/*
*
de:
* METHODE zum Durchsuchen der XML-Struktur nach dem
XML-Element für ein JFrame
* oder einen
JDialog.
* en:
*
METHOD to search the XML-structure for the XML-Element for a JFrame
or JDialog. */
private
Element
getFrame_Element(String parmsearchedFrameClassName) {
/*
*
Variablen / Variables:
*/
/*
* de:
*
Element für den <FrameIndividual> Abschnitt, Element für
ein <Frame>,
* Element für die <FrameClass>,
Zeichenkette mit dem Namen der FrameClass,
* element für
den <FrameTitle> und Zeichenkette mit dessen Inhalt.
*
en:
* Element for the <FrameIndividual> Division,
element for one <Frame>,
* element for the
<FrameClass>, String with the name of the FrameClass,
*
element for the <FrameTitle> and String with the content of it.
*/
Element
elementFrameIndividual;
Element
elementFrame;
Element
elementFrameClass;
String
strFrameClassName;
/*
de: Liste mit allen <Frame>-Elementen, Anzahl und Index zum
Durchsuchen.
* en: List of all <Frame>-elements, size
and index for searching it. */
java.util.List
listFrame;
int
intlistFrameSize;
int
intlistFrameIndex
= 0;
/*
*
de: Generelle Prüfung ob überhaupt <FrameIndividual>
Elemente vorhanden sind.
* en: General check if there are
child-elements named <FrameIndividual>
present. */
elementFrameIndividual
=
XML_RootElement
.getChild(
"FrameIndividual"
);
if
(elementFrameIndividual
==
null
)
{
StatusCode
=
CONST_FRAMEINDIVIDUAL_DIVISION_NOT_PRESENT
;
return
null
;
}
/*
*
de: Holen der Liste mit den <Frame>-Elementen und ermitteln der
Anzahl in der Liste.
* en: Get the list of <Frame>-elements
and the number of elements within. */
listFrame
= elementFrameIndividual.getChildren();
intlistFrameSize
= listFrame.size();
if
(intlistFrameSize
== 0) {
StatusCode
=
CONST_FRAMECLASS_NOT_PRESENT
;
return
null
;
}
/*
*
de:
* Jedes Element der Liste untersuchen um das Element,
das zum gesuchten
* Klassen-Namen des JFrame (als Parameter
übergeben) passt.
* en:
* Inspect each element
of the list to find the element
fitting the
Class-Name of the JFrame passed as parameter. */
for
(intlistFrameIndex
= 0; intlistFrameIndex < intlistFrameSize; intlistFrameIndex++)
{
elementFrame =
(Element) listFrame.get(intlistFrameIndex);
/*
de:
* XML-Element mit der <FrameClass> herausholen um
dessen Inhalt mit dem
* Klassen-Namen aus dem Parameter
vergleichen zu können.
* en:
* Get the
XML-element with the <FrameClass> to compare its content
* with the Class-Name of the passed
parameter. */
elementFrameClass
= elementFrame.getChild(
"FrameClass"
);
if
(elementFrameClass
==
null
)
{
StatusCode
=
CONST_FRAMECLASS_NOT_PRESENT
;
return
null
;
}
strFrameClassName
= elementFrameClass.getTextTrim();
if
(strFrameClassName.compareTo(parmsearchedFrameClassName)
== 0) {
/*
de:
* Passendes <JFrame>-Element in der Liste
gefunden; dieses
zurückliefern.
*
en:
* Fitting <Frame>-element found within the list;
return
it. */
StatusCode
=
CONST_OK
;
return
elementFrame;
}
}
/*
*
de:
* Liste durchsucht ohne ein <Frame>-Element mit
passendem Klassen-Namen zu finden;
* Fehler
zurückliefern.
* en:
* List
searched without finding a <Frame>-element with fitting
class-name;
* return the error. */
StatusCode
=
CONST_FRAMECLASS_NOT_PRESENT
;
return
null
;
}
/*
*
************************************************** */
/*
*
de:
* METHODE zum Durchsuchen der XML-Struktur nach dem Text
für die Title-Bar eines JFrame
* oder JDialog.
*
en:
*
METHOD to search the XML-structure for the Title-Text of a JFrame or
JDialog */
private
String
getFrameTitle(String parmsearchedFrameClassName) {
/*
*
Variablen / Variables:
*/
/*
* de:
*
Element für das <Frame>,
* element für den
<FrameFrameIconFileName>.
* en:
* element for
the <Frame>,
* element for the <FrameIconFileName>.
*/
Element
elementFrame;
Element
elementFrameTitle;
/*
*
de: Methode verwenden die das XML-Element für einen
Klassen-Namen liefert.
* en: Use the method that return the
XML-element for a given class-name. */
elementFrame
= getFrame_Element(parmsearchedFrameClassName);
/*
*
de: Prüfen ob ein passendes XML-Element gefunden wurde.
*
en: Verify if a fitting XML-element was found. */
if
(elementFrame
==
null
)
{
return
""
;
}
if
(
StatusCode
!=
CONST_OK
)
{
return
""
;
}
/*
*
de:
* XML-Element für das gesuchte JFrame gefunden;
XML-Element für den Text der Title-Bar
* extrahieren
und Zeichenkette mit dem Text zurückliefern.
* en:
*
XML-element for the searched JFrame found; extract the XML-Element
for the Title-Bar-Text
* and return the String with the
text. */
elementFrameTitle
= elementFrame.getChild(
"FrameTitle"
);
if
(elementFrameTitle
==
null
)
{
StatusCode
=
CONST_FRAMETITLE_NOT_PRESENT
;
return
""
;
}
StatusCode
=
CONST_OK
;
return
elementFrameTitle.getTextTrim();
}
/*
*
************************************************** */
/*
*
de:
* METHODE die den Dateinamen für das graphische
Element (Icon), das in der Title-Bar
* eines JFrame
angezeigt wird, zurückliefert.
* en:
*
METHOD that returns the file-name of the Icon, which is shown in the
title-bar of
* a JFrame. */
private
String
getFrameIconFileName(String parmsearchedFrameClassName) {
/*
*
Variablen / Variables:
*/
/*
* de:
*
Element für das <Frame>,
* element für den
<FrameFrameIconFileName>.
* en:
* element for
the <Frame>,
* element for the <FrameIconFileName>.
*/
Element
elementFrame;
Element
elementFrameIconFileName;
/*
*
de: Methode verwenden die das XML-Element für einen
Klassen-Namen liefert.
* en: Use the method that return the
XML-element for a given class-name. */
elementFrame
= getFrame_Element(parmsearchedFrameClassName);
/*
*
de: Prüfen ob ein passendes XML-Element gefunden wurde.
*
en: Verify if a fitting XML-element was found. */
if
(elementFrame
==
null
)
{
return
""
;
}
if
(
StatusCode
!=
CONST_OK
)
{
return
""
;
}
/*
*
de:
* XML-Element für das gesuchte JFrame gefunden;
XML-Element für den Icon-File-Namen
* extrahieren und
Zeichenkette mit dem Datei-Namen zurückliefern.
* en:
* XML-element for the searched JFrame found; extract the
XML-Element for the Icon-File-Name
* and return the String
with the file-name. */
elementFrameIconFileName
= elementFrame.getChild(
"IconFileName"
);
if
(elementFrameIconFileName
==
null
)
{
StatusCode
=
CONST_FRAMETITLE_NOT_PRESENT
;
return
""
;
}
StatusCode
=
CONST_OK
;
return
elementFrameIconFileName.getTextTrim();
}
/*
*
************************************************** */
/*
*
de:
* METHODE die den Dateinamen für das Dokument mit
dem Hilfe-Text zurückliefert.
* en:
*
METHOD that returns the file-name of the document with the Help-text.
*/
public
String
getFrameHelpFileName(String parmsearchedFrameClassName) {
/*
*
Variablen / Variables:
*/
/*
* de:
*
Element für das <Frame>,
* element für den
<FrameFrameHelpFileName>.
* en:
* element for
the <Frame>,
* element for the <FrameIconFileName>.
*/
Element
elementFrame;
Element
elementFrameHelpFileName;
/*
*
de: Methode verwenden die das XML-Element für einen
Klassen-Namen liefert.
* en: Use the method that return the
XML-element for a given class-name. */
elementFrame
= getFrame_Element(parmsearchedFrameClassName);
/*
*
de: Prüfen ob ein passendes XML-Element gefunden wurde.
*
en: Verify if a fitting XML-element was found. */
if
(elementFrame
==
null
)
{
return
""
;
}
if
(
StatusCode
!=
CONST_OK
)
{
return
""
;
}
/*
*
de:
* XML-Element für das gesuchte JFrame gefunden;
XML-Element für den Help-File-Namen
* extrahieren und
Zeichenkette mit dem Datei-Namen zurückliefern.
* en:
* XML-element for the searched JFrame found; extract the
XML-Element for the Help-File-Name
* and return the String
with the file-name. */
elementFrameHelpFileName
= elementFrame.getChild(
"HelpFileName"
);
if
(elementFrameHelpFileName
==
null
)
{
StatusCode
=
CONST_FRAMETITLE_NOT_PRESENT
;
return
""
;
}
StatusCode
=
CONST_OK
;
return
elementFrameHelpFileName.getTextTrim();
}
/*
*
de:
Wrapper-METHODEN
für die obige Methode.
* en:
Wrapper-METHODS
for the above methods. */
public
String
getFrameHelpFileName(JSBS_StartFrame parmJSBS_StartFrame) {
return
getFrameHelpFileName(parmJSBS_StartFrame.getClass().getName());
}
public
String
getFrameHelpFileName(JSBS_TaskFrame parmJSBS_TaskFrame) {
return
getFrameHelpFileName(parmJSBS_TaskFrame.getClass().getName());
}
public
String
getFrameHelpFileName(JDialog parmJDialog) {
return
getFrameHelpFileName(parmJDialog.getClass().getName());
}
/*
*
************************************************** */
/*
*
Method to get a DOM-Element belonging to the <FrameIndividual>
division of the XML-structure */
private
Element
getGUI_Element(String parmstrFrameClassName, String
parmstrElementName) {
/*
* Variables:
*/
/*
Element for the <FrameIndividual> Division, element for one
<Frame>,
* element for the <FrameClass>, String
with the name of the FrameClass,
* element for one
GUI-Element within the <Frame>,
*
element for the <ElementName> and String with the content of it
(the name). */
Element
elementFrameIndividual;
Element
elementFrame;
Element
elementFrameClass;
String
strFrameClassName;
Element
elementGUI_Element;
Element
elementElementName;
String
strElementName;
/*
List of all <Frame>-elements, size and index for searching it.
*/
java.util.List
listFrame;
int
intlistFrameSize;
int
intlistFrameIndex
= 0;
/*
List of all GUI-<Element>-elements, size and index for
searching it. */
java.util.List
listGUI_Element;
int
intlistGUI_ElementSize;
int
intlistGUI_ElementIndex
= 0;
/*
* Set
the StatusCode to OK to see at the end of the method if anything went
wrong. */
StatusCode
=
CONST_OK
;
/*
* General
check if there are child-elements named <FrameIndividual>
present. */
elementFrameIndividual
=
XML_RootElement
.getChild(
"FrameIndividual"
);
if
(elementFrameIndividual
==
null
)
{
StatusCode
=
CONST_FRAMEINDIVIDUAL_DIVISION_NOT_PRESENT
;
return
null
;
}
/*
* Get
the list of <Frame>-elements and the number of elements
within. */
listFrame
= elementFrameIndividual.getChildren();
intlistFrameSize
= listFrame.size();
if
(intlistFrameSize
== 0) {
StatusCode
=
CONST_FRAMECLASS_NOT_PRESENT
;
return
null
;
}
/*
* Inspect
each element of the list to find the element
fitting
the Class-Name of the JFrame passed as parameter. */
for
(intlistFrameIndex
= 0; intlistFrameIndex < intlistFrameSize; intlistFrameIndex++)
{
elementFrame =
(Element) listFrame.get(intlistFrameIndex);
/* Get
the element with the <FrameClass> to compare its content
* with the Class-Name of the passed
parameter. */
elementFrameClass
= elementFrame.getChild(
"FrameClass"
);
if
(elementFrameClass
==
null
)
{
StatusCode
=
CONST_FRAMECLASS_NOT_PRESENT
;
return
null
;
}
strFrameClassName
= elementFrameClass.getTextTrim();
if
(strFrameClassName.compareTo(parmstrFrameClassName)
== 0) {
/* Fitting
<Frame>-element found within the list;
* extract
the list of GUI-elements and inspect each of
it. */
listGUI_Element
=
elementFrame.getChildren(
"Element"
);
intlistGUI_ElementSize
= listGUI_Element.size();
if
(intlistGUI_ElementSize
== 0) {
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
null
;
}
for
(intlistGUI_ElementIndex
= 0; intlistGUI_ElementIndex < intlistGUI_ElementSize;
intlistGUI_ElementIndex++) {
elementGUI_Element
= (Element) listGUI_Element.get(intlistGUI_ElementIndex);
/* Get
the element <ElementName> to compare its content (name of the
GUI-element)
* and compare it with the name of the
GUI-element
passed
as parameter. */
elementElementName
= elementGUI_Element.getChild(
"ElementName"
);
if
(elementElementName
==
null
)
{
/* Found
a GUI-element without a name.
* Should not happen but
is not a reason to end; skip further
inspection */
strElementName
=
""
;
}
else
{
strElementName
=
elementElementName.getTextTrim();
}
if
(strElementName.compareTo(parmstrElementName)
==
0) {
/* Fitting
element found within the XML-structure;
* check if
there are properties at a <CommonElement> and merge if
necessary.
* Check and merge is done in a separate
method to limit the depth of 'for' and 'if'
* hierachies
in this
method. */
mergeCommonElementProperties(elementGUI_Element);
return
elementGUI_Element;
}
}
}
}
/* Searched
GUI-element not found within the XML-structure; return the
error. */
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
null
;
}
/*
*
************************************************** */
/* de:
*
Method zum Prüfen ob Werte innerhalb des <CommonElements>
Bereich definiert
* sind und - wenn Werte existieren - diese
auf das als Parameter übergebene
* DOM-Element
übertragen
*
en:
*
Method to check if properties are defined within a DOM-element
belonging
*
to
the <CommonElements> and – if one exists –
transfer its properties
* to the DOM-element passed as
parameter. */
private
void
mergeCommonElementProperties(Element
parmelementGUI_Element) {
/*
* Variable
/ Variables:
* de:
* Element für die
<CommonElementReference> und Zeichenkette mit dem Inhalt.
*
en:
* Element for the <CommonElementReference> and
String with the content of it. */
Element
elementCommonElementReference;
String
strCommonElementReference;
/*
de:
* Unter-Elemente aus dem XML-Element das als Parameter
übergeben wurde.
*
en:
*
Sub-Elements of the XML-Element passed as parameter. */
Element
elementElementText_Param;
Element
elementToolTipText_Param;
Element
elementInfoMessage_Param;
Element
elementMinimumLength_Param;
Element
elementMaximumLength_Param;
Element
elementMandatory_Param;
Element
elementMinimumValue_Param;
Element
elementMaximumValue_Param;
Element
elementNumberOfDecimals_Param;
/*
*
de:
* Prüfen ob ein Element vorhanden ist, daß
die Referenz (Namen) auf das
* CommonElement enthält
*
en:
* Test
if the element with the reference (name) to the CommonElement is
present. */
elementCommonElementReference
=
parmelementGUI_Element.getChild(
"CommonElementReference"
);
if
(elementCommonElementReference
==
null
)
{
/*
de: Keine Referenz vorhanden; weitere Verarbeitung nicht
ausführen.
* en: No reference present; further
processing can be skipped. */
return
;
}
/*
de:
* Name des <CommonReference>-Elementes ermitteln
und dann die Methode
* um es zu 'holen' aufrufen.
*
en:
* Get the name of the <CommonReference>-element
and then call the method to get it. */
strCommonElementReference
= elementCommonElementReference.getTextTrim();
Element
locelementCommonReference =
getCommonElement(strCommonElementReference);
if
(locelementCommonReference
==
null
)
{
/*
de:
* Referenziertes Element nicht gefunden obwohl eine
Referenz beim
* FrameIndividual-Element vorhanden ist;
*
Sollte nicht passieren - deswegen einen Fehler zurückmelden.
*
en:
* Referenced element not found although an reference was
found at the
* FrameIndividual-Element;
* should
not happen – so report an error. */
StatusCode
=
CONST_GUI_ELEMENT_COMMON_NOT_PRESENT
;
return
;
}
/*
*
de:
* Werte des (gerade 'geholten') <CommonElement>
auf das Element, das als
* Parameter übergeben wurde,
übertragen.
* Eine genaue Erklärung des
Algorithmus ist beim ersten zu übertragenden Element.
*
en:
* Transfer
properties from the <CommonElement> (just fetched)
* to
the element passed as parameter.
* Explanation of
the algorithm only for the first transfer. */
String
strElementVariableName =
"ElementText"
;
/*
* de:
* Prüfen ob der Wert nicht schon beim
individuellen Element
* (als Parameter übergeben)
festgelegt ist.
* Ein individuell festgelegter Wert
ist 'stärker' als jener des CommonElement.
*
en:
* Check if property was not already defined at the
individual element
* (passed as parameter).
* An
individual defined property is 'stronger' as the one defined at
*
the CommonElement.
*/
elementElementText_Param
=
parmelementGUI_Element.getChild(strElementVariableName);
if
(
elementElementText_Param ==
null
)
{
/*
de:
* Individuelles Element nicht vorhanden; Wert aus dem
<CommonElement>
* übertragen - sofern
vorhanden.
* en:
* Individual Element not present;
transfer property from <CommonElement> -
* if
present. */
Element
locelementElementText_Common =
locelementCommonReference.getChild(strElementVariableName);
if
(locelementElementText_Common
!=
null
)
{
/*
en:
* Element innerhalb des verarbeiteten
<CommonElement>;
* übertragen der Daten auf das
als Parameter übergebene Element.
* de:
*
Element found with in the processed <CommonElement>;
* transfer data to the element passed as parameter. */
Element
locelementElementText_New = new
Element(strElementVariableName);
locelementElementText_New.setText(locelementElementText_Common.getTextTrim());
parmelementGUI_Element.addContent(locelementElementText_New);
}
}
/*
de: 'ToolTipText' übertragen; gleicher Algorithmus wie für
den <ElementText>.
*
en: Transfer 'ToolTipText'; same algorithm as for <ElementText>. */
strElementVariableName
=
"ToolTipText"
;
elementToolTipText_Param
=
parmelementGUI_Element.getChild(strElementVariableName);
if
(
elementToolTipText_Param ==
null
)
{
Element
locelementToolTipText_Common =
locelementCommonReference.getChild(strElementVariableName);
if
(locelementToolTipText_Common
!=
null
)
{
Element
locelementToolTipText_New = new
Element(strElementVariableName);
locelementToolTipText_New.setText(locelementToolTipText_Common.getTextTrim());
parmelementGUI_Element.addContent(locelementToolTipText_New);
}
}
/*
de: 'InfoMessage' übertragen; gleicher Algorithmus wie für
den <ElementText>.
*
en: Transfer 'InfoMessage'; same algorithm as for <ElementText>. */
strElementVariableName
=
"InfoMessage"
;
elementInfoMessage_Param
=
parmelementGUI_Element.getChild(strElementVariableName);
if
(
elementInfoMessage_Param ==
null
)
{
Element
locelementInfoMessage_Common =
locelementCommonReference.getChild(strElementVariableName);
if
(locelementInfoMessage_Common
!=
null
)
{
Element
locelementInfoMessage_New = new
Element(strElementVariableName);
locelementInfoMessage_New.setText(locelementInfoMessage_Common.getTextTrim());
parmelementGUI_Element.addContent(locelementInfoMessage_New);
}
}
/*
de: 'MinimumLength' übertragen; gleicher Algorithmus wie für
den <ElementText>.
*
en: Transfer 'MinimumLength'; same algorithm as for <ElementText>. */
strElementVariableName
=
"MinimumLength"
;
elementMinimumLength_Param
=
parmelementGUI_Element.getChild(strElementVariableName);
if
(elementMinimumLength_Param
==
null
)
{
Element
locelementMinimumLength_Common =
locelementCommonReference.getChild(strElementVariableName);
if
(locelementMinimumLength_Common
!=
null
)
{
Element
locelementMinimumLength_New = new
Element(strElementVariableName);
locelementMinimumLength_New.setText(locelementMinimumLength_Common.getTextTrim());
parmelementGUI_Element.addContent(locelementMinimumLength_New);
}
}
/*
de: 'MaximumLength' übertragen; gleicher Algorithmus wie für
den <ElementText>.
*
en: Transfer 'MaximumLength'; same algorithm as for <ElementText>. */
strElementVariableName
=
"MaximumLength"
;
elementMaximumLength_Param
=
parmelementGUI_Element.getChild(strElementVariableName);
if
(elementMaximumLength_Param
==
null
)
{
Element
locelementMaximumLength_Common =
locelementCommonReference.getChild(strElementVariableName);
if
(locelementMaximumLength_Common
!=
null
)
{
Element
locelementMaximumLength_New = new
Element(strElementVariableName);
locelementMaximumLength_New.setText(locelementMaximumLength_Common.getTextTrim());
parmelementGUI_Element.addContent(locelementMaximumLength_New);
}
}
/*
de: 'Mandatory' übertragen; gleicher Algorithmus wie für
den <ElementText>.
*
en: Transfer 'Mandatory'; same algorithm as for <ElementText>. */
strElementVariableName
=
"Mandatory"
;
elementMandatory_Param
=
parmelementGUI_Element.getChild(strElementVariableName);
if
(elementMandatory_Param
==
null
)
{
Element
locelementMandatory_Common =
locelementCommonReference.getChild(strElementVariableName);
if
(locelementMandatory_Common
!=
null
)
{
Element
locelementMandatory_New = new
Element(strElementVariableName);
locelementMandatory_New.setText(locelementMandatory_Common.getTextTrim());
parmelementGUI_Element.addContent(locelementMandatory_New);
}
}
/*
de: 'MinimumValue' übertragen; gleicher Algorithmus wie für
den <ElementText>.
*
en: Transfer 'MinimumValue'; same algorithm as for <ElementText>. */
strElementVariableName
=
"MinimumValue"
;
elementMinimumValue_Param
=
parmelementGUI_Element.getChild(strElementVariableName);
if
(elementMinimumValue_Param
==
null
)
{
Element
locelementMinimumValue_Common =
locelementCommonReference.getChild(strElementVariableName);
if
(locelementMinimumValue_Common
!=
null
)
{
Element
locelementMinimumValue_New = new
Element(strElementVariableName);
locelementMinimumValue_New.setText(locelementMinimumValue_Common.getTextTrim());
parmelementGUI_Element.addContent(locelementMinimumValue_New);
}
}
/*
de: 'MaximumValue' übertragen; gleicher Algorithmus wie für
den <ElementText>.
*
en: Transfer 'MaximumValue'; same algorithm as for <ElementText>. */
strElementVariableName
=
"MaximumValue"
;
elementMaximumValue_Param
=
parmelementGUI_Element.getChild(strElementVariableName);
if
(elementMaximumValue_Param
==
null
)
{
Element
locelementMaximumValue_Common =
locelementCommonReference.getChild(strElementVariableName);
if
(locelementMaximumValue_Common
!=
null
)
{
Element
locelementMaximumValue_New = new
Element(strElementVariableName);
locelementMaximumValue_New.setText(locelementMaximumValue_Common.getTextTrim());
parmelementGUI_Element.addContent(locelementMaximumValue_New);
}
}
/*
de: 'NumberOfDecimals' übertragen; gleicher Algorithmus wie für
den <ElementText>.
*
en: Transfer 'NumberOfDecimals'; same algorithm as for
<ElementText>. */
strElementVariableName
=
"NumberOfDecimals"
;
elementNumberOfDecimals_Param
=
parmelementGUI_Element.getChild(strElementVariableName);
if
(elementNumberOfDecimals_Param
==
null
)
{
Element
locelementNumberOfDecimals_Common =
locelementCommonReference.getChild(strElementVariableName);
if
(locelementNumberOfDecimals_Common
!=
null
)
{
Element
locelementNumberOfDecimals_New = new
Element(strElementVariableName);
locelementNumberOfDecimals_New.setText(locelementNumberOfDecimals_Common.getTextTrim());
parmelementGUI_Element.addContent(locelementNumberOfDecimals_New);
}
}
}
/*
*
************************************************** */
/*
*
Method to get a DOM-Element belonging to the <CommonElements>
division of the XML-structure */
public
Element
getCommonElement(String parmstrElementName)
{
/*
* Variables:
*/
/*
Element for the <CommonElements> Division, element for one
<CommonElement>,
*
element for the <CommonElementName> and String with the content
of it (the name). */
Element
elementCommonElements;
Element
elementCommonElement;
Element
elementCommonElementName;
String
strCommonElementName;
/*
List of all <CommonElement>-elements, size and index for
searching it. */
java.util.List
listCommonElement;
int
intlistCommonElementSize;
int
intlistCommonElementIndex
= 0;
/*
* General
check if there are child-elements named <CommonElements>
present. */
elementCommonElements
=
XML_RootElement
.getChild(
"CommonElements"
);
if
(elementCommonElements
==
null
)
{
StatusCode
=
CONST_COMMONELEMENTS_DIVISION_NOT_PRESENT
;
return
null
;
}
/*
* Get
the list of <CommonElement>-elements and the number of elements
within. */
listCommonElement
= elementCommonElements.getChildren();
intlistCommonElementSize
= listCommonElement.size();
if
(intlistCommonElementSize
== 0) {
StatusCode
=
CONST_COMMONELEMENTS_DIVISION_NOT_PRESENT
;
return
null
;
}
/*
* Inspect
each element of the list to find the element
fitting
the element-name passed as parameter. */
for
(intlistCommonElementIndex
= 0; intlistCommonElementIndex < intlistCommonElementSize;
intlistCommonElementIndex++) {
elementCommonElement
=
(Element) listCommonElement.get(intlistCommonElementIndex);
/* Get
the element with the <ElementName> to compare its contents with
the passed parameter. */
elementCommonElementName
=
elementCommonElement.getChild(
"ElementName"
);
if
(elementCommonElementName
!=
null
)
{
/* Compare
if the element was found; otherwise skip and do not consider it as
error. */
strCommonElementName
= elementCommonElementName.getTextTrim();
if
(strCommonElementName.compareTo(parmstrElementName)
== 0) {
/* Fitting
<CommonElement>-element found within the list; return it
! */
return
elementCommonElement;
}
}
}
/* Searched
common-element not found within the XML-structure; return the
error. */
StatusCode
=
CONST_GUI_ELEMENT_COMMON_NOT_PRESENT
;
return
null
;
}
/*
* **************************************************
*/
/*
* Method to check if properties for the Font
and Foreground-Color are defined
* for the Individual
GUI-Element of type JLabel or JLabel-like GUI-components.
* If
no individual Font or Color is defined, the general definitions from
the
* 'Layout'-section of the XML-structure is taken.
*/
private
void
mergeLayoutElementLabelFontProperties(Element
parmelementGUI_Element) {
/*
*
Variables: */
/* Auxilliary XML-element to check if
Font-properties are already present at
* the Individual
GUI-element. */
Element
elementExistingFontProperty;
/*
Elements that are derived from the 'Layout'-section of the
XML-structure. */
Element
elementFontName;
Element
elementFontSize;
Element
elementFontColor;
Element
elementFontStyle;
/*
* The Font-properties are derived from the
'Layout'-section of the XML-structure.
* This is done
before checking if an individual Font-property was already defined
*
with the Individual GUI-element because defining Individual
Font-properties
* is considered to be very rare.
*/
Element
elementLayout =
XML_RootElement
.getChild(
"Layout"
);
/* Check
if the 'Layout'-section is present.
* Quit method if
not to avoid later dump due to missing values. */
if
(elementLayout
==
null
)
return
;
/* Get
the XML-elements for each Font-property. */
elementFontName
= elementLayout.getChild(
"LabelFontName"
);
elementFontSize
= elementLayout.getChild(
"LabelFontSize"
);
elementFontColor
= elementLayout.getChild(
"LabelFontColor"
);
elementFontStyle
= elementLayout.getChild(
"LabelFontStyle"
);
/*
* For each Font-property is checked:
* *
Does an individual value already exist with the Individual
GUI-element.
* * If no individual value exists
then the value from the general 'Layout'
* is
added to the XML-element representing the Individual GUI-component.
*/
elementExistingFontProperty
= parmelementGUI_Element.getChild(
"FontName"
);
if
(elementExistingFontProperty
==
null
)
{
/*
Individual Font-property not present; take over the one from the
'Layout'-section.
* But only if there is a valid one
defined in the 'Layout'-section. */
if
(elementFontSize
!=
null
)
{
Element
locelementFontName_New =
new
Element(
"FontName"
);
locelementFontName_New.setText(elementFontName.getTextTrim());
parmelementGUI_Element.addContent(locelementFontName_New);
}
}
/*
***** */
elementExistingFontProperty
= parmelementGUI_Element.getChild(
"FontSize"
);
if
(elementExistingFontProperty
==
null
)
{
/*
Individual Font-property not present; take over the one from the
'Layout'-section.
* But only if there is a valid one
defined in the 'Layout'-section. */
if
(elementFontSize
!=
null
)
{
Element
locelementFontSize_New =
new
Element(
"FontSize"
);
locelementFontSize_New.setText(elementFontSize.getTextTrim());
parmelementGUI_Element.addContent(locelementFontSize_New);
}
}
/*
***** */
elementExistingFontProperty
= parmelementGUI_Element.getChild(
"FontColor"
);
if
(elementExistingFontProperty
==
null
)
{
/*
Individual Font-property not present; take over the one from the
'Layout'-section.
* But only if there is a valid one
defined in the 'Layout'-section. */
if
(elementFontSize
!=
null
)
{
Element
locelementFontColor_New =
new
Element(
"FontColor"
);
locelementFontColor_New.setText(elementFontColor.getTextTrim());
parmelementGUI_Element.addContent(locelementFontColor_New);
}
}
/*
***** */
elementExistingFontProperty
= parmelementGUI_Element.getChild(
"FontStyle"
);
if
(elementExistingFontProperty
==
null
)
{
/*
Individual Font-property not present; take over the one from the
'Layout'-section.
* But only if there is a valid one
defined in the 'Layout'-section. */
if
(elementFontSize
!=
null
)
{
Element
locelementFontStyle_New =
new
Element(
"FontStyle"
);
locelementFontStyle_New.setText(elementFontStyle.getTextTrim());
parmelementGUI_Element.addContent(locelementFontStyle_New);
}
}
/*
***** */
}
/*
* **************************************************
*/
/*
* Method to check if properties for the Font
and Foreground-Color are defined
* for the Individual
GUI-Element of type JTextField or JTextArea GUI-components.
* If
no individual Font or Color is defined, the general definitions from
the
* 'Layout'-section of the XML-structure is taken.
*/
private
void
mergeLayoutElementTextFontProperties(Element
parmelementGUI_Element) {
/*
*
Variables: */
/* Auxilliary XML-element to check if
Font-properties are already present at
* the Individual
GUI-element. */
Element
elementExistingFontProperty;
/*
Elements that are derived from the 'Layout'-section of the
XML-structure. */
Element
elementFontName;
Element
elementFontSize;
Element
elementFontColor;
Element
elementFontStyle;
/*
* The Font-properties are derived from the
'Layout'-section of the XML-structure.
* This is done
before checking if an individual Font-property was already defined
*
with the Individual GUI-element because defining Individual
Font-properties
* is considered to be very rare.
*/
Element
elementLayout =
XML_RootElement
.getChild(
"Layout"
);
/* Check
if the 'Layout'-section is present.
* Quit method if
not to avoid later dump due to missing values. */
if
(elementLayout
==
null
)
return
;
/* Get
the XML-elements for each Font-property. */
elementFontName
= elementLayout.getChild(
"TextFontName"
);
elementFontSize
= elementLayout.getChild(
"TextFontSize"
);
elementFontColor
= elementLayout.getChild(
"TextFontColor"
);
elementFontStyle
= elementLayout.getChild(
"TextFontStyle"
);
/*
* For each Font-property is checked:
* *
Does an individual value already exist with the Individual
GUI-element.
* * If no individual value exists
then the value from the general 'Layout'
* is
added to the XML-element representing the Individual GUI-component.
*/
elementExistingFontProperty
= parmelementGUI_Element.getChild(
"FontName"
);
if
(elementExistingFontProperty
==
null
)
{
/*
Individual Font-property not present; take over the one from the
'Layout'-section.
* But only if there is a valid one
defined in the 'Layout'-section. */
if
(elementFontSize
!=
null
)
{
Element
locelementFontName_New =
new
Element(
"FontName"
);
locelementFontName_New.setText(elementFontName.getTextTrim());
parmelementGUI_Element.addContent(locelementFontName_New);
}
}
/*
***** */
elementExistingFontProperty
= parmelementGUI_Element.getChild(
"FontSize"
);
if
(elementExistingFontProperty
==
null
)
{
/*
Individual Font-property not present; take over the one from the
'Layout'-section.
* But only if there is a valid one
defined in the 'Layout'-section. */
if
(elementFontSize
!=
null
)
{
Element
locelementFontSize_New =
new
Element(
"FontSize"
);
locelementFontSize_New.setText(elementFontSize.getTextTrim());
parmelementGUI_Element.addContent(locelementFontSize_New);
}
}
/*
***** */
elementExistingFontProperty
= parmelementGUI_Element.getChild(
"FontColor"
);
if
(elementExistingFontProperty
==
null
)
{
/*
Individual Font-property not present; take over the one from the
'Layout'-section.
* But only if there is a valid one
defined in the 'Layout'-section. */
if
(elementFontSize
!=
null
)
{
Element
locelementFontColor_New =
new
Element(
"FontColor"
);
locelementFontColor_New.setText(elementFontColor.getTextTrim());
parmelementGUI_Element.addContent(locelementFontColor_New);
}
}
/*
***** */
elementExistingFontProperty
= parmelementGUI_Element.getChild(
"FontStyle"
);
if
(elementExistingFontProperty
==
null
)
{
/*
Individual Font-property not present; take over the one from the
'Layout'-section.
* But only if there is a valid one
defined in the 'Layout'-section. */
if
(elementFontSize
!=
null
)
{
Element
locelementFontStyle_New =
new
Element(
"FontStyle"
);
locelementFontStyle_New.setText(elementFontStyle.getTextTrim());
parmelementGUI_Element.addContent(locelementFontStyle_New);
}
}
/*
***** */
}
/*
* **************************************************
*/
/*
* de:
* METHODE zum Übertragen der in
der XML-Struktur definierten Eigenschaften auf ein GUI-Element vom
* Typ JTextField.
*
en:
* METHOD to transfer the properties defined in the
XML-structure to a GUI-element of type JTextField. */
public
int
processJTextField(JTextField
parmJTextField, String parmstrFrameClassName) {
/*
*
Variable / Variables:
*/
/*
* de:
*
Passendes Element aus der XML-Struktur mit den
XML-Elementen,
die alle Eigenschaften,
* die auf das JTextField übertragen
werden sollen, enthalten.
* en:
* Fitting element
out of the XML-structure containing
* XML-elements
representing all properties to be transferred to the JTextField.
*/
Element
elementGUI_Element;
/*
* de:
* Name des JTextField; verwendet um das
passende XML-Element mit den Eigenschaften für das
GUI-Element
* aus der XML-STruktur holen zu können.
*
en:
* Name of the JTextField; used as identifier to get the
fitting XML-element containing the properties
* for the
GUI-Element
out
of the XML-structure. */
String
strTextFieldName = parmJTextField.getName();
/*
* de:
* Prüfen ob das GUI-element einen Namen
hat; sonst tritt unvorhersehbares des Algorithmus Verhalten ein.
*
en:
* Verify if the GUI-element has a name; otherwise there
is unpredicted behaviour of the algorithm. */
if
(strTextFieldName
!=
null
)
{
/*
*
de: Holen des passenden XML-Elements mit der weiter oben
implementierten Methode.
* en:
Get
the fitting XML-element using the method implemented above.
*/
elementGUI_Element
= getGUI_Element(parmstrFrameClassName, strTextFieldName);
if
(elementGUI_Element
==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
* de:
* Prüfen ob das GUI-Element 'enabled' ist und diesen Status aufheben.
* Dann das GUI-Elment auf 'enabled' setzen. Dieser Status ist notwendig um die Eigenschaften
* dem GUI-Element zuordnen zu können.
* en:
* Verify if the GUI-Element is enabled and keep this status.
* Set the GUI-element to 'enabled' thereafter. This status is needed to attach the properties
* to the GUI-element.
*/
boolean
bolGUIElementEnabled =
parmJTextField
.isEnabled();
parmJTextField
.setEnabled(
true
);
/*
* de: Eigenschaftem aus der XML-Datei dem GUI-Element zuordnen.
* en: Attach the properties from the XML-file to the GUI-Element
.
*/
/*
* de:
* Übertragen der Eigenschaften die im
XML-Element definiert sind auf das, als Parameter
*
übergebene, JTextField.
* en:
*
Transfer the properties defined with the XML-element to the
JTextField passed as parameter.
*/
parmJTextField.setToolTipText(getProperty_ElementToolTipText(elementGUI_Element));
/*
* de:
* Dazumischen der Eigenschaften für den
Font aus dem 'Layout'-Bereich.
* en:
* Merge the
Font-properties that are defined in the 'Layout'-section.
*/
mergeLayoutElementTextFontProperties(elementGUI_Element);
/*
* de:
* Setzen der Font-Eigenschaften und der
'Vordergrund'-Farbe (für Text) des GUI-Elements.
*
en:
* Set the Font and the Foreground-Color (for text) of
the GUI-element. */
String
strFontName = getProperty_FontName(elementGUI_Element);
int
intFontSize
= getProperty_FontSize(elementGUI_Element);
int
intFontStyle
= getProperty_FontStyle(elementGUI_Element);
Font
fntFont =
new
Font(strFontName,
intFontStyle,
intFontSize);
parmJTextField.setFont(fntFont);
Color
clrFontColor =
getProperty_FontColor(elementGUI_Element);
parmJTextField.setForeground(clrFontColor);
/*
* de:
* Nicht die 'gegraute' Version der Farbe
verwenden wenn die Eingabe im GUI-Element
* nicht erlaubt
ist.
* en:
* Do not use the 'greyed' Version of the
color if entry to this GUI-Element is disabled.
*/
parmJTextField.setDisabledTextColor(clrFontColor);
/*
* de: 'Enabled'/'Disabled' Status vom Anfang der Methode wieder zuordnen.
* en: Restore the 'enabled'/'disabled' status from the begin of the method
.
*/
parmJTextField
.setEnabled(
bolGUIElementEnabled
);
}
else
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;}
/*
* de:
* Zurückliefern des Status-Codes dieser
Klasse; er signalisiert eventuelle Fehler während der
*
Vararbeitung.
* en:
*
Return the Status-code of this class; it reflects if errors occured
during processing */
return
StatusCode
;
}
/*
* **************************************************
*/
/*
* de:
* METHODE zum Übertragen der in
der XML-Struktur definierten Eigenschaften auf ein GUI-Element vom
* Typ JTextArea.
* Für detailierte
Erklärungen zur Funktion des Codes sehen Sie bitte bei der
Methode processJTextField
* nach.
*
en:
* METHOD to transfer the properties defined in the
XML-structure to a GUI-element of type JTextArea.
* Please
see the comments at the method processJTextField for a detailed
explanation of the code.
*/
public
int
processJTextArea(JTextArea
parmJTextArea, String parmstrFrameClassName) {
Element
elementGUI_Element;
String
strTextAreaName = parmJTextArea.getName();
if
(strTextAreaName
!=
null
)
{
elementGUI_Element
= getGUI_Element(parmstrFrameClassName, strTextAreaName);
if
(elementGUI_Element
==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
* de:
* Prüfen ob das GUI-Element 'enabled' ist und diesen Status aufheben.
* Dann das GUI-Elment auf 'enabled' setzen. Dieser Status ist notwendig um die Eigenschaften
* dem GUI-Element zuordnen zu können.
* en:
* Verify if the GUI-Element is enabled and keep this status.
* Set the GUI-element to 'enabled' thereafter. This status is needed to attach the properties
* to the GUI-element.
*/
boolean
bolGUIElementEnabled =
parmJTextArea
.isEnabled();
parmJTextArea
.setEnabled(
true
);
/*
* de: Eigenschaftem aus der XML-Datei dem GUI-Element zuordnen.
* en: Attach the properties from the XML-file to the GUI-Element
.
*/
parmJTextArea.setToolTipText(getProperty_ElementToolTipText(elementGUI_Element));
mergeLayoutElementTextFontProperties(elementGUI_Element);
String
strFontName = getProperty_FontName(elementGUI_Element);
int
intFontSize
= getProperty_FontSize(elementGUI_Element);
int
intFontStyle
= getProperty_FontStyle(elementGUI_Element);
Font
fntFont =
new
Font(strFontName,
intFontStyle,
intFontSize);
parmJTextArea.setFont(fntFont);
Color
clrFontColor =
getProperty_FontColor(elementGUI_Element);
parmJTextArea.setForeground(clrFontColor);
parmJTextArea.setDisabledTextColor(clrFontColor);
/*
* de: 'Enabled'/'Disabled' Status vom Anfang der Methode wieder zuordnen.
* en: Restore the 'enabled'/'disabled' status from the begin of the method
.
*/
parmJTextArea
.setEnabled(
bolGUIElementEnabled
);
}
else
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;}
return
StatusCode
;
}
/*
* **************************************************
*/
/*
* de:
* METHODE zum Übertragen der in
der XML-Struktur definierten Eigenschaften auf ein GUI-Element vom
* Typ JComboBox.
* Für detailierte
Erklärungen zur Funktion des Codes sehen Sie bitte bei der
Methode processJTextField
* nach.
*
en:
* METHOD to transfer the properties defined in the
XML-structure to a GUI-element of type JComboBox.
* Please
see the comments at the method processJTextField for a detailed
explanation of the code.
*/
public
int
processJComboBox(JComboBox
parmJComboBox, String parmstrFrameClassName) {
Element
elementGUI_Element;
String
strComboBoxName = parmJComboBox.getName();
if
(strComboBoxName
!=
null
)
{
elementGUI_Element
= getGUI_Element(parmstrFrameClassName, strComboBoxName);
if
(elementGUI_Element
==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
* de:
* Prüfen ob das GUI-Element 'enabled' ist und diesen Status aufheben.
* Dann das GUI-Elment auf 'enabled' setzen. Dieser Status ist notwendig um die Eigenschaften
* dem GUI-Element zuordnen zu können.
* en:
* Verify if the GUI-Element is enabled and keep this status.
* Set the GUI-element to 'enabled' thereafter. This status is needed to attach the properties
* to the GUI-element.
*/
boolean
bolGUIElementEnabled = parmJComboBox.isEnabled();
parmJComboBox.setEnabled(
true
);
/*
* de: Eigenschaftem aus der XML-Datei dem GUI-Element zuordnen.
* en: Attach the properties from the XML-file to the GUI-Element
.
*/
parmJComboBox.setToolTipText(getProperty_ElementToolTipText(elementGUI_Element));
mergeLayoutElementLabelFontProperties(elementGUI_Element);
String
strFontName = getProperty_FontName(elementGUI_Element);
int
intFontSize
= getProperty_FontSize(elementGUI_Element);
int
intFontStyle
= getProperty_FontStyle(elementGUI_Element);
Font
fntFont =
new
Font(strFontName,
intFontStyle,
intFontSize);
parmJComboBox.setFont(fntFont);
Color
clrFontColor =
getProperty_FontColor(elementGUI_Element);
parmJComboBox.setForeground(clrFontColor);
/*
* de: 'Enabled'/'Disabled' Status vom Anfang der Methode wieder zuordnen.
* en: Restore the 'enabled'/'disabled' status from the begin of the method
.
*/
parmJComboBox.setEnabled(
bolGUIElementEnabled
);
}
else
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;}
return
StatusCode
;
}
/*
* **************************************************
*/
/*
* de:
* METHODE zum Übertragen der in
der XML-Struktur definierten Eigenschaften auf ein GUI-Element vom
* Typ JLabel.
* Für detailierte Erklärungen
zur Funktion des Codes sehen Sie bitte bei der Methode
processJTextField
* nach.
*
en:
* METHOD to transfer the properties defined in the
XML-structure to a GUI-element of type JLabel.
* Please see
the comments at the method processJTextField for a detailed
explanation of the code.
*/
public
int
processJLabel(JLabel
parmJLabel, String parmstrFrameClassName) {
Element
elementGUI_Element;
String
strLabelName = parmJLabel.getName();
if
(strLabelName
!=
null
)
{
elementGUI_Element
= getGUI_Element(parmstrFrameClassName, strLabelName);
if
(elementGUI_Element
==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
* de:
* Prüfen ob das GUI-Element 'enabled' ist und diesen Status aufheben.
* Dann das GUI-Elment auf 'enabled' setzen. Dieser Status ist notwendig um die Eigenschaften
* dem GUI-Element zuordnen zu können.
* en:
* Verify if the GUI-Element is enabled and keep this status.
* Set the GUI-element to 'enabled' thereafter. This status is needed to attach the properties
* to the GUI-element.
*/
boolean
bolGUIElementEnabled =
parmJLabel
.isEnabled();
parmJLabel
.setEnabled(
true
);
/*
* de: Eigenschaftem aus der XML-Datei dem GUI-Element zuordnen.
* en: Attach the properties from the XML-file to the GUI-Element
.
*/
parmJLabel.setText(getProperty_ElementText(elementGUI_Element));
parmJLabel.setToolTipText(getProperty_ElementToolTipText(elementGUI_Element));
mergeLayoutElementLabelFontProperties(elementGUI_Element);
String
strFontName = getProperty_FontName(elementGUI_Element);
int
intFontSize
= getProperty_FontSize(elementGUI_Element);
int
intFontStyle
= getProperty_FontStyle(elementGUI_Element);
Font
fntFont =
new
Font(strFontName,
intFontStyle,
intFontSize);
parmJLabel.setFont(fntFont);
Color
clrFontColor =
getProperty_FontColor(elementGUI_Element);
parmJLabel.setForeground(clrFontColor);
/*
* de: 'Enabled'/'Disabled' Status vom Anfang der Methode wieder zuordnen.
* en: Restore the 'enabled'/'disabled' status from the begin of the method
.
*/
parmJLabel
.setEnabled(
bolGUIElementEnabled
);
}
else
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;}
return
StatusCode
;
}
/*
* **************************************************
*/
/*
* de:
* METHODE zum Übertragen der in
der XML-Struktur definierten Eigenschaften auf ein GUI-Element vom
* Typ JButton.
* Für detailierte Erklärungen
zur Funktion des Codes sehen Sie bitte bei der Methode
processJTextField
* nach.
*
en:
* METHOD to transfer the properties defined in the
XML-structure to a GUI-element of type JButton.
* Please see
the comments at the method processJTextField for a detailed
explanation of the code.
*/
public
int
processJButton(JButton
parmJButton, String parmstrFrameClassName) {
Element
elementGUI_Element;
String
strButtonName = parmJButton.getName();
if
(strButtonName
!=
null
)
{
elementGUI_Element
= getGUI_Element(parmstrFrameClassName, strButtonName);
if
(elementGUI_Element
==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
* de:
* Prüfen ob das GUI-Element 'enabled' ist und diesen Status aufheben.
* Dann das GUI-Elment auf 'enabled' setzen. Dieser Status ist notwendig um die Eigenschaften
* dem GUI-Element zuordnen zu können.
* en:
* Verify if the GUI-Element is enabled and keep this status.
* Set the GUI-element to 'enabled' thereafter. This status is needed to attach the properties
* to the GUI-element.
*/
boolean
bolGUIElementEnabled =
parmJButton
.isEnabled();
parmJButton
.setEnabled(
true
);
/*
* de: Eigenschaftem aus der XML-Datei dem GUI-Element zuordnen.
* en: Attach the properties from the XML-file to the GUI-Element
.
*/
parmJButton.setText(getProperty_ElementText(elementGUI_Element));
parmJButton.setToolTipText(getProperty_ElementToolTipText(elementGUI_Element));
mergeLayoutElementLabelFontProperties(elementGUI_Element);
String
strFontName = getProperty_FontName(elementGUI_Element);
int
intFontSize
= getProperty_FontSize(elementGUI_Element);
int
intFontStyle
= getProperty_FontStyle(elementGUI_Element);
Font
fntFont =
new
Font(strFontName,
intFontStyle,
intFontSize);
parmJButton.setFont(fntFont);
Color
clrFontColor =
getProperty_FontColor(elementGUI_Element);
parmJButton.setForeground(clrFontColor);
/*
* de: 'Enabled'/'Disabled' Status vom Anfang der Methode wieder zuordnen.
* en: Restore the 'enabled'/'disabled' status from the begin of the method
.
*/
parmJButton
.setEnabled(
bolGUIElementEnabled
);
}
else
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;}
return
StatusCode
;
}
/*
* **************************************************
*/
/*
* de:
* METHODE zum Übertragen der in
der XML-Struktur definierten Eigenschaften auf ein GUI-Element vom
* Typ JRadioButton.
* Für detailierte
Erklärungen zur Funktion des Codes sehen Sie bitte bei der
Methode processJTextField
* nach.
*
en:
* METHOD to transfer the properties defined in the
XML-structure to a GUI-element of type JRadioButton.
*
Please see the comments at the method processJTextField for a
detailed explanation of the code.
*/
public
int
processJRadioButton(JRadioButton
parmJRadioButton, String parmstrFrameClassName) {
Element
elementGUI_Element;
String
strRadioButtonName = parmJRadioButton.getName();
if
(strRadioButtonName
!=
null
)
{
elementGUI_Element
= getGUI_Element(parmstrFrameClassName,
strRadioButtonName);
if
(elementGUI_Element
==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
* de:
* Prüfen ob das GUI-Element 'enabled' ist und diesen Status aufheben.
* Dann das GUI-Elment auf 'enabled' setzen. Dieser Status ist notwendig um die Eigenschaften
* dem GUI-Element zuordnen zu können.
* en:
* Verify if the GUI-Element is enabled and keep this status.
* Set the GUI-element to 'enabled' thereafter. This status is needed to attach the properties
* to the GUI-element.
*/
boolean
bolGUIElementEnabled =
parmJRadioButton
.isEnabled();
parmJRadioButton
.setEnabled(
true
);
/*
* de: Eigenschaftem aus der XML-Datei dem GUI-Element zuordnen.
* en: Attach the properties from the XML-file to the GUI-Element
.
*/
parmJRadioButton.setText(getProperty_ElementText(elementGUI_Element));
parmJRadioButton.setToolTipText(getProperty_ElementToolTipText(elementGUI_Element));
mergeLayoutElementLabelFontProperties(elementGUI_Element);
String
strFontName = getProperty_FontName(elementGUI_Element);
int
intFontSize
= getProperty_FontSize(elementGUI_Element);
int
intFontStyle
= getProperty_FontStyle(elementGUI_Element);
Font
fntFont =
new
Font(strFontName,
intFontStyle,
intFontSize);
parmJRadioButton.setFont(fntFont);
Color
clrFontColor =
getProperty_FontColor(elementGUI_Element);
parmJRadioButton.setForeground(clrFontColor);
/*
* de: 'Enabled'/'Disabled' Status vom Anfang der Methode wieder zuordnen.
* en: Restore the 'enabled'/'disabled' status from the begin of the method
.
*/
parmJRadioButton
.setEnabled(
bolGUIElementEnabled
);
}
else
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;}
return
StatusCode
;
}
/*
* **************************************************
*/
/*
* de:
* METHODE zum Übertragen der in
der XML-Struktur definierten Eigenschaften auf ein GUI-Element vom
* Typ JCheckBox.
* Für detailierte
Erklärungen zur Funktion des Codes sehen Sie bitte bei der
Methode processJTextField
* nach.
*
en:
* METHOD to transfer the properties defined in the
XML-structure to a GUI-element of type JCheckBox.
* Please
see the comments at the method processJTextField for a detailed
explanation of the code.
*/
public
int
processJCheckBox(JCheckBox
parmJCheckBox, String parmstrFrameClassName) {
Element
elementGUI_Element;
String
strCheckBoxName = parmJCheckBox.getName();
if
(strCheckBoxName
!=
null
)
{
elementGUI_Element
= getGUI_Element(parmstrFrameClassName, strCheckBoxName);
if
(elementGUI_Element
==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
* de:
* Prüfen ob das GUI-Element 'enabled' ist und diesen Status aufheben.
* Dann das GUI-Elment auf 'enabled' setzen. Dieser Status ist notwendig um die Eigenschaften
* dem GUI-Element zuordnen zu können.
* en:
* Verify if the GUI-Element is enabled and keep this status.
* Set the GUI-element to 'enabled' thereafter. This status is needed to attach the properties
* to the GUI-element.
*/
boolean
bolGUIElementEnabled =
parmJCheckBox
.isEnabled();
parmJCheckBox
.setEnabled(
true
);
/*
* de: Eigenschaftem aus der XML-Datei dem GUI-Element zuordnen.
* en: Attach the properties from the XML-file to the GUI-Element
.
*/
parmJCheckBox.setText(getProperty_ElementText(elementGUI_Element));
parmJCheckBox.setToolTipText(getProperty_ElementToolTipText(elementGUI_Element));
mergeLayoutElementLabelFontProperties(elementGUI_Element);
String
strFontName = getProperty_FontName(elementGUI_Element);
int
intFontSize
= getProperty_FontSize(elementGUI_Element);
int
intFontStyle
= getProperty_FontStyle(elementGUI_Element);
Font
fntFont =
new
Font(strFontName,
intFontStyle,
intFontSize);
parmJCheckBox.setFont(fntFont);
Color
clrFontColor =
getProperty_FontColor(elementGUI_Element);
parmJCheckBox.setForeground(clrFontColor);
/*
* de: 'Enabled'/'Disabled' Status vom Anfang der Methode wieder zuordnen.
* en: Restore the 'enabled'/'disabled' status from the begin of the method
.
*/
parmJCheckBox
.setEnabled(
bolGUIElementEnabled
);
}
else
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;}
return
StatusCode
;
}
/*
* **************************************************
*/
/*
* de:
* METHODE zum Übertragen der in
der XML-Struktur definierten Eigenschaften auf die 'Tabs' (Reiter)
* für die Panels innerhalb eines JTabbedPane.
* Für detailierte
Erklärungen zur allgemeinen Funktion des Codes sehen Sie bitte bei der
Methode
*
processJTextField
nach.
*
en:
* METHOD to transfer the properties defined in the
XML-structure to the 'Tabs' for the JPanels within
* the
GUI-element of type JTabbedPane.
* Please
see the comments at the method processJTextField for a detailed
explanation of the common code.
*/
public
int
processJTabbedPane(JTabbedPane
parmJTabbedPane, String parmstrFrameClassName) {
/*
* de:
* Die untergeordneten GUI-Elemente innerhalb des als Parameter übergebenen JTabbedPane
ermitteln
* und jedes einzelne innerhalb der for-Schleife bearbeiten.
*
en:
* Get the subordinate GUI-Elements within the JTabbedPane passed as parameter and process each within
* the
for-loop.
*/
int
intComponentCount = parmJTabbedPane.getComponentCount();
int
intComponentIndex;
for
(intComponentIndex = 0; intComponentIndex < intComponentCount; intComponentIndex++) {
/* de:
* Herausholen des untergeordneten GUI-Elements und vergleichen, ob es von der Klasse 'JPanel' ist.
* Nur ein 'JPanel' wird weiter bearbeitet.
*
en:
* Get the subordinate GUI-Element and compare if it is of class 'JPanel', Only a 'JPanel' is
*
processed further
.
*/
Component comp =
parmJTabbedPane.getComponentAt(
intComponentIndex
);
if
(! (comp
instanceof
JPanel))
continue
;
/* de:
* Component wieder einem JPanel zuweisen (cast) und den Namen des JPanel auslesen.
*
en:
* Cast the Component to a JPanel again and get the name of the JPanel
.
*/
JPanel locJPanel = (JPanel) comp;
String
strJPanelName = locJPanel.getName();
/* de:
* Wenn dem JPanel kein Name zugewiesen ist kann auch kein passendes XML-Element gefunden werden;
* weiter in der for-Schleife mit dem nächsten JPanel innerhalb des JTabbedPane
.
*
en:
* If a name was not assigned to the JPanel then it is impossible to find a fitting XML-element;
* in that case continue the for-loop with the next JPanel
.
*/
if
(
strJPanelName
==
null
)
continue
;
/* de:
* XML-Element für den Namen des JPanels aus der XML-Struktur auslesen. Wenn
kein passendes XML-Element
*
gefunden wurde
dann weiter in der for-Schleife mit dem nächsten JPanel innerhalb des JTabbedPane
.
*
en:
* Get the XML-Element fitting to the name of the JPanel out of the XML-structure
.
If a fitting
* XML-element was not found then continue the for-loop with the next JPanel.
*/
Element
elementGUI_Element;
elementGUI_Element
= getGUI_Element(parmstrFrameClassName,
strJPanelName
);
if
(elementGUI_Element
==
null
)
continue
;
/*
* de: Eigenschaftem aus der XML-Datei dem GUI-Element zuordnen.
* en: Attach the properties from the XML-file to the GUI-Element
.
*/
parmJTabbedPane.setTitleAt(intComponentIndex,
getProperty_ElementText(elementGUI_Element));
parmJTabbedPane
.setToolTipText
At(intComponentIndex,
getProperty_ElementToolTipText(elementGUI_Element));
/* de:
* Layout aus dem XML-Element mit der allgemeinen Definition
'dazumischen' und dann den
* Font und die Farbe für den 'Titel'-Text des jeweiligen 'Tab' (Reiter) zuordnen
.
*
en:
* Merge the Layout from the XML-element with the common definition and then set the font
* and the color for the 'Title'-text of the 'Tab'.
*/
mergeLayoutElementLabelFontProperties(elementGUI_Element);
String
strFontName = getProperty_FontName(elementGUI_Element);
int
intFontSize
= getProperty_FontSize(elementGUI_Element);
int
intFontStyle
= getProperty_FontStyle(elementGUI_Element);
Font
fntFont =
new
Font(strFontName,
intFontStyle,
intFontSize);
/*
* de:
*
Bei einem JTabbedPane kann nur ein gemeinsamer Font für alle 'Title'-Texte zugeordnet
* werden. Sind in der XML-Struktur verschiedene Fonts definiert, wird der Font
* des 'letzten Tabs' verwendet
.
* en:
*
At a JTabbedPane only one common Font can be attached to all 'Title'-texts. If different
* fonts are defined within the XML-structure, only the font of the 'last Tab' is used
.
*/
parmJTabbedPane
.setFont(fntFont);
/* *** */
Color
clrFontColor =
getProperty_FontColor(elementGUI_Element);
parmJTabbedPane
.setForeground
At(intComponentIndex,
clrFontColor);
}
StatusCode
=
CONST_OK
;
return
StatusCode
;
}
/*
* **************************************************
*/
/* de:
* Methode zum Auslesen des Textes im
XML-Element <InfoMessage>
für
*
ein gesuchtes GUI-Element in einem gesuchten Frame.
*
Das gesuchte GUI-Element wird im Parameter 'parmContainer' und der
*
Name des Frames wird im Parameter 'parmstrFrameClassName' übergeben.
*
Beim Auftreten eines Fehlers wird ein leerer String
zurückgeliefert.
*
Das ist akzeptabel, weil die InfoMessage nur eine unterstützende
Anzeige ist.
*
en:
* Method to get and return the <InfoMessage>
defined for a GUI-Element
*
passed
as parameter parmContainer
*
for
a Frame with the name passed as parameter parmstrFrameClassName.
*
If
an error occurs, an empty String is returned.
*
This
can be accepted as the InfoMessage is a supporting indication only.
*/
public
String
getInfoMessage(Container parmContainer, String parmstrFrameClassName)
{
/*
*
Variables:
*/
/* de:
*
Passendes Element aus der XML-Structur; diese enthält auch
das XML-Element
* für die anzuzeigende 'InfoMessage'
wenn das GUI-Element den 'Focus' hat.
*
en:
*
Fitting element out of the XML-structure and
* elements
representing all properties to be transferred to the JCheckBox.
*/
Element
elementGUI_Element;
/*
de:
* Name
des GUI-Elements; verwendet als Identifikation um das passende
XML-element
*
aus der XML-Struktur zu 'holen'.
*
en:
* Name
of the GUI-Element;
* used
as identifier to get the fitting XML-element out of the
XML-structure. */
String
strComponentName = parmContainer.getName();
/*
de:
*
Methode abbrechen wenn das GUI-Element nicht mit einem Name versehen
ist
*
en:
*
Quit the method if a name is not attached to the GUI-Element.
*/
if
(strComponentName
==
null
)
return
""
;
/*
de:
* Passendes XML-Element holen; dazu die weiter oben
implementiert Methode verwenden.
*
en:
* Get the fitting XML-element using the private
method implemented above. */
elementGUI_Element
= getGUI_Element(parmstrFrameClassName, strComponentName);
if
(elementGUI_Element
==
null
)
return
""
;
/*
de:
* Private Methode zum Auslesen der InfoMessage aufrufen
und den Text an die
*
aufrufende Methode zurückgeben.
*
en:
* Get the InfoMessage using the private method and
return the Text-String. */
String strInfoMessage =
getProperty_ElementInfoMessage(elementGUI_Element);
if
(strInfoMessage
==
null
)
return
""
;
return
strInfoMessage;
}
/*
* **************************************************
*/
/* de:
* Methoden zum Auslesen einzelner Werte aus
dem XML-Element <Element>.
*
en:
* Methods
to get the individual properties out of the XML-element <Element>
*/
private
String
getProperty_ElementText(Element parmelementGUI_Element)
{
Element
elementGUI_ElementText =
parmelementGUI_Element.getChild(
"ElementText"
);
if
(elementGUI_ElementText
!=
null
)
return
elementGUI_ElementText.getTextTrim();
else
return
""
;
}
/*
***** */
private
String
getProperty_ElementToolTipText(Element parmelementGUI_Element)
{
Element
elementGUI_ElementToolTipText =
parmelementGUI_Element.getChild(
"ToolTipText"
);
if
(elementGUI_ElementToolTipText
!=
null
)
return
elementGUI_ElementToolTipText.getTextTrim();
else
return
""
;
}
/*
***** */
private
String
getProperty_ElementInfoMessage(Element parmelementGUI_Element)
{
Element
elementGUI_ElementInfoMessage =
parmelementGUI_Element.getChild(
"InfoMessage"
);
if
(elementGUI_ElementInfoMessage
!=
null
)
return
elementGUI_ElementInfoMessage.getTextTrim();
else
return
""
;
}
/*
***** */
private
String
getProperty_FontName(Element parmelementGUI_Element)
{
Element
elementGUI_ElementFontName =
parmelementGUI_Element.getChild(
"FontName"
);
if
(elementGUI_ElementFontName
!=
null
)
return
elementGUI_ElementFontName.getTextTrim();
else
return
"Default"
;
}
/*
***** */
private
int
getProperty_FontSize(Element
parmelementGUI_Element) {
Element
elementGUI_ElementFontSize =
parmelementGUI_Element.getChild(
"FontSize"
);
if
(elementGUI_ElementFontSize
!=
null
)
{
/*
de:
*
Zeichenkette mit dem numerischen Wert wird auf eine Variable vom Typ
'int'
*
übertragen.
*
en:
*
String with the numeric value has to be transferred to a variable of
*
type 'int'. */
String
strFontSize = elementGUI_ElementFontSize.getTextTrim();
try
{
int
intFontSize
= (
new
Integer(strFontSize)).intValue();
return
intFontSize;
}
catch
(Exception
Exc) {
return
12;}
}
else
/*
de: Font-Größe nicht definiert oder gültig;
Standard-Wert zurückliefern.
*
en: FontSize not defined or not valid; return a default-value.
*/
return
12;
}
/*
***** */
private
Color
getProperty_FontColor(Element parmelementGUI_Element)
{
Element
elementGUI_ElementFontColor =
parmelementGUI_Element.getChild(
"FontColor"
);
if
(elementGUI_ElementFontColor
!=
null
)
{
/*
de:
*
Zeichenkette mit dem numerischen Wert wird auf eine Variable vom Typ
'int'
*
übertragen.
*
en:
*
String with the numeric value has to be transferred to a variable of
*
type 'int'. */
String
strFontColor =
elementGUI_ElementFontColor.getTextTrim();
try
{
int
intFontColor
= (
new
Integer(strFontColor)).intValue();
return
new
Color(intFontColor);
}
catch
(Exception
Exc) {
return
Color.
BLACK
;}
}
else
/*
de: Font-Farbe nicht definiert oder gültig; Standard-Wert
zurückliefern.
*
en: FontColor not defined or not valid; return a default-value.
*/
return
Color.
BLACK
;
}
/*
***** */
private
int
getProperty_FontStyle(Element
parmelementGUI_Element) {
Element
elementGUI_ElementFontStyle =
parmelementGUI_Element.getChild(
"FontStyle"
);
if
(elementGUI_ElementFontStyle
!=
null
)
{
/*
de:
*
Zeichenkette mit dem numerischen Wert wird auf eine Variable vom Typ
'int'
*
übertragen.
*
en:
*
String with the numeric value has to be transferred to a variable of
*
type 'int'. */
String
strFontStyle =
elementGUI_ElementFontStyle.getTextTrim();
try
{
int
intFontStyle
= (
new
Integer(strFontStyle)).intValue();
return
intFontStyle;
}
catch
(Exception
Exc) {
return
Font.
PLAIN
;}
}
else
/*
de: Font-Stil nicht definiert oder gültig; Standard-Wert
zurückliefern.
*
en: FontStyle not defined or not valid; return a default-value.
*/
return
Font.
PLAIN
;
}
/*
***** */
protected
Integer
getProperty_MinimumLength(Element parmelementGUI_Element)
{
Element
elementGUI_ElementMinimumLength
=
parmelementGUI_Element.getChild(
"MinimumLength"
);
if
(elementGUI_ElementMinimumLength
==
null
)
return
null
;
else
{
/*
de:
*
Zeichenkette mit dem numerischen Wert wird auf eine Variable der
Klasse
*
'Integer' übertragen.
*
en:
*
String with the numeric value has to be transferred to a variable of
*
class 'Integer'. */
String
locString
=
elementGUI_ElementMinimumLength.getTextTrim();
Integer locInteger;
try
{
locInteger
=
new
Integer(locString);
return
locInteger;
}
catch
(Exception
Exc) {
return
null
;}
}
}
/*
***** */
protected
Integer getProperty_MaximumLength
(Element parmelementGUI_Element) {
Element
elementGUI_Element
MaximumLength
=
parmelementGUI_Element.getChild(
"MaximumLength"
);
if
(elementGUI_Element
MaximumLength
==
null
)
return null
;
else
{
/* de:
*
Zeichenkette mit dem numerischen Wert wird auf eine Variable der Klasse 'Integer' übertragen.
* en:
*
String
with the numeric value has to be transferred to a variable of
class 'Integer'.
*/
String locString
=
elementGUI_Element
MaximumLength
.getTextTrim();
Integer locInteger
;
try
{
locInteger
=
new
Integer
(
locString
);
return
locInteger
;
}
catch
(Exception Exc) {
return null
;}
}
}
/*
***** */
private
Boolean getProperty_Mandatory(Element parmelementGUI_Element) {
Element
elementGUI_Element
Mandatory
=
parmelementGUI_Element.getChild(
"Mandatory"
);
/* de:
*
Unterschied zu anderen 'Properties': Das Nicht-Existieren bedeutet, daß
* die Eingabe nicht verpflichtend ('Mandatory') ist
.
* en:
*
Difference to other 'Properties': Property not existing means that an entry
*
is not 'Mandatory'.
*/
if
(elementGUI_Element
Mandatory
==
null
)
return new
Boolean(
false
)
;
else
return new
Boolean(
true
)
;
}
/*
***** */
private
BigDecimal getProperty_MinimumValue
(Element parmelementGUI_Element) {
Element
elementGUI_Element
MinimumValue
=
parmelementGUI_Element.getChild(
"MinimumValue"
);
if
(elementGUI_Element
MinimumValue
==
null
)
return null
;
else
{
/* de:
*
Zeichenkette mit dem numerischen Wert wird auf eine Variable der Klasse
* 'BigDecimal' übertragen
.
* en:
*
String
with the numeric value has to be transferred to a variable of
*
class 'BigDecimal'.
*/
String locString
=
elementGUI_Element
MinimumValue
.getTextTrim();
BigDecimal locBigDecimal
;
try
{
locBigDecimal
=
new
BigDecimal
(locString
);
return
locBigDecimal
;
}
catch
(Exception Exc) {
return null
;}
}
}
/*
***** */
private
BigDecimal getProperty_MaximumValue
(Element parmelementGUI_Element) {
Element
elementGUI_Element
MaximumValue
=
parmelementGUI_Element.getChild(
"MaximumValue"
);
if
(elementGUI_Element
MaximumValue
==
null
)
return null
;
else
{
/* de:
*
Zeichenkette mit dem numerischen Wert wird auf eine Variable der Klasse
* 'BigDecimal' übertragen
.
* en:
*
String
with the numeric value has to be transferred to a variable of
*
class 'BigDecimal'.
*/
String locString
=
elementGUI_Element
MaximumValue
.getTextTrim();
BigDecimal locBigDecimal
;
try
{
locBigDecimal
=
new
BigDecimal
(locString
);
return
locBigDecimal
;
}
catch
(Exception Exc) {
return null
;}
}
}
/*
***** */
/*
***** */
private
Integer getProperty_NumberOfDecimals
(Element parmelementGUI_Element) {
Element
elementGUI_Element
NumberOfDecimals
=
parmelementGUI_Element.getChild(
"NumberOfDecimals"
);
if
(elementGUI_Element
NumberOfDecimals
==
null
)
return null
;
else
{
/* de:
*
Zeichenkette mit dem numerischen Wert wird auf eine Variable der Klasse
* 'Integer' übertragen
.
* en:
*
String
with the numeric value has to be transferred to a variable of
*
class 'Integer'.
*/
String locString
=
elementGUI_Element
NumberOfDecimals
.getTextTrim();
Integer locInteger
;
try
{
locInteger
=
new
Integer(
locString
);
return
locInteger
;
}
catch
(Exception Exc) {
return null
;}
}
}
/*
***** */
/* de:
/* 'Wrapper' für die obige Methode; damit die Anzahl der Nachkommastellen
/* ermittelt werden kann wenn ein bestimmtes Eingabefeld (und das Frame in dem es
/* platziert ist) bekannt ist.
/* en:
/* 'Wrapper' for the above method; to be able to get the number of the
/* fractional part of a decimal number if the entry-field (and the frame where
/* the field is located) is known.
*/
public
Integer getProperty_NumberOfDecimals
(String parmSearchedFrameClassName,
String
parmSearchedGUI_ElementName
) {
/* de:
* Methode, die das XML-Element mit allen Eigenschaften ausliest, aufrufen
.
* en:
* Call the method that is reading the XML-Element with all properties
.
*/
Element
elementGUI_Element
=
getGUI_Element(parmSearchedFrameClassName, parmSearchedGUI_ElementName
);
/* de:
* Prüfen ob ein passendes XML-Element gefunden wurde; 'null' zurückliefern wenn nicht
.
* en:
*
Verify if a fitting XML-Element was found; return 'null' to signal if not
.
*/
if
(elementGUI_Element
==
null
)
return null
;
/* de:
*
XML-Element mit 'Eigenschaften' gefunden; private Methode aufrufen um die Anzahl der
* definierten Dezimal
stellen zu ermitteln.
* en:
*
XML-Element with 'properties' found; call the private method to determine the number
* representing the size of the fractional part of the decimal number
.
*/
return
getProperty_NumberOfDecimals(elementGUI_Element
);
}
/*
***** */
/*
* **************************************************
*/
/*
* de:
* METHODE zum Übertragen der in der XML-Struktur definierten Eigenschaften
* auf ein GUI-Element vom Typ JTable.
* Weiters werden die im Parameter 'parmvecRawData' entsprechend den Anweisungen
* in der XML-Struktur angezeigt.
* Wenn eine gültige information über die Spaltenbreite im Parameter
* 'parmarrayColumnWidth' enthalten ist dann werden die Spaltenbreiten danach angepasst.
* en:
*
METHOD to transfer the properties defined in
the XML-structure
* to a GUI-element of type JTable.
* Furthermore the data passed in the parameter 'parmvecRawData' is displayed
* according to the specification in the XML-structure.
* If a valid column-
width information is passed in parameter 'parmarrayColumnWidth'
* then the columns are resized according to this specification.
*/
public synchronized
int
processJTable(JTable parmJTable, String
parmstrFrameClassName,
Vector
parmvecRawData, String[] parmarrayColumnWidth)
{
/*
* Variable / Variables:
*/
/*
* de:
* Array mit den Anzahl der Dezimalstellen für die Werte in jeder Spalte der Tabelle.
* Ein negativer Wert bedeutet, dass in der Tabellenspalte kein numerischer Wert angezeigt wird.
* en:
*
Array with the numbers of decimals for the values in each column of the table.
* A negative value indicates that a non-numeric value is displayed in the table-column.
*/
int
[] arrayDecimalPosition =
new
int
[0];
/*
* de:
* Passendes XML-element für das zu bearbeitende GUI-Element und
* XML-Elemente mit den Eigenschaften die auf die JTable übertragen werden
* en:
*
Fitting XML-element for the GUI-Element to be processed and
* XML-elements
representing all properties to be transferred to the JTable
*/
Element
elementGUI_Element;
Element
elementTableHeaderColumns;
Element
elementColumn;
Element
elementSymbolicName;
String
strSymbolicName;
Element
elementElementText;
String
strElementText;
Element
elementWidth;
String
strWidth;
Element
elementNumberOfDecimals;
String
strNumberOfDecimals;
/*
de: Liste mit XML-Elementen; ihre Größe und Indizes zum Bearbeiten.
* en:
Lists of XML-Element; their size and indexes for processing them.
*/
java.util.List listColumn;
int
intlistColumnSize;
int
intlistColumnIndex;
/*
de:
* Vector für die Anordnung der Spalten entsprechend der Sortierung der symbolischen
* Spalten-Namen aus der XML-Struktur.
* en:
*
Vector used for the arrangement of the columns according to the order of symbolic
* column-names out of the XML-structure.
*/
Vector
vecSymbolicNamesForColumns =
new
Vector();
/*
de:
Vector für die Spalten-Überschriften
aus der XML-Struktur.
* en:
Vector for the column-headers
out of the XML-structure.
*/
Vector
vecHeaderTextForColumns =
new
Vector();
/*
de:
* Hinweis, dass die Definition der Spaltenbreite aus der XML-Struktur verwendet wird
* und nicht die Definition aus dem Parameter.
* Dieser Hinweis ist 'true' wenn die Anzahl der definierten Spalten untterschiedlich ist.
* en:
*
Flag to signal that column-width definitions from XML-structure override the definition
*
passed in the parameter.
* This flag is set to true if the number of
columns does not match. */
boolean
bolUseColumnWidthDefinitionFromXML =
false
;
/*
de:
* Name der JTable; verwendet als Identifikation um das passende GUI-Element aus der
* XML-Struktur lesen zu können.
* en:
* Name of the JTable; used as identifier to get the
fitting GUI-element out of the XML-structure. */
String
strTableName = parmJTable.getName();
/*
de:
*
Prüfen, dass das GUI-Element einen Namen hat; sonst ist das Verhalten des Programms nicht
*
vorhersehbar.
* en:
*
Verify
if the element has a name; otherwise there is unpredicted behaviour.
*/
if
(strTableName ==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
de:
* 'ColumnModel' aus der Tabelle extrahieren und Anzahl der Spalten
ermitteln
.
* Die Spalten-Anzahl kann 0 sein wenn die Tabelle noch nicht gefüllt ist.
* en:
*
Extract 'ColumnModel' and number of existing columns.
* The number of the columns might be 0 if the table was not already populated
.
*/
TableColumnModel locColumnModel = parmJTable.getColumnModel();
int
intTableColumnCount = locColumnModel.getColumnCount();
/*
de:
* 'TableColumnListener' aus dem TableColumnModel ermitteln und in einer lokalen Variable
* aufheben. Das ist notwendig, weil die beim Füllen mit neuen Werten das TableModel (und damit
* auch das TableColumnModel) ausgetauscht wird und der Listener dann wieder dem neuen
* TableColumnModel hinzugefügt werden muss.
* en:
*
Extract the 'TableColumnListener' from the TableColumnModel and keep it in a local Variable.
* That is neccessary because the TableModel (and the included TableColumnModel) is changed when
* the table is populated with new values. Thereafter the Listener can be added to the new
* TableColumnModel
.
*/
TableColumnModelListener[] arrayTableColumnModelListener =
(
TableColumnModelListener[]
) parmJTable.getListeners(TableColumnModelListener.
class
);
TableColumnModelListener locTableColumnModelListener =
null
;
/*
de:
* Wenn ein 'TableColumnListener' vorhanden ist wird dieser in der lokalen Variable aufgehoben.
* Zusätzlich wird der Listener vom TableColumnModel entfernt damit die Events verhindert werden
* wenn in dieser Methode die Spaltenbreite neu festgelegt wird
.
* en:
* If a
'TableColumnListener' is attached the this Listener will be kept in the local variable.
* Additionally, the Listener is removed from the TableColumnModel to prevent Events when the
* width of columns is set new within this method
.
*/
if
(arrayTableColumnModelListener.
length
> 0) {
locTableColumnModelListener = array
TableColumnModelListener[0]
;
locColumnModel.removeColumnModelListener(loc
TableColumnModelListener)
;
}
/*
de:
*
Das für das GUI-Element passende XML-Element aus der XML-Struktur extrahieren.
* Dazu eine andere Methode dieser Klasse verwenden.
* en:
* Get
the XML-Element for the fitting GUI-element out of the XML-structure.
*
Use another method of this class to do this job.
*/
elementGUI_Element
= getGUI_Element(parmstrFrameClassName, strTableName);
if
(elementGUI_Element ==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
de:
* XML-Element mit den Unter-Elementen für die Eigenschaften einzelner Spalten der
* JTable extrahieren.
* en:
* Extract the XML-element with all sub-elements defining the properties for
*
the
columns of a JTable. */
elementTableHeaderColumns
= elementGUI_Element.getChild(
"TableHeaderColumns"
);
if
(elementTableHeaderColumns ==
null
)
{
StatusCode
=
CONST_GUI_ELEMENT_NOT_PRESENT
;
return
StatusCode
;
}
/*
de:
* Extrahieren der Liste mit den XML-Elementen für die Eigenschaften einer Spalte.
* en:
*
Get the list of XML-elements defining properties for each 'column'.
*/
listColumn
=
elementTableHeaderColumns.getChildren(
"Column"
);
intlistColumnSize
= listColumn.size();
/*
de:
* Prüfen ob die Zahl der Spalten aus der XML-Struktur noch mit der Anzahl im
* Array, das als Parameter übergeben wurde.
* Diese Prüfung bestimmt, ob die Zahl der Spalten in der XML-Struktur geändert wurde.
* en:
* Check if the number of columns out of the XML-structure
still fits
* the size of the array passed as
parameter.
* This check determines if the number of columns in the XML-structure has changed.
*/
if
(intlistColumnSize != parmarrayColumnWidth.
length
)
{
/* de:
* Anzahl der Spalten ist unterschiedlich; Array, das in den Parametern übergeben wurde,
* ersetzen und Markierung setzen, die zeigt, das die Anzahl und Breite der Spalten aus
* der XML-Struktur genommen werden muss.
* en:
* Number of columns is different
; replace the array passed as parameter and set the flag
*
to indicate that the number and width for the columns has to be taken from the
*
XML-structure. */
parmarrayColumnWidth
=
new
String[intlistColumnSize];
bolUseColumnWidthDefinitionFromXML
=
true
;
}
/*
* de:
* Array mit der Anzahl der Dezimalstellen mit der Anzahl von Elementen, die der Zahl der Spalten
* in der Tabelle entspricht, initialisieren
.
* en:
* Initialize the array with the number of decimals with the number of elements that coincides with
* the number of columns in the table
. */
arrayDecimalPosition =
new int
[intlistColumnSize];
/*
* de:
* Jedes XML-Element aus der Liste verarbeiten.
* en:
* Process each XML-element of the list. */
for
(intlistColumnIndex = 0;
intlistColumnIndex
< intlistColumnSize;
intlistColumnIndex++)
{
/*
de:
* Einzelnes XML-Element, das die Eigenschafter einer Tabellenspalte repräsentiert,
* aus der Liste holen.
* en:
*
Retrieve one XML-element representing the properties of a column. */
elementColumn
= (Element) listColumn.get(intlistColumnIndex);
/*
de:
* Wenn das gesuchte XML-Element Daten enthält dann die Elemente unterhalb bearbeiten.
* en:
*
If the requested XML-element contains data then process the elements underneath
it. */
if
(elementColumn !=
null
)
{
/*
de:
* Die Sortierung der 'Column'-Elemente innerhalb der XML-STruktur bestimmt die
* Reihenfolge wie die Spalten innerhalb der JTable angeordnet sind.
* en:
*
The order of the 'Column' elements within the XML-structure defines the order how the
*
columns
of data are arranged within the JTable
*/
elementSymbolicName
= elementColumn.getChild(
"SymbolicName"
);
/*
de:
* Der 'SymbolicName' ist der Programm-interne Name der Variable.
* Dieser symbolische Name ist auch in der Zeile 0 des RawDataVector (der als Parameter
* übergeben wurde) vorhanden.
* Die Reihenfolge in der XML-Struktur bestimmt den Zusammenhang in welcher Spalte der JTable
* die Daten aus einer Spalte des RawDataVectors angezeigt werden soll.
* Das Füllen der JTable erfolgt später.
* en:
*
The 'SymbolicName' is the program-internal name of a
variable.
* This symbolic name is also present in row 0 of
the RawDataVector (passed as parameter)
* and defines
in coordination in which column of the JTable the data of the specified column
*
of the
RawDataVector should be displayed. The filling of
the JTable is done later */
if
(elementSymbolicName !=
null
)
strSymbolicName = elementSymbolicName.getTextTrim();
else
strSymbolicName =
""
;
vecSymbolicNamesForColumns.addElement(strSymbolicName);
/* de:
* Der 'ElementText' enthält den sprachabhängigen Text für den Spalten-Kopf einer JTable.
* en:
* The
'ElementText' contains the language-specific text for the column-header of the JTable */
elementElementText
= elementColumn.getChild(
"ElementText"
);
if
(elementElementText !=
null
)
strElementText = elementElementText.getTextTrim();
else
strElementText =
""
;
vecHeaderTextForColumns.addElement(strElementText);
/*
* de:
* Wenn die Spaltenbreite in dem als Parameter übergebenen Array nicht mehr gültig
* ist, dann werden die Werte für die Spaltenbreite im Array aus den Informationen
* aus der XML-Struktur (XML-Element 'ColumnWidth') neu gefüllt.
* en:
* If the column-width in the array passed as parameter is no longer valid then the
* values in the array are refilled with the informations from the XML-structure
* (XML-Element 'ColumnWidth').
*/
if
(bolUseColumnWidthDefinitionFromXML) {
elementWidth
= elementColumn.getChild(
"Width"
);
if
(elementWidth !=
null
)
strWidth = elementWidth.getTextTrim();
else
strWidth =
""
;
parmarrayColumnWidth[intlistColumnIndex]
= strWidth;
}
/* de:
* Prüfen ob ein XML-Element mit der Anzahl der Dezimalstellen vorhanden ist.
* en:
* Verirfy if a XML-Element with the number of decimal positions is present */
elementNumberOfDecimals
= elementColumn.getChild(
"NumberOfDecimals"
);
if
(elementNumberOfDecimals ==
null
)
/* de:
* Kein XML-Element für die Dezimalstellen: die Tabellenspalte enthält Text.
*
Diese Tatsache durch einen negativen Wert im Array kennzeichnen.
* en:
* No XML-Element for the number of decimals: the table-column contains text.
* Mark this with a negative value within the array
. */
arrayDecimalPosition[intlistColumnIndex] = -1;
else
{
/* de:
* Wert des XML-Element ermitteln, Text in 'int' umwandeln und im Array aufheben.
* en:
* Get the value of the XML-element, convert text into 'int' and save in the array
. */
strNumberOfDecimals = elementNumberOfDecimals.getTextTrim();
try
{
arrayDecimalPosition[intlistColumnIndex] =
(
new
Integer(strNumberOfDecimals)).intValue();
}
catch
(Exception e) {
/* de:
* Wert aus dem XML-Element ist nicht numerisch; nicht als Fehler behandeln sondern so,
* wie wenn die Tabellenspalte keinen numerischen Wert enthalten würde
.
* en:
* Value in the XML-Element is not numeric; do not handle it as an error but assume that
* the table-column does not contain a numeric value
. */
arrayDecimalPosition[intlistColumnIndex] = -1;
}
}
}
}
/*
* de: Wiedererstellen des Inhalts der JTable.
*
en: Rebuild
the content of the JTable. */
/*
* de:
* Zuerst einen Vector erstellen der die Spaltenüberschriften und die Werte,
*
die in der JTable angezeigt werden, enthält.
* Das Erstellen des Vectors erfolgt in einer eigenen Methode um diese Methode nicht
* mit Code zu überladen.
* en:
*
First,
build a vector containing the column-headers and values displayed in the JTable.
* The built
is done in an own method to avoid overloading of this
method. */
Vector
vecTableData = getFieldData(parmvecRawData,
vecSymbolicNamesForColumns, arrayDecimalPosition);
/*
* de:
* Zweitens, der Inhalt der JTable wird wieder gefüllt.
* Die Prozedur ist ein wenig kompliziert weil Werte in Tabellen-Zellen nicht direkt
* über die Angabe von Zeile und Spalte angesprochen werden können.
* en:
* Second,
refill the content of the JTable.
* The procedure is a
little bit compicated as values in table-cells can not be directly
* adressed by row/column. */
JTable
locJTable =
new
JTable(vecTableData, vecHeaderTextForColumns);
TableModel
locTableModel =
locJTable.getModel();
parmJTable.setModel(locTableModel);
/*
* de:
* Renderer für alle Spalten, in denen ein numerischer Wert angezeigt werden soll,
* durch JSBS_TableCellRenderer ersetzen. Damit wird der Werr 'rechtsbündig' angezeigt
.
* en:
*
Replace the renderer for all columns that will display a numeric value by JSBS_TableCellRenderer.
* This will 'right-justify' the displayed value within the table-cell. */
JSBS_TableCellRenderer renderer =
new
JSBS_TableCellRenderer(arrayDecimalPosition)
;
for
(
int
intTableColumnIndex = 0; intTableColumnIndex < parmJTable.getColumnCount();
intTableColumnIndex++) {
/* de:
* Sicherheitsprüfung ob das Array mit den Dezimalstellen auch noch einen Wert für diese Spalte hat
.
* en:
*
Assertion that the array with the number of decimals contains a value for this column. */
if
(intTableColumnIndex < arrayDecimalPosition.
length
)
/* de:
* Wenn ein numerischer Wert angezeigt werden soll dann wird der Renderer für die betreffende Spalte ersetzt
.
* en:
*
If a numeric value should be displayed the the renderer for the concerned column is replaced. */
if
(arrayDecimalPosition[intTableColumnIndex] >= 0
)
parmJTable.setDefaultRenderer(parmJTable.getColumnClass
(intTableColumnIndex), renderer);
}
/*
* de:
* Einige Möglichkeiten der JTable ausschalten; das wird getan um den/die Anwender/in nicht
* zu verwirren wenn sie/er die Breite einer einzelnen Spalte ändert oder
* versehentlich die Reihenfolge der Spalten ändern oder eine ganze Spalte auswählen will.
* en:
*
Disable
some features of JTable; this is done that a user does not get
confused if
* she/he changes the width of a single
column
* or erratically changes the column-order or
selects a whole
column. */
parmJTable.setAutoResizeMode(JTable.
AUTO_RESIZE_SUBSEQUENT_COLUMNS
);
parmJTable.getTableHeader().setReorderingAllowed(
false
);
parmJTable.getColumnModel().setColumnSelectionAllowed(
false
);
/*
* de:
* Breite der Spalten setzen.
* Im Array mit der Breite der Spalten können unter Umständen nur Verhältnis-Werte stehen
* wenn das Array mit Werten aus der XML-Struktur gefüllt wurde.
* Deswegen muss ein Verhältniswert zwischen der 'echten' Breite der JTable und der Summe
* der Werte aus dem Array berechnet werden.
* en:
*
Set
the width of the columns.
* The array with the column-width might contains only relative values if the array was filled
* with the values out of the XML-structure.
* Therefore it is necessary to calculate a ratio betwwen the 'real' width of the JTable and
* the sum of the values in the array
. */
locColumnModel
= parmJTable.getColumnModel();
/* de: Anzahl der Bildpunkte die für alle Spalten zusammen vorhanden sind.
* en:
Number
of pixels that are available for all columns. */
int
intTableTotalColumnWidth
= locColumnModel.getTotalColumnWidth();
/* de:
* Summe der Bildpunkte die sich aus den 'ColumnWidth' in der XML-Struktur ergibt.
* Zusammen mit der Anzahl der Bildpunkte für alle Spalten zusammen wird später
* der Verhältniswert errechnet.
* en:
*
Sum
of pixels that is given by the 'ColumnWidth' in the
XML-structure.
* Together with the sum of pixels
available in the table, a ratio is calculated later.
*/
int
intDefinedTotalColumnWidth
= 0;
/* de: Hilfsvariable für die festgelegte Breite einer Spalte
*
en: Auxilliary
variable to hold the defined width of one column. */
int
intSingleColumnWidth;
/*
* de:
* Vorbereitungen zum Berechnen des Verhältnisses zwischen der tatsächlichen Anzahl
* der Bildpunkte für alle Spalten einer JTable und der Summe der relativen
*
Spaltenbreiten aus dem Array.
* Dieser Algorithmus ist nötig um aus den relativen Spaltenbreiten aus der XML-Struktur
* (welche verwendet wird wenn im Array aus der Datenbank die Anzahl der Spalten nicht
*
mehr mit der Zahl
der Spalten
aus der XML-Struktur übereinstimmt) die tatsächliche
*
Anzahl der Bildpunkte
zu berechnen.
* Weiters korrigiert dieser Algorithmus auch, wenn die Tabelle gefüllt wird bevor
* die ursprünglich vom Anwender gewählte Größe wieder hergestellt wurde.
* en:
* Preparations for the calculation of the ratio between the real number of pixels
* for all columns of the JTable and the sum of the relative column-width
* out of the Array
.
* This algorithm is neccessary to calculate the real number of pixels out of the
* relative column-widths of the XML-structure - which is used if the number of columns
* in the Array loaded from the database does not fit the number of columns
out of the
* XML-structure.
* Furthermore, this algoritm corrects the if the table is filled before the original
* size of the frame - as chosen by the user - is restored.
*/
/*
*
de: Addieren der Gesamtzahl der Bildpunkte die im Array definiert sind.
* en: Accumulate
the number of pixels as defined in the array. */
intTableColumnCount
= parmarrayColumnWidth.
length
;
for
(
int
intTableColumnIndex
= 0;
intTableColumnIndex
< intTableColumnCount;
intTableColumnIndex++)
{
/* de:
Umwandeln des Wertes (Typ String) im Array in einen int-Wert.
* en:
Convert
the value (type String) in the array to an int-value. */
try
{
intSingleColumnWidth
=
Integer.parseInt(parmarrayColumnWidth[intTableColumnIndex]);
}
catch
(Exception exc) { intSingleColumnWidth = 1;}
/* de: Den Wert zur Summe der Spalten-Breiten aus dem Array addieren.
* en:
Add
the value to the sum of the column width out of the array.
*/
intDefinedTotalColumnWidth
+= intSingleColumnWidth;
}
/*
* de: Festlegen der wirklichen Spaltenbreiten der JTable.
* en: Set
the real column-with of the JTable. */
for
(
int
intTableColumnIndex
= 0;
intTableColumnIndex
< intTableColumnCount;
intTableColumnIndex++)
{
/* de:
Umwandeln des Wertes (Typ String) im Array in einen int-Wert.
* en:
Convert
the value (type String) in the array to an int-value. */
try
{
intSingleColumnWidth
=
Integer.parseInt(parmarrayColumnWidth[intTableColumnIndex]);
}
catch
(Exception exc) { intSingleColumnWidth = 1;}
/*
* de:
* Berechnen der tatsächlichen Spaltenbreite einer Spalte wenn im Array
* die relativen Spaltenbreiten aus der XML-Struktur enthalten sind.
* en:
*
If the relative column-widths from
the XML-structure were taken,
* adapt the column-width in accordance with the total width of the
table.
*/
if
(bolUseColumnWidthDefinitionFromXML)
intSingleColumnWidth
=
intSingleColumnWidth
* intTableTotalColumnWidth / intDefinedTotalColumnWidth;
/*
* de: Festlegen der wirklichen Breite einer einzelnen Spalte.
* en:
Set
the real width of a single column.
*/
locColumnModel.getColumn(intTableColumnIndex).setPreferredWidth(intSingleColumnWidth);
}
/*
* de: Abstand zwischen angezeigtem Wert und linken bzw. rechten Spaltenrand vergrößern.
* en:
Enlarge the distance between the displayed value and the left and right column-border.
*/
locColumnModel.setColumnMargin(7);
/*
* de:
*
Wenn als Parameter übergebene JTable einen ColumnModelListener enthalten hat dann diesen
* wieder zum ColumnModel hinzufügen
.
* en:
*
If the JTable, passed as parameter, contained a ColumnModelListener then this Listener is
* added to the ColumnModel again
.
*/
if
(
loc
TableColumnModelListener
!=
null
)
locColumnModel.addColumnModelListener(
loc
TableColumnModelListener
);
/*
* de:
* Status-Code dieser Klasse an die aufrufende Methode zurückliefern;
* dieser meldet wenn ein Fehler während der Verarbeitung aufgetreten ist.
*
en:
*
Return the Status-code of this class; it reflects if
errors occured during processing. */
return
StatusCode
;
}
/*
* **************************************************
*/
/*
* de:
* METHODE zum Erstellen des Daten-Vektors der gebraucht wird um die Felder der JTable
* zu füllen. Die Spalten der JTable sind so sortiert wie im als Parameter übergebenen
* 'parmvecSymbolicNames' festgelegt ist.
* Dieser Parameter folgt der Reihenfolge die in der Datei 'DisplayStrings.xml' festgelegt ist.
* Mit dem Array im Parameter 'parmArrayDecimalPositions' wird für jede Tabellenspalte die Anzahl
* der Positionen nach dem Dezimalpunkt übergeben.
* Für nicht numerische Text) Tabellenspalten enthält das Array-Element eine negative Zahl.
* en:
* METHOD to build the data-vector that is
needed to fill the fields of a JTable.
* The columns of
the JTable are sorted according to the definition passed
with
* parameter 'parmvecSymbolicNames'.
* This
parameter reflects the order defined in file
'DisplayStrings.xml'.
* With the array 'parmArrayDecimalPositions', the number of digits after the decimal-separator
* is passed.
* For non-numeric (text) table-columns, the array-element contains a negative number.
*/
private
Vector
getFieldData(Vector parmvecRawData,
Vector
parmvecSymbolicColumnNames
,
int
[] parmArrayDecimalPositions
) {
/*
* Variable / Variables:
*/
/*
* de: Vector der zurück geliefert wird.
*
en; Vector
to be returned. */
Vector
vecTableData =
new
Vector();
/*
* de: Anzahl der Zeilen im - als Parameter übergebenen - Rohdaten-Vektor und Index dafür.
* en:
Number
of rows in the raw data passed as parameter and index for it.
*/
int
intvecRawDataSize
= parmvecRawData.size();
int
intvecRawDataIndex;
/*
* de:
* Ermitteln der Reihenfolge der Spalten im Rohdaten-Vektor.
* Diese Information ist im ersten Element des Vectors (index 0).
* en:
* Get the o
rder
of columns of the raw data vector.
* This information
is in the first element of the vector (index 0). */
Vector
vecRawDataSymbolicColumnNames =
new
Vector();
if
(intvecRawDataSize
> 0) {
vecRawDataSymbolicColumnNames
= (Vector) parmvecRawData.elementAt(0);
}
/*
* de: Anzahl der Zeilen im übergebenen Rohdaten-Vektor und Index dafür.
* en:
Number
of rows in the raw data passed as parameter and index for it.
*/
int
intvecRawDataSymbolicColumnNamesSize
= vecRawDataSymbolicColumnNames.size();
int
intvecRawDataSymbolicColumnNamesIndex;
/*
* de:
* Anzahl der Spalten des Vektors mit den symbolischen Namen - der als Parameter
* übergeben wurde und die Reihenfolge der Tabellen-Spalten
festlegt - und Index dafür.
* en:
*
Number
of columns of the vector with the symbolic names (passed as parameter
and
* defining the ordering of table-columns) and index for
it. */
int
intvecSymbolicColumnNamesSize
= parmvecSymbolicColumnNames.size();
int
intvecSymbolicColumnNamesIndex;
/*
* de: Einige Variablen aus Zeichenketten zum Verarbeiten des Inhalts des Vektors.
* en:
Some
String-variables to handle the content of the vectors.
*/
String
strFieldValue;
String
strRawDataSymbolicColumnName;
String
strSymbolicColumnName;
/*
* de: Vektor mit einer 'Zeile' innerhalb des Rohdaten-Vektors.
* en:
Vector
representing one 'row' within the raw data vector. */
Vector
vecRawDataRow;
/*
* de:
* Ermitteln des Charakters für den Dezimalpunkt.
* Dieser ist abhängig von der Sprache und in der Struktur der Universal-Parameter enthalten.
* Aus Kompatibilitätsgründen mit älteren Versionen kann diese Struktur nicht vorhanden sein -
* in diesem Fall wird ein Punkt ('.') verwendet.
* en:
* Determine the character for the decimal-seperator.
* This depend on the language and is a part of the structure of the universal-parameters.
* For compatibility reasons with older versions this structur may not exist - in that case
* a point ('.') is used
. */
char
chrDecimalPoint = '.';
if
(frmCC !=
null
)
chrDecimalPoint =
frmCC
.
structJSBS_UniversalParameters
.
strLanguageDependantDecimalPoint
.charAt(0)
;
/*
* de:
* Durchgehen jeder 'Zeile' der Rohdaten.
* Das beginnt mit Index 1 weil das Element mit Index 0 die symbolischen Spaltennamen enthält.
* en:
* Go
through each 'row' of the raw data.
* This starts with
index 1 as the element with index 0 contains the symbolic column
names. */
for
(intvecRawDataIndex = 1;
intvecRawDataIndex
< intvecRawDataSize;
intvecRawDataIndex++)
{
/*
* de: Herausholen eines Elements das eine 'Zeile' der Tabelle repräsentiert.
* en:
Retrive one element representing a 'row' for the table.
*/
vecRawDataRow
= (Vector) parmvecRawData.elementAt(intvecRawDataIndex);
/*
* de: Erstellen eines Vektors der eine 'Zeile' in der JTable sein wird.
* en:
Create a vector which will be the 'row' for the JTable.
*/
Vector
vecJTableDataRow =
new
Vector();
/*
* de:
* Durchgehen des Vektors mit den symbolischen Spaltennamen für die Anordnung der
* Spalten in der Anzeige (Tabelle).
* Dieser Vektor wurde entsprechend den Eintragungen in der Datei 'DisplayStrings.xml'
* aufgebaut.
* en:
* Go
through vector with the Symbolic Column Names in the order for
display (table).
* This vector is build according the order in
file 'DisplayStrings.xml'. */
for
(intvecSymbolicColumnNamesIndex =
0;
intvecSymbolicColumnNamesIndex
<
intvecSymbolicColumnNamesSize;
intvecSymbolicColumnNamesIndex++)
{
/*
* de: Namen der symbolischen Spalte aus dem Vektor auslesen.
* en:
Get the name of the symbolic column out of the vector.
*/
strSymbolicColumnName
=
(String)
parmvecSymbolicColumnNames.elementAt(intvecSymbolicColumnNamesIndex);
/*
* de:
* Füllen des Feldes das in der JTable angezeigt wird mit einer leeren Zeichenkette.
* Das ist eine Vorkehrung wenn in der folgenden Verarbeitung kein Wert gefunden wird.
* en:
*
Fill the field to be displayed in JTable with an empty
string.
* This is a precaution if no value is found in
the following processing. */
strFieldValue
=
""
;
/*
* de:
* Herausfinden in welcher Spalte des Vectors mit den Rohdaten die angeforderte Spalte
* (festgelegt durch den symbolischen Namen, der in eine übergeordneten for-Schleife
* ermittelt wurde) ist.
* en:
* Find
out in which column of the raw data vector the requested
column
* (defined by the symbolic column name acquiered
in the higher-ranking for-loop) is. */
for
(intvecRawDataSymbolicColumnNamesIndex =
0;
intvecRawDataSymbolicColumnNamesIndex
<
intvecRawDataSymbolicColumnNamesSize;
intvecRawDataSymbolicColumnNamesIndex++)
{
/*
* de: Vergleichen ob die 'Spalte' im Rohdaten-Vektor übereinstimmt.
* en:
Compare, if the 'column' in the raw data vector matches.
*/
strRawDataSymbolicColumnName
=
(String)
vecRawDataSymbolicColumnNames.elementAt(intvecRawDataSymbolicColumnNamesIndex);
if
(((strRawDataSymbolicColumnName.trim()).compareTo(
strSymbolicColumnName.trim()))
== 0) {
/*
* de: Passende 'Spalte' in den Rohdaten gefunden.
* en:
Fitting 'column' in the raw data found. */
/*
* de:
* Zuerst prüfen ob der Vektor, der eine 'Zeile' repräsentiert, wirklich alle Daten enthält.
* Ein Fehler sollte theoretisch nicht passieren - aber wenn er doch passiert verhindert diese
* Prüfung einen 'Dump' des Programms.
* en:
*
First check if the
vector representing a 'row' really contains all data.
* This
should not happen theoretically – but if it happens this check prevents a 'dump' of the program.
*/
if
(vecRawDataRow.size() > intvecRawDataSymbolicColumnNamesIndex)
{
/*
*
de:
* Spezielle Behandlung wenn das Vector-Element einen 'null'-Wert enthält: die Tabellenzelle bleibt leer.
* en:
* Special code if the vector-element contains a 'null'-value: the table-cell stays empty
. */
if
(vecRawDataRow.elementAt(
intvecRawDataSymbolicColumnNamesIndex
) !=
null
)
{
/*
*
de:
* Mit den folgenden 'instanceof' Abfragen wird ermittelt welche Klasse das Element im Vektor hat
* und danach die entsprechende Formatierung ausgeführt bzw. ein 'String' 'so wie er ist' angezeigt.
* en:
* With the following 'instanceof' comparisons it is determined which class the element in the vector
* is of. Thereafter the suitable formatting is performed or a 'String' is displayed 'as is'.
/*
*
de: Abfrage ob das Vector-Element ein 'String' ist.
* en:
Comparison if the vector-element is a 'String'
. */
if
(vecRawDataRow.elementAt(
intvecRawDataSymbolicColumnNamesIndex
)
instanceof
String)
{
strFieldValue
= (String)
vecRawDataRow.elementAt(intvecRawDataSymbolicColumnNamesIndex);
}
/*
*
de: Abfrage ob das Vector-Element ein 'Short' ist - in diesem Fall Methode zum Formatieren aufrufen.
* en:
Comparison if the vector-element is a 'String'
. */
if
(vecRawDataRow.elementAt(
intvecRawDataSymbolicColumnNamesIndex
)
instanceof
Short)
{
strFieldValue
= JSBS_Formatter.toFormattedString(
(Short)
vecRawDataRow.elementAt(intvecRawDataSymbolicColumnNamesIndex),
chrDecimalPoint,
parmArrayDecimalPositions[
intvecSymbolicColumnNamesIndex
])
;
}
/*
*
de: Abfrage ob das Vector-Element ein 'Integer' ist - in diesem Fall Methode zum Formatieren aufrufen.
* en:
Comparison if the vector-element is a 'String'
. */
if
(vecRawDataRow.elementAt(
intvecRawDataSymbolicColumnNamesIndex
)
instanceof
Integer)
{
strFieldValue
= JSBS_Formatter.toFormattedString(
(Integer)
vecRawDataRow.elementAt(intvecRawDataSymbolicColumnNamesIndex),
chrDecimalPoint,
parmArrayDecimalPositions[
intvecSymbolicColumnNamesIndex
])
;
}
/*
*
de: Abfrage ob das Vector-Element ein 'BigDecimal' ist - in diesem Fall Methode zum Formatieren aufrufen.
* en:
Comparison if the vector-element is a 'String'
. */
if
(vecRawDataRow.elementAt(
intvecRawDataSymbolicColumnNamesIndex
)
instanceof
BigDecimal)
{
strFieldValue
= JSBS_Formatter.toFormattedString(
(BigDecimal)
vecRawDataRow.elementAt(intvecRawDataSymbolicColumnNamesIndex),
chrDecimalPoint,
parmArrayDecimalPositions[
intvecSymbolicColumnNamesIndex
])
;
}
}
}
/*
*
de: Wert des Feldes übertragen; Loop muss nicht fortgesetzt werden.
*
en:
Field-value transferred; no more need to continue within the loop.
*/
break
;
}
}
/*
*
de: Aufbereiteten Wert des Feldes in den Vektor, der eine Zeile der JTable repräsentiert, einfügen.
*
en:
Add the acquiered field-value to the vector representing one row of
the JTable.
*/
vecJTableDataRow.addElement(strFieldValue);
strFieldValue
=
new
String();
}
/*
*
de: Den Vektor, der eine Tabellenzeile darstellt, zum Vektor mit allen Zeilen hinzufügen.
*
en:
Add the vector representing one row of the JTable to the vector with
all rows.
*/
vecTableData.addElement(vecJTableDataRow);
}
return
vecTableData;
}
/*
*
************************************************** */
/*
* de:
* Methode um den Inhalt von <InfoMessage> eines Elements, dass zum <SupplementaryText> Bereich
* der XML-Struktur gehört, auszulesen.
* Für diese Methode ist ein Beispiel-Aufruf beschrieben.
* en:
*
Method
to get the <InfoMessage> of an Element belonging to the
* <SupplementaryText> division of the
XML-structure */
public
String
getSupplementaryText(String parmstrElementName)
{
/*
* Variable / Variables:
*/
/*
* de:
* XML-Element für den <SupplementaryText> Bereich, XML-Element für ein <Element> innerhalb des Bereichs,
* XML-Elemente und Zeichenketten für <ElementName> und <InfoMessage>.
* en:
*
XML-Element
for the <SupplementaryText> Division, XML-Element for one
<Element> within the Division,
* XML-Elements and text-Strings for
<ElementName> and <InfoMessage>. */
Element
elementSupplementaryText;
Element
elementElement;
Element
elementElementName;
String
strElementName;
Element
elementInfoMessage;
String
strInfoMessage;
/*
* de: Liste aller <Element>-elemente, Anzahl und Index zum Durchsuchen.
*
en:
List of all <Element>-elements, size and index for searching
it. */
java.util.List listElements;
int
intlistElementsSize;
int
intlistElementsIndex = 0;
/*
* de: Generelle Prüfung ob Child-Elemente mit Namen <SupplementaryText> vorhanden sind.
* en: General
check if there are child-elements named <SupplementaryText>
present. */
elementSupplementaryText
=
XML_RootElement
.getChild(
"SupplementaryText"
);
if
(elementSupplementaryText
==
null
)
{
StatusCode
=
CONST_SUPPLEMENTARYTEXT_DIVISION_NOT_PRESENT
;
return
""
;
}
/*
* de:
*
Holen der Liste mit den <SupplementaryText>-Elementen und Ermitteln der Anzahl der Elemente
* in der Liste.
* en:
*
Get
the list of <SupplementaryText>-elements and the number of
elements within the list. */
listElements
= elementSupplementaryText.getChildren();
intlistElementsSize
= listElements.size();
if
(intlistElementsSize
== 0) {
StatusCode
=
CONST_SUPPLEMENTARYTEXT_DIVISION_NOT_PRESENT
;
return
""
;
}
/*
* de:
* Jedes Element der Liste untersuchen um den das Element mit dem Namen, der als Parameter
* übergeben wurde, zu finden.
* en:
* Inspect
each element of the list to find the element
*
fitting
the element-name passed as parameter. */
for
(intlistElementsIndex
= 0;
intlistElementsIndex
< intlistElementsSize;
intlistElementsIndex++)
{
elementElement =
(Element) listElements.get(intlistElementsIndex);
/*
* de:
*
Holen des <ElementName>-Elements um dessen Inhalt mit dem übergebenen Parameter vergleichen zu können.
* en:
*
Get
the <ElementName>-element to compare its contents with
the passed parameter. */
elementElementName
= elementElement.getChild(
"ElementName"
);
/*
* de:
*
Prüfen ob ein <ElementName>-Element gefunden wurde; wenn nicht dann dies nicht als Fehler ansehen
* sondern nur die weitere Verarbeitung überspringen.
*
en:
*
Verify
if the element was found; otherwise skip and do not consider it as
error. */
if
(elementElementName
!=
null
)
{
strElementName
= elementElementName.getTextTrim();
if
(strElementName.compareTo(parmstrElementName)
== 0) {
/*
* de:
* Passenden XML-Element innerhalb der Liste gefunden; Text auslesen !
* en:
*
Fitting XML-element found within the list; get the text
! */
elementInfoMessage
= elementElement.getChild(
"InfoMessage"
);
if
(elementInfoMessage
==
null
)
{
/*
* de:
Kein Message-Text gefunden; das ist ein Fehler !
* en:
No
Message-Text defined: is an error ! */
StatusCode
=
CONST_SUPPLEMENTARYTEXT_ELEMENT_NOT_PRESENT
;
return
""
;
}
/*
* de:
Message-Text auslesen und zurück liefern.
* en:
Get
the Message-Text and return it ! */
strInfoMessage
= elementInfoMessage.getTextTrim();
return
strInfoMessage;
}
}
}
/*
* de:
Gesuchtes Element nicht innerhalb der XML-Struktur gefunden; Fehler zurück liefern.
* en:
Searched
element not found within the XML-structure; return the
error. */
StatusCode
=
CONST_SUPPLEMENTARYTEXT_ELEMENT_NOT_PRESENT
;
return
""
;
}
/*
*
************************************************** */
/*
* Method
to fill the Borders for the different kinds of meaning
* within
the structure JSBS_UniversalParameters with the colors
* that
are defined within the 'Layout'-division of the XML-structure
*/
public
void
processJSBS_UniversalParameters(
JSBS_UniversalParameters
parmJSBS_UniversalParameters) {
/*
* Variables:
*/
/* Element
for the <Layout> Division, Element for one
BorderColor,
* text-String for the value of an
XML-element BorderColor and 'int'-values
* for the
'Highlight' and 'Shadow'-color of a 'Border'. */
Element
elementLayout;
Element
elementBorderColor;
String
strBorderColor;
int
intBorderColorHighlight;
int
intBorderColorShadow;
/* Set
the Status-Code that will be returned if it is not overwritten.
*/
StatusCode
=
CONST_OK
;
/*
* General
check if there is a child-element named <Layout> present
underneat the 'root'. */
elementLayout
=
XML_RootElement
.getChild(
"Layout"
);
if
(elementLayout ==
null
)
{
/* <Layout>
division missing; report this as an error. */
StatusCode
=
CONST_LAYOUT_DIVISION_NOT_PRESENT
;
return
;
}
/*
* Read
the colors for each border; create the border and save it in the
fitting
* variable of the
JSBS_UniversalParameters-structure. */
intBorderColorHighlight
= 0;
elementBorderColor =
elementLayout.getChild(
"PanelBorderColor1"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorHighlight
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* Set
the Border for the panel; at panels, the Highlight- and the
Shadow-color are the same.
*/
parmJSBS_UniversalParameters.
bdrPanelBorder1
=
new
EtchedBorder(
new
Color(intBorderColorHighlight),
new
Color(intBorderColorHighlight));
/* ***** */
intBorderColorHighlight
= 0;
elementBorderColor =
elementLayout.getChild(
"PanelBorderColor2"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor
.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorHighlight
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* Set
the Border for the panel; at panels, the Highlight- and the
Shadow-color are the same.
*/
parmJSBS_UniversalParameters.
bdrPanelBorder2
=
new
EtchedBorder(
new
Color(intBorderColorHighlight),
new
Color(intBorderColorHighlight));
/* ***** */
intBorderColorHighlight
= 0;
elementBorderColor =
elementLayout.getChild(
"OptionalBorderHighlightColor"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor
.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorHighlight
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* *** */
intBorderColorShadow
= 0;
elementBorderColor =
elementLayout.getChild(
"OptionalBorderShadowColor"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor
.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorShadow
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* Set
the Border for the GUI-component.
*/
parmJSBS_UniversalParameters.
bdrOptionalBorder
=
new
EtchedBorder(
new
Color(intBorderColorHighlight),
new
Color(intBorderColorShadow));
/* ***** */
intBorderColorHighlight
= 0;
elementBorderColor =
elementLayout.getChild(
"MandatoryBorderHighlightColor"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor
.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorHighlight
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* *** */
intBorderColorShadow
= 0;
elementBorderColor =
elementLayout.getChild(
"MandatoryBorderShadowColor"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor
.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorShadow
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* Set
the Border for the GUI-component.
*/
parmJSBS_UniversalParameters.
bdrMandatoryBorder
=
new
EtchedBorder(
new
Color(intBorderColorHighlight),
new
Color(intBorderColorShadow));
/* ***** */
intBorderColorHighlight
= 0;
elementBorderColor =
elementLayout.getChild(
"SelectedBorderHighlightColor"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor
.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorHighlight
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* *** */
intBorderColorShadow
= 0;
elementBorderColor =
elementLayout.getChild(
"SelectedBorderShadowColor"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor
.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorShadow
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* Set
the Border for the GUI-component.
*/
parmJSBS_UniversalParameters.
bdrSelectedBorder
=
new
EtchedBorder(
new
Color(intBorderColorHighlight),
new
Color(intBorderColorShadow));
/* ***** */
intBorderColorHighlight
= 0;
elementBorderColor =
elementLayout.getChild(
"EnterTriggeredButtonBorderHighlightColor"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor
.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorHighlight
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* *** */
intBorderColorShadow
= 0;
elementBorderColor =
elementLayout.getChild(
"EnterTriggeredButtonBorderShadowColor"
);
/* Check
that the XML-element exists and has a value to avoid a dump at
further processing. */
if
(elementBorderColor !=
null
)
{
strBorderColor =
elementBorderColor
.getTextTrim();
if
(strBorderColor !=
null
)
{
/* Convert
the value of the string to an int-value. */
try
{
intBorderColorShadow
= (
new
Integer(strBorderColor)).intValue();
}
/* In
case that the value for the color was not numeric the value defined
above is used. */
catch
(Exception
Exc) {}
}
}
/* Set
the Border for the GUI-component.
*/
parmJSBS_UniversalParameters.
bdrEnterTriggeredButtonBorder
=
new
EtchedBorder(
new
Color(intBorderColorHighlight),
new
Color(intBorderColorShadow));
}
/*
*
************************************************** */
/*
* de:
* METHODE zum Auslesen der Eingabe-Regeln (Regeln, mit denen die Gültigkeit
* von eingegebenen Werten geprüft wird
) aus der XML-Struktur
* und Einfügen in die Struktur mit den Eingabe-Regeln.
* en:
* METHOD
to read the Entry-Rules (Rules to check the validity of entered
* values) out of the XML-structure and enter it to the structure of the
* Entry-Rules.
*/
public
void
setEntryRule(
JSBS_EntryRules
parmJSBS_EntryRules,
String
parmFrameClassName,
String
parmGUIElementName
) {
/*
* de:
Prüfen ob die Parameter nicht 'null' sind.
* en: Verify that the parameters are not 'null'. */
if
(parmJSBS_EntryRules ==
null
)
return
;
if
(
parmFrameClassName
==
null
)
return
;
if
(
parmGUIElementName
==
null
)
return
;
/*
* de:
*
Holen des Elements für die - in den Parametern übergebene - Kombination
* aus FrameClassName und GUI-ElementName aus der XML-Struktur
.
* en:
* Get the Element for the combination of FrameClassName and GUI-ElementName
*
- passed in the parameters - out of the XML-structure
.
*/
Element elementGUIElement =
getGUI_Element(
parmFrameClassName, parmGUIElementName
)
;
/*
* de:
*
Wenn kein XML-Element gefunden wird existieren keine Eingaberegeln.
* Diese Methode abbrechen.
* en:
* If no XML-Element is found then Entry-Rules to not exist.
*
End this method. */
if
(
elementGUIElement
==
null
)
return
;
/*
* de:
* 'Auslesen' der einzelnen Eingabe-Regeln. Wenn keine Regel existiert dann wird
* der Wert 'null' von der jeweiligen Methode zurückgeliefert.
* 'null'-Werte können anschließend als Parameter an
*
'JSBS_EntryRules.setEntryRules(...) übergeben werden.
* en:
* 'Read' the single Entry-Rules. If no Rule exist, then a value of 'null'
* is returned by each the called method.
* 'null' values can be passed as parameter to the following method
*
'JSBS_EntryRules.setEntryRules(...)
. */
Integer intMinimumLength
= getProperty_MinimumLength(elementGUIElement
)
;
Integer intMaximumLength
= getProperty_MaximumLength(elementGUIElement
)
;
Boolean bolMandatory
= getProperty_Mandatory(elementGUIElement
)
;
BigDecimal bdMinimumValue
= getProperty_MinimumValue(elementGUIElement
)
;
BigDecimal bdMaximumValue
= getProperty_MaximumValue(elementGUIElement
)
;
Integer intNumberOfDecimals
= getProperty_NumberOfDecimals(elementGUIElement
)
;
/*
* de:
* Einfügen der Werte in die Struktur mit den Eingabe-Regeln
.
* Der 'null' Wert (letzter Parameter) ist eine noch nicht implementierte
* Regel für den Aufbau von eingegebenen Zeichenketten.
* en:
* Insert the values into the structure with the Entry-Rules
.
* The 'null'-value (last parameter) is a not yet implemented rule for
* the appearance of entered strings.
*/
parmJSBS_EntryRules.setEntryRuleValues(
parmGUIElementName, bolMandatory,
bdMinimumValue, bdMaximumValue, intNumberOfDecimals,
intMinimumLength, intMaximumLength,
null
)
;
}
/*
*
************************************************** */
/*
* de:
* METHODE zum Auslesen der Werte von Eigenschaften im Abschnitt <Layout>.
* Die Bezeichnung des XML-Elements wird im Parameter übergeben.
* Rückgabewert ist der Wert des XML-Elements; wenn kein passendes XML-Element
* gefunden wird dann wird 'null' zurückgeliefert
.
* en:
* METHOD
to read the values of properties in the <Layout> section.
* The name of the XML-element is passed as parameter.
* Return-value is the value of the XML-element; if not fitting XML-element
* is found the 'null' is returned
.
*/
public
String getLayoutProperty(
String
parmPropertyName
) {
/*
* de:
* Element für den gesamten <Layout>-Abschnitt aus der XML-Struktur holen
.
* en:
* Get the element for the whole <Layout>-section out of the XML-structure
. */
Element elementLayout =
XML_RootElement
.getChild(
"Layout"
)
;
/*
* de:
* Wenn kein <Layout>-Abschnitt vorhanden ist dann 'null' zurückliefern.
* en:
* If no <Layout>-section present then return 'null'
. */
if
(
elementLayout
==
null
)
return null
;
/*
* de:
* Element für die im Parameter übergebene Eigenschaft aus der XML-Struktur holen
.
* en:
* Get the element for the property passed as parameter out of the XML-structure
. */
Element elementProperty =
elementLayout
.getChild(parmPropertyName
)
;
/*
* de:
* Wenn kein XML-Element mit gesuchtem Namen vorhanden ist dann 'null' zurückliefern.
* en:
* If no XML-element with requested name is present then return 'null'
. */
if
(
elementProperty
==
null
)
return null
;
/*
* de:
* Wert (für die Eigenschaft) aus dem XML-Element zurückliefern.
* en:
* Return the value (for the property) of the XML-element
. */
return
elementProperty
.getTextTrim()
;
}
}
public
String
getSupplementaryText(String parmstrElementName)
Diese
Methode liest einen sprachabhängigen Text zur beliebigen
Verwendung aus der XML-Struktur aus. [mehr]
Allgemeine Beschreibung dieser Klasse für die Verarbeitung der Datei mit sprachabhängigen Text-Elementen
Die
Methoden dieser Klasse sind für das Einlesen der Datei
'DisplayStrings.xml' und das Extrahieren verschiedener Werte der in der
Datei enthaltenen XML-Struktur.
▲
zum
Inhaltsverzeichnis (Erklärungen und Anwendungsbeispiele)
public
String
getSupplementaryText(String parmstrElementName)
Diese
Methode liest einen sprachabhängigen Text zur beliebigen
Verwendung aus der XML-Struktur aus.
/*
* Sprachabhängigen Text für die 'Titlebar' des File-Dialog-Fensters aus der XML-Datei 'auslesen'
. */
String strTitle = parmTF.
frmCC
.
structJSBS_XML_DisplayStrings
.
getSupplementaryText(
"LanguageDependantLayoutImport_ActionHandler*FD_TitleBar"
)
;
/*
* Fenster für den 'File-Dialog' aufrufen; in diesem kann der Benutzer eine Datei auswählen
. */
FileDialog fd = FileDialog(parmTF, strTitle, FileDialog.
LOAD
)
;
▲
zum
Inhaltsverzeichnis (Erklärungen und Anwendungsbeispiele)
Dokument |
Inhalt |
Datei 'DisplayStrings.xml' mit sprachabhängigen Texten für die Anzeige auf der GUI |
Dieses Dokument beschreibt den Aufbau der Datei 'DisplayStrings.xml'. |