Search in sources :

Example 1 with PossibleValuesService

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

the class LiferayPortletXmlTest method testLiferayScriptPossibleValuesService.

@Test
public void testLiferayScriptPossibleValuesService() throws Exception {
    if (shouldSkipBundleTests())
        return;
    NewLiferayPluginProjectOp newProjectOp = NewLiferayPluginProjectOp.TYPE.instantiate();
    newProjectOp.setProjectName("test-script");
    newProjectOp.setPluginType(PluginType.portlet);
    newProjectOp.setIncludeSampleCode(true);
    newProjectOp.setPortletFramework("mvc");
    newProjectOp.setPortletName("testPortlet");
    final IProject testProject = createAntProject(newProjectOp);
    LiferayPortletXml liferayPortletApp = op(testProject);
    for (LiferayPortlet liferayPortlet : liferayPortletApp.getPortlets()) {
        ElementList<PortletStyleElement> portletCsses = liferayPortlet.getHeaderPortletCsses();
        {
            for (PortletStyleElement portletCss : portletCsses) {
                final PossibleValuesService scriptService = portletCss.getValue().service(PossibleValuesService.class);
                assertEquals(true, scriptService.values().contains("/css/main.css"));
            }
        }
    }
}
Also used : PossibleValuesService(org.eclipse.sapphire.PossibleValuesService) LiferayPortletXml(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortletXml) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) PortletStyleElement(com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement) LiferayPortlet(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortlet) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 2 with PossibleValuesService

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

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

PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)3 Property (org.eclipse.sapphire.Property)2 LiferayPortlet (com.liferay.ide.portlet.core.lfportlet.model.LiferayPortlet)1 LiferayPortletXml (com.liferay.ide.portlet.core.lfportlet.model.LiferayPortletXml)1 PortletStyleElement (com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement)1 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)1 NewLiferayProfile (com.liferay.ide.project.core.model.NewLiferayProfile)1 IProject (org.eclipse.core.resources.IProject)1 Element (org.eclipse.sapphire.Element)1 Event (org.eclipse.sapphire.Event)1 FilteredListener (org.eclipse.sapphire.FilteredListener)1 ImageData (org.eclipse.sapphire.ImageData)1 Listener (org.eclipse.sapphire.Listener)1 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)1 PropertyDef (org.eclipse.sapphire.PropertyDef)1 ValueImageService (org.eclipse.sapphire.services.ValueImageService)1 ValueLabelService (org.eclipse.sapphire.services.ValueLabelService)1 SwtResourceCache (org.eclipse.sapphire.ui.forms.swt.SwtResourceCache)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1