# Class TargetEvents

java.lang.Object
org.eclipse.pde.core.target.TargetEvents

public class TargetEvents extends Object
Target events and event topic definitions.

The following code is an example of to subscribe to the `TOPIC_TARGET_SAVED` event:

    EventHandler eventHandler = event -> {
            if (event.getProperty(IEventBroker.DATA) instanceof ITargetHandle handle) {
                    // Work with the target handle...
            }
    };
    IEclipseContext context = EclipseContextFactory.getServiceContext(bundleContext);
    IEventBroker broker = context.get(IEventBroker.class);
    if (broker != null) {
            broker.subscribe(TargetEvents.TOPIC_TARGET_SAVED, eventHandler);
            // Do not forget to unsubscribe later!
    }

Since:
  3.13
See Also:
  - `ITargetPlatformService`
  - `IEventBroker.subscribe(String, EventHandler)`
  - `IEventBroker.subscribe(String, String, EventHandler, boolean)`
  - `IEventBroker.unsubscribe(EventHandler)`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`TOPIC_ALL`
Topic for all target events.
`static final String`
`TOPIC_BASE`
Base topic for all target events.
`static final String`
`TOPIC_TARGET_DELETED`
Sent when a target is deleted.
`static final String`
`TOPIC_TARGET_SAVED`
Sent when a target is saved.
`static final String`
`TOPIC_WORKSPACE_TARGET_CHANGED`
Sent when workspace target definition is changed.

## Constructor Summary

Constructors
Constructor
Description
`TargetEvents()`

## Method Summary

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### TOPIC_BASE

public static final String TOPIC_BASE
Base topic for all target events.

See Also:
  - Constant Field Values

### TOPIC_ALL

public static final String TOPIC_ALL
Topic for all target events.

See Also:
  - Constant Field Values

### TOPIC_WORKSPACE_TARGET_CHANGED

public static final String TOPIC_WORKSPACE_TARGET_CHANGED
Sent when workspace target definition is changed.

The `data` `event property` of events with this topic is the changed `ITargetDefinition`.

See Also:
  - `ITargetPlatformService.getWorkspaceTargetDefinition()`
  - Constant Field Values

### TOPIC_TARGET_SAVED

public static final String TOPIC_TARGET_SAVED
Sent when a target is saved.

The `data` `event property` of events with this topic is the saved `ITargetHandle`.

Since:
  3.20
See Also:
  - `ITargetPlatformService.saveTargetDefinition(ITargetDefinition)`
  - `IEventBroker`
  - Constant Field Values

### TOPIC_TARGET_DELETED

public static final String TOPIC_TARGET_DELETED
Sent when a target is deleted.

The `data` `event property` of events with this topic is the deleted `ITargetHandle`.

Since:
  3.20
See Also:
  - `ITargetPlatformService.deleteTarget(ITargetHandle)`
  - Constant Field Values

## Constructor Details

### TargetEvents

public TargetEvents()