abstract class FileChooserUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.logging.Logger |
LOG
Logger.
|
(package private) static java.lang.String |
VF_CONTROLPANEL
Control Panel virtual folder.
|
(package private) static java.lang.String |
VF_FAVORITES
Favorites virtual folder.
|
(package private) static java.lang.String |
VF_LIBRARIES
Libraries virtual folder.
|
(package private) static java.lang.String |
VF_NETWORK
Network virtual folder.
|
(package private) static java.lang.String |
VF_RECENTPLACES
Recent Places virtual folder.
|
(package private) static java.lang.String |
VF_RECYCLEBIN
Recycle Bin virtual folder.
|
(package private) static java.lang.String |
VF_THISPC
This PC virtual folder.
|
Constructor and Description |
---|
FileChooserUtils() |
Modifier and Type | Method and Description |
---|---|
(package private) static void |
drawImage(GuiDriver gd,
ImageWrapper<java.awt.image.BufferedImage> img,
int x,
int y)
Draws an image (if valid) at specified coordinates.
|
private static java.lang.String |
floatToString(float f,
int decimals)
Helper worker method for
getSizeAsString() . |
(package private) static byte[] |
getBinaryResource(java.lang.String path)
Utility method for loading an image resource from packaging bundle and return its binary
content as a byte array.
|
(package private) static java.lang.String |
getDateAsString(java.nio.file.attribute.FileTime fileTime)
Utility method that converts a file timestamp to its string representation.
|
(package private) static java.lang.String |
getDisplayName(java.nio.file.Path path)
Obtain the name of the file to be displayed, including virtual folders.
|
(package private) static java.lang.String |
getDisplayName(java.lang.String absPath)
Obtain the name of the file to be displayed, including virtual folders.
|
(package private) static java.lang.String |
getFileName(java.nio.file.Path path)
Worker method for extracting the file name from a
Path as a String and avoid
a NPE in case of root paths. |
(package private) static java.lang.String |
getSizeAsString(long size,
boolean forceUnits,
int decimals)
Convert a long number representing a file size into a string using multiplicative binary
units.
|
(package private) static boolean |
isPathVisible(java.nio.file.Path path)
Tests whether the
path is visible when navigating the file tree. |
(package private) static boolean |
isVirtualFolder(java.lang.String path)
Checks whether the absolute or relative path is a virtual folder.
|
(package private) static ImageWrapper<java.awt.image.BufferedImage> |
loadImage(java.lang.String icon)
Loads a image resource.
|
private static final java.util.logging.Logger LOG
static final java.lang.String VF_FAVORITES
static final java.lang.String VF_RECENTPLACES
static final java.lang.String VF_THISPC
static final java.lang.String VF_NETWORK
static final java.lang.String VF_LIBRARIES
static final java.lang.String VF_CONTROLPANEL
static final java.lang.String VF_RECYCLEBIN
static void drawImage(GuiDriver gd, ImageWrapper<java.awt.image.BufferedImage> img, int x, int y)
gd
- The graphic driver to be used.img
- The image to be rendered.x
- X coordinate of the location where the image is drawn.y
- Y coordinate of the location where the image is drawn.static byte[] getBinaryResource(java.lang.String path)
<theme-name>/filedialog
. This allows theme-dependent icons to be created.path
- The path of the resource. It is computed relative to current theme.null
array is returned.static ImageWrapper<java.awt.image.BufferedImage> loadImage(java.lang.String icon)
<theme-name>/filedialog
. This allows theme-dependent
icons to be created.
The resource name must end in .png. Although the PNG file format is not required (any other
well known format will be automatically used by ImageIO
) it is recommended because
it support full 32 bit images (including 8 bit alpha) and they are super compact in size.
icon
- The image to be loaded.ImageWrapper
with the image resource loaded or null
if resource
was not found or it could not be decoded.static java.lang.String getSizeAsString(long size, boolean forceUnits, int decimals)
size
- The file size.forceUnits
- If true
forces KB prefix even if size
is less than 1 kilobytedecimals
- How many decimals the result should have. Valid values are 0 to 3.size
with eventual multiplication prefix.private static java.lang.String floatToString(float f, int decimals)
getSizeAsString()
. This method uses DecimalFormat
to format f
to specified number of decimals.f
- The decimal number to convert.decimals
- The numbers of decimals.f
with specified number of decimals.static java.lang.String getDateAsString(java.nio.file.attribute.FileTime fileTime)
99/99/9999 HH:MM
format of datetime
.fileTime
- The timestamp to be converted.static boolean isPathVisible(java.nio.file.Path path)
path
is visible when navigating the file tree. This is OS
dependent: if we are running on Windows OS, we need to check the appropriate file attributes
(Hidden and System), when running on Linux and Solaris the files starting with a .
are not visible.path
- The path to test.true
if path should be visible in file selection dialogs.static java.lang.String getFileName(java.nio.file.Path path)
Path
as a String
and avoid
a NPE in case of root paths.path
- The path to be analyzed.path
.static java.lang.String getDisplayName(java.nio.file.Path path)
path
- An absolute path or virtual folder name.static java.lang.String getDisplayName(java.lang.String absPath)
absPath
- An absolute path or virtual folder name.static boolean isVirtualFolder(java.lang.String path)
path
- The path to check.true
if the path provided is a virtual folder id.