|
Letzte
Bearbeitung dieses Dokuments: |
Code
Erklärungen
und Anwendungsbeispiele
Verwandte
Dokumentation
package
js_base.frame
;
import
java.awt.*;
import
java.math.*;
import
java.util.*;
import
javax.swing.*;
import
javax.swing.table.*;
import
javax.swing.text.*;
import
js_base.structures.JSBS_UniversalParameters;
import
js_base.utilities.*;
import
js_base.xml.*;
/**
*
* @author kurt(at)javascout[dot]biz
*
@date 2007-05-14
*
* @description
* de:
* Klasse mit statischen Methoden die 'Hilfsmittel' zur
* Bearbeitung von GUI-Elementen im Allgemeinen und von GUI-
* Elementen in den Klassen JSBS_StartFrame und JSBS_DetailFrame
* zur Verfügung stellen.
* en:
* Class
with static methods providing utilities around
* GUI-elements
in general and
* the classes JSBS_StartFrame and
JSBS_DetailFrame.
*
* @change-log
*
when who why
*
--------------------------------------------------------
*
2010-01-28 KG Added Code to perform EntryRules-verification for
* Short, Integer and BigDecimal
*
*/
public
class
JSBS_GUIServices
{
/*
* de:
* Konstante für den Trenner zwischen Code und erklärendem Text
* in JCombobox und JListbox
.
* en:
* Constant
for the delimiter-string that separates code from explanatory text
in
* JComboBoxes and JListBoxes. */
public
static
String
CONST_CODE_TEXT_DELIMITER
=
"-"
;
/*
* -------------------------
*
de:
* METHODE um einen Mausklick auf einen JButton zu simulieren - sofern der JButton
* nicht 'disabled' ist.
*
Dazu wird der 'Container' der als Parameter übergeben wurde
(üblicherweise
* das 'ContentPane' eines 'JFrame') und die enthaltenen 'JPanel's rekursiv durchsucht.
* Dabei werden die Namen alle gefundenen 'JButton's mit jenem Namen, der als
* Parameter übergeben wurde, verglichen.
* Wenn der JButton mit dem gesuchten Namen gefunden ist wird ein Mausklick
* simuliert - sofern der JButton nicht 'disabled' ist.
* en:
* METHOD to simulate a mouse-click onto a JButton - if this JButton is not disabled.
* This is done by going
recursively through the Container passed as
parameter
*
(usually the ContentPane of a JFrame) and its
sub-JPanels,
*
inspect all JButtons if their names compare to the one passed as parameter.
* If the JButton with the
searched name is found it is 'clicked' if it is not disabled.
*/
public
static int
clickButton(
Container
parmContainer,
String parmButtonName
)
{
/*
de: Return-Code um einen eventuellen Fehler an die aufrufende Methode
* mitzuteilen.
*
en: Return-Code to pass an error-status back to the calling method.
*/
int
intStatusCode
= 0;
int
locintStatusCode
= 0;
/*
de: Prüfen ob der als Parameter übergebene 'Container' ein 'JButton' ist.
* en: Check if the 'Container' passed as parameter is a
JButton. */
if
(parmContainer
instanceof
JButton)
{
/*
de:
*
'Container' auf ein lokales Objekt vom Type 'JButton'
übertragen damit wieder alle
* Eigenschaften von 'JButton' wieder verfügbar sind.
*
en:
* Transfer 'Container'
to a local object of type 'JButton' to have all properties
*
of 'JButton'
available. */
JButton locJButton = (JButton) parmContainer;
/*
de:
* Name des untersuchten 'JButton' auslesen damit er mit dem gesuchten Namen
* (als Parameter übergeben) verglichen werden kann.
* en:
*
Get the name of the inspected JButton and compare it to the searched
name
*
passed as parameter. */
String
strlocJButtonName = locJButton.getName();
/*
de:
Prüfen ob der JButton auch einen Namen hat
; sonst diese Methode abbrechen.
* en:
Verify if the JButton has a name; otherwise return from this method
. */
if
(strlocJButtonName ==
null
)
return
intStatusCode;
if
(strlocJButtonName.equals(parmButtonName))
{
/*
de:
*
Gesuchter 'JButton' gefunden. Wenn er 'enabled' ist wird ein Mausklick simuliert.
* en:
*
Searched 'JButton' found.
If it is 'enabled' than a mouse-click is simulated. */
if
(locJButton.isEnabled())
locJButton.doClick();
else
{
/*
de: Schaltfläche 'disabled'; Anwender durch einen 'beep' warnen.
*
en: Button 'disabled'; warn the user with a 'beep'. */
JFrame
locJFrame =
new
JFrame();
locJFrame.getToolkit().beep();
}
/*
de:
* Sonst kann kein 'JButton' mit dem gesuchten Namen vorhanden sein;
* deswegen
Methode abbrechen.
* en:
* Another 'JButton' with the searched name cannot be present;
* Therefore return from this method
. */
return
intStatusCode;
}
}
/*
de: 'children' dieses 'container' auslesen und diese rekursiv untersuchen.
*
en: Get the 'children' of this Container and inspect them recursively.
*/
Component
comps[] = parmContainer.getComponents();
for
(
int
i
= 0; i < comps.
length
;
i++) {
Component
comp = comps[i];
if
(comp
instanceof
Container)
{
/*
de:
* 'Child' ist wieder ein 'Container'; d.h. er kann weitere 'children' haben.
*
en:
*
'Child' is another Container;
*
i.e. it might be a JButton or has
'children' of its own. */
locintStatusCode
=
clickButton((Container)
comp, parmButtonName);
/*
de:
* Untersuchen ob ein Fehler beim rekursiven Aufruf passiert ist.
* In diesem Fall den Status-Code für die spätere 'Rückgabe' aufheben.
* en:
*
Inspect if an error happened within the recursive call.
* In
case of error keep the Status-Code for later return. */
if
(locintStatusCode
> 0) intStatusCode = locintStatusCode;
}
}
/*
de: Status-Code an die aufrufende Methode zurückgeben.
*
en: Return the Status-Code to the calling method. */
return
intStatusCode;
}
/*
* --------------------
* de:
* METHODE um den sprachabhängigen Text für ein GUI-Element, dessen Klasse von
* JDialog abgeleitet ist, zu setzen.
* en:
* METHOD
to set the language dependant text to the GUI-elements of
* classes
derived from JDialog. */
public
static int
processLanguageDependantElements(
JSBS_StartFrame
parmfrmJSBS_StartFrame,
JDialog
parmJDialog)
{
/*
* de:
* Return-Code um den Status, der das Ergebnis von aufgerufenen Methoden
ist,
* zurück zu liefern.
* en:
*
Return-Code
to pass the status, that was reported by called methods, back
*/
int
intStatusCode
= 0;
/*
* de: Lokaler Status-Code für Vergleiche.
*
en: Local
StatusCode for comparisons */
int
locintStatusCode
= 0;
/*
* de: Methode zum Setzen des Textes in der TitleBar des Frames aufrufen.
* en: Call
the method that sets the text into the TitleBar of the frame
*/
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJDialog(parmJDialog);
/*
* de:
*
Prüfen ob ein anderer Code als 0 (OK) zurück geleiefert wurde und den Code in
* diesem Fall aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case
*/
if
(locintStatusCode
> 0) intStatusCode = locintStatusCode ;
/*
* de:
*
'ClassName' des übergebenen Parameters ermitteln; dieser wird beim nächsten Aufruf
* der Methode gebraucht.
* en:
*
Get
the 'ClassName' of the passed parameter - it is used in the next
method-call. */
String
locstrClassName = parmJDialog.getClass().getName().trim();
/*
* de: 'ContentPane' auslesen und die Methode aufrufen um es rekursiv zu untersuchen.
* en: Get
the 'ContentPane' and call the method that inspects it recursive
*/
Container
locContainer = parmJDialog.getContentPane();
locintStatusCode
=
processLanguageDependantElements(
locstrClassName,
parmfrmJSBS_StartFrame, locContainer);
/*
* de:
*
Prüfen ob ein anderer Code als 0 (OK) zurück geleiefert wurde und den Code in
* diesem Fall aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case
*/
if
(locintStatusCode
> 0) intStatusCode = locintStatusCode ;
/*
* Return
the Status to the caller */
return
intStatusCode;
}
/*
* --------------------
* de:
* METHODE zum Setzen des sprachabhängigen Textes bei GUI-Elementen
* von Klassen, die vom JSBS_StartFrame abgeleitet wurden.
* en:
*
METHOD
to set the language dependant text to the GUI-elements of
* classes
derived from JSBS_StartFrame. */
public
static int
processLanguageDependantElements(
JSBS_StartFrame
parmfrmJSBS_StartFrame) {
/*
* de:
* Return-Code um den Status, der von aufgerufenen Methoden zurückgeliefert
* wurde, an die aufrufende Methode melden zu können.
* en:
*
Return-Code
to pass the status, that was reported by called methods, back.
*/
int
intStatusCode
= 0;
/*
* de:
* Lokale Variable für den Status-Code um vergleichen zu können.
* en:
*
Local variable for the
StatusCode for comparisons. */
int
locintStatusCode
= 0;
/*
* de:
* Methode aufrufen die den Text in die 'TitleBar' eines Frames (Fenster)
* überträgt.
* en:
*
Call
the method that sets the text into the TitleBar of the frame.
*/
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJFrame(
parmfrmJSBS_StartFrame);
/*
* de:
* Prüfen ob ein anderer Status-Code als OK zurückgeliefert wurde.
* In diesem Fall den zurückgelieferten Status-Code aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case.
*/
if
(locintStatusCode
> 0) intStatusCode = locintStatusCode ;
/*
* de:
* 'ClassName' des übergebenen Parameters ermitteln; dieser wird beim anschließenden
*
Aufruf benötigt.
* en:
*
Get
the 'ClassName' of the passed parameter - it is used in the next
method-call. */
String
locstrClassName =
parmfrmJSBS_StartFrame.getClass().getName().trim();
/*
* de:
* 'ContentPane' holen und die Methode aufrufen die dieses rekursiv untersucht.
* en:
*
Get
the 'ContentPane' and call the method that inspects it recursively.
*/
Container
locContainer = parmfrmJSBS_StartFrame.getContentPane();
locintStatusCode
=
processLanguageDependantElements(
locstrClassName,
parmfrmJSBS_StartFrame, locContainer);
/*
* de:
* Prüfen ob ein anderer Status-Code als OK zurückgeliefert wurde.
* In diesem Fall den zurückgelieferten Status-Code aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case.
*/
if
(locintStatusCode
> 0) intStatusCode = locintStatusCode ;
/*
* de:
* Methode aufrufen die eventuell bei den GUI-Elementen in der XML-Sturktur
*
defininierte
Eingabe-Regeln in das Objekt mit den Eingabe-Regeln überträgt
.
* en:
*
Call the method that transfers Entry-Rules (that might be defined at the
* GUI-Elements within the XML-structure) to the object with the Entry-Rules
.
*/
processEntryRules(
parmfrmJSBS_StartFrame.
structJSBS_EntryRules
,
locstrClassName,
parmfrmJSBS_StartFrame, locContainer);
/*
* de: Status-Code an die aufrufende Methode zurückliefern.
* en: Return
the Status to the caller. */
return
intStatusCode;
}
/*
* --------------------
* de:
* METHODE zum Setzen des sprachabhängigen Textes bei GUI-Elementen
* von Klassen, die vom JSBS_TaskFrame abgeleitet wurden.
* en:
*
METHOD
to set the language dependant text to the GUI-elements of
* classes
derived from JSBS_TaskFrame.
*/
public
static int
processLanguageDependantElements(
JSBS_TaskFrame
parmfrmJSBS_TaskFrame) {
/*
* de:
* Return-Code um den Status, der von aufgerufenen Methoden zurückgeliefert
* wurde, an die aufrufende Methode melden zu können.
* en:
*
Return-Code
to pass the status, that was reported by called methods, back.
*/
int
intStatusCode
= 0;
/*
* de:
* Lokale Variable für den Status-Code um vergleichen zu können.
* en:
*
Local variable for the
StatusCode for comparisons. */
int
locintStatusCode
= 0;
/* de: Start-Frame aus dem übergebenen Parameter ermitteln
*
en: Derive
the StartFrame out of the passed parameter. */
JSBS_StartFrame
frmJSBS_StartFrame = parmfrmJSBS_TaskFrame.
frmCC
;
/*
* de:
* Methode aufrufen die den Text in die 'TitleBar' eines Frames (Fenster)
* überträgt.
* en:
*
Call
the method that sets the text into the TitleBar of the frame.
*/
locintStatusCode
=
frmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJFrame(
parmfrmJSBS_TaskFrame);
/*
* de:
* Prüfen ob ein anderer Status-Code als OK zurückgeliefert wurde.
* In diesem Fall den zurückgelieferten Status-Code aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case.
*/
if
(locintStatusCode
> 0) intStatusCode = locintStatusCode ;
/*
* de:
* 'ClassName' des übergebenen Parameters ermitteln; dieser wird beim anschließenden
*
Aufruf benötigt.
* en:
*
Get
the 'ClassName' of the passed parameter - it is used in the next
method-call.
*/
String
locstrClassName =
parmfrmJSBS_TaskFrame.getClass().getName().trim();
/*
* de:
* 'ContentPane' holen und die Methode aufrufen die dieses rekursiv untersucht.
* en:
*
Get
the 'ContentPane' and call the method that inspects it recursively.
*/
Container
locContainer = parmfrmJSBS_TaskFrame.getContentPane();
locintStatusCode
=
processLanguageDependantElements(
locstrClassName,
frmJSBS_StartFrame, locContainer);
/*
* de:
* Prüfen ob ein anderer Status-Code als OK zurückgeliefert wurde.
* In diesem Fall den zurückgelieferten Status-Code aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case.
*/
if
(locintStatusCode
> 0) intStatusCode = locintStatusCode ;
/*
* de:
* Methode aufrufen die eventuell bei den GUI-Elementen in der XML-Struktur
*
defininierte
Eingabe-Regeln in das Objekt mit den Eingabe-Regeln überträgt
.
* en:
*
Call the method that transfers Entry-Rules (that might be defined at the
* GUI-Elements within the XML-structure) to the object with the Entry-Rules
.
*/
processEntryRules(
parmfrmJSBS_TaskFrame.
structJSBS_EntryRules
,
locstrClassName, frmJSBS_StartFrame, locContainer);
/*
* de: Status-Code an die aufrufende Methode zurückliefern.
* en: Return
the Status to the caller.
*/
return
intStatusCode;
}
/*
* --------------------
*
de:
*
METHODE, die für jedes GUI-Element für das Frame, dessen Name als
*
Parameter übergeben wurde, die in der Klasse 'JSBS_XML_DisplayStrings'
*
implementierte Methode zur Übernahme von Eingabe-Regeln aufruft.
*
en:
*
METHOD that calls
the method to take over Entry-Rules
for each GUI-Element
*
of the Frame, which name was
passed as parameter.
*
This method is
implemented in class
'JSBS_XML_DisplayStrings'
.
*/
private
static void
processEntryRules(
JSBS_EntryRules parmJSBS_EntryRules,
String
parmFrameClassName,
JSBS_StartFrame
parmJSBS_StartFrame,
Container
parmContainer) {
/*
*
de:
*
Name des 'Containers' ermitteln - falls es kein 'Container' sondern ein
*
in der XML-Struktur definiertes GUI-Element ist.
*
en:
*
Get the name of the 'Container' - just if it is no 'Container' but a
*
GUI-Element that is defined within the XML-Struktur.
*/
String
strGUIElementName = parmContainer.getName();
/*
*
de:
* Methode zur Übernahme der Eingabe-Regel aufrufen.
* Die aufgerufene Methode prüft, ob ein 'passendes' GUI-Element überhaupt
* in der XML-Struktur vorhanden ist und wenn es vorhanden ist, ob überhaupt
* eine Eingabe-Regel definiert ist.
* Nur dann wird ein Objekt dafür innerhalb der als Parameter übergebenen
* 'parmJSBS_EntryRules' erstellt.
*
en:
* Call the method to take over the Entry-Rule.
* The called method checks, if a 'suitable' GUI-Element is existing within the
* XML-structure and if, it has at least one Entry-Rule defined.
* Only then a object for it is constructed within the 'parmJSBS_EntryRules
* passed as parameter
.
*/
parmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.s
etEntryRule(
parmJSBS_EntryRules,
parmFrameClassName,
strGUIElementName
);
/*
* de:
*
Prüfen, ob Unter-Element vom Typ 'Container' vorhanden sind und bei
* Bedarf diese Methode rekursive aufrufen.
* en:
* Check if
child-elements of type 'Container' are present and if neccessary,
*
call this method recursively */
Component
comps[] = parmContainer.getComponents();
for
(
int
i = 0; i < comps.
length
;
i++) {
Component
comp = comps[i];
if
(comp
instanceof
Container) {
processEntryRules(parmJSBS_EntryRules,
parmFrameClassName,
parmJSBS_StartFrame,
(Container)
comp);
}
}
}
/*
* --------------------
* de:
* METHODE zum rekursiven Durchsuchen der hierarchischen Struktur der GUI.
* Das ist eine interne (private) Methode; 'Warapper'-Methoden für den Aufruf aus
* anderen Methoden sind:
* -
processLanguageDependantElements(JSBS_StartFrame
parmfrmJSBS_StartFrame) und
* - processLanguageDependantElements(JSBS_TaskFrame
parmfrmJSBS_TaskFrame)
* en:
*
METHOD to recursively search the hierarchic structure of
the GUI.
* This is an internal (private) method; wrapper-methods to be
called from other methods are:
* -
processLanguageDependantElements(JSBS_StartFrame
parmfrmJSBS_StartFrame)
and
* - processLanguageDependantElements(JSBS_TaskFrame
parmfrmJSBS_TaskFrame)
*/
private
static int
processLanguageDependantElements(
String
parmstrFrameClassName,
JSBS_StartFrame
parmfrmJSBS_StartFrame,
Container
parmContainer) {
/*
* de:
* Return-Code um den Status, der von aufgerufenen Methoden zurückgeliefert
* wurde, an die aufrufende Methode melden zu können.
* en:
*
Return-Code
to pass the status, that was reported by called methods, back.
*/
int
intStatusCode
= 0;
/*
* de:
* Lokale Variable für den Status-Code um vergleichen zu können.
* en:
*
Local variable for the
StatusCode for comparisons. */
int
locintStatusCode
= 0;
/*
* de: Prüfen zu welcher Sub-Klasse der 'Container' gehört und passende Methode aufrufen.
* en: Check
what sub-class the 'Container' is of and call the suitable method
*/
if
(parmContainer
instanceof
JTextField) {
JTextField
locJTextField = (JTextField) parmContainer;
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJTextField(locJTextField,
parmstrFrameClassName);
/*
* de: Hintergrundfarbe des GUI-Elements setzen;
*
die Farbe wurde beim Start des CommandCenters (StartFrame) in den Universalparametern definiert.
* en: Set the background color of the GUI-Element;
* the color was defined in the Universal-parameters at the start of the CommandCenter
(StartFrame).
*/
loc
JTextField.setBackground(parmfrmJSBS_StartFrame.
structJSBS_UniversalParameters
.
clrNormalBackground
);
/*
* de:
* Prüfen ob ein anderer Status-Code als OK zurückgeliefert wurde.
* In diesem Fall den zurückgelieferten Status-Code aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case.
*/
if
(locintStatusCode > 0) intStatusCode =
locintStatusCode;
return
intStatusCode;
}
/* */
if
(parmContainer
instanceof
JTextArea) {
JTextArea
locJTextArea = (JTextArea) parmContainer;
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJTextArea(locJTextArea,
parmstrFrameClassName);
/*
* de: Hintergrundfarbe des GUI-Elements setzen;
*
die Farbe wurde beim Start des CommandCenters (StartFrame) in den Universalparametern definiert.
* en: Set the background color of the GUI-Element;
* the color was defined in the Universal-parameters at the start of the CommandCenter
(StartFrame).
*/
loc
JTextArea.setBackground(parmfrmJSBS_StartFrame.
structJSBS_UniversalParameters
.
clrNormalBackground
);
/*
* de:
* Prüfen ob ein anderer Status-Code als OK zurückgeliefert wurde.
* In diesem Fall den zurückgelieferten Status-Code aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case.
*/
if
(locintStatusCode > 0) intStatusCode =
locintStatusCode;
return
intStatusCode;
}
/* */
if
(parmContainer
instanceof
JComboBox) {
JComboBox
locJComboBox = (JComboBox) parmContainer;
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJComboBox(locJComboBox,
parmstrFrameClassName);
/*
* de: Hintergrundfarbe des GUI-Elements setzen;
*
die Farbe wurde beim Start des CommandCenters (StartFrame) in den Universalparametern definiert.
* en: Set the background color of the GUI-Element;
* the color was defined in the Universal-parameters at the start of the CommandCenter
(StartFrame).
*/
loc
JComboBox.setBackground(parmfrmJSBS_StartFrame.
structJSBS_UniversalParameters
.
clrNormalBackground
);
/*
* de:
* Prüfen ob ein anderer Status-Code als OK zurückgeliefert wurde.
* In diesem Fall den zurückgelieferten Status-Code aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case.
*/
if
(locintStatusCode > 0) intStatusCode =
locintStatusCode;
return
intStatusCode;
}
/* */
if
(parmContainer
instanceof
JLabel) {
JLabel
locJLabel = (JLabel) parmContainer;
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJLabel(locJLabel,
parmstrFrameClassName);
/*
* de:
* Prüfen ob ein anderer Status-Code als OK zurückgeliefert wurde.
* In diesem Fall den zurückgelieferten Status-Code aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case.
*/
if
(locintStatusCode > 0) intStatusCode =
locintStatusCode;
return
intStatusCode;
}
/* */
if
(parmContainer
instanceof
JButton) {
JButton
locJButton = (JButton) parmContainer;
/*
* de: Teil 1 der Bearbeitung eines JButton: Text und ToolTipText setzen.
*
en: Part 1 for JButton-processing: set Text and ToolTipText. */
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJButton(locJButton,
parmstrFrameClassName);
/*
* de:
* Prüfen ob ein anderer Status-Code als OK zurückgeliefert wurde.
* In diesem Fall den zurückgelieferten Status-Code aufheben.
* en:
*
Check
if another Code than 0 (OK) was returned and keep it in that case.
*/
if
(locintStatusCode > 0) intStatusCode = locintStatusCode;
/*
*
de:
*
Teil 2 der Bearbeitung für JButtons:
Prüfen ob die XML-Struktur initialisiert ist
*
und dann Icon und Funktions-Tasten-Code zuweisen
* en:
*
Part 2 for JButton-processing: Verify if the XML-structure is initialized
*
and then assign the Icon and the
Funktion-Key-Code. */
if
(
parmfrmJSBS_StartFrame.
structJSBS_XML_FunctionKeys
!=
null
) {
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_FunctionKeys
.processJButton(locJButton,
parmstrFrameClassName);
/*
*
de:
* Prüfen ob ein anderer Code als 0 (OK) zurückgeliefert wurde und wenn ja
* diesen 'aufheben' und ihn später an das aufrufende Programm zurückgeben.
* en:
* Check
if another Code than 0 (OK) was returned and keep it in that case
*/
if
(locintStatusCode > 0) intStatusCode = locintStatusCode;
return
intStatusCode;
}
}
/* */
if
(parmContainer
instanceof
JRadioButton) {
JRadioButton
locJRadioButton = (JRadioButton)
parmContainer;
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJRadioButton(locJRadioButton,
parmstrFrameClassName);
/*
*
de:
* Prüfen ob ein anderer Code als 0 (OK) zurückgeliefert wurde und wenn ja
* diesen 'aufheben' und ihn später an das aufrufende Programm zurückgeben.
* en:
* Check
if another Code than 0 (OK) was returned and keep it in that case
*/
if
(locintStatusCode > 0) intStatusCode =
locintStatusCode;
return
intStatusCode;
}
/* */
if
(parmContainer
instanceof
JCheckBox) {
JCheckBox
locJCheckBox = (JCheckBox) parmContainer;
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJCheckBox(locJCheckBox,
parmstrFrameClassName);
/*
*
de:
* Prüfen ob ein anderer Code als 0 (OK) zurückgeliefert wurde und wenn ja
* diesen 'aufheben' und ihn später an das aufrufende Programm zurückgeben.
* en:
* Check
if another Code than 0 (OK) was returned and keep it in that case
*/
if
(locintStatusCode > 0) intStatusCode =
locintStatusCode;
return
intStatusCode;
}
/* */
if
(parmContainer
instanceof
JTabbedPane) {
JTabbedPane
locJTabbedPane = (JTabbedPane) parmContainer;
/*
*
de:
* Text und TooltipText für die Tabs der einzelnen untergeordneten Panels setzen
.
* en:
* Set Text and TooltipText for the Tabs of the subordinate panels.
*/
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_DisplayStrings
.processJTabbedPane(locJTabbedPane,
parmstrFrameClassName);
/*
*
de:
* Prüfen ob ein anderer Code als 0 (OK) zurückgeliefert wurde und wenn ja
* diesen 'aufheben' und ihn später an das aufrufende Programm zurückgeben.
* en:
* Check
if another Code than 0 (OK) was returned and keep it in that case
*/
if
(locintStatusCode > 0) intStatusCode =
locintStatusCode;
/*
*
de:
*
Teil 2 der Bearbeitung gleich wie für JButtons:
Prüfen ob die XML-Struktur initialisiert ist
*
und dann Icon und den Tasten-Code für die 'Mnemonic'-Fuktion zuweisen
* en:
*
Part 2 of the processing similar to a JButton: Verify if the XML-structure is initialized
*
and then assign the Icon and the Key-Code for the 'Mnemonic'-function. */
if
(
parmfrmJSBS_StartFrame.
structJSBS_XML_FunctionKeys
!=
null
) {
locintStatusCode
=
parmfrmJSBS_StartFrame.
structJSBS_XML_FunctionKeys
.processJTabbedPane(
locJTabbedPane
,
parmstrFrameClassName);
/*
*
de:
* Prüfen ob ein anderer Code als 0 (OK) zurückgeliefert wurde und wenn ja
* diesen 'aufheben' und ihn später an das aufrufende Programm zurückgeben.
* en:
* Check
if another Code than 0 (OK) was returned and keep it in that case
*/
if
(locintStatusCode > 0) intStatusCode =
locintStatusCode;
}
/*
*
de:
* Bei einem JTabbedPane sind mit Sicherheit weitere untergeordnete GUI-Kompo
nenten vorhanden;
* deswegen wird die Methode nicht mit einem 'return' beendet
.
* en:
* Within a JTabbedPane there are subordinate GUI-components existing;
* therefore the method is not ended with a 'return'.
*/
}
/*
* de: Child-Elemente ermitteln und diese Methode rekursiv aufrufen.
* en: Get
child-elements and call this method recursively. */
Component
comps[] = parmContainer.getComponents();
for
(
int
i = 0; i < comps.
length
;
i++) {
Component
comp = comps[i];
if
(comp
instanceof
Container) {
locintStatusCode
=
processLanguageDependantElements(parmstrFrameClassName,
parmfrmJSBS_StartFrame,
(Container)
comp);
/*
*
de:
* Prüfen ob ein anderer Code als 0 (OK) zurückgeliefert wurde und wenn ja
* diesen 'aufheben' und ihn später an das aufrufende Programm zurückgeben.
* en:
* Check
if another Code than 0 (OK) was returned and keep it in that case
*/
if
(locintStatusCode
> 0) intStatusCode = locintStatusCode
;
}
}
/*
* de: Status an die aufrufende Methode zurück liefern.
* en: Return
the Status to the caller */
return
intStatusCode;
}
/*
* --------------------
*
de:
* METHODEN um die Ränder von JPanels, JButtons, JComboBoxes, JTextFields und JTextAreas
* mit den in der XML-Datei für Sprachabhängige Texte definierten Farben zu versehen.
* Die Objekte für die Borders (Ränder) sind bereits konstruiert und werden in der Struktur
* JSBS_UniversalParameters aufbewahrt.
* en:
*
METHODS to color the borders of JPanels, JButtons, JComboBoxes,
JTextFields and JTextAreas
* with colors defined in the
XML-file for LanguageDependantElements.
* The objects for the Borders are
already constructed and held in the
*
JSBS_UniversalParameters-structure. */
public
static void
processBorders(JSBS_StartFrame parmJSBS_StartFrame) {
/*
* de: Prüfen dass der Parameter nicht 'null' ist; das würde später zu einem Absturz führen.
* en:
Check that the parameter is not 'null' as this would lead to a dump
later. */
if
(parmJSBS_StartFrame
==
null
)
return
;
/*
* de: Spezialisierte Methoden zum Einfärben der Ränder aufrufen.
* en:
Call the specialised methods to color borders. */
setEntryFieldBorders(parmJSBS_StartFrame,
parmJSBS_StartFrame.
structJSBS_UniversalParameters
,
parmJSBS_StartFrame.
structJSBS_EntryRules
);
setButtonBorders(parmJSBS_StartFrame,
parmJSBS_StartFrame.
structJSBS_UniversalParameters
);
setPanelBorders(parmJSBS_StartFrame,
parmJSBS_StartFrame.
structJSBS_UniversalParameters
,
parmJSBS_StartFrame.
arrayJPanelBordersToBeColored
);
}
/* --------------------
*
de:
* Abwandlung der vorigen Methode mit einem TaskFrame als Parameter.
* en:
*
Derivation of the above method with a TaskFrame as parameter.
*/
public
static void
processBorders(JSBS_TaskFrame parmJSBS_TaskFrame) {
/*
* de:
*
Prüfen ob der übergebene Parameter nicht 'null' ist; 'null würde im weiteren
* Ablauf der Methode zu einem Dump führen.
* en:
*
Check that the parameter is not 'null' as this would lead to a dump
later. */
if
(parmJSBS_TaskFrame
==
null
)
return
;
/*
* de:
*
Aufrufen der spezialisierten Methode zum Einfärben der Ränder; dort wird
*
die Arbeit gemacht.
* en:
*
Call the specialised methods to color borders; the work is done there. */
setEntryFieldBorders(parmJSBS_TaskFrame,
parmJSBS_TaskFrame.
frmCC
.
structJSBS_UniversalParameters
,
parmJSBS_TaskFrame.
structJSBS_EntryRules
);
setButtonBorders(parmJSBS_TaskFrame,
parmJSBS_TaskFrame.
frmCC
.
structJSBS_UniversalParameters
);
setPanelBorders(parmJSBS_TaskFrame,
parmJSBS_TaskFrame.
frmCC
.
structJSBS_UniversalParameters
,
parmJSBS_TaskFrame.
arrayJPanelBordersToBeColored
);
}
/*
* --------------------
* de:
* METHODE zum Hinzufügen eines Randes (Border) zu jedem JButton.
* Die Farbe des Randes ist innerhalb der Struktur JSBS_UniversalParameters in der Variable
* 'OptionalBorder' festgelegt.
*
en:
*
METHOD to add a border to each JButton.
* The color of the
button-border is defined as 'OptionalBorder' within
*
the structure
JSBS_UniversalParameters. */
public
static void
setButtonBorders(Container
parmContainer,
JSBS_UniversalParameters parmJSBS_UniversalParameters) {
/*
* de: Prüfen ob der Parameter 'null' ist; das würde im weiteren Ablauf zu einem Dump führen.
* en:
Check that the parameters are not 'null' as this would lead to a dump
later. */
if
(parmContainer
==
null
)
return
;
if
(parmJSBS_UniversalParameters
==
null
)
return
;
/*
* de: Prüfen ob die GUI-Komponenten 'Container' ein JButton ist und wenn ja: Rand hinzufügen.
* en:
Verify if the GUI-component 'Container' is a JButton and set the
border if it is. */
if
(parmContainer
instanceof
JButton) {
JButton locJButton =
(JButton) parmContainer;
locJButton.setBorder(parmJSBS_UniversalParameters.
bdrOptionalBorder
);
/*
* de: Rekursion beenden weil kein weitere JButton auf einer unteren Ebene sein kann.
* en:
End the recursion as there could be no other JButton underneath.
*/
return
;
}
/*
* de: Prüfen ob der Container weitere Komponenten enthält.
* en:
Inspect the Container if it contains components. */
Component
comps[] = parmContainer.getComponents();
for
(
int
i = 0; i < comps.
length
;
i++) {
Component comp =
comps[i];
if
(comp
instanceof
Container) {
/*
* de:
*
Ein Container könnte GUI-Komponenten der Klasse JButton enthalten; diese Methode
* rekursiv aufrufen.
*
en:
*
A Container may contain JButton GUI-components; call this method
recursively. */
setButtonBorders((Container) comp,
parmJSBS_UniversalParameters);
}
}
}
/*
* de:
* Abwandlung der vorigen Methode:
* Zusätzlich wird ein JButton als Parameter übergeben, der die farbliche Randmarkierung für
*
'Triggered when Enter-Key is pressed'
erhalten soll.
*
en:
*
Derivation of the above method:
* A JButton, that should be
marked as 'Triggered when the Enter-Key is pressed'
* is
passed as additional parameter. */
public
static void
setButtonBorders(Container
parmContainer,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
JButton parmEnterTriggeredButton) {
/*
* de:
* Alle JButtons, die mit der normalen Farbe 'umrandet' werden sollen,
* werden bearbeitet
* en:
*
Process all JButtons to be 'bordered' with the standard-color.
*/
setButtonBorders(parmContainer,
parmJSBS_UniversalParameters);
/*
* de:
* Wenn ein gültiger JButton als Parameter für den 'EnterTriggeredButton'
* übergeben wurde dann wird dieser mit der entsprechenden Farbe 'umrandet'.
* en:
*
If a valid JButton was passed to be the 'EnterTriggeredButton'
*
this one is 'bordered' with the marking color. */
if
(parmEnterTriggeredButton
!=
null
)
parmEnterTriggeredButton.setBorder(
parmJSBS_UniversalParameters.
bdrEnterTriggeredButtonBorder
);
}
/*
* --------------------
*
de:
*
METHODE zum Einfärben des Hintergrundes eines GUI-Elements.
*
Das GUI-Element wird im Parameter parmContainer übergeben.
*
Die beiden Farben sind als Variable in der Struktur JSBS_UniversalParameters
*
definiert. Ursprünglich sind die beiden Farben im Bereich <Layout> in der Datei
*
'DisplayStrings.xml' festgelegt.
*
Welche Farbe für den Hintergrund verwendet wird, wird über den Parameter
*
parmErrorFree entschieden. 'true' bedeuted eine fehlerfreie Eingabe.
*
en:
*
METHOD to color the background of a GUI-element
* The GUI-element is passed in the paramter parmContainer.
* Both colors are defined as variables within the structure
*
JSBS_UniversalParameters. Originally those two colors are defined in the
*
<Layout> division within the file 'DisplayStrings.xml'
*
Which color is used for the background is controlled via the parameter
*
parmErrorFree. 'true' indicates that the entry is error-free.
*/
public
static void
setEntryFieldBackground(
Container
parmContainer,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
boolean
parmErrorFree) {
/*
de:
*
Prüfen daß die Parameter nicht 'null' sind; das würde zu einem Absturz führen.
*
en:
*
Check that the parameters are not 'null' as this would lead to a dump
later. */
if
(parmContainer
==
null
)
return
;
if
(parmJSBS_UniversalParameters
==
null
)
return
;
/*
de:
*
Besondere Behandlung für ein GUI-Element vom Typ JComboBox; dort ist der
*
Hintergrund erst Teil einer Unter-Komponente.
*
en:
*
Special treatment for a GUI-element of type JComboBox; there the background
*
is part of a sub-component. */
if
(parmContainer
instanceof
JComboBox) {
/*
de:
* Die Komponente der JComboBox, die den Background enthält herausholen und
* diesen entsprechend einfärben
.
*
en:
* Get the component of the JComboBox that contains the background and color
* this background according to parmErrorFree
. */
if
(parmErrorFree)
parmContainer.getComponent(2).setBackground(
parmJSBS_UniversalParameters.
clrNormalBackground
);
else
parmContainer.getComponent(2).setBackground(
parmJSBS_UniversalParameters.
clrErrorBackground
);
}
else
{
/*
de:
* Der Background ist direkt Teil des als Parameter übergebenen GUI-Elements
.
*
en:
* The background is a direct part of the GUI-element passed as parameter
. */
if
(parmErrorFree)
parmContainer.setBackground(
parmJSBS_UniversalParameters.
clrNormalBackground
);
else
parmContainer.setBackground(
parmJSBS_UniversalParameters.
clrErrorBackground
);
}
;
}
/*
* --------------------
* de:
* METHODE um den Rand (Border) eines JTextField, JTextArea oder JComboBox, die nicht den 'Focus'
* haben (d.h. der 'Cursor' ist nicht im Feld positioniert), zu setzen.
* Welche Farbe für den Rand (Border) verwendet wird ist durch die zugeordnete Variable
* in der Struktur JSBS_UniversalParameters festgelegt.
* en:
*
METHOD to set the border
to
a JTextField, JTextArea or a JComboBox
* that does not have
the 'focus' - i.e. the 'cursor' is not positioned in it.
*
Which color is used for the Border is defined by the associated
variable in JSBS_UniversalParameters. */
public
static void
setEntryFieldBorderUnfocussed(
Container
parmContainer,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
JSBS_EntryRules
parmJSBS_EntryRules) {
/*
* de: Prüfen dass der Parameter nicht 'null' ist; das würde zu einem Dump im weiteren Ablauf führen.
*
en: Check that the parameters are not 'null' as this would lead to a dump
later. */
if
(parmContainer
==
null
)
return
;
if
(parmJSBS_UniversalParameters
==
null
)
return
;
if
(parmJSBS_EntryRules
==
null
)
return
;
/*
* de:
* Name des 'Container' ermitteln; dieser Name wird verwendet um zu Untersuchen,
* ob dieses Feld eine verpflichtende (mandatory) Eingabe erfordert.
* en:
*
Get the name of the 'Container' as this name is used to search if
entry into
* this GUI-component is 'mandatory'.
*/
String
strContainerName = parmContainer.getName();
/*
* de:
* Nachsehen in den 'EntryRules' ob diese GUI-Komponente als 'mandatory' definiert wurde.
* en:
*
Look up the 'EntryRules' to see if entry to this GUI-component is
mandatory. */
boolean
bolMandatory =
parmJSBS_EntryRules.checkMandatory(strContainerName);
/*
* de:
* Feststellen welche Sub-Klasse die GUI-Komponente hat und den Rand setzen.
* en:
*
See which kind of GUI-component the container is and set the border
to it. */
if
(parmContainer
instanceof
JTextField) {
JTextField locJTextField = (JTextField) parmContainer;
if
(bolMandatory)
locJTextField.setBorder(parmJSBS_UniversalParameters.
bdrMandatoryBorder
);
else
locJTextField.setBorder(parmJSBS_UniversalParameters.
bdrOptionalBorder
);
}
/*
***** */
if
(parmContainer
instanceof
JTextArea) {
JTextArea
locJTextArea = (JTextArea) parmContainer;
if
(bolMandatory)
locJTextArea.setBorder(parmJSBS_UniversalParameters.
bdrMandatoryBorder
);
else
locJTextArea.setBorder(parmJSBS_UniversalParameters.
bdrOptionalBorder
);
}
/*
***** */
if
(parmContainer
instanceof
JComboBox) {
JComboBox
locJComboBox
=
(JComboBox) parmContainer;
if
(bolMandatory)
locJComboBox.setBorder(parmJSBS_UniversalParameters.
bdrMandatoryBorder
);
else
locJComboBox.setBorder(parmJSBS_UniversalParameters.
bdrOptionalBorder
);
}
}
/*
* --------------------
* de:
*
METHODE zum Einfärben des Border eines GUI-Elements das den 'Focus' hat
;
* d.h. der 'Cursor' ist in diesem GUI-Element positioniert.
* Die Farb-Kombination für das Border ist durch die
entsprechende Variable
*
in der Struktur
JSBS_UniversalParameters definiert.
* Weiters wird die zugehörige Info-Message aus der
XML-Structure ausgelesen und
* der Text wird auf das JLabel, das als Parameter übergeben
wurde, übertragen.
* en:
*
METHOD to set the border
to
a JTextField, JTextArea or a JComboBox
* that has the
'focus' - i.e. the 'cursor' is positioned within it.
* Which
color is used for the Border is defined by the associated variable
*
in
JSBS_UniversalParameters.
* Furthermore the associated Info-Message is derived from the
XML-Structure and
* the text is set to the JLabel passed as parameter.
*/
private
static void
setEntryFieldBorderFocussed(
Container
parmContainer,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
String
parmFrameClassName,
JSBS_XML_DisplayStrings
parmJSBS_XML_DisplayStrings,
JLabel
parmlbl_InfoMessage) {
/*
* de:
* Prüfen, dass die Parameter (nötig zum Einfärben des Border)
*
nicht 'null'-Werte
sind;
das würde zu einem
Dump führen.
* en:
*
Check that the
parameters (needed to color the Border) are not 'null'
*
as this would lead
to a dump
later. */
if
(parmContainer
==
null
)
return
;
if
(parmJSBS_UniversalParameters
==
null
)
return
;
/*
de:
* Prüfen, welche Klasse der als Parameter übergebene
'Container' hat und
* setzen des Borders
.
* en:
*
Verify which class
the 'Container' passed as parameter is
*
and set the Border
to it. */
if
(parmContainer
instanceof
JTextField) {
JTextField locJTextField = (JTextField) parmContainer;
locJTextField.setBorder(parmJSBS_UniversalParameters.
bdrSelectedBorder
);
}
/*
***** */
if
(parmContainer
instanceof
JTextArea) {
JTextArea
locJTextArea = (JTextArea) parmContainer;
locJTextArea.setBorder(parmJSBS_UniversalParameters.
bdrSelectedBorder
);
}
/*
***** */
if
(parmContainer
instanceof
JComboBox) {
JComboBox
locJComboBox = (JComboBox) parmContainer;
locJComboBox.setBorder(parmJSBS_UniversalParameters.
bdrSelectedBorder
);
}
/*
***** */
if
(parmContainer
instanceof
JList) {
JList
locJListBox = (JList) parmContainer;
locJListBox.setBorder(parmJSBS_UniversalParameters.
bdrSelectedBorder
);
}
/*
* de:
* Prüfen, daß die Parameter (nötig zum Auslesen der
Info-Message)
*
nicht 'null'-Werte
sind;
das würde zu einem
Dump führen.
* en:
*
Check that the
parameters (needed to get the Info-Message) are not 'null'
*
as this would lead
to a dump
later. */
if
(parmFrameClassName
==
null
)
return
;
if
(parmJSBS_XML_DisplayStrings
==
null
)
return
;
if
(parmlbl_InfoMessage
==
null
)
return
;
/*
de:
* Methode (in der Klasse JSBS_XML_DisplayStrings) zum
Auslesen der zugehörigen
* Info-Message aufrufen und Text auf das als Parameter
übergebene JLabel übertragen.
* en:
*
Call the method (in
class JSBS_XML_DisplayStrings) to derive the associated
*
Info-Message and
transfer the text to the JLabel passed as parameter. */
parmlbl_InfoMessage.setText(
parmJSBS_XML_DisplayStrings.getInfoMessage(
parmContainer, parmFrameClassName));
}
/*
* --------------------
* de:
*
WRAPPER-METHODE in der die nötigen Variablen aus einem JSBS_StartFrame
*
extrahiert werden und dann die private Methode (gleichen Namens)
aufgerufen wird
.
* en:
*
WRAPPER-METHOD in which the needed variables from a JSBS_StartFrame
are
* extracted and the private method (of same name) is called
.
*/
public
static void
setEntryFieldBorderFocussed(
Container
parmContainer,
JSBS_StartFrame
parmJSBS_StartFrame) {
setEntryFieldBorderFocussed(
parmContainer,
parmJSBS_StartFrame.structJSBS_UniversalParameters,
parmJSBS_StartFrame.getClass().getName(),
parmJSBS_StartFrame.structJSBS_XML_DisplayStrings,
parmJSBS_StartFrame.get_
lbl_InfoMessage());
}
/*
* --------------------
* de:
*
WRAPPER-METHODE in der die nötigen Varaiblen aus einem JSBS_TaskFrame
*
extrahiert werden und dann die private Methode (gleichen Namens)
aufgerufen wird
.
* en:
*
WRAPPER-METHOD in which the needed variables from a JSBS_TaskFrame
are
* extracted and the private method (of same name) is called
.
*/
public
static void
setEntryFieldBorderFocussed(
Container
parmContainer,
JSBS_TaskFrame
parmJSBS_TaskFrame) {
setEntryFieldBorderFocussed(
parmContainer,
parmJSBS_TaskFrame
.frmCC
.structJSBS_UniversalParameters,
parmJSBS_TaskFrame.getClass().getName(),
parmJSBS_TaskFrame
.frmCC
.structJSBS_XML_DisplayStrings,
parmJSBS_TaskFrame.get_
lbl_InfoMessage());
}
/*
* --------------------
*
de:
*
METHODE um einen 'Rand' (Border) um jede(s) JTextField, JTextArea oder JComboBox
*
hinzu zu fügen. Diese Methode untersucht den übergebenen Parameter 'Container'
*
rekursiv bis eine GUI-Komponente des geforderten Typs gefunden ist.
*
en:
*
METHOD to add a border to each TextField, JTextArea or JComboBox.
*
This method inspects the passed parameter 'Container' recursively
until a
* GUI-component of the requested type is found.
*/
private
static void
setEntryFieldBorders(Container
parmContainer,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
JSBS_EntryRules
parmJSBS_EntryRules) {
/*
de: Prüfen dass die Parameter nicht 'null' sind; das würde sonst zu einem Dump führen.
*
en:
Check that the parameters are not 'null' as this would lead to a dump
later. */
if
(parmContainer
==
null
)
return
;
if
(parmJSBS_UniversalParameters
==
null
)
return
;
if
(parmJSBS_EntryRules
==
null
)
return
;
/*
de:
*
Prüfen ob die GUI-Komponente 'Container' ein JTextField, eine JTextArea oder eine
*
JComboBox ist und dann die Methode aufrufen die den Rand mit der Farbe für ein GUI-Element,
*
das nicht den 'Focus' (der Positionszeiger ist darin positioniert) hat.
*
en:
*
Verify if the GUI-component 'Container' is a JTextField, a JTextArea or a
JComboBox
* and call the method to set the 'unfocussed'
border. */
if
( (parmContainer
instanceof
JTextField) || (parmContainer
instanceof
JTextArea)
|| (parmContainer
instanceof
JComboBox)
) {
setEntryFieldBorderUnfocussed(parmContainer,
parmJSBS_UniversalParameters, parmJSBS_EntryRules);
/*
de:
*
Weil eine Eingabe-Feld nicht ein anderes Eingabe-Feld enthalten kann wird die Methode
*
jetzt beendet.
*
en:
*
As an Entry-Field can not contain another Entry-Field the method is
terminated. */
return
;
}
/*
de: Den Container untersuchen ob er weitere 'components' enthält.
*
en:
Inspect the Container if it contains components. */
Component
comps[] = parmContainer.getComponents();
for
(
int
i = 0; i < comps.
length
;
i++) {
Component comp =
comps[i];
if
(comp
instanceof
Container) {
/*
de:
*
Ein Container kann weitere GUI-'components' vom Typ JPanel enthalten;
*
deswegen diese Methode rekursiv aufrufen.
*
en:
*
A Container may contain JPanel GUI-components; call this method
recursively. */
setEntryFieldBorders((Container) comp,
parmJSBS_UniversalParameters, parmJSBS_EntryRules);
}
}
}
/*
* --------------------
* de:
* METHODE um jedes JPanel, das im JPanel-Array, welches im Parameter parmJPanelArray
* übergeben wird, enthalten ist, mit einem farbigen Rand (border) zu versehen.
* Wenn der übergebene Parameter 'null' ist oder das Array die Länge 0 hat werden
* alle JPanels mit einem farbigen Rand versehen.
* Die Farbe des Randes ist in den Variablen 'PanelBorder1' und 'PanelBorder2' innerhalb
* der Struktur JSBS_UniversalParameters festgelegt.
* Welche Farbe verwendet wird ist durch den Parameter parmAlternateBorder bestimmt.
* en:
*
METHOD to add a border to each JPanel within the JPanel-array
*
passed with the parameter parmJPanelArray. If this parameter is 'null
or the array has length 0,
* all JPanel-Borders will be
colored.
* The color of the JPanel-border is defined as
'PanelBorder1'
or
'PanelBorder2'
*
within the JSBS_UniversalParameters.
* Which color is used
for the Border is defined by the parameter 'parmAlternateBorder'.
*/
private
static void
setPanelBorders(Container
parmContainer,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
JPanel[]
parmJPanelArray,
boolean
parmAlternateBorder) {
/*
* de:
* Prüfen, dass die Parameter nicht 'null' sind; das würde im weiteren Ablauf zu einem Dump führen.
* en:
*
Check that the parameters are not 'null' as this would lead to a dump
later. */
if
(parmContainer
==
null
)
return
;
if
(parmJSBS_UniversalParameters
==
null
)
return
;
/*
* de:
* Feststellen ob die GUI-Komponente 'Container' ein JPanel ist und wenn ja dann den Rand zuordnen.
* en:
*
Verify if the GUI-component 'Container' is a JPanel and set the
border if it is. */
if
(parmContainer
instanceof
JPanel) {
JPanel
locJPanel = (JPanel) parmContainer;
/*
* de: Einen Marker, ob dieses JPanel einen farbigen Rand bekommt, definieren
* en:
Define a Flag if this JPanel-Border has to be colored. */
boolean
bolColorBorder;
if
(parmJPanelArray
==
null
)
{
/*
* de: Alle Ränder von JPanels bekommen einen farbigen Rand; dieses auch.
* en:
All JPanel-Borders have to be colored - this too. */
bolColorBorder
=
true
;
}
else
{
if
(parmJPanelArray.length
== 0) {
/*
* de:
*
Keine Elemente im als Parameter übergebenen Array: Alle Ränder von JPanels werden eingefärbt -
* dieses auch.
* en:
*
No elements within the parameter: all JPanel-Borders have to be
colored - this too. */
bolColorBorder
=
true
;
}
else
{
/*
* de:
* Prüfen ob das bearbeitete JPanel im Array mit den 'einzufärbenden' JPanels enthalten ist.
* en:
*
Check if the processed JPanel is within the Array with the JPanels
which Borders should be colored. */
bolColorBorder
= isPanelWithinArray(parmJPanelArray, locJPanel);
}
}
/*
* de: Wenn der Rand des Panels eingefärbt werden soll dann wird dieses jetzt gemacht.
* en:
If this panel-border should be colored then it is done now. */
if
(bolColorBorder)
{
/*
* de: Der Rand des Panels wird mit der zu verwendenden Farbe versehen.
* en:
Depending which border-color should be used, the panel-border is
colored. */
if
(parmAlternateBorder)
locJPanel.setBorder(parmJSBS_UniversalParameters.
bdrPanelBorder2
);
else
locJPanel.setBorder(parmJSBS_UniversalParameters.
bdrPanelBorder1
);
}
}
/*
* de:
* Feststellen ob die GUI-Komponente 'Container' eine 'JSBS_Dividerline' ist und wenn ja dann diese
* Dividerline mit der 'HighlightColor' für den Panelrand einfärben
.
* en:
*
Verify if the GUI-component 'Container' is a 'JSBS_Dividerline' and if it is, then color it with
* the 'HighlightColor' of the panel-border
. */
if
(parmContainer
instanceof
JSBS_Dividerline) {
JSBS_Dividerline
locJSBS_Dividerline = (JSBS_Dividerline) parmContainer;
if
(parmAlternateBorder)
locJSBS_Dividerline
.changeColor(parmJSBS_UniversalParameters.
bdrPanelBorder2
.getHighlightColor());
else
locJSBS_Dividerline
.
changeColor
(parmJSBS_UniversalParameters.
bdrPanelBorder1
.getHighlightColor()
);
}
/*
* de: Untersuchen ob der Container weitere Komponenten enthält.
* en:
Inspect the Container if it contains components. */
Component
comps[] = parmContainer.getComponents();
for
(
int
i = 0; i < comps.
length
;
i++) {
Component comp =
comps[i];
if
(comp
instanceof
Container) {
/*
* de:
*
Der Container kann weitere GUI-Komponenten der Klasse JPanel enthalten;
* diese Methode rekursiv aufrufen.
* en:
*
A Container may contain JPanel GUI-components; call this method
recursively. */
setPanelBorders((Container) comp,
parmJSBS_UniversalParameters,
parmJPanelArray, parmAlternateBorder);
}
}
}
/*
* de:
* METHODEN
zum Prüfen ob ein JPanel (als Parameter übergeben) innerhalb des
* JPanel[]-Arrays das als Parameter übergeben wurde.
* en:
*
METHODS to check if a JPanel (passed as parameter)
* is
within the JPanel[]-array passed as parameter. */
private
static boolean
isPanelWithinArray(JPanel[] parmJPanelArray, JPanel parmJPanelToFind)
{
int
intArraySize = parmJPanelArray.
length
;
for
(
int
intArrayIndex = 0; intArrayIndex < intArraySize;
intArrayIndex++)
{
if
(parmJPanelArray[intArrayIndex]
== parmJPanelToFind)
return
true
;
}
return
false
;
}
/*
* de:
* Als public deklarierte METHODEN um die obige Methode zu umhüllen (wrap).
* Die Anforderung, welche Farbe für den Rand der Panels zu verwenden ist wird mit dem
* Parameter 'parmAlternateBorder' übergeben.
* en:
* Public METHODS to encapsulate (wrap) the above method.
* The demand
for the color of the panels is passed by the parameter
'parmAlternateBorder'. */
public
static void
setPanelBorders(Container
parmContainer,
JSBS_UniversalParameters parmJSBS_UniversalParameters) {
/*
* de:
* Als private deklarierte Methode aufrufen und die Information, dass die
* alternative Farbe _nicht_ für den Rand verwendet werden soll, übergeben
* en:
*
Call the private method and pass the information, that
* the
alternative Color should _not_ be used.
*/
setPanelBorders(parmContainer,
parmJSBS_UniversalParameters,
null
,
false
);
}
/*
*** */
public
static void
setPanelBordersAlternate(Container
parmContainer,
JSBS_UniversalParameters parmJSBS_UniversalParameters) {
/*
* de:
* Als private deklarierte Methode aufrufen und die Information, dass die
* alternative Farbe für den Rand verwendet werden soll, übergeben
* en:
*
Call the private method and pass the information, that
* the
alternative Color should be used.
*/
setPanelBorders(parmContainer,
parmJSBS_UniversalParameters,
null
,
true
);
}
/*
*** */
public
static void
setPanelBorders(Container
parmContainer,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
JPanel[] parmJPanelArray) {
/*
* de:
* Als private deklarierte Methode aufrufen und die Information, dass die
* alternative Farbe _nicht_ für den Rand verwendet werden soll, übergeben
* en:
*
Call the private method and pass the information, that
* the
alternative Color should _not_ be used.
*/
setPanelBorders(parmContainer,
parmJSBS_UniversalParameters, parmJPanelArray,
false
);
}
/*
*** */
public
static void
setPanelBordersAlternate(Container
parmContainer,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
JPanel[] parmJPanelArray) {
/*
* de:
* Als private deklarierte Methode aufrufen und die Information, dass die
* alternative Farbe für den Rand verwendet werden soll, übergeben
* en:
*
Call the private method and pass the information, that
* the
alternative Color should be used.
*/
setPanelBorders(parmContainer,
parmJSBS_UniversalParameters, parmJPanelArray,
true
);
}
/*
* --------------------
*
de:
*
METHODE um einen Wert vom Typ Short aus dem Text eines JTextField zu holen.
*
Wenn ein ungültiger (nicht ganzzahliger numerischer) Wert eingegeben wurde oder
*
der Wert die Eingaberegeln nicht erfüllt wird ein 'null'-Wert zurückgeliefert.
*
Im Falle eines ungültigen Eingabe-Wertes wird der 'Fehler-Hintergrund' gesetzt.
*
en:
*
METHOD to get a Short value out of the text entered in a
JTextField.
* If an invalid value (not numeric) was entered
or the entered value does not
* fulfill the EntryRules, a
'null' value is returned.
* In case of an invalid entry, the
'Error-Background' is set. */
public
static
Short getShort(JTextField parmJTextField, JSBS_StartFrame
parmfrmCC) {
/*
de:
*
Die notwendigen Daten-Structuren extrahieren und dann die Methode, die 'die wirkliche Arbeit'
*
macht, aufrufen.
*
en:
*
Extract the data-structures needed and call the 'method doing the real
work'. */
JSBS_UniversalParameters
locstructJSBS_UniversalParameters;
JSBS_EntryRules
locstructJSBS_EntryRules;
/*
de: Prüfen ob das GUI-Element ungültig ist um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Detail-Variable, die als Parameter für die private Methode notwendig sind, extrahieren.
*
en:
Extract the detail-variables that are requiered as parameters by the private
method. */
locstructJSBS_UniversalParameters
=
parmfrmCC.
structJSBS_UniversalParameters
;
locstructJSBS_EntryRules
= parmfrmCC.
structJSBS_EntryRules
;
/*
de: private Methode die Arbeit machen lassen.
*
en:
Let the private method do the work. */
return
getShort(parmJTextField,
locstructJSBS_UniversalParameters,
locstructJSBS_EntryRules);
}
/
*
* de: METHODE mit einem Task-Frame als Parameter.
*
en:
METHOD with a Task-Frame as parameter. */
public
static
Short getShort(JTextField parmJTextField, JSBS_TaskFrame parmJSBS_TaskFrame)
{
/*
de:
*
Die notwendigen Daten-Structuren extrahieren und dann die Methode, die 'die wirkliche Arbeit'
*
macht, aufrufen.
*
en:
*
Extract the data-structures needed and then call the 'method doing the real
work'. */
JSBS_UniversalParameters
locstructJSBS_UniversalParameters;
JSBS_EntryRules
locstructJSBS_EntryRules;
/*
de: Prüfen ob das GUI-Element ungültig ist um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Detail-Variable, die als Parameter für die private Methode notwendig sind, extrahieren.
*
en:
Extract the detail-variables that are requiered as parameters by the private
method. */
locstructJSBS_UniversalParameters
=
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_UniversalParameters
;
locstructJSBS_EntryRules
=
parmJSBS_TaskFrame
.
structJSBS_EntryRules
;
/*
de: private Methode die Arbeit machen lassen und Ergebnis für weitere Verarbeitung aufheben.
*
en:
Let the private method do the work and keep the result for further processing. */
Short intIntermediateResult = getShort(parmJTextField,
locstructJSBS_UniversalParameters,
locstructJSBS_EntryRules);
/*
*
de:
*
Wenn die Methode 'null' zurückliefert dann wurde die Eingabe-Regel nicht
*
erfüllt
.
*
en:
*
If the method return 'null' then the EntryRule was not fulfilled. */
if
(
intIntermediateResult
!=
null
)
{
/*
*
de:
*
Eingabe-Regel
erfüllt
; Eingabe-Hinweis anzeigen weil in 'lbl_InfoMessage'
*
eventuell durch
einen vorigen Fehler ein Fehler-Hinweis enthalten ist.
*
en:
*
Entry-Rule fulfilled; show the Info-Message for the entry because an
*
Error-Message might be displayed in
'lbl_InfoMessage' due to a previous
*
error.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
parmJSBS_TaskFrame.
frmCC
.
structJSBS_XML_DisplayStrings
.getInfoMessage(
parmJTextField, parmJSBS_TaskFrame.getClass().getName())
)
;
/*
de: Eingegebenen Wert für das Short zurückliefern
.
*
en: Return entered value for the Short
.
*/
return
intIntermediateResult;
}
else
{
/*
*
de:
*
Eingabe-Regel nicht
erfüllt
; mit dem folgenden Code feststellen ob der Wert
zu klein
* oder zu groß ist und dann den entsprechenden
Eingabe-Hinweis in
'lbl_InfoMessage' anzeigen
.
*
en:
*
Entry-Rule not fulfilled; verify with the following code if the value ist too small or too big
* and then display the fitting Info in 'lbl_InfoMessage'
.
*/
/*
*
de: Lokale Hilfs-Variablen.
*
en: Local auxilliary variables
. */
String locstrInfoMessageText =
""
;
BigDecimal locbdEntryRuleValue =
new
BigDecimal(0);
/*
*
de: Eingegebenen Wert ohne Prüfung aus dem GUI-Element extrahieren.
*
en: Extract the entered value out of the GUI-Element
. */
intIntermediateResult = getShort(parmJTextField,
locstructJSBS_UniversalParameters,
null
);
/*
*
de:
*
Zuerst Prüfen ob der eingegebene Wert überhaupt numerisch und innerhalb des Bereichs
*
für die Java-Klasse ist
.
*
en:
*
Verify first if the entered value is numeric and within the range of the Java-class
. */
if
(
intIntermediateResult ==
null
)
{
/*
*
de:
Eingegebene Wert nicht gültig für die Java-Klasse; weiter unterscheiden
.
*
en: Entered value not valid for the Java-class; make a further decision
. */
if
(
parmJTextField.getText().trim().length() == 0
)
{
/*
*
de: Eingabefelde leer; prüfen ob das Feld 'mandatory' ist
.
*
en: Entry field empty; check if the field is 'mandatory'
. */
if
(
parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMandatory(
parmJTextField.getName())
)
{
/*
*
de: Eingabefelde leer aber als 'mandatory' definiert; Fehler-Hinweis anzeigen
.
*
en: Entry field empty but defined as 'mandatory'
; show error-message. */
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueMandatory"
);
}
else
{
/*
*
de:
*
Eingabe-Feld leer aber nicht 'mandatory' ist kein Fehler
; Eingabe-Hinweis anzeigen weil
*
in 'lbl_InfoMessage'
eventuell durch
einen vorigen Fehler ein Fehler-Hinweis enthalten ist.
*
en:
*
Entry-field empty but not 'mandatory' ist not an error; show the Info-Message for the entry
*
because an
Error-Message might be displayed in
'lbl_InfoMessage' due to a previous
error.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
parmJSBS_TaskFrame.
frmCC
.
structJSBS_XML_DisplayStrings
.getInfoMessage(
parmJTextField, parmJSBS_TaskFrame.getClass().getName())
)
;
/*
de: Eingegebenen Wert für das Short zurückliefern
.
*
en: Return entered value for the Short
.
*/
return
intIntermediateResult;
}
}
else
{
/*
*
de:
*
Eingabe Fehlerhaft aber nicht durch leeres Feld und 'mandatory'
.
*
Grund kann eine nicht numerische Eingabe oder ein Wert ausserhalb des Wertebereichs
*
für die Java-Klasse sein.
*
en:
*
Entry in error but not due to an empty field and 'mandatory'.
*
Reason is either a non-numeric entry or a value out of the value-range of the java-class
. */
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueNotNumeric"
);
}
}
else
{
/*
*
de:
*
Eingegebener Wert is numerisch und innerhalb des Wertebereich der Java-Klasse
.
*
Detaillierten Fehler ermitteln
*
en:
*
Entered value is numeric and within the value-range of the Java-class.
* Find out the detailed error-reason. */
/*
*
de:
Prüfen ob der eingegebene Wert zu klein ist
.
*
en: Verify if the entered value is too small
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMinimumValue(
parmJTextField.getName(), intIntermediateResult)
)
{
/*
de:
*
Eingegebener Wert zu klein
.
*
Aus den Prüf-Regeln den notwendigen Minimalwert auslesen.
*
en:
*
Entered value too small.
*
Get the requiered minimum value out of the Entry-Rules.
*/
locbdEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMinimumValue(
parmJTextField.getName());
/*
de:
*
Sprachabhängigen Fehler-Text für die Info-Message ermitteln und den
* Minimal-Wert 'anhängen'
.
*
en:
*
Get the language-dependant error-text for the info-message
and 'concate' the
*
minimum-value
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueTooSmall"
);
locstrInfoMessageText +=
" "
+
setBigDecimalToString(locbdEntryRuleValue,
locstructJSBS_UniversalParameters.
strLanguageDependantDecimalPoint
, 0
)
;
}
/*
*
de:
Prüfen ob der eingegebene Wert zu gross ist
.
*
en: Verify if the entered value is too large
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMaximumValue(
parmJTextField.getName(), intIntermediateResult)
)
{
/*
de:
*
Eingegebener Wert zu gross
.
*
Aus den Prüf-Regeln den notwendigen Maximalwert auslesen.
*
en:
*
Entered value too large.
*
Get the requiered maximum value out of the Entry-Rules.
*/
locbdEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMaximumValue(
parmJTextField.getName());
/*
de:
*
Sprachabhängigen Fehler-Text für die Info-Message ermitteln und den
* Maximal-Wert 'anhängen'
.
*
en:
*
Get the language-dependant error-text for the info-message
and 'concate' the
* maximum-value
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueTooBig"
);
locstrInfoMessageText +=
" "
+
setBigDecimalToString(locbdEntryRuleValue,
locstructJSBS_UniversalParameters.
strLanguageDependantDecimalPoint
, 0
)
;
}
}
/*
de:
Fehler-Text im GUI-Element 'lbl_InfoMessage' anzeigen
.
*
en: Display the error-message in the GUI-Element 'lbl_InfoMessage'
.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
locstrInfoMessageText
);
/*
de:
*
Aufrufender Methode durch 'null' signalisieren, dass der eingegebene
Wert
*
die Eingabe-Regel nicht erfüllt.
*
en:
*
Signal to the calling method by 'null' that the entered value has not passed
*
the Entry-Rules
.
*/
return null
;
}
}
/
*
* de:
* Private METHODE die den Short-Wert extrahiert, prüft ob er innerhalb der Grenzen
* der der Prüfregeln liegt und den Feld-Hintergrund einfärbt - abhängig davon ob
* der Wert die Prüfregeln erfüllt oder nicht.
* en:
* Private METHOD that extracts the Short value,
checks against the limit
* and colors the
field-background depending if an error was detected or not.
*/
private
static
Short getShort(JTextField parmJTextField,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
JSBS_EntryRules
parmJSBS_EntryRules) {
/*
de: Prüfen ob das GUI-Element ungültig ist um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Eine Variable für den Wert, den die Methode zurück gibt, definieren.
*
en:
Define the variable holding the value to be returned.
*/
Short
locintReturnValue
;
/*
de: Eine Variable für den Text aus dem Feld definieren und den Text aus dem Feld holen.
*
en:
Define the variable for the text entered within the field and get the
text. */
String
strEnteredText = getTextFromJTextField(parmJTextField).trim();
/*
de: auf eine 'leere' Variable prüfen um einen Dump zu vermeiden.
*
en: Check for empty variable to avoid a dump. */
if
(strEnteredText ==
null
)
return
null
;
/*
* de:
* Ein '+' Zeichen an führenden oder nachfolgender Position oder
* ein '-' Zeichen an nachfolgender Position
* führen zu einem Fehler wenn versucht wird, den 'Text' in den Typ Short zu konvertieren.
* Deswegen muss ein '+' entfernt werden und das '-' an die führende Position gesetzt werden.
* en:
* A
'+' sign on the leading or trailing position or
* a '-'
sign on the trailing position
* causes an error when
the 'text' is tried to be converted to the type Short.
* Therefore
'+' has to be removed and '-' has to be set to the leading position.
*/
int
intSignPosition
= strEnteredText.indexOf(
'+'
);
/*
de:
*
Beginnen mit der Prüfung ob ein '+' an führender Position ist.
* In diesem Fall das '+'-Zeichen entfernen.
* en:
*
Start with the check for '+' at the leading position.
* In that case remove the '+'-character
. */
if
(intSignPosition
== 0) {
strEnteredText
= strEnteredText.substring(1);
strEnteredText
= strEnteredText.trim();
}
/*
de:
* Prüfen ob ein '+' an nachfolgender Position ist.
* In diesem Fall das '+'-Zeichen entfernen.
* en:
*
Check for '+' at the trailing position
.
* In that case remove the '+'-character
.
*/
if
( (intSignPosition
> 0)
&& (intSignPosition
== (strEnteredText.length() - 1))) {
strEnteredText
= strEnteredText.substring(0,
intSignPosition);
strEnteredText
= strEnteredText.trim();
}
/*
de:
* Prüfen ob ein '-' an nachfolgender Position ist.
* In diesem Fall das '-'-Zeichen vor die Zahl setzen.
* en:
*
Check for '-' at the trailing position
.
* In that case set the '+'-character in front of the number
.
*/
intSignPosition
= strEnteredText.indexOf(
'-'
);
if
( (intSignPosition
> 0)
&& (intSignPosition
== (strEnteredText.length() - 1))) {
strEnteredText
= strEnteredText.substring(0,
intSignPosition);
strEnteredText
= strEnteredText.trim();
/*
de: Das '-' Zeichen an den Beginn des Textes bringen damit der Text konvertiert werden kann.
* en:
Bring the '-' sign to the begin of the text-string so that the text
can be converted. */
strEnteredText
=
"-"
+ strEnteredText;
}
/*
* de: Die 'Short' Klasse die Umwandlung von der Zeichenkette in Short ausfüheren lassen.
* en: Let the 'Short' class do the conversion from
String to Short. */
try
{
locintReturnValue
=
new
Short(strEnteredText.trim());
}
catch
(Exception Exc) {
/*
* de:
*
Boolsche Variable zum Entscheiden, ob eine verpflichtende Eingabe für das Feld festgelegt
* ist.
Ob die Eingabe verpflichtend ist, ist in der Struktur JSBS_EntryRules (als Parameter übergeben)
*
definiert. Nachdem der Parameter auch 'null' sein kann, kann die if-Abfrage nicht direkt auf die
* Struktur JSBS_EntryRules erfolgen.
* en:
*
Boolean variable to decide if a mandatory entry is definied for the field. A mandatory entry for the field
* is specified within the structure JSBS_EntryRules (passed as parameter). As this parameter can be 'null',
* the if-decision can not directly use the JSBS_EntraRules structure
. */
boolean
bolMandatory =
false
;
/*
* de: Wenn ein Wert für JSBS_EntryRules in den Parametern übergeben wurde dann auf 'mandatory' prüfen.
* en: If a value was passed for JSBS_EntryRules in the parameters then check for 'mandatory'. */
if
(parmJSBS_EntryRules !=
null
)
bolMandatory = parmJSBS_EntryRules.checkMandatory(parmJTextField.getName())
;
/* de:
* 'Fehler'-Hintergrund wird nur gesetzt wenn ein nicht numerischer Wert eingegeben
* wurde oder das Feld als 'mandatory' festgelegt ist.
* en:
*
'Error'-background
is only set if there was a non-numeric value entered
* or
the field is defined as 'mandatory'.
*/
if
((strEnteredText.trim().length()
>
0) || bolMandatory)
{
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
}
else
{
/* de:
* Wenn kein Text eingegeben wurde und das Feld nicht als 'mandatory' definiert ist
* wird der normale Hintergrund gesetzt.
* en:
*
If
no text was entered and the field is not defined mandatory,
* then
the normal background is set.
*/
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
}
/* de: Ein 'Short'-Wert konnte nicht 'herausgeholt' werden: 'null' wird zurück geliefert.
* en:
As
a 'Short'-value could not be derived: 'null' is returned.
*/
return
null
;
}
/* de:
* Der eingegebene 'Text' konnte auf einen Short-Wert umgewandelt werden;
* zuerst prüfen ob in den Parametern auch eine Struktur mit den Prüfregeln übergeben wurde.
* en:
*
Entered
'text' could be converted to an Short value;
* check first if a structure with validation rules was passed in the parameters.
*/
if
(parmJSBS_EntryRules ==
null
)
return
locintReturnValue;
/* de:
* Prüfregeln wurden als Parameter übergeben.
* Prüfen ob der Wert innerhalb der 'Minimum' und 'Maximum' Werte ist
(soferne diese
*
festgelegt sind)
* en:
*
Validation rules were passed as parameter.
* check
the value against 'Minimum' and 'Maximum' values (if defined).
*/
if
(parmJSBS_EntryRules.checkValueRange(parmJTextField.getName(),
locintReturnValue)) {
/* de: Eingegebener Wert ist innerhalb des Bereichs; Hintergrund setzen und Wert zurückliefern.
* en:
Entered
value within the range; set background and return the value.
*/
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
return
locintReturnValue;
}
else
{
/* de: Eingegebener Wert ist ein gültiger Short-Wert aber ausserhalb des festgelegten Bereichs.
* en:
Entered
value is a valid Short-value but without the defined range.
*/
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
return
null
;
}
}
/*
* --------------------
*
de:
*
METHODE um einen Wert vom Type Integer aus dem Text eines JTextField zu holen.
*
Wenn ein ungültiger (nicht ganzzahliger numerischer) Wert eingegeben wurde oder
*
der Wert die Eingaberegeln nicht erfüllt wird ein 'null'-Wert zurückgeliefert.
*
Im Falle eines ungültigen Eingabe-Wertes wird der 'Fehler-Hintergrund' gesetzt.
*
en:
*
METHOD to get a Integer value out of the text entered in a
JTextField.
* If an invalid value (not numeric) was entered
or the entered value does not
* fulfill the EntryRules, a
'null' value is returned.
* In case of an invalid entry, the
'Error-Background' is set. */
public
static
Integer getInteger(JTextField parmJTextField, JSBS_StartFrame
parmfrmCC) {
/*
de:
*
Die notwendigen Daten-Structuren extrahieren und dann die Methode, die 'die wirkliche Arbeit'
*
macht, aufrufen.
*
en:
*
Extract the data-structures needed and then call the 'method doing the real
work'. */
JSBS_UniversalParameters
locstructJSBS_UniversalParameters;
JSBS_EntryRules
locstructJSBS_EntryRules;
/*
de: Prüfen ob das GUI-Element ungültig ist um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Detail-Variable, die als Parameter für die private Methode notwendig sind, extrahieren.
*
en:
Extract the detail-variables that are requiered as parameters by the private
method. */
locstructJSBS_UniversalParameters
=
parmfrmCC.
structJSBS_UniversalParameters
;
locstructJSBS_EntryRules
= parmfrmCC.
structJSBS_EntryRules
;
/*
de: private Methode die Arbeit machen lassen.
*
en:
Let the private method do the work. */
return
getInteger(parmJTextField,
locstructJSBS_UniversalParameters,
locstructJSBS_EntryRules);
}
/
*
* de: METHODE mit einem Task-Frame als Parameter.
*
en:
METHOD with a Task-Frame as parameter. */
public
static
Integer getInteger
(JTextField parmJTextField, JSBS_TaskFrame parmJSBS_TaskFrame)
{
/*
de:
*
Die notwendigen Daten-Structuren extrahieren und dann die Methode, die 'die wirkliche Arbeit'
*
macht, aufrufen.
*
en:
*
Extract the data-structures needed and then call the 'method doing the real
work'. */
JSBS_UniversalParameters
locstructJSBS_UniversalParameters;
JSBS_EntryRules
locstructJSBS_EntryRules;
/*
de: Prüfen ob das GUI-Element ungültig ist um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Detail-Variable, die als Parameter für die private Methode notwendig sind, extrahieren.
*
en:
Extract the detail-variables that are requiered as parameters by the private
method. */
locstructJSBS_UniversalParameters
=
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_UniversalParameters
;
locstructJSBS_EntryRules
=
parmJSBS_TaskFrame
.
structJSBS_EntryRules
;
/*
de: private Methode die Arbeit machen lassen und Ergebnis für weitere Verarbeitung aufheben.
*
en:
Let the private method do the work and keep the result for further processing. */
Integer intIntermediateResult = getInteger(parmJTextField,
locstructJSBS_UniversalParameters,
locstructJSBS_EntryRules);
/*
*
de:
*
Wenn die Methode 'null' zurückliefert dann wurde die Eingabe-Regel nicht
*
erfüllt
.
*
en:
*
If the method return 'null' then the EntryRule was not fulfilled. */
if
(
intIntermediateResult
!=
null
)
{
/*
*
de:
*
Eingabe-Regel
erfüllt
; Eingabe-Hinweis anzeigen weil in 'lbl_InfoMessage'
*
eventuell durch
einen vorigen Fehler ein Fehler-Hinweis enthalten ist.
*
en:
*
Entry-Rule fulfilled; show the Info-Message for the entry because an
*
Error-Message might be displayed in
'lbl_InfoMessage' due to a previous
*
error.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
parmJSBS_TaskFrame.
frmCC
.
structJSBS_XML_DisplayStrings
.getInfoMessage(
parmJTextField, parmJSBS_TaskFrame.getClass().getName())
)
;
/*
de: Eingegebenen Wert für das Short zurückliefern
.
*
en: Return entered value for the Short
.
*/
return
intIntermediateResult;
}
else
{
/*
*
de:
*
Eingabe-Regel nicht
erfüllt
; mit dem folgenden Code feststellen ob der Wert
zu klein
* oder zu groß ist und dann den entsprechenden
Eingabe-Hinweis in
'lbl_InfoMessage' anzeigen
.
*
en:
*
Entry-Rule not fulfilled; verify with the following code if the value ist too small or too big
* and then display the fitting Info in 'lbl_InfoMessage'
.
*/
/*
*
de: Lokale Hilfs-Variablen.
*
en: Local auxilliary variables
. */
String locstrInfoMessageText =
""
;
BigDecimal locbdEntryRuleValue =
new
BigDecimal(0);
/*
*
de: Eingegebenen Wert ohne Prüfung aus dem GUI-Element extrahieren.
*
en: Extract the entered value out of the GUI-Element
. */
intIntermediateResult = getInteger(parmJTextField,
locstructJSBS_UniversalParameters,
null
);
/*
*
de:
*
Zuerst Prüfen ob der eingegebene Wert überhaupt numerisch und innerhalb des Bereichs
*
für die Java-Klasse ist
.
*
en:
*
Verify first if the entered value is numeric and within the range of the Java-class
. */
if
(
intIntermediateResult ==
null
)
{
/*
*
de:
Eingegebene Wert nicht gültig für die Java-Klasse; weiter unterscheiden
.
*
en: Entered value not valid for the Java-class; make a further decision
. */
if
(
parmJTextField.getText().trim().length() == 0
)
{
/*
*
de: Eingabefelde leer; prüfen ob das Feld 'mandatory' ist
.
*
en: Entry field empty; check if the field is 'mandatory'
. */
if
(
parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMandatory(
parmJTextField.getName())
)
{
/*
*
de: Eingabefelde leer aber als 'mandatory' definiert; Fehler-Hinweis anzeigen
.
*
en: Entry field empty but defined as 'mandatory'
; show error-message. */
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueMandatory"
);
}
else
{
/*
*
de:
*
Eingabe-Feld leer aber nicht 'mandatory' ist kein Fehler
; Eingabe-Hinweis anzeigen weil
*
in 'lbl_InfoMessage'
eventuell durch
einen vorigen Fehler ein Fehler-Hinweis enthalten ist.
*
en:
*
Entry-field empty but not 'mandatory' ist not an error; show the Info-Message for the entry
*
because an
Error-Message might be displayed in
'lbl_InfoMessage' due to a previous
error.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
parmJSBS_TaskFrame.
frmCC
.
structJSBS_XML_DisplayStrings
.getInfoMessage(
parmJTextField, parmJSBS_TaskFrame.getClass().getName())
)
;
/*
de: Eingegebenen Wert für das Short zurückliefern
.
*
en: Return entered value for the Short
.
*/
return
intIntermediateResult;
}
}
else
{
/*
*
de:
*
Eingabe Fehlerhaft aber nicht durch leeres Feld und 'mandatory'
.
*
Grund kann eine nicht numerische Eingabe oder ein Wert ausserhalb des Wertebereichs
*
für die Java-Klasse sein.
*
en:
*
Entry in error but not due to an empty field and 'mandatory'.
*
Reason is either a non-numeric entry or a value out of the value-range of the java-class
. */
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueNotNumeric"
);
}
}
else
{
/*
*
de:
*
Eingegebener Wert is numerisch und innerhalb des Wertebereich der Java-Klasse
.
*
Detaillierten Fehler ermitteln
*
en:
*
Entered value is numeric and within the value-range of the Java-class.
* Find out the detailed error-reason. */
/*
*
de:
Prüfen ob der eingegebene Wert zu klein ist
.
*
en: Verify if the entered value is too small
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMinimumValue(
parmJTextField.getName(), intIntermediateResult)
)
{
/*
de:
*
Eingegebener Wert zu klein
.
*
Aus den Prüf-Regeln den notwendigen Minimalwert auslesen.
*
en:
*
Entered value too small.
*
Get the requiered minimum value out of the Entry-Rules.
*/
locbdEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMinimumValue(
parmJTextField.getName());
/*
de:
*
Sprachabhängigen Fehler-Text für die Info-Message ermitteln und den
* Minimal-Wert 'anhängen'
.
*
en:
*
Get the language-dependant error-text for the info-message
and 'concate' the
*
minimum-value
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueTooSmall"
);
locstrInfoMessageText +=
" "
+
setBigDecimalToString(locbdEntryRuleValue,
locstructJSBS_UniversalParameters.
strLanguageDependantDecimalPoint
, 0
)
;
}
/*
*
de:
Prüfen ob der eingegebene Wert zu gross ist
.
*
en: Verify if the entered value is too large
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMaximumValue(
parmJTextField.getName(), intIntermediateResult)
)
{
/*
de:
*
Eingegebener Wert zu gross
.
*
Aus den Prüf-Regeln den notwendigen Maximalwert auslesen.
*
en:
*
Entered value too large.
*
Get the requiered maximum value out of the Entry-Rules.
*/
locbdEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMaximumValue(
parmJTextField.getName());
/*
de:
*
Sprachabhängigen Fehler-Text für die Info-Message ermitteln und den
* Maximal-Wert 'anhängen'
.
*
en:
*
Get the language-dependant error-text for the info-message
and 'concate' the
* maximum-value
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueTooBig"
);
locstrInfoMessageText +=
" "
+
setBigDecimalToString(locbdEntryRuleValue,
locstructJSBS_UniversalParameters.
strLanguageDependantDecimalPoint
, 0
)
;
}
}
/*
de:
Fehler-Text im GUI-Element 'lbl_InfoMessage' anzeigen
.
*
en: Display the error-message in the GUI-Element 'lbl_InfoMessage'
.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
locstrInfoMessageText
);
/*
de:
*
Aufrufender Methode durch 'null' signalisieren, dass der eingegebene
Wert
*
die Eingabe-Regel nicht erfüllt.
*
en:
*
Signal to the calling method by 'null' that the entered value has not passed
*
the Entry-Rules
.
*/
return null
;
}
}
/
*
* de:
* Private METHODE die den Integer-Wert extrahiert, prüft ob er innerhalb der Grenzen
* der der Prüfregeln liegt und den Feld-Hintergrund einfärbt - abhängig davon ob
* der Wert die Prüfregeln erfüllt oder nicht.
* en:
* Private METHOD that extracts the Integer value,
checks against the limit
* and colors the
field-background depending if an error was detected or not.
*/
public
static
Integer getInteger
(JTextField parmJTextField,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
JSBS_EntryRules
parmJSBS_EntryRules) {
/*
de: Prüfen ob das GUI-Element ungültig ist um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Eine Variable für den Wert, den die Methode zurück gibt, definieren.
*
en:
Define the variable holding the value to be returned.
*/
Integer
locintReturnValue
;
/*
de: Eine Variable für den Text aus dem Feld definieren und den Text aus dem Feld holen.
*
en:
Define the variable for the text entered within the field and get the
text. */
String
strEnteredText = getTextFromJTextField(parmJTextField).trim();
/*
de: auf eine 'leere' Variable prüfen um einen Dump zu vermeiden.
*
en: Check for empty variable to avoid a dump. */
if
(strEnteredText ==
null
)
return
null
;
/*
* de:
* Ein '+' Zeichen an führenden oder nachfolgender Position oder
* ein '-' Zeichen an nachfolgender Position
* führen zu einem Fehler wenn versucht wird, den 'Text' in den Typ Integer zu konvertieren.
* Deswegen muss ein '+' entfernt werden und das '-' an die führende Position gesetzt werden.
* en:
* A
'+' sign on the leading or trailing position or
* a '-'
sign on the trailing position
* causes an error when
the 'text' is tried to be converted to the Integer.
* Therefore
'+' has to be removed and '-' has to be set to the leading position.
*/
int
intSignPosition
= strEnteredText.indexOf(
'+'
);
/*
de:
*
Beginnen mit der Prüfung ob ein '+' an führender Position ist.
* In diesem Fall das '+'-Zeichen entfernen.
* en:
*
Start with the check for '+' at the leading position.
* In that case remove the '+'-character
. */
if
(intSignPosition
== 0) {
strEnteredText
= strEnteredText.substring(1);
strEnteredText
= strEnteredText.trim();
}
/*
de:
* Prüfen ob ein '+' an nachfolgender Position ist.
* In diesem Fall das '+'-Zeichen entfernen.
* en:
*
Check for '+' at the trailing position
.
* In that case remove the '+'-character
.
*/
if
( (intSignPosition
> 0)
&& (intSignPosition
== (strEnteredText.length() - 1))) {
strEnteredText
= strEnteredText.substring(0,
intSignPosition);
strEnteredText
= strEnteredText.trim();
}
/*
de:
* Prüfen ob ein '-' an nachfolgender Position ist.
* In diesem Fall das '-'-Zeichen vor die Zahl setzen.
* en:
*
Check for '-' at the trailing position
.
* In that case set the '+'-character in front of the number
.
*/
intSignPosition
= strEnteredText.indexOf(
'-'
);
if
( (intSignPosition
> 0)
&& (intSignPosition
== (strEnteredText.length() - 1))) {
strEnteredText
= strEnteredText.substring(0,
intSignPosition);
strEnteredText
= strEnteredText.trim();
/*
de: Das '-' Zeichen an den Beginn des Textes bringen damit der Text konvertiert werden kann.
* en:
Bring the '-' sign to the begin of the text-string so that the text
can be converted. */
strEnteredText
=
"-"
+ strEnteredText;
}
/*
* de: Die 'Integer' Klasse die Umwandlung von der Zeichenkette in Integer ausfüheren lassen.
* en: Let the 'Integer' class do the conversion from
String to Integer. */
try
{
locintReturnValue
=
new
Integer(strEnteredText.trim());
}
catch
(Exception Exc) {
/*
* de:
*
Boolsche Variable zum Entscheiden, ob eine verpflichtende Eingabe für das Feld festgelegt
* ist.
Ob die Eingabe verpflichtend ist, ist in der Struktur JSBS_EntryRules (als Parameter übergeben)
*
definiert. Nachdem der Parameter auch 'null' sein kann, kann die if-Abfrage nicht direkt auf die
* Struktur JSBS_EntryRules erfolgen.
* en:
*
Boolean variable to decide if a mandatory entry is definied for the field. A mandatory entry for the field
* is specified within the structure JSBS_EntryRules (passed as parameter). As this parameter can be 'null',
* the if-decision can not directly use the JSBS_EntraRules structure
. */
boolean
bolMandatory =
false
;
/*
* de: Wenn ein Wert für JSBS_EntryRules in den Parametern übergeben wurde dann auf 'mandatory' prüfen.
* en: If a value was passed for JSBS_EntryRules in the parameters then check for 'mandatory'. */
if
(parmJSBS_EntryRules !=
null
)
bolMandatory = parmJSBS_EntryRules.checkMandatory(parmJTextField.getName())
;
/* de:
* 'Fehler'-Hintergrund wird nur gesetzt wenn ein nicht numerischer Wert eingegeben
* wurde oder das Feld als 'mandatory' festgelegt ist.
* en:
*
'Error'-background
is only set if there was a non-numeric value entered
* or
the field is defined as 'mandatory'.
*/
if
((strEnteredText.trim().length()
>
0) || bolMandatory)
{
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
}
else
{
/* de:
* Wenn kein Text eingegeben wurde und das Feld nicht als 'mandatory' definiert ist
* wird der normale Hintergrund gesetzt.
* en:
*
If
no text was entered and the field is not defined mandatory,
* then
the normal background is set.
*/
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
}
/* de: Ein 'Integer'-Wert konnte nicht 'herausgeholt' werden: 'null' wird zurück geliefert.
* en:
As
a Integer-value could not be derived: 'null' is returned.
*/
return
null
;
}
/* de:
* Der eingegebene 'Text' konnte auf einen Integer-Wert umgewandelt werden;
* zuerst prüfen ob in den Parametern auch eine Struktur mit den Prüfregeln übergeben wurde.
* en:
*
Entered
'text' could be converted to an Integer value;
* check first if a structure with validation rules was passed in the parameters.
*/
if
(parmJSBS_EntryRules ==
null
)
return
locintReturnValue;
/* de:
* Prüfregeln wurden als Parameter übergeben.
* Prüfen ob der Wert innerhalb der 'Minimum' und 'Maximum' Werte ist
(soferne diese
*
festgelegt sind)
* en:
*
Validation rules were passed as parameter.
* check
the value against 'Minimum' and 'Maximum' values (if defined).
*/
if
(parmJSBS_EntryRules.checkValueRange(parmJTextField.getName(),
locintReturnValue)) {
/* de: Eingegebener Wert ist innerhalb des Bereichs; Hintergrund setzen und Wert zurückliefern.
* en:
Entered
value within the range; set background and return the value.
*/
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
return
locintReturnValue;
}
else
{
/* de: Eingegebener Wert ist ein gültiger Integer-Wert aber ausserhalb des festgelegten Bereichs.
* en:
Entered
value is a valid Integer but without the defined range.
*/
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
return
null
;
}
}
/*
* --------------------
*
de:
*
METHODE um einen Wert vom Typ BigDecimal aus dem Text eines JTextField zu holen.
*
Wenn ein ungültiger (falsches oder zu viele Dezimaltrennzeichen) Wert eingegeben wurde
*
oder der Wert die Eingaberegeln nicht erfüllt wird ein 'null'-Wert zurückgeliefert.
*
Im Falle eines ungültigen Eingabe-Wertes wird der 'Fehler-Hintergrund' gesetzt.
*
en:
*
METHOD to get a BigDecimal value out of the text entered in a
JTextField.
* If an invalid value (wrong or to many decimal-seperators) was entered
or the
*
entered value does not
fulfill the EntryRules, a
'null' value is returned.
* In case of an invalid entry, the
'Error-Background' is set. */
public
static
BigDecimal getBigDecimal(JTextField parmJTextField, JSBS_StartFrame
parmfrmCC) {
/*
de:
*
Die notwendigen Daten-Structuren extrahieren und dann die Methode, die 'die wirkliche Arbeit'
*
macht, aufrufen.
*
en:
*
Extracted data-structures needed when calling the 'method doing the real
work'. */
JSBS_UniversalParameters
locstructJSBS_UniversalParameters;
JSBS_EntryRules
locstructJSBS_EntryRules;
/*
de: Prüfen ob das GUI-Element ungültig ist um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Detail-Variable, die als Parameter für die private Methode notwendig sind, extrahieren.
*
en:
Extract the detail-variables that are requiered as parameters by the private
method. */
locstructJSBS_UniversalParameters
=
parmfrmCC.
structJSBS_UniversalParameters
;
locstructJSBS_EntryRules
= parmfrmCC.
structJSBS_EntryRules
;
/*
de: private Methode die Arbeit machen lassen.
*
en:
Let the private method do the work. */
return
getBigDecimal(parmJTextField,
locstructJSBS_UniversalParameters,
locstructJSBS_EntryRules);
}
/
*
* de: METHODE mit einem Task-Frame als Parameter.
*
en:
METHOD with a Task-Frame as parameter. */
public
static
BigDecimal getBigDecimal(JTextField parmJTextField, JSBS_TaskFrame parmJSBS_TaskFrame)
{
/*
de:
*
Die notwendigen Daten-Structuren extrahieren und dann die Methode, die 'die wirkliche Arbeit'
*
macht, aufrufen.
*
en:
*
Extracted data-structures needed when calling the 'method doing the real
work'. */
JSBS_UniversalParameters
locstructJSBS_UniversalParameters;
JSBS_EntryRules
locstructJSBS_EntryRules;
/*
de: Prüfen ob das GUI-Element ungültig ist um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Detail-Variable, die als Parameter für die private Methode notwendig sind, extrahieren.
*
en:
Extract the detail-variables that are requiered as parameters by the private
method. */
locstructJSBS_UniversalParameters
=
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_UniversalParameters
;
locstructJSBS_EntryRules
=
parmJSBS_TaskFrame
.
structJSBS_EntryRules
;
/*
de: private Methode die Arbeit machen lassen und Ergebnis für weitere Verarbeitung aufheben.
*
en:
Let the private method do the work and keep the result for further processing. */
BigDecimal bdIntermediateResult = getBigDecimal(parmJTextField,
locstructJSBS_UniversalParameters,
locstructJSBS_EntryRules);
/*
*
de:
*
Wenn die Methode 'null' zurückliefert dann wurde die Eingabe-Regel nicht
*
erfüllt
.
*
en:
*
If the method return 'null' then the EntryRule was not fulfilled. */
if
(
bdIntermediateResult
!=
null
)
{
/*
*
de:
*
Eingabe-Regel
erfüllt
; Eingabe-Hinweis anzeigen weil in 'lbl_InfoMessage'
*
eventuell durch
einen vorigen Fehler eine Fehler-Hinweis enthält.
*
en:
*
Entry-Rule fulfilled; show the Info-Message for the entry because an
*
Error-Message might be displayed in
'lbl_InfoMessage' due to a previous
*
error.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
parmJSBS_TaskFrame.
frmCC
.
structJSBS_XML_DisplayStrings
.getInfoMessage(
parmJTextField, parmJSBS_TaskFrame.getClass().getName())
)
;
/*
de: Eingegebenen Wert für das BigDecimal zurückliefern
.
*
en: Return entered value for the BigDecimal
.
*/
return
bdIntermediateResult;
}
else
{
/*
*
de:
*
Eingabe-Regel nicht
erfüllt
; mit dem folgenden Code feststellen ob der Wert
* zu klein, zu groß oder mit zu vielen Nachkommastellen ist und dann den entsprechenden
*
Eingabe-Hinweis in
'lbl_InfoMessage' anzeigen
.
*
en:
*
Entry-Rule not fulfilled; verify with the following code if the value ist too small,
* too big or contains to many decimal digits and then display the fitting Info in 'lbl_InfoMessage'
.
*/
/*
*
de: Lokale Hilfs-Variablen.
*
en: Local auxilliary variables
. */
String locstrInfoMessageText =
""
;
BigDecimal locbdEntryRuleValue =
new
BigDecimal(0);
/*
*
de: Eingegebenen Wert ohne Prüfung aus dem GUI-Element extrahieren.
*
en: Extract the entered value out of the GUI-Element
. */
bdIntermediateResult = getBigDecimal(parmJTextField,
locstructJSBS_UniversalParameters,
null
);
/*
*
de:
*
Zuerst Prüfen ob der eingegebene Wert überhaupt numerisch und innerhalb des Bereichs
*
für die Java-Klasse ist
.
*
en:
*
Verify first if the entered value is numeric and within the range of the Java-class
. */
if
(
bdIntermediateResult ==
null
)
{
/*
*
de:
Eingegebene Wert nicht gültig für die Java-Klasse; weiter unterscheiden
.
*
en: Entered value not valid for the Java-class; make a further decision
. */
if
(
parmJTextField.getText().trim().length() == 0
)
{
/*
*
de: Eingabefelde leer; prüfen ob das Feld 'mandatory' ist
.
*
en: Entry field empty; check if the field is 'mandatory'
. */
if
(
parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMandatory(
parmJTextField.getName())
)
{
/*
*
de: Eingabefelde leer aber als 'mandatory' definiert; Fehler-Hinweis anzeigen
.
*
en: Entry field empty but defined as 'mandatory'
; show error-message. */
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueMandatory"
);
}
else
{
/*
*
de:
*
Eingabe-Feld leer aber nicht 'mandatory' ist kein Fehler
; Eingabe-Hinweis anzeigen weil
*
in 'lbl_InfoMessage'
eventuell durch
einen vorigen Fehler ein Fehler-Hinweis enthalten ist.
*
en:
*
Entry-field empty but not 'mandatory' ist not an error; show the Info-Message for the entry
*
because an
Error-Message might be displayed in
'lbl_InfoMessage' due to a previous
error.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
parmJSBS_TaskFrame.
frmCC
.
structJSBS_XML_DisplayStrings
.getInfoMessage(
parmJTextField, parmJSBS_TaskFrame.getClass().getName())
)
;
/*
de: Eingegebenen Wert für das Short zurückliefern
.
*
en: Return entered value for the Short
.
*/
return
bdIntermediateResult;
}
}
else
{
/*
*
de:
*
Eingabe Fehlerhaft aber nicht durch leeres Feld und 'mandatory'
.
*
Grund kann eine nicht numerische Eingabe oder ein Wert ausserhalb des Wertebereichs
*
für die Java-Klasse sein.
*
en:
*
Entry in error but not due to an empty field and 'mandatory'.
*
Reason is either a non-numeric entry or a value out of the value-range of the java-class
. */
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueNotNumeric"
);
}
}
else
{
/*
*
de:
*
Eingegebener Wert is numerisch und innerhalb des Wertebereich der Java-Klasse
.
*
Detaillierten Fehler ermitteln
*
en:
*
Entered value is numeric and within the value-range of the Java-class.
* Find out the detailed error-reason. */
/*
*
de:
*
Aus den Prüfregeln die maximal erlaubte Anzahl der Dezimalstellen auslesen.
*
Dieser Wert wird benötigt um die Fehlerhinweise an den Anwender zu formatieren.
*
en:
*
Extract the entered value out of the GUI-Element.
*
This value is needed to format the error messages for the user. */
int
intNumberOfDecimals
=
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getNumberOfDecimals(
parmJTextField.getName());
/*
*
de:
Prüfen ob die Anzahl der Dezimalstellen innerhalb des Limits ist
.
*
en: Verify if the number of decimals is within the limit
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkNumberOfDecimals(
parmJTextField.getName(), bdIntermediateResult)
)
{
/*
de:
*
Sprachabhängigen Fehler-Text für die Info-Message ermitteln und die erlaubte Anzahl
*
der Dezimalstellen 'anhängen'
.
*
en:
*
Get the language-dependant error-text for the info-message
and 'concate' the
*
allowed number of decimal digits
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_NumberOfDecimalsTooLarge"
);
locstrInfoMessageText +=
" "
+
JSBS_Formatter.toFormattedString(intNumberOfDecimals)
;
}
/*
*
de:
Prüfen ob der eingegebene Wert zu klein ist
.
*
en: Verify if the entered value is too small
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMinimumValue(
parmJTextField.getName(), bdIntermediateResult)
)
{
/*
de:
*
Eingegebener Wert zu klein
.
*
Aus den Prüf-Regeln den notwendigen Minimalwert auslesen.
*
en:
*
Entered value too small.
*
Get the requiered minimum value out of the Entry-Rules.
*/
locbdEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMinimumValue(
parmJTextField.getName());
/*
de:
*
Sprachabhängigen Fehler-Text für die Info-Message ermitteln und den
* Minimal-Wert 'anhängen'
.
*
en:
*
Get the language-dependant error-text for the info-message
and 'concate' the
*
minimum-value
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueTooSmall"
);
locstrInfoMessageText +=
" "
+
setBigDecimalToString(locbdEntryRuleValue,
locstructJSBS_UniversalParameters.
strLanguageDependantDecimalPoint
,
intNumberOfDecimals
)
;
}
/*
*
de:
Prüfen ob der eingegebene Wert zu gross ist
.
*
en: Verify if the entered value is too large
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMaximumValue(
parmJTextField.getName(), bdIntermediateResult)
)
{
/*
de:
*
Eingegebener Wert zu gross
.
*
Aus den Prüf-Regeln den notwendigen Maximalwert auslesen.
*
en:
*
Entered value too large.
*
Get the requiered maximum value out of the Entry-Rules.
*/
locbdEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMaximumValue(
parmJTextField.getName());
/*
de:
*
Sprachabhängigen Fehler-Text für die Info-Message ermitteln und den
* Maximal-Wert 'anhängen'
.
*
en:
*
Get the language-dependant error-text for the info-message
and 'concate' the
* maximum-value
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_ValueTooBig"
);
locstrInfoMessageText +=
" "
+
setBigDecimalToString(locbdEntryRuleValue,
locstructJSBS_UniversalParameters.
strLanguageDependantDecimalPoint
,
intNumberOfDecimals
)
;
}
}
/*
de:
Fehler-Text im GUI-Element 'lbl_InfoMessage' anzeigen
.
*
en: Display the error-message in the GUI-Element 'lbl_InfoMessage'
.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
locstrInfoMessageText
);
/*
de:
*
Aufrufender Methode durch 'null' signalisieren, daß der eingegebene
Wert
*
die Eingabe-Regel nicht erfüllt.
*
en:
*
Signal to the calling method by 'null' that the entered value has not passed
*
the Entry-Rules
.
*/
return null
;
}
}
/
*
* de:
* Private METHODE die den BigDecimal-Wert extrahiert, prüft ob er innerhalb der Grenzen
* der der Prüfregeln liegt und den Feld-Hintergrund einfärbt - abhängig davon ob
* der Wert die Prüfregeln erfüllt oder nicht.
* en:
* Private METHOD that extracts the BigDecimal value,
checks against the limit
* and colors the
field-background depending if an error was detected or not.
*/
private
static
BigDecimal getBigDecimal(JTextField parmJTextField,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
JSBS_EntryRules
parmJSBS_EntryRules) {
/*
de: Prüfen ob das GUI-Element ungültig ist um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Eine Variable für den Wert, den die Methode zurück gibt, definieren.
*
en:
Define the variable holding the value to be returned.
*/
BigDecimal
locbdReturnValue
;
/*
de: Eine Variable für den Text aus dem Feld definieren und den Text aus dem Feld holen.
*
en:
Define the variable for the text entered within the field and get the
text. */
String
strEnteredText = getTextFromJTextField(parmJTextField).trim();
/*
de: auf eine 'leere' Variable prüfen um einen Dump zu vermeiden.
*
en: Check for empty variable to avoid a dump. */
if
(strEnteredText ==
null
)
return
null
;
/*
* de:
* Ein '+' Zeichen an führenden oder nachfolgender Position oder
* ein '-' Zeichen an nachfolgender Position
* führen zu einem Fehler wenn versucht wird, den 'Text' in den Typ Integer zu konvertieren.
* Deswegen muss ein '+' entfernt werden und das '-' an die führende Position gesetzt werden.
* en:
* A
'+' sign on the leading or trailing position or
* a '-'
sign on the trailing position
* causes an error when
the 'text' is tried to be converted to the Integer.
* Therefore
'+' has to be removed and '-' has to be set to the leading position.
*/
int
intSignPosition
= strEnteredText.indexOf(
'+'
);
/*
de:
*
Beginnen mit der Prüfung ob ein '+' an führender Position ist.
* In diesem Fall das '+'-Zeichen entfernen.
* en:
*
Start with the check for '+' at the leading position.
* In that case remove the '+'-character
. */
if
(intSignPosition
== 0) {
strEnteredText
= strEnteredText.substring(1);
strEnteredText
= strEnteredText.trim();
}
/*
de:
* Prüfen ob ein '+' an nachfolgender Position ist.
* In diesem Fall das '+'-Zeichen entfernen.
* en:
*
Check for '+' at the trailing position
.
* In that case remove the '+'-character
.
*/
if
( (intSignPosition
> 0)
&& (intSignPosition
== (strEnteredText.length() - 1))) {
strEnteredText
= strEnteredText.substring(0,
intSignPosition);
strEnteredText
= strEnteredText.trim();
}
/*
de:
* Prüfen ob ein '-' an nachfolgender Position ist.
* In diesem Fall das '-'-Zeichen vor die Zahl setzen.
* en:
*
Check for '-' at the trailing position
.
* In that case set the '+'-character in front of the number
.
*/
intSignPosition
= strEnteredText.indexOf(
'-'
);
if
( (intSignPosition
> 0)
&& (intSignPosition
== (strEnteredText.length() - 1))) {
strEnteredText
= strEnteredText.substring(0,
intSignPosition);
strEnteredText
= strEnteredText.trim();
/*
de: Das '-' Zeichen an den Beginn des Textes bringen damit der Text konvertiert werden kann.
* en:
Bring the '-' sign to the begin of the text-string so that the text
can be converted. */
strEnteredText
=
"-"
+ strEnteredText;
}
/*
* de:
*
Sprach-spezifisches Dezimal-Trennzeichen durch System-spezifisches Zeichen ('.')
* ersetzen
.
* en:
*
Replace language-specific decimal-separator by system-specific one ('.'). */
strEnteredText =
strEnteredText.replace(
parmJSBS_UniversalParameters.
strLanguageDependantDecimalPoint
,
"."
)
;
/*
* de: Die 'BigDecimal' Klasse die Umwandlung von der Zeichenkette in BigDecimal ausführen lassen.
* en: Let the 'BigDecimal' class do the conversion from
String to BigDecimal. */
try
{
locbdReturnValue
=
new
BigDecimal(strEnteredText.trim());
}
catch
(Exception Exc) {
/*
* de:
*
Boolsche Variable zum Entscheiden, ob eine verpflichtende Eingabe für das Feld festgelegt
* ist.
Ob die Eingabe verpflichtend ist, ist in der Struktur JSBS_EntryRules (als Parameter übergeben)
*
definiert. Nachdem der Parameter auch 'null' sein kann, kann die if-Abfrage nicht direkt auf die
* Struktur JSBS_EntryRules erfolgen.
* en:
*
Boolean variable to decide if a mandatory entry is definied for the field. A mandatory entry for the field
* is specified within the structure JSBS_EntryRules (passed as parameter). As this parameter can be 'null',
* the if-decision can not directly use the JSBS_EntraRules structure
. */
boolean
bolMandatory =
false
;
/*
* de: Wenn ein Wert für JSBS_EntryRules in den Parametern übergeben wurde dann auf 'mandatory' prüfen.
* en: If a value was passed for JSBS_EntryRules in the parameters then check for 'mandatory'. */
if
(parmJSBS_EntryRules !=
null
)
bolMandatory = parmJSBS_EntryRules.checkMandatory(parmJTextField.getName())
;
/* de:
* 'Fehler'-Hintergrund wird nur gesetzt wenn ein nicht numerischer Wert eingegeben
* wurde oder das Feld als 'mandatory' festgelegt ist.
* en:
*
'Error'-background
is only set if there was a non-numeric value entered
* or
the field is defined as 'mandatory'.
*/
if
((strEnteredText.trim().length()
>
0) || bolMandatory)
{
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
}
else
{
/* de:
* Wenn kein Text eingegeben wurde und das Feld nicht als 'mandatory' definiert ist
* wird der normale Hintergrund gesetzt.
* en:
*
If
no text was entered and the field is not defined mandatory,
* then
the normal background is set.
*/
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
}
/* de: Ein 'BigDecimal'-Wert konnte nicht 'herausgeholt' werden: 'null' wird zurück geliefert.
* en:
As
a BigDecimal-value could not be derived: 'null' is returned.
*/
return
null
;
}
/* de:
* Der eingegebene 'Text' konnte auf einen BigDecimal-Wert umgewandelt werden;
* zuerst prüfen ob in den Parametern auch eine Struktur mit den Prüfregeln übergeben wurde.
* en:
*
Entered
'text' could be converted to an BigDecimal value;
* check first if a structure with validation rules was passed in the parameters.
*/
if
(parmJSBS_EntryRules ==
null
)
return
locbdReturnValue;
/* de:
* Prüfregeln wurden als Parameter übergeben.
* Prüfen ob der Wert innerhalb der 'Minimum' und 'Maximum' Werte ist
(soferne diese
*
festgelegt sind)
* en:
*
Validation rules were passed as parameter.
* check
the value against 'Minimum' and 'Maximum' values (if defined).
*/
if
(parmJSBS_EntryRules.checkValueRange(parmJTextField.getName(),
locbdReturnValue)) {
/* de: Eingegebener Wert ist innerhalb des Bereichs; Hintergrund setzen und Wert zurückliefern.
* en:
Entered
value is within the range; set background and return the value.
*/
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
return
locbdReturnValue;
}
else
{
/* de: Eingegebener Wert ist ein gültiger BigDecimal-Wert aber ausserhalb des festgelegten Bereichs.
* en:
Entered
value is a valid BigDecimal-value but without the defined range.
*/
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
return
null
;
}
}
/*
* --------------------
*
de:
*
METHODE um einen Wert der Klasse BigDecimal in eine Zeichenkette (String) umzuwandeln.
* In den Methode wird der sprach-spezifische Dezimalstellen-Trenner eingefügt und
* festgelegt, wie viele Nachkommastellen angezeigt werden
.
*
en:
*
METHOD to convert a value of class BigDecimal into a string.
* Within the method the language-dependant decimal-separator is inserted and the
*
length of the fractional part is decided
. */
public
static
String setBigDecimalToString(BigDecimal parmBigDecimal,
String
parmDecimalSeparator,
int
parmDecimalFraction
) {
/*
de: Prüfen ob der übergebene Parameter mit der Zahl leer ist um einen Dump zu vermeiden.
*
en:
Check for an empty Parameter with the number to avoid a dump. */
if
(parmBigDecimal
==
null
)
return
null
;
/*
de: Zeichenkette, die das Ergebnis enthalten wird definieren.
*
en:
Define a String which will contain the result. */
String returnString;
/*
de: BigDecimal für die interne Bearbeitung definieren.
*
en: Define BigDecimal for the internal processing
. */
BigDecimal locbd =
new
BigDecimal(0);
locbd
= locbd.add(parmBigDecimal)
;
/*
de: Dezimalstellen festlegen und kaufmännisch runden.
*
en: Define the fractional part and round
. */
locbd
= locbd.setScale(parmDecimalFraction, BigDecimal.
ROUND_HALF_UP
)
;
/*
*
de:
*
BigDecimal in eine Zeichenkette umwandeln und sprachspezifisches Dezimaltrennzeichen
*
statt dem '.' einfügen
.
*
en:
*
Convert the BigDecimal into a String and insert the decimal-separator instead of
*
the '.'
. */
returnString
= locbd.toString(
)
;
returnString
= returnString.replace(
"."
, parmDecimalSeparator
)
;
/*
de: Zeichenkette zurückliefern.
*
en: Return the String
. */
return
returnString
;
}
/*
* --------------------
*
de:
*
METHODE um einen Wert der Klasse BigDecimal in eine Zeichenkette (String).
* Vereinfachung der obigen Methode mit fixen Dezimaltrenner und 2 Dezimalstellen
.
*
en:
*
METHOD to convert a value of class BigDecimal into a String.
* Simplified version of the above method with fixed decimal-separator and length 2 for the
* decimal-fraction
. */
public
static
String setBigDecimalToString(BigDecimal parmBigDecimal
) {
/*
de: Methode mit der Grundfunktionalität die Arbeit machen lassen.
*
en:
Let the method with the basic functionality do the work. */
return
setBigDecimalToString(parmBigDecimal,
"."
,
2);
}
/*
* --------------------
*
de:
*
METHODE um einen Wert der Klasse BigDecimal in eine Zeichenkette (String) umzuwandeln.
* Dezimaltrenner und Anzahl der Dezimalstellen wird aus den Konfigurationswerten
* ausgelesen
.
*
en:
*
METHOD to convert a value of class BigDecimal into a String.
* Decimal-separator and length of the decimal-fraction is derived from the
* configuration-values
. */
public
static
String setBigDecimalToString(BigDecimal parmBigDecimal,
JSBS_TaskFrame parmTaskFrame,
String parmGUIElementName
) {
/*
de: Prüfen ob die übergebenen Parameter leer sind um einen Dump zu vermeiden.
*
en:
Check for empty parameters to avoid a dump. */
if
(parmTaskFrame
==
null
)
return
null
;
if
(parmGUIElementName
==
null
)
return
null
;
/*
de: Name der Klasse für das übergebene Task-Frame ermitteln.
*
en:
Derive the name of the class for the Task-Frame. */
String strTaskFrameName = parmTaskFrame.getClass().getName();
/*
de:
*
Objekt für das Start-Frame lokal in dieser Methode halten.
*
In diesem Objekt sind die Konfigurationsdaten enthalten.
*
en:
*
Keep the object for the Start-Frame locally within this methode.
*
This object contains the configuration-data.
*/
JSBS_StartFrame frmCC = parmTaskFrame.
frmCC
;
/*
de:
*
Das Dezimaltrennzeichen ist als Variable in einer Struktur des Start-Frames
*
enthalten. Lokale Kopie anlegen damit der Variablenname kürzer wird.
*
en:
* The decimal-separator is within a variable of the structure of the Start-Frame
.
* Make a local copy to make the variable-name shorter.
*/
String strDecimalSeparator =
frmCC.
structJSBS_UniversalParameters
.
strLanguageDependantDecimalPoint
;
/*
de:
* Anzahl der Nachkommastellen für das entsprechende Feld aus der XML-Struktur auslesen
.
*
en:
* Read the length of the fractional part out of the XML-structure
.
*/
Integer IntDecimalFraction =
frmCC.
structJSBS_XML_DisplayStrings
.getProperty_NumberOfDecimals(
strTaskFrameName, parmGUIElementName);
/*
de:
* Umwandeln von Klasse Integer auf Basistyp int; als Default 2 Nachkommastellen vorsehen
.
*
en:
* Convert from class Integer into base-type int;
*
define 2 as length of fractio
nal-part as default.
*/
int
intDecimalFraction = 2;
if
(IntDecimalFraction !=
null
)
intDecimalFraction =
IntDecimalFraction.intValue()
;
/*
de: Methode mit der Grundfunktionalität die Arbeit machen lassen.
*
en:
Let the method with the basic functionality do the work. */
return
setBigDecimalToString(parmBigDecimal,
strDecimalSeparator
,
intDecimalFraction);
}
/*
* --------------------
*
de:
*
METHODE um einen Wert der Klasse BigDecimal als Text in einem JTextField anzuzeigen.
* Dezimaltrenner und Anzahl der Dezimalstellen wird aus den Konfigurationswerten
* ausgelesen
.
*
en:
*
METHOD to display a value of class BigDecimal within a
JTextField.
* Decimal-separator and length of the decimal-fraction is derived from the
* configuration-values
. */
public
static void
setBigDecimalToJTextField(JTextField parmJTextField,
BigDecimal parmBigDecimal,
JSBS_TaskFrame parmTaskFrame
) {
/*
de: Prüfen ob die übergebenen Parameter leer sind um einen Dump zu vermeiden.
*
en:
Check for empty parameters to avoid a dump. */
if
(parmJTextField
==
null
)
return
;
if
(parmBigDecimal
==
null
)
return
;
if
(parmTaskFrame
==
null
)
return
;
/*
de: Zugewiesenen Namen für das JTextField ermitteln.
*
en:
Derive the assigned name of the JTextField. */
String strGUIElementName = parmJTextField.getName();
/*
de:
*
BigDecimal in eine Zeichenkette umwandeln; dabei die
Methode mit der
*
Grundfunktionalität
die Arbeit machen lassen.
*
en:
*
Convert the BigDecimal into a String; let the method with the basic
*
functionality do the work. */
String locText =
setBigDecimalToString(parmBigDecimal,
parmTaskFrame
,
strGUIElementName);
/*
de:
*
Prüfen ob die Umwandlung fehlerfrei erfolgte; in diesem Fall die Zeichenkette.
*
im JTextField anzeigen.
*
en:
* Verify if the conversion ended with an error; in that case display the String
* in the JTextField.
*/
if
(locText !=
null
)
parmJTextField.setText
(locText)
;
}
/*
* --------------------
*
de:
* Methode, um den von einem Benutzer in einem GUI-Element der Klasse JTextField
*
eingegebenen Text extrahieren zu können.
*
In dieser Methode gibt es keine weiteren Prüfungen und keine weitere Verarbeitung.
*
en:
*
Method to get the text entered by a user out of a GUI-Element of
class JTextField.
*
There are no further checks and not additional processing within this method.
*/
public
static
String
getTextFromJTextField(JTextField parmJTextField) {
/*
de: Prüfen auf 'leeres' GUI-Element um einen Programmabsturz zu vermeiden.
*
en: Check for empty GUI-element to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
/*
de: Text extrahieren und an die aufrufende Methode zurückliefern.
*
en: Extract the text and return it to the calling method. */
return
parmJTextField.getText().trim();
}
/*
* --------------------
*
de:
* Methode, um den von einem Benutzer in einem GUI-Element der Klasse JTextField
*
im CommandCenter (Task-Frame) eingegebenen Text zu Prüfen und, wenn die Eingabe-Regeln
*
erfüllt sind, zu
Extrahieren.
* Abhängig davon, ob die Eingabe den Regeln entspricht oder nicht, wird der
* Hintergrund des Feldes verschieden eingefärbt und ein Hinweis im GUI-Element
* 'lbl_InfoMessage' (definiert in der Basisklasse JSBS_StartFrame) angezeigt.
*
en:
*
Method to check the text entered by a user out of a GUI-Element of
class JTextField
* within the CommandCenter (Start-Frame) and extract it if the Entry-Rules are fulfilled.
* Depending, if the Entry-Rules are fulfilled or not, the background of the field
* ist colored with different colors and a message is displayed in the GUI-Element
* 'lbl_InfoMessage' (defined in the base-class JSBS_StartFrame)
.
*/
public
static
String
getTextFromJTextField(JTextField parmJTextField,
JSBS_StartFrame parmJSBS_StartFrame) {
/*
*
de: Prüfen auf 'leeres' Start-Frame um einen Programmabsturz zu vermeiden.
*
en: Check for 'empty' Start-Frame to avoid a dump. */
if
(parmJSBS_StartFrame
==
null
)
return
null
;
/*
*
de:
*
Aufrufen der privaten Methode die extrahiert, prüft und den Hintergrund
*
einfärbt.
*
en:
*
Call the private method which extracts, checks and colors the background. */
String strIntermediateResult =
getTextFromJTextField(parmJTextField,
parmJSBS_StartFrame
.
structJSBS_UniversalParameters
,
parmJSBS_StartFrame
.
structJSBS_EntryRules
);
/*
*
de:
*
Wenn die Methode 'null' zurückliefert dann wurde die Eingabe-Regel nicht
*
erfüllt
.
*
en:
*
If the method returns 'null' then the EntryRule was not fulfilled. */
if
(
strIntermediateResult
!=
null
)
{
/*
*
de:
*
Eingabe-Regel
erfüllt
; Eingabe-Hinweis anzeigen weil in 'lbl_InfoMessage'
*
eventuell durch
einen vorigen Fehler eine Fehler-Hinweis enthält.
*
en:
*
Entry-Rule fulfilled; show the Info-Message for the entry because an
*
Error-Message might be displayed in
'lbl_InfoMessage' due to a previous
*
error.
*/
parmJSBS_StartFrame.get_lbl_InfoMessage().setText(
parmJSBS_StartFrame
.
structJSBS_XML_DisplayStrings
.
getInfoMessage(
parmJTextField,
parmJSBS_StartFrame
.getClass().getName())
)
;
/*
de: Eingegebenen Text aus dem JTextField zurückliefern
.
*
en: Return entered text from JTextField
.
*/
return
strIntermediateResult;
}
else
{
/*
*
de:
*
Eingabe-Regel nicht
erfüllt
; zuerst feststellen ob die Eingabe zu kurz
*
oder zu lang ist und dann den entsprechenden
Eingabe-Hinweis in
*
'lbl_InfoMessage' anzeigen
.
*
en:
*
Entry-Rule not fulfilled; first find out if the entered text is too short
*
or too long and then display the fitting Info in 'lbl_InfoMessage'
.
*/
/*
*
de: Lokale Hilfs-Variablen.
*
en: Local auxilliary variables
. */
String locstrInfoMessageText =
""
;
Integer locintEntryRuleValue =
new
Integer(0);
/*
*
de: Eingegebenen Text ohne Prüfung aus dem GUI-Element extrahieren.
*
en: Extract the entered text out of the GUI-Element
. */
strIntermediateResult = getTextFromJTextField(parmJTextField);
/*
*
de:
Prüfen ob der eingegebene Text zu kurz ist
.
*
en: Verify if the entered text is too short
. */
if
(
! parmJSBS_StartFrame.
structJSBS_EntryRules
.checkMinimumLength(
parmJTextField.getName(), strIntermediateResult.trim().length())
)
{
/*
de:
*
Eingegebene Zeichenkette zu kurz
.
*
Aus den Prüf-Regeln die minimal notwendige Anzahl der Zeichen auslesen.
*
en:
*
Entered text-string too short.
*
Get the requiered minimum number of charactes out of the Entry-Rules.
*/
locintEntryRuleValue =
parmJSBS_StartFrame
.
structJSBS_EntryRules
.getMinimumLength(
parmJTextField.getName());
/*
de: Sprachabhängigen Fehler-Text für die Info-Message ermitteln.
*
en: Get the language-dependant error-text for the info-message
.
*/
locstrInfoMessageText =
parmJSBS_StartFrame
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_StringTooShort"
);
}
/*
*
de:
Prüfen ob der eingegebene Text zu lang ist
.
*
en: Verify if the entered text is too long
. */
if
(
!
parmJSBS_StartFrame
.
structJSBS_EntryRules
.checkMaximumLength(
parmJTextField.getName(), strIntermediateResult.trim().length())
)
{
/*
de:
*
Eingegebene Zeichenkette zu lang
.
*
Aus den Prüf-Regeln die maximal erlaubte Anzahl der Zeichen auslesen.
*
en:
*
Entered text-string too long.
*
Get the requiered maximum number of charactes out of the Entry-Rules.
*/
locintEntryRuleValue =
parmJSBS_StartFrame
.
structJSBS_EntryRules
.getMaximumLength(
parmJTextField.getName());
/*
de: Sprachabhängigen Fehler-Text für die Info-Message ermitteln.
*
en: Get the language-dependant error-text for the info-message
.
*/
locstrInfoMessageText =
parmJSBS_StartFrame
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_StringTooLong"
);
}
/*
de:
Fehler-Text im GUI-Element 'lbl_InfoMessage' anzeigen
.
*
en: Display the error-message in the GUI-Element #lbl_InfoMessage'
.
*/
parmJSBS_StartFrame
.get_lbl_InfoMessage().setText(
locstrInfoMessageText +
" "
+
JSBS_Formatter.toFormattedString(
locintEntryRuleValue
));
/*
de:
*
Aufrufender Methode durch 'null' signalisieren, daß der eingegebene
Wert
*
die Eingabe-Regel nicht erfüllt.
*
en:
*
Signal to the calling method by 'null' that the entered value has not passed
*
the Entry-Rules
.
*/
return null
;
}
}
/*
* --------------------
*
de:
* Methode, um den von einem Benutzer in einem GUI-Element der Klasse JTextField
*
(auf einenm Task-Frame) eingegebenen Text zu Prüfen und, wenn die Eingabe-Regeln
*
erfüllt sind, zu
Extrahieren.
* Abhängig davon, ob die Eingabe den Regeln entspricht oder nicht, wird der
* Hintergrund des Feldes verschieden eingefärbt und ein Hinweis im GUI-Element
* 'lbl_InfoMessage' (definiert in der Basisklasse JSBS_TaskFrame) angezeigt.
*
en:
*
Method to check the text entered by a user out of a GUI-Element of
class JTextField
* (on a Task-Frame) and extract it if the Entry-Rules are fulfilled.
* Depending, if the Entry-Rules are fulfilled or not, the background of the field
* ist colored with different colors and a message is displayed in the GUI-Element
* 'lbl_InfoMessage' (defined in the base-class JSBS_TaskFrame)
.
*/
public
static
String
getTextFromJTextField(JTextField parmJTextField,
JSBS_TaskFrame parmJSBS_TaskFrame) {
/*
*
de: Prüfen auf 'leeres' Task-Frame um einen Programmabsturz zu vermeiden.
*
en: Check for 'empty' Task-Frame to avoid a dump. */
if
(parmJSBS_TaskFrame
==
null
)
return
null
;
/*
*
de:
*
Aufrufen der privaten Methode die extrahiert, prüft und den Hintergrund
*
einfärbt.
*
en:
*
Call the private method which extracts, checks and colors the background. */
String strIntermediateResult =
getTextFromJTextField(parmJTextField,
parmJSBS_TaskFrame.
frmCC
.
structJSBS_UniversalParameters
,
parmJSBS_TaskFrame.
structJSBS_EntryRules
);
/*
*
de:
*
Wenn die Methode 'null' zurückliefert dann wurde die Eingabe-Regel nicht
*
erfüllt
.
*
en:
*
If the method return 'null' then the EntryRule was not fulfilled. */
if
(
strIntermediateResult
!=
null
)
{
/*
*
de:
*
Eingabe-Regel
erfüllt
; Eingabe-Hinweis anzeigen weil in 'lbl_InfoMessage'
*
eventuell durch
einen vorigen Fehler eine Fehler-Hinweis enthält.
*
en:
*
Entry-Rule fulfilled; show the Info-Message for the entry because an
*
Error-Message might be displayed in
'lbl_InfoMessage' due to a previous
*
error.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
parmJSBS_TaskFrame.
frmCC
.
structJSBS_XML_DisplayStrings
.getInfoMessage(
parmJTextField, parmJSBS_TaskFrame.getClass().getName())
)
;
/*
de: Eingegebenen Text aus dem JTextField zurückliefern
.
*
en: Return entered text from JTextField
.
*/
return
strIntermediateResult;
}
else
{
/*
*
de:
*
Eingabe-Regel nicht
erfüllt
; zuerst feststellen ob die Eingabe zu kurz
*
oder zu lang ist und dann den entsprechenden
Eingabe-Hinweis in
*
'lbl_InfoMessage' anzeigen
.
*
en:
*
Entry-Rule not fulfilled; first find out if the entered text is too short
*
or too long and then display the fitting Info in 'lbl_InfoMessage'
.
*/
/*
*
de: Lokale Hilfs-Variablen.
*
en: Local auxilliary variables
. */
String locstrInfoMessageText =
""
;
Integer locintEntryRuleValue =
new
Integer(0);
/*
*
de: Eingegebenen Text ohne Prüfung aus dem GUI-Element extrahieren.
*
en: Extract the entered text out of the GUI-Element
. */
strIntermediateResult = getTextFromJTextField(parmJTextField);
/*
*
de:
Prüfen ob der eingegebene Text zu kurz ist
.
*
en: Verify if the entered text is too short
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMinimumLength(
parmJTextField.getName(), strIntermediateResult.trim().length())
)
{
/*
de:
*
Eingegebene Zeichenkette zu kurz
.
*
Aus den Prüf-Regeln die minimal notwendige Anzahl der Zeichen auslesen.
*
en:
*
Entered text-string too short.
*
Get the requiered minimum number of charactes out of the Entry-Rules.
*/
locintEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMinimumLength(
parmJTextField.getName());
/*
de: Sprachabhängigen Fehler-Text für die Info-Message ermitteln.
*
en: Get the language-dependant error-text for the info-message
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_StringTooShort"
);
}
/*
*
de:
Prüfen ob der eingegebene Text zu lang ist
.
*
en: Verify if the entered text is too long
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMaximumLength(
parmJTextField.getName(), strIntermediateResult.trim().length())
)
{
/*
de:
*
Eingegebene Zeichenkette zu lang
.
*
Aus den Prüf-Regeln die maximal erlaubte Anzahl der Zeichen auslesen.
*
en:
*
Entered text-string too long.
*
Get the requiered maximum number of charactes out of the Entry-Rules.
*/
locintEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMaximumLength(
parmJTextField.getName());
/*
de: Sprachabhängigen Fehler-Text für die Info-Message ermitteln.
*
en: Get the language-dependant error-text for the info-message
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_StringTooLong"
);
}
/*
de:
Fehler-Text im GUI-Element 'lbl_InfoMessage' anzeigen
.
*
en: Display the error-message in the GUI-Element #lbl_InfoMessage'
.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
locstrInfoMessageText +
" "
+
JSBS_Formatter.toFormattedString(
locintEntryRuleValue
));
/*
de:
*
Aufrufender Methode durch 'null' signalisieren, daß der eingegebene
Wert
*
die Eingabe-Regel nicht erfüllt.
*
en:
*
Signal to the calling method by 'null' that the entered value has not passed
*
the Entry-Rules
.
*/
return null
;
}
}
/*
* --------------------
*
de:
* Lokale Methode, um den von einem Benutzer in einem GUI-Element der Klasse
*
JTextField
eingegebenen Text zu Prüfen und, wenn die Eingabe-Regeln erfüllt
*
sind, zu
Extrahieren.
* Abhängig davon, ob die Eingabe den Regeln entspricht oder nicht, wird der
* Hintergrund des Feldes verschieden eingefärbt und ein Hinweis im GUI-Element
* 'lbl_InfoMessage' (definiert in der Basisklasse JSBS_TaskFrame) angezeigt.
*
en:
*
Local method to check the text entered by a user out of a GUI-Element of
*
class JTextField
and extract it if the Entry-Rules are fulfilled.
* Depending, if the Entry-Rules are fulfilled or not, the background of the field
* ist colored with different colors and a message is displayed in the GUI-Element
* 'lbl_InfoMessage' (defined in the base-class JSBS_TaskFrame)
.
*/
private
static
String
getTextFromJTextField(
JTextField parmJTextField,
JSBS_UniversalParameters
parmJSBS_UniversalParameters
,
JSBS_EntryRules parmJSBS_EntryRules
) {
/*
*
de: Prüfen auf 'leere' Parameter um einen Programmabsturz zu vermeiden.
*
en: Check for 'empty' parameters to avoid a dump. */
if
(parmJTextField
==
null
)
return
null
;
if
(parmJSBS_UniversalParameters
==
null
)
return
null
;
if
(parmJSBS_EntryRules
==
null
)
return
null
;
/*
*
de: Eingegebenen Text aus dem GUI-Element extrahieren.
*
en: Extract the entered text out of the GUI-Element. */
String locstrText
= getTextFromJTextField(parmJTextField
)
;
/*
*
de: Sicherheitshalber auf 'null' prüfen.
*
en: Check against 'null' to make sure not to dump. */
if
(locstrText
==
null
)
return
null
;
/*
*
de:
*
Algorithmus zum speziellen Prüfen eines GUI-Elements ohne Eingabe.
*
Wenn das Eingabefeld innerhalb der Application als 'Mandatory' definiert
* wurde, dann ist eine fehlende Eingabe auf jeden Fall ein Fehler.
*
Wenn ein Eingabe-Feld in der XML-Datei ('DisplayStrings.xml') nicht als
*
'Mandatory' (Eingabe erforderlich) definiert
ist und keine Eingabe erfolgt ist
*
(leere Zeichenkette) dann wird die
Prüfung auf korrekte Länge nicht ausgeführt.
*
en:
*
Algorithm for a special verification of a GUI-Elements with a blank entry.
* If the entry-field is defined as 'mandatory' within the application, then
* a blank entry is always an error.
* If an entry-field is defined as not 'mandatory' in the XML-file ('DisplayStrings.xml')
*
then a further check of the correct length is not performed
.
*/
int
locintTextLength = locstrText.trim().length()
;
if
(
locintTextLength == 0
) {
if
(parmJSBS_EntryRules.checkApplicationMandatory(parmJTextField.getName()))
{
/*
*
de:
*
In der Application als 'Mandatory' definiert - Leere Eingabe ist ein Fehler.
*
Hintergrundfarbe (Fehler) des GUI-Elementes festlegen und Wert zurückliefern.
*
en:
*
Defined as 'mandatory' within the application - blank entry is an error.
*
Set the background-color (error) for the GUI-element and return the value. */
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
return null
;
}
if
(! parmJSBS_EntryRules.checkParameterizedMandatory(parmJTextField.getName()))
{
/*
*
de:
*
In der XML-Datei als 'Nicht Mandatory' definiert - Leere Eingabe ist kein Fehler.
*
Hintergrundfarbe (in Ordnung) des GUI-Elementes festlegen und Wert zurückliefern.
*
en:
*
Defined as 'not mandatory' in the XML-file - blank entry is not an error.
*
Set the background-color (o.k.) for the GUI-element and return the value. */
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
return
""
;
}
}
/*
*
de: Prüfen ob die eventuell definierte Eingabe-Regel erfüllt ist.
*
en: Check if a potential defined Entry-Rule is fulfilled. */
if
(parmJSBS_EntryRules.checkLengthRange(parmJTextField.getName(),
locintTextLength)) {
/*
*
de:
*
Eingabe-Regel erfüllt; passende Farbe für den Hintergrund setzen und
*
eingegebenen Wert an die aufrufende Methode zurückliefern
.
*
en:
*
Entry-Rule fulfilled; set fitting color for the background and
* return the entered value to the calling method
. */
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
return
locstrText;
}
else
{
/*
*
de:
*
Eingabe-Regel nicht erfüllt; passende Farbe für den Hintergrund setzen und
* 'null' an die aufrufende Methode zurückliefern
um eine fehlerhafte Eingabe
*
zu signalisieren.
*
en:
*
Entry-Rule not fulfilled; set fitting color for the background and
* return 'null' to the calling method to signal an incorrect entry
. */
parmJTextField.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
return null
;
}
}
/*
* --------------------
*
de:
*
METHODE um einen vom Anwender eingegebenen Text aus einem GUI-Element der Klasse JTextArea
*
auszulesen.
*
en:
*
METHOD to get the text entered by a user out of a GUI-Element of
class JTextArea. */
public
static
String
getTextFromJTextArea(JTextArea parmJTextArea) {
/*
*
de: Auf ein leeres GUI-Element prüfen um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump */
if
(parmJTextArea
==
null
)
return
null
;
String
locstrReturnValue = parmJTextArea.getText();
return
locstrReturnValue;
}
/*
* --------------------
*
de:
*
METHODE um einen vom Anwender eingegebenen Text aus einem GUI-Element der
*
Klasse JTextArea auszulesen wobei der String '\n' als Ersatz für eine neue
*
Zeile eingefügt wird.
*
Für Details zum Algorithmus sehen Sie bitte in der aufgerufenen Methode nach.
*
en:
*
METHOD to get the text entered by a user out of a GUI-Element of
class JTextArea
* with the String '\n' as substitute
for a New-Line-character within the String.
* For
Details please refer to the called method. */
public
static
String
getTextWithNewLineFromJTextArea(JTextArea parmJTextArea) {
/*
*
de: Prüfen auf leeres GUI-Element um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump, */
if
(parmJTextArea
==
null
)
return
null
;
String
locstrReturnValue = parmJTextArea.getText();
return
getTextWithNewLineFromJTextArea(parmJTextArea,
"\\n"
);
}
/*
* --------------------
*
de:
*
METHODE um einen vom Anwender eingegebenen Text aus einem GUI-Element der
*
Klasse JTextArea auszulesen.
*
Ein System-spezifischer Character (im Text) für eine neue Zeile wird durch
*
die im Parameter 'parmNewLineSubstitute' übergebene
Zeichenkette ersetzt.
*
Das Einfügen eines Ersatzes ist notwendig weil der System-spezifische Character
*
für eine neue Zeile möglicherweise verschwindet wenn die Zeichenkette in einer
*
Datenbank gespeichert und wieder ausgelesen wird.
*
en:
*
METHOD to get the text entered by a user out of a GUI-Element of
class JTextArea.
* A system-specific
'New-Line'-character is replaced by the parameter
'parmNewLineSubstitute'.
* The insertion of the
'substitute' is necessary as the system-provides 'New-Line'
* might
diasppear when the String is stored in the database and retrieved
again. */
public
static
String
getTextWithNewLineFromJTextArea(JTextArea
parmJTextArea,
String
parmNewLineSubstitute) {
/*
*
de:
*
Auf leeres GUI-Element und der Ersatz-Zeichenkette für neue Zeile prüfen
*
um einen Dump zu vermeiden.
*
en:
*
Check for empty GUI-element and Substitute-String to avoid a dump
*/
if
(parmJTextArea
==
null
)
return
null
;
if
(parmNewLineSubstitute
==
null
)
return
null
;
/*
*
de: Text aus dem GUI-Element auslesen.
*
en:
Get the text from the GUI-Element. */
String
strTextAreaContent = getTextFromJTextArea(parmJTextArea);
/*
*
de:
*
Eine Variable für eine neue Zeichenkette definieren und die Methode aufrufen, die
*
den System-spezifischen Character durch die als Parameter übergebene Zeichenkette
*
ersetzt.
* en:
*
Define a new String-variable and call the method to replace the
system-provided 'New-Line'
* by the New-Line-substitute
passed as parameter. */
String
locstrReturnValue =
JSBS_Formatter.replaceAllSubstrings(strTextAreaContent,
System.getProperty(
"line.separator"
),
parmNewLineSubstitute);
return
locstrReturnValue;
}
/*
* --------------------
*
de:
*
METHODE um eine Zeichenkette mit dem Standard-Ersatz für eine neue Zeile (\n)
*
in einer JTextArea anzuzeigen.
*
Diese Methode wird benötigt, weil das Speichern einer Zeichenkette mit dem
*
System-spezifischen Character für 'Neue Zeile' in einer Datei oder Datenbank
*
üblicherweise zu einem Verlust der Informationen für 'Neue Zeile' führt.
*
In dieser Methode wird die Methode, die eine beliebige Zeichenkette durch den
*
System-spezifischen Character für 'Neue Zeile' ersetzt aufgerufen und '\n'
*
als Parameter für die individuelle Zeichenkette für 'Neue Zeile' übergeben.
*
en:
* METHOD
to set a String containing substitutes (\n) for
NewLine-Characters
* to a JTextArea.
* This
method is needed as storing a String with
System-provided NewLine-characters
* in a file
or a database usually leads to a loss of the System-provided
New-Line.
* Within this method, the method that
replaces a 'substitute'-string by the
* System-provided
'New-Line' is called and "\n" is passed as parameter.
*/
public
static void
setStringWithNewLineToJTextArea(JTextArea parmJTextArea,
String
parmStringWithNewLine)
{
setStringWithNewLineToJTextArea(parmJTextArea,
parmStringWithNewLine,
"\\n"
);
}
/*
*
de:
*
Abwandlung der vorigen Methode mit einem Parameter für eine beliebige Zeichen
*
für 'Neue Zeile' innerhalb des Textes.
*
en:
*
Derivation
of the method with a parameter for a supplied substitute for NewLine.
*/
public
static void
setStringWithNewLineToJTextArea(JTextArea parmJTextArea,
String
parmStringWithNewLine,
String
parmNewLineSubstitute) {
/*
*
de: Prüfen auf leeres GUI-element oder Zeichenkette um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element or Strings to avoid a dump. */
if
(parmJTextArea
==
null
)
return
;
if
(parmStringWithNewLine
==
null
)
return
;
if
(parmNewLineSubstitute
==
null
)
return
;
/*
*
de:
*
Aufrufen der Methode die eine Zeichenkette durch eine andere ersetzt und zuweisen
*
des Resultats auf eine neue Variable.
*
en:
*
Call
the method to replace a string by another and put the result to a new
variable. */
String
locstrText =
JSBS_Formatter.replaceAllSubstrings(parmStringWithNewLine,
parmNewLineSubstitute,
System.getProperty(
"line.separator"
));
parmJTextArea.setText(locstrText);
}
/*
* --------------------
*
de:
*
METHODE zum Holen des Textes des ausgewählten Elementes oder des Textes der eingegeben wurde
*
aus einem GUI-Element der Klasse JComboBox
*
en:
*
METHOD to get the text of the selection or the text entered in a GUI-Element of class
JComboBox. */
public
static
String
getSelectedTextFromJComboBox(JComboBox parmJComboBox) {
/*
de: Prüfen ob als Parameter ein 'null'-Wert übergeben wurde um einen Dump zu vermeiden.
*
en:
Check if a 'null'-value was passed as parameter to avoid a dump. */
if
(parmJComboBox
==
null
)
return
null
;
/*
de:
* Prüfen ob in der JComboBox noch keine Elemente sind. Bei einer 'leeren' ComboBox erfolgt
*
ein Dump wenn versucht wird, das gewählte Item auszulesen.
*
Wenn die direkte Eingabe eines Textes erlaubt ist, dann darf die Auswahlliste leer sein.
*
en:
*
Check for no items within the box as a dump occurs when the number of
items is 0.
* JComboBox can be empty if entry of new values
is allowed. */
if
((parmJComboBox.getItemCount()
== 0) && (! parmJComboBox.isEditable()))
return
null
;
/*
de:
*
Vorbemerkung:
* Wenn direkt Text in die JComboBox eingegeben werden kann dann muss der eingegebene
oder
* ausgewählte Text auf andere Weise ermittelt werden als wenn der Text nur aus der Liste
* ausgewählt werden darf
.
*
en:
*
Preface:
* If it is allowed to enter text directly into the JComboBox, then the entered or selected
* text has to be derived with another method than if it is only allowed to select a text
* out of the list
.
*
*/
String
locstrReturnValue;
if
(parmJComboBox.isEditable()) {
/*
*
de:
* Eingegebener Text kann aus der JComboBox nicht direkt ausgelesen werden; deswegen muss zuvor die
* JTextComponent 'geholt' werden
.
*
en:
*
Entered Text can not be directly derived from the JComboBox; therefore the JTextComponent
* has to be derived first. */
JTextComponent tc = (JTextComponent)
parmJComboBox.getEditor().getEditorComponent();
/*
de:
* Holen des Textes (egal ob direkt eingegeben oder ausgewählt) aus der JTextComponent
.
*
en:
*
Deriving the text (no matter if directly entered or selected) from the JTextComponent. */
locstrReturnValue = tc.getText();
}
else
{
/*
de:
Ermitteln des ausgewählten Textes aus der Liste
.
*
en:
Deriving the selected text out of the list. */
locstrReturnValue = parmJComboBox.getSelectedItem().toString();
}
/*
*
de:
* Z
urückliefern an die aufrufende Methode
.
*
en:
* R
eturning to the calling method. */
return
locstrReturnValue;
}
/*
* --------------------
*
de:
* Methode, um den
Auswahl-Code des ausgewählten Elementes einer Combobox-Liste oder des
* direkt eingegebenen Textes
zu extrahieren.
* Der
Auswahl-Code ist jener Teil, der vor dem (im Parameter 'parmDelimiterString'
* übergebenen) Trennzeichen steht
.
* Wird kein Trennzeichen im ausgewählten Eintrag der Combobox-Liste gefunden
,
* dann wird die gesamte Zeichenkette zurück geliefert
.
* Abhängig davon, ob die Eingabe den Regeln entspricht oder nicht, wird der
* Hintergrund des Feldes verschieden eingefärbt und ein Hinweis im GUI-Element
* 'lbl_InfoMessage' (definiert in der Basisklasse JSBS_TaskFrame) angezeigt.
*
en:
*
Method to extract the selection code of the selected element of the JCombobox-list
* or the direct entered text.
* The selection-code is the part before the delimiter-character (passed in parameter
* 'parmDelimiterString').
* If no delimiter-character is found within the selected entry of the JCombobox-list,
*
then the whole string is returned
.
* Depending, if the Entry-Rules are fulfilled or not, the background of the field
* ist colored with different colors and a message is displayed in the GUI-Element
* 'lbl_InfoMessage' (defined in the base-class JSBS_TaskFrame)
.
*/
public
static
String
getSelectedCodeFromJComboBox(JComboBox parmJComboBox
,
String parmDelimiterString
) {
/*
*
de: Prüfen auf 'leeres' Trennzeichen um einen Programmabsturz zu vermeiden.
*
en: Check for 'empty' delimiter to avoid a dump. */
if
(parmDelimiterString
==
null
)
return
null
;
/*
*
de:
*
Aufrufen der Methode die die gesamte Zeichenkette des ausgewählten Eintrags
*
zurück
liefert.
*
en:
*
Call the method which extracts the whole string of the selected entry of the
* JComboBox-list
and returns the string. */
String strSelectedComboBoxText = getSelectedTextFromJComboBox(parmJComboBox
);
/*
*
de:
*
Prüfen ob eine gültige Zeichenkette zurück geliefert wurde die weiter bearbeitet werden kann.
*
en:
*
Check if a valid string was returned which can be processed further. */
if
(
strSelectedComboBoxText
==
null
)
return
null
;
/*
*
de:
Ermitteln der Position des Trennzeichens.
*
en:
Get the position of the delimiter-character
. */
int
intDelimiterPosition
= strSelectedComboBoxText.indexOf(parmDelimiterString)
;
/*
*
de:
*
Prüfen, ob überhaupt ein Trennzeichen vorhanden ist.
*
Bei fehlendem Trennzeichen wird der gesamte Inhalt der Zeichenkette zurück geliefert.
*
en:
* Verify, if a delimiter-character exists.
* If the delimiter-character is missing, then the whole content of the string is returned.
*/
if
(intDelimiterPosition
< 0)
return
strSelectedComboBoxText
;
/*
*
de:
*
Bei existierendem Trennzeichen wird der Code-Teil vor dem Trennzeichen extrahiert und
*
zurück geliefert
.
*
en:
* If a delimiter-character exists, then the code-part is extracted und returned
.
*/
else
return
strSelectedComboBoxText
.substring(0, intDelimiterPosition);
}
/*
* --------------------
*
de:
* Methode, um den von einem Benutzer in einem GUI-Element der Klasse JComboBox
*
eingegebenen Text zu Prüfen und, wenn die Eingabe-Regeln erfüllt sind, zu
*
Extrahieren.
* Abhängig davon, ob die Eingabe den Regeln entspricht oder nicht, wird der
* Hintergrund des Feldes verschieden eingefärbt und ein Hinweis im GUI-Element
* 'lbl_InfoMessage' (definiert in der Basisklasse JSBS_TaskFrame) angezeigt.
*
en:
*
Method to check the text entered by a user out of a GUI-Element of
class JComboBox
* and extract it if the Entry-Rules are fulfilled.
* Depending, if the Entry-Rules are fulfilled or not, the background of the field
* ist colored with different colors and a message is displayed in the GUI-Element
* 'lbl_InfoMessage' (defined in the base-class JSBS_TaskFrame)
.
*/
public
static
String
getSelectedTextFromJComboBox(JComboBox parmJComboBox,
JSBS_TaskFrame parmJSBS_TaskFrame) {
/*
*
de: Prüfen auf 'leeres' Task-Frame um einen Programmabsturz zu vermeiden.
*
en: Check for 'empty' Task-Frame to avoid a dump. */
if
(parmJSBS_TaskFrame
==
null
)
return
null
;
/*
*
de:
*
Aufrufen der privaten Methode die extrahiert, prüft und den Hintergrund
*
einfärbt.
*
en:
*
Call the private method which extracts, checks and colors the background. */
String strIntermediateResult =
getSelectedTextFromJComboBox(
parmJComboBox
,
parmJSBS_TaskFrame.
frmCC
.
structJSBS_UniversalParameters
,
parmJSBS_TaskFrame.
structJSBS_EntryRules
);
/*
*
de:
*
Wenn die Methode 'null' zurückliefert dann wurde die Eingabe-Regel nicht
*
erfüllt
.
*
en:
*
If the method return 'null' then the EntryRule was not fulfilled. */
if
(
strIntermediateResult
!=
null
)
{
/*
*
de:
*
Eingabe-Regel
erfüllt
; Eingabe-Hinweis anzeigen weil in 'lbl_InfoMessage'
*
eventuell durch
einen vorigen Fehler eine Fehler-Hinweis enthält.
*
en:
*
Entry-Rule fulfilled; show the Info-Message for the entry because an
*
Error-Message might be displayed in
'lbl_InfoMessage' due to a previous
*
error.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
parmJSBS_TaskFrame.
frmCC
.
structJSBS_XML_DisplayStrings
.getInfoMessage(
parmJComboBox
, parmJSBS_TaskFrame.getClass().getName())
)
;
/*
de: Eingegebenen Text aus dem JTextField zurückliefern
.
*
en: Return entered text from JTextField
.
*/
return
strIntermediateResult;
}
else
{
/*
*
de:
*
Eingabe-Regel nicht
erfüllt
; zuerst feststellen ob die Eingabe zu kurz
*
oder zu lang ist und dann den entsprechenden
Eingabe-Hinweis in
*
'lbl_InfoMessage' anzeigen
.
*
en:
*
Entry-Rule not fulfilled; first find out if the entered text is too short
*
or too long and then display the fitting Info in 'lbl_InfoMessage'
.
*/
/*
*
de: Lokale Hilfs-Variablen.
*
en: Local auxilliary variables
. */
String locstrInfoMessageText =
""
;
Integer locintEntryRuleValue =
new
Integer(0);
/*
*
de: Eingegebenen Text ohne Prüfung aus dem GUI-Element extrahieren.
*
en: Extract the entered text out of the GUI-Element
. */
strIntermediateResult = getSelectedTextFromJComboBox(
parmJComboBox
);
/*
*
de:
Prüfen ob der eingegebene Text zu kurz ist
.
*
en: Verify if the entered text is too short
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMinimumLength(
parmJComboBox
.getName(), strIntermediateResult.trim().length())
)
{
/*
de:
*
Eingegebene Zeichenkette zu kurz
.
*
Aus den Prüf-Regeln die minimal notwendige Anzahl der Zeichen auslesen.
*
en:
*
Entered text-string too short.
*
Get the requiered minimum number of charactes out of the Entry-Rules.
*/
locintEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMinimumLength(
parmJComboBox
.getName());
/*
de: Sprachabhängigen Fehler-Text für die Info-Message ermitteln.
*
en: Get the language-dependant error-text for the info-message
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_StringTooShort"
);
}
/*
*
de:
Prüfen ob der eingegebene Text zu lang ist
.
*
en: Verify if the entered text is too long
. */
if
(
! parmJSBS_TaskFrame.
structJSBS_EntryRules
.checkMaximumLength(
parmJComboBox
.getName(), strIntermediateResult.trim().length())
)
{
/*
de:
*
Eingegebene Zeichenkette zu lang
.
*
Aus den Prüf-Regeln die maximal erlaubte Anzahl der Zeichen auslesen.
*
en:
*
Entered text-string too long.
*
Get the requiered maximum number of charactes out of the Entry-Rules.
*/
locintEntryRuleValue =
parmJSBS_TaskFrame.
structJSBS_EntryRules
.getMaximumLength(
parmJComboBox
.getName());
/*
de: Sprachabhängigen Fehler-Text für die Info-Message ermitteln.
*
en: Get the language-dependant error-text for the info-message
.
*/
locstrInfoMessageText =
parmJSBS_TaskFrame
.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(
"JSBS_StringTooLong"
);
}
/*
de:
Fehler-Text im GUI-Element 'lbl_InfoMessage' anzeigen
.
*
en: Display the error-message in the GUI-Element #lbl_InfoMessage'
.
*/
parmJSBS_TaskFrame.get_lbl_InfoMessage().setText(
locstrInfoMessageText +
" "
+
JSBS_Formatter.toFormattedString(
locintEntryRuleValue
));
/*
de:
*
Aufrufender Methode durch 'null' signalisieren, daß der eingegebene
Wert
*
die Eingabe-Regel nicht erfüllt.
*
en:
*
Signal to the calling method by 'null' that the entered value has not passed
*
the Entry-Rules
.
*/
return null
;
}
}
/*
* --------------------
*
de:
* Methode, um den von einem Benutzer in einem GUI-Element der Klasse JComboBox
*
eingegebenen Text zu Prüfen und, wenn die Eingabe-Regeln erfüllt sind, einen
*
Auswahl-Code zu extrahieren.
* Der
Auswahl-Code ist jener Teil, der vor dem (im Parameter 'parmDelimiterString'
* übergebenen) Trennzeichen steht
.
* Wird kein Trennzeichen im ausgewählten Eintrag der Combobox-Liste gefunden
,
* dann wird die gesamte Zeichenkette zurück geliefert
.
* Abhängig davon, ob die Eingabe den Regeln entspricht oder nicht, wird der
* Hintergrund des Feldes verschieden eingefärbt und ein Hinweis im GUI-Element
* 'lbl_InfoMessage' (definiert in der Basisklasse JSBS_TaskFrame) angezeigt.
*
en:
*
Method to check the text entered by a user out of a GUI-Element of
class JComboBox
* and extract a selection-code if the Entry-Rules are fulfilled.
* The selection-code is the part before the delimiter-character (passed in parameter
* 'parmDelimiterString').
* If no delimiter-character is found within the selected entry of the JCombobox-list,
*
then the whole string is returned
.
* Depending, if the Entry-Rules are fulfilled or not, the background of the field
* ist colored with different colors and a message is displayed in the GUI-Element
* 'lbl_InfoMessage' (defined in the base-class JSBS_TaskFrame)
.
*/
public
static
String
getSelectedCodeFromJComboBox(JComboBox parmJComboBox
,
String parmDelimiterString
,
JSBS_TaskFrame parmJSBS_TaskFrame) {
/*
*
de: Prüfen auf 'leeres' Task-Frame und Trennzeichen um einen Programmabsturz zu vermeiden.
*
en: Check for 'empty' Task-Frame and delimiter to avoid a dump. */
if
(parmDelimiterString
==
null
)
return
null
;
if
(parmJSBS_TaskFrame
==
null
)
return
null
;
/*
*
de:
*
Aufrufen der Methode die die gesamte Zeichenkette des ausgewählten Eintrags
*
der Combobox-Liste prüft, den Hintergrund einfärbt und die Zeichenkette zurück
* liefert.
*
en:
*
Call the method which extracts the whole string of the selected entry of the
* JComboBox-list
, checks it colors the background and returns the string. */
String strSelectedComboBoxText = getSelectedTextFromJComboBox(parmJComboBox,
parmJSBS_TaskFrame);
/*
*
de:
*
Prüfen ob eine gültige Zeichenkette zurück geliefert wurde die weiter bearbeitet werden kann.
*
en:
*
Check if a valid string was returned which can be processed further. */
if
(
strSelectedComboBoxText
==
null
)
return
null
;
/*
*
de:
Ermitteln der Position des Trennzeichens.
*
en:
Get the position of the delimiter-character
. */
int
intDelimiterPosition
= strSelectedComboBoxText.indexOf(parmDelimiterString)
;
/*
*
de:
*
Prüfen, ob überhaupt ein Trennzeichen vorhanden ist.
*
Bei fehlendem Trennzeichen wird der gesamte Inhalt der Zeichenkette zurück geliefert.
*
en:
* Verify, if a delimiter-character exists.
* If the delimiter-character is missing, then the whole content of the string is returned.
*/
if
(intDelimiterPosition
< 0)
return
strSelectedComboBoxText
;
/*
*
de:
*
Bei existierendem Trennzeichen wird der Code-Teil vor dem Trennzeichen extrahiert und
*
zurück geliefert
.
*
en:
* If a delimiter-character exists, then the code-part is extracted und returned
.
*/
else
return
strSelectedComboBoxText
.substring(0, intDelimiterPosition);
}
/*
* --------------------
*
de:
* Lokale Methode, um den von einem Benutzer in einem GUI-Element der Klasse
*
JComboBox
eingegebenen Text zu Prüfen und, wenn die Eingabe-Regeln erfüllt
*
sind, zu
Extrahieren.
* Abhängig davon, ob die Eingabe den Regeln entspricht oder nicht, wird der
* Hintergrund des Feldes verschieden eingefärbt und ein Hinweis im GUI-Element
* 'lbl_InfoMessage' (definiert in der Basisklasse JSBS_TaskFrame) angezeigt.
*
en:
*
Local method to check the text entered by a user out of a GUI-Element of
*
class JComboBox
extract it if the Entry-Rules are fulfilled.
* Depending, if the Entry-Rules are fulfilled or not, the background of the field
* ist colored with different colors and a message is displayed in the GUI-Element
* 'lbl_InfoMessage' (defined in the base-class JSBS_TaskFrame)
.
*/
private
static
String
getSelectedTextFromJComboBox(
JComboBox
parmJComboBox
,
JSBS_UniversalParameters
parmJSBS_UniversalParameters
,
JSBS_EntryRules parmJSBS_EntryRules
) {
/*
*
de: Prüfen auf 'leere' Parameter um einen Programmabsturz zu vermeiden.
*
en: Check for 'empty' parameters to avoid a dump. */
if
(
parmJComboBox
==
null
)
return
null
;
if
(parmJSBS_UniversalParameters
==
null
)
return
null
;
if
(parmJSBS_EntryRules
==
null
)
return
null
;
/*
*
de: Eingegebenen Text aus dem GUI-Element extrahieren.
*
en: Extract the entered text out of the GUI-Element. */
String locstrText
= getSelectedTextFromJComboBox(
parmJComboBox
)
;
/*
*
de: Sicherheitshalber auf 'null' prüfen.
*
en: Check against 'null' to make sure not to dump. */
if
(locstrText
==
null
)
return
null
;
/*
*
de:
*
Algorithmus zum speziellen Prüfen eines GUI-Elements ohne Eingabe.
*
Wenn das Eingabefeld innerhalb der Application als 'Mandatory' definiert
* wurde, dann ist eine fehlende Eingabe auf jeden Fall ein Fehler.
*
Wenn ein Eingabe-Feld in der XML-Datei ('DisplayStrings.xml') nicht als
*
'Mandatory' (Eingabe erforderlich) definiert
ist und keine Eingabe erfolgt ist
*
(leere Zeichenkette) dann wird die
Prüfung auf korrekte Länge nicht ausgeführt.
*
en:
*
Algorithm for a special verification of a GUI-Elements with a blank entry.
* If the entry-field is defined as 'mandatory' within the application, then
* a blank entry is always an error.
* If an entry-field is defined as not 'mandatory' in the XML-file ('DisplayStrings.xml')
*
then a further check of the correct length is not performed
.
*/
int
locintTextLength = locstrText.trim().length()
;
if
(
locintTextLength == 0
) {
if
(parmJSBS_EntryRules.checkApplicationMandatory(
parmJComboBox
.getName()))
{
/*
*
de:
*
In der Application als 'Mandatory' definiert - Leere Eingabe ist ein Fehler.
*
Hintergrundfarbe (Fehler) des GUI-Elementes festlegen und Wert zurückliefern.
*
en:
*
Defined as 'mandatory' within the application - blank entry is an error.
*
Set the background-color (error) for the GUI-element and return the value. */
parmJComboBox
.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
return null
;
}
if
(! parmJSBS_EntryRules.checkParameterizedMandatory(
parmJComboBox
.getName()))
{
/*
*
de:
*
In der XML-Datei als 'Nicht Mandatory' definiert - Leere Eingabe ist kein Fehler.
*
Hintergrundfarbe (in Ordnung) des GUI-Elementes festlegen und Wert zurückliefern.
*
en:
*
Defined as 'not mandatory' in the XML-file - blank entry is not an error.
*
Set the background-color (o.k.) for the GUI-element and return the value. */
parmJComboBox
.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
return
""
;
}
}
/*
*
de: Prüfen ob die eventuell definierte Eingabe-Regel erfüllt ist.
*
en: Check if a potential defined Entry-Rule is fulfilled. */
if
(parmJSBS_EntryRules.checkLengthRange(
parmJComboBox
.getName(),
locintTextLength)) {
/*
*
de:
*
Eingabe-Regel erfüllt; passende Farbe für den Hintergrund setzen und
*
eingegebenen Wert an die aufrufende Methode zurückliefern
.
*
en:
*
Entry-Rule fulfilled; set fitting color for the background and
* return the entered value to the calling method
. */
parmJComboBox
.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
return
locstrText;
}
else
{
/*
*
de:
*
Eingabe-Regel nicht erfüllt; passende Farbe für den Hintergrund setzen und
* 'null' an die aufrufende Methode zurückliefern
um eine fehlerhafte Eingabe
*
zu signalisieren.
*
en:
*
Entry-Rule not fulfilled; set fitting color for the background and
* return 'null' to the calling method to signal an incorrect entry
. */
parmJComboBox
.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
return null
;
}
}
/*
* --------------------
*
de:
*
METHODE um einen Text (in einer Zeichenkette, Klasse String) in einem GUI-Element
*
der Klasse JTextField anzuzeigen.
*
en:
*
METHOD to set the text (as a String) to a GUI-Element of class
JTextField. */
public
static void
setTextToJTextField(JTextField parmJTextField, String parmString)
{
/*
*
de: Prüfen auf leeres GUI-Element um einen Dump zu vermeiden.
*
en:
Check for empty GUI-element to avoid a dump */
if
(parmJTextField
==
null
)
return
;
/*
*
de:
*
Wenn der String (Zeichenkette) mit dem anzuzeigenden Text nicht 'null' ist
*
dann den Text im JTextField anzeigen.
*
en:
*
If the 'String' with the text to be displayed is not 'null',
* then
set the text to the JTextField. */
if
(parmString
!=
null
)
parmJTextField.setText(parmString);
}
/*
* --------------------
* de:
* METHODE um ein GUI-Element der Klasse JComboBox mit Auswahlmöglichkeiten zu füllen.
* Die anzuzeigenden Text-Elemente sind in einem Array mit Zeichenketten (Strings) enthalten.
* en:
* METHOD
to set the list of choices to a GUI-Element of class
JComboBox.
* The text-elements to be listed are
provided within an array of Strings. */
public
static void
setListToJComboBox(JComboBox parmJComboBox, String[] parmListValues)
{
/*
* de: Prüfen ob GUI-Element oder Array leer sind um einen Dump zu vermeiden.
* en:
Check for empty GUI-element or Array to avoid a dump. */
if
(parmJComboBox
==
null
)
return
;
if
(parmListValues
==
null
)
return
;
/*
* de: 'Private' Methode verwenden um das Array in einen Vector umzuwandeln.
* en:
Use the 'private' method to convert the array to a vector.
*/
Vector
vecListValues = transformArrayToVector(parmListValues);
/*
* de: JComboBox füllen: dabei die Methode mit dem Vector als Parameter verwenden.
* en:
Fill
the JComboBox using the method with the vector as parameter.
*/
setListToJComboBox(parmJComboBox,
vecListValues);
}
/*
* de:
* Abwandlung der obigen Methode mit einem Vector, der eine Liste von Werten, die nicht
* in der Liste der Combo-Box angezeigt werden sollen, enthält.
* en:
*
Derivation of the above method with a Vector containing the values to
be excluded. */
public
static void
setListWithExclusionsToJComboBox(
JComboBox parmJComboBox, String[] parmListValues, Vector
parmExclusionValues) {
/*
* de: Prüfen ob GUI-Element, Array oder Vector leer sind um einen Dump zu vermeiden.
* en:
Check for empty GUI-element, Array or Vector to avoid a dump. */
if
(parmJComboBox
==
null
)
return
;
if
(parmListValues
==
null
)
return
;
if
(parmExclusionValues
==
null
)
return
;
/*
* de: Umwandeln des Array mit den Zeichenketten in einen Vector.
* en:
Transform the array of Strings to a Vector. */
Vector vecListValues = transformArrayToVector(parmListValues);
/*
* de: Obige Methode zum Füllen der JComboBox aufrufen.
* en:
Use the above method to fill the JComboBox. */
setListWithExclusionsToJComboBox(parmJComboBox, parmListValues,
parmExclusionValues);
}
/*
* de:
* ABWANDLUNG der obigen METHODE mit einem Array aus Zeichenketten (Strings) mit den Werten,
* die nicht in der Liste der Combo-Box angezeigt werden sollen.
* en:
* DERIVATION of the above METHOD with an array of Strings with the
values to be excluded. */
public
static void
setListWithExclusionsToJComboBox(
JComboBox parmJComboBox, String[] parmListValues, String[]
parmExclusionValues) {
/*
* de: Prüfen ob GUI-Element oder Arrays leer sind um einen Dump zu vermeiden.
* en:
Check for empty GUI-element or Arrays to avoid a dump. */
if
(parmJComboBox
==
null
)
return
;
if
(parmListValues
==
null
)
return
;
if
(parmExclusionValues
==
null
)
return
;
/*
* de: Beide Arrays mit Zeichenketten in einen Vector umwandeln.
* en:
Transform both array of Strings to a vector. */
Vector
vecListValues = transformArrayToVector(parmListValues);
Vector
vecExclusionValues = transformArrayToVector(parmExclusionValues);
/*
* de: Obige Methode zum Füllen der JComboBox aufrufen.
* en:
Use the above method to fill the JComboBox. */
setListWithExclusionsToJComboBox(parmJComboBox, vecListValues,
vecExclusionValues);
}
/*
* de:
* ABWANDLUNG der obigen Methode mit einer einzelnen Zeichenkette (String) mit einem
* Wert, der nicht in der Liste angezeigt werden soll.
* en:
* DERIVATION of the above method with a single String with one value
to be excluded. */
public
static void
setListWithExclusionsToJComboBox(
JComboBox parmJComboBox, String[] parmListValues, String
parmExclusionValue) {
/*
* de: Prüfen ob GUI-Element oder Array leer sind um einen Dump zu vermeiden.
* en:
Check for empty GUI-element or Array to avoid a dump. */
if
(parmJComboBox
==
null
)
return
;
if
(parmListValues
==
null
)
return
;
/*
* de: Umwandeln des Array mit den Zeichenketten in einen Vector.
* en:
Transform the array of Strings to a Vector. */
Vector vecListValues = transformArrayToVector(parmListValues);
/*
* de: Leeren Vector erstellen; dieser wird den einzelnen auszuschliessenden Wert enthalten.
* en:
Create an empty Vector which will hold the Exclusion value. */
Vector vecExclusionValues =
new
Vector();
/*
* de:
*
Wenn der übergebene String mit dem auszuschliessenden Wert nicht null ist dann wird
* er in den Vector eingefügt.
* en:
*
If the passed String with the value to be excluded is not null then add it to the Vector.
*/
if
(parmExclusionValue
!=
null
)
vecExclusionValues.addElement(parmExclusionValue);
/*
* de: Obige Methode zum Füllen der JComboBox aufrufen.
* en:
Use the above method to fill the JComboBox. */
setListWithExclusionsToJComboBox(parmJComboBox, vecListValues,
vecExclusionValues);
}
/*
* --------------------
* de:
* METHODE zum Auflisten einer Menge von Auswahlmöglichkeiten in einem GUI-Element
* der Klasse JComboBox. Die anzuzeigenden Texte sind in einem Vector enthalten
* en:
* METHOD
to set the list of choices to a GUI-Element of class
JComboBox.
* The text-elements to be listed are
provided within a Vector. */
public
static void
setListToJComboBox(JComboBox parmJComboBox, Vector parmListValues)
{
/*
de: Prüfen auf leeres GUI-Element oder Vector um eine späteren Dump zu vermeiden.
* en:
Check for empty GUI-element or Vector to avoid a dump. */
if
(parmJComboBox
==
null
)
return
;
if
(parmListValues
==
null
)
return
;
/*
de: Combo-Box leeren.
* en:
Clear
the combo-box. */
parmJComboBox.removeAllItems();
/*
de: Anzahl der Elemente im Vector ermitteln.
* en:
Get
the number of elements within the Vector. */
int
intVectorSize
= parmListValues.size();
/*
de: Den Vector durchgehen, jedes Element herausholen und dessen Wert zur Combo-Box
* hinzufügen
.
* en:
Cycle
through the vector, get each element and add its value to the combo-box.
*/
for
(
int
intVectorIndex
= 0; intVectorIndex < intVectorSize; intVectorIndex++)
{
String
locstrElement = (String)
parmListValues.elementAt(intVectorIndex);
parmJComboBox.addItem(locstrElement);
}
}
/*
* --------------------
* de:
* METHODE um ein GUI-Element der Klasse JBomboBox mit Auswahlmöglichkeiten zu füllen.
* Die zu listenden Text-Elemente werden in einem Vector bereit gestellt.
* Aus der Liste auszuschliessende Werte werden ebenfall in einem Vector bereit gestellt.
* en:
* METHOD
to set the list of choices to a GUI-Element of class
JComboBox.
* The text-elements to be listed are
provided within a Vector.
* The values to be excluded from
the list are provided within a Vector, too. */
public
static void
setListWithExclusionsToJComboBox(
JComboBox parmJComboBox, Vector parmListValues, Vector
parmExclusionValues) {
/*
* de: Prüfen auf leeres GUI-Element oder leeren Vector um einen Dump zu vermeiden.
* en:
Check for empty GUI-element or Vector to avoid a dump. */
if
(parmJComboBox
==
null
)
return
;
if
(parmListValues
==
null
)
return
;
/*
* de: Combo-Box leeren.
* en:
Clear
the combo-box. */
parmJComboBox.removeAllItems();
/*
* de: Anzahl der Elemente des Vectors ermitteln.
* en:
Get
the number of elements within the Vector. */
int
intVectorSize
= parmListValues.size();
/*
* de: Den Vector 'durchgehen', jedes Element auslesen und in die Combo-Box einfügen.
* en:
Cycle
through the vector, get each element and add it to the combo-box.
*/
for
(
int
intVectorIndex
= 0; intVectorIndex < intVectorSize; intVectorIndex++)
{
String
locstrElement = (String)
parmListValues.elementAt(intVectorIndex);
/*
* de: Prüfen ob das Element in der Liste der auszuschliessenden Werte enthalten ist.
* en:
Check
if the Element is within the List with the values to be excluded.
*/
if
(!
isStringWithinList(parmExclusionValues, locstrElement))
parmJComboBox.addItem(locstrElement);
}
}
/*
* de:
* ABWANDLUNG der obigen METHODE mit einem Array aus Strings (Zeichenketten) mit den Werten
* die von der Anzeige ausgeschlossen werden sollen.
* en:
*
DERIVATION of the above METHOD with an array of Strings with the
values to be excluded. */
public
static void
setListWithExclusionsToJComboBox(
JComboBox parmJComboBox, Vector parmListValues, String[]
parmExclusionValues) {
/*
* de: Umwandeln des String-Arrays in einen Vector.
* en:
Transform the array of Strings to a vector. */
Vector vecExclusionValues =
transformArrayToVector(parmExclusionValues);
/*
* de: Die obige Methode verwenden um die JComboBox zu füllen.
* en:
Use the above method to fill the JComboBox. */
setListWithExclusionsToJComboBox(parmJComboBox, parmListValues,
vecExclusionValues);
}
/*
* de:
* ABWANDLUNG der obigen METHODE mit einem einzigen String mit einem Wert, der nicht in
* der Liste der Combo-Box angezeigt werden soll.
* en:
* DERIVATION of the above METHOD with a single String with one value
to be excluded. */
public
static void
setListWithExclusionsToJComboBox(
JComboBox parmJComboBox, Vector parmListValues, String
parmExclusionValue) {
/*
* de: Einen leeren Vector erzeugen.
* en:
Create an empty Vector. */
Vector vecExclusionValues =
new
Vector();
/*
* de:
*
Wenn die übergebene Zeichenkette (String) nicht 'null' ist dann wird sie in den Vector eingefügt.
* en:
*
If the passed String is not 'null' then add it to the Vector.
*/
if
(parmExclusionValue
!=
null
)
vecExclusionValues.addElement(parmExclusionValue);
/*
* de: Die obige Methode verwenden um die JComboBox zu füllen.
* en:
Use the above method to fill the JComboBox. */
setListWithExclusionsToJComboBox(parmJComboBox, parmListValues,
vecExclusionValues);
}
/*
* --------------------
* de:
* METHODE zum Anzeigen der Auswahlliste in einem GUI-Element der Klasse JComboBox.
* Die Liste mit dem Inhalt der Combo-Box ist aus dem Vector mit den
*
'Roh-Daten für die Anzeige' der im zugehörigen Client-Side Business-Object (BOC)
* aufbereitet wurde.
* Die 'Umwandlung' der Daten aus den Parametern in die Zeilen für die Anzeige erfolgt
* in der aufgerufenen Methode.
* en:
* METHOD
to set the list of choices to a GUI-Element of class
JComboBox.
* The list of the combo-box content is derived
from a 'raw-display-data' vector
* which was prepared
within the client-side Business Object (BOC).
* The 'conversion' of the data in the parameters to the lines for display is done
* in the method called
.
*/
public
static void
setListWithExclusionsToJComboBox(JComboBox parmJComboBox,
Vector
parmRawDisplayData,
String[] parmArrangementDirections,
Vector parmExclusionValues) {
/*
*
de:
*
Vector 'konstruieren* und die Methode aufrufen, die aus den Daten in den Parametern
* die Vector-Elemente der Klasse 'String' aufbereiten
.
* en:
*
'Construct' a Vector and call the method that build the Vector-elements of class 'String'
* out of the data passed as parameter
.
*/
Vector vecValuesToBeDisplayed =
buildVectorForDisplayInComboboxOrList(parmRawDisplayData,
parmArrangementDirections,
parmExclusionValues)
;
/*
*
de: Basis-Method zum Füllen der JComboBox mit den Daten aus dem Vector benutzen.
* en:
Use
the base-method to fill the JComboBox out of a vector.
*/
setListToJComboBox(parmJComboBox,
vecValuesToBeDisplayed);
}
/*
* de:
* ABWANDLUNG der obigen METHODE mit einem Array mit Zeichenketten (Strings) das die Werte,
* die nicht in der Combo-Box angezeigt werden sollen, enthält.
*
en:
* DERIVATION of the above METHOD with an array of Strings with the
values to be excluded. */
public
static void
setListWithExclusionsToJComboBox(JComboBox parmJComboBox,
Vector parmRawDisplayData,
String[]
parmArrangementDirections,
String[]
parmExclusionValues) {
/*
* de: Array mit den Strings in einen Vector umwandeln.
* en:
Transform the array of Strings to a vector. */
Vector vecExclusionValues =
transformArrayToVector(parmExclusionValues);
/*
* de: Methode mit der Basis-Funktionalität verwenden um die Combo-Box zu füllen.
* en: Use the method with basic functionality to fill
the JComboBox. */
setListWithExclusionsToJComboBox(parmJComboBox,
parmRawDisplayData,
parmArrangementDirections,
vecExclusionValues);
}
/*
* de:
* ABWANDLUNG der obigen METHODE mit einem Array mit einer einzelnen Zeichenketten (String),
* die den Wert der nicht in der Combo-Box angezeigt werden sollen, enthält.
*
en:
* DERIVATION of the above METHOD with a single String containing the
value to be excluded. */
public
static void
setListWithExclusionsToJComboBox(JComboBox parmJComboBox,
Vector parmRawDisplayData,
String[]
parmArrangementDirections,
String
parmExclusionValue) {
/*
* de: Einen neuen Vector erstellen und den String einfügen.
* en:
Create a new Vector and add the String. */
Vector
vecExclusionValues =
new
Vector();
/*
* de: Wenn der String nicht 'null' ist dann in den Vector einfügen.
* en:
If the passed String is not null then add it to the Vector.
*/
if
(parmExclusionValue
!=
null
)
vecExclusionValues.addElement(parmExclusionValue);
/*
* de: Methode mit der Basis-Funktionalität verwenden um die Combo-Box zu füllen.
* en: Use the method with basic functionality to fill
the JComboBox. */
setListWithExclusionsToJComboBox(parmJComboBox,
parmRawDisplayData,
parmArrangementDirections,
vecExclusionValues);
}
/*
* --------------------
* de:
* METHODE zum Füllen der Liste mit den Auswahlmöglichkeiten in einem GUI-Element
* der Klasse JComboBox.
* en:
* METHOD
to fill the list of choices to a GUI-Element of class JComboBox.
*
This
method is a derivation of the above method.
*/
public
static void
setListToJComboBox(JComboBox parmJComboBox,
Vector parmRawDisplayData,
String[] parmArrangementDirections) {
/*
de:
*
Konstruieren eines leeren Vectors für die Werte, die nicht in der Liste der
* angezeigten Werte aufgenommen werden.
*
en:
*
Construct an empty vector for the Exclusion-Values. */
Vector vecExclusionValues =
new
Vector();
/* de: Verwenden der vorhegehenden Methode um die Combo-Box zu füllen.
* en:
Use above method to fill the JComboBox. */
setListWithExclusionsToJComboBox(parmJComboBox,
parmRawDisplayData,
parmArrangementDirections,
vecExclusionValues);
}
/*
* --------------------
* de:
* METHODE zum Markieren (und Auswählen) eines Eintrags in einer JComboBox wenn der Eintrag
* gleich ist wie der im Parameter 'parmCode' übergebene Wert.
* Der boolsche Return-Wert zeigt an, ob der im 'parmCode' übergebene Wert überhaupt
* in der Liste der Werte der Combo-Box enthalten ist.
* Wenn der Wert des Parameters 'parmJSBS_UniversalParameters' nicht 'null' ist dann wird
* der Hintergrund der JComboBox entsprechend den in der Struktur JSBS_UniversalParameters
* festgelegten Farben eingefärbt.
* Der Parameter 'parmPopUp' bewirkt, dass die Liste der Combo-Box aufgeklappt wird wenn
* der in 'parmCode' übergebene Wert nicht in der Liste enthalten ist.
* Die Einträge in der Liste der Combo-Box werden geprüft ob sie einen Delimiter-String
* (definiert als Konstante zu Beginn dieser Klasse) enthalten. Wenn ein Delimiter-String
* vorhanden ist dann wird nur der Teil vor dem Delimiter-String mit dem im 'parmCode'
* übergebenen Wert verglichen.
* en:
* METHOD
to select the item of a JComboBox that coincides with the passed
parameter
* 'parmCode'.
* The boolean
return-value signals if the value passed with 'parmCode' is an item
of
* the list displayed within the JComboBox.
* If
there is the JSBS_UniversalParameters provided (not null), then the
background
* of the JComboBox is colored according to
the colors set in JSBS_UniversalParameters.
* The
parameter 'parmPopUp' causes the list of the JComboBox to be shown if
the
* Code passed as parameter is not contained in the
list of the JComboBox.
* The single elements of the
JComboBox are checked if the contain the delimiter-string
* defined
as constant (-). If this is found, only the part before the delimiter
is
* compared to the parameter
'parmCode'. */
public
static boolean
setJComboBoxItem(JComboBox parmJComboBox,
String
parmCode,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
boolean
parmPopUp) {
/*
* de: Prüfen ob alle verpflichtenden Parameter einen Wert enthalten; das vermeidet einen Dump.
* en:
Check
if all mandatory parameters contain values; this avoids a dump later. */
if
(parmJComboBox
==
null
)
return
false
;
if
(parmCode
==
null
)
return
false
;
/*
* de:
* Führende und nachfolgende Leerzeichen vom Vergleichswert entfernen und den
* Vergleichswert auf eine lokale Variable übertragen.
* en:
*
Remove
leading and trailing blanks from the value to be checked and transfer
it
* to a local value. */
String
strCode = parmCode.trim();
/*
* de: Lokale Variable für die Werte aus der JComboBox.
* en:
Local
variables for values derived from the JComboBox. */
String
strStringFromList;
String
strCodeFromList =
""
;
/*
* de: Index für den Delimiter-String
* en:
Index
for the delimiter-string. */
int
intDelimiterPosition;
/*
* de: Anzahl der Einträge in der JComboBox und Index für die Adressierung.
* en:
Number
of items within the JComboBox and index to adress a
item. */
int
intListSize = parmJComboBox.getItemCount();
int
intListIndex;
/*
* de:
* Überprüfen ob das Feld der JComboBox editiert werden kann.
* Wenn nicht, dann muss es für einen Augenblick editierbar gemacht werden
* um den in 'parmCode' übergebenen Wert anzeigen zu können.
* en:
*
Check
if the field of the JComboBox can be edited.
* If not,
then the JComboBox has to be made 'editable' for a short moment
* to
display a 'parmCode' that is not an item of the list.
*/
boolean
bolIsEditable = parmJComboBox.isEditable();
if
(!bolIsEditable)
parmJComboBox.setEditable(
true
);
parmJComboBox.setSelectedItem(strCode);
/*
* de: Wenn die JComboBox nicht als editierbar definiert war dann dieses wieder Ausschalten.
* en:
If
JComboBox was not defined as 'editable' then inhibit editing
again. */
if
(!bolIsEditable) parmJComboBox.setEditable(
false
);
/*
* de:
* Liste der Einträge in der Combo-Box durchgehen um zu prüfen ob ein Eintrag gleich dem
* als Parameter übergebenen Wert ist.
* en:
*
Loop
through the list if the items to see if an item matches the code
passed as parameter. */
for
(intListIndex = 0; intListIndex < intListSize; intListIndex++)
{
/*
* de:
* Übertragen des 'Texts' des ausgewählten Listen-Eintrags auf einen eigenen, lokalen String.
* en:
*
Transfer
the 'text' of the selected list-item to its own, local
string. */
strStringFromList
= ((String) parmJComboBox.getItemAt(intListIndex)).trim();
/*
* de:
*
Vergleichen des im Parameter übergebenen Text ob er den Text des Listen-Eintrag entspricht.
* en:
*
Compare
if the text passed as parameter matches the text of the
list-item. */
if
(strStringFromList.equals(strCode)) {
/*
* de:
* Hintergrund des JComboBox auf normale Hintergrundfarbe setzen; diese Farbe ist in der
* Struktur JSBS_UniversalParameters definiert.
* Aber nur dann Ausführen wenn im Parameter JSBS_UniversalStructure ein Wert übergeben wurde.
* en:
*
Set
the background of the JComboBox to the 'normal' color as defined
within the
* JSBS_UniversalParameters.
* But
do this only if the JSBS_UniversalParameters-structure is passed.
*/
if
(parmJSBS_UniversalParameters !=
null
)
{
parmJComboBox.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
}
/*
* de:
* Wenn die Auswahlliste der JComboBox noch angezeigt wird (verursacht durch einen
*
vorhergehenden Fehler) dann die Auswahlliste verbergen.
* Das Verbergen ist nur möglich wenn die JComboBox 'visible' ist - sonst tritt eine
* Exception (Ausnahmesituation) auf.
* en:
*
If
the item-list of the JComboBox is showing due to a previous error
then hide it.
* This command can only be done when the
JComboBox is visible – otherwise an exeption
* will
occur. */
if
(parmJComboBox.isShowing()) parmJComboBox.hidePopup();
/*
* de: Ausgewählten Eintrag wieder setzen und Methode beenden.
* en:
Set
the selected item again and return.
*/
parmJComboBox.setSelectedItem(strStringFromList);
return
true
;
}
}
/*
* de:
* Der als Parameter übergebenen 'Code' passt nicht als gesamte Zeichenkette zu einem
* Eintrag in der JComboBox.
* Versuchen ob der Text vor dem Delimiter-String mit dem gesuchten Code übereinstimmt.
* en:
*
The 'code' passed as parameter did not match a whole String of an
Item of the JComboBox.
* Try the text before the first
delimiter-character as 'code'. */
/*
* de:
* Die Liste mit den Einträgen durchgehen und ermitteln ob auf diese Weise ein zum
* als Parameter übergebenen Code passt.
* en:
* Loop through
the list if the items to see if an item matches the code passed
*
as
parameter. */
for
(intListIndex = 0; intListIndex < intListSize; intListIndex++)
{
/*
* de: Übertragen des 'Text' des ausgewählten Eintrags auf eine eigene Zeichenkette.
* en:
Transfer
the 'text' of the selected list-item to its own
string. */
strStringFromList
= (String) parmJComboBox.getItemAt(intListIndex);
/*
* de: Feststellen ob der beginnende Teil des Textes der Code ist.
* en:
See
if there is a code-part. */
intDelimiterPosition
= strStringFromList.indexOf(
CONST_CODE_TEXT_DELIMITER
);
if
(intDelimiterPosition < 1) {
/*
* de: Kein Trennzeichen gefunden; gesamten Text als 'Code' betrachten.
* en:
No
delimiter found; the whole text is considered as
'code'. */
strCodeFromList
= strStringFromList;
}
else
{
/*
* de: Trennzeichen gefunden; 'Code' extrahieren.
* en:
Delimiter
found; extract the 'code'. */
strCodeFromList
= strStringFromList.substring(0,
intDelimiterPosition).trim();
}
/*
* de:
*
Vergleichen ob der als Parameter übergebenen Code mit dem Code-Teil des Eintrags
* in der Combo-Box übereinstimmt.
* en:
*
Compare
if the code passed as parameter matches the code-part of the
list-item. */
if
(strCodeFromList.equals(strCode)) {
/*
* de:
* Hintergrund des JComboBox auf normale Hintergrundfarbe setzen; diese Farbe ist in der
* Struktur JSBS_UniversalParameters definiert.
* Aber nur dann Ausführen wenn im Parameter JSBS_UniversalStructure ein Wert übergeben wurde.
* en:
*
Set
the background of the JComboBox to the 'normal' color as defined
within the
* JSBS_UniversalParameters.
* But
do this only if the JSBS_UniversalParameters-structure is passed.
*/
if
(parmJSBS_UniversalParameters !=
null
)
{
parmJComboBox.setBackground(parmJSBS_UniversalParameters.
clrNormalBackground
);
}
/*
* de:
* Wenn die Auswahlliste der JComboBox noch angezeigt wird (verursacht durch einen
*
vorhergehenden Fehler) dann die Auswahlliste verbergen.
* Das Verbergen ist nur möglich wenn die JComboBox 'visible' ist - sonst tritt eine
* Exception (Ausnahmesituation) auf.
* en:
*
If
the item-list of the JComboBox is showing due to a previous error
then hide it.
* This command can only be done when the
JComboBox is visible – otherwise an exeption
* will
occur. */
if
(parmJComboBox.isShowing()) parmJComboBox.hidePopup();
/*
* de: Ausgewählten Eintrag wieder setzen und Methode beenden.
* en:
Set
the selected item again and return.
*/
parmJComboBox.setSelectedItem(strStringFromList);
return
true
;
}
}
/*
* de:
* Der als Parameter übergebene Code wurde nicht in der Auswahlliste gefunden.
* Hintergrund der Combo-Box mit der Fehlerfarbe versehen (wenn es durch den
* Parameter JSBS_UniversalParameters verlangt wird), Liste mit den Auswahlmöglichkeiten
* 'aufklappen' (wenn es durch den Parameter verlangt wird) und 'false' an die
*
aufrufende Methode signalisieren.
* en:
*
Code
passed as parameter was not found within the list of items.
* Set
background-color to 'Error' (if requested by the caller), show the
item-list
* (if requested) and return 'false'.
*/
if
(parmJSBS_UniversalParameters !=
null
)
{
parmJComboBox.setBackground(parmJSBS_UniversalParameters.
clrErrorBackground
);
}
if
(parmJComboBox.isShowing()) parmJComboBox.showPopup();
return
false
;
}
/*
* --------------------
* de:
* METHODEN zum Markieren (und Auswählen) eines Eintrags in einer JComboBox wenn der
* auszuwählende Wert eine Nummer ist.
* Damit wird ermöglicht, numerische Wert als Referenz zu verwenden und diese numerischen
* Werte in der Datenbank-Tabelle zu speichern.
* Beim Anzeigen der Auswahlliste in der Combobox können zu diesen numerischen Werten
* weitere Unterscheidungsmerkmale zugeordnet werden - z.B. sprachabhängige Texte.
* Beim Auswählen des jeweiligen Combobox-Eintrags kann diesen Methoden als Parameter
* eine numerische Klasse oder ein numerische elementarer Typ übergeben werden
.
* en:
* METHODS
to mark (and select) the item of a JComboBox if the passed
parameter
'parmCode'
* is a numeric value
.
* This enables the usage of numeric values as a reference and store these numeric values
* in a database-table.
* When the selection-list of the combobox is displayed, further distinguishing features can
* be shown in addition to the identifying number.
* Those distinguishing features can be language specific
.
* At the time when an element of the combobox has to be selected, a value of
a numeric
* class or a numeric elementary type can be passed in the parameter
'parmCode'. */
public
static boolean
setJComboBoxItem(JComboBox parmJComboBox,
Integer
parmCode,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
boolean
parmPopUp) {
/*
* de: Umwandeln des numerischen Parameters in eine Zeichenkette und die Methode für die
* Auswahl eines reinen Textes aus der Combobox-Liste aufrufen
.
* en:
*
Convert the numeric parameter into a string and call the method to select a pure text from
* the list displayed in a combobox
. */
return
setJComboBoxItem(parmJComboBox,
JSBS_Formatter.toFormattedString(parmCode),
parmJSBS_UniversalParameters, parmPopUp
)
;
}
/* *** */
public
static boolean
setJComboBoxItem(JComboBox parmJComboBox,
int
parmCode,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
boolean
parmPopUp) {
return
setJComboBoxItem(parmJComboBox,
JSBS_Formatter.toFormattedString(parmCode),
parmJSBS_UniversalParameters, parmPopUp
)
;
}
/* *** */
public
static boolean
setJComboBoxItem(JComboBox parmJComboBox,
Short parmCode,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
boolean
parmPopUp) {
return
setJComboBoxItem(parmJComboBox,
JSBS_Formatter.toFormattedString(parmCode),
parmJSBS_UniversalParameters, parmPopUp
)
;
}
/* *** */
public
static boolean
setJComboBoxItem(JComboBox parmJComboBox,
short
parmCode,
JSBS_UniversalParameters
parmJSBS_UniversalParameters,
boolean
parmPopUp) {
return
setJComboBoxItem(parmJComboBox,
JSBS_Formatter.toFormattedString(parmCode),
parmJSBS_UniversalParameters, parmPopUp
)
;
}
/*
* --------------------
* de:
* METHODE um einen 'Eintrag' am Anfang der Liste (item-position 0) einfügen zu können.
* Diese Methode ist notwendig um eine eventuelle Alternative zu den Einträgen
* präsentieren zu können.
* Diese Alternative kann z.B. 'Standard', 'Default' usw. sein.
* en:
* METHOD
to insert an 'item' at the beginning of the list (item-position
0)
* of a JComboBox.
* This method is
needed to present an alternative to the list.
* This
alternative might be e.g. 'Standard', 'default', etc. */
public
static void
insertJComboBoxItemAtIndex0(JComboBox parmJComboBox,
String
parmItemText) {
/*
* de: Prüfen auf leeres GUI-Element oder String um einen Dump zu vermeiden.
* en:
Check for empty GUI-element or Strings to avoid a dump. */
if
(parmJComboBox
==
null
)
return
;
if
(parmItemText
==
null
)
return
;
/*
* de:
*
Einfügen des als Text übergebenen Parameters in die erste Position der Auswahlliste
* der Combo-Box.
* en:
*
Insert the text passed as parameter at the first position of the
JComboBox-list. */
parmJComboBox.insertItemAt(parmItemText,
0);
}
/*
* de:
* ABWANDLUNG der obigen METHODE.
* Der am Beginn der Liste einzufügende Text ist sprach-abhängig.
*
Daher wird ein symbolischer Name als Parameter übergeben.
* Mit dem symbolischen Namen wird der sprach-abhängige Text aus der XML-Struktur
* mit den sprach-abhängigen GUI-Elementen ausgelesen.
* Der Zugriff auf die XML-Struktur erfolgt über das als Parameter übergebene Task-Frame.
* en:
*
DERIVATION
of the above METHOD.
* The text to be inserted should
be language-dependant.
*
Therefore a symbolic name is passed as parameter.
* With
that symbolic name the language dependant text for display is derived
from
* the XML-structure with language-dependant
GUI-elements.
* This XML-structure is accessed over the
Task-Frame passed as parameter. */
public
static void
insertJComboBoxItemAtIndex0(JComboBox parmJComboBox,
String
parmSymbolicName,
JSBS_TaskFrame
parmJSBS_TaskFrame) {
/*
* de: Prüfen auf leeres GUI-element, String oder TaskFrame um einen Dump zu vermeiden.
* en:
Check for empty GUI-element, String, or TaskFrame to avoid a dump.
*/
if
(parmJComboBox
==
null
)
return
;
if
(parmSymbolicName
==
null
)
return
;
if
(parmJSBS_TaskFrame
==
null
)
return
;
/*
* de: Sprach-abhängigen Text aus der XML-Struktur holen.
* en:
Get the language-dependant-text out of the XML-structure.
*/
String
strItemText
=
parmJSBS_TaskFrame.
frmCC
.
structJSBS_XML_DisplayStrings
.getSupplementaryText(parmSymbolicName);
/*
* de:
* Den aus der XML-Struktur ausgelesenen Text in die erste Position der JComboBox-Liste einfügen
* en:
*
Insert the text derived from the XML-structure at the first position
of the JComboBox-list.
*/
parmJComboBox.insertItemAt(strItemText,
0);
}
/*
* --------------------
* de:
* METHODE um den ersten Eintrag (mit index 0) einer JComboBox zu markieren.
* Das ermöglicht, den Eintrag mit einer speziellen Bedeutung als Auswahl-Vorschlag
* zu kennzeichnen.
* en:
* METHOD
to select the first item (with index 0) of a JComboBox.
* This
allows to present the user an item with a special meaning as default selection.
*/
public
static void
setJComboBoxItem0(JComboBox parmJComboBox) {
/*
* de: Prüfen auf leeres GUI-element um einen Dump zu vermeiden.
* en:
Check for empty GUI-element to avoid a dump. */
if
(parmJComboBox
==
null
)
return
;
/*
* de: Eintrag mit Index 0 auswählen.
* en:
Select the item with index 0.
*/
parmJComboBox.setSelectedIndex(0);
}
/*
* --------------------
* de:
* METHODE zum Prüfen, ob der Anwender den ersten Eintrag (mit Index 0) der JComboBox-Liste
* gewählt hat.
* Das erlaubt zu prüfen, ob eine spezielle Bedeutung (z.B. 'Standard', Default') ausgewählt
* wurde.
* en:
* METHOD
to check if the user selected the first item (with index 0) of a
JComboBox-list.
* This allows to verify if a special
meaning (e.g. 'Standard', 'default', etc.) was chosen. */
public
static boolean
isJComboBoxItem0Selected(JComboBox parmJComboBox) {
/*
* de: Prüfen auf leeres GUi-element um einen Dump zu vermeiden.
* en:
Check for empty GUI-element to avoid a dump. */
if
(parmJComboBox
==
null
)
return
false
;
/*
* de:
*
'Index' des ausgewählten Eintrags ermitteln; vergleichen ob der Index 0 ist und Methode beenden.
* en:
*
Get the 'index' of the selected item; compare if it is 0 and return.
*/
int
intIndex
= parmJComboBox.getSelectedIndex();
return
(intIndex
== 0);
}
/*
* --------------------
* de:
* METHODE zum Auflisten einer Menge von Auswahlmöglichkeiten in einem GUI-Element
* der Klasse JSBS_JList. Die anzuzeigenden Texte sind in einem Vector enthalten
* en:
* METHOD
to set the list of choices to a GUI-Element of class
JSBS_JList.
* The text-elements to be listed are
provided within a Vector. */
public
static void
setListToJSBS_JList(JSBS_JList parmJSBS_JList, Vector parmListValues)
{
/*
de: Prüfen auf leeres GUI-Element oder Vector um eine späteren Dump zu vermeiden.
* en:
Check for empty GUI-element or Vector to avoid a dump. */
if
(parmJSBS_JList
==
null
)
return
;
if
(parmListValues
==
null
)
return
;
/*
de:
*
List-Box leeren. Das muß über das 'Model' erfolgen.
* en:
*
Clear
the combo-box. That has to be done via the 'Model'. */
DefaultListModel locJListModel = parmJSBS_JList.getModel();
locJListModel.clear();
/*
de: Anzahl der Elemente im Vector ermitteln.
* en:
Get
the number of elements within the Vector. */
int
intVectorSize
= parmListValues.size();
/*
de: Den Vector durchgehen, jedes Element herausholen und dessen Wert zur Combo-Box
* hinzufügen
.
* en:
Cycle
through the vector, get each element and add its value to the combo-box.
*/
for
(
int
intVectorIndex
= 0; intVectorIndex < intVectorSize; intVectorIndex++)
{
String
locstrElement = (String)
parmListValues.elementAt(intVectorIndex);
locJListModel.add(intVectorIndex, locstrElement);
}
}
/*
* --------------------
* de:
* METHODE zum Füllen der Liste mit den Auswahlmöglichkeiten in einem GUI-Element
* der Klasse JSBS_JList. Diese Methode ist eine Abwandlung der vorhergehenden Methode.
* en:
* METHOD
to fill the list of choices to a GUI-Element of class JSBS_JList.
*
This
method is a derivation of the above method.
*/
public
static void
setListToJSBS_JList(JSBS_JList parmJSBS_JList,
Vector parmRawDisplayData,
String[] parmArrangementDirections) {
/*
de:
*
Konstruieren eines leeren Vectors für die Werte, die nicht in der Liste der
* angezeigten Werte aufgenommen werden.
*
en:
*
Construct an empty vector for the Exclusion-Values. */
Vector vecExclusionValues =
new
Vector();
/* de: Verwenden der vorhegehenden Methode um die List-Box zu füllen.
* en:
Use above method to fill the List-Box. */
setListWithExclusionsToJSBS_JList(parmJSBS_JList,
parmRawDisplayData,
parmArrangementDirections,
vecExclusionValues);
}
/*
* --------------------
* de:
* METHODE zum Anzeigen der Auswahlliste in einem GUI-Element der Klasse JSBS_JList.
* Die Liste mit dem Inhalt der List-Box ist aus dem Vector mit den
*
'Roh-Daten für die Anzeige' der im zugehörigen Client-Side Business-Object (BOC)
* aufbereitet wurde.
* Die 'Umwandlung' der Daten aus den Parametern in die Zeilen für die Anzeige erfolgt
* in der aufgerufenen Methode.
* en:
* METHOD
to set the list of choices to a GUI-Element of class
JSBS_JList.
* The list of the list-box content is derived
from a 'raw-display-data' vector
* which was prepared
within the client-side Business Object (BOC).
* The 'conversion' of the data in the parameters to the lines for display is done
* in the method called
.
*/
public
static void
setListWithExclusionsToJSBS_JList(JSBS_JList parmJSBS_JList,
Vector
parmRawDisplayData,
String[] parmArrangementDirections,
Vector parmExclusionValues) {
/*
*
de:
*
Vector 'konstruieren* und die Methode aufrufen, die aus den Daten in den Parametern
* die Vector-Elemente der Klasse 'String' aufbereiten
.
* en:
*
'Construct' a Vector and call the method that build the Vector-elements of class 'String'
* out of the data passed as parameter
.
*/
Vector vecValuesToBeDisplayed =
buildVectorForDisplayInComboboxOrList(parmRawDisplayData,
parmArrangementDirections,
parmExclusionValues)
;
/*
*
de: Basis-Method zum Füllen der JSBS_JList mit den Daten aus dem Vector benutzen.
* en:
Use
the base-method to fill the JSBS_JList out of a vector.
*/
setListToJSBS_JList(parmJSBS_JList,
vecValuesToBeDisplayed);
}
/*
* --------------------
* de:
* METHODE zum Hinzufügen einer Menge von Auswahlmöglichkeiten in einem GUI-Element
* der Klasse JSBS_JList. Die anzuzeigenden Texte sind in einem Vector enthalten und werden
* anschließend an die bereits angezeigten Text-Zeilen eingefügt.
* en:
* METHOD
to add a list of choices to a GUI-Element of class
JSBS_JList.
* The text-elements to be added are
provided within a Vector and will be diplayed
* after the already displayed lines of text
. */
public
static void
addListToJSBS_JList(JSBS_JList parmJSBS_JList, Vector parmListValues)
{
/*
de: Prüfen auf leeres GUI-Element oder Vector um einen späteren Dump zu vermeiden.
* en:
Check for empty GUI-element or Vector to avoid a dump. */
if
(parmJSBS_JList
==
null
)
return
;
if
(parmListValues
==
null
)
return
;
/*
de:
'Model' der List-Box herausholen; nur im Model können Werte hinzugefügt werden.
* en: Get the
'Model'; values can only be added via the Model. */
DefaultListModel locJListModel = parmJSBS_JList.getModel();
/*
de:
Ermitteln wieviel Zeilen bereits in der List-Box angezeigt werden.
* en: Get the
number of lines already displayed within the List-Box. */
int
intLinesInJSBS_JList = locJListModel.size();;
/*
de: Anzahl der Elemente im Vector ermitteln.
* en:
Get
the number of elements within the Vector. */
int
intVectorSize
= parmListValues.size();
/*
de: Den Vector durchgehen, jedes Element herausholen und dessen Wert zur Combo-Box
* hinzufügen
.
* en:
Cycle
through the vector, get each element and add its value to the combo-box.
*/
for
(
int
intVectorIndex
= 0; intVectorIndex < intVectorSize; intVectorIndex++)
{
String
locstrElement = (String)
parmListValues.elementAt(intVectorIndex);
locJListModel.add(intVectorIndex + intLinesInJSBS_JList, locstrElement);
}
}
/*
* --------------------
* de:
* METHODE zum Hinzufügen einer Menge von Auswahlmöglichkeiten in einem GUI-Element
* der Klasse JSBS_JList. Diese Methode ist eine Abwandlung der vorhergehenden Methode.
* en:
* METHOD
to add a list of choices to a GUI-Element of class JSBS_JList.
*
This
method is a derivation of the above method.
*/
public
static void
addListToJSBS_JList(JSBS_JList parmJSBS_JList,
Vector parmRawDisplayData,
String[] parmArrangementDirections) {
/*
de:
*
Konstruieren eines leeren Vectors für die Werte, die nicht in der Liste der
* angezeigten Werte aufgenommen werden.
*
en:
*
Construct an empty vector for the Exclusion-Values. */
Vector vecExclusionValues =
new
Vector();
/* de: Verwenden der vorhegehenden Methode um die List-Box zu füllen.
* en:
Use above method to fill the List-Box. */
addListWithExclusionsToJSBS_JList(parmJSBS_JList,
parmRawDisplayData,
parmArrangementDirections,
vecExclusionValues);
}
/*
* --------------------
* de:
* METHODE zum Hinzufügen einer Menge von Auswahlmöglichkeiten in einem GUI-Element
* der Klasse JSBS_JList. Diese Methode ist eine Abwandlung der vorhergehenden Methode.
* Die Liste mit dem Inhalt der List-Box ist aus dem Vector mit den
*
'Roh-Daten für die Anzeige' der im zugehörigen Client-Side Business-Object (BOC)
* aufbereitet wurde.
* Die 'Umwandlung' der Daten aus den Parametern in die Zeilen für die Anzeige erfolgt
* in der aufgerufenen Methode.
* en:
* METHOD
to add a list of choices to a GUI-Element of class JSBS_JList.
* The list of the list-box content is derived
from a 'raw-display-data' vector
* which was prepared
within the client-side Business Object (BOC).
* The 'conversion' of the data in the parameters to the lines for display is done
* in the method called
.
*/
public
static void
addListWithExclusionsToJSBS_JList(JSBS_JList parmJSBS_JList,
Vector
parmRawDisplayData,
String[] parmArrangementDirections,
Vector parmExclusionValues) {
/*
*
de:
*
Vector 'konstruieren* und die Methode aufrufen, die aus den Daten in den Parametern
* die Vector-Elemente der Klasse 'String' aufbereiten
.
* en:
*
'Construct' a Vector and call the method that build the Vector-elements of class 'String'
* out of the data passed as parameter
.
*/
Vector vecValuesToBeDisplayed =
buildVectorForDisplayInComboboxOrList(parmRawDisplayData,
parmArrangementDirections,
parmExclusionValues)
;
/*
*
de: Basis-Method zum Füllen der JSBS_JList mit den Daten aus dem Vector benutzen.
* en:
Use
the base-method to fill the JSBS_JList out of a vector.
*/
addListToJSBS_JList(parmJSBS_JList,
vecValuesToBeDisplayed);
}
/*
*
-----------------------
* Method to transfer the widths (in pixel) to an array of
Strings.
* This method is mainly used to store the users
setting of a table when a window is closed. */
public
static
String[] getTableColumnWidth(JT
able
parmJTable
)
{
/*
Check for empty GUI-element to avoid a dump. */
if
(parmJTable
==
null
)
return
new
String[0];
/*
Derive the Column-Model of the JTable as the number and widths of the
columns
* can be derived from there. */
TableColumnModel locColumnModel = parmJTable.getColumnModel();
int
intTableColumnCount
= locColumnModel.getColumnCount()
;
/*
Build the String-array that will hold the widths of each column.
*/
String[] strReturnValue =
new
String[intTableColumnCount];
/*
Loop through each column and transfer its widths to the String-array.
*/
for
(
int
intTableColumnIndex = 0;
intTableColumnIndex < intTableColumnCount;
intTableColumnIndex++) {
strReturnValue[intTableColumnIndex] =
JSBS_Formatter.toFormattedString(
locColumnModel.getColumn(intTableColumnIndex).getWidth());
}
/*
Return the String-array with the column-widths. */
return
st
rReturnValue;
}
/*
* --------------------
* de:
* METHODE die ein String-array in einen Vector umwandelt
* en:
* METHOD
to transform an array of Strings to a Vector. */
private
static
Vector
transformArrayToVector(String[] parmStringArray) {
/* de: Leeren Vector konstruieren.
* en:
Construct
an empty Vector. */
Vector
vecReturnValues =
new
Vector();
/* de: Prüfen auf ein leeres Array um einen Dump zu vermeiden.
* en:
Check
for empty array to avoid a dump. */
if
(parmStringArray
==
null
)
return
vecReturnValues;
/* de: Größe des Arrays feststellen.
* en:
Determine
the size of the array. */
int
intArraySize
= parmStringArray.
length
;
/* de: 'String's (Zeichenketten) aus dem Array lesen und den Vector füllen.
* en:
Read
the strings out of the array and fill the vector. */
for
(
int
intArrayIndex
= 0; intArrayIndex < intArraySize; intArrayIndex++)
{
vecReturnValues.addElement(parmStringArray[intArrayIndex]);
}
/* de: Den gerade erstellten Vector zurückliefern.
* en:
Return
the vector just built. */
return
vecReturnValues;
}
/*
* --------------------
* de:
* METHODE zum Prüfen ob der Wert eines Strings (Zeichenkette) in einem Vector mit Strings vorkommt.
* en:
* METHOD
to check if a value of a String is within a Vector of Strings. */
private
static boolean
isStringWithinList(Vector parmExclusionValues, String
parmStringToCheck) {
/* de: Prüfen auf 'leeren' Vector oder String um einen späteren Dump zu vermeiden.
* en:
Check
for empty Vector or String to avoid a dump. */
if
(parmExclusionValues
==
null
)
return
false
;
if
(parmStringToCheck
==
null
)
return
false
;
/*
de: Anzahl der Elemente innerhalb des Vectors ermitteln.
* en:
Get the number of elements within the Vector. */
int
intVectorSize
= parmExclusionValues.size();
/*
de: Den Vector 'durchgehen', jedes Element auslesen und mit dem String vergleichen.
* en:
Cycle through the vector, get each element and compare to the String.
*/
for
(
int
intVectorIndex
= 0; intVectorIndex < intVectorSize; intVectorIndex++) {
String locstrElement = (String)
parmExclusionValues.elementAt(intVectorIndex);
if
(locstrElement.compareTo(parmStringToCheck)
== 0)
return
true
;
}
/*
de:
*
Text im String nicht innerhalb der Elemente des Vectors; dieses Ergebnis zurückliefern.
* en:
*
Text of String not within the Elements of the Vector; return this result.
*/
return
false
;
}
/*
* --------------------
*
de:
*
METHODE, die aus dem Vector mit den rohen Daten für die Anzeige (wie er in BOC-Objekten
* gebildet wird) einen Vektor mit 'String's macht der für die Anzeige der Daten
*
in GUI-Elementen
vom Typ
JComboBox
oder JSBS_JList verwendet werden kan
n.
* Bedeutung der Parameter:
* parmRawDisplayData: Vector mit der Matrix der Variablen in den anzuzeigenden Datensätzen.
* Dieser Vector wurde nach dem Lesen von der Datenbank vom jeweiligen BOC-Objekt gebildet.
* parmArrangementDirections: String-Array mit den symbolischen Namen der Attribute
* im RawDisplayDataVector. Dieser Parameter bestimmt welche Attribute in welcher Reihenfolge
* den String für die Anzeige einer Zeile in der Combo-Box oder List-Box bilden.
* parmExclusionValues: Vector mit Strings die bestimmen, welche Strings, die aus den Daten
* von parmRawDisplayData und parmArrangementDirections nicht in den Vector für die
* spätere Anzeige aufgenommen werden.
* Damit können z.B. schon ausgewählte Werte aus der Auswahlliste herausgenommen werden.
*
en:
* METHOD making a Vector with 'String's for the display of data in GUI-elements of type
* JComboBox or JSBS_JList.
* The input for the Vector with data to be displayed comes from a raw-data-vector as it is built
* in BOC-objects
.
* Meaning of the parameters:
* parmRawDisplayData: Vector with the matrix of the variables in the datasets to be displayed.
* This Vector was build within the BOC-object after the data was read from the database.
* parmArrangementDirections: String-Array with the symbolic name of the attributes in the
* RawDisplayDataVector. This parameter decides which attributes in which order will
* build the String for the display of a line in the Combo-Box or List-Box.
* parmExclusionValues: Vector with Strings that decide which Strings, built out of the data
* in parmRawDisplayData and parmArrangementDirections will not be added to the Vector for
* later display.
* That allows, e.g., to exclude values that were already selected from the list for selection.
*/
private
static
Vector buildVectorForDisplayInComboboxOrList(
Vector parmRawDisplayData,
String[]
parmArrangementDirections
,
Vector parmExclusionValues
) {
/*
* de: Prüfen auf 'leere' Parameter-Werte um späteren Dump zu vermeiden.
* en:
Check
for empty parameter-values to avoid a dump later. */
if
(
parmRawDisplayData
==
null
)
return
new
Vector()
;
if
(
parmArrangementDirections
==
null
)
return
new
Vector()
;
if
(parmExclusionValues
==
null
)
parmExclusionValues =
new
Vector()
;
/*
* de:
*
Flag zum signalisieren ob ein Element nicht in den Vector mit den Werten für die Anzeige
* aufgenommen werden soll
.
* en:
*
Flag to signal if a element should not be put into the Vector with the values to be displayed. */
boolean
bolToBeExcluded =
false
;
/*
* de:
*
Zeichenkette für einen Wert, der in den Vector mit den Elementen für die Anzeige aufgenommen
* werden soll
.
* en:
*
String
containing one value to be added to the vector with the elements for display. */
String
strListValue;
/*
* de:
* Vector mit den Elementen die später angezeigt werden sollen.
* Dieser Vector ist der Rückgabe-Wert dieser Methode
.
* en:
*
Vector
with the elements to be displayed later.
*
This Vector is the return-value of this method.
*/
Vector
vecListValues =
new
Vector();
/*
* de: Anzahl der Elemente im Vector mit den Roh-Daten für die Anzeige.
* en:
Number
of elements within the raw-data-vector. */
int
intRawDisplayDataSize = parmRawDisplayData.size();
/*
* de:
* Aus dem Vector mit den Rohdaten extrahierter Vector mit den symbolischen
*
Namen für die Spalten, die Anzahl der Spalten und einem Wert für den Index.
* en:
*
Extracted
vector with the column-names of the raw-data-vector,
* its
number of elements and index for it. */
Vector
vecRawDisplayDataHeader =
new
Vector();
int
intRawDisplayDataHeaderSize;
int
intRawDisplayDataHeaderIndex;
/*
* de:
* Anzahl der Elemente im String-Array mit den Anweisungen für die Auswahl und Anordnung
* der 'Spalten' aus dem Rohdaten-Vector und ein Wert für den Index
.
* en:
*
Number
of elements within the array for the ArrangementDirections
and
* index for it. */
int
intArrangementDirectionsSize =
parmArrangementDirections.
length
;
int
intArrangementDirectionsIndex;
/*
* de:
* Aus dem Vector mit den Rohdaten extrahierter einzelner Vector mit den
*
Werten der Attribute für einen Datensatz, die Anzahl der Spalten (Attribute) und
*
einem Wert für den Index.
* en:
*
Extracted
vector with the values for one set,
* its number of
elements and string for an individual value. */
Vector
vecRawDisplayDataElement;
int
intRawDisplayDataElementSize;
String
strDisplayDataValue;
/*
* de:
* Werte zum Vergleichen der Werte eines Elements aus den ArragangementDirections
*
mit einem Wert aus dem Spalten-Namen-Vector von parmRawDisplayData
.
* en:
*
Values
to compare the values in the ArrangementDirections and in the
* Vector with the column-names for the
raw-data-vector. */
String
strColumnNameInArrangementDirections;
String
strColumnNameInRawDisplayDataHeader;
/*
* de:
* Wert zum Aufheben des Index des gesuchten symboöischen
Spalten-Namens im Vector mit der
* Anordnung der Spalten (raw-display-data-header) which is the first element of
*
parmRawDisplayData
.
* en:
*
Value
to keep the index of the searched column-name in the
raw-display-data-header. */
int
intColumnFoundIndex;
/*
* de:
* Prüfen ob der Roh-Daten-Vector überhaupt ein Element enthält und in diesem Fall
* das erste Element extrahieren - das ist dann der Vector mit den symbolischen
* Spalten-Namen
.
* en:
*
Check
if there is at least on element within the raw-data-vector and
* extract
the first element which is the vector with the column-names.
*/
if
(intRawDisplayDataSize > 0)
vecRawDisplayDataHeader
= (Vector) parmRawDisplayData.elementAt(0);
/*
de:
Holen der Anzahl der Spalten (Größe des Vectors mit den symbolischen Spalten-Namen)
.
* en:
Get
the number of columns (size of vector with symbolic column-names).
*/
intRawDisplayDataHeaderSize
= vecRawDisplayDataHeader.size();
/*
de:
In der for-Schleife jedes Element des Roh-Daten-Vector bearbeiten
.
*
en: Cycle
through the elements (vectors) with the raw-display-values.
*/
for
(
int
intRawDisplayDataIndex = 1;
intRawDisplayDataIndex
< intRawDisplayDataSize;
intRawDisplayDataIndex++)
{
/*
de:
*
Flag zum späteren Markieren ob ein Element nicht in der Liste angezeigt werden soll,
* zurücksetzen
.
*
en:
*
Reset the flag that might be used later to mark if the Element should not be listed
*
in the display.
*/
bolToBeExcluded =
false
;
/*
de:
*
Neue leere Zeichenkette
'konstruieren' für einen, der in die Liste für die Anzeige
*
aufgenommen wird.
*
en:
*
'Construct'
a new empty String for the value to be added to the list for display. */
strListValue
=
""
;
/*
de:
*
Einen Vector aus dem Roh-Daten-Vector extrahieren. Dieser extrahierte Vector enthält
*
alle Werte für einen Datensatz (Business-Object / BO).
*
en:
*
Extract
one vector containing all values of a data-set (Business Object / BO).
*/
vecRawDisplayDataElement
= (Vector)
parmRawDisplayData.elementAt(intRawDisplayDataIndex);
/*
de:
*
Das Array mit den Anweisungen für die Anordnung der Spalten untersuchen
.
*
en:
*
Cycle
through the strings of the array ArrangementDirections.
*/
for
(intArrangementDirectionsIndex = 0;
intArrangementDirectionsIndex
<
intArrangementDirectionsSize;
intArrangementDirectionsIndex++)
{
/*
de:
*
Einen symbolischen Spalten-Namen oder Zwsichen-Text aus
den ArrangementDirections
*
extrahieren.
*
en:
*
Extract
the symbolic column-name or delimiter string out of the ArrangementDirections.
*/
strColumnNameInArrangementDirections
=
parmArrangementDirections[intArrangementDirectionsIndex];
/*
de:
*
Index für die Spalte im Roh-Daten-Vector auf -1 setzen als Zeichen für 'nicht gefunden'.
*
Dieser Wert wird ersetzt wenn ein passender Spalten-Name im Roh-Daten-Vector gefunden wird.
*
en:
*
Set
the Index of the column in the raw-data-vector to -1 as signal for 'not
found'.
* This value is replaced if a matching
column-name is found in the raw-data-vector.
*/
intColumnFoundIndex
= -1;
/*
de:
*
Den Vector mit den symbolischen Spalten-Name (Element 0 im Roh-Daten-Vector) untersuchen
*
um den (symbolischen) Spalten-Namen zu finden der zum untersuchten Spalten-Namen
*
aus den ArrangementDirections zu finden.
*
en:
*
Cycle
through the vector with the symbolic column-names (element 0 in the
raw-data-vector)
* to find a column-name matching the
column-name in the ArrangementDirections. */
for
(intRawDisplayDataHeaderIndex = 0;
intRawDisplayDataHeaderIndex
<
intRawDisplayDataHeaderSize;
intRawDisplayDataHeaderIndex++)
{
/*
de:
*
Spalten-Namen
für den spezifizierten Index aus dem Vector holen.
*
en:
*
Get
the column-name for the specified index out of the Vector.
*/
strColumnNameInRawDisplayDataHeader
=
(String)
vecRawDisplayDataHeader.elementAt(intRawDisplayDataHeaderIndex);
strColumnNameInRawDisplayDataHeader
= strColumnNameInRawDisplayDataHeader.trim();
/*
de:
*
Vergleichen ob der symbolischen Spalten-Name (aus dem Roh-Daten-Vector) gleich ist
* wie der bearbeitete Name aus dem Array ArrangementDirections
.
*
en:
*
Compare
if the found column-name (from the raw-data-vector) is the same
as
* the name out of the array ArrangementDirections.
*/
if
(strColumnNameInRawDisplayDataHeader.compareTo(
strColumnNameInArrangementDirections.trim())
== 0) {
/*
de:
*
Den gefundenen Index
für die Spalte für spätere Verarbeitung aufheben und die
*
for-Schleife beenden.
*
en:
*
Save
the found index of the column for processing after the loop and end the
for-loop. */
intColumnFoundIndex
=
intRawDisplayDataHeaderIndex;
break
;
}
}
/*
de:
*
Sicherstellen dass der Vector mit den Daten-Werten mindestens so viele Elemente enthält
*
wie erwartet um einen Laufzeit-Fehler zu verhindern.
*
en:
*
Verify
if the vector with the data-values contains as many elements as expected
* to
avoid a run-time-exception. */
intRawDisplayDataElementSize
= vecRawDisplayDataElement.size();
if
((intColumnFoundIndex >= 0)
&&
(intRawDisplayDataElementSize >= intColumnFoundIndex)) {
/*
de:
* Prüfen welche Klasse der Wert im Vector-Element hat und wenn es ein numerischer Wert ist
* dann in eine formatierte Zeichenkette konvertieren
.
*
en:
*
Verify which class the value in the vector-element is of. If it is a numeric value then
* convert it into a string.
*/
if
(vecRawDisplayDataElement.elementAt(intColumnFoundIndex)
instanceof
String) {
strDisplayDataValue
=
(String)
vecRawDisplayDataElement.elementAt(intColumnFoundIndex);
}
else
{
if
(vecRawDisplayDataElement.elementAt(intColumnFoundIndex)
instanceof
Integer) {
strDisplayDataValue
=
JSBS_Formatter.toFormattedString((Integer)
vecRawDisplayDataElement.elementAt(intColumnFoundIndex));
}
else
{
if
(vecRawDisplayDataElement.elementAt(intColumnFoundIndex)
instanceof
Short) {
strDisplayDataValue
=
JSBS_Formatter.toFormattedString((Short)
vecRawDisplayDataElement.elementAt(intColumnFoundIndex));
}
else
{
if
(vecRawDisplayDataElement.elementAt(intColumnFoundIndex)
instanceof
BigDecimal) {
/*
de:
*
Verlegenheitslösung für das Formatieren eines Dezimalwertes
.
* Weil kein Zugriff auf das StartFrame zur Verfügung steht wird der Dezimalpunkt verwendet und
*
3 Nachnkommastellen festgelegt.
*
en:
*
Stopgap to format a decimal value.
* As an access to the StartFrame is not possible the stop is used as decimal separator and
* 3 digits after the decimal point are defined
. */
strDisplayDataValue
=
JSBS_Formatter.toFormattedString((BigDecimal)
vecRawDisplayDataElement.elementAt(intColumnFoundIndex), '.', 3);
}
else
{
/*
de:
*
Für andere Klassen wird die inkludierte Methode zum Umwandeln in eine Zeichenkette benutzt
.
*
en:
*
For other classes the included method for a conversion into a string is used
. */
strDisplayDataValue
=
((Object)
((Object)
vecRawDisplayDataElement.elementAt(intColumnFoundIndex))).toString();
}
}
}
}
/*
de:
*
Wenn der (Daten-)Wert der erste Teil der Zeichenkette für die Zeile, die angezeigt
* werden soll, ist dann wird geprüft ob dieser Wert im Vector mit den Werten, die nicht
* angezeigt werden sollen, ist
.
*
en:
*
If the (data-)value is the first part of the String for a line do be displayed,
* then check if this value is in the
Exclusion-List. */
if
(intArrangementDirectionsIndex == 0) {
bolToBeExcluded
= isStringWithinList(parmExclusionValues, strDisplayDataValue);
}
/*
de:
* Wenn der Wert exkludiert werden soll dann wird der Aufbau der Zeichenkette für die
* anzuzeigende Zeile jetzt abgebrochen
.
*
en:
*
If the value should be excluded then terminate the building of the
String for the line
*
to be displayed. */
if
(bolToBeExcluded)
break
;
/*
de:
Wert zu der Zeile die angezeigt werden soll hinzufügen
.
*
en:
Add the value to the line to be displayed.
*/
strListValue
+= strDisplayDataValue;
}
else
{
/*
de:
* Der Wert in den ArrangementDirections ist kein symbolischer Spalten-Name
* Es ist ein 'fixer' Text der in die anzuzeigende Zeile eingefügt wird
.
*
en:
* Value in the ArrangementDirections is not a symbolic column-name.
*
It is fixed text that is inserted into the line to be displayed.
*/
strListValue
+= parmArrangementDirections[intArrangementDirectionsIndex];
}
}
/*
de:
* Die Zeichenkette mit der Text-Zeile, die angezeigt werden soll in den dafür
* vorgesehenen Vector einfügen.
*
Das Einfügen erfolgt nur, wenn dieser Wert nicht von der Anzeige exkludiert wird.
*
en:
*
Add
the string with the text-line to be displayed to the designated vector.
*
This is only done if the line should not be excluded. */
if
(! bolToBeExcluded) vecListValues.addElement(strListValue);
}
return
vecListValues
;
}
/*
* --------------------
* de:
* METHODE zum Verändern von Vordergrund- und Hintergrund-Farbe.
*
Damit kann ein Eingabefeld auffällig markiert werden.
* en:
* METHOD
to change foreground- and background-color to catch attention for the field. */
public
static void
reverseColors(Component parmComponent) {
/* de: Prüfen auf 'leeren' Parameter um einen späteren Dump zu vermeiden.
* en:
Check
for 'empty' parameter to avoid a dump. */
if
(parmComponent
==
null
)
return
;
/*
de:
*
Auslesen der bestehenden Farben fürden Hintergrund.
* Diese Farbe ist Basis für die neuen Farben für Vordergrund und Hintergrund.
* en:
*
Get the existing colors for foreground and background.
* This color is base for the new colors for foreground and background
. */
Color clrForeground = parmComponent.getBackground();
Color clrBackground = parmComponent.getBackground();
/*
de: Invertierte Farbe für den neuen Hintergrund ermitteln.
* en:
Calculate the inverted color for the new background. */
int
intNewRed
= 255 - clrBackground.getRed();
int
intNewGreen
= 255 - clrBackground.getGreen();
int
intNewBlue
= 255 - clrBackground.getBlue();
/*
de: Neue Hintergrundfarbe aus den invertierten Werten der Einzelfarben bauen.
* en:
Build new background-color from the inverted singular color values.
*/
clrBackground =
new
Color(intNewRed, intNewGreen, intNewBlue);
parmComponent.setBackground(
clrBackground
);
/*
de: Originale Hintergrundfarbe wird die neue Vordergrundfarbe.
* en:
Original background color becomes new foreground color.
*/
parmComponent.setForeground(
clrForeground
);
}
/*
* --------------------
* de:
* METHODE zum Wieder-Herstellen der für die GUI-Komponente festgelegten Vordergrundfarbe.
*
Damit kann das normale Erscheinen eines Eingabefeldes, das z.B. durch die
*
Methode 'reverseColors(...)' auffällig markiert wurde, wieder hergestellt werden.
* en:
* METHOD
to re-establish the forground color defined for the GUI-Component.
*
This allows to restore the usual appearance of an entry-field which might have been
*
marked as eyecatcher - e.g. with the method 'reverseColors(...)'. */
public
static void
setDefinedForegroundColor(Container parmContainer, JSBS_TaskFrame parmTF) {
/* de: Prüfen auf 'leere' Parameter um einen späteren Dump zu vermeiden.
* en:
Check
for 'empty' parameters to avoid a dump. */
if
(parmContainer
==
null
)
return
;
if
(parmTF
==
null
)
return
;
/*
de:
*
Ermitteln des Namens der Klasse für das Task-Frame. Notwendig zum Auslesen der festgelegten Farbe
.
* en:
*
Get the name of the class for the task-frame. Neccessary to read the defined
. */
String strFrameClassName = parmTF.getClass().getName();
/*
de: Aufrufen der Methode zum Wiederherstellen von Standard-Farbe, -Font und -Schriftgrösse.
* en:
Call the method to re-establish default-color, -font and -size. */
processLanguageDependantElements(strFrameClassName, parmTF.
frmCC
, parmContainer);
}
/*
* --------------------
* de:
* METHODE zum 'Diable' eines GUI-Elements.
*
Diese eigene Methode ist notwendig, um folgende Nachteile der Standard-Methode 'setEnabled(false)'
*
für GUI-Elemente zu vermeiden:
* * Bei einer JComboBox ist das Verhältnis zwischen Vordergrund- und Hintergrundfarbe so schwach
* dass die Schrift nicht mehr erkennbar ist.
* * Bei einem JTextField oder einer JTextArea kann im 'Disabled' Status der Text nicht mehr
* selektiert und damit auch nicht mehr kopiert werden.
* Die Massnahmen zur Vermeidung dieser Schwächen ist innerhalb des folgenden Codes kommentiert.
* Zusätzlich ist es auch notwendig, einzelne Eigenschaften des GUI-Elements aufzuheben damit diese
* Eigenschaften bei einem 'Enable' wieder zuordnen zu können - auch das ist im Detail innerhalb des
* Codes kommentiert.
* en:
* METHOD
to 'Disable' a GUI-Element.
*
This individual method is neccessary to avoid the following disadvantages of the standard-method
* 'setEnabled(fälse)':
* * With a JComboBox, the relation between foreground- and backgroundcolor is so week that it is
* difficult to read the text.
* *
With a JTextField or a JTextArea, the text an not be marked in 'disabled' status - an therfore it is
* impossible to copy the text.
* The techniques to avoid this disadvantages is described within the following code.
* In addition, it is neccessary to 'store' individual properties of the GUI-Element to be able to
* assign these properties again when the GUI-Element is 'enabled - this is also described in detail
*
within the following code. */
public
static void
processDisableGUIElement(
JSBS_TaskFrame parmTF,
Component parmGUIElement) {
/* de: Prüfen auf 'leere' Parameter um einen späteren Dump zu vermeiden.
* en:
Check
for 'empty' parameters to avoid a dump. */
if
(parmTF
==
null
)
return
;
if
(parmGUIElement
==
null
)
return
;
/*
de:
*
Folgende Variable dienen zum Aufheben der Eigenschaften, die das GUI-Element hat bevor es
*
'disabled' wird
.
* en:
*
The following variables will keep the properties of the GUI-Element before it will be 'disabled'
. */
Boolean bolEditableFlag =
new
Boolean(
false
);
Color colOriginalBackground =
parmGUIElement.getBackground()
;
Color colDisabledBackground =
getDisabledColor(colOriginalBackground)
;
/*
de: Setzen des geänderten Hintergrundes als Hinweis, dass dieses GUI-Element 'disabled' ist.
* en:
Set the changed background to indicate that this GUI-Element is 'disabled'. */
parmGUIElement.setBackground(colDisabledBackground)
;
/*
*
de:
*
Unterscheiden der verschiedenen Arten der GUI-Elemente und darauf abgestimmte spezielle Bearbeitung.
* en:
*
Differentiate the kinds of GUI-Elements and adapted processing. */
if
(parmGUIElement
instanceof
JComboBox) {
/*
de:
*
Abfragen und Aufheben ob die JComboBox 'Editable' ist. Der Status 'Editable' muss bei 'disabled'
*
gesetzt werden damit die Schrift gut lesbar ist - aber fragen Sie bitte nicht warum das so sein muss
.
* en:
*
Determine and save if the JComboBox is 'Editable'. The status 'Editable' has to be set to get an easily
*
readable text when it is 'disabled' - and do not ask why this is so, please. */
bolEditableFlag =
new
Boolean(((JComboBox) parmGUIElement).isEditable());
/*
de:
* 'Herausholen' der Komponente mit dem Text aus der gesamten JComboBox und setzen des Hintergrundes
*
für den Hinweis auf 'disabled'
.
* en:
*
Get the component with the text out of the whole JComboBox and set the background to indicate
*
'disabled'. */
((JTextField) ((JComboBox) parmGUIElement).getEditor().getEditorComponent()).setBackground(colDisabledBackground)
;
/*
de:
* 'Herausholen' der Komponente mit dem Text aus der gesamten JComboBox und setzen des Vordergrundes bei
*
'disabled' auf die gleiche Farbe wie bei 'enabled'
.
* Das ist notwendig weil sonst bei 'disabled' die Textfarbe stark grau-getönt wird und dann schwer lesbar ist.
* en:
*
Get the component with the text out of the whole JComboBox and set the foreground for 'disabled' to the same
*
color as when 'enabled'.
* This is neccessary as otherwise the color for the text ist moved heavily towards grey when 'disabled'
* which makes it very difficult to read the text.
*/
((JTextField) ((JComboBox) parmGUIElement).getEditor().getEditorComponent()).setDisabledTextColor(
((JComboBox) parmGUIElement).getForeground()
)
;
/*
de:
Setzen der JComboBox auf 'disabled'
.
* en:
Set the JComboBox to 'disabled'
. */
parmGUIElement.setEnabled(
false
);
/*
de:
*
Setzen der JComboBox auf 'editable'; erst dann werden die zuvor gesetzten Farben für Text und Hintergrund wirksam
.
* en:
*
Set the JComboBox to 'editable'; only this activates the colors for text and background defined before
. */
((JComboBox) parmGUIElement).setEditable(
true
);
}
/* *****
*/
if
(parmGUIElement
instanceof
JTextField) {
/*
de:
*
Für ein JTextField muss das Feld 'enabled' sein damit der Text im Feld markiert - und damit kopiert -
*
werden kann. Damit eine Eingabe verhindert wird, wird das Feld auf nicht 'editable' gesetzt.
* en:
*
A JTextField must be 'enabled' to be able to mark the Text within the field - and have the option
*
to copy the text. To prevent a change of the text the field is set to not 'editable'. */
((JTextField) parmGUIElement).setEditable(
false
)
;
parmGUIElement.setEnabled(
true
)
;
}
/* *****
*/
if
(parmGUIElement
instanceof
JTextArea) {
/*
de: Gleiche Verarbeitung wie bei einem JTextField
.
* en: Same processing as for a JTextField
. */
((JTextArea) parmGUIElement).setEditable(
false
)
;
parmGUIElement.setEnabled(
true
)
;
}
/*
de:
*
Wenn noch kein Eintrag in den Vector mit den 'disabled' GUI-Elementen existiert dann die
* Java-Klasse des GUI-Elements eintragen.
* Die Prüfung erfolgt zur Sicherheit und vermeidet mehrfache Einträge wenn diese Methode
* (zum 'disable') mehr als einmal aufgerufen wird
.
* en:
*
If there is no entry within the vector with the 'disabled' GUI-Elements, then insert the
* Java-class of the GUI-element.
* The validation is to make sure to avoid multiple entries
if this method (to 'disable')
* is called more than once
. */
if
(getDisabledGUIElementIndex(parmTF, parmGUIElement) < 0)
insertDisabledGUIElementIntoVector(parmTF,
parmGUIElement, bolEditableFlag, colOriginalBackground
)
;
}
/*
* --------------------
* de:
* METHODE zum 'Enable' eines zuvor mit der Methode processDisableGUIElement(...) bearbeiteten GUI-Elements.
*
Diese eigene Methode ist notwendig, um bei einem GUI-Element die vor dem 'Disable' gestzten
*
Eigenschaften wieder herzustellen und das Feld für die Eingabe bzw. die ComboBox für die Auswahl zu 'öffnen'.
* en:
* METHOD
to 'Enable' a GUI-Element which was processed before with the method process DisableGUIElement(...).
*
This individual method is neccessary restore the properties owned before the 'disable' and to open the field for
* entry of text or the combobox for selection, respectively
. */
public
static void
processEnableGUIElement(
JSBS_TaskFrame parmTF,
Component parmGUIElement) {
/* de: Prüfen auf 'leere' Parameter um einen späteren Dump zu vermeiden.
* en:
Check
for 'empty' parameters to avoid a dump. */
if
(parmTF
==
null
)
return
;
if
(parmGUIElement
==
null
)
return
;
/*
de: Generelles Setzen von 'enabled', egal welche Java-Klasse das GUI-Element hat.
* en: Generally set to 'enabled' - no matter which Java-Class the GUI-element is of
. */
parmGUIElement.setEnabled(
true
)
;
/*
de: Ermitteln ob die Eigenschaften vor dem 'disable' gespeichert wurden.
* en: Verify if properties were saved before 'disable'
. */
int
intIndex = getDisabledGUIElementIndex(parmTF, parmGUIElement)
;
/*
*
de:
*
Unterscheiden der verschiedenen Arten der GUI-Elemente und darauf abgestimmte spezielle Bearbeitung.
* en:
*
Differentiate the kinds of GUI-Elements and adapted processing. */
if
(parmGUIElement
instanceof
JComboBox) {
/*
de:
Prüfen, ob gespeicherte Werte vor dem 'disable' gefunden wurden
.
* en: Verify if stored values before the 'disable' were found
. */
if
(intIndex >= 0
) {
/*
de:
Auslesen des Eintrags für das GUI-Element
.
* en: Read the record for the GUI-Element
. */
Vector vecDisabledGUIElement =
(Vector) parmTF.vecDisabledGUIElements.elementAt(intIndex)
;
/*
de:
* Sicherheitsprüfung ob auch ein Eintrag für 'Editable' vorhanden ist und dann die
Eigenschaft
* der JComboBox auf den Wert vor dem 'Disable' setzen
.
* en:
*
Security-check if an entry for 'Editable' exists and then set the property of the JComboBox
* to the value before the
'disable'. */
if
(vecDisabledGUIElement.size() > 1
) {
boolean
bolEditableFlag =
((Boolean) vecDisabledGUIElement.elementAt(1)).booleanValue()
;
((JComboBox) parmGUIElement).setEditable(bolEditableFlag)
;
}
/*
de:
* Sicherheitsprüfung ob auch ein Eintrag für die Hintergrundfarbe existiert und dann den
* Hintergrund der JComboBox auf den Wert vor dem 'Disable' setzen
.
* en:
*
Security-check if an entry for the background-color exists and set the background of the
* JComboBox to the color before the
'disable'. */
if
(vecDisabledGUIElement.size() > 2
) {
((JTextField) ((JComboBox) parmGUIElement).getEditor().getEditorComponent()).setBackground(
((Color) vecDisabledGUIElement.elementAt(2)
))
;
}
}
}
/*
de:
* Für die GUI-Elemente anderer Java-Klassen wird die Hintergrundfarbe vor dem 'disable' wieder hergestellt
.
* en:
*
For GUI-Elements of other Java-classes the background-color is reestablished
.
*/
else
{
/*
de:
Prüfen, ob gespeicherte Werte vor dem 'disable' gefunden wurden
.
* en: Verify if stored values before the 'disable' were found
. */
if
(intIndex >= 0
) {
/*
de:
Auslesen des Eintrags für das GUI-Element
.
* en: Read the record for the GUI-Element
. */
Vector vecDisabledGUIElement =
(Vector) parmTF.vecDisabledGUIElements.elementAt(intIndex)
;
/*
de:
* Sicherheitsprüfung ob auch ein Eintrag für die Hintergrundfarbe existiert und dann den
* Hintergrund der JComboBox auf den Wert vor dem 'Disable' setzen
.
* en:
*
Security-check if an entry for the background-color exists and set the background of the
* JComboBox to the color before the
'disable'. */
if
(vecDisabledGUIElement.size() > 2
)
parmGUIElement.setBackground(
(Color) vecDisabledGUIElement.elementAt(2)
)
;
}
}
/*
de:
*
Spezieller Code für JTextField und JTextArea weil diese wieder auf 'Editable' gesetzt
* werden müssen und diese Methode nicht in der Klasse 'Component' vorhanden ist
.
* en:
*
Special code for JTextField and JTextArea because these have to be set to 'Editable' again
* and this method is not available within the class 'Component'
. */
if
(parmGUIElement
instanceof
JTextField) {
((JTextField) parmGUIElement).setEditable(
true
)
;
}
/* *****
*/
if
(parmGUIElement
instanceof
JTextArea) {
((JTextArea) parmGUIElement).setEditable
(
true
)
;
}
/*
de:
* Eingabe im Feld wieder ermöglichen,
*
Vordergrund wieder auf die definierte Farbe setzen (wird zur Sicherheit ausgeführt)
* und den Eintrag, dass das GUI-Element 'disabled' ist aus dem zuständigen Vector entfernen
.
* en:
* Enable entry for the field again,
*
security-check if an entry for the background-color exists and set the background of the
* JComboBox to the color before the
'disable'. */
parmGUIElement.setEnabled(
true
)
;
setDefinedForegroundColor((Container) parmGUIElement, parmTF);
removeDisabledGUIElementFromVector(
parmTF
, parmGUIElement);
}
/*
* --------------------
* de:
* METHODE zum Ermitteln des Index, mit dem die gespeicherten Eigenschaften vor dem 'disable'
* des GUI-Elements
gespeichert sind.
*
Über diesen Index können die Eigenschaften aus dem Vector ausgelesen werden.
* en:
* METHOD
to get the index that points to the properties saved before the 'disable' of the GUI-Element.
* With this index the properties can be read out of the vector
. */
public
static int
getDisabledGUIElementIndex(
JSBS_TaskFrame parmTF,
Component parmGUIElement) {
/* de: Prüfen auf 'leere' Parameter um einen späteren Dump zu vermeiden.
* en:
Check
for 'empty' parameters to avoid a dump. */
if
(parmTF
==
null
)
return
-1
;
if
(parmGUIElement
==
null
)
return
-1
;
/*
de: Anzahl der Elemente im Vector und Index zum Auslesen der einzelnen Elemente im Vector.
* en: Number of elements within the vector and index to read one element of the vector
. */
int
intVectorSize = parmTF.
vecDisabledGUIElements
.size()
;
int
intVectorIndex
;
/*
de: Einzelnes Vector-Element: wieder ein Vector mit den Eigenschaften des GUI-Elements.
* en: Singular vector-element: again a vector with the properties of the GUI-element
. */
Vector vecDisabledGUIElement
;
/*
de: Object des GUI-Elements innerhalb des Vectors - zum Vergleichen mit dem Parameter-Wert.
* en: Object of the GUI-element within the vector - to be compared with the parameter-value
. */
Object objGUIElement
;
/*
*
de:
In einer for-Schleife die einzelnen Elemente des Vectors auslesen.
* en: Read the single elements of the vector within a for-loop
. */
for
(intVectorIndex = 0; intVectorIndex < intVectorSize; intVectorIndex++
) {
/*
de: Auslesen des Vectors mit der Struktur für ein GUI-Element
.
* en: Extract the vector with the structure for one GUI-Element
. */
vecDisabledGUIElement =
(Vector) parmTF.vecDisabledGUIElements.elementAt(intVectorIndex)
;
/*
de:
Sicherheitsprüfung ob auch ein Eintrag mit dem GUI-Element vorhanden ist
.
* en:
Security-check if an entry with the GUI-element exists
. */
if
(vecDisabledGUIElement.size() > 0
) {
/*
de:
Auslesen des Objektes mit dem GUI-Element
.
* en:
Extract the object with the GUI-element
. */
objGUIElement =
vecDisabledGUIElement.elementAt(0)
;
/*
de:
*
Vergleichen des
Objektes mit dem GUI-Element
aus dem Vector mit dem als Parameter übergebenen Wert.
* Bei Übereinstimmung wird der Wert des Indexes an die aufrufende Methode zurück geliefert.
* en:
*
Compare the object with the GUI-element from the vector
with the value passed as parameter.
* Return the value of the index to the calling method if matching
. */
if
(objGUIElement.equals(parmGUIElement))
return
intVectorIndex
;
}
}
/*
de:
* Wenn im Vector kein GUI-Element, dass zum Parameter-Wert passt, dann mit dem Rückgabewert -1
* an die aufrufende Methode signalisieren
.
* en:
* if the vector contains no GUI-Element that matches the parameter-value, then use the
return-value -1
* to signal this to the calling method
.
*/
return
-1;
}
/*
* --------------------
* de:
* METHODE zum Einfügen der Eigenschaften eines GUI-Elements in den dafür vorgesehenen Vector
.
* en:
* METHOD
to insert the properties of a GUI-Element into the vector designated for that
. */
public
static void
insertDisabledGUIElementIntoVector(
JSBS_TaskFrame parmTF,
Component parmGUIElement,
Boolean parmComboBoxEditable, Color parmOriginalBackgroundColor
) {
/* de: Prüfen auf 'leere' Parameter um einen späteren Dump zu vermeiden.
* en:
Check
for 'empty' parameters to avoid a dump. */
if
(parmTF
==
null
)
return
;
if
(parmGUIElement
==
null
)
return
;
if
(parmComboBoxEditable
==
null
)
parmComboBoxEditable
=
new
Boolean(
false
);
if
(
parmOriginalBackgroundColor
==
null
)
parmOriginalBackgroundColor
=
Color.WHITE;
/*
de:
*
Prüfen ob bereits ein Eintrag für das GUI-Element im Vector vorhanden ist.
* Das verhindert mehrfache Einträge wenn ein GUI-Element versehentlich mehr als einmal
* 'disabled' wird.
* en:
*
Verify if an entry for the GUI-element already exists within the vector.
* This avoids multiple entries if a GUI-Element is
'disabled' more than once erratically. */
if
(getDisabledGUIElementIndex(parmTF, parmGUIElement) >= 0)
return
;
/*
de: Vector für die Eigenschaften eines GUI-Elements konstruieren.
* en: Construct the vector for the properties of one GUI-element
. */
Vector vecDisabledGUIElement
=
new
Vector();
/*
de: In den Parametern übergebene Eigenschaften des GUI-Elementes in den Vector einfügen.
* en: Properties of the GUI-element (passed as parameters) are inserted into the vector
. */
vecDisabledGUIElement.addElement(parm
GUIElement)
;
vecDisabledGUIElement.addElement(
parmComboBoxEditable
)
;
vecDisabledGUIElement.addElement(
parmOriginalBackgroundColor
)
;
/*
de:
*
Gerade erstellen Vector mit den Eigenschaften eines GUI-Elementes in den Vector mit allen
* GUI-Elementen, die 'disabled' sind, einfügen.
* Dieser Vector ist in der Klasse für das Task-Frame (wurde als Parameter übergeben) definiert
.
* en:
* Just constructed vector with the properties of one GUI-element will be inserted into the
* vector with all GUI-elements that are marked as 'disabled'.
* This vector is defined in the class for the Task-Frame; that is passed as a parameter
. */
parmTF.vecDisabledGUIElements
.addElement(
vecDisabledGUIElement
)
;
}
/*
* --------------------
* de:
* METHODE zum Entfernen der Eigenschaften eines GUI-Elements aus dem dafür vorgesehenen Vector
.
* en:
* METHOD
to remove the properties of a GUI-Element from the vector designated for that
. */
public
static void
removeDisabledGUIElementFromVector(
JSBS_TaskFrame parmTF,
Component parmGUIElement
) {
/*
de:
Ermitteln des Index für den Eintrag mit den Eigenschaften des GUI-Elements
.
* en: Get the index of the entry with the properties of the GUI-element
. */
int
intIndex = getDisabledGUIElementIndex(parmTF, parmGUIElement)
;
/*
de: Prüfen ob überhaupt ein Eintrag vorhanden ist.
* en: Check if an entry exists
. */
if
(intIndex >= 0)
return
;
/*
de: Entfernen des Einzelvectors mit den Eigenschaften des GUI-Elements.
* en: Remove the singular vector with the properties of the GUI-element
. */
parmTF.vecDisabledGUIElements
.removeElement(intIndex
)
;
}
/*
* --------------------
* de:
* METHODE zum Ermitteln einer neuen Grundfarbe für ein GUI-Element das als 'disabled'
* markiert werden soll.
* Zuerst wird die Helligkeit jeder einzelnen Farb-Komponente ermittelt.
*
Bei einer hellen Farbe wird die Farbe etwas verdunkelt und
umgekehrt
.
* en:
* METHOD
to get a new color for a GUI-Element that should be marked as disabled.
* First the bri
ghtness of each color-component is determined.
* A bright color is darkened a little bit and vice-versa
. */
public
static
Color getDisabledColor(
Color parmEnabledColor
) {
/*
de: Wert zum Aufhellen oder Verdunkeln der Farb-Komponente
.
* en: Value to brighten or darken the color-component
. */
final int
intAbsoluteChangeValue = 10
;
/* de: Prüfen auf 'leeren' Parameter um einen späteren Dump zu vermeiden.
* en:
Check
for 'empty' parameters to avoid a dump. */
if
(
parmEnabledColor
==
null
)
parmEnabledColor
=
Color.WHITE;
/*
de: Ermitteln der einzelnen Farb-Komponenten.
* en: Get the singular color-components
. */
int
intRed = parmEnabledColor.getRed()
;
int
intGreen = parmEnabledColor.getGreen()
;
int
intBlue = parmEnabledColor.getBlue()
;
/*
de:
Ändern jeder Farb-Komponente.
* en: Change each color-component
. */
if
(intRed > 127) intRed = intRed - intAbsoluteChangeValue
;
else
intRed = intRed + intAbsoluteChangeValue
;
if
(intGreen > 127)
intGreen
=
intGreen
- intAbsoluteChangeValue
;
else
intGreen
=
intGreen
+ intAbsoluteChangeValue
;
if
(intBlue > 127)
intBlue
=
intBlue
- intAbsoluteChangeValue
;
else
intBlue
=
intBlue
+ intAbsoluteChangeValue
;
/*
de: Bilden der neuen Farbe und an die aufrufende Methode zurück liefern.
* en: Build the new color and return it to the calling method
. */
return new
Color(intRed, intGreen
, intBlue
)
;
}
}
xxx
Dokument |
Inhalt |
|