com.im.ijc.widgets/1 5.9.1

com.im.ijc.widgets.common
Class CommonWidgetsUtils

java.lang.Object
  extended by com.im.ijc.widgets.common.CommonWidgetsUtils

public final class CommonWidgetsUtils
extends Object

Common Widgets utilities.


Nested Class Summary
static class CommonWidgetsUtils.TreeCategory
           
 
Method Summary
static List<? extends DFItem> acceptItems(DFDataTree.Vertex vertex, BindFieldAcceptor acceptor, boolean recursive)
          Recursively traverse subtree of the given vertex and returns all items accepted by the given acceptor.
static void acceptItemsAsTree(List<CommonWidgetsUtils.TreeCategory> treeCollector, DFDataTree.Vertex vertex, BindFieldAcceptor acceptor)
           
static void acceptItemsAsTreeAndList(List<CommonWidgetsUtils.TreeCategory> treeCollector, List<DFItem> listCollector, DFDataTree.Vertex vertex, BindFieldAcceptor acceptor)
           
static void addActionToMenu(JPopupMenu menu, Action action)
           
static void addActionToMenu(JPopupMenu menu, Action action, Boolean checked)
           
static void addActionToMenu(JPopupMenu menu, Class<? extends SystemAction> actionClass)
           
static void addLayerSubmenu(JPopupMenu menu, DatasetType fgDatasetType, Function<DatasetType,Void> callback)
           
static boolean canStartTableCellEditing(EventObject anEvent)
          Performs a check if an event can initiate cell editing in a table.
static String computeExpressionAsText(DFTermExpression expr)
           
static String computeExpressionAsText(DFTermExpression expr, String originalText)
           
static JPopupMenu createOperatorPopupMenu(DFResultSet rs, DFField field, Runnable runInAWT)
          Create popup menu for selection all available operators for the given field.
static
<T> WidgetSettingsWithRenderer<T>
createSettings()
           
static MouseListener createStartEditMouseListener(IJCWidget.Editable widget)
          Simple factory to create a mouse listener that initiates editing on a mouse double click.
static void executeQuery(DFView view)
           
static Object findFieldInQuery(DFField field, DFTermExpression term)
          Tries to find the bound field in given result set's working query.
static MarvinStructure findStructureInQuery(DFField field, DFTermExpression term)
           
static List<? extends DFField> getAllFields(DFDataTree dataTree)
           
static List<? extends DFField> getAllFields(DFView view)
           
static CommonWidgetSettings getCommonWidgetSettings(Object storedSettings)
           
static List<? extends DFField> getNumericFields(DFDataTree tree, boolean recursive)
           
static SelectionDescription getRelativeSelection(SelectionDescription selection, DatasetType datasetType)
           
static SelectionDescription getWidgetSelection(SelectionDescription selection, DatasetType datasetType)
           
static
<T> WidgetSettingsWithRenderer<T>
getWidgetSettingsWithRenderer(Class<T> rendererClass, Object storedSettings, Compatibility compatibility)
          Returns an instance of widget settings properly initialized with the old settings - a renderer; if the old settings is being restored or just casted instance of the widget settings.
static boolean isRelationFields(DFField field)
          Check if field is part of relation.
static void notifyErrorWhenSettingValue(Exception exc)
           
static
<T> boolean
openPropertySheetFor(Iterable<T> beans)
          Open the dialog with property sheet.
static boolean queryUpdateRSFromTextWidget(DFResultSet rs, DFField field, String newExpressionAsText, Runnable beforeRSUpdate, Runnable afterRSUpdate)
          Helper utility method used by text widget and table widget.
static boolean queryValidateFromTextWidget(DFResultSet rs, DFField field, String newExpressionAsText)
          Helper utility method used by text widget and table widget.
static void registerStandardKeys(JComponent comp, IJCWidget.Editable widget)
          Maps Edit (F2), Delete, Cut, Copy and Paste keys to standard actions.
static void setCFFieldsValues(Object renderer, DFResultSet.VertexState vs)
           
static void setDeleteAction(JComponent comp, Action action)
          Sets given action as a delete action of the given component.
static void setToolTipError(TermErrors errors, JComponent component)
           
static void setToolTipError(TermErrors errors, String toolTipWhenNoErrors, JComponent component)
          Set tooltip hint for components in query mode.
static void tryToCustomizeStructureRenderer(Object renderer)
           
static void tryToSetOperatorToStructureRenderer(Object renderer, DFTermExpression expr)
           
static boolean updateMoleculeInQuery(DFResultSet rs, DFField field, MarvinStructure mol)
           
static boolean updateOperatorOrOptionsInQuery(DFResultSet rs, DFField field, DFOperator operator, Map<String,Object> options, Runnable runInAWT)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

canStartTableCellEditing

public static boolean canStartTableCellEditing(EventObject anEvent)
Performs a check if an event can initiate cell editing in a table. Current requires double click to start editing.

See Also:
DefaultCellEditor.setClickCountToStart(int)

openPropertySheetFor

public static <T> boolean openPropertySheetFor(Iterable<T> beans)
Open the dialog with property sheet.

Parameters:
beans - The bean(s) to be customized
Returns:
The status of the operation. true means data were potentially changed, false means beans wasn't changed.

findFieldInQuery

public static Object findFieldInQuery(DFField field,
                                      DFTermExpression term)
Tries to find the bound field in given result set's working query. If there is only a single expression where this field takes part it returns the DFTermExpression instance. In all other cases it returns one of SpecialWidgetValue suitable for query mode (UNBOUND, MULTIPLE_QUERIES, NOT_PART_OF_QUERY).

Parameters:
field - The field which you are looking for. Can be null
term - The term where you are looking for the field occurrences. Can be null
Returns:
DFTermExpression or SpecialWidgetValue instance. Never returns null

findStructureInQuery

public static MarvinStructure findStructureInQuery(DFField field,
                                                   DFTermExpression term)

computeExpressionAsText

public static String computeExpressionAsText(DFTermExpression expr,
                                             String originalText)
Parameters:
expr - expression
originalText - user's original input
Returns:
text representation of an Expression, respects user's input (prefer typed text if the only difference is whitespaces or comma)

computeExpressionAsText

public static String computeExpressionAsText(DFTermExpression expr)

queryValidateFromTextWidget

public static boolean queryValidateFromTextWidget(DFResultSet rs,
                                                  DFField field,
                                                  String newExpressionAsText)
Helper utility method used by text widget and table widget. This method tries to parse the given expression part in text and validate the query in given result set context.

Parameters:
rs - Result set for which the expression should be validated
field - The field for this expression
newExpressionAsText - The text version of the expression (without field name).
Returns:
Returns true if current expression is valid otherwise false.

queryUpdateRSFromTextWidget

public static boolean queryUpdateRSFromTextWidget(DFResultSet rs,
                                                  DFField field,
                                                  String newExpressionAsText,
                                                  Runnable beforeRSUpdate,
                                                  Runnable afterRSUpdate)
Helper utility method used by text widget and table widget. This method tries to parse the given expression part in text and update the query in result set.

Parameters:
rs - Result set where the expression should be updated
field - The field for this expression
newExpressionAsText - The text version of the expression (without field name).
beforeRSUpdate - This Runnable is executed just before DFResultSet.setWorkingQuery method call. Can be null.
afterRSUpdate - This Runnable is executed after DFResultSet.setWorkingQuery method call. Can be null.
Returns:
Returns true if current expression is valid otherwise false.

setToolTipError

public static void setToolTipError(TermErrors errors,
                                   String toolTipWhenNoErrors,
                                   JComponent component)
Set tooltip hint for components in query mode.

Parameters:
errors - Can be null - then it means there is no error and default tooltip will be used. If there are errors, then the first error message is used as a tooltip.
toolTipWhenNoErrors - In the case that there is no error this tooltip will be used
component - The component where tooltip will be set

setToolTipError

public static void setToolTipError(TermErrors errors,
                                   JComponent component)

updateMoleculeInQuery

public static boolean updateMoleculeInQuery(DFResultSet rs,
                                            DFField field,
                                            MarvinStructure mol)

createOperatorPopupMenu

public static JPopupMenu createOperatorPopupMenu(DFResultSet rs,
                                                 DFField field,
                                                 Runnable runInAWT)
Create popup menu for selection all available operators for the given field. All actions in this menu are connected to given result set and the field. If user chooses the operator in popup menu the expression using the field is changed to this new operator (if existed before), otherwise it is added as a new sub-expression with no arguments just this operator (which means it's usually invalid).

Parameters:
rs - The base resultset object - new working query will be set to this result set
field - The field bound to the widget which is invoking this popup menu
runInAWT - The special runnable to be executed in AWT thread after operator is changed.
Returns:
The valid and fully functional popup menu changing operators.

addActionToMenu

public static void addActionToMenu(JPopupMenu menu,
                                   Action action,
                                   Boolean checked)

registerStandardKeys

public static void registerStandardKeys(JComponent comp,
                                        IJCWidget.Editable widget)
Maps Edit (F2), Delete, Cut, Copy and Paste keys to standard actions.


createStartEditMouseListener

public static MouseListener createStartEditMouseListener(IJCWidget.Editable widget)
Simple factory to create a mouse listener that initiates editing on a mouse double click.


updateOperatorOrOptionsInQuery

public static boolean updateOperatorOrOptionsInQuery(DFResultSet rs,
                                                     DFField field,
                                                     DFOperator operator,
                                                     Map<String,Object> options,
                                                     Runnable runInAWT)

tryToCustomizeStructureRenderer

public static void tryToCustomizeStructureRenderer(Object renderer)

tryToSetOperatorToStructureRenderer

public static void tryToSetOperatorToStructureRenderer(Object renderer,
                                                       DFTermExpression expr)

isRelationFields

public static boolean isRelationFields(DFField field)
Check if field is part of relation.


executeQuery

public static void executeQuery(DFView view)

acceptItems

public static List<? extends DFItem> acceptItems(DFDataTree.Vertex vertex,
                                                 BindFieldAcceptor acceptor,
                                                 boolean recursive)
Recursively traverse subtree of the given vertex and returns all items accepted by the given acceptor. Among fields, items includes also owning entities for which the number of their accepted fields were more then zero or if acceptor accepts empty entities.

Parameters:
vertex - root of a subtree to be traversed
acceptor - field acceptor
recursive - if true traverse recursively
Returns:
list of all accepted items

acceptItemsAsTree

public static void acceptItemsAsTree(List<CommonWidgetsUtils.TreeCategory> treeCollector,
                                     DFDataTree.Vertex vertex,
                                     BindFieldAcceptor acceptor)

acceptItemsAsTreeAndList

public static void acceptItemsAsTreeAndList(List<CommonWidgetsUtils.TreeCategory> treeCollector,
                                            List<DFItem> listCollector,
                                            DFDataTree.Vertex vertex,
                                            BindFieldAcceptor acceptor)

getNumericFields

public static List<? extends DFField> getNumericFields(DFDataTree tree,
                                                       boolean recursive)

getAllFields

public static List<? extends DFField> getAllFields(DFDataTree dataTree)

getAllFields

public static List<? extends DFField> getAllFields(DFView view)

addActionToMenu

public static void addActionToMenu(JPopupMenu menu,
                                   Class<? extends SystemAction> actionClass)

addActionToMenu

public static void addActionToMenu(JPopupMenu menu,
                                   Action action)

getWidgetSettingsWithRenderer

public static <T> WidgetSettingsWithRenderer<T> getWidgetSettingsWithRenderer(Class<T> rendererClass,
                                                                              Object storedSettings,
                                                                              Compatibility compatibility)
Returns an instance of widget settings properly initialized with the old settings - a renderer; if the old settings is being restored or just casted instance of the widget settings.

Type Parameters:
T - type of old settings
Parameters:
rendererClass - class of old renderer
storedSettings - currently stored settings. Might be WidgetSettingsWithRenderer instance or old renderer instance
compatibility - Compatibility object
Returns:
widget settings

createSettings

public static <T> WidgetSettingsWithRenderer<T> createSettings()

getCommonWidgetSettings

public static CommonWidgetSettings getCommonWidgetSettings(Object storedSettings)

setCFFieldsValues

public static void setCFFieldsValues(Object renderer,
                                     DFResultSet.VertexState vs)

notifyErrorWhenSettingValue

public static void notifyErrorWhenSettingValue(Exception exc)

addLayerSubmenu

public static void addLayerSubmenu(JPopupMenu menu,
                                   DatasetType fgDatasetType,
                                   Function<DatasetType,Void> callback)

getWidgetSelection

public static SelectionDescription getWidgetSelection(SelectionDescription selection,
                                                      DatasetType datasetType)

getRelativeSelection

public static SelectionDescription getRelativeSelection(SelectionDescription selection,
                                                        DatasetType datasetType)

setDeleteAction

public static void setDeleteAction(JComponent comp,
                                   Action action)
Sets given action as a delete action of the given component. The action will be invoked on pressing Delete key.

Parameters:
comp - target component
action - action to be performed

com.im.ijc.widgets/1 5.9.1