org.vishia.mainGuiSwt
Class GuiPanelMng

java.lang.Object
  extended by org.vishia.mainGuiSwt.GuiPanelMng
All Implemented Interfaces:
GuiPanelMngBuildIfc, GuiPanelMngWorkingIfc

public class GuiPanelMng
extends java.lang.Object
implements GuiPanelMngBuildIfc, GuiPanelMngWorkingIfc

This class manages the building of a Dialog Box (Window) using a Java-AWT-container and Swing elements. The container can be visiblized as a part of another container of any window. An example is given in org.vishia.mainGui.SampleGui

The positions on the display does not based on pixel units. Instead, a grid is used. The grid-size (number of x- and y-pixel per grid unit) is able to set, so a more large or a more small representation of the graphic is shown, depending on the display point size, the distance to view or personal defaults.

A layout manager is not used. The user sets fix positions in the grid units. A grid unit is a half-small-line in the vertical direction and about a small character width in the x-direction. So a closed-to-user-thinking position is able to set for any component. It is like rows or lines and columns. An automatically layout managing using self-deciding positioning of any components is not done. But a next added component may be positioned right from the previous or below the previous without manually calculation and setting of the position. It simplifies.

This class supports setting of values of shown components with symbolic access (String-name) in runtime and selecting of button-actions and data-container while creating with symbolic access to the action-instance or the data-container. This property is used especially by the text-script-controlled built of a dialog widget using the GuiDialogZbnfControlled, but it is able to simplify the access to data and actions elsewhere too.








Nested Class Summary
protected  class GuiPanelMng.ButtonUserAction
          Action for user commands of buttons.
static class GuiPanelMng.GuiChangeReq
           
protected  class GuiPanelMng.MouseClickAction
          This action class supports the call of a user method while mouse-button.
 class GuiPanelMng.NotExistException
          The GUI may be determined by a external user file.
protected static interface GuiPanelMng.UserAction
          It is a marker interface.
 
Nested classes/interfaces inherited from interface org.vishia.mainGui.GuiPanelMngBuildIfc
GuiPanelMngBuildIfc.WidgetDescriptor<WidgetTYPE>
 
Field Summary
(package private)  boolean bBelow
          True if the next element should be placed below the last.
(package private)  boolean bRigth
          True if the next element should be placed below the last.
private  Composite currPanel
           
private  GuiDispatchCallbackWorker dispatchListener
          The dispatch listener should be included in the dispatch loop in the SWT-Thread.
(package private)  java.util.concurrent.ConcurrentLinkedQueue<GuiPanelMng.GuiChangeReq> guiChangeRequests
          Index of all Tables, which are representable.
private  java.util.Map<java.lang.String,GuiPanelMngBuildIfc.WidgetDescriptor<Control>> indexNameWidgets
          Index of all input fields to access symbolic.
private  LogMessage log
           
private  java.util.Map<java.lang.String,Composite> panels
          The container of the whole dialog window.
 PropertiesGuiSwt propertiesGui
          Properties of this Dialog Window.
private static long serialVersionUID
           
private  java.util.Map<java.lang.String,GuiPanelMngBuildIfc.WidgetDescriptor<Control>> showFields
          Index of all input fields to access symbolic.
(package private)  Table testTable
           
private  java.util.Map<java.lang.String,UserActionGui> userActions
          Index of all user actions, which are able to use in Button etc.
(package private)  int xPos
          Position of the next widget to add.
(package private)  int xPosPrev
          Position of the next widget to add.
(package private)  int yPos
          Position of the next widget to add.
(package private)  int yPosPrev
          Position of the next widget to add.
 
Constructor Summary
GuiPanelMng(Device device, int width, int height, char displaySize, LogMessage log)
          Creates an instance.
GuiPanelMng(int width, int height, PropertiesGuiSwt propertiesGui, LogMessage log)
          Creates an instance.
 
Method Summary
 Button addButton(java.lang.String sButtonText, int height, int width, java.lang.String sCmd, java.lang.String sUserAction, java.lang.String sName)
          Adss a button
 Canvas addCurveViewY(java.lang.String sName, int dyGrid, int dxGrid, int nrofXvalues, int nrofTracks)
          Adds a curve view for displaying values with ordinary x-coordinate.
 void addLine(int colorValue, float xa, float ya, float xe, float ye)
          Adds a line.
 java.lang.Object addMouseButtonAction(java.lang.String sName, java.lang.String sRegisteredUserAction, java.lang.String sCmdPress, java.lang.String sCmdRelease, java.lang.String sCmdDoubleClick)
          Adds a mouse click action (left button) to any widget.
 Table addTable(java.lang.String sName, int height, int[] columnWidths)
          Adds a table, which is able to scroll.
 Label addText(java.lang.String sText, char size, int color)
          Adds a simple text at the current position.
 Text addTextField(java.lang.String sName, int width, boolean editable, java.lang.String prompt, char promptStylePosition)
          Adds a edit field for editing a number value.
