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

public class ShapeFileChooser
extends ShapeInputControl
File chooser control. Embeds a JPanel with JTextField and JButton.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Nested Class Summary

Modifier and TypeClassDescription
static enum ShapeFileChooser.Type
File chooser type constants

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

ShapeControl.ValueType

Field Summary

Modifier and TypeFieldDescription
static final ShapeFileChooser.TypeTYPE_DOWNLOAD 
static final ShapeFileChooser.TypeTYPE_UPLOAD 
Stringvalue
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

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

ConstructorDescription
ShapeFileChooser(Presentable p, boolean ispublic, double x, double y, double width, double height, Color backgroundColor, Color textColor, boolean enabled, Font font, String title, ShapeFileChooser.Type type, String fileTypes, String value)
Creates a file chooser control.

Method Summary

Modifier and TypeMethodDescription
voiddestroy() 
voidexecuteUserAction(String value)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
StringgetTitle()
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.
StringgetValue()
Returns the currently selected file name or empty string if no file selected
voidresetSVGState()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
voidsetTitle(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.
voidsetValue(String fileName)
Sets the selected filename to given fileName
Doesn't execute user action code
voidsetValue(String fileName, boolean callAction)
Sets the selected filename to given fileName
Executes user action code (if any exists) if callAction parameter is true
SVGElementupdateSVGProperties(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.

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 java.lang.Object

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

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

initializeInternal, postInitialize

Field Details

TYPE_UPLOAD

public static final ShapeFileChooser.Type TYPE_UPLOAD

TYPE_DOWNLOAD

public static final ShapeFileChooser.Type TYPE_DOWNLOAD

value

@AnyLogicInternalAPI
public volatile 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 Details

ShapeFileChooser

public ShapeFileChooser(Presentable p,
 boolean ispublic,
 double x,
 double y,
 double width,
 double height,
 Color backgroundColor,
 Color textColor,
 boolean enabled,
 Font font,
 String title,
 ShapeFileChooser.Type type,
 String fileTypes,
 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 Details

getTitle

public 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(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(String fileName)
Sets the selected filename to given fileName
Doesn't execute user action code
Parameters:
fileName - the file name

setValue

public void setValue(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 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(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(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