Listing of Source ../source/GOF/GofEntryFieldIdentifier.javapackage se.entra.phantom.server;
import java.util.Vector;
/**
* This class identifies entry field controls for the Gui-on-the-fly, from unused GofHostFields.
* @author J. Bergström
*/
public class GofEntryFieldIdentifier extends GofControlIdentifierAdapter implements PhantomControlType
{
// ------------------
// INSTANCE VARIABLES
// ------------------
/**
* Indicates the way the entry field's layout will be created.
* Valid values are:
* <pre>
* DEFAULT
* FONT
* COLOR
* FONTANDCOLOR
* </pre>
*/
private String layout;
/**
* Filler character if there is one. Will be <code>null</code> otherwise.
*/
private String entryFieldFiller;
// ----------------
// INSTANCE METHODS
// ----------------
/**
* Loads setting for the control from the server ini-file.
* <p>
* This class has a setting that affects the look of the entry fields. This is the
* <code>entryfieldlayout</code> setting. Valid values for this setting are:
* <pre>
* entryfieldlayout=DEFAULT
* entryfieldlayout=FONT
* entryfieldlayout=COLOR
* entryfieldlayout=FONTANDCOLOR
* </pre>
* DEFAULT means that no settings are taken from the template panel, default values will be used.
* <p>
* FONT means that the font is taken from template panel, from an output text with the id=E, id=ER,
* id=ENL or id=ENR (depending on the host fields justification, and if the host field is numeric or not).
* If this control cannot be found, or if it is not an output text control, default values will
* be used.
* <p>
* COLOR means that the color is taken from template panel, from an output text with the id=E, id=ER,
* id=ENL or id=ENR (depending on the host fields justification, and if the host field is numeric or not).
* If this control cannot be found, or if it is not an output text control, default values will
* be used.
* <p>
* FONTANDCOLOR means that the font and color are taken from template panel, from an output text
* with the id=E, id=ER, id=ENL or id=ENR (depending on the host fields justification, and if the host
* field is numeric or not). If this control cannot be found, or if it is not an output text control,
* default values will be used.
* <p>
* Any other value will be treated as DEFAULT.
* <p>
* There is also a setting that specifies if there is a filler character to use, and what character
* this should be. This setting as called entryfieldfiller, and if the filler character is the
* underscore character, it would look like this:
* <pre>
* entryfieldfiller=_
* </pre>
* @param confFile The server ini file.
*/
@Override
public void getControlSettings( IniFile confFile, String subsection )
{
layout = confFile.getData( subsection, "entryfieldlayout" );
if( layout == null )
layout = "DEFAULT";
String setting = confFile.getData( subsection, "entryfieldfiller" );
if( setting != null && setting.equals( "" ) == false )
entryFieldFiller = setting;
else
entryFieldFiller = null;
}
/**
* This class takes every unused GofHostField that is not protected, and creates an
* entry field from it. It will check if the current GofHostField points to the same
* host field as the previous GofHostField. If so, this is a continuation of the
* previous one, and will not be created.
* @param gofRuntime The GuiOnTheFlyRuntime instance.
* @param areaIdentifier The areaIdentifier in which the entry fields should be identified..
* @param phantomHostScreen The Phantom host screen corresponding to the host screen.
* @param hostScreen The host screen that we are trying to build a GOF panel for.
* @param newPanel The newly created Gui-on-the-fly runtime panel.
* @param offsetX The offset in columns for popup window.
* @param offsetY The offset in lines for popup window.
*/
@Override
public void identifyCtrls( GuiOnTheFlyRuntime gofRuntime,
GofHostAreaIdentifier areaIdentifier,
PhantomHostScreen phantomHostScreen,
HostScreen hostScreen,
PhantomPanelData templPanel,
PhantomPanelData newPanel,
int offsetX,
int offsetY )
{
this.templPanel = templPanel;
Vector<GofHostField> gofHostFields = areaIdentifier.getAreasGofHostFields( );
GofHostField gofHostField = null, prevGofHostField = null;
boolean hasListCont = false;
Boolean b = ( Boolean )gofRuntime.getAttribute( "hasListCont" );
if( b != null )
hasListCont = b.booleanValue( );
int lastListLine = -1;
String listContMark = null;
if( hasListCont == true )
{
Object value;
value = gofRuntime.getAttribute( "lastListLine" );
if( value != null )
lastListLine = ( ( Integer )value ).intValue( );
listContMark = ( String )gofRuntime.getAttribute( "listContMark" );
}
hostFieldLoop:
for( int i = 0, s = gofHostFields.size( ); i < s; i++ )
{
prevGofHostField = gofHostField;
gofHostField = gofHostFields.elementAt( i );
if( gofHostField.hasBeenProcessed == false && gofHostField.isProtected( ) == false )
{
HostField hf = gofHostField.getHostField( );
boolean isCont = false;
if( prevGofHostField != null )
{
HostField prevHf = prevGofHostField.getHostField( );
if( hf.equals( prevHf ) )
isCont = true;
}
if( isCont == false )
{
int x = gofHostField.getX( );
int y = gofHostField.getY( );
int cx = gofHostField.getCx( );
if( hasListCont == true && y == lastListLine && listContMark.equals( gofHostField.getText( ) ) == true )
continue hostFieldLoop;
// Create the base control.
PhantomControlBase bc = new PhantomControlBase( GOF_MARGINX + ( x - offsetX ) * GOF_STEPX,
GOF_MARGINY + ( y - offsetY ) * GOF_STEPY,
cx * GOF_GUIUNITX,
GOF_GUIUNITY,
CTRLTYPE_INOUT );
// Create the PhantomHostField.
PhantomHostField phf = new PhantomHostField( phantomHostScreen, hostScreen, hf );
if( entryFieldFiller != null )
{
phf.filler = entryFieldFiller.charAt( 0 );
phf.flags = PhantomHostField.FORMAT_STRIPEND;
}
phantomHostScreen.addHostField( phf );
// Check the right justification of the field.
boolean isRJ = ( hf.justification == HostField.HFJ_RightZero || hf.justification == HostField.HFJ_RightBlank );
// Get layout parameters.
int font = -1;
int foregroundColor=-1;
int backgroundColor=-1;
PhantomControl templateControl;
if( hf.type == HostField.HFT_NumericOnly ||
hf.type == HostField.HFT_DigitsOnly ||
hf.type == HostField.HFT_SignedNumeric ||
hf.type == HostField.HFT_ImpliedDecimal ||
hf.type == HostField.HFT_NumericShift )
{
if( isRJ == true )
templateControl = templPanel.getControlFromID( "ENR" );
else
templateControl = templPanel.getControlFromID( "ENL" );
}
else if( isRJ == true )
templateControl = templPanel.getControlFromID( "ER" );
else
templateControl = templPanel.getControlFromID( "E" );
if( layout.equals( "FONT" ) )
{
if( templateControl != null && templateControl.controlBase.type == CTRLTYPE_OUT )
font = ( ( PhantomCEntryField )templateControl ).font;
}
else if( layout.equals( "COLOR" ) )
{
if( templateControl != null && templateControl.controlBase.type == CTRLTYPE_OUT )
{
foregroundColor = ( ( PhantomCEntryField )templateControl ).getForegroundColor();
backgroundColor = ( ( PhantomCEntryField )templateControl ).getBackgroundColor();
}
}
else if( layout.equals( "FONTANDCOLOR" ) )
{
if( templateControl != null && templateControl.controlBase.type == CTRLTYPE_OUT )
{
font = ( ( PhantomCEntryField )templateControl ).font;
foregroundColor = ( ( PhantomCEntryField )templateControl ).getForegroundColor();
backgroundColor = ( ( PhantomCEntryField )templateControl ).getBackgroundColor();
}
}
// Create the entry field.
PhantomCEntryField ef= new PhantomCEntryField( newPanel, bc, cx, isRJ, gofHostField.isHidden( ), phf );
ef.font = font;
ef.setForegroundColor(foregroundColor);
ef.setBackgroundColor(backgroundColor);
// Add the entry field.
newPanel.addControl( ef );
areaIdentifier.addControl( ef );
gofHostField.hasBeenProcessed = true;
}
}
}
}
}