private  void furtherSetPosition(int dx, int dy)
          Sets the position for further add.. calls.
 java.lang.String getFieldContent(java.lang.String name)
          Gets the content of any field during operation.
 java.util.Set<java.util.Map.Entry<java.lang.String,GuiPanelMngBuildIfc.WidgetDescriptor<Control>>> getShowFields()
          Returns a Set of all fields, which are created to show.
 GuiDispatchCallbackWorker getTheGuiChangeWorker()
          The GUI-change-listener should be called in the dispatch-loop of the GUI-(SWT)-Thread.
 java.lang.String insertInfo(java.lang.String name, int ident, java.lang.String content)
          Inserts a textual information at any widget.
 void registerPanel(java.lang.String name, java.lang.Object panelP)
          Registers a panel to place the widgets.
 void registerUserAction(java.lang.String name, UserActionGui action)
          Registers all user actions, which are able to use in Button etc.
 void repaint()
           
 void selectPanel(java.lang.String sName)
          selects a registered panel for the next add-operations.
private  void setBounds_(Control component)
          Places a current component with knowledge of the current positions and the spreads of the component on graphic.
private  void setBounds_(Control component, int yGridSize, int xGridSize)
          Places a current component with knowledge of the current positions and the spreads of the component on graphic.
private  void setBounds_(Control component, int pyGrid, int pxGrid, int dyGrid, int dxGrid)
          Places a current component with knowledge of the current positions and the spreads of the component on graphic.
private  void setBounds_(Control component, Point size)
          Places a current component with knowledge of the current positions and the spreads of the component on graphic.
 void setColorGridCurveViewY(java.lang.String sName, int backgroundColor, int[] colorLines, char grid)
          Sets the appearance of the graphic respectively color and grid.
 java.lang.String setFieldContent(java.lang.String name, java.lang.String content)
          Sets the content of any field during operation.
 void setLineCurveView(java.lang.String sNameView, int trackNr, java.lang.String sNameLine, java.lang.String sVariable, int colorValue, int style, int nullLine, float yScale, float yOffset)
          Sets the values for a line
 void setNextPositionX()
          Positions the next widget below to the previous one.
 void setNextPositionY()
          Positions the next widget on the right next to the previous one.
 void setPosition(int ypos, int xpos)
          Sets the position for the next widget to add in the container.
 void setSampleCurveViewY(java.lang.String sName, float[] values)
          Adds a sampling value set.
protected  void windowClosing()
          This method can be override by the user to force some actions if the dialog window is closed.
 int xxxgetWidthLast()
          Returns the width (number of grid step horizontal) of the last element.
 void xxxregisterTableAccess(java.lang.String name, Table table)
          Registers all Tables, which are representable.
 void xxxsetWindowVisible()
          This method is able to call by the user anywhere to set a dialog window visible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

log

private final LogMessage log

panels

private final java.util.Map<java.lang.String,Composite> panels
The container of the whole dialog window.


currPanel

private Composite currPanel

propertiesGui

public final PropertiesGuiSwt propertiesGui
Properties of this Dialog Window.


xPos

int xPos
Position of the next widget to add. If some widgets are added one after another, it is similar like a flow-layout. But the position can be set.


yPos

int yPos
Position of the next widget to add. If some widgets are added one after another, it is similar like a flow-layout. But the position can be set.


xPosPrev

int xPosPrev
Position of the next widget to add. If some widgets are added one after another, it is similar like a flow-layout. But the position can be set.


yPosPrev

int yPosPrev
Position of the next widget to add. If some widgets are added one after another, it is similar like a flow-layout. But the position can be set.


bBelow

boolean bBelow
True if the next element should be placed below the last.


bRigth

boolean bRigth
True if the next element should be placed below the last.


indexNameWidgets

private final java.util.Map<java.lang.String,GuiPanelMngBuildIfc.WidgetDescriptor<Control>> indexNameWidgets
Index of all input fields to access symbolic.


