Search in sources :

Example 11 with Property

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

the class ServiceImplJavaTypeConstraintService method initJavaTypeConstraintService.

@Override
protected void initJavaTypeConstraintService() {
    super.initJavaTypeConstraintService();
    Property property = context().find(Property.class);
    JavaTypeConstraint javaTypeConstraintAnnotation = property.definition().getAnnotation(JavaTypeConstraint.class);
    Set<JavaTypeKind> kind = EnumSet.noneOf(JavaTypeKind.class);
    for (JavaTypeKind k : javaTypeConstraintAnnotation.kind()) {
        kind.add(k);
    }
    _kinds = kind;
    _behavior = javaTypeConstraintAnnotation.behavior();
    _service = context(ServiceWrapper.class);
    Listener listener = new FilteredListener<PropertyContentEvent>() {

        @Override
        public void handleTypedEvent(PropertyContentEvent event) {
            refresh();
        }
    };
    _service.attach(listener, "ServiceType");
}
Also used : JavaTypeKind(org.eclipse.sapphire.java.JavaTypeKind) FilteredListener(org.eclipse.sapphire.FilteredListener) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) JavaTypeConstraint(org.eclipse.sapphire.java.JavaTypeConstraint) ServiceWrapper(com.liferay.ide.hook.core.model.ServiceWrapper) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) Property(org.eclipse.sapphire.Property)

Example 12 with Property

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

the class PortletColumnsListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    Property property = event.property();
    Element element = property.element();
    LayoutTplElement layouttpl = element.nearest(LayoutTplElement.class);
    updateColumns(layouttpl, 1);
}
Also used : LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) Element(org.eclipse.sapphire.Element) PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) Property(org.eclipse.sapphire.Property) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement)

Example 13 with Property

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

the class CreatePortletAppResourceBundleActionHandler method run.

/**
 * (non-Javadoc)
 *
 * @see
 * org.eclipse.sapphire.ui.SapphireActionHandler#run(org.eclipse.sapphire.ui.
 * SapphireRenderingContext)
 */
@Override
protected Object run(Presentation context) {
    Element element = getModelElement();
    IProject project = element.adapt(IProject.class);
    Property property = property();
    Value<Path> resourceBundle = element.property((ValueProperty) property.definition());
    String resourceBundleText = resourceBundle.text();
    int index = resourceBundleText.lastIndexOf(".");
    if (index == -1) {
        index = resourceBundleText.length();
    }
    String packageName = resourceBundleText.substring(0, index);
    String defaultRBFileName = PortletUtil.convertJavaToIoFileName(resourceBundleText, GenericResourceBundlePathService.RB_FILE_EXTENSION);
    IFolder rbSourecFolder = getResourceBundleFolderLocation(project, defaultRBFileName);
    IPath entryPath = rbSourecFolder.getLocation();
    if (getModelElement() instanceof PortletApp) {
        List<IFile> missingRBFiles = new ArrayList<>();
        StringBuilder rbFileBuffer = new StringBuilder("#Portlet Application Resource Bundle \n");
        IFile rbFile = wroot.getFileForLocation(entryPath.append(defaultRBFileName));
        missingRBFiles.add(rbFile);
        createFiles(context, project, packageName, missingRBFiles, rbFileBuffer);
        setEnabled(false);
        Property modelElement = getModelElement().property(property().definition());
        modelElement.refresh();
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) Element(org.eclipse.sapphire.Element) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) PortletApp(com.liferay.ide.portlet.core.model.PortletApp) ValueProperty(org.eclipse.sapphire.ValueProperty) Property(org.eclipse.sapphire.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 14 with Property

use of org.eclipse.sapphire.Property 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 15 with Property

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

the class PossibleValuesRadioButtonsGroupBinding method initialize.

@Override
@SuppressWarnings("unchecked")
protected void initialize(PropertyEditorPresentation propertyEditorPresentation, Control control) {
    super.initialize(propertyEditorPresentation, control);
    final PossibleValuesService possibleValuesService = propertyEditorPresentation.property().service(PossibleValuesService.class);
    _possibleValues = new ArrayList<>(possibleValuesService.values());
    _buttonsGroup = (RadioButtonsGroup) control;
    final Property property = propertyEditorPresentation.property();
    String auxTextProviderName = propertyEditorPresentation.part().getRenderingHint("possible.values.aux.text.provider", (String) null);
    PossibleValuesAuxTextProvider auxTextProvider = null;
    if (auxTextProviderName != null) {
        try {
            Bundle bundle = ProjectUI.getDefault().getBundle();
            Class<PossibleValuesAuxTextProvider> providerClass = (Class<PossibleValuesAuxTextProvider>) bundle.loadClass(auxTextProviderName);
            auxTextProvider = providerClass.newInstance();
        } catch (Exception e) {
        }
    }
    for (String possibleValue : _possibleValues) {
        final ValueLabelService labelService = property.service(ValueLabelService.class);
        final String possibleValueText = labelService.provide(possibleValue);
        String auxText = propertyEditorPresentation.part().getRenderingHint(PropertyEditorDef.HINT_AUX_TEXT + "." + possibleValue, null);
        if ((auxText == null) && (auxTextProvider != null)) {
            auxText = auxTextProvider.getAuxText(element(), property.definition(), possibleValue);
        }
        ValueImageService imageService = property.service(ValueImageService.class);
        ImageData imageData = imageService.provide(possibleValue);
        SwtResourceCache resources = presentation().resources();
        Image image = resources.image(imageData);
        final Button button = this._buttonsGroup.addRadioButton(possibleValueText, auxText, image);
        button.setData(possibleValue);
    }
    _buttonsGroup.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            updateModel();
            updateTargetAttributes();
        }
    });
}
Also used : PossibleValuesService(org.eclipse.sapphire.PossibleValuesService) ValueLabelService(org.eclipse.sapphire.services.ValueLabelService) Bundle(org.osgi.framework.Bundle) ValueImageService(org.eclipse.sapphire.services.ValueImageService) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Image(org.eclipse.swt.graphics.Image) Button(org.eclipse.swt.widgets.Button) ImageData(org.eclipse.sapphire.ImageData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SwtResourceCache(org.eclipse.sapphire.ui.forms.swt.SwtResourceCache) Property(org.eclipse.sapphire.Property)

Aggregations

Property (org.eclipse.sapphire.Property)16 Element (org.eclipse.sapphire.Element)10 IProject (org.eclipse.core.resources.IProject)5 ValueProperty (org.eclipse.sapphire.ValueProperty)4 IType (org.eclipse.jdt.core.IType)3 JavaModelException (org.eclipse.jdt.core.JavaModelException)3 IJavaSearchScope (org.eclipse.jdt.core.search.IJavaSearchScope)3 FilteredListener (org.eclipse.sapphire.FilteredListener)3 Listener (org.eclipse.sapphire.Listener)3 Value (org.eclipse.sapphire.Value)3 Path (org.eclipse.sapphire.modeling.Path)3 Hook (com.liferay.ide.hook.core.model.Hook)2 Transition (com.liferay.ide.kaleo.core.model.Transition)2 ArrayList (java.util.ArrayList)2 TypeSelectionExtension (org.eclipse.jdt.ui.dialogs.TypeSelectionExtension)2 Event (org.eclipse.sapphire.Event)2 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)2 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)2 PropertyDef (org.eclipse.sapphire.PropertyDef)2 JavaTypeKind (org.eclipse.sapphire.java.JavaTypeKind)2