Jump to: navigation, search

Difference between revisions of "Code Editor"


(MetaProperties)
(Start workflow snippet)
Line 155: Line 155:
  
 
===Start workflow snippet===
 
===Start workflow snippet===
This snippet will insert the code to execute an {{UBIK}} workflow synchronously, meaning in the same thread as the rest of the code is executed. So code execution will only continue after the workflow is finished. Example:
+
This snippet will insert the code to execute a {{UBIK}} workflow synchronously, meaning in the same thread as the rest of the code is executed. So code execution will only continue after the workflow is finished. Example:
  
 
<source lang = "csharp">
 
<source lang = "csharp">

Revision as of 06:58, 24 April 2013

Purpose

Code Editor control

The Code Editor is designed to display and edit the runtime behavior of a single UBIK® object. Technically, it reads the definition of overrideable properties and methods of the context object (directly from the context object if it is of type MetaClass, otherwise it gets the MetaClass of the context object and reads the definition from there).

When using the Code Editor, basic programming skills in Microsoft's C# are certainly beneficial.



Basics

Appearance

Code controls

The control reads the definition from the current context object and displays a code editing box for each eligible property or method, its appearance depending on status of the actual property/method:

Appearance Example Comment
Disabled expand button UI CodeEditor CodeControl Disabled.png The code for this property/method can't be edited
Enabled expand button UI CodeEditor CodeControl Enabled.png The code for this property/method is editable
Flat caption UI CodeEditor CodeControl Enabled.png There is no custom code for this property/method stored yet
Raised caption UI CodeEditor CodeControl Overridden.png There is already custom code for this property/method stored
Bold caption UI CodeEditor CodeControl Changed.png The custom code for this property/method was edited but not saved yet

Captions

Per default, each Code control shows the name of the respective property/method as its caption.

Tooltips

When hovering over the expand/collapse button of a code control, a Tooltip with its code will appear.


Drag & Drop

The Code Editor does not support Drag&Drop operations.

Toolbar

The Code Editor features a toolbar with the following items, from left to right:

Item Purpose
View Style Indicates or changes the View Style of the control; changing it will result in reloading of the control
Insert code snippet... Displays a sub menu with predefined UBIK® code snippets; selecting one will insert the respective code at the current caret position
Navigate to context object Attempts to navigate to the current context MetaClass
Save Saves the context object
Delete Deletes the custom code and replaces it with the default code

Context menu

This control doesn't feature any context menu yet.

View Styles

The Code Editor has four different View Styles, each of them providing different views and functionality.

Events

In this view mode you can override certain events that are thrown by a UBIK® object. This means that custom code can be executed once the event raises. The following events are currently exposed by UBIK® objects:

Event Exposed by Description
OnAddedToRelationship All event fired when the given object was added as a child to a relation
OnAttributeAdded All event fired when a new attribute is added to the attribute collection of the given base object
OnAttributeChanged All event fired when the value of one the own attributes changes
OnAttributeValueValidating All event fired when the validation of a new attribute value occurs; possibility to block the change
OnBeforeDelete All event fired when a base object is deleted; possibility to cancel the deletion
OnBeforeSave All event fired when a base object is saved; possibility to cancel the saving
OnCreated All event fired when a new instance of the object was created
OnDeleted All event fired when the given object was deleted
OnDisposed All event fired when an instance of the object was disposed (garbage collection)
OnInitializeCompleted All event fired when the initialization of the object was successful
OnInitializeFailed All event fired when the initialization of an object failed => returned false
OnNotLongerReferencedBy All event fired when an object removes its reference to the given object
OnObjectChanged All event fired when: PropertyValueChanged, PropertyIndexValueChanged, ReferenceChanged, AttributeChanged, AttributeAdded
OnPropertyIdxValueChanged All event fired when the value of one of the property objects changes
OnPropertyValueChanged All event fired when the value of one of the property objects changes; is not fired for references
OnPropertyValueIdxValidating All event fired when the validation of a new property index value occurs possibility to block the change
OnPropertyValueValidating All event fired when the validation of a new property value occurs; possibility to block the change
OnReferenceChanged All event fired when the value of one of the reference property objects changes
OnReferencedBy All event fired when an object refers to the given object via a reference
OnRelationAdded All event fired when the given object has got a new relation child
OnRelationRemoved All event fired when an object was removed as child from a relation
OnRemovedFromRelationship All event fired when the given object was removed as a child from a relation
OnSaved All event fired when the given object was saved
OnLocalFileDocumentIsAvailable Document -
OnLocalFileDocumentNoLongerAvailable Document -
OnLocalFileDocumentUpdated Document -

Methods

In this view mode you can override certain properties and methods that are exposed by an UBIK® object.

Name Kind Exposed by Description
DisplayString Property All -
DisplayStrings Property All -
DisplayStringItem Method All -
NumberOfDisplayStrings Method All -
ToString Method All The string representation of the object; is evaluated in most of the UBIK® Studio controls

MetaProperties

In this view mode you can modify the code that is executed within the accessors of a UBIK® MetaProperty

IC Hint square.pngThe Code Editor will not display inherited MetaProperties, but only the ones defined on the very context object!

Custom

In this view mode it is possible to store code which is not related to events, methods or MetaProperties but shall still be assembled with a MetaClass or with the entire customizing. Use this if you want to provide a code library or classes that shall be used by your custom event or property/method code.

  • Custom Object Code: this code will be assembled into the class code of teh UBIK® MetaClass
  • UBIK Code Library: this code will be assembled only once per customizing, and is therefore available across all MetaClasses

Code snippets

Start workflow snippet

This snippet will insert the code to execute a UBIK® workflow synchronously, meaning in the same thread as the rest of the code is executed. So code execution will only continue after the workflow is finished. Example:

//*** Calling UBIK Workflow: WFICON Assign icon
Dictionary<string, object> args = new Dictionary<string, object>();
args.Add("UBIKObject", this);
UBIK.WorkflowBase.Invoker.InvokeWorkflow(this.MetaClass.AllWorkflows.Find(p => p.ID == "2bf8f8e9-156d-4914-bd25-fd133148638d"), args);
//*** End of calling UBIK Workflow

This code locates the workflow object at the MetaClass of the object using its UID, loads the declared XAML code and sends it to the invoker. The calling object will be passed as first and only parameter UBIKObject.

IC Hint square.pngIf you need the workflow to be executed conditionally, just wrap the conditions (e.g. and if block around the generated snippet!

Other functionality