showFields

private final java.util.Map<java.lang.String,GuiPanelMngBuildIfc.WidgetDescriptor<Control>> showFields
Index of all input fields to access symbolic.


userActions

private final java.util.Map<java.lang.String,UserActionGui> userActions
Index of all user actions, which are able to use in Button etc.


guiChangeRequests

java.util.concurrent.ConcurrentLinkedQueue<GuiPanelMng.GuiChangeReq> guiChangeRequests
Index of all Tables, which are representable.


testTable

Table testTable

dispatchListener

private final GuiDispatchCallbackWorker dispatchListener
The dispatch listener should be included in the dispatch loop in the SWT-Thread. It should be called any time if the Graphic is updated and cyclically too.

The run-method of this class is called one time in any dispatch loop process. It has to be returned immediately (not like the run-method of the thread), after it may be changed the graphic appearance. The graphic appearance is changed if any command is set in the guiChangeRequests-Queue, see

Constructor Detail

GuiPanelMng

public GuiPanelMng(Device device,
                   int width,
                   int height,
                   char displaySize,
                   LogMessage log)
Creates an instance.

Parameters:
guiContainer - The container where the elements are stored in.
width - in display-units for the window's width, the number of pixel depends from param displaySize.
height - in display-units for the window's height, the number of pixel depends from param displaySize.
displaySize - character 'A' to 'E' to determine the size of the content (font size, pixel per cell). 'A' is the smallest, 'E' the largest size. Default: use 'C'.

GuiPanelMng

public GuiPanelMng(int width,
                   int height,
                   PropertiesGuiSwt propertiesGui,
                   LogMessage log)
Creates an instance.

Parameters:
guiContainer - The container where the elements are stored in.
width - in display-units for the window's width, the number of pixel depends from param displaySize.
height - in display-units for the window's height, the number of pixel depends from param displaySize.
displaySize - character 'A' to 'E' to determine the size of the content (font size, pixel per cell). 'A' is the smallest, 'E' the largest size. Default: use 'C'.
Method Detail

registerPanel

public void registerPanel(java.lang.String name,
                          java.lang.Object panelP)
Registers a panel to place the widgets. The panel can be selected with its name calling the selectPanel(String) -Routine

Specified by:
registerPanel in interface GuiPanelMngBuildIfc
Parameters:
name - Name of the panel.
panel - The panel.

xxxsetWindowVisible

public void xxxsetWindowVisible()
This method is able to call by the user anywhere to set a dialog window visible. The dialog window may be existing and holds data, but it isn't visible, if the dialog isn't activate. s


windowClosing

protected void windowClosing()
This method can be override by the user to force some actions if the dialog window is closed. It may be left empty.


registerUserAction

public void registerUserAction(java.lang.String name,
                               UserActionGui action)
Registers all user actions, which are able to use in Button etc. The name is related with the userAction= designation in the configuration String.

Specified by:
registerUserAction in interface GuiPanelMngBuildIfc
Parameters:
name -
action -

xxxregisterTableAccess

public void xxxregisterTableAccess(java.lang.String name,
                                   Table table)
Registers all Tables, which are representable.


selectPanel

public void selectPanel(java.lang.String sName)
selects a registered panel for the next add-operations.

Specified by:
selectPanel in interface GuiPanelMngBuildIfc

setPosition

public void setPosition(int ypos,
                        int xpos)
Sets the position for the next widget to add in the container.

Specified by:
setPosition in interface GuiPanelMngBuildIfc
Parameters:
xpos - x-Position in x-Units, count from left of the box.
ypos - y-Position in y-Units, count from top of the box. It is the bottom line of the widget. It means ypos = 0 is not a proper value. To show a text in the first line, use y=2.

setNextPositionX

public void setNextPositionX()
Positions the next widget below to the previous one.

Specified by:
setNextPositionX in interface GuiPanelMngBuildIfc

setNextPositionY

public void setNextPositionY()
Positions the next widget on the right next to the previous one.


xxxgetWidthLast

public int xxxgetWidthLast()
Returns the width (number of grid step horizontal) of the last element.

Returns:
Difference between current auto-position and last pos.

setBounds_

private void setBounds_(Control component)
Places a current component with knowledge of the current positions and the spreads of the component on graphic.

Parameters:
component - The component to place.

setBounds_

private void setBounds_(Control component,
                        Point size)
Places a current component with knowledge of the current positions and the spreads of the component on graphic.

