Search in sources :

Example 1 with SapphireActionHandler

use of org.eclipse.sapphire.ui.SapphireActionHandler in project liferay-ide by liferay.

the class KaleoNodeAddActionHandlerFactory method create.

@Override
public List<SapphireActionHandler> create() {
    List<SapphireActionHandler> handlers = new ArrayList<>();
    SapphireDiagramEditorPagePart diagramPart = (SapphireDiagramEditorPagePart) getPart();
    for (DiagramNodeTemplate nodeTemplate : diagramPart.getVisibleNodeTemplates()) {
        NewNodeAddActionHandler addNodeHandler = _createKaleoNodeActionHandlerForTemplate(nodeTemplate);
        handlers.add(addNodeHandler);
    }
    return handlers;
}
Also used : SapphireDiagramEditorPagePart(org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart) DiagramNodeTemplate(org.eclipse.sapphire.ui.diagram.editor.DiagramNodeTemplate) ArrayList(java.util.ArrayList) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler)

Example 2 with SapphireActionHandler

use of org.eclipse.sapphire.ui.SapphireActionHandler 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 3 with SapphireActionHandler

use of org.eclipse.sapphire.ui.SapphireActionHandler 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 4 with SapphireActionHandler

use of org.eclipse.sapphire.ui.SapphireActionHandler 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)

Example 5 with SapphireActionHandler

use of org.eclipse.sapphire.ui.SapphireActionHandler in project liferay-ide by liferay.

the class QuickActionsHandlerFactory method create.

/**
 * (non-Javadoc)
 *
 * @see SapphireActionHandlerFactory#create()
 */
@Override
public List<SapphireActionHandler> create() {
    List<SapphireActionHandler> listOfHandlers = new ArrayList<>();
    for (int i = 0; i < _modelProperties.length; i++) {
        String property = _modelProperties[i];
        if ((property != null) && "Portlets".equalsIgnoreCase(property) && _isPartInLiferayProject()) {
            SapphireActionHandler handler = new CreateLiferayPortletActionHandler();
            handler.init(getAction(), null);
            handler.addImage(Portlet.TYPE.image());
            handler.setLabel(_getActionLabel(Msgs.portlets));
            listOfHandlers.add(handler);
        } else {
            listOfHandlers.add(new Handler(property));
        }
    }
    return listOfHandlers;
}
Also used : ArrayList(java.util.ArrayList) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler)

Aggregations

SapphireActionHandler (org.eclipse.sapphire.ui.SapphireActionHandler)5 ArrayList (java.util.ArrayList)3 Presentation (org.eclipse.sapphire.ui.Presentation)3 SapphireAction (org.eclipse.sapphire.ui.SapphireAction)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 DiagramNodeTemplate (org.eclipse.sapphire.ui.diagram.editor.DiagramNodeTemplate)1 SapphireDiagramEditorPagePart (org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart)1