AnyLogic AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, java.io.Serializable, java.lang.Cloneable

public class ShapeFileChooser
extends ShapeInputControl
File chooser control. Embeds a JPanel with JTextField and JButton.
This object is only available in the AnyLogic Professional
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Nested Class Summary

Nested Classes 
static class  ShapeFileChooser.Type
File chooser type constants
Modifier and Type Class Description

Nested classes/interfaces inherited from class com.anylogic.engine.presentation.ShapeControl

ShapeControl.ValueType

Field Summary

Fields 
static ShapeFileChooser.Type TYPE_DOWNLOAD  
static ShapeFileChooser.Type TYPE_UPLOAD  
java.lang.String value
Returns the currently selected file name (or empty string if no file selected) that can be accessed in the overridden action() method.
Use getValue() to obtain the currently selected file name from other places
Modifier and Type Field Description

Fields inherited from class com.anylogic.engine.presentation.ShapeControl

TYPE_DOUBLE, TYPE_INT, TYPE_STRING

Fields inherited from class com.anylogic.engine.presentation.Shape

UNKNOWN_NAME

Constructor Summary

Constructors 
ShapeFileChooser​(Presentable p, boolean ispublic, double x, double y, double width, double height, java.awt.Color backgroundColor, java.awt.Color textColor, boolean enabled, java.awt.Font font, java.lang.String title, ShapeFileChooser.Type type, java.lang.String fileTypes, java.lang.String value)
Creates a file chooser control.
Constructor Description

Method Summary

All Methods Instance Methods Concrete Methods 
void destroy()  
void executeUserAction​(java.lang.String value)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
java.lang.String getTitle()
Returns the title of the file chooser - the string always displayed in Download case and displayed before the file has been uploaded in Upload case.
java.lang.String getValue()
Returns the currently selected file name or empty string if no file selected
void resetSVGState()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
void setTitle​(java.lang.String title)
Sets the new title of the file chooser - the string always displayed in Download case and displayed before the file has been uploaded in Upload case.
void setValue​(java.lang.String fileName)
Sets the selected filename to given fileName
Doesn't execute user action code
void setValue​(java.lang.String fileName, boolean callAction)
Sets the selected filename to given fileName
Executes user action code (if any exists) if callAction parameter is true
SVGElement updateSVGProperties​(java.util.List<SVGCommand> output, ShapeDrawMode drawMode, boolean publicOnly, SVGElement owner, SVGElement elbehind)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Updates SVG properties of the element that are then sent to the rendering client.
Modifier and Type Method Description

Methods inherited from class com.anylogic.engine.presentation.ShapeInputControl

postSVGShapeSpecificAttributes

Methods inherited from class com.anylogic.engine.presentation.ShapeControl

action, clone, contains, executeAction, getHeight, getPresentable, getWidth, isEnabled, randomPointInside, restoreOwner, setEnabled, setHeight, setValueToDefault, setWidth

Methods inherited from class com.anylogic.engine.presentation.Shape

canHandleClick, findSVGElement, getDrawMode, getGroup, getLevel, getName, getRotation, getScaleX, getScaleY, getSVGId, getX, getY, isJava2DSwingPresentation, isPublic_xjal, isSVGPresentation, isVisible, onAggregatorVisibilityChanged, onClick, randomPointInside, removeSVGFromOwner, removeSVGImage, setLevel, setPos, setPos, setPublic_xjal, setRotation, setScale, setScale, setScaleX, setScaleY, setVisible, setX, setY, updateDynamicProperties, updateDynamicPropertiesStructural

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

initializeInternal, postInitialize

Field Detail

TYPE_UPLOAD

public static final ShapeFileChooser.Type TYPE_UPLOAD

TYPE_DOWNLOAD

public static final ShapeFileChooser.Type TYPE_DOWNLOAD

value

@AnyLogicInternalAPI
public volatile java.lang.String value
Returns the currently selected file name (or empty string if no file selected) that can be accessed in the overridden action() method.
Use getValue() to obtain the currently selected file name from other places

Constructor Detail

ShapeFileChooser

public ShapeFileChooser​(Presentable p,
                        boolean ispublic,
                        double x,
                        double y,
                        double width,
                        double height,
                        java.awt.Color backgroundColor,
                        java.awt.Color textColor,
                        boolean enabled,
                        java.awt.Font font,
                        java.lang.String title,
                        ShapeFileChooser.Type type,
                        java.lang.String fileTypes,
                        java.lang.String value)
Creates a file chooser control. You should override the action() method, in which you can access the current selection as "values".
Parameters:
p - the presentable object owning this control
ispublic - if true, the control is visible on container's presentation
x - the x coordinate
y - the y coordinate
width - the width
height - the height
backgroundColor - the background color
textColor - the text color
enabled - the initial enabled state
font - the text font
title - the title of the file chooser dialog
type - one of
  • #TYPE_OPEN
  • #TYPE_SAVE
fileTypes - file types acceptable by file chooser in the TYPE_UPLOAD mode. Examples: ".xls, .xlsx", ".png, .jpg", "image/png", "image/*".
value -

Method Detail

getTitle

public java.lang.String getTitle()
Returns the title of the file chooser - the string always displayed in Download case and displayed before the file has been uploaded in Upload case.
Returns:
the title of the file chooser

setTitle

public void setTitle​(java.lang.String title)
Sets the new title of the file chooser - the string always displayed in Download case and displayed before the file has been uploaded in Upload case.
Parameters:
title - the new title

setValue

public void setValue​(java.lang.String fileName)
Sets the selected filename to given fileName
Doesn't execute user action code
Parameters:
fileName - the file name

setValue

public void setValue​(java.lang.String fileName,
                     boolean callAction)
Sets the selected filename to given fileName
Executes user action code (if any exists) if callAction parameter is true
Parameters:
fileName - the file name
callAction - if true user action code (if any exists) will be executed

getValue

public java.lang.String getValue()
Returns the currently selected file name or empty string if no file selected
Returns:
the currently selected file name or empty string if no file selected

destroy

public void destroy()

resetSVGState

public void resetSVGState()
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
resetSVGState in interface SVGElement
Overrides:
resetSVGState in class Shape

updateSVGProperties

public SVGElement updateSVGProperties​(java.util.List<SVGCommand> output,
                                      ShapeDrawMode drawMode,
                                      boolean publicOnly,
                                      SVGElement owner,
                                      SVGElement elbehind)
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Updates SVG properties of the element that are then sent to the rendering client. If the element is not yet in the SVG scene, generates "C" command, if it is there, but some properties are out of date, generates "U" command. If SVG drawing of this element is not needed because of public only settings, or permanently not needed, or not supported yet, returns false and does nothing.
Specified by:
updateSVGProperties in interface SVGElement
Overrides:
updateSVGProperties in class Shape
Parameters:
output - the list of commands to add to
drawMode - TODO
publicOnly - drawing context: if true, only shapes that are marked as public only are updated
owner - the SVG element that serves as a container for this element
elbehind - the SVG element behind this one, or null if none or if order is irrelevant
Returns:
the actual owner this element has been added to or null if element is not drawn (e.g. drawing of this element is not needed because of public only settings, permanently not needed or not supported - hence SVG id is not set). The actual owner may differ from the given owner when the svg element is added to a different place (e.g. GIS map).

executeUserAction

@AnyLogicInternalAPI
public void executeUserAction​(java.lang.String value)
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
executeUserAction in interface SVGElement
Overrides:
executeUserAction in class Shape
How can we improve this article?