|
Letzte
Bearbeitung dieses Dokuments: |
Code
Erklärungen
und Anwendungsbeispiele
Verwandte
Dokumentation
package
js_base.frame;
import java.awt.*;
import java.awt.event.*;
import
java.net.*;
import
java.text.*;
import
java.util.*;
import javax.swing.*;
import js_base.bo.JSBS_BO;
import
js_base.boc.JSBS_FramePosition_BOC;
import
js_base.xml.JSBS_XML_ErrorMessages;
/**
*
* @author kurt[at]javascout(dot)biz
* @date
2008-08-047
*
* @description
* de: *
Frame zum Anzeigen von (für den Anwender) unerwarteten
Ereignissen (Fehler oder
* Warnungen) und
zum Schreiben des zugehörigen (Location-)Codes in eine
Log-Datei.
*
* Diese Klasse kann
'konstruiert' werden wenn der Entwickler des Anwendungsprogramms
*
entscheidet, dass der Status den das Anwendungsprogramm erreicht hat,
in die Log-Datei
* geschrieben werden soll und/oder
der Anwender informiert werden muß.
*
*
Der Text zur Anzeige der Information wird aus der XML-Struktur in der
Datei
* 'ErrorMessages.xml' (im Verzeichnis TEXT.ln -
wobei ln durch den ISO-code der Sprache
* ersetzt
wird) gelesen.
*
* Diese XML-Struktur
enthält auch die Information, ob das unerwartete Ereignis zum
* Ende des Anwendungsprogramms führt (Dump), der
Anwender einen Warn-Hinweis bekommt
* (und das
Anwendungsprogramm nach einer Bestätigung durch den Anwender
fortgesetzt wird)
* oder das Ereignis nur in die
Log-Datei eingetragen wird.
* en: *
Frame to show unexpected events (Error or Warning) and to write the
Event with the
* associated (location-)code to a
Log-File.
*
* This class can be
constructed when the developer of the application decides,
*
that the state of processing needs to be logged and/or the user has
to be informed.
*
* The informative text is
held in a XML-structure in the file named 'ErrorMessages.xml'
*
in the directory TEXT.ln (where ln is replaced by the ISO-code of the
language).
*
* This XML-structure also holds
the information if this Event will lead to a dump
*
(termination of the application), a warning (user-confirmation
requiered) or
* is only logged.
*
*
@change-log
* when who why
*
--------------------------------------------------------
*
*/public
class
JSBS_ErrorDialog
extends
JDialog
implements
ActionListener, KeyListener, WindowListener {
/*
*
de: *
Referenz auf das 'Start-Frame', auch als 'CommandCenter' oder 'CC'
bezeichnet.
*
Das 'CC' enthält die generellen Werte des
Anwendungsprogramms.
*
en:
*
Reference to the 'Start-Frame', also referred as 'Command-Center' or
'CC'.
* The 'CC' helds general values of the application.
*/
private
JSBS_StartFrame
frmCC
=
null
;
/*
* de: *
Frame in dem das Ereignis ausgelöst wurde und welches gesperrt
ist
*
solange dieser Dialog angezeigt wird.
*
en:
*
Frame where the Error- or Warning-Event was triggered and which is
locked
* as long as this Dialog is shown.
*/
private
JFrame
frmParent
=
null
;
/*
*
de: XML-Struktur mit den Fehler- und Warn-Hinweisen. *
en: XML-structure with Error- and Warning-Messages. */
JSBS_XML_ErrorMessages structJSBS_XML_ErrorMessages;
/*
*
de: Variable die beim Aufrufen des 'Constructors' übergeben
wurden. *
en: Variables that are passed with the call of the constructor.
*/
private
String
str_OriginClass
=
""
;
private
String
str_OriginCode
=
""
;
private
String
str_Parameter1
=
""
;
private
String
str_Parameter2
=
""
;
private
String
str_Parameter3
=
""
;
private
String
str_Parameter4
=
""
;
private
String
str_Parameter5
=
""
;
/*
*
de: Werte aus der Datei mit der XML-Struktur. *
en: Values derived from the file with the XML-structure.
*/
public
static
String
CONST_PROCESS_DUMP
=
"S"
;
public
String
strProcessIndicator
=
"D"
;
private
String
strUnexpectedEventText
=
""
;
private
String
strIndividualMessageText
=
""
;
private
String
strLogFileName
=
""
;
/*
*
de: Name der Datei mit dem Graphischen Symbol für die
Schaltfläche 'btn_WarningIcon'. *
en: Name of the file with the Icon for the Button 'btn_WarningIcon'.
*/
private
String
strIconFileNameIncludingDirectory
=
""
;
/*
*
de:
* Text der in der 'Title-Bar' des aufrufenden Frames
angezeigt wird.
* Als Teil der Information angezeigt, die
dem Anwender Hinweise gibt, welches Frame
* betroffen ist
wenn er das gesamte Anwendungsprogramm beendet und damit die noch
*
offenen Task-Frames automatisch geschlossen werden. *
en:
* Text of the 'Title-Bar' of the calling Frame.
*
Shown as part of the Information to give the user guidance, which
frame ist concerned
* when he closes the whole application
and thereby open task-frames automatically. */
private
String
strCallingFrameTitleBarText
=
""
;
/*
*
de:
* Schaltfläche die 'angeklickt' wird wenn die
Eingabe-Taste auf der Tastatur
* betätigt wird.
*
Diese Variable kann dynamisch durch das Anwendungsprogramm mit einem
Wert versorgt
* werden und damit kann dem Anwender
signalisiert werden welche Schaltfläche als
* nächstes
empfohlen wird.
* en:
* Button that is 'clicked'
when the Enter-Key on the keyboard is pressed.
* This
variable can be dynamically filled by the application to guide the
user
* what button is recommended to be used next.
*/
private
JButton
btnEnterTriggeredButton
=
null
;
/*
*
de:
* Flags (Merker) zum merken ob 'Modifier'-Tasten (Alt,
Steuerung, Umschalten)
* betätigt wurden,
*
Diese Merker werden gebraucht weil Tasten-Kombinationen
'hintereinander' von der
* Tastatur an das
Anwendungsprogramm 'geliefert' werden
* en:
* Flags
to keep if 'modifier'-keys were typed.
* Those flags are
necessary as key-combinations are delivered from the keyboard
*
to the application as sequential key-strokes. */
private
boolean
bolAltKeyModifier
=
false
;
private
boolean
bolCtrlKeyModifier
=
false
;
private
boolean
bolShiftKeyModifier
=
false
;
/*
*
de:
* Business-Object, dass die Information über Größe
(Breite, Höhe) und Position
* (Abstand zwischen linker
oberer Ecke des Monitors und linker oberer Ecke des Frames)
*
in Bildpunkten speichert.
* Weiters enthält dieses BO
10 Arrays für die Aufnahme von Spaltenbreiten von JTables.
*
Diese Struktur kann von Task-Frames, die von dieser Basisklasse
erben, verwendet werden.
* en: *
Business-Object that stores the information about the Frame-Size
(width, height)
* and Position (distance between the
upper-left corner of the frame from the
* upper-left corner
of the display-screen) in pixels.
* Further, this BO holds
10 arrays to describe the column-widths of JTables.
* Those
structure can be utilized by Task-Frames inheriting this base-class.
*/
public
JSBS_FramePosition_BOC
structJSBS_FramePosition_BOC
;
/*
*
de: GUI-Elemente für das Layout des Dialogs. *
en: GUI-elements for the layout of the dialog. */
protected
JPanel
pnl_Main
;
protected
JScrollPane
pnl_UnexpectedEventScroll
;
protected
JTextArea
txt_UnexpectedEvent
;
protected
JLabel
lbl_OriginClass
;
protected
JTextField
txt_OriginClass
;
protected
JLabel
lbl_OriginCode
;
protected
JTextField
txt_OriginCode
;
protected
JLabel
lbl_ErrorText
;
protected
JScrollPane
pnl_ErrorTextScroll
;
protected
JTextArea
txt_ErrorText
;
protected
JButton
btn_WarningStopIcon
;
protected
JButton
btn_Print
;
protected
JButton
btn_Continue
;
/*
*
-------------------------------
* de: Constructor wenn diese
Klasse vom Start-Frame (CommandCenter) genutzt wird. *
en: Constructor when the class is used by a Start-Frame
(CommandCenter). */
public
JSBS_ErrorDialog(JSBS_StartFrame
parmCC,
String
parmOriginClass, String
parmOriginCode,
String
parmParameter1, String
parmParameter2,
String
parmParameter3, String
parmParameter4,
String
parmParameter5) {/*
*
de:
* Superklasse verwenden um diesen Dialog an ein Frame zu
binden und den Dialog
* 'modal' zu machen. 'Modal'
bedeutet, dass das Frame für Eingaben des Benutzers
*
'gesperrt' ist solange der Dialog angezeigt wird.
* en: *
Use the superclass to 'attach' this Dialog to a Frame and make it
'modal'.
* 'Modal' means, that the Frame is 'locked' (for
user-entries) while the Dialog
* is shown.
*/
super
(parmCC,
true
);
/*
*
de: Übertragen der als Parameter übergebenen Werte auf die
Variablen dieser Klasse. *
en: Transfer the values passed as parameters to the variables of this
class. */
frmCC
= parmCC;
frmParent
= parmCC;
str_OriginClass
= parmOriginClass;
str_OriginCode
= parmOriginCode;
str_Parameter1
= parmParameter1;
str_Parameter2
= parmParameter2;
str_Parameter3
= parmParameter3;
str_Parameter4
= parmParameter4;
str_Parameter5
= parmParameter5;
/*
*
de: Starten der Verarbeitung des Codes *
en: Start processing of the code.
*/
initialize_before_frame();
initialize_frame();
initialize_after_frame();
}/*
*
-------------------------------
* de: Constructor wenn diese
Klasse von einem Task-Frame genutzt wird. *
en: Constructor when the class is used by a Task-Frame. */
public
JSBS_ErrorDialog(JSBS_TaskFrame
parmParent,
String
parmOriginClass, String
parmOriginCode,
String
parmParameter1, String
parmParameter2,
String
parmParameter3, String
parmParameter4,
String
parmParameter5) {/*
*
de:
* Superklasse verwenden um diesen Dialog an ein Frame zu
binden und den Dialog
* 'modal' zu machen. 'Modal'
bedeutet, dass das Frame für Eingaben des Benutzers
*
'gesperrt' ist solange der Dialog angezeigt wird.
* en: *
Use the superclass to 'attach' this Dialog to a Frame and make it
'modal'.
* 'Modal' means, that the Frame is 'locked' (for
user-entries) while the Dialog
* is shown.
*/
super
(parmParent,
true
);
/*
*
de: Übertragen der als Parameter übergebenen Werte auf die
Variablen dieser Klasse. *
en: Transfer the values passed as parameters to the variables of this
class. */
frmCC
= parmParent.
frmCC
;
frmParent
= parmParent;
str_OriginClass
= parmOriginClass;
str_OriginCode
= parmOriginCode;
str_Parameter1
= parmParameter1;
str_Parameter2
= parmParameter2;
str_Parameter3
= parmParameter3;
str_Parameter4
= parmParameter4;
str_Parameter5
= parmParameter5;
/*
*
de: Starten der Verarbeitung des Codes *
en: Start processing of the code.
*/
initialize_before_frame();
initialize_frame();
initialize_after_frame();
}
/*
*
-------------------------------
* de: Methode mit dem Code
der ausgeführt wird bevor die GUI aufgebaut wird. *
en: Method with code that is executed before the GUI is built.
*/
private
void
initialize_before_frame()
{
/*
*
de: Initialisieren der XML-Struktur mit den Fehler- und
Warn-Hinweisen. *
en: Initialize the XML-structure with Error- and Warning-Messages.
*/
structJSBS_XML_ErrorMessages =
new
JSBS_XML_ErrorMessages(
frmCC
);
/*
*
de: Prüfen ob die XML-Struktur ohne Fehler konstruiert wurde. *
en: Verify if the XML-structure was constructed without an error.
*/
if
(structJSBS_XML_ErrorMessages.
StatusCode
== structJSBS_XML_ErrorMessages.
CONST_OK
)
{
/*
*
de: Information ermitteln wie das Ereignis verarbeitet werden
soll. *
en: Get the information how to process the event.
*/
strProcessIndicator
=
structJSBS_XML_ErrorMessages.getProcessIndicator(str_OriginClass
,
str_OriginCode
);
}
else
{
/*
* de: XML-Struktur konnte nicht geladen werden;
Minimal-Nachricht anzeigen.
* en: XML-structure could not
be loaded; show minimum-message. */
strProcessIndicator
=
"D"
;
strIndividualMessageText
= "Unable
to load file with Error-Messages"
;
}/*
* de:
* 'Konstruieren' des BOC mit den
Positions-Informationen des Fensters
* und bestimmter
GUI-Elemente (z.B. die Breite der Spalten in einer JTable).
*
en:
* 'Construct' the BOC containing Position-informations
of the frame
* and certain GUI-Elements (e.g. column-size
within a JTable). */
structJSBS_FramePosition_BOC
=
new
JSBS_FramePosition_BOC(
frmCC
);
}
/*
*
de: Methode mit dem Code zum Aufbau der Benutzer-Oberfläche
(GUI).
* en: Method with code to build the User-Interface
(GUI). */
private
void
initialize_frame()
{
/*
* de: Benutzer-Oberfläche wird nur für 'Dump'
oder 'Warning' angezeigt; nicht für 'Log'.
* en:
User-interface is only shown in case of 'Dump' or 'Warning'; not for
'Log'. */
if
((
strProcessIndicator
.compareTo(
"D"
)
== 0)
||
(strProcessIndicator
.compareTo(
"W"
)
== 0)) {
/*
* de: Fenster ('Dialog') mit der GUI 'bauen'.
*
en: Build the GUI-window ('Dialog'). */
setSize(700, 550);
setContentPane(get_pnl_Main());/*
* de:
* Bearbeiten der GUI-Elemente mit den
sprach-spezifischen Texten und
* anderen
Layout-Spezifikationen.
* en:
* Process the
GUI-Elements with the language-specific texts and other
*
layout-specifications. */
JSBS_GUIServices.processLanguageDependantElements(
frmCC
,
this
);
JSBS_GUIServices.setButtonBorders(get_pnl_Main(),
frmCC
.
structJSBS_UniversalParameters
);
JSBS_GUIServices.setPanelBorders(get_pnl_Main(),
frmCC
.
structJSBS_UniversalParameters
);
/*
* de: Texte mit Fehler- oder Warn-Information auf die
GUI-Elemente übertragen.
* en: Transfer the texts with
Error- or Warning-information to the GUI-elements. */
fillGUIElementsWithValues();
/*
* de: Schaltfläche, die durch die 'Eingabe'-Taste
ausgelöst wird festlegen und Rand färben.
* en:
Define the Button that is triggered by the 'Enter'-Key and color the
border. */
btnEnterTriggeredButton
=
get_btn_Continue();
JSBS_GUIServices.setButtonBorders(get_pnl_Main(),
frmCC
.
structJSBS_UniversalParameters
,
get_btn_Continue());
/*
* de: Listeners zu den GUI-Elementen hinzufügen.
*
en: Add the Listeners to the GUI-elements.
*/ addListeners(get_pnl_Main());
/*
* de: Größe und Position des Fenster beim
letzten Schließen wieder herstellen.
* en: Restore
size and position at the time of last closing. */
setFramePosition();
/*
* de: Dialog anzeigen.
* en: Show the Dialog.
*/ setVisible(
true
);
}
}/*
* de: Methode mit dem Code der nach der Anzeige der GUI
ausgeführt wird. *
en: Method with code to be processed after the GUI was shown.
*/
private
void
initialize_after_frame()
{
/*
* Will
contain the processing for writing to the Log-File.
*/ }
/*
* ********************
*
de: GUI-Elemente erstellen.
* en: Create the GUI-elements.
*/
protected
JPanel
get_pnl_Main() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
pnl_Main
==
null
)
{
try
{
pnl_Main
=
new
JPanel();
pnl_Main.setName(
"pnl_Main"
);
pnl_Main.setLayout(new
GridBagLayout());
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_pnl_UnexpectedEventScroll =
new
GridBagConstraints();
gbc_pnl_UnexpectedEventScroll.gridx
= 0;
gbc_pnl_UnexpectedEventScroll.gridy
= 0;
gbc_pnl_UnexpectedEventScroll.gridwidth
= 2;
gbc_pnl_UnexpectedEventScroll.fill
=
GridBagConstraints.
BOTH
;
gbc_pnl_UnexpectedEventScroll.weightx
= 3;
gbc_pnl_UnexpectedEventScroll.weighty
= 3;
gbc_pnl_UnexpectedEventScroll.anchor
=
GridBagConstraints.
CENTER
;
gbc_pnl_UnexpectedEventScroll.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints.
*/
get_pnl_Main().add(get_pnl_UnexpectedEventScroll(), gbc_pnl_UnexpectedEventScroll);
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_lbl_OriginClass =
new
GridBagConstraints();
gbc_lbl_OriginClass.gridx
= 0;
gbc_lbl_OriginClass.gridy
= 1;
gbc_lbl_OriginClass.fill
=
GridBagConstraints.
HORIZONTAL
;
gbc_lbl_OriginClass.weightx
= 1;
gbc_lbl_OriginClass.anchor
= GridBagConstraints.
LINE_END
;
gbc_lbl_OriginClass.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints.
*/
get_pnl_Main().add(get_lbl_OriginClass(),
gbc_lbl_OriginClass);
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_txt_OriginClass =
new
GridBagConstraints();
gbc_txt_OriginClass.gridx
= 1;
gbc_txt_OriginClass.gridy
= 1;
gbc_txt_OriginClass.fill
=
GridBagConstraints.
HORIZONTAL
;
gbc_txt_OriginClass.weightx
= 10;
gbc_txt_OriginClass.anchor
= GridBagConstraints.
LINE_START
;
gbc_txt_OriginClass.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints.
*/
get_pnl_Main().add(get_txt_OriginClass(),
gbc_txt_OriginClass);
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_lbl_OriginCode =
new
GridBagConstraints();
gbc_lbl_OriginCode.gridx
= 0;
gbc_lbl_OriginCode.gridy
= 2;
gbc_lbl_OriginCode.fill
= GridBagConstraints.
HORIZONTAL
;
gbc_lbl_OriginCode.weightx
= 1;
gbc_lbl_OriginCode.anchor
= GridBagConstraints.
LINE_END
;
gbc_lbl_OriginCode.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints.
*/
get_pnl_Main().add(get_lbl_OriginCode(),
gbc_lbl_OriginCode);
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_txt_OriginCode =
new
GridBagConstraints();
gbc_txt_OriginCode.gridx
= 1;
gbc_txt_OriginCode.gridy
= 2;
gbc_txt_OriginCode.fill
= GridBagConstraints.
HORIZONTAL
;
gbc_txt_OriginCode.weightx
= 10;
gbc_txt_OriginCode.anchor
= GridBagConstraints.
LINE_START
;
gbc_txt_OriginCode.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints.
*/
get_pnl_Main().add(get_txt_OriginCode(),
gbc_txt_OriginCode);
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_btn_WarningStopIcon =
new
GridBagConstraints();
gbc_btn_WarningStopIcon.gridx
= 2;
gbc_btn_WarningStopIcon.gridy
= 0;
gbc_btn_WarningStopIcon.gridwidth
= 1;
gbc_btn_WarningStopIcon.gridheight
= 3;
gbc_btn_WarningStopIcon.fill
= GridBagConstraints.
BOTH
;
gbc_btn_WarningStopIcon.weightx
= 1;
gbc_btn_WarningStopIcon.weighty
= 1;
gbc_btn_WarningStopIcon.anchor
= GridBagConstraints.
CENTER
;
gbc_btn_WarningStopIcon.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints.
*/
get_pnl_Main().add(get_btn_WarningStopIcon(),
gbc_btn_WarningStopIcon);
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_lbl_ErrorText =
new
GridBagConstraints();
gbc_lbl_ErrorText.gridx
= 0;
gbc_lbl_ErrorText.gridy
= 3;
gbc_lbl_ErrorText.gridwidth
= 2;
gbc_lbl_ErrorText.fill
= GridBagConstraints.
HORIZONTAL
;
gbc_lbl_ErrorText.weightx
= 3;
gbc_lbl_ErrorText.anchor
= GridBagConstraints.
LINE_START
;
gbc_lbl_ErrorText.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints.
*/
get_pnl_Main().add(get_lbl_ErrorText(),
gbc_lbl_ErrorText);
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_pnl_ErrorTextScroll =
new
GridBagConstraints();
gbc_pnl_ErrorTextScroll.gridx
= 0;
gbc_pnl_ErrorTextScroll.gridy
= 4;
gbc_pnl_ErrorTextScroll.gridwidth
= 2;
gbc_pnl_ErrorTextScroll.gridheight
= 2;
gbc_pnl_ErrorTextScroll.
fill
= GridBagConstraints.
BOTH
;
gbc_pnl_ErrorTextScroll.weightx
= 3;
gbc_pnl_ErrorTextScroll.weighty
= 3;
gbc_pnl_ErrorTextScroll.anchor
= GridBagConstraints.
CENTER
;
gbc_pnl_ErrorTextScroll.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints.
*/
get_pnl_Main().add(get_pnl_ErrorTextScroll(), gbc_pnl_ErrorTextScroll);
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_btn_Print =
new
GridBagConstraints();
gbc_btn_Print.gridx
= 2;
gbc_btn_Print.gridy
= 4;
gbc_btn_Print.fill
= GridBagConstraints.
BOTH
;
gbc_btn_Print.weightx
= 1;
gbc_btn_Print.weighty
= 1;
gbc_btn_Print.anchor
= GridBagConstraints.
CENTER
;
gbc_btn_Print.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints. */
get_pnl_Main().add(get_btn_Print(),
gbc_btn_Print);
/*
*
Define GridBagConstraints for the element to be added.
*/
GridBagConstraints
gbc_btn_Continue =
new
GridBagConstraints();
gbc_btn_Continue.gridx
= 2;
gbc_btn_Continue.gridy
= 5;
gbc_btn_Continue.fill
= GridBagConstraints.
BOTH
;
gbc_btn_Continue.weightx
= 1;
gbc_btn_Continue.weighty
= 1;
gbc_btn_Continue.anchor
= GridBagConstraints.
CENTER
;
gbc_btn_Continue.insets
=
new
Insets(3,3,3,3);
/*
Add the element to the panel; element-position is controlled by
GridBagConstraints.
*/
get_pnl_Main().add(get_btn_Continue(),
gbc_btn_Continue);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building pnl_Main in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
pnl_Main
;
}
/*
* ********************
*/
public
JScrollPane
get_pnl_UnexpectedEventScroll() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
pnl_UnexpectedEventScroll
==
null
)
{
try
{
pnl_UnexpectedEventScroll
=
new
JScrollPane();
pnl_UnexpectedEventScroll.setName(
"pnl_UnexpectedEventScroll"
);
pnl_UnexpectedEventScroll
.setAutoscrolls(
true
);
pnl_UnexpectedEventScroll
.setMinimumSize(
new
Dimension(200,100));
pnl_UnexpectedEventScroll.setVerticalScrollBarPolicy(JScrollPane.
VERTICAL_SCROLLBAR_AS_NEEDED
);
pnl_UnexpectedEventScroll.setHorizontalScrollBarPolicy(JScrollPane.
HORIZONTAL_SCROLLBAR_AS_NEEDED
);
pnl_UnexpectedEventScroll
.setEnabled(
false
);
pnl_UnexpectedEventScroll
.setViewportView(get_txt_UnexpectedEvent());
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building pnl_UnexpectedEventScroll in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
pnl_UnexpectedEventScroll
;
}
/*
* ********************
*/
public
JTextArea
get_txt_UnexpectedEvent() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
txt_UnexpectedEvent
==
null
)
{
try
{
txt_UnexpectedEvent
=
new
JTextArea();
txt_UnexpectedEvent.setName(
"txt_UnexpectedEvent"
);
txt_UnexpectedEvent.setMinimumSize(
new
Dimension(300,200));
/*
Do not allow editing of the element as it is intended for display
only.
*/
txt_UnexpectedEvent
.setEditable(
false
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building txt_UnexpectedEvent in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
txt_UnexpectedEvent
;
}
/*
* ********************
*/
public
JLabel
get_lbl_OriginClass() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
lbl_OriginClass
==
null
)
{
try
{
lbl_OriginClass
=
new
JLabel();
lbl_OriginClass.setName(
"lbl_OriginClass"
);
lbl_OriginClass.setText(
".
. . . . .
"
);
lbl_OriginClass.setHorizontalAlignment(SwingConstants.
TRAILING
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building lbl_OriginClass in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
lbl_OriginClass
;
}
/*
* ********************
*/
public
JTextField
get_txt_OriginClass() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
txt_OriginClass
==
null
)
{
try
{
txt_OriginClass
=
new
JTextField();
txt_OriginClass.setName(
"txt_OriginClass"
);
txt_OriginClass.setHorizontalAlignment(SwingConstants.
LEADING
);
txt_OriginClass.setEditable(
false
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building txt_OriginClass in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
txt_OriginClass
;
}
/*
* ********************
*/
public
JLabel
get_lbl_OriginCode() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
lbl_OriginCode
==
null
)
{
try
{
lbl_OriginCode
=
new
JLabel();
lbl_OriginCode.setName(
"lbl_OriginCode"
);
lbl_OriginCode.setText(
".
. . . . .
"
);
lbl_OriginCode.setHorizontalAlignment(SwingConstants.
TRAILING
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building lbl_OriginCode in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
lbl_OriginCode
;
}
/*
* ********************
*/
public
JTextField
get_txt_OriginCode() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
txt_OriginCode
==
null
)
{
try
{
txt_OriginCode
=
new
JTextField();
txt_OriginCode.setName(
"txt_OriginCode"
);
txt_OriginCode.setHorizontalAlignment(SwingConstants.
LEADING
);
txt_OriginCode.setEditable(
false
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building txt_OriginCode in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
txt_OriginCode
;
}
/*
* ********************
*/
public
JLabel
get_lbl_ErrorText() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
lbl_ErrorText
==
null
)
{
try
{
lbl_ErrorText
=
new
JLabel();
lbl_ErrorText.setName(
"lbl_ErrorText"
);
lbl_ErrorText.setText(
".
. . . . . "
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building lbl_ErrorText in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
lbl_ErrorText
;
}
/*
* ********************
*/
public
JScrollPane
get_pnl_ErrorTextScroll() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
pnl_ErrorTextScroll
==
null
)
{
try
{
pnl_ErrorTextScroll
=
new
JScrollPane();
pnl_ErrorTextScroll.setName(
"pnl_ErrorTextScroll"
);
pnl_ErrorTextScroll
.setAutoscrolls(
true
);
pnl_ErrorTextScroll
.setMinimumSize(
new
Dimension(200,100));
pnl_ErrorTextScroll.setVerticalScrollBarPolicy(JScrollPane.
VERTICAL_SCROLLBAR_AS_NEEDED
);
pnl_ErrorTextScroll.setHorizontalScrollBarPolicy(JScrollPane.
HORIZONTAL_SCROLLBAR_AS_NEEDED
);
pnl_ErrorTextScroll
.setEnabled(
false
);
pnl_ErrorTextScroll
.setViewportView(get_txt_ErrorText());
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building pnl_ErrorTextScroll in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
pnl_ErrorTextScroll
;
}
/*
* ********************
*/
public
JTextArea
get_txt_ErrorText() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
txt_ErrorText
==
null
)
{
try
{
txt_ErrorText
=
new
JTextArea();
txt_ErrorText.setName(
"txt_ErrorText"
);
txt_ErrorText.setMinimumSize(
new
Dimension(300,200));
/*
Do not allow editing of the element as it is intended for display
only.
*/
txt_ErrorText
.setEditable(
false
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building txt_ ErrorText in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
txt_ErrorText
;
}
/*
* ********************
*/
public
JButton
get_btn_WarningStopIcon() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
btn_WarningStopIcon
==
null
)
{
try
{
btn_WarningStopIcon
=
new
JButton();
btn_WarningStopIcon.setName(
"btn_WarningStopIcon"
);
/*
de: Bei dieser Schaltfläche den Text unterhalb des Graphischen
Symbols (Icons) platzieren.
*
en: Place the text below the Icon at this button.
*/
btn_WarningStopIcon.setVerticalAlignment(SwingConstants.
TOP
);
btn_WarningStopIcon.setHorizontalAlignment(SwingConstants.
CENTER
);
btn_WarningStopIcon.setVerticalTextPosition(SwingConstants.
BOTTOM
);
btn_WarningStopIcon.setHorizontalTextPosition(SwingConstants.
CENTER
);
/*
de: Bei einem Mausklick auf diese Schaltfläche einen ActionEvent
auslösen.
*
en: Trigger an ActionEvent when this button is clicked with the
mouse.
*/
btn_WarningStopIcon.setActionCommand(
"btn_WarningStopIcon"
);
btn_WarningStopIcon.addActionListener(
this
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building btn_WarningStopIcon in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
btn_WarningStopIcon
;
}
/*
* ********************
*/
public
JButton
get_btn_Print() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
btn_Print
==
null
)
{
try
{
btn_Print
=
new
JButton();
btn_Print.setName(
"btn_Print"
);
btn_Print.setHorizontalAlignment(SwingConstants.
LEADING
);
btn_Print.setActionCommand(
"btn_Print"
);
btn_Print.addActionListener(
this
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building btn_Print in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
btn_Print
;
}
/*
* ********************
*/
public
JButton
get_btn_Continue() {
/*
Auto-create the GUI-element if it does not already exist. */
if
(
btn_Continue
==
null
)
{
try
{
btn_Continue
=
new
JButton();
btn_Continue.setName(
"btn_Continue"
);
btn_Continue.setHorizontalAlignment(SwingConstants.
LEADING
);
btn_Continue.setActionCommand(
"btn_Continue"
);
btn_Continue.addActionListener(
this
);
}
catch
(Throwable
Exc) {
System.out
.println(
"Error
while building btn_Continue in class
JSBS_ErrorDialog"
);
Exc.printStackTrace();
}
} return
btn_Continue
;
}
/*
*
de:
* Methode zum Ersetzen der Platzhalter für
Parameter innerhalb des Hinweis-
* Textes (der aus der
XML-Struktur gelesen wurde) durch die übergebenen
*
Parameter.
* Wenn mehr Parameter-Werte übergeben
wurden als Platzhalter vorhanden sind
* dann werden die
Parameter am Ende des Hinweis-Textes angehängt.
* en:
* Method to replace the placeholders for parameters in the
Message-Text
* (fetched from the XML-structure) by the
values of the passed parameters.
* If there were more
parameters passed than placeholders then
* the values
of the parameter are appended to the message-text as new lines.
*/
private
void
insertParameterIntoMessageText()
{
for
(
int
intIndex = 1; intIndex <= 5; intIndex++) {
/*
* de:
* Name des Parameters; verwendet um die
Position (des Platzhalters) innerhalb
* des Fehler-Textes
zu suchen.
* en:
* Name of the parameter;
used to search the position (of the placeholder)
* within
the Error-Message. */ String
strParameterToReplace =
""
;
/*
* de: Werte des Parameter (an diese Klasse übergeben)
der den Platzhalter ersetzen wird.
* en: Value of the
parameter (passed to this class) that will replace the placeholder.
*/ String
strParameterValue =
""
;
switch
(intIndex)
{
case
1:
strParameterToReplace =
"Parameter1"
;
strParameterValue
= str_Parameter1
;
break
;
case
2:
strParameterToReplace =
"Parameter2"
;
strParameterValue
= str_Parameter2
;
break
;
case
3:
strParameterToReplace =
"Parameter3"
;
strParameterValue
= str_Parameter3
;
break
;
case
4:
strParameterToReplace =
"Parameter4"
;
strParameterValue
= str_Parameter4
;
break
;
case
5:
strParameterToReplace =
"Parameter5"
;
strParameterValue
= str_Parameter5
;
break
;
}/*
* de:
* Ersetzen in einer for-Schleife weil für
einen Parameter auch mehrere Platzhalter
* erlaubt sind.
* Zuerst wird ein Flag gesetzt das signalisiert, ob
der Parameter-Wert in den Text
* eingefügt wurde oder
nicht.
* en:
* Replacement within a for-loop
because for one parameter there is more than
* one
placeholder allowed.
* First, a flag is set signalling if
the parameter-value is already inserted into
* the text.
*/
boolean
bolNotAlreadyReplaced
=
true
;
strParameterToReplace =
"%"
+
strParameterToReplace +
"%"
;
for
(;;)
{
/*
* de: Algorithmus zum Finden des Platzhalters und um ihn zu
entfernen.
* en: Algorithm to find the placeholder and
replace it. */
int
intParameterIndex =
strIndividualMessageText
.indexOf(strParameterToReplace);
if
(intParameterIndex >= 0) {
/*
* de: Fehler-Text in 2 Teile aufteilen und den
'Platzhalter' entfernen.
* en: Split error-text into 2
parts to eliminate 'placeholder' string. */
String strLeftPart =
strIndividualMessageText
.substring(0,
intParameterIndex);
String
strRightPart =
strIndividualMessageText
.substring(intParameterIndex
+ strParameterToReplace.length());
/*
* de: Zusammensetzen mit dem Parameter-Wert.
*
en: Concatenate including parameter-value. */
strIndividualMessageText
=
strLeftPart + strParameterValue + strRightPart;
/*
* de: Flag signalisieren lassen, dass der Parameter-Wert
bereits eingefügt wurde.
* en: Let the flag signal
that the parameter-value was already inserted. */
bolNotAlreadyReplaced =
false
;
}
else
{
/*
* de:
* Platzhalter nicht gefunden; Wert des
Parameters in einer neuen Zeile anhängen.
* Aber nur
wenn der Wert noch nicht in den Text eingefügt wurde und der
Parameter
* auch einen Text enthält.
* en:
* Placeholder not found; append value in a new line.
* But
do this only if the parameter-value was not already inserted into the
text and the
* value contains text. */
if
(bolNotAlreadyReplaced && (strParameterValue.trim().length()
> 0)) {
strIndividualMessageText
+=
"\n"
+ strParameterToReplace +
": "
+ strParameterValue;
}/*
* de: for-Schleife abbrechen.
* en: End the
for-loop. */
break
;
} }
}
}/*
* de: Methode um die GUI-Elemente mit dem individuellen
Text zu füllen. *
en: Method to fill the GUI-elements with individual text.
*/
private
void
fillGUIElementsWithValues()
{
/*
*
de: Prüfen ob die XML-Struktur ohne Fehler konstruiert wurde. *
en: Verify if the XML-structure was constructed without an error.
*/
if
(structJSBS_XML_ErrorMessages.
StatusCode
== structJSBS_XML_ErrorMessages.
CONST_OK
)
{
/*
* de: Holen der Information für den Anwender wenn
'Dump' oder 'Warning'. *
en: Fetch the information for the user if 'Dump' or 'Warning'. */
if
((
strProcessIndicator
.compareTo(
"D"
)
== 0)
||
(strProcessIndicator
.compareTo(
"W"
)
== 0)) {
strIndividualMessageText
=
structJSBS_XML_ErrorMessages.getMessageText(str_OriginClass
,
str_OriginCode
);
}/*
* de:
* Abhängig vom ProcessIndicator:
*
Erklärungs-Text für den Fehler (mit Programmabbruch) oder
die Warnung holen
* und den Datei-Namen mit dem Graphischen
Symbol (Icon).
* en:
* Depending on the
ProcessIndicator:
* Fetch the explanatory text for
Error (Dump) or Warning
* and the file-name with the Icon.
*/
if
(
strProcessIndicator
.compareTo(
"D"
)
== 0) {
strUnexpectedEventText
=
structJSBS_XML_ErrorMessages.getErrorExplanationText();
strIconFileNameIncludingDirectory
=
structJSBS_XML_ErrorMessages.getErrorIconFileName();
}
if
(
strProcessIndicator
.compareTo(
"W"
)
== 0) {
strUnexpectedEventText
=
structJSBS_XML_ErrorMessages.getWarningExplanationText();
strIconFileNameIncludingDirectory
=
structJSBS_XML_ErrorMessages.getWarningIconFileName();
}/*
* de: Einfügen der übergebenen Parameter in den
Nachrichten-Text aus der XML-Struktur.
* en: Insert passed
parameters into the message-text from the XML-structure. */
insertParameterIntoMessageText();
/*
* de: Übertragen der Texte in die GUI-Elemente.
*
en: Transfer the texts into the GUI-elements. */
JSBS_GUIServices.setStringWithNewLineToJTextArea(get_txt_UnexpectedEvent(),
strUnexpectedEventText
);
get_txt_OriginClass().setText(str_OriginClass
.trim());
get_txt_OriginCode().setText(str_OriginCode
.trim());
JSBS_GUIServices.setStringWithNewLineToJTextArea(get_txt_ErrorText(),
strIndividualMessageText
);
/*
* de:
* Wenn ein Wert für den
Icon-Datei-Namen zurück geliefert wurde dann erweitern des
Datei-Namens
* um das komplette Verzeichnis und Anzeigen
des Graphischen Symbols auf der Schaltfläche.
* en:
*
If a value for the icon-file-name was returned then extend the
file-name by the complete
* directory and display of the
Icon on the Button. */
if
(
strIconFileNameIncludingDirectory
.length()
> 0) {
strIconFileNameIncludingDirectory
=
frmCC
.
structJSBS_UniversalParameters
.
strGraphicElementsDirectoryName
+
strIconFileNameIncludingDirectory
;
get_btn_WarningStopIcon().setIcon(new
ImageIcon(
strIconFileNameIncludingDirectory
));
}
} }
/*
*
-------------------------------
* de:
* Methode,
die den KeyListener zu einem GUI-Element und allen seinen
untergeordneten
* Komponenten hinzufügt.
*
Diese Methode untersucht jeden 'Conteiner' auf untergeordnete
Komponenten und für jede
* gefundene Komponente ruft
sich diese Methode selbst auf und übergibt die Komponente als
*
Parameter.
*
* en:
* Method that adds the
KeyListener to a GUI-element and all its subordinate
components.
* This method inspects each 'Container' for
components and calls itself for each component
* and passes
that component as parameter. */
private
void
addListeners(Container
parmContainer) {
/*
de: KeyListener werden zu jedem Typ eines
GUI-Elementeshinzugefügt.
* en: KeyListener are added
to any type of a GUI-element.
*/
parmContainer.addKeyListener(
this
);
/*
de:
* Untersuchen ob der 'Container' weitere Komponenten
enthält. Wenn Komponenten in diesem
* 'Container'
vorhanden sind, dann diese Methode rekursiv für jeden
'Container' aufrufen.
* en:
* Inspect if the
'Container' has components in it. If there are components
* within
this 'Container', call this method recursively for each of it.
*/
Component
comps[] = parmContainer.getComponents();
for
(
int
i = 0; i < comps.
length
;
i++) {
Component
comp = comps[i];
addListeners((Container)
comp);
} }
/*
*
-------------------------------
* de:
* Methoden
die zusammen mit der Interface KeyListener implementiert werden
müssen.
* Wenn eine Methode dieser Basis-Klasse Code
enthält und diese Methode in einer
* abgeleiteten
Klasse überschrieben werden muß, dann muß die
Methode dieser
* Basis-Klasse auf folgende Weise aufgerufen
werden:
* super.keyPressed(e);.
* en:
*
Methods that are requiered together with the interface
KeyListener.
* If a method of this base-class contains
code and has to be overwritten
* in the derived class, the
method in this base class has to be called in the * overwriting
method like this example:
* super.keyPressed(e);.
*/
public
void
keyPressed(KeyEvent
e) {
/*
de:
* Diese Methode wird verwendet um zu prüfen ob eine
Funktionstaste (der Tastatur)
* betätigt wurde.
*
en:
* This method is used to check if a Function-Key (of the
keyboard) was pressed. */
/* de:
* Zeichenkette die den
internen Tastatur-Code enthalten wird. Das ist jener Code
*
der innerhalb des JavaScout Fat-Client-Framework (JS-FCF) verwendet
wird.
* en:
* String that will contain the Internal
Key-Code. That ist the code that is
* used within the
JavaScout Fat-Client-Framework (JS-FCF). */ String
strInternalKeyCode =
""
;
/*
de: Flag ob eine Funktionstaste (F1 bis F12) betätigt wurde.
*
en: Flag to indicate if a Function-Key (F1 to F12) was pressed.
*/
boolean
bolFunctionKeyPressed
=
false
;
/*
de: Den Java-internen Tastatur-Code aus dem KeyEvent ermitteln.
*
en: Derive the Java-internal key-code from the KeyEvent. */
int
intKeyCode
= e.getKeyCode();
/*
de:
* Untersuchen des Key-Events ob die 'Enter'- (Eingabe-)
Taste betätigt wurde.
* Diese simuliert einen Mausklick
auf eine definierte Schaltfläche (JButton).
* en:
*
Inspect the Key-Event if the 'Enter'-Key was pressed. This key
simulates
* a mouse-click to the defined 'JButton'.
*/
if
(intKeyCode
== KeyEvent.
VK_ENTER
)
{
/*
de:
* 'Eingabe'- (Enter-) Taste gedrückt; prüfen
ob dieser eine Schaltfläche
* (JButton) zugeordnet
ist.
* en: Enter-key was pressed; verify if a Button is
attached to the Enter-key. */
if
(
btnEnterTriggeredButton
!=
null
)
{
/*
de:
* Schaltfläche (JButton) ist zugeordnet; Prüfen
ob er 'enabled' ist und dann
* den 'Mausklick'
simulieren.
* en: JButton is defined, see if the Button is
enabled and simulate the 'click'. */
if
(
btnEnterTriggeredButton
.isEnabled())
{
btnEnterTriggeredButton
.doClick();
e.consume();
}
/*
de: Schaltfläche nicht 'enabled'; einen 'Beep' zur Warnung
ausgeben.
* en: Button not enabled; produce a beep to warn
the user. */
else
getToolkit().beep();
/*
de: Aufgabe der Methode erfüllt; Methode beenden.
* en:
Mission of this method completed; end the method. */
return
;
}
}/*
de:
* Untersuchen des Key-Events ob eine 'Modifier'-Taste
betätigt wurde.
* Nur so ist eine Prüfung
unabhängig von Betriebssystem und gewählter
*
Sprache möglich.
* en:
* Inspect the
Key-Event if a 'Modifier'-Key was pressed. This code is the only
*
way to check independent from operating system and chosen language.
*/
if
(intKeyCode
== KeyEvent.
VK_ALT
)
{
bolAltKeyModifier
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_CONTROL
)
{
bolCtrlKeyModifier
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_SHIFT
)
{
bolShiftKeyModifier
=
true
;
e.consume();
}/*
de:
* Wenn 'Modifier'-Tasten gedrückt sind dann den
internen Code für diese jetzt in
* die Zeichenkette
für den Internen Key-Code einfügen.
* en:
*
If 'Modifier'-keys are pressed then insert the internal code for them
* now to the string for the Internal Key-Code. */
if
(
bolAltKeyModifier
)
strInternalKeyCode +=
"Alt-"
;
if
(
bolCtrlKeyModifier
)
strInternalKeyCode +=
"Ctrl-"
;
if
(
bolShiftKeyModifier
)
strInternalKeyCode +=
"Shift-"
;
/*
de:
* Untersuchen des Key-Events ob eine Funktionstaste
betätigt wurde.
* Nur so ist eine Prüfung
unabhängig von Betriebssystem und gewählter
*
Sprache möglich.
* en:
* Inspect the
Key-Event if a Function-Key was pressed. This code is the only
*
way to check independent from operating system and chosen language.
*/
if
(intKeyCode
== KeyEvent.
VK_F1
)
{
strInternalKeyCode
+= "F1"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F2
)
{
strInternalKeyCode
+= "F2"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F3
)
{
strInternalKeyCode
+= "F3"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F4
)
{
strInternalKeyCode
+= "F4"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F5
)
{
strInternalKeyCode
+= "F5"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F6
)
{
strInternalKeyCode
+= "F6"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F7
)
{
strInternalKeyCode
+= "F7"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F8
)
{
strInternalKeyCode
+= "F8"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F9
)
{
strInternalKeyCode
+= "F9"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F10
)
{
strInternalKeyCode
+= "F10"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F11
)
{
strInternalKeyCode
+= "F11"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_F12
)
{
strInternalKeyCode
+= "F12"
;
bolFunctionKeyPressed
=
true
;
e.consume();
}/*
de:
* Wenn kein definierter 'Virtual-Key' für eine
Funktionstaste gedrückt wurde *
dann wird der Internal Key-Code mit der in Java festgelegten
Bezeichnung
* für die Taste gebildet. Diese Bezeichnung
der Taste kann vom Betriebssystem
* oder der gewählten
Sprache abhängen.
* en:
* If no defined
'Virtual-Key' for a Function-Key was pressed then the
*
Internal Key-Code is build with the Java-defined Text of the key.
*
This text might depend on the operating system or chosen language.
*/
if
(!
bolFunctionKeyPressed)
strInternalKeyCode += KeyEvent.getKeyText(intKeyCode);/*
de:
* Untersuchen der XML-Struktur ob ein ButtonName dem
Internal Key-Code
* zugeordnet ist.
* en:
*
Inspect the XML-structure if a ButtonName is associated with the
*
Internal Key-Code. */
String strButtonName
=
frmCC
.
structJSBS_XML_FunctionKeys
.getButtonName(
this
.getClass().getName(),
strInternalKeyCode);
/*
de:
* Wenn ein 'ButtonName' gefunden wurde dann wird die
Methode aufgerufen,
* die unter den GUI-Elementen den
'JButton' mit dem passenden Namen sucht
* und einen
'Mausklick' auf diesen 'JButton' simuliert.
* en:
*
If a 'ButtonName' was found then the method is called to find
the 'JButton'
* with the fitting ButtonName amongst the
GUI-Elements and simulate a 'mouse-click'
* on that
'JButton'. */
if
(strButtonName.length()
> 0) {
JSBS_GUIServices.clickButton(this
.getContentPane(),
strButtonName);
/*
de:
* 'Consume' (Verbrauchen) des KeyEvent damit er nichts
anderes auslöst.
* en:
* 'Consume' the
KeyEvent so it can not trigger something esle.
*/ e.consume();
}
}
public
void
keyReleased(KeyEvent
e) {
/*
de:
* Diese Methode setzt die Markierungen für die
Midifier-Tasten (Alt, Steuerung,
* Umschalten) zurück.
*
Zuerst wird der numerische Tastatur-Code ermittelt und dieser wird
dann mit
* dem 'Virtual-Key' verglichen.
*
Der Vergleich mit dem 'Virtual Key' liefert ein eindeutiges Ergebnis
das nicht
* vom verwendeten Betriebssystem oder der
eingestellten Sprache abhängt.
* en:
* This
method is used to reset the flags for Modifier-keys (Alt, Control,
Shift).
* First derive the numeric key-code and then
compare it with the 'Virtual-Key'.
* The comparison with the
'Virtual-Key' gives a unique result independent from
* the
underlying operating-system or the chosen language. */
int
intKeyCode
= e.getKeyCode();
/*
de:
* Untersuchen ob ein 'Modifier-Key' losgelassen wurde.
* Wenn es ein 'Midifier-Key' war dann das entsprechende
'Flag' zurücksetzen und
* den KeyEvent als 'consumed'
markieren.
* en:
* Inspect if a Modifier-key
was released.
* If it was a Modifier-Key, reset the
flag and mark the KeyEvent as 'consumed'. */
if
(intKeyCode
== KeyEvent.
VK_ALT
)
{
bolAltKeyModifier
=
false
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_CONTROL
)
{
bolCtrlKeyModifier
=
false
;
e.consume();
}
if
(intKeyCode
== KeyEvent.
VK_SHIFT
)
{
bolShiftKeyModifier
=
false
;
e.consume();
}
}
public
void
keyTyped(KeyEvent
e) {
}/*
*
-------------------------------
* de:
* Methoden
die zusammen mit der interface WindowListener erforderlich sind.
*
Wenn Methoden Code enthalten und von einer erbenden Klasse
überschrieben werden,
* dann muss die Methode in dieser
Klasse wie in diesem Beispiel aufgerufen werden:
*
super.windowActivated(e); .
* en: *
Methods that are requiered together with the interface
WindowListener.
* If these methods contain code and are
overwritten in the derived class,
* the method in this
base class has to be called in the overwriting method
* like
this example:
* super.windowActivated(e); .
*/
public
void
windowActivated(WindowEvent
e) {
}
public
void
windowClosed(WindowEvent
e) {
this
.dispose();
}
public
void
windowClosing(WindowEvent
e) {
/*
de: Methode aufrufen, die Größe und Position des JFrame
auf der Datenbank speichert.
* en: Call the method that
stores size and position of the JFrame to the database. */
storeFramePosition();
this
.dispose();
}
public
void
windowDeactivated(WindowEvent
e) {
}
public
void
windowDeiconified(WindowEvent
e) {
}
public
void
windowIconified(WindowEvent
e) {
}
public
void
windowOpened(WindowEvent
e) {
}/*
*
-------------------------------
* de:
* Methode zum
'Holen' der Eigenschaften (Größe und Postion) des Frames
und der Spaltenbreiten
* für JTables von der Datenbank
und Anpassen von Größe und Position des Frames
*
en: *
Methods to retrieve the Frame-Properties (size and position) and the
column-widths for JTables
* from the database and resize and
position the Frame according to them. */
/*
* de:
*
Die folgende Methode muss von der erbenden Klasse (Teilprogramm /
Task-Frame mit der spezifischen
* Geschäftsanwendung)
aufgerufen werden nachdem die Verbindung zur Datenbank (oder zum
EJB-Server)
* hergestellt ist und das JFrame konstruiert
wurde.
* en: *
The following method has to be called by the derived class
(application-specific Task-Frame)
* after the access to the
database (or EJB-server) is established and the JFrame is
constructed. */
public
void
setFramePosition()
{
/*
de: Holen der FramePosition-Eigenschaften von der Datenbank.
*
en: Retrieve the FramePosition-properties from the database. */
structJSBS_FramePosition_BOC
.getValidByUserKnownKey(
this
.getClass().getName(),
frmCC.structJSBS_UniversalParameters.strUserName
);
/*
de:
* Nachdem die Datenbank-Tabelle 'Parameter' im
Anwendungprogramm, das diese Klasse erbt, nicht
* erstellt
sein kann führt ein Fehler beim Zugriff auf die Datenbank nicht
zu einem Ereignis
* über das der Benutzer informiert
wird.
* Der Unterschied zwischen fehlerfreier Abfrage und
Auftreten eines Fehler ist nur, wie das BOS
* mit Daten
versorgt wird.
* en:
* As there is no
obligation for an application using this base-class to have a
database-table
* named 'Parameter', a failure of the
data-access is not an error to be reported.
* The
differentiation is just the way, how the BOS is supplied with values.
*/
if
(
structJSBS_FramePosition_BOC
.
StatusCode
== JSBS_BO.
CONST_OK
)
{
/*
de: Eigenschaften auf der Tabelle gefunden; Frame anpassen.
*
en: Frame-Position-properties found on the database; adapt the Frame.
*/
this
.setSize(
structJSBS_FramePosition_BOC
.
FrameWidth
,
structJSBS_FramePosition_BOC
.
FrameHeight
);
this
.setLocation(
structJSBS_FramePosition_BOC
.
PosX
,
structJSBS_FramePosition_BOC
.
PosY
);
}
else
{
/*
de:
* Eigenschaften für die Frame-Position nicht auf
der Datenbank gefunden;
* Dieses BO mit dem Namen des JFrame
und des Benutzer versorgen - für den Fall, dass das
*
BO beim Schließen des Fenster gespeichert wird.
*
en:
* Frame-Position-properties not found on the database;
* Supply the BO with the name of the JFrame and the user -
in case that this information is stored
* when the JFrame is
closing. */
structJSBS_FramePosition_BOC
.
FrameClassName
=
this
.getClass().getName();
structJSBS_FramePosition_BOC
.
UserID
=
frmCC.structJSBS_UniversalParameters.strUserName
;
}
}/*
*
de:
* Die folgende Methode wird aufgerufen wenn das JFrame
(Window) geschlossen wird.
* Innerhalb dieser Methode wird
die Größe und Position des JFrame ermittelt und in der
Datenbank
* gespeichert. *
en:
* The following method is called when the JFrame
(window) is 'closing'.
* Within this method, the size and
the position of the JFrame is taken and stored to the database.
*/
public
void
storeFramePosition()
{
/*
Check if the BOC is constructed.
* As the construction
happens in the derived Task-Frame (application-specific)
*
the application might not make use of keeping the Frame-postion and
-size within the database. */
if
(
structJSBS_FramePosition_BOC
==
null
)
return
;
/*
Get the properties from the frame; the properties can be derived as
type Rectangle. */
Rectangle
locRectangle =
new
Rectangle();
locRectangle
=
this
.getBounds();
structJSBS_FramePosition_BOC
.
PosX
= locRectangle.
x
;
structJSBS_FramePosition_BOC
.
PosY
= locRectangle.
y
;
structJSBS_FramePosition_BOC
.
FrameWidth
= locRectangle.
width
;
structJSBS_FramePosition_BOC
.
FrameHeight
= locRectangle.
height
;
/*
Store the values to the database.
* As there might be not
database-table 'Parameter' existing for the application,
*
The result is not checked and an error is not reported. */
structJSBS_FramePosition_BOC
.store();
}/*
*
-------------------------------
* de:
* Methode die
einen Ausdruck mit den Ursachen-Daten der Warnung oder des Fehlers
*
erstellt.
* en:
* Method producing a printout with
the data causing the warning or the error. */
public
void
processPrint()
{
/*
* de:
* Variable zum Verwalten des vertikalen
Startpunktes für den Ausdruck der nächsten
*
Zeile. Das Maß ist in 'Punkten'.
* en:
*
Variable to administrate the vertical start-point for the printing of
the next line.
* Measure is in 'Points'.
*/
int
intVerticalPointPosition
= 30;
/*
* de: 'Frame'; dieses stellt den 'PrintJob' zur Verfügung.
* en: 'Frame'; that is supplying the 'PrintJob'.
*/
Frame
f =
new
Frame();
/*
* de:
* 'Konstruieren' des 'PrintJob'. Wegen der
(hoffentlich) seltenen Verwendung wird der
*
Identifikationstext nicht sprachabhängig gestaltet sondern nur
ein Fixtext verwendet.
* en:
* 'Construct' the
'PrintJob'. Due to the (hopefully) rare usage the
identification-text
* will not be language-specific; just a
fixed text is used. */
PrintJob
pJob = f.getToolkit().getPrintJob(f,
"Printout
for Error or Warning"
,
null
);
/*
* de: 'Fläche' zum platzieren graphischer Elemente
(zum 'Zeichnen') holen.
* en: Get the 'area' to place
graphic elements (to paint). */
Graphics
g = pJob.getGraphics();
/*
* de:
* Es folgen die Texte für die
Information über die Ursache für den Hinweis oder die
*
Fehlermeldung.
* Wegen der (hoffentlich) selten notwendigen
Verwendung dieser Methode werden die
* Hinweise nicht
sprach-spezifisch sondern in Englisch gedruckt.
* en:
*
Following are the texts for the information about the reason for the
Warning- or
* Error-Message.
* Due to the
(hopefully) rare usage of this method the informations are not
*
language-specific; just in English. *//*
* de: Festlegen von Farbe und Schriftart für den zu
'zeichnenden' Text.
* en: Define color and font for the
text to be 'drawn'.
*/
g.setColor(Color.
black
);
g.setFont(
new
Font(
"Arial"
,
Font.
BOLD
,
12));
g.drawString(
"JavaScout
:: Printout for Error- or Warning-Message"
,
50, intVerticalPointPosition);
/*
* de: Erhöhen der 'vertikalen Position' für die
Platzierung der nächsten Zeile.
* en: Increase the
'vertical position' for the placement of the next line. */
intVerticalPointPosition+=
25;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Classname
of the calling frame:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(
frmParent
.getClass().getName(),
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Origin-class
of the event:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(str_OriginClass,
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Origin-code
(location) of the event:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(str_OriginCode,
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Process-indicator
from the XML-file:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(strProcessIndicator,
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Parameter
1 of the event:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(
str_Parameter1
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Parameter
2 of the event:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(
str_Parameter2
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Parameter
3 of the event:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(
str_Parameter3
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Parameter
4 of the event:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(
str_Parameter4
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Parameter
5 of the event:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(
str_Parameter5
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
30;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Logged
on user:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(
frmCC
.
structJSBS_UniversalParameters
.
strUserName
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"Workstation
TCP/IP:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*
de: Zeichenkette für die Repräsentation der
TCP/IP-Adresse.
*
en: String holding later the representation of the TCP/IP-address.
*/
String
strIPAddr =
""
;
/*
de: Ermittlung innerhalb der try/catch-Logik falls Fehler
auftreten.
*
en: Getting within a try/catch-logic in case that errors occur.
*/
try
{
/*
de: Internet-Kennungen des Computers auf dem das Programm läuft,
ermitteln.
*
en: Get the Internet-properties of the computer the program is
running on. */
InetAddress
addr = InetAddress.getLocalHost();
/*
de: TCP/IP-Adresse extrahieren.
*
en: Extract TCP/IP_Address. */
byte
[]
ipAddr = addr.getAddress();
/*
de: Umwandeln der TCP/IP-Adresse in eine Zeichenkette für
späteren Ausdruck.
*
en: Convert the TCP/IP-Address into a string for later printing.
*/
for
(
int
i = 0; i < ipAddr.
length
;
i++) {
if
(i
> 0) strIPAddr +=
"."
;
strIPAddr
+= ipAddr[i]&0xFF;
}
}
/*
de: Keine Behandlung eines eventuellen Fehlers; leeren String
drucken.
*
en: No processing of an error; print empty string. */
catch
(Exception
e) {}
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(strIPAddr,
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
*/
g.setFont(
new
Font(
"Arial"
,
Font.
PLAIN
,
12));
g.drawString(
"System
date and time:"
,
50, intVerticalPointPosition);
intVerticalPointPosition+=
15;
/*
*
de: Datum und Zeit des Computers auf dem das Programm ausgeführt
wird.
*
en: Date and time of the computer this program is running.
*/
Date
actualDate =
new
Date();
DateFormat
dF =
DateFormat.getDateTimeInstance(DateFormat.
DEFAULT
,
DateFormat.
LONG
);
/*
*/
g.setFont(
new
Font(
"Courier"
,
Font.
BOLD
,
12));
g.drawString(dF.format(actualDate),
50, intVerticalPointPosition);
intVerticalPointPosition+=
20;
/*
* de: 'Schreiben' der Texte abgeschlossen; Ausdruck
starten.
* en: 'Writing' of the texts finished; start the
printout. */
g.dispose();
pJob.end();
/*
*/
}
/*
*
-------------------------------
* de:
* Methode die
aufgerufen wird wenn ein GUI-Element mit zugewiesenem
'ActionListener'
* angeklickt wurde.
* en:
*
Method that is triggered when a GUI-element with attached
'ActionListener'
* is clicked. */
public
void
actionPerformed(ActionEvent
e) {
/*
*
de:
* Ermitteln des 'ActionCommand'.
* Dieser wurde
dem GUI-Element mit der Methode 'setActionCommand' zugewiesen.
*
en:
* Derive the 'ActionCommand'.
* That was
attached to the GUI-element through the method 'setActionCommand'.
*/
String
cmd = e.getActionCommand();
/*
* de: Feststellen welchen ActionCommand übergeben
wurde und die passende Aktion ausführen.
* en: Check
which ActionCommand was handed over and perform the appropriate
action.
* */
if
(cmd.equals(
"btn_WarningStopIcon"
))
{
/*
de: Diese Schaltfläche wird auch für den Aufruf der
Hilfe-Information genutzt.
* en: This JButton is also used
to call the 'Help'-Information. */ String
strHelpFileName =
frmCC
.
structJSBS_XML_DisplayStrings
.getFrameHelpFileName(
this
);
if
(strHelpFileName !=
null
)
{
/*
de: Erste Prüfung ob ein Datei-Name gefunden wurde.
*
en: First verification if a file-name was found. */
if
(strHelpFileName.length() > 0) {
/*
de: Zweite Prüfung ob ein Datei-Name gefunden wurde.
*
en: Second verification if a file-name was found. *//*
de: Erweitern des Datei-Namens auf gesamte Verzeichnis-Struktur.
*
en: Expand the file-name to the complete directory-structure. */
strHelpFileName =
frmCC
.
structJSBS_UniversalParameters
.
strHelpElementsDirectoryName
+
strHelpFileName;
/*
de: Anzeigen des Hilfe-Dokumentes.
* en: Display the
Help-document. */
try
{Desktop.getDesktop().browse(
new
URI(
"file:///"
+ strHelpFileName));}
/*
de: Fehler beim Anzeigen des Hilfe-Dokumentes - kein Grund für
eine Fehlerbehandlung.
* en: Error when displaying the
help-document - no reason for error-handling. */
catch
(Exception
wwwExc) {wwwExc.printStackTrace();}
}
}
}/*
* de: Feststellen welchen ActionCommand übergeben
wurde und die passende Aktion ausführen.
* en: Check
which ActionCommand was handed over and perform the appropriate
action. */
if
(cmd.equals(
"btn_Continue"
))
{
/*
de: Methode aufrufen, die Größe und Position des JFrame
auf der Datenbank speichert.
* en: Call the method that
stores size and position of the JFrame to the database.
*/
storeFramePosition();/*
de: Bestätigung des Anwenders; Dialog schliessen.
* en:
Confirmation of the user; close the dialog.
*/
this
.dispose();
}
if
(cmd.equals(
"btn_Print"
))
{
/*
* de: Methode zum Ausdrucken aufrufen.
* en: Call
the method to print. */ processPrint();
}
}}
xxx
Dokument |
Inhalt |
Dieser
Leitfaden enthält die notwendigen Tätigkeiten für
die Entwicklung eines StartFrame (auch als Command-Center
bekannt). |