Search in sources :

Example 6 with PropertyDef

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

the class LiferayVersionDefaultValueService method initDefaultValueService.

@Override
protected void initDefaultValueService() {
    super.initDefaultValueService();
    PropertyDef def = context().find(PropertyDef.class);
    Property property = context(Element.class).property(def);
    PossibleValuesService possibleValuesService = property.service(PossibleValuesService.class);
    possibleValuesService.attach(new Listener() {

        @Override
        public void handle(Event event) {
            _possibleValues = possibleValuesService.values();
            refresh();
        }
    });
    NewLiferayProfile profile = context(NewLiferayProfile.class);
    profile.property(NewLiferayProfile.PROP_RUNTIME_NAME).attach(new FilteredListener<PropertyContentEvent>() {

        @Override
        protected void handleTypedEvent(PropertyContentEvent event) {
            _possibleValues = possibleValuesService.values();
            _runtimeVersion = null;
            refresh();
        }
    });
    _possibleValues = possibleValuesService.values();
}
Also used : PossibleValuesService(org.eclipse.sapphire.PossibleValuesService) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) PropertyDef(org.eclipse.sapphire.PropertyDef) Element(org.eclipse.sapphire.Element) NewLiferayProfile(com.liferay.ide.project.core.model.NewLiferayProfile) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) Event(org.eclipse.sapphire.Event) Property(org.eclipse.sapphire.Property)

Example 7 with PropertyDef

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

the class CreatePortletAppResourceBundleActionHandler method init.

/**
 * (non-Javadoc)
 *
 * @see
 * org.eclipse.sapphire.ui.SapphirePropertyEditorActionHandler#init(org.eclipse.
 * sapphire.ui.SapphireAction, ActionHandlerDef)
 */
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
    super.init(action, def);
    Element element = getModelElement();
    Property property = property();
    listener = new FilteredListener<PropertyEvent>() {

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

        @Override
        public void handle(Event event) {
            if (event instanceof DisposeEvent) {
                PropertyDef definition = property().definition();
                getModelElement().detach(listener, definition.name());
            }
        }
    };
    attach(listen);
}
Also used : FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) PropertyDef(org.eclipse.sapphire.PropertyDef) 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) Property(org.eclipse.sapphire.Property)

Example 8 with PropertyDef

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

the class LabelPositionResource method createBinding.

@Override
protected PropertyBinding createBinding(Property property) {
    PropertyBinding binding = null;
    PropertyDef def = property.definition();
    if (Position.PROP_X.equals(def) || Position.PROP_Y.equals(def)) {
        binding = new ValuePropertyBinding() {

            @Override
            public String read() {
                String retval = null;
                if (LabelPositionResource.this._point != null) {
                    if (Position.PROP_X.equals(def)) {
                        retval = Integer.toString(LabelPositionResource.this._point.getX());
                    } else if (Position.PROP_Y.equals(def)) {
                        retval = Integer.toString(LabelPositionResource.this._point.getY());
                    }
                }
                return retval;
            }

            @Override
            public void write(String value) {
                if (LabelPositionResource.this._point == null) {
                    LabelPositionResource.this._point = new Point();
                }
                if (Position.PROP_X.equals(def)) {
                    LabelPositionResource.this._point.setX(Integer.parseInt(value));
                } else if (Position.PROP_Y.equals(def)) {
                    LabelPositionResource.this._point.setY(Integer.parseInt(value));
                }
                /*
					 * if (Position.PROP_X.equals( def ) ||
					 * Position.PROP_Y.equals( def )) {
					 * WorkflowNodeMetadataObject parentMetadata =
					 * parent().adapt( WorkflowNodeMetadataResource.class
					 * ).getMetadata(); parentMetadata.setNodeLocation(
					 * LabelPositionResource.this.point ); }
					 */
                WorkflowNodeMetadataResource metadataResource = parent().adapt(WorkflowNodeMetadataResource.class);
                metadataResource.saveMetadata();
            }
        };
    }
    if (binding != null) {
        binding.init(property);
    }
    return binding;
}
Also used : PropertyBinding(org.eclipse.sapphire.PropertyBinding) ValuePropertyBinding(org.eclipse.sapphire.ValuePropertyBinding) PropertyDef(org.eclipse.sapphire.PropertyDef) ValuePropertyBinding(org.eclipse.sapphire.ValuePropertyBinding)

Aggregations

PropertyDef (org.eclipse.sapphire.PropertyDef)8 PropertyBinding (org.eclipse.sapphire.PropertyBinding)4 ValuePropertyBinding (org.eclipse.sapphire.ValuePropertyBinding)4 List (java.util.List)2 Element (org.eclipse.sapphire.Element)2 ElementType (org.eclipse.sapphire.ElementType)2 Event (org.eclipse.sapphire.Event)2 FilteredListener (org.eclipse.sapphire.FilteredListener)2 LayeredListPropertyBinding (org.eclipse.sapphire.LayeredListPropertyBinding)2 Listener (org.eclipse.sapphire.Listener)2 Property (org.eclipse.sapphire.Property)2 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)2 Resource (org.eclipse.sapphire.Resource)2 ConnectionBendpoint (com.liferay.ide.kaleo.core.model.ConnectionBendpoint)1 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)1 NewLiferayProfile (com.liferay.ide.project.core.model.NewLiferayProfile)1 CoreException (org.eclipse.core.runtime.CoreException)1 DisposeEvent (org.eclipse.sapphire.DisposeEvent)1 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)1 PropertyEvent (org.eclipse.sapphire.PropertyEvent)1