Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions docs/Event_Model.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@ Posting an Event

Publishing an event on the global event bus is as simple as calling one of two methods

```java
IEventBroker.post(String topic, Object data) // asynchronous delivery

```
or

```java
IEventBroker.send(String topic, Object data) // synchronous delivery
```

Example:

```java
...
foo.Bar payload = getPayload();
boolean wasDispatchedSuccessfully = eventBroker.send(TOPIC_STRING, payload);
```

If the payload of the send or post command is a regular Java object, the payload is attached to the OSGi event as a property with the key IEventBroker.DATA. If the payload is a Dictionary or a Map, all the values from the collection are added as properties with their associated keys.

Expand All @@ -58,10 +61,12 @@ Dependency Injection

Whenever possible you should use dependency injection to register and respond to events. This technique results in less code, is easier to read and maintain and has fewer anonymous inner classes. Internally, the E4 code base does not currently use this technique for subscribing to its own events. However, this is the result of a limitation that was late in the M4 cycle. Early in the M5 cycle, we will be changing our implementations to use the dependency injection technique for UI event handling.

```java
@Inject @Optional
void closeHandler(@UIEventTopic(''TOPIC_STRING'') foo.Bar payload) {
// Useful work that has access to payload. The instance of foo.Bar that the event poster placed on the global event bus with the topic ''TOPIC_STRING''
}
```

A quick note on the visibility of the injected handler methods.

Expand All @@ -77,7 +82,7 @@ In some circumstances you will not be able to use dependency injection and must
You also can not use dependency injection if the topic string you are registering is constructed at run time. The annotation strings need to be available and complete at compile time to be used by @UIEventTopic() (This is the reason we have not previously used dependency injection internally to subscribe to UIEvents ... but that will be changing in M5)



```java
IEventBroker eventBroker;
void addSubscribers() {
Expand All @@ -97,6 +102,7 @@ You also can not use dependency injection if the topic string you are registerin
// Useful work that has access
foo.Bar payload = (foo.Bar) event.getProperty(IEventBroker.DATA);
}
```

UI Model Events
===============
Expand All @@ -113,7 +119,7 @@ UIEvents Structure
Each EMF model element has a corresponding interface defined in UIEvents. Each interface has two constants defined for each attribute of the model element.

Here is the example for the UILabel model element

```java
public static interface UILabel {

// Topics that can be subscribed to
Expand All @@ -127,13 +133,16 @@ Here is the example for the UILabel model element
public static final String LABEL = "label"; //$NON-NLS-1$
public static final String TOOLTIP = "tooltip"; //$NON-NLS-1$
}
```

The TOPIC_* constants are used to subscribe to events generated when the corresponding attribute changes. The constant can be used by either the dependency injection technique or the IEventBroker.subscribe() technique described above. The TOPIC_ALL constant is used to register for changes on all the attributes of a model element. If the dependency injection technique is used, the event payload is the event itself.

```java
@Inject @Optional
private void closeHandler(@UIEventTopic(UIEvents.UILifeCycle.ACTIVATE) org.osgi.service.event.Event event) {
...
}
```

The constants named directly for the element attribute (LABEL, TOOLTIP and ICONURI from the example above) are used in event handlers if you need to inspect the event and determine which attributes have actually changed. This works because UIEventPublisher adds the attribute name from the source EMF event to the OSGi event with the property key UIEvents.EventTags.ATTNAME. The other UIEvents.EventTags.* constants list other values that may be published in an event depending on the event type. Different event types will store different tags in the event.

13 changes: 6 additions & 7 deletions docs/JFaceDataBindingFAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The JFace Data Binding plug-ins can be found in any of the following distributio
* RCP Runtime/SDK
* Platform Runtime/SDK


Just select the desired build (e.g. stable, integration, nightly) and download one of the above distributions.

The plug-ins or JAR files that you need are these:
Expand All @@ -35,32 +35,31 @@ The plug-ins or JAR files that you need are these:
* org.eclipse.jface.databinding (if your want SWT and JFace databinding)
* org.eclipse.core.databinding.beans (if you want databinding to Java beans).


The databinding framework is accessible using Maven with these dependencies:

```xml
<!-- The core databinding framework -->
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.databinding</artifactId>
<version>1.9.0</version>
</dependency>

<!-- If you want databinding to Java beans -->
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.databinding.beans</artifactId>
<version>1.6.100</version>
</dependency>

<!-- If you want JFace and SWT databinding -->
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.jface.databinding</artifactId>
<version>1.11.100</version>
</dependency>



```

### What is a Realm, and do I need to care?

Expand Down
Loading
Loading