public class UIUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
UIUtils.DragThroughMouseListener |
Constructor and Description |
---|
UIUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addEscapeListener(JDialog dialog)
Makes a
JDialog close when the escape key is hit |
static void |
addFillerGridBagComponent(Container component,
int row,
int column)
Equivalent of
Box .verticalGlue() for GridBagLayout |
static JPopupMenu |
addPopupMenuToComponent(AbstractButton target)
Adds a popup menu to a button.
|
static JPopupMenu |
addPopupMenuToComponent(AbstractButton target,
JPopupMenu popupMenu)
Adds an existing popup menu to a button
|
static JPopupMenu |
addReloadablePopupMenuToComponent(AbstractButton target,
JPopupMenu popupMenu,
Runnable reloadFunction)
Adds an existing popup menu to a button
Adds a function that is run before the popup is shown
|
static JPopupMenu |
addReloadableRightClickPopupMenuToComponent(AbstractButton target,
JPopupMenu popupMenu,
Runnable reloadFunction)
Adds an existing popup menu to a button
Adds a function that is run before the popup is shown
|
static JPopupMenu |
addRightClickPopupMenuToComponent(AbstractButton target)
Adds an existing popup menu to a button
Adds a function that is run before the popup is shown
|
static JPopupMenu |
addRightClickPopupMenuToComponent(AbstractButton target,
JPopupMenu popupMenu)
Adds an existing popup menu to a button
Adds a function that is run before the popup is shown
|
static void |
applyThemeToCodeEditor(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) |
static int |
askOpenInCurrentWindow(Component parent,
String title)
Asks the user how to open a project: In the current window or a new window
|
static JPanel |
boxHorizontal(Component... components) |
static JPanel |
boxVertical(Component... components) |
static boolean |
checkAndAskIfFileExists(Component parent,
Path path,
String title)
Checks if a file exists and asks the user if it should be overwritten
|
static boolean |
confirmResetParameters(JIPipeWorkbench parent,
String title) |
static void |
copyToClipboard(String string)
Copies the string to the clipboard
|
static JLabel |
createInfoLabel(String text,
String subtext) |
static JLabel |
createJLabel(String text,
Icon icon) |
static JLabel |
createJLabel(String text,
Icon icon,
int fontSize) |
static JLabel |
createJLabel(String text,
int fontSize) |
static JMenuItem |
createMenuItem(String label,
String description,
Icon icon,
Runnable action) |
static Map<String,JMenu> |
createMenuTree(JMenu rootMenu,
Set<String> menuPaths)
Creates a hierarchy of menus based on the menu paths vector
|
static JLabel |
createStarRatingLabel(String title,
double stars,
int maximum)
Creates a read-only "star-rating" label
|
static JSeparator |
createVerticalSeparator() |
static void |
expandAllTree(JTree tree)
Expands the whole tree
|
static void |
fitRowHeights(JTable table)
Fits the row heights of a
JTable |
static String |
getAWTWindowTitle(Window window) |
static Color |
getBorderColorFor(JIPipeNodeInfo info)
Returns a border color for
JIPipeNodeInfo |
static Optional<Double> |
getDoubleByDialog(Component parent,
String title,
String message,
double initialValue,
double min,
double max)
Gets an integer by dialog
|
static BufferedImage |
getExtensionBuilderLogo400() |
static Color |
getFillColorFor(JIPipeNodeInfo info)
Returns a fill color for
JIPipeNodeInfo |
static BufferedImage |
getHeaderPanelBackground() |
static HTMLText |
getHTMLByDialog(JIPipeWorkbench workbench,
Component parent,
String title,
String message,
HTMLText initialValue)
Gets a formatted HTML string by dialog
|
static ImageIcon |
getIcon128FromResources(String iconName)
Returns an icon from JIPipe resources
If you want to utilize resources from your Java extension, use
JIPipeResourceManager |
static ImageIcon |
getIcon16FromResources(String iconName)
Returns an icon from JIPipe resources
If you want to utilize resources from your Java extension, use
JIPipeResourceManager |
static ImageIcon |
getIcon32FromResources(String iconName)
Returns an icon from JIPipe resources
If you want to utilize resources from your Java extension, use
JIPipeResourceManager |
static ImageIcon |
getIcon64FromResources(String iconName)
Returns an icon from JIPipe resources
If you want to utilize resources from your Java extension, use
JIPipeResourceManager |
static ImageIcon |
getIcon8FromResources(String iconName)
Returns an icon from JIPipe resources
If you want to utilize resources from your Java extension, use
JIPipeResourceManager |
static SolidColorIcon |
getIconFromColor(Color color)
Creates 16x16 a color icon
|
static ImageIcon |
getIconFromResources(String iconName)
Returns an icon from JIPipe resources
If you want to utilize resources from your Java extension, use
JIPipeResourceManager |
static ImageIcon |
getIconInverted32FromResources(String iconName)
Returns an icon from JIPipe resources
If you want to utilize resources from your Java extension, use
JIPipeResourceManager |
static ImageIcon |
getIconInvertedFromResources(String iconName)
Returns an icon from JIPipe resources
If you want to utilize resources from your Java extension, use
JIPipeResourceManager |
static URL |
getIconURLFromResources(String iconName)
Returns an icon from JIPipe resources
If you want to utilize resources from your Java extension, use
JIPipeResourceManager |
static Optional<Integer> |
getIntegerByDialog(Component parent,
String title,
String message,
int initialValue,
int min,
int max)
Gets an integer by dialog
|
static BufferedImage |
getLogo() |
static BufferedImage |
getLogo400() |
static String |
getMultiLineStringByDialog(Component parent,
String title,
String message,
String initialValue)
Gets a multiline string by dialog
|
static <T> List<T> |
getSelectionByDialog(Component parent,
Collection<T> input,
Collection<T> selected,
String title,
String message,
ListCellRenderer<T> renderer,
ListSelectionMode selectionMode)
Lets the user select one or multiple items from a list
|
static String |
getStringFromClipboard()
Returns a string from clipboard or an empty string
|
static JIPipeUITheme |
getThemeFromRawSettings() |
static String |
getUniqueStringByDialog(Component parent,
String message,
String initialValue,
Predicate<String> exists)
Continuously asks for an unique string
|
static JPanel |
gridHorizontal(Component... components) |
static JPanel |
gridVertical(Component... components) |
static void |
installMenuExtension(JIPipeWorkbench workbench,
JMenu targetMenu,
JIPipeMenuExtensionTarget targetMenuType,
boolean withSeparator)
Installs an extension menu
|
static void |
invokeScrollToTop(JScrollPane scrollPane) |
static void |
loadLookAndFeelFromSettings()
Attempts to override the look and feel based on the JIPipe settings
|
static JTextPane |
makeBorderlessReadonlyTextPane(String text,
boolean opaque)
Creates a readonly text pane (that can do HTML)
|
static void |
makeBorderlessWithoutMargin(AbstractButton component)
Makes a component borderless
|
static void |
makeFlat(AbstractButton component)
Makes a button flat
|
static void |
makeFlat(AbstractButton component,
Color borderColor,
int top,
int left,
int right,
int bottom)
Makes a button flat
|
static void |
makeFlat25x25(AbstractButton component)
Makes a button flat and 25x25 size
|
static void |
makeFlatH25(AbstractButton component)
Makes a button flat and have a height of 25px
|
static JTextPane |
makeMarkdownReader(MarkdownDocument document,
String[] css)
Creates a
JTextPane that displays Markdown content |
static JTextArea |
makeReadonlyBorderlessTextArea(String text)
Creates a readonly text area
|
static JTextField |
makeReadonlyBorderlessTextField(String value)
Creates a readonly text field
|
static JTextArea |
makeReadonlyTextArea(String text)
Creates a readonly text area
Cannot do HTML.
|
static JTextField |
makeReadonlyTextField(String value)
Creates a readonly text field
|
static JTextPane |
makeReadonlyTextPane(String text)
Creates a readonly text pane (that can do HTML)
|
static void |
makeToggleReadonly(JToggleButton toggleButton)
Makes a toggle button readonly without greying it out
|
static JLabel |
makeURLLabel(String url)
Makes a label that contains a URL and opens the URL when clicked
|
static void |
openErrorDialog(Component parent,
Exception exception)
Opens a dialog showing an exception
|
static void |
openFileInNative(Path path)
Opens a website with given URL
|
static void |
openNotificationsDialog(JIPipeWorkbench workbench,
Component parent,
JIPipeNotificationInbox notifications,
String title,
String infoText,
boolean autoClose) |
static void |
openValidityReportDialog(Component parent,
JIPipeIssueReport report,
String title,
String infoText,
boolean modal)
Opens a dialog showing a validity report
|
static void |
openWebsite(String url)
Opens a website with given URL
|
static void |
packDataTable(org.jdesktop.swingx.JXTable table)
packAll() for a data table (with a limit)
|
static void |
redirectDragEvents(Component component,
Component target) |
static void |
registerHyperlinkHandler(JTextPane content) |
static void |
sendTrayNotification(String caption,
String message,
TrayIcon.MessageType messageType) |
static void |
setJTextPaneFont(JTextPane jtp,
Font font,
Color c)
Utility method for setting the font and color of a JTextPane.
|
static void |
setNodeExpandedState(JTree tree,
DefaultMutableTreeNode node,
boolean expanded) |
static void |
setToAskOnClose(JFrame window,
String message,
String title)
Installs an event to the window that asks the user before the window is closes
|
static void |
setToAskOnClose(JFrame window,
Supplier<String> message,
String title)
Installs an event to the window that asks the user before the window is closes
|
static void |
setTreeExpandedState(JTree tree,
boolean expanded) |
static void |
showConnectionErrorMessage(Component parent,
JIPipeDataSlot source,
JIPipeDataSlot target) |
static boolean |
showOKCancelDialog(Component parent,
Component component,
String title)
Shows a component in a JIPipe-styled dialog with OK and Cancel button
|
public static final FileNameExtensionFilter EXTENSION_FILTER_CSV
public static final FileNameExtensionFilter EXTENSION_FILTER_TSV
public static final FileNameExtensionFilter EXTENSION_FILTER_XLSX
public static final FileNameExtensionFilter EXTENSION_FILTER_PNG
public static final FileNameExtensionFilter EXTENSION_FILTER_IMAGEIO_IMAGES
public static final FileNameExtensionFilter EXTENSION_FILTER_SVG
public static final FileNameExtensionFilter EXTENSION_FILTER_MD
public static final FileNameExtensionFilter EXTENSION_FILTER_PDF
public static final FileNameExtensionFilter EXTENSION_FILTER_HTML
public static final FileNameExtensionFilter EXTENSION_FILTER_JPEG
public static final FileNameExtensionFilter EXTENSION_FILTER_BMP
public static final FileNameExtensionFilter EXTENSION_FILTER_TIFF
public static final FileNameExtensionFilter EXTENSION_FILTER_JIP
public static final FileNameExtensionFilter EXTENSION_FILTER_JIPE
public static final FileNameExtensionFilter EXTENSION_FILTER_JIPC
public static final FileNameExtensionFilter EXTENSION_FILTER_JSON
public static final FileNameExtensionFilter EXTENSION_FILTER_TXT
public static final FileNameExtensionFilter EXTENSION_FILTER_ZIP
public static final FileNameExtensionFilter EXTENSION_FILTER_ROI_ZIP
public static final FileNameExtensionFilter EXTENSION_FILTER_ROI
public static final FileNameExtensionFilter EXTENSION_FILTER_ROIS
public static final FileNameExtensionFilter EXTENSION_FILTER_AVI
public static final Insets UI_PADDING
public static final Map<String,ImageIcon> ICON_INVERTED_FROM_RESOURCES_CACHE
public static boolean DARK_THEME
public static void registerHyperlinkHandler(JTextPane content)
public static void sendTrayNotification(String caption, String message, TrayIcon.MessageType messageType)
public static void packDataTable(org.jdesktop.swingx.JXTable table)
table
- the tablepublic static void loadLookAndFeelFromSettings()
public static void applyThemeToCodeEditor(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
public static JIPipeUITheme getThemeFromRawSettings()
public static BufferedImage getExtensionBuilderLogo400()
public static BufferedImage getLogo400()
public static BufferedImage getLogo()
public static BufferedImage getHeaderPanelBackground()
public static void addFillerGridBagComponent(Container component, int row, int column)
Box
.verticalGlue() for GridBagLayout
component
- the target component that has GridBagLayout
row
- the rowcolumn
- the columnpublic static JPopupMenu addPopupMenuToComponent(AbstractButton target)
target
- target buttonpublic static JPopupMenu addPopupMenuToComponent(AbstractButton target, JPopupMenu popupMenu)
target
- target buttonpopupMenu
- the popup menupublic static JPopupMenu addReloadablePopupMenuToComponent(AbstractButton target, JPopupMenu popupMenu, Runnable reloadFunction)
target
- target buttonpopupMenu
- the popup menureloadFunction
- the function that is run before showing the popuppublic static JPopupMenu addReloadableRightClickPopupMenuToComponent(AbstractButton target, JPopupMenu popupMenu, Runnable reloadFunction)
target
- target buttonpopupMenu
- the popup menureloadFunction
- the function that is run before showing the popuppublic static JPopupMenu addRightClickPopupMenuToComponent(AbstractButton target)
target
- target buttonpublic static JPopupMenu addRightClickPopupMenuToComponent(AbstractButton target, JPopupMenu popupMenu)
target
- target buttonpublic static JSeparator createVerticalSeparator()
public static ImageIcon getIcon16FromResources(String iconName)
JIPipeResourceManager
iconName
- relative to the icons/ plugin resourcepublic static ImageIcon getIconInvertedFromResources(String iconName)
JIPipeResourceManager
iconName
- relative to the icons/ plugin resourcepublic static ImageIcon getIconInverted32FromResources(String iconName)
JIPipeResourceManager
iconName
- relative to the icons/ plugin resourcepublic static ImageIcon getIconFromResources(String iconName)
JIPipeResourceManager
iconName
- relative to the icons/ plugin resourcepublic static ImageIcon getIcon32FromResources(String iconName)
JIPipeResourceManager
iconName
- relative to the icons/ plugin resourcepublic static ImageIcon getIcon64FromResources(String iconName)
JIPipeResourceManager
iconName
- relative to the icons/ plugin resourcepublic static ImageIcon getIcon128FromResources(String iconName)
JIPipeResourceManager
iconName
- relative to the icons/ plugin resourcepublic static ImageIcon getIcon8FromResources(String iconName)
JIPipeResourceManager
iconName
- relative to the icons/ plugin resourcepublic static URL getIconURLFromResources(String iconName)
JIPipeResourceManager
iconName
- relative to the icons/ plugin resourcepublic static SolidColorIcon getIconFromColor(Color color)
color
- the colorpublic static void makeFlat(AbstractButton component)
component
- the buttonpublic static void makeFlat(AbstractButton component, Color borderColor, int top, int left, int right, int bottom)
component
- the buttonborderColor
- border colortop
- top border sizeleft
- left border sizeright
- right border sizebottom
- bottom border sizepublic static void makeFlat25x25(AbstractButton component)
component
- the buttonpublic static void makeFlatH25(AbstractButton component)
component
- the buttonpublic static void makeBorderlessWithoutMargin(AbstractButton component)
component
- the componentpublic static void setToAskOnClose(JFrame window, String message, String title)
window
- the windowmessage
- the close messagetitle
- the close message titlepublic static void setToAskOnClose(JFrame window, Supplier<String> message, String title)
window
- the windowmessage
- the close messagetitle
- the close message titlepublic static void expandAllTree(JTree tree)
tree
- the treepublic static int askOpenInCurrentWindow(Component parent, String title)
parent
- parent componenttitle
- window titleJOptionPane
.YES_OPTION to open in this window; JOptionPane
.NO_OPTION to open in a new window; JOptionPane
.CANCEL_OPTION to cancel.public static boolean checkAndAskIfFileExists(Component parent, Path path, String title)
parent
- the parent componentpath
- the path. can be null, will return falsetitle
- the titlepublic static JLabel createStarRatingLabel(String title, double stars, int maximum)
title
- the label titlestars
- the number of starsmaximum
- the maximum number of starspublic static void openErrorDialog(Component parent, Exception exception)
parent
- the parent componentexception
- the exceptionpublic static void openNotificationsDialog(JIPipeWorkbench workbench, Component parent, JIPipeNotificationInbox notifications, String title, String infoText, boolean autoClose)
public static void openValidityReportDialog(Component parent, JIPipeIssueReport report, String title, String infoText, boolean modal)
parent
- the parent componentreport
- the reporttitle
- the titleinfoText
- the info textmodal
- make the dialog modalpublic static <T> List<T> getSelectionByDialog(Component parent, Collection<T> input, Collection<T> selected, String title, String message, ListCellRenderer<T> renderer, ListSelectionMode selectionMode)
T
- typeparent
- parent componentinput
- list of input objectsselected
- pre-selected itemstitle
- the titlemessage
- the message (can be null to disable message)renderer
- the renderer for the items (null to use default renderer)selectionMode
- the selection modepublic static boolean showOKCancelDialog(Component parent, Component component, String title)
parent
- the parent componentcomponent
- the componenttitle
- the titlepublic static HTMLText getHTMLByDialog(JIPipeWorkbench workbench, Component parent, String title, String message, HTMLText initialValue)
workbench
- the workbenchparent
- the parent componenttitle
- the titlemessage
- messageinitialValue
- initial valuepublic static String getMultiLineStringByDialog(Component parent, String title, String message, String initialValue)
parent
- the parent componenttitle
- the titlemessage
- messageinitialValue
- initial valuepublic static Optional<Integer> getIntegerByDialog(Component parent, String title, String message, int initialValue, int min, int max)
parent
- parent componenttitle
- titlemessage
- messageinitialValue
- initial valuemin
- minimum valuemax
- maximum valuepublic static Optional<Double> getDoubleByDialog(Component parent, String title, String message, double initialValue, double min, double max)
parent
- parent componenttitle
- titlemessage
- messageinitialValue
- initial valuemin
- minimum valuemax
- maximum valuepublic static String getUniqueStringByDialog(Component parent, String message, String initialValue, Predicate<String> exists)
parent
- parent componentmessage
- the messageinitialValue
- the initial stringexists
- function that returns true if the value existspublic static Color getFillColorFor(JIPipeNodeInfo info)
JIPipeNodeInfo
info
- the algorithm typepublic static Color getBorderColorFor(JIPipeNodeInfo info)
JIPipeNodeInfo
info
- the algorithm typepublic static void makeToggleReadonly(JToggleButton toggleButton)
toggleButton
- toggle buttonpublic static JTextField makeReadonlyTextField(String value)
value
- textpublic static JTextArea makeReadonlyTextArea(String text)
text
- textpublic static JTextPane makeReadonlyTextPane(String text)
text
- textpublic static void setJTextPaneFont(JTextPane jtp, Font font, Color c)
public static JTextPane makeBorderlessReadonlyTextPane(String text, boolean opaque)
text
- textopaque
- if the area should be opaquepublic static JTextField makeReadonlyBorderlessTextField(String value)
value
- textpublic static JTextArea makeReadonlyBorderlessTextArea(String text)
text
- textpublic static JTextPane makeMarkdownReader(MarkdownDocument document, String[] css)
JTextPane
that displays Markdown contentdocument
- the markdown documentcss
- style sheetspublic static void fitRowHeights(JTable table)
JTable
table
- the tablepublic static Map<String,JMenu> createMenuTree(JMenu rootMenu, Set<String> menuPaths)
rootMenu
- the root menumenuPaths
- strings that have menu items separated by newlinespublic static void addEscapeListener(JDialog dialog)
JDialog
close when the escape key is hitdialog
- the dialogpublic static JLabel makeURLLabel(String url)
url
- the URLpublic static void setTreeExpandedState(JTree tree, boolean expanded)
public static void setNodeExpandedState(JTree tree, DefaultMutableTreeNode node, boolean expanded)
public static void installMenuExtension(JIPipeWorkbench workbench, JMenu targetMenu, JIPipeMenuExtensionTarget targetMenuType, boolean withSeparator)
workbench
- the workbenchtargetMenu
- the menutargetMenuType
- the menu typewithSeparator
- if a separator should be prepended if items are installedpublic static void copyToClipboard(String string)
string
- the stringpublic static String getStringFromClipboard()
public static void openWebsite(String url)
url
- the URLpublic static void openFileInNative(Path path)
path
- the filepublic static boolean confirmResetParameters(JIPipeWorkbench parent, String title)
public static void showConnectionErrorMessage(Component parent, JIPipeDataSlot source, JIPipeDataSlot target)
public static void invokeScrollToTop(JScrollPane scrollPane)
Copyright © 2020–2022 Leibniz Institute for Natural Product Research and Infection Biology - Hans Knöll Institute (HKI). All rights reserved.