use of org.eclipse.sapphire.ui.def.ActionHandlerDef in project liferay-ide by liferay.
the class WorkflowNodeAddHandlerFactory method create.
@Override
public List<SapphireActionHandler> create() {
List<SapphireActionHandler> handlers = new ArrayList<>();
if (getModelElement() instanceof Task) {
Task task = getModelElement().nearest(Task.class);
handlers.add(new SapphireActionHandler() {
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
addImage(Action.TYPE.image());
setLabel("Task Action");
}
@Override
protected Object run(Presentation context) {
Action newAction = task.getTaskActions().insert();
ActionsListAddActionHandler.addActionDefaults(newAction);
return newAction;
}
});
handlers.add(new SapphireActionHandler() {
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
addImage(ActionNotification.TYPE.image());
setLabel("Task Notification");
}
@Override
protected Object run(Presentation context) {
ActionNotification newTaskNotificaction = task.getTaskNotifications().insert();
NotificationsListAddActionHandler.addNotificationDefaults(newTaskNotificaction);
return newTaskNotificaction;
}
});
} else {
ActionTimer actionTimer = getModelElement().nearest(ActionTimer.class);
handlers.add(new SapphireActionHandler() {
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
addImage(Action.TYPE.image());
setLabel("Action");
}
@Override
protected Object run(Presentation context) {
Action newAction = actionTimer.getActions().insert();
ActionsListAddActionHandler.addActionDefaults(newAction);
return newAction;
}
});
handlers.add(new SapphireActionHandler() {
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
addImage(Notification.TYPE.image());
setLabel("Notification");
}
@Override
protected Object run(Presentation context) {
ActionNotification newNotificaction = actionTimer.getNotifications().insert();
NotificationsListAddActionHandler.addNotificationDefaults(newNotificaction);
return newNotificaction;
}
});
}
return handlers;
}
use of org.eclipse.sapphire.ui.def.ActionHandlerDef in project liferay-ide by liferay.
the class ActionsDiagramNodeEditHandlerFactory method create.
@Override
public List<SapphireActionHandler> create() {
ListFactory<SapphireActionHandler> factory = ListFactory.start();
Element element = getElement();
if (element == null) {
return factory.result();
}
ElementList<Action> actions = getActions();
if (_listener == null) {
_listener = new FilteredListener<PropertyEvent>() {
@Override
public void handleTypedEvent(PropertyEvent event) {
broadcast(new Event());
}
};
}
element.attach(_listener, getListPropertyName());
for (Action action : actions) {
action.getName().attach(_listener);
factory.add(new ScriptableOpenActionHandler() {
@Override
public void init(SapphireAction sapphireAction, ActionHandlerDef def) {
super.init(sapphireAction, def);
String name = action.getName().content(true);
setLabel(empty(name) ? "<null>" : name);
addImage(Action.TYPE.image());
}
@Override
protected Scriptable scriptable(Presentation context) {
return action;
}
});
}
return factory.result();
}
use of org.eclipse.sapphire.ui.def.ActionHandlerDef in project liferay-ide by liferay.
the class NotificationsDiagramNodeEditHandlerFactory method create.
@Override
public List<SapphireActionHandler> create() {
ListFactory<SapphireActionHandler> factory = ListFactory.start();
Element element = getElement();
if (element == null) {
return factory.result();
}
List<ActionNotification> notifications = getNotifications();
if (_listener == null) {
_listener = new FilteredListener<PropertyEvent>() {
@Override
public void handleTypedEvent(PropertyEvent event) {
broadcast(new Event());
}
};
}
element.attach(_listener, getListPropertyName());
for (Notification notification : notifications) {
notification.getName().attach(_listener);
factory.add(new TemplateOpenActionHandler() {
@Override
public void init(SapphireAction sapphireAction, ActionHandlerDef def) {
super.init(sapphireAction, def);
String name = notification.getName().content(true);
setLabel(empty(name) ? "<null>" : name);
addImage(ActionNotification.TYPE.image());
}
@Override
protected Notification notification(Presentation context) {
return notification;
}
});
}
return factory.result();
}
Aggregations