|
Last
revision of this document: |
This document lists the steps (with links to more detailed descriptions and sample code) to develop a Start-Frame as Command-Center to start Task-Frames to perform Business-Tasks.
Shortcut:This
document covers the following steps:
Step
by step instructions for developing a Fat-Client application with
the sections:
* Create
the class,
* Code
the 'Constructor',
* Define
the language dependant GUI-elements and add the code to display
it,
* Define
the GUI-elements individual for the Task 'Project',
* Create
the Business Objects and the Database Access Objects (link to
seperate document)',
* Implement
the Client-Side Business Object',
* React
to the 'Store' button and write to the database',
* Display
the list with the stored 'Projects',
Credits:To
many to list; please see the linked documents with the detailed
descriptions.
Aside,
that the Eclipse
workbench with the plugin for the Visual
Editor (VE) has to be installed,
Mandatory
steps for developing a Start-Frame has to be completed.
Step
by step instructions:Create
the classA
more detailed description with screenshots is in the document
JS_FC01i – Create and code the class
for the 'Task-Frame' to maintain 'Projects'.
In
catchwords:
* .Right
click onto the 'Project' and select
>New>Other...
* In
the following window expand 'Java' (if not alredy done), select
>Visual
Class and
click the [ Next
> ] button.
* Enter
the Package (xxx_project_xxx.clientframes,
e.g. js_projassist.clientframe),
the (Class-)Name
(XXX_Project_XXX_BusinessTask,
e.g. JS_ProjAssist_Project) and
the
Superclass (js_base.frame.JSBS_TaskFrame).
Make sure that no checkbox is marked and click
the [ Finish ] button
As
the constructor of the inherited class has a parameter, an error is
reported as soon as the class is created.
This error will be fixed
in the next step.
Code
the 'Constructor' and call the class from the 'CommandCenter'
The
following step assumes, that the GUI-elements of the standard layout
(as defined in the inherited class JSBS_TaskFrame)
should be used.
To
keep the code clearly arranged, the constructor just calls three
methods with the consecutive commands.
The parameter passed
(language used during start-up) will be used in one of the following
steps.public
class JS_ProjAssist_Project
extends JSBS_TaskFrame
{/*
*
-------------------------------
* Constructor of the class
*/public
JS_ProjAssist_Project(JSBS_StartFrame
parmCC){
super(parmCC); initialize_before_frame();
initialize_frame(); initialize_after_frame(); }
/*
*
-------------------------------
* Method with code to be
executed before the GUI is build */ private
void initialize_before_frame()
{ } /*
*
-------------------------------
* Method with code to
construct and display the GUI (Graphic User Interface) */private
void initialize_frame()
{
setVisible(true);
setSize(600,
400);/* Use
the standard GUI-layout (without currency-selection)
* as
defined in the inherited class (JSBS_StartFrame).
*/
setContentPane(get_pnl_Main()); } /*
*
-------------------------------
* Method with code to be
executed after the GUI is build */ private
void initialize_after_frame()
{
}}
Contrary
to the Command-Center (Start-Frame), this class does not have a
main() - method.
It
is undesired, to start a Task-Frame on its own as settings for the
whole application (a set of Task-Frames) are held in the
Command-Center and all Task-Frames are requested to access
them.
Therefore, a Task-Frame has to be started from the
Command-Center.
To
do so, uncomment the responsible line in the
class
.JS_ProjAssist_CommandCenter__ActionHandler
(See
Mandatory
steps for developing a Start-Frame | Reacting to the button-click and
open the Task-Frame where the lines had been commented out as the
class for the Task-Frame did not exist at that time.) *
-------------------------------
* Method to get the selected
code for the Business Task out of the entry-field
* and
call the frame with the chosen Business Task. */private
static void
openBusinessTask(JS_ProjAssist_CommandCenter parmCC){/* String
strInternalCode =
* Get
the internal code using a combined method that also fills the
parameter-fields.
* Instead of the parameter-fields,
'null'-values are passed to signal the method
* just to
return the internal code. */
parmCC.structJSBS_XML_Tasks.processParameterFields(parmCC.get_txt_Code(),
null,
null,
)null,
null, null,
null;/* Check
which button was clicked and call the appropriate method. */ if
(strInternalCode.equals("P"))
{ JS_ProjAssist_Project
frm_ }JS_ProjAssist_Project
= new
JS_ProjAssist_Project(parmCC); frm_
JS_ProjAssist_Project.setVisible(true); }
To
verify, run the application, enter 'P' at the Selection field
and click the button [ Continue ].
A
Task-Frame will open that looks like that:
There
is not text visible yet as the text is imported from a language
dependant external file.
That will be covered in the next step.
Define
the language dependant GUI-elements and add the code to display itThe
following step assumes, that the stardard layout (as defined in the
inherited class JSBS_TaskFrame)
should be used.
The
basic work to access an external file with the XML-structure was
already done with the Mandatdory
steps for developing a Start-Frame | Define the language dependent
GUI-elements and add the code to display it.
What
has to be done for a Task-Frame is,
to
copy the enhanced
XML-structure into the existing file 'DisplayStrings.xml' in
directory 'Text.en' and
to
add the code to load the GUI-elements with the language-specific
text.
private
void initialize_after_frame()
{/* Assign
the language dependent text to the GUI-elements. }
* The
method used is defined in the imported library JSBS_Base.
*/
JSBS_FrameServices.processLanguageDependantElements(this);
To
verify, run the application and you should get a frame like that:
You
might have realized that the file 'DisplayStrings.xml'
* Contains
definitions in the <CommonElements>
section.
This is wise, as those GUI-elements
are used mainly for every Task.
The
ToolTip-text was defined with the </FrameIndividual
section, as the guiding of a user is individual for each Task. >
*
Contains definitions for GUI-elements that do not already
exist.
Those elements are used only for the
Task 'Project' and are documented in the next step.
Define
the GUI-elements individual for the Task 'Project'As
you might have realised, till now there are no GUI-Elements within
the JPanel pnl_Entry
defined.
Those GUI-elements are individual for each Task-Frame.
To
save some space, the additional code of the class
(JS_ProjAssist_Project)
is not copied into this
document.
Please see the code following *
GUI-elements
individual for this Task. */
and
the code following *
Create the GUI-elements specific for this class.
Please
click onto the green text to follow the link to the complete
code.
After
typing the additional code (or better: copy & paste it),
run the application and you should get a frame like that:
Create
the Business Objects and the Database Access ObjectsThere
might be already Business Objects (BO) and Database Access (DBA)
Objects available for the Task you are working on which are waiting
only to be used ;-).
In an early phase of the development of an
application, however, it is unlikely that exactly the Business
Objects and DBA Objects you need now already exist.
As
developing Database Access Objects and Business Objects can be done
independent from GUI-Design, the Step-By-Step instructions are
described in a separate document. To get there, please follow
this link.
Implement
the Client-Side Business ObjectReact
to the 'Store' button and write to the databaseThe
following step assumes, that the class inherites from class
JSBS_StartFrame.
Otherwise,
the Interface ActionListener
has to be implemented.
A
more detailed description with screenshots how to react to a
button-click and handle an action are in the documents JS_FC01i
– Create and code the class for the 'Task-Frame to maintain
'Projects' and Base
lesson 2, step 2: Adding an action: selecting the file with the
SQL-commands.
As
discussed in the documents above, it is wise to create an extra class
for handling actions. In
catchwords:
* Right
click onto the package (js_projassist.clientframes
in our example) and select >New>Class.* Enter
the Package (xxx_project_xxx.clientframes)
and
the
(Class-)Name (XXX_Project_XXX_CommandCenter__ActionHandler).
* Make sure that no checkbox is selected and click the
[ Finish ] button.
Copy
the code from JS_ProjAssist_CommandCenter__ActionHandler
into the just created class.
As there are no classes for
the Task-Frames are defined now, some error will show.
Please
comment out the lines with the 'construction' of the
Task-Frame. private
void initialize_before_frame(String
parmstrLanguageCode) {/*
* Initialize
the structure with the set of parameters .
. . . . . . . . . .
That
the event can be handles, the following package has to be
imported:package
js_projassist.clientframes;
import
;java.awt.event.*import
js_base.frame.*;
import
js_base.structures.*;import
js_base.xml.*;
Finally,
a method actionPerformed(ActionEvent
e) must be defined in the class
JS_ProjAssist_CommandCenter.This
method is called when a button is clicked.
Its only function is
to call the method handleEvent()
in the just created class
and pass the parameter of class ActionEvent.JS_ProjAssist_CommandCenter__ActionHandler/*
*
-------------------------------
* Method that is triggered
when a button is clicked.
* This method overwrites the
method in the inherited class (JSBS_StartFrame). */ JS_ProjAssist_CommandCenter__ActionHandler.handleEvent(this,
e);public
void actionPerformed(ActionEvent e)
{
}
dummy
for copyingRelated
Documents: