Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352170 - Sapphire expression EL should support instanceof operation
Summary: Sapphire expression EL should support instanceof operation
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Sapphire (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Konstantin Komissarchik CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-14 18:33 EDT by Shenxue Zhou CLA
Modified: 2021-11-19 09:21 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shenxue Zhou CLA 2011-07-14 18:33:14 EDT
I have a use case where I need to use different images for a diagram node depending on the model element type. Here is my property that I intend to reference in my node image expression:

 // *** TaskFlowReference ***
 
    @Type
    ( 
        base = ITaskFlowReference.class, 
        possible = 
        { 
            IStaticTaskFlowReference.class, 
            IDynamicTaskFlowReference.class
        }
    )    
    @Label( standard = "task flow reference" )
    @XmlElementBinding
    ( 
        mappings = 
        {
            @XmlElementBinding.Mapping( element = "task-flow-reference", type = IStaticTaskFlowReference.class ),
            @XmlElementBinding.Mapping( element = "dynamic-task-flow-reference", type = IDynamicTaskFlowReference.class )
        }
    )
        
    ElementProperty PROP_TASK_FLOW_REFERENCE = new ElementProperty( TYPE, "TaskFlowReference" );

I need to write my node image expression like the following:

${TaskFlowReference instanceof IStaticTaskFlowReference ? (((IStaticTaskFlowReference)TaskFlowReference).Id != null ? completeTFCallIcon : incompleteTFCallIcon) : incompleteTFCallIcon}


Currently there is no instanceof or function in the EL. It'd be great to support them.
Comment 1 Konstantin Komissarchik CLA 2011-07-15 12:58:27 EDT
Implemented InstanceOf function (not operator). From the docs:

Determines if an object is of specified type. The object to be checked is the first operand and the type is the second operand. The type must be a fully-qualified Java class name.

Example

${ InstanceOf( 12345, "java.lang.Number" ) }
${ InstanceOf( SampleProperty, "org.eclipse.sapphire.samples.ISampleModelElement" ) }

Unit test TestExpr0008 covers the new functionality.

Please verify.
Comment 2 Shenxue Zhou CLA 2011-07-15 18:08:41 EDT
I've verified the new instanceof function using the following expression:

${InstanceOf(TaskFlowReference, "oracle.eclipse.tools.adf.controller.model.IStaticTaskFlowReference") ? (TaskFlowReference.Id != null ? "taskFlowCallIcon" : "tfCallIncompleteIcon") : "tfCallIncompleteIcon"}

It works great. Thanks!