Search in sources :

Example 1 with PropertyEvent

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

the class CreateDirectoryActionHandler method init.

@Override
public void init(SapphireAction action, ActionHandlerDef def) {
    super.init(action, def);
    Element element = getModelElement();
    ValueProperty property = (ValueProperty) property().definition();
    Listener listener = new FilteredListener<PropertyEvent>() {

        @Override
        public void handleTypedEvent(PropertyEvent event) {
            refreshEnablementState();
        }
    };
    element.attach(listener, property.name());
    attach(new Listener() {

        @Override
        public void handle(Event event) {
            if (event instanceof DisposeEvent) {
                element.detach(listener, property.name());
            }
        }
    });
}
Also used : FilteredListener(org.eclipse.sapphire.FilteredListener) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) Element(org.eclipse.sapphire.Element) Event(org.eclipse.sapphire.Event) DisposeEvent(org.eclipse.sapphire.DisposeEvent) PropertyEvent(org.eclipse.sapphire.PropertyEvent) PropertyEvent(org.eclipse.sapphire.PropertyEvent) DisposeEvent(org.eclipse.sapphire.DisposeEvent) ValueProperty(org.eclipse.sapphire.ValueProperty)

Example 2 with PropertyEvent

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

the class CustomJspsEnablementService method initEnablementService.

@Override
protected void initEnablementService() {
    Listener listener = new FilteredListener<PropertyEvent>() {

        protected void handleTypedEvent(PropertyEvent event) {
            refresh();
        }
    };
    ElementHandle<Element> element = _hook().property(Hook.PROP_CUSTOM_JSP_DIR);
    element.attach(listener, CustomJspDir.PROP_VALUE.name());
}
Also used : FilteredListener(org.eclipse.sapphire.FilteredListener) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) Element(org.eclipse.sapphire.Element) PropertyEvent(org.eclipse.sapphire.PropertyEvent)

Example 3 with PropertyEvent

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

the class ColumnImageService method initImageService.

@Override
protected void initImageService() {
    _listener = new FilteredListener<PropertyEvent>() {

        @Override
        protected void handleTypedEvent(PropertyEvent event) {
            refresh();
        }
    };
    context(Element.class).attach(_listener, Column.PROP_PRIMARY.name());
    attach(new Listener() {

        @Override
        public void handle(Event event) {
            if (event instanceof DisposeEvent) {
                context(Element.class).detach(_listener, Column.PROP_PRIMARY.name());
            }
        }
    });
}
Also used : FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) Element(org.eclipse.sapphire.Element) Event(org.eclipse.sapphire.Event) DisposeEvent(org.eclipse.sapphire.DisposeEvent) PropertyEvent(org.eclipse.sapphire.PropertyEvent) PropertyEvent(org.eclipse.sapphire.PropertyEvent) DisposeEvent(org.eclipse.sapphire.DisposeEvent)

Example 4 with PropertyEvent

use of org.eclipse.sapphire.PropertyEvent 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 5 with PropertyEvent

use of org.eclipse.sapphire.PropertyEvent 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

Element (org.eclipse.sapphire.Element)7 PropertyEvent (org.eclipse.sapphire.PropertyEvent)7 Event (org.eclipse.sapphire.Event)6 FilteredListener (org.eclipse.sapphire.FilteredListener)5 Listener (org.eclipse.sapphire.Listener)5 DisposeEvent (org.eclipse.sapphire.DisposeEvent)4 ValueProperty (org.eclipse.sapphire.ValueProperty)2 Presentation (org.eclipse.sapphire.ui.Presentation)2 SapphireAction (org.eclipse.sapphire.ui.SapphireAction)2 SapphireActionHandler (org.eclipse.sapphire.ui.SapphireActionHandler)2 ActionHandlerDef (org.eclipse.sapphire.ui.def.ActionHandlerDef)2 Action (com.liferay.ide.kaleo.core.model.Action)1 ActionNotification (com.liferay.ide.kaleo.core.model.ActionNotification)1 Notification (com.liferay.ide.kaleo.core.model.Notification)1 Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)1 Property (org.eclipse.sapphire.Property)1 PropertyDef (org.eclipse.sapphire.PropertyDef)1