Parameters:
component - The component to place.

setBounds_

private void setBounds_(Control component,
                        int yGridSize,
                        int xGridSize)
Places a current component with knowledge of the current positions and the spreads of the component on graphic.

Parameters:
component - The component to place.

setBounds_

private void setBounds_(Control component,
                        int pyGrid,
                        int pxGrid,
                        int dyGrid,
                        int dxGrid)
Places a current component with knowledge of the current positions and the spreads of the component on graphic.

Parameters:
component - The component to place.
diff - movement of the placement in dedicated pixel units, usefull for example to place a table head and body. It may be null.

furtherSetPosition

private void furtherSetPosition(int dx,
                                int dy)
Sets the position for further add.. calls.

Parameters:
dx -
dy -

addText

public Label addText(java.lang.String sText,
                     char size,
                     int color)
Description copied from interface: GuiPanelMngBuildIfc
Adds a simple text at the current position.

Specified by:
addText in interface GuiPanelMngBuildIfc
Parameters:
sText - The text
size - size, 'A' is small ...'E' is large.
color - The color as RGB-value in 3 Byte. 0xffffff is white, 0xff0000 is red.
Returns:

addTextField

public Text addTextField(java.lang.String sName,
                         int width,
                         boolean editable,
                         java.lang.String prompt,
                         char promptStylePosition)
Adds a edit field for editing a number value.

Specified by:
addTextField in interface GuiPanelMngBuildIfc
Parameters:
sName - The register name
width - Number of grid units for length
editable - true than edit-able, false to show content
prompt - If not null, than a description label is shown
promptStylePosition - Position and size of description label: upper case letter: normal font, lower case letter: small font 'l' left, 't' top (above field)
Returns:

addLine

public void addLine(int colorValue,
                    float xa,
                    float ya,
                    float xe,
                    float ye)
Adds a line.

To adding a line is only possible if the current panel is of type CanvasStorePanel. This class stores the line coordinates and conditions and draws it as background if drawing is invoked.

Specified by:
addLine in interface GuiPanelMngBuildIfc
Parameters:
colorValue - The value for color, 0xffffff is white, 0xff0000 is red.
xa - start of line relative to current position in grid units. The start is relative to the given position! Not absolute in window!
ya - start of line relative to current position in grid units.
xe - end of line relative to current position in grid units.
ye - end of line relative to current position in grid units.

addButton

public Button addButton(java.lang.String sButtonText,
                        int height,
                        int width,
                        java.lang.String sCmd,
                        java.lang.String sUserAction,
                        java.lang.String sName)
Description copied from interface: GuiPanelMngBuildIfc
Adss a button

Specified by:
addButton in interface GuiPanelMngBuildIfc
Parameters:
sButtonText - text in the button
height - in grid-units
width - in grid-unigs
sCmd - The command string will be transfered to the action-method
sUserAction - The user action shoult be registered before calling GuiPanelMngBuildIfc.registerUserAction(String, UserActionGui)
Returns:

addCurveViewY

public Canvas addCurveViewY(java.lang.String sName,
                            int dyGrid,
                            int dxGrid,
                            int nrofXvalues,
                            int nrofTracks)
Description copied from interface: GuiPanelMngBuildIfc
Adds a curve view for displaying values with ordinary x-coordinate. The scaling of the curve view is set to -100..100 per default.

Specified by:
addCurveViewY in interface GuiPanelMngBuildIfc
Parameters:
sName - Its registered name
dyGrid - height in grid-units
dxGrid - width in grid-units
nrofXvalues - depth of the buffer for x-values. It should be 6..20 times of dx.
nrofTracks - number of curves (tracks).
Returns:
The Canvas Object.

addMouseButtonAction

public java.lang.Object addMouseButtonAction(java.lang.String sName,
                                             java.lang.String sRegisteredUserAction,
                                             java.lang.String sCmdPress,
                                             java.lang.String sCmdRelease,
                                             java.lang.String sCmdDoubleClick)
Adds a mouse click action (left button) to any widget. It is able to apply especially for widget without mouse handling, for example geometric figures all a canvas area. It should not be applied to a widget which has a special handling for mouse buttons already.

The first parameter of user action will be called with

addTable

public Table addTable(java.lang.String sName,
                      int height,
                      int[] columnWidths)
Description copied from interface: GuiPanelMngBuildIfc
Adds a table, which is able to scroll.

