public class GComponent extends Object implements MouseWheelListener
Modifier and Type | Class and Description |
---|---|
static class |
GComponent.CopyPasteOperation
Enum of the available copy-paste operations.
|
protected static class |
GComponent.DisplayIndicatorStatus
Enum to determine if the ismModifiedIndicator shall be displayed: always, never, automatic.
|
static class |
GComponent.ItemType
Enum represeting the type of items that can be saved in a configuration file.
|
static class |
GComponent.Operation
Enum to determine the operation that shall be performed by the put method.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
NAME_ATTRIBUTE
String constant.
|
Modifier | Constructor and Description |
---|---|
|
GComponent()
Constructor by default
|
protected |
GComponent(String widgetId)
Creates a component with the corresponding widgetId, if the widgetId is null, it will be
created automatically.
|
Modifier and Type | Method and Description |
---|---|
protected void |
activateConstraintsByType(Class<?> className)
Switch method to activate the functionality to set constraints by class for a given class.
Example: To set a width of 500 to the GRealField of all the GEntryReals in current panel: setClassConstraint(GEntryReal.class, 1, new GConstraint(GConstraint.width(500))); |
void |
attachCopyPasteMenu()
Attach the copy and paste menu to this component.
|
void |
attachCopyPasteMenu(String label,
GComponent.CopyPasteOperation... operationList)
Attach the copy and paste menu to this component.
|
protected void |
beginOfElement(GItemTypeInterface type,
String name)
Begins an XML structural element of a given type and with a given name when loading/saving to
the configuration file.
|
protected void |
beginOfElement(GItemTypeInterface type,
String name,
Boolean allowWriteComment)
Begins an XML structural element of a given type and with a given name when loading/saving to
the configuration file.
|
protected void |
beginOfElement(String type,
String name)
Begins an XML structural element of a given type and with a given name when loading/saving to
the configuration file.
|
protected void |
beginOfElement(String type,
String name,
Boolean allowWriteComment)
Begins an XML structural element of a given type and with a given name when loading/saving to
the configuration file.
|
void |
clearAllInnerDescendantConstraint()
Method to clear the constraints for a given component and all its sub-components recursively.
|
void |
clearConstraint()
Clears the constraint for the component.
|
void |
clearInnerDescendantContraint(int... positionList)
Clears the constraint of the inner subcomponent.
|
protected String |
composeWidgetId(String finalWidgetId)
Compose the widget id by adding ".
|
void |
doDisplay(GComponent component)
Perform the display of the internal component.
|
protected void |
endOfElement()
Ends an element, previously generated with beginOfElement, when loading/saving to file.
|
String |
getCommentInConfigFile()
Gets the comment to be set in the configuration file.
|
Component |
getComponent()
Returns the low level Swing Component encapsulated by the class if any, otherwise returns
null.
|
GConstraint |
getConstraint()
Return the current component constraint.
|
protected static GComponent.Operation |
getCurrentOperation()
Gets the current skeleton index.
|
GComponent.DisplayIndicatorStatus |
getDisplayIndicatorStatus()
Get the display indicator status.
|
boolean |
getDisplayIsModifiedIndicator()
Get the displayIsModifiedIdicator.
|
org.jdom.Element |
getElement()
Gets the XML DOM element that will be used to store/load the component value from file.
|
String |
getGClassName()
Method to get the class name scaping the "$" character for the internal classes.
|
GPanel |
getGPanel()
Gets the current panel containing the component.
|
GComponent |
getGParent()
Get the component that is the parent of this component.
|
GUnit |
getGUnitInConfigFile()
Gets the GUnit to use to save the component in the configuration file.
|
GConstraint |
getInnerDescendantConstraint(Integer... positionList)
Get the constraint of the inner subcomponent.
|
String |
getName()
Get the name of the component at Swing level, if no Swing component is assigned to this
GComponent then the class name is returned.
|
String |
getNameInConfigFile()
Get the name to be used when saving the component in the configuration file.
|
protected static boolean |
getOperationSaveValue()
Gets the boolean indicating if the operation shall update the saved not.
|
String |
getPathInConfigFile()
Get the path of current component respect to the configuration file structure
|
String |
getSimpleWidgetId()
Get the last part of the Swing name (identifier) of the component (after last ".").
|
GIntervalAbstract.GStatus |
getStatus()
Get the status of the widget.
|
String |
getStringConstraint()
Return the current component constraint.
|
GComponent |
getSubComponent(int position)
Gets the subcomponent occupying the position defined by position.
|
String |
getWidgetId()
Get the Swing name (identifier) of the component, no Swing component is encapsulated then
null is returned.
|
protected boolean |
handleCopyPasteEvent(GComponent copyPasteMenuComponent,
GComponent componentToBeHandled,
GEvent event)
Handles the copy-paste event if possible.
|
protected boolean |
handleCopyPasteEvent(GComponent copyPasteMenuComponent,
GEvent event)
Handles the copy-paste event if possible.
|
protected static void |
handleProcessEventException(GException ex)
Show the exception dialog to display an exception.
|
GComponent.CopyPasteOperation |
isCopyPasteEvent(GEvent event)
Checks if the event corresponds to one of the copy and paste menu operations.
|
boolean |
isEnabled()
Gets the enable status of the widget.
|
GIntervalAbstract.GStatus |
isForcedStatus()
Returns the forced status, null if undefined.
|
boolean |
isModified()
Gets the modification status of the component against the last set of values loaded or saved.
|
protected void |
launchInvalidPositionException(int position)
Launch an invalid position exception.
|
void |
mouseWheelMoved(MouseWheelEvent e) |
static String |
parseSimpleConstraint(String simpleConstraint,
String prevConstraint)
Parse a new simple constraint in string format.
|
protected static void |
processGEvent(GEvent event,
GComponent source)
Process an event generated by a descendant component.
|
void |
processMouseWheelEvent(MouseWheelEvent e)
Allows the user to scroll while the mouse cursor is on the panel and not exclusively when the
cursor is on the scrollbar.
|
void |
setBusyCursor(boolean flag)
Set or clear the busy mouse cursor for the component.
|
void |
setCommentInConfigFile(String comment)
Sets the comment to be set in the configuration file.
|
void |
setConstraint(GConstraint constraint)
Set the constraint for the component.
|
void |
setCopyPasteMenuEnabled(boolean flag)
Set the enable status of the copy-paste menu associated to the component.
|
protected static void |
setCurrentOperation(GComponent.Operation operation,
boolean operationSaveValue)
Sets the value of the current operation.
|
protected void |
setDataForConstraintsByType(Class<?> ownerClass,
Integer... positionArray)
Setter for the father type and the subcomponent rank into the father type for constraints by
class.
Example: To set a width of 500 to the GTextField of all the GEntryReals in current panel: setClassConstraint(GEntryReal.class, 1, new GConstraint(GConstraint.width(1000))); In order to make this possible, GTextField in its doDiplay must know that it is a part of a GEntryReal, and that it is the subcomponent "1" of the GEntryReal. |
protected void |
setDefaultConstraints()
Set default constraints.
|
void |
setDisplayIsModifiedIndicator(GComponent.DisplayIndicatorStatus displayIndicatorStatus)
Activates the display of the isModified indicator.
|
void |
setElement(org.jdom.Element element)
Sets the XML DOM element that will be used to store/load the component value from file.
|
void |
setEnabled(boolean flag)
Set the enable status of the component.
|
void |
setForcedStatus(GIntervalAbstract.GStatus forcedStatus)
Set the forced status.
|
void |
setGPanel(GPanel panel)
Sets the current panel containing the component.
|
void |
setGParent(GComponent parent)
Sets the component that is the parent of this component.
|
void |
setGUnitInConfigFile(GUnit unit)
Sets the GUnit to use to save the component in the configuration file.
|
void |
setInnerDescendantConstraint(GConstraint constraint,
Integer... positionList)
Set the constraint of the inner subcomponent.
|
void |
setName()
Set the Swing name (identifier) of the component to the widgetId.
|
protected void |
setNameAndCommentInConfigFile(String text)
Sets the name and the comment of the item in the configuration file.
|
void |
setNameInConfigFile(String name)
Sets the name to be used when saving the component in the configuration file.
|
void |
setPathInConfigFile(String path)
Sets the Path to be used when saving the component in the configuration file.
|
protected void |
setStatus(GIntervalAbstract.GStatus status)
Set the status of the widget.
|
void |
setStringConstraint(String simpleConstraint)
Set the constraint in string format for the component.
|
void |
setToolTipText(String text)
Empty method to be overwrite by the components at a higher level if needed.
|
void |
setWidgetId(String widgetId)
Sets the widget identifier of the component.
|
protected boolean |
setWidth(Integer minWidth,
Integer preferredWidth,
Integer maxWidth)
Method to modify the width of a GComponent.
|
static void |
setWindowBusyCursor(boolean flag,
GComponent component) |
protected void |
updateIsModifiedIndicator()
Updates the isModified indicator, this method shall be overwritten by the child classes that
need to.
|
protected org.jdom.Element |
writeCollection(org.jdom.Element parentElement,
GItemTypeInterface type,
String name,
Map<String,String> attributes)
Writes a collection to the configuration file.
|
protected org.jdom.Element |
writeCollection(org.jdom.Element parentElement,
GItemTypeInterface type,
String name,
Map<String,String> attributes,
Boolean allowWriteComment)
Writes a collection to the configuration file.
|
protected org.jdom.Element |
writeCollection(org.jdom.Element parentElement,
String type,
String name,
Map<String,String> attributes,
Boolean allowWriteComment)
Deprecated.
The argument type should be an enum implementing the interface GItemTypeInterface
instead of a String. See
GItemTypeInterface for more details. |
protected org.jdom.Element |
writeCollection(GItemTypeInterface type,
String name,
Map<String,String> attributes)
Writes a collection to the configuration file.
|
protected org.jdom.Element |
writeConfigItem(org.jdom.Element parentElement,
GItemTypeInterface type,
String name,
String value,
Map<String,String> attributes)
Writes the values of an item in the configuration file.
|
protected org.jdom.Element |
writeConfigItem(org.jdom.Element parentElement,
GItemTypeInterface type,
String name,
String value,
Map<String,String> attributes,
Boolean allowWriteComment)
Writes the values of an item in the configuration file.
|
protected org.jdom.Element |
writeConfigItem(org.jdom.Element parentElement,
String type,
String name,
String value,
Map<String,String> attributes,
Boolean allowWriteComment)
Deprecated.
The argument type should be an enum implementing the interface GItemTypeInterface
instead of a String. See
GItemTypeInterface for more details. |
protected void |
writeConfigItem(GItemTypeInterface type,
String value,
Map<String,String> attributes)
Writes the values of an item in the configuration file.
|
protected void |
writeConfigItem(GItemTypeInterface type,
String value,
Map<String,String> attributes,
Boolean allowWriteComment)
Writes the values of an item in the configuration file.
|
protected static final String NAME_ATTRIBUTE
public GComponent()
protected GComponent(String widgetId)
widgetId
- identifier of the widget.public GComponent getSubComponent(int position) throws GComponentException
position
- position of the requested component.GComponentException
- in case the position argument is invalid.public GConstraint getInnerDescendantConstraint(Integer... positionList)
positionList
- the ordered subcomponent index.public void setInnerDescendantConstraint(GConstraint constraint, Integer... positionList)
constraint
- constraint to set.positionList
- the ordered subcomponent index.public void attachCopyPasteMenu()
public void attachCopyPasteMenu(String label, GComponent.CopyPasteOperation... operationList)
label
- of the copy&paste menu, if null no label is displayed.operationList
- list of operations to set in the menu. Valid values are Copy if the
"Copy" menu is available, Paste if the "Paste" menu is available, Import if the
"Import" menu is available, and Export if the "Export" menu is available.public GComponent.CopyPasteOperation isCopyPasteEvent(GEvent event)
event
- to check.protected boolean handleCopyPasteEvent(GComponent copyPasteMenuComponent, GEvent event) throws GFileManipulatorException
copyPasteMenuComponent
- component that has the attached copy-paste menu.event
- to be processed.GFileManipulatorException
- in case the copy-paste operation raises an exception.protected boolean handleCopyPasteEvent(GComponent copyPasteMenuComponent, GComponent componentToBeHandled, GEvent event) throws GFileManipulatorException
copyPasteMenuComponent
- component that has the attached copy-paste menu.componentToBeHandled
- the component to be copied/pasted/imported/exported.event
- to be processed.GFileManipulatorException
- in case the copy-paste operation raises an exception.public Component getComponent()
public void setName()
public String getName()
public void setWidgetId(String widgetId)
widgetId
- the widget identifier of the component.protected String composeWidgetId(String finalWidgetId)
finalWidgetId
- chain to be added to the widget id.public final String getWidgetId()
public String getSimpleWidgetId()
protected void setStatus(GIntervalAbstract.GStatus status)
status
- the new status of the widget.public GIntervalAbstract.GStatus getStatus()
public void setForcedStatus(GIntervalAbstract.GStatus forcedStatus)
To remove forced status, call ##setForcedStatus(null)
.
Warning: once status has been forced, in order to update status, a call to updateStatus() should be performed.
forcedStatus
- the new forced statuspublic GIntervalAbstract.GStatus isForcedStatus()
public void setBusyCursor(boolean flag)
flag
- if true the busy cursor is set for the component, otherwise it is cleared.public static void setWindowBusyCursor(boolean flag, GComponent component)
flag
- if true change the cursorcomponent
- defining the change of the cursorprotected static void setCurrentOperation(GComponent.Operation operation, boolean operationSaveValue)
operation
- new value of the current operation.operationSaveValue
- true if the operation shall updated the saved values.protected static GComponent.Operation getCurrentOperation()
protected static boolean getOperationSaveValue()
public void setGPanel(GPanel panel)
panel
- containing the component.public GPanel getGPanel()
public void setGParent(GComponent parent)
parent
- the component that is the parent of this component.public GComponent getGParent()
protected void setDefaultConstraints()
public void clearConstraint()
public void clearInnerDescendantContraint(int... positionList)
positionList
- the ordered subcomponent index.public void clearAllInnerDescendantConstraint()
public void setConstraint(GConstraint constraint)
constraint
- constraint to set for the component.public void setStringConstraint(String simpleConstraint)
simpleConstraint
- constraint in string format to set for the component.public static String parseSimpleConstraint(String simpleConstraint, String prevConstraint)
simpleConstraint
- constraint to be parsedprevConstraint
- previous constraintpublic GConstraint getConstraint()
public String getStringConstraint()
public void doDisplay(GComponent component)
component
- to be displayed.protected static void processGEvent(GEvent event, GComponent source)
event
- to be treated.source
- of the event.protected static void handleProcessEventException(GException ex)
ex
- exception to display.public void setPathInConfigFile(String path)
path
- to be used when saving the component in the configuration file.public void setNameInConfigFile(String name)
name
- to be used when saving the component in the configuration file.public String getNameInConfigFile()
public String getPathInConfigFile()
public void setGUnitInConfigFile(GUnit unit)
unit
- to use to save the component in the configuration file.public void setToolTipText(String text)
text
- to set in the tooltip.public GUnit getGUnitInConfigFile()
public void setCommentInConfigFile(String comment)
comment
- to be set in the configuration file.public String getCommentInConfigFile()
protected void setNameAndCommentInConfigFile(String text)
text
- to be used for the name and the comment of the item in the configuration file.public void setElement(org.jdom.Element element)
element
- that will be used to store/load the component value from file.public org.jdom.Element getElement()
protected void beginOfElement(String type, String name) throws GException
beginOfElement(GItemTypeInterface, String, Boolean)
if you want to avoid it.type
- of the XML structure item.name
- attribute of the XML structure item.GException
- in case that the element is not found when reading from the configuration
file.protected void beginOfElement(String type, String name, Boolean allowWriteComment) throws GException
setCommentInConfigFile(String)
and if the comment is different to the item name.type
- of the XML structure item.name
- attribute of the XML structure item.allowWriteComment
- flag to allow writing or not the item comment in the configuration
file.GException
- in case that the element is not found when reading from the configuration
file.protected void beginOfElement(GItemTypeInterface type, String name, Boolean allowWriteComment) throws GException
setCommentInConfigFile(String)
and if the comment is different to the item name.type
- of the XML structure item.name
- attribute of the XML structure item.allowWriteComment
- flag to allow writing or not the item comment in the configuration
file.GException
- in case that the element is not found when reading from the configuration
file.protected void beginOfElement(GItemTypeInterface type, String name) throws GException
beginOfElement(GItemTypeInterface, String, Boolean)
if you want to avoid it.type
- of the XML structure item.name
- attribute of the XML structure item.GException
- in case that the element is not found when reading from the configuration
file.protected void endOfElement()
protected org.jdom.Element writeCollection(GItemTypeInterface type, String name, Map<String,String> attributes)
setCommentInConfigFile(String)
and if the comment is different to the item name.type
- of element.name
- of the element.attributes
- of the element.protected org.jdom.Element writeCollection(org.jdom.Element parentElement, GItemTypeInterface type, String name, Map<String,String> attributes)
setCommentInConfigFile(String)
and if the comment is different to the item name.parentElement
- element parent of this one.type
- of element.name
- of the element.attributes
- of the element.protected org.jdom.Element writeCollection(org.jdom.Element parentElement, GItemTypeInterface type, String name, Map<String,String> attributes, Boolean allowWriteComment)
setCommentInConfigFile(String)
and if the comment is different to the item
name.parentElement
- element parent of this one.type
- of element.name
- of the element.attributes
- of the element.allowWriteComment
- flag to allow writing or not the item comment in the configuration
file.@Deprecated protected org.jdom.Element writeCollection(org.jdom.Element parentElement, String type, String name, Map<String,String> attributes, Boolean allowWriteComment)
GItemTypeInterface
for more details.setCommentInConfigFile(String)
and if the comment is different to the item
name.parentElement
- element parent of this one.type
- of element.name
- of the element.attributes
- of the element.allowWriteComment
- flag to allow writing or not the item comment in the configuration
file.@Deprecated protected org.jdom.Element writeConfigItem(org.jdom.Element parentElement, String type, String name, String value, Map<String,String> attributes, Boolean allowWriteComment)
GItemTypeInterface
for more details.setCommentInConfigFile(String)
and if the comment is different to
the item name.parentElement
- element parent of this one.type
- of element.name
- of the element.value
- of the element.attributes
- of the element.allowWriteComment
- flag to allow writing or not the item comment in the configuration
file.protected org.jdom.Element writeConfigItem(org.jdom.Element parentElement, GItemTypeInterface type, String name, String value, Map<String,String> attributes, Boolean allowWriteComment)
setCommentInConfigFile(String)
and if the comment is different to
the item name.parentElement
- element parent of this one.type
- of element.name
- of the element.value
- of the element.attributes
- of the element.allowWriteComment
- flag to allow writing or not the item comment in the configuration
file.protected org.jdom.Element writeConfigItem(org.jdom.Element parentElement, GItemTypeInterface type, String name, String value, Map<String,String> attributes)
setCommentInConfigFile(String)
and if the comment is different to the item name.parentElement
- element parent of this one.type
- of element.name
- of the element.value
- of the element.attributes
- of the element.protected void writeConfigItem(GItemTypeInterface type, String value, Map<String,String> attributes, Boolean allowWriteComment) throws GException
setCommentInConfigFile(String)
and if the comment is different to the item name.type
- of element.value
- of the element.attributes
- of the element.allowWriteComment
- flag to allow writing or not the item comment in the configuration
file.GException
- if the element can not be created because its "name in configuration" is
empty.protected void writeConfigItem(GItemTypeInterface type, String value, Map<String,String> attributes) throws GException
setCommentInConfigFile(String)
and if the comment is different to the item name.type
- of element.value
- of the element.attributes
- of the element.GException
- if the element can not be created because its "name in configuration" is
empty.public boolean isEnabled()
public void setEnabled(boolean flag)
flag
- new enable status of the component.public void setCopyPasteMenuEnabled(boolean flag)
flag
- new enable status.public GComponent.DisplayIndicatorStatus getDisplayIndicatorStatus()
public void setDisplayIsModifiedIndicator(GComponent.DisplayIndicatorStatus displayIndicatorStatus)
displayIndicatorStatus
- if Always the modifiedStatusIndicator is always shown, if Never
the modifiedStatusIndicator is never shown, if Automatic the modifiedStatusIndicator
is shown as needed.protected void updateIsModifiedIndicator()
public boolean getDisplayIsModifiedIndicator()
public boolean isModified()
protected void launchInvalidPositionException(int position) throws GComponentException
position
- invalid position.GComponentException
- in case the subcomponent position is invalid.protected void setDataForConstraintsByType(Class<?> ownerClass, Integer... positionArray)
setClassConstraint(GEntryReal.class, 1, new GConstraint(GConstraint.width(1000)));
ownerClass
- the class object that represents the father component.positionArray
- array representing the position of this component into the owner class.protected void activateConstraintsByType(Class<?> className)
setClassConstraint(GEntryReal.class, 1, new GConstraint(GConstraint.width(500)));
className
- The Class object that represents the runtime class of this object.protected boolean setWidth(Integer minWidth, Integer preferredWidth, Integer maxWidth)
minWidth
- minimum allowed width for the component. It prevails over the applying
"width" constraint.preferredWidth
- width of the component when no constraint is given.maxWidth
- maximum allowed width for the component. It prevails over the applying
"width" constraint.public String getGClassName()
public void mouseWheelMoved(MouseWheelEvent e)
mouseWheelMoved
in interface MouseWheelListener
e
- eventpublic void processMouseWheelEvent(MouseWheelEvent e)
e
- eventCopyright © 2024. All rights reserved.