author | fturovic <frank.turovich@nokia.com> |
Tue, 27 Jul 2010 15:28:19 -0500 | |
changeset 1704 | 24ac5a5cf80c |
parent 0 | fb279309251b |
permissions | -rw-r--r-- |
1704
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
2 |
<html> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
3 |
<head> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
4 |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
5 |
<meta http-equiv="Content-Style-Type" content="text/css" /> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
6 |
<title>Defining Transient Component</title> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
7 |
<link rel="StyleSheet" href="../../../book.css" type="text/css"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
8 |
</head> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
9 |
<body bgcolor="#FFFFFF"> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
10 |
<h2>Defining a Transient Component</h2> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
11 |
<p>The following information describes how to define a transient component by using a simple transient S60 component as an example. For example, the Note component. When requested, a note appears briefly to provide a message. Notes come in four basic types: confirmation, information, warning and error. They differ by icon and the message displayed. Each is implemented as a different c++ class.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
12 |
<p>However, since they all have basically the same properties, they are good candidates for implementation as a single component, with an additional selector property to determine which one the developer wants. Since the developer will probably want to activate the note dynamically given the right conditions (for example, if a requested action succeeds or fails), the source code output of a note component should probably be a routine that can be called when the condition warrants displaying the note.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
13 |
<h3>Component Implementation</h3> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
14 |
<p>First, the selector property type should be declared. Since this property is not a basic type, and very much specific to this component, its type should be declared with the component. This property will be able to take one of the four possible note types (confirmation, information, warning and error). Therefore, this should be declared as an enumeration property.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
15 |
<p>Following is an example of the selector property type declaration:</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
16 |
<pre class="listing"><enumPropertyDeclaration qualifiedName="com.nokia.sdt.series60.StandardNote.type"> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
17 |
<enumElement value="CAknConfirmationNote"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
18 |
<enumElement value="CAknInformationNote"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
19 |
<enumElement value="CAknWarningNote"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
20 |
<enumElement value="CAknErrorNote"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
21 |
</enumPropertyDeclaration> </pre> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
22 |
<p>The display name for an enum element may be specified two ways. In the fully-specified form, the displayValue attribute is a literal string or a percent-prefixed key (%<em>name</em>) to look up in the .properties file. In the form used here, the displayValue is not specified and the value itself is used as the key for the .properties file.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
23 |
<h4>Attributes and properties</h4> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
24 |
<p>To have transient component behavior (icon in the non-layout area and transient appearance in the layout area), the component must declare itself to be a non-layout component as well as a transient component. These declarations are achieved by attributes. Since attributes are inherited, the StandardNote component can inherit from the NonLayoutBase component to get its non-layout behavior as well as its required unique “name” property.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
25 |
<pre class="listing"><attributes> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
26 |
<attribute key="is-layout-object">false</attribute> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
27 |
<attribute key="is-non-layout-object">true</attribute> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
28 |
</attributes> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
29 |
<br /><properties> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
30 |
<property category="Design" name="name" type="uniqueName"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
31 |
</properties> </pre> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
32 |
<p>Specific transient attributes can be declared directly. It declares itself to be a transient object as well as one that can’t be resized or moved.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
33 |
<pre class="listing"><attributes> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
34 |
<attribute key="is-non-resizable-or-moveable-layout-object">true</attribute> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
35 |
<attribute key="is-transient-object">true</attribute> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
36 |
</attributes> </pre> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
37 |
<p>Finally, its own specific properties can be declared. Standard location and size properties are set in order to behave correctly in the editor. Developers do not need to see these properties because they do not represent anything in the source code. These properties can be hidden from developers by declaring the special category “Hidden.” A text property is declared to hold the message of the note, and the selector property, “type” is declared with the enumeration type declared previously.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
38 |
<pre class="listing"><properties> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
39 |
<compoundProperty category="Hidden" name="location" |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
40 |
type="com.nokia.sdt.series60.locationProperty" |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
41 |
editorClass="com.nokia.sdt.symbian.ui.editors.ReadOnlySummaryEditorFactory"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
42 |
<compoundProperty category="Hidden" name="size" |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
43 |
type="com.nokia.sdt.series60.sizeProperty" |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
44 |
editorClass="com.nokia.sdt.symbian.ui.editors.ReadOnlySummaryEditorFactory"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
45 |
<property category="Data" name="text" type="localizedString" default="Note" /> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
46 |
<enumProperty category="Appearance" name="type" |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
47 |
type="com.nokia.sdt.series60.StandardNote.type" |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
48 |
default="CAknConfirmationNote"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
49 |
</properties></pre> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
50 |
<h4>JavaScript implementations</h4> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
51 |
<p>After adding all the static features to the component, some dynamic features can be added to provide design time rendering, layout, and other behavior. This is done by writing JavaScript code that implements specific interfaces that are known to the editor. The StandardNote component will implement various interfaces. It will implement IVisualAppearance to allow it to render itself in the editor and change the rendering when its properties change. It implements ILayout to allow it to exist in various layout sizes. IDirectLabelEdit allows developers to enter label text directly on the editor rather than through the properties view and IComponentPropertyListener allows it to resize if necessary as its text grows.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
52 |
<pre class="listing"><implementations> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
53 |
<implementation> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
54 |
<interface id="com.nokia.sdt.datamodel.adapter.IVisualAppearance"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
55 |
<interface id="com.nokia.sdt.datamodel.adapter.IDirectLabelEdit"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
56 |
<script file="StandardNote_visual.js" prototype="StandardNoteVisual"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
57 |
</implementation> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
58 |
<implementation> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
59 |
<interface id="com.nokia.sdt.datamodel.adapter.ILayout"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
60 |
<interface id="com.nokia.sdt.datamodel.adapter.IComponentInstancePropertyListener"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
61 |
<script file="StandardNote_layout.js" prototype="StandardNoteLayout"/> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
62 |
</implementation> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
63 |
</implementations></pre> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
64 |
<p>In the StandardNote component, two prototypes are used, each one in its own JavaScript file. StandardNoteVisual implements IVisualAppearance and IDirectLabelEdit since these implementations are related. One is drawing the text while the other allows the text to be edited in place.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
65 |
<p>StandardNoteLayout implements ILayout and IComponentInstancePropertyListener since these implementations are also related. One gives the instance its size and location, while the other forces it to layout when the text property changes.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
66 |
<h4>Source generation</h4> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
67 |
<p>The output of any component is the source code it generates into the developer’s project. As mentioned earlier, the StandardNote component generates a routine into the owning class that can be called to display the note at runtime.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
68 |
<p>Because its text property should be localizable, it is placed in a TBUF resource, so the component needs to map the text property to the resource. The sourceMapping element describes this mapping, while the sourceGen element encapsulates the template for generating source code into the owning class.</p> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
69 |
<h5>Related Reference</h5> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
70 |
<ul> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
71 |
<li><a href="cc_source_mapping.htm">Source Mapping</a></li> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
72 |
<li><a href="cc_source_generation.htm">Source Generation</a></li> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
73 |
</ul> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
74 |
<div id="footer">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. <br>License: <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a></div> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
75 |
|
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
76 |
</body> |
24ac5a5cf80c
updated copyright dates and fixed some css issues
fturovic <frank.turovich@nokia.com>
parents:
0
diff
changeset
|
77 |
</html> |