Class InputTableHelper
java.lang.Object
com.illumon.iris.console.utils.input.InputTableHelper
public class InputTableHelper extends Object
A Helper Class for performing UI Related Actions on a MutableInputTable.
-
Constructor Summary
Constructors Constructor Description InputTableHelper()
-
Method Summary
Modifier and Type Method Description static JMenuItem
clipboardAwarePasteMenu(Clipboard clipboard, MutableInputTable inputTable, GuiTable guiTable, com.fishlib.io.logger.Logger log)
Builds a context-aware menu-item or sub-menu for paste based on the current contents of the clipboardstatic void
copyKey(MutableInputTable it, Table table, int index, InputTableStatusListener listener)
Copy the specified row of the input table, using the parameter table as the source of initial data.static void
deleteKeysWithAbort(com.fishlib.io.logger.Logger log, MutableInputTable it, Table table, Component parentComponent, int... positions)
Delete the specified rows, after prompting the user.static void
editKey(MutableInputTable it, Table table, int index, InputTableStatusListener listener)
Edit the specified row of the input table, using the parameter table as the source of initial data.static void
newElement(MutableInputTable it, InputTableStatusListener listener)
Create and add a new element to the input table.static void
pasteRows(MutableInputTable inputTable, com.fishlib.io.logger.Logger log, GuiTable guiTable)
Attempts to paste the contents of the clipboard into an InputTable.static void
setField(MutableInputTable it, Table table, String columnName, int[] rows, InputTableStatusListener listener)
Edit the value of the specified column for all specified rows.static void
setField(MutableInputTable it, Table table, String columnName, int[] rows, Object newValue, InputTableStatusListener listener)
Set the value of the specified column for all specified rows.
-
Constructor Details
-
InputTableHelper
public InputTableHelper()
-
-
Method Details
-
newElement
Create and add a new element to the input table. This method will open a dialog and therefore must be invoked on the UI thread,- Parameters:
it
- The input table to uselistener
- A listener to handle the result of the write.
-
editKey
public static void editKey(MutableInputTable it, Table table, int index, @NotNull InputTableStatusListener listener)Edit the specified row of the input table, using the parameter table as the source of initial data. This method must be invoked on the UI thread.- Parameters:
it
- The input table to usetable
- The table containing original dataindex
- The row to edit.listener
- A listener to handle the result of the asynchronous write.
-
copyKey
public static void copyKey(MutableInputTable it, Table table, int index, @NotNull InputTableStatusListener listener)Copy the specified row of the input table, using the parameter table as the source of initial data. This method must be invoked on the UI thread.- Parameters:
it
- The input table to usetable
- The table containing original dataindex
- The row to edit.listener
- A listener to handle the result of the asynchronous write.
-
setField
public static void setField(MutableInputTable it, Table table, String columnName, int[] rows, @NotNull InputTableStatusListener listener)Edit the value of the specified column for all specified rows. This method must be invoked on the UI thread.- Parameters:
it
- The input table to usetable
- The table containing original datacolumnName
- The column to edit.rows
- The rows to edit.listener
- A listener to handle the result of the asynchronous write.
-
setField
public static void setField(MutableInputTable it, Table table, String columnName, int[] rows, Object newValue, @NotNull InputTableStatusListener listener)Set the value of the specified column for all specified rows. This method must be invoked on the UI thread.- Parameters:
it
- The input table to usetable
- The table containing original datacolumnName
- The column to edit.rows
- The rows to edit.newValue
- The value to set.listener
- A listener to handle the result of the asynchronous write.
-
deleteKeysWithAbort
public static void deleteKeysWithAbort(com.fishlib.io.logger.Logger log, MutableInputTable it, Table table, Component parentComponent, int... positions)Delete the specified rows, after prompting the user. This method must be invoked on the UI thread.- Parameters:
log
- A log to record results.it
- The input table to usetable
- The source of dataparentComponent
- The component invokingpositions
- The rows to delete.
-
clipboardAwarePasteMenu
@NotNull public static JMenuItem clipboardAwarePasteMenu(Clipboard clipboard, MutableInputTable inputTable, GuiTable guiTable, com.fishlib.io.logger.Logger log)Builds a context-aware menu-item or sub-menu for paste based on the current contents of the clipboard- Parameters:
clipboard
- the system clipboardinputTable
- the table which is used to identify column-types and targeted for paste-operationsguiTable
- a component to identify error-dialog locationlog
- a logger used for potential troubleshooting- Returns:
- a JMenuItem, which may be a sub-menu providing valid paste-operations for the current clipboard contents
-
pasteRows
public static void pasteRows(MutableInputTable inputTable, com.fishlib.io.logger.Logger log, GuiTable guiTable)Attempts to paste the contents of the clipboard into an InputTable. If the contents of the clip board parse into rows a dialog will pop up asking the user to confirm the paste.- Parameters:
inputTable
- the InputTable to paste intolog
- the loggerguiTable
- a component parent for dialogs and defining column-display order
-