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 |
addBalloonToComponent(AbstractButton button,
String text) |
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 void |
addPanningToScrollPane(JScrollPane scrollPane) |
static JPopupMenu |
addPopupMenuToButton(AbstractButton target)
Adds a popup menu to a button.
|
static JPopupMenu |
addPopupMenuToButton(AbstractButton target,
JPopupMenu popupMenu)
Adds an existing popup menu to a button
|
static JPopupMenu |
addReloadablePopupMenuToButton(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 |
addReloadableRightClickPopupMenuToButton(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 |
addRightClickPopupMenuToButton(AbstractButton target)
Adds an existing popup menu to a button
Adds a function that is run before the popup is shown
|
static JPopupMenu |
addRightClickPopupMenuToButton(AbstractButton target,
JPopupMenu popupMenu)
Adds an existing popup menu to a button
Adds a function that is run before the popup is shown
|
static JPopupMenu |
addRightClickPopupMenuToComponent(Component target)
Adds an existing popup menu to a button
Adds a function that is run before the popup is shown
|
static void |
addRightClickPopupMenuToComponent(Component target,
JPopupMenu popupMenu)
Adds an existing popup menu to a button
Adds a function that is run before the popup is shown
|
static void |
addRightClickPopupMenuToJList(JList<?> target,
JPopupMenu popupMenu,
Runnable reloadFunction) |
static void |
addSeparatorIfNeeded(JMenu menu)
Adds a separator if there is at least one component in the menu and the last item is not a separator
|
static void |
addSeparatorIfNeeded(JPopupMenu menu)
Adds a separator if there is at least one component in the menu and the last item is not a separator
|
static void |
addToStatusBarWithSeparator(JComponent target,
JComponent control) |
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 |
borderNorthCenter(JComponent north,
JComponent center) |
static JPanel |
borderNorthSouth(JComponent north,
JComponent south) |
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 void |
copyToClipboard(String string)
Copies the string to the clipboard
|
static JButton |
createBalloonHelpButton(String text) |
static JTextPane |
createBorderlessReadonlyTextPane(String text,
boolean opaque)
Creates a readonly text pane (that can do HTML)
|
static JButton |
createButton(String text,
Icon icon,
Runnable function) |
static Border |
createButtonBorder(Color color) |
static Border |
createControlBorder() |
static Border |
createControlBorder(Color color) |
static Border |
createControlErrorBorder() |
static Border |
createEmptyBorder(int i) |
static JButton |
createFlatButton(String text,
Icon icon,
Runnable function) |
static JSeparator |
createHorizontalFillingSeparator() |
static JButton |
createIconOnlyButton(String text,
Icon icon,
Runnable function) |
static JLabel |
createInfoLabel(String text,
String subtext) |
static JLabel |
createInfoLabel(String text,
String subtext,
Icon icon) |
static JLabel |
createJLabel(String text,
Icon icon) |
static JLabel |
createJLabel(String text,
Icon icon,
int fontSize) |
static JLabel |
createJLabel(String text,
int fontSize) |
static JButton |
createLeftAlignedButton(String text,
ImageIcon icon,
Runnable action) |
static JTextPane |
createMarkdownReader(MarkdownText document,
String[] css)
Creates a
JTextPane that displays Markdown content |
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 Map<String,JComponent> |
createMenuTree(JPopupMenu rootMenu,
Set<String> menuPaths)
Creates a hierarchy of menus based on the menu paths vector
|
static Border |
createPanelBorder() |
static Border |
createPanelBorder(int left,
int top,
int right,
int bottom) |
static JButton |
createPopupHelpButton(String text) |
static JTextArea |
createReadonlyBorderlessTextArea(String text)
Creates a readonly text area
|
static JTextField |
createReadonlyBorderlessTextField(String value)
Creates a readonly text field
|
static JTextArea |
createReadonlyTextArea(String text)
Creates a readonly text area
Cannot do HTML.
|
static JTextField |
createReadonlyTextField(String value)
Creates a readonly text field
|
static JTextPane |
createReadonlyTextPane(String text)
Creates a readonly text pane (that can do HTML)
|
static JButton |
createStandardButton(String text,
ImageIcon icon,
Runnable action) |
static JLabel |
createStarRatingLabel(String title,
double stars,
int maximum)
Creates a read-only "star-rating" label
|
static Border |
createSuccessBorder() |
static JLabel |
createURLLabel(String url)
Makes a label that contains a URL and opens the URL when clicked
|
static JSeparator |
createVerticalSeparator() |
static void |
drawStringVerticallyCentered(Graphics2D g2,
String text,
int x,
int y,
FontMetrics fontMetrics) |
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 Color |
getControlBorderColor() |
static Map<?,?> |
getDesktopRenderingHints() |
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(JIPipeDesktopWorkbench 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 |
getIcon12FromResources(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 URL |
getIcon32URLFromResources(String iconName) |
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 Color |
getIconBaseColor() |
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 |
getIconInverted12FromResources(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 BufferedImage |
getImageFromResources(String path) |
static Optional<Integer> |
getIntegerByDialog(Component parent,
String title,
String message,
int initialValue,
int min,
int max)
Gets an integer by dialog
|
static Image |
getJIPipeIcon128() |
static BufferedImage |
getLogo() |
static BufferedImage |
getLogo400() |
static JMenuItem |
getMenuItem(JComponent menu,
int index) |
static int |
getMenuItemCount(JComponent menu) |
static Optional<double[]> |
getMinMaxByDialog(Component parent,
String title,
String message,
double initialMin,
double initialMax,
double min,
double max)
Gets an integer by dialog
|
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 JIPipeDesktopUITheme |
getTheme() |
static JIPipeDesktopUITheme |
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 |
invokeMuchLater(int timeout,
Runnable run) |
static void |
invokeScrollToBottom(JScrollPane scrollPane) |
static void |
invokeScrollToTop(JScrollPane scrollPane) |
static String |
keyStrokeToString(KeyStroke key) |
static void |
loadLookAndFeelFromSettings()
Attempts to override the look and feel based on the JIPipe settings
|
static <T extends AbstractButton> |
makeButtonBorderlessWithoutMargin(T component)
Makes a component borderless
|
static <T extends AbstractButton> |
makeButtonFlat(T component)
Makes a button flat and have a height of 25px
|
static <T extends AbstractButton> |
makeButtonFlat25x25(T component)
Makes a button flat and 25x25 size
|
static <T extends AbstractButton> |
makeButtonFlatWithSize(T component,
int size)
Makes a button flat and 25x25 size
|
static <T extends AbstractButton> |
makeButtonFlatWithSize(T component,
int size,
int borderSize)
Makes a button flat and 25x25 size
|
static <T extends AbstractButton> |
makeButtonHighlightedSuccess(T button) |
static JButton |
makeButtonTransparent(JButton button) |
static void |
makeNonOpaque(Component component,
boolean recursive) |
static void |
makeToggleButtonReadonly(JToggleButton toggleButton)
Makes a toggle button readonly without greying it out
|
static void |
openFileInNative(Path path)
Opens a website with given URL
|
static void |
openNotificationsDialog(JIPipeDesktopWorkbench workbench,
Component parent,
JIPipeNotificationInbox notifications,
String title,
String infoText,
boolean autoClose) |
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 |
rebuildMenu(JMenu menu,
List<Component> items) |
static void |
rebuildMenu(JPopupMenu menu,
List<Component> items) |
static void |
redirectDragEvents(Component component,
Component target) |
static void |
registerHyperlinkHandler(JTextPane content) |
static void |
removeAllWithDispose(JComponent component) |
static void |
repaintLater(Component component) |
static void |
requestFocusOnShown(JComponent component) |
static <T> void |
selectItemsInJList(JList<T> list,
List<T> itemsToSelect) |
static void |
sendTrayNotification(String caption,
String message,
TrayIcon.MessageType messageType) |
static <T extends JComponent> |
setFontSize(T component,
int fontSize) |
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 |
setStandardButtonBorder(AbstractButton component)
Makes a button flat
|
static void |
setStandardButtonBorder(AbstractButton component,
Color borderColor,
int top,
int left,
int right,
int bottom)
Makes a button flat
|
static <T extends JComponent> |
setStandardControlBorder(T component) |
static void |
setTextPaneFont(JTextPane textPane,
String fontFamily,
int fontSize) |
static void |
setToAskOnClose(JDialog 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,
String message,
String title)
Installs an event to the window that asks the user before the window is closes
|
static void |
setToAskOnClose(JFrame window,
String message,
String title,
Supplier<Boolean> askOnClose)
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 boolean |
showConfirmDialog(Component parent,
String title,
Dimension size,
Component content) |
static void |
showConnectionErrorMessage(Component parent,
JIPipeDataSlot source,
JIPipeDataSlot target) |
static void |
showErrorDialog(JIPipeDesktopWorkbench workbench,
Component parent,
Throwable exception)
Opens a dialog showing an exception
|
static boolean |
showOKCancelDialog(Component parent,
Component component,
String title)
Shows a component in a JIPipe-styled dialog with OK and Cancel button
|
static void |
showValidityReportDialog(JIPipeDesktopWorkbench workbench,
Component parent,
JIPipeValidationReport report,
String title,
String infoText,
boolean modal)
Opens a dialog showing a validity report
|
static <T> DefaultComboBoxModel<T> |
toComboBoxModel(Collection<T> elements) |
static <T> DefaultListModel<T> |
toListModel(Collection<T> elements) |
static JPanel |
wrapInEmptyBorder(JComponent component,
int borderSize) |
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_OME_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_TAR_GZ
public static final FileNameExtensionFilter EXTENSION_FILTER_ARCHIVE
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 FileNameExtensionFilter EXTENSION_FILTER_HDF5
public static final FileNameExtensionFilter EXTENSION_FILTER_ZARR_ZIP
public static final Insets UI_PADDING
public static final Map<String,ImageIcon> ICON_INVERTED_FROM_RESOURCES_CACHE
public static final Map<String,BufferedImage> IMAGE_FROM_RESOURCES_CACHE
public static final JMenuItem MENU_ITEM_SEPARATOR
public static final Color COLOR_ERROR
public static final Color COLOR_SUCCESS
public static boolean DARK_THEME
public static void addPanningToScrollPane(JScrollPane scrollPane)
public static void rebuildMenu(JPopupMenu menu, List<Component> items)
public static Border createControlErrorBorder()
public static Color getControlBorderColor()
public static Border createControlBorder()
public static void addToStatusBarWithSeparator(JComponent target, JComponent control)
public static Border createPanelBorder()
public static Border createPanelBorder(int left, int top, int right, int bottom)
public static void registerHyperlinkHandler(JTextPane content)
public static Image getJIPipeIcon128()
public static void addBalloonToComponent(AbstractButton button, String text)
public static void sendTrayNotification(String caption, String message, TrayIcon.MessageType messageType)
public static Color getIconBaseColor()
public static JSeparator createHorizontalFillingSeparator()
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 JIPipeDesktopUITheme getThemeFromRawSettings()
public static BufferedImage getImageFromResources(String path)
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 addPopupMenuToButton(AbstractButton target)
target
- target buttonpublic static JPopupMenu addPopupMenuToButton(AbstractButton target, JPopupMenu popupMenu)
target
- target buttonpopupMenu
- the popup menupublic static JPopupMenu addReloadablePopupMenuToButton(AbstractButton target, JPopupMenu popupMenu, Runnable reloadFunction)
target
- target buttonpopupMenu
- the popup menureloadFunction
- the function that is run before showing the popuppublic static void addRightClickPopupMenuToJList(JList<?> target, JPopupMenu popupMenu, Runnable reloadFunction)
public static JPopupMenu addReloadableRightClickPopupMenuToButton(AbstractButton target, JPopupMenu popupMenu, Runnable reloadFunction)
target
- target buttonpopupMenu
- the popup menureloadFunction
- the function that is run before showing the popuppublic static JPopupMenu addRightClickPopupMenuToComponent(Component target)
target
- target buttonpublic static void addRightClickPopupMenuToComponent(Component target, JPopupMenu popupMenu)
target
- target buttonpublic static JPopupMenu addRightClickPopupMenuToButton(AbstractButton target)
target
- target buttonpublic static JPopupMenu addRightClickPopupMenuToButton(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 getIconInverted12FromResources(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 getIcon12FromResources(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 setStandardButtonBorder(AbstractButton component)
component
- the buttonpublic static void setStandardButtonBorder(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 <T extends AbstractButton> T makeButtonFlat25x25(T component)
component
- the buttonpublic static <T extends AbstractButton> T makeButtonFlatWithSize(T component, int size)
component
- the buttonpublic static <T extends AbstractButton> T makeButtonFlatWithSize(T component, int size, int borderSize)
component
- the buttonpublic static <T extends AbstractButton> T makeButtonFlat(T component)
component
- the buttonpublic static <T extends AbstractButton> T makeButtonBorderlessWithoutMargin(T component)
component
- the componentpublic static void setToAskOnClose(JDialog window, String message, String title)
window
- the windowmessage
- the close messagetitle
- the close message titlepublic static void setToAskOnClose(JFrame window, String message, String title)
window
- the windowmessage
- the close messagetitle
- the close message titlepublic static void setToAskOnClose(JFrame window, String message, String title, Supplier<Boolean> askOnClose)
window
- the windowmessage
- the close messagetitle
- the close message titleaskOnClose
- only ask if condition is truepublic 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 showErrorDialog(JIPipeDesktopWorkbench workbench, Component parent, Throwable exception)
workbench
- the workbenchparent
- the parent componentexception
- the exceptionpublic static void openNotificationsDialog(JIPipeDesktopWorkbench workbench, Component parent, JIPipeNotificationInbox notifications, String title, String infoText, boolean autoClose)
public static void showValidityReportDialog(JIPipeDesktopWorkbench workbench, Component parent, JIPipeValidationReport report, String title, String infoText, boolean modal)
workbench
- the workbenchparent
- 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(JIPipeDesktopWorkbench workbench, Component parent, String title, String message, HTMLText initialValue)
workbench
- the workbenchparent
- the parent componenttitle
- the titlemessage
- messageinitialValue
- initial valuepublic static boolean showConfirmDialog(Component parent, String title, Dimension size, Component content)
public 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 Optional<double[]> getMinMaxByDialog(Component parent, String title, String message, double initialMin, double initialMax, double min, double max)
parent
- parent componenttitle
- titlemessage
- messageinitialMin
- initial minimum valueinitialMax
- initial maximum 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 makeToggleButtonReadonly(JToggleButton toggleButton)
toggleButton
- toggle buttonpublic static JTextField createReadonlyTextField(String value)
value
- textpublic static JTextArea createReadonlyTextArea(String text)
text
- textpublic static JTextPane createReadonlyTextPane(String text)
text
- textpublic static void setJTextPaneFont(JTextPane jtp, Font font, Color c)
public static JTextPane createBorderlessReadonlyTextPane(String text, boolean opaque)
text
- textopaque
- if the area should be opaquepublic static void setTextPaneFont(JTextPane textPane, String fontFamily, int fontSize)
public static JTextField createReadonlyBorderlessTextField(String value)
value
- textpublic static JTextArea createReadonlyBorderlessTextArea(String text)
text
- textpublic static JTextPane createMarkdownReader(MarkdownText 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 JMenuItem getMenuItem(JComponent menu, int index)
public static int getMenuItemCount(JComponent menu)
public static Map<String,JComponent> createMenuTree(JPopupMenu 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 createURLLabel(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 void addSeparatorIfNeeded(JPopupMenu menu)
menu
- the menupublic static void addSeparatorIfNeeded(JMenu menu)
menu
- the menupublic static void showConnectionErrorMessage(Component parent, JIPipeDataSlot source, JIPipeDataSlot target)
public static void invokeScrollToTop(JScrollPane scrollPane)
public static void invokeScrollToBottom(JScrollPane scrollPane)
public static JMenuItem createMenuItem(String label, String description, Icon icon, Runnable action)
public static void drawStringVerticallyCentered(Graphics2D g2, String text, int x, int y, FontMetrics fontMetrics)
public static void removeAllWithDispose(JComponent component)
public static Map<?,?> getDesktopRenderingHints()
public static JButton createIconOnlyButton(String text, Icon icon, Runnable function)
public static JButton createStandardButton(String text, ImageIcon icon, Runnable action)
public static JButton createLeftAlignedButton(String text, ImageIcon icon, Runnable action)
public static Border createSuccessBorder()
public static <T extends AbstractButton> T makeButtonHighlightedSuccess(T button)
public static <T extends JComponent> T setFontSize(T component, int fontSize)
public static Border createEmptyBorder(int i)
public static JIPipeDesktopUITheme getTheme()
public static void repaintLater(Component component)
public static void requestFocusOnShown(JComponent component)
public static void makeNonOpaque(Component component, boolean recursive)
public static void invokeMuchLater(int timeout, Runnable run)
public static JPanel borderNorthSouth(JComponent north, JComponent south)
public static JPanel borderNorthCenter(JComponent north, JComponent center)
public static <T> DefaultComboBoxModel<T> toComboBoxModel(Collection<T> elements)
public static <T> DefaultListModel<T> toListModel(Collection<T> elements)
public static <T extends JComponent> T setStandardControlBorder(T component)
public static JPanel wrapInEmptyBorder(JComponent component, int borderSize)
Copyright © 2020–2025 Leibniz Institute for Natural Product Research and Infection Biology - Hans Knöll Institute (HKI). All rights reserved.