Search in sources :

Example 1 with Presentation

use of org.eclipse.sapphire.ui.Presentation 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;
}
Also used : ActionHandlerDef(org.eclipse.sapphire.ui.def.ActionHandlerDef) ActionTimer(com.liferay.ide.kaleo.core.model.ActionTimer) Task(com.liferay.ide.kaleo.core.model.Task) Action(com.liferay.ide.kaleo.core.model.Action) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) ArrayList(java.util.ArrayList) Presentation(org.eclipse.sapphire.ui.Presentation) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification)

Example 2 with Presentation

use of org.eclipse.sapphire.ui.Presentation 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();
}
Also used : Action(com.liferay.ide.kaleo.core.model.Action) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) Element(org.eclipse.sapphire.Element) PropertyEvent(org.eclipse.sapphire.PropertyEvent) Presentation(org.eclipse.sapphire.ui.Presentation) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler) ActionHandlerDef(org.eclipse.sapphire.ui.def.ActionHandlerDef) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) Event(org.eclipse.sapphire.Event) PropertyEvent(org.eclipse.sapphire.PropertyEvent)

Example 3 with Presentation

use of org.eclipse.sapphire.ui.Presentation 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();
}
Also used : Element(org.eclipse.sapphire.Element) PropertyEvent(org.eclipse.sapphire.PropertyEvent) Presentation(org.eclipse.sapphire.ui.Presentation) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification) Notification(com.liferay.ide.kaleo.core.model.Notification) ActionHandlerDef(org.eclipse.sapphire.ui.def.ActionHandlerDef) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) Event(org.eclipse.sapphire.Event) PropertyEvent(org.eclipse.sapphire.PropertyEvent)

Aggregations

Presentation (org.eclipse.sapphire.ui.Presentation)3 SapphireAction (org.eclipse.sapphire.ui.SapphireAction)3 SapphireActionHandler (org.eclipse.sapphire.ui.SapphireActionHandler)3 ActionHandlerDef (org.eclipse.sapphire.ui.def.ActionHandlerDef)3 Action (com.liferay.ide.kaleo.core.model.Action)2 ActionNotification (com.liferay.ide.kaleo.core.model.ActionNotification)2 Element (org.eclipse.sapphire.Element)2 Event (org.eclipse.sapphire.Event)2 PropertyEvent (org.eclipse.sapphire.PropertyEvent)2 ActionTimer (com.liferay.ide.kaleo.core.model.ActionTimer)1 Notification (com.liferay.ide.kaleo.core.model.Notification)1 Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)1 Task (com.liferay.ide.kaleo.core.model.Task)1 ArrayList (java.util.ArrayList)1