Specified by:
addTable in interface GuiPanelMngBuildIfc
Parameters:
sName - register name, used for GuiPanelMngWorkingIfc.insertInfo(String, int, String).
height - The height in grid units for the appearance
columnWidths - Array with width of the columns. Each column has a fix default width per construction. It may or may not a fix widht, it may able to change by mouse actions, adequate to the possibilities of the used graphic base system.
Returns:

repaint

public void repaint()
Specified by:
repaint in interface GuiPanelMngBuildIfc

setFieldContent

public java.lang.String setFieldContent(java.lang.String name,
                                        java.lang.String content)
                                 throws GuiPanelMng.NotExistException
Sets the content of any field during operation. The GUI should be created already.

Parameters:
name - Name of the field, corresponding with the name-designation of the field in the configuration.
content - The new content.
Returns:
The old content of the field. throws GuiDialogZbnfControlled.NotExistException if the field with the given name isn't found.
Throws:
GuiPanelMng.NotExistException

insertInfo

public java.lang.String insertInfo(java.lang.String name,
                                   int ident,
                                   java.lang.String content)
Inserts a textual information at any widget. The widget may be for example: The insertion is written into a queue, which is red in another thread. It may be possible too, that the GUI is realized in another module, maybe remote. It means, that a few milliseconds should be planned before the change appears. If the thread doesn't run or the remote receiver isn't present, than the queue may be overflowed or the request may be lost.

Specified by:
insertInfo in interface GuiPanelMngWorkingIfc
Parameters:
name - The name of the widget, which was given by the add...()-Operation
ident - A identifying number. It meaning depends on the kind of widget. 0 means, insert on top. Integer.MAXVALUE means, insert after the last element (append).
content - The content to insert.
Returns:

getFieldContent

public java.lang.String getFieldContent(java.lang.String name)
                                 throws GuiPanelMng.NotExistException
Gets the content of any field during operation. The GUI should be created already.

Parameters:
name - Name of the field, corresponding with the name-designation of the field in the configuration.
Returns:
The content of the field. throws GuiDialogZbnfControlled.NotExistException if the field with the given name isn't found.
Throws:
GuiPanelMng.NotExistException

getShowFields

public java.util.Set<java.util.Map.Entry<java.lang.String,GuiPanelMngBuildIfc.WidgetDescriptor<Control>>> getShowFields()
Returns a Set of all fields, which are created to show.

Specified by:
getShowFields in interface GuiPanelMngBuildIfc
Returns:
the set, never null, possible an empty set.

getTheGuiChangeWorker

public GuiDispatchCallbackWorker getTheGuiChangeWorker()
The GUI-change-listener should be called in the dispatch-loop of the GUI-(SWT)-Thread.

Specified by:
getTheGuiChangeWorker in interface GuiPanelMngBuildIfc
Returns:
The instance to call run(). Hint: run() returns after checking orders and should be called any time in the loop.

setSampleCurveViewY

public void setSampleCurveViewY(java.lang.String sName,
                                float[] values)
Description copied from interface: GuiPanelMngWorkingIfc
Adds a sampling value set.

Specified by:
setSampleCurveViewY in interface GuiPanelMngWorkingIfc
Parameters:
sName - The registered name
values - The values.

setColorGridCurveViewY

public void setColorGridCurveViewY(java.lang.String sName,
                                   int backgroundColor,
                                   int[] colorLines,
                                   char grid)
Description copied from interface: GuiPanelMngBuildIfc
Sets the appearance of the graphic respectively color and grid.

Specified by:
setColorGridCurveViewY in interface GuiPanelMngBuildIfc
Parameters:
sName - The registered name
backgroundColor - The color of the background
colorLines - Array of color values for the lines. Any value should be given as red-green-blue value in 24 bit. Additionally
  • bit24,25, is the thickness of the line.
grid - character to determine how the grid is shown. '0' no grid, 'a'..'f' weak to strong.

setLineCurveView

public void setLineCurveView(java.lang.String sNameView,
                             int trackNr,
                             java.lang.String sNameLine,
                             java.lang.String sVariable,
                             int colorValue,
                             int style,
                             int nullLine,
                             float yScale,
                             float yOffset)
Description copied from interface: GuiPanelMngBuildIfc
Sets the values for a line

Specified by:
setLineCurveView in interface GuiPanelMngBuildIfc
yScale - This value is that value, which is shown in a 10%-difference in the output window.
yOffset - This value will be subtract from the input values before scale. It is the 0-line-reference of the input values.