com.im.ijc.core/1 5.9.4

com.im.ijc.core.api.util
Class IJCCoreUtils

java.lang.Object
  extended by com.im.ijc.core.api.util.IJCCoreUtils

public final class IJCCoreUtils
extends Object


Nested Class Summary
static class IJCCoreUtils.PrintUtilities
          Purpose of this class is to be used for getting the print settings that should be shared for all prints in IJC
 
Method Summary
static void annotateException(Throwable t, String localizedMessage)
           
static Task applyChangesWithProgress(DFCustomizer customizer)
           
static Task applyChangesWithProgress(DFCustomizer customizer, String progressName, String errorMsg)
           
static IJCWidget.DesignerHandle bounded(IJCWidget.DesignerHandle ijcw, DFView view)
           
static String checkProjectProtocol(String urif)
          Check if URL is using our private project: protocol
static DFResultSet.VertexState computeCommonVS(IJCWidget widget)
           
static DFResultSet.VertexState computeCommonVS(IJCWidgetCookie widgetCookie)
          TODO P1 - fix this method to take array of IJCWidgetCookies Computes the VertexState common for all selected widgets.
static List<DFField> computeFields(IJCWidget widget, boolean bindOrSelected, boolean onlyIfAllInOneEntity)
          TODO P1 - fix this method to take array of IJCWidget Compute the union of all fields from the widget.
static List<DFField> computeFields(IJCWidgetCookie widgetCookie, boolean bindOrSelected, boolean onlyIfAllInOneEntity)
          Deprecated. use computeFields(com.im.ijc.core.api.views.IJCWidget, boolean, boolean) instead
static List<? extends Object> convertListValues(DFField sourceField, DFField targetField, List<? extends Object> sourceValues, boolean forceValidation, DFEnvironmentRO env)
          Convert list of values of sourceField to values for targetField
static NewDFItemWizardIterator<DFEntity> createNewEntityWizard(DFSchema ijcSchema, List<DFNewType<DFEntity>> newtypes, boolean createDataTree, boolean createView, WizardDescriptor.Panel extraPanel, Dimension size)
          Creates a new DFEntity, based on the newtypes passed.
static SchemaSelector createSchemaSelector(boolean selectOnlyWriteableSchema)
          Creates a default implementation of SchemaSelector.
static String createWrappedText(String text, String wrapSymbol, int limitInPixel, FontMetrics fm)
          Text will be formatted so that the string would be smart-wrapped to fit the multi-line text area
static void deleteDataFromSelection(IJCWidget widget, boolean delOrCut)
           
static void deleteDataFromSelection(IJCWidgetCookie widgetCookie, boolean delOrCut)
           
static Action findActionFromLayer(String resourceName)
           
static List<DFResultSet> findActiveResultSetsFor(DFEntity entity)
          Find all active result sets where the given entity participates in.
static List<DFEntity> findEntities(Node[] activatedNodes)
           
static List<DFField> findFields(Node[] activatedNodes)
           
static DFNewType<DFList> findNewListNT(DFEntity entity)
           
static DFNewType<DFQuery> findNewQueryNT(DFDataTree dataTree)
           
static String findProjectPath(DFSchema schema)
           
static List<DFRelationship> findRelationships(Node[] activatedNodes)
           
static String findSelectedProjectPath()
           
static DFResultSet.VertexState findVertexState(Node[] nodes)
          Computes the VertexState common for all nodes.
static String formatStringForHtmlOutput(String text)
          given text will be formated so as it could be displayed in HTML format
static String generateNewListOrQueryName()
          Generate default name for a new temporary or permanent list or query.
static List<? extends Comparable<?>> getAssociatedIDs(SelectionDescription selection, DFResultSet.VertexState vs)
          Returns list of IDs (primary key values) for the given selection.
static char[] getBreakChars()
           
static Image getIconResource(Class<?> clazz, int iconType)
           
static Image getIconResource(DFItem item, int iconType)
           
static Comparator<Node> getNodeComparator(boolean ascending)
           
static Object[] getValuesFromExpression(DFTermExpression expr)
          Unwrap the values objects from list of operands.
static boolean isDefaultListOrQueryName(String name)
          Is the name of default format?
static boolean isJavaWebstart()
          Check if IJC is running from java webstart
static Action[] loadActionsForNode(String key, Action[] addBefore, Action[] addAfter)
          Load actions from layer.
static void reloadDataInResultSetsFor(DFEntity entity, boolean askUser)
          This method first finds all active result sets where the given entity participates in.
static void selectInProjects(DataObject dobj, boolean selectIt)
          Expand the node for the given connection (schema) in "Projects explorer"
static void selectInProjects(DFDataTree item, boolean selectIt)
          Expand the node for the given dataTree in "Projects explorer".
static void selectInProjects(DFSchema item, boolean selectIt)
          Expand the node for the given schema in "Projects explorer".
static void selectInProjects(DFScript item, boolean selectIt)
          Expand the node for the given script in "Projects explorer".
static void selectInProjects(DFView item, boolean selectIt)
          Expand the node for the given view in "Projects explorer".
static void setNewSelection(DFResultSet.VertexState vertexState, int delta)
          Set new selection on background.
static void setNewSelection(DFResultSet.VertexState vertexState, SelectionDescription selection)
          Set new selection on background.
static void setNewSelection(DFResultSet.VertexState vertexState, SelectionDescription selection, boolean synchronously)
          Set selection in vertexState and wail till selection is done.
static void setNewSort(DFResultSet.VertexState vertexState, SortDirective newSort)
           
static boolean showLicenseExpiredDialog(Throwable exception)
           
static boolean showLicenseExpiredDialog(Throwable exception, boolean showEveryTime)
          If the license or it cause is License exception it will show dialog with license excpetion.
static void switchAllOpenedViewsMode(DFDataTree dt, ViewMode viewMode)
           
static MarvinStructure tryToGetStructureOperand(DFTermExpression expr, boolean returnEmptyStructureInsteadOfNull)
          Try to get MarvinStructure operand from the expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

applyChangesWithProgress

public static Task applyChangesWithProgress(DFCustomizer customizer)

applyChangesWithProgress

public static Task applyChangesWithProgress(DFCustomizer customizer,
                                            String progressName,
                                            String errorMsg)

createSchemaSelector

public static SchemaSelector createSchemaSelector(boolean selectOnlyWriteableSchema)
Creates a default implementation of SchemaSelector.


getIconResource

public static Image getIconResource(DFItem item,
                                    int iconType)

getIconResource

public static Image getIconResource(Class<?> clazz,
                                    int iconType)

setNewSelection

public static void setNewSelection(DFResultSet.VertexState vertexState,
                                   SelectionDescription selection)
Set new selection on background.


setNewSelection

public static void setNewSelection(DFResultSet.VertexState vertexState,
                                   int delta)
Set new selection on background.


setNewSelection

public static void setNewSelection(DFResultSet.VertexState vertexState,
                                   SelectionDescription selection,
                                   boolean synchronously)
Set selection in vertexState and wail till selection is done.

Parameters:
vertexState - working vertexState
selection - new selection
synchronously - it will wail till selection is done if it's true.

getAssociatedIDs

public static List<? extends Comparable<?>> getAssociatedIDs(SelectionDescription selection,
                                                             DFResultSet.VertexState vs)
Returns list of IDs (primary key values) for the given selection.

Parameters:
selection - selected indexes
vs - might be null in which case empty list is returned
Returns:
list of IDs

setNewSort

public static void setNewSort(DFResultSet.VertexState vertexState,
                              SortDirective newSort)

findSelectedProjectPath

public static String findSelectedProjectPath()

findProjectPath

public static String findProjectPath(DFSchema schema)

deleteDataFromSelection

public static void deleteDataFromSelection(IJCWidgetCookie widgetCookie,
                                           boolean delOrCut)

deleteDataFromSelection

public static void deleteDataFromSelection(IJCWidget widget,
                                           boolean delOrCut)

computeCommonVS

public static DFResultSet.VertexState computeCommonVS(IJCWidgetCookie widgetCookie)
TODO P1 - fix this method to take array of IJCWidgetCookies Computes the VertexState common for all selected widgets. Returns some non-null value only if at least one widget has specified VertexState and all selected widgets has the same VertexState.

Parameters:
widgetCookie - The cookies which provides the selected widget
Returns:
The common VertexState or null

computeCommonVS

public static DFResultSet.VertexState computeCommonVS(IJCWidget widget)

findVertexState

public static DFResultSet.VertexState findVertexState(Node[] nodes)
Computes the VertexState common for all nodes. Returns some non-null value only if at least one widget has specified VertexState and all nodes have the same VertexState. This method uses VertexStateCookie and IJCWidgetCookie for obtaining the VertexState.

Parameters:
nodes - The nodes where you are looking for the common vertex state
Returns:
The common VertexState or null

computeFields

public static List<DFField> computeFields(IJCWidget widget,
                                          boolean bindOrSelected,
                                          boolean onlyIfAllInOneEntity)
TODO P1 - fix this method to take array of IJCWidget Compute the union of all fields from the widget.

Parameters:
widget - the widget to be used
bindOrSelected - If true bound fields are computed, if false then only selected fields
onlyIfAllInOneEntity - If false then it requires all fields must be from the same entity (VertexState). If there are widgets which are bound to fields from different entity and this parameter is true, the method will return empty list.
Returns:
The union of all fields. Each field is there only once.

computeFields

public static List<DFField> computeFields(IJCWidgetCookie widgetCookie,
                                          boolean bindOrSelected,
                                          boolean onlyIfAllInOneEntity)
Deprecated. use computeFields(com.im.ijc.core.api.views.IJCWidget, boolean, boolean) instead


findEntities

public static List<DFEntity> findEntities(Node[] activatedNodes)

findRelationships

public static List<DFRelationship> findRelationships(Node[] activatedNodes)

annotateException

public static void annotateException(Throwable t,
                                     String localizedMessage)

findFields

public static List<DFField> findFields(Node[] activatedNodes)

getNodeComparator

public static Comparator<Node> getNodeComparator(boolean ascending)

findActiveResultSetsFor

public static List<DFResultSet> findActiveResultSetsFor(DFEntity entity)
Find all active result sets where the given entity participates in.

Parameters:
entity - The entity
Returns:
The list of result sets

reloadDataInResultSetsFor

public static void reloadDataInResultSetsFor(DFEntity entity,
                                             boolean askUser)
This method first finds all active result sets where the given entity participates in. Then reload data in all of them on background. It can be used by import for example, because data in all opened views should be reloaded when import is finished. Otherwise result sets are not reloaded and won't contain the newly imported rows.

Parameters:
entity - The entity which was updated

selectInProjects

public static void selectInProjects(DFSchema item,
                                    boolean selectIt)
Expand the node for the given schema in "Projects explorer".

Parameters:
item - The s chema to shown in explorer
selectIt - Selects the node in explorer (if false the node is just expanded).

selectInProjects

public static void selectInProjects(DFDataTree item,
                                    boolean selectIt)
Expand the node for the given dataTree in "Projects explorer".

Parameters:
item - The d atatree to shown in explorer
selectIt - Selects the node in explorer (if false the node is just expanded).

selectInProjects

public static void selectInProjects(DFScript item,
                                    boolean selectIt)
Expand the node for the given script in "Projects explorer".

Parameters:
item - The script to shown in explorer
selectIt - Selects the node in explorer (if false the node is just expanded).

selectInProjects

public static void selectInProjects(DFView item,
                                    boolean selectIt)
Expand the node for the given view in "Projects explorer".

Parameters:
item - The v iew to shown in explorer
selectIt - Selects the node in explorer (if false the node is just expanded).

selectInProjects

public static void selectInProjects(DataObject dobj,
                                    boolean selectIt)
Expand the node for the given connection (schema) in "Projects explorer"

Parameters:
dobj - The d ataobject to shown in explorer. It must be some dataobject directly under project node e.g. SchemaConnectionDataObject.
selectIt - Selects the node in explorer (if false the node is just expanded).

createNewEntityWizard

public static NewDFItemWizardIterator<DFEntity> createNewEntityWizard(DFSchema ijcSchema,
                                                                      List<DFNewType<DFEntity>> newtypes,
                                                                      boolean createDataTree,
                                                                      boolean createView,
                                                                      WizardDescriptor.Panel extraPanel,
                                                                      Dimension size)
Creates a new DFEntity, based on the newtypes passed. Displays Wizard UI for setting up the entity. After the entity is created, a default DataTree is created for it with an initial View.

The function returns the Wizard iterator so you can wait on the task finish.

Caution - when the Creation task finishes, the datatree and view might not be yet created.

Parameters:
ijcSchema - The target Schema
newtypes - The applicable NewTypes
Returns:
The WizardIterator creating the entity.

formatStringForHtmlOutput

public static String formatStringForHtmlOutput(String text)
given text will be formated so as it could be displayed in HTML format


getBreakChars

public static char[] getBreakChars()
Returns:
array of characters defining suitable places to break text in text components.

createWrappedText

public static String createWrappedText(String text,
                                       String wrapSymbol,
                                       int limitInPixel,
                                       FontMetrics fm)
Text will be formatted so that the string would be smart-wrapped to fit the multi-line text area


switchAllOpenedViewsMode

public static void switchAllOpenedViewsMode(DFDataTree dt,
                                            ViewMode viewMode)

getValuesFromExpression

public static Object[] getValuesFromExpression(DFTermExpression expr)
Unwrap the values objects from list of operands. It is expected that the first operand is the field (DFTermField) so this method returns only values from 2nd, 3rd, ... operand. If there is any operand (except the first one representing field) which is not instance of DFTermValue this method throws IllegalArgumentException!

The reason of this method is that if you want to create new DFTermExpression using DFTermsFactory methods you need to put there List of values and not List of DFTermValue objects. This method makes this common code simpler.

Parameters:
expr - The expression to be
Returns:
The values of the DFTermValues as an array

tryToGetStructureOperand

public static MarvinStructure tryToGetStructureOperand(DFTermExpression expr,
                                                       boolean returnEmptyStructureInsteadOfNull)
Try to get MarvinStructure operand from the expression. It is expected that structure is 2nd operand (the 1st one if the field). The second operand must be of DFTermValue type and the value itself must be MarvinStructure instance. Otherwise returns null (but see the second method parameter!)

Parameters:
expr - The structure expression.
returnEmptyStructureInsteadOfNull - If structure is not found should the method return a new empty instance of MarvinStructure instead of null?
Returns:
MarvinStructure or null. If returnEmptyStructureInsteadOfNull, the method never returns null.

findActionFromLayer

public static Action findActionFromLayer(String resourceName)

showLicenseExpiredDialog

public static boolean showLicenseExpiredDialog(Throwable exception,
                                               boolean showEveryTime)
If the license or it cause is License exception it will show dialog with license excpetion.

Parameters:
exception - The attached exception
Returns:
True if license exception was found

showLicenseExpiredDialog

public static boolean showLicenseExpiredDialog(Throwable exception)

generateNewListOrQueryName

public static String generateNewListOrQueryName()
Generate default name for a new temporary or permanent list or query. The current implementation is using SHORT version of Time instance of DateFormat. It means currently new temporary lists and queries are named with current time e.g. "12:55".

Returns:
The new list/query name

isDefaultListOrQueryName

public static boolean isDefaultListOrQueryName(String name)
Is the name of default format?

Returns:
True if name matches default "new list or query" name.

loadActionsForNode

public static Action[] loadActionsForNode(String key,
                                          Action[] addBefore,
                                          Action[] addAfter)
Load actions from layer. Actions are are expected in folder IJC/UI/Nodes/{nameOfThisNodeUsecase}

Parameters:
key - The name of folder under IJC/UI/Nodes for example "EntityInSchemaEditor"
addBefore - Add these actions before actions loaded from layer
addAfter - Add these actions after actions loaded from layer
Returns:
The complete array of actions

isJavaWebstart

public static boolean isJavaWebstart()
Check if IJC is running from java webstart

Returns:
True on javaWebstart

checkProjectProtocol

public static String checkProjectProtocol(String urif)
Check if URL is using our private project: protocol

Parameters:
urif - URL string
Returns:
The urif or URL string without project: protocol, prefixed with project path

bounded

public static IJCWidget.DesignerHandle bounded(IJCWidget.DesignerHandle ijcw,
                                               DFView view)

convertListValues

public static List<? extends Object> convertListValues(DFField sourceField,
                                                       DFField targetField,
                                                       List<? extends Object> sourceValues,
                                                       boolean forceValidation,
                                                       DFEnvironmentRO env)
Convert list of values of sourceField to values for targetField

Parameters:
sourceField - Source field whose values are going to be converted
targetField - Field whose values are expected as result of this method
sourceValues - Values of sourceField
forceValidation - When true then this operation is going to SELECT database even when source and target field is the same. In other words it does validation and filters out non-existing values. When false this returns sourceValues if sourceValues == targetField.
env - Environment for monitoring progress
Returns:
The converted list values, never returns null

findNewListNT

public static DFNewType<DFList> findNewListNT(DFEntity entity)

findNewQueryNT

public static DFNewType<DFQuery> findNewQueryNT(DFDataTree dataTree)

com.im.ijc.core/1 5.9.4