com.im.ijc.core/1 2.4

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

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

public 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
 
Constructor Summary
IJCCoreUtils()
           
 
Method Summary
static void annotateException(Throwable t)
           
static void annotateException(Throwable t, String localizedMessage)
           
static Task applyChangesWithProgress(DFCustomizer customizer)
           
static Task applyChangesWithProgress(DFCustomizer customizer, String progressName, String errorMsg)
           
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(IJCWidgetCookie ovc, boolean bindOrSelected, boolean onlyIfAllInOneEntity)
          TODO P1 - fix this method to take array of IJCWidgetCookies Compute the union of all fields from the selected widgets given by IJCWidgetCookie.
static com.im.ijc.core.wizards.newdfitem.NewDFItemWizardIterator<DFEntity> createNewEntityWizard(DFSchema schema, List<DFNewType<DFEntity>> newtypes, boolean createDataTree, boolean createView)
          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(IJCWidgetCookie ovc, 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 List<DFRelationship> findRelationships(Node[] activatedNodes)
           
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 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 Action[] loadActionsForNode(String key, Action[] addBefore, Action[] addAfter)
          Load actions from layer.
static Color mixColors(Color a, Color b, float balance)
          Computes the colour between the given two colours according to balance (0.0-1.0).
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(DFView item, boolean selectIt)
          Expand the node for the given view in "Projects explorer".
static void setNewSelection(DFResultSet.VertexState vertexState, int delta)
           
static void setNewSelection(DFResultSet.VertexState vertexState, SelectionDescription selection)
           
static void setNewSort(DFResultSet.VertexState vertexState, SortDirective newSort)
           
static boolean showLicenseExpiredDialog(Throwable exception)
          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
 

Constructor Detail

IJCCoreUtils

public IJCCoreUtils()
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)

setNewSelection

public static void setNewSelection(DFResultSet.VertexState vertexState,
                                   int delta)

setNewSort

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

deleteDataFromSelection

public static void deleteDataFromSelection(IJCWidgetCookie ovc,
                                           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

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(IJCWidgetCookie ovc,
                                          boolean bindOrSelected,
                                          boolean onlyIfAllInOneEntity)
TODO P1 - fix this method to take array of IJCWidgetCookies Compute the union of all fields from the selected widgets given by IJCWidgetCookie.

Parameters:
ovc - The cookies which provides the selected widgets
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.

findEntities

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

findRelationships

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

annotateException

public static void annotateException(Throwable t)

annotateException

public static void annotateException(Throwable t,
                                     String localizedMessage)

findFields

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

mixColors

public static Color mixColors(Color a,
                              Color b,
                              float balance)
Computes the colour between the given two colours according to balance (0.0-1.0). Luminosity contrast check is used for resulting color and color b. If contrast too small, color is adjusted in a direction where's more color space to go...


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:
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 - schema 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 - datatree 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 - view 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 - dataobject 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 com.im.ijc.core.wizards.newdfitem.NewDFItemWizardIterator<DFEntity> createNewEntityWizard(DFSchema schema,
                                                                                                        List<DFNewType<DFEntity>> newtypes,
                                                                                                        boolean createDataTree,
                                                                                                        boolean createView)
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:
schema - the target Schema
newtypes - 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


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 simplier.

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)
If the license or it cause is License exception it will show dialog with license excpetion.

Parameters:
exception - catched exception
Returns:
true if license exception was found

generateNewListOrQueryName

public static String generateNewListOrQueryName()
Generate default name for a new temporary or permanent list or query. The current implemenation 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:
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

com.im.ijc.core/1 2.4