Search in sources :

Example 1 with ValueLabelService

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

the class NewLiferayPluginProjectOpBase method testProjectProviderValueLabel.

@Test
public void testProjectProviderValueLabel() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NewLiferayPluginProjectOp op = newProjectOp("test-project-provider-value-label");
    final ValueLabelService vls = op.getProjectProvider().service(ValueLabelService.class);
    final Set<String> actualProviderShortNames = op.getProjectProvider().service(PossibleValuesService.class).values();
    Set<String> actualLabels = new HashSet<String>();
    for (String shortName : actualProviderShortNames) {
        actualLabels.add(vls.provide(shortName));
    }
    assertNotNull(actualLabels);
    Set<String> exceptedLabels = new HashSet<String>();
    exceptedLabels.add("Ant (liferay-plugins-sdk)");
    exceptedLabels.add("Maven (liferay-maven-plugin)");
    assertEquals(true, exceptedLabels.containsAll(actualLabels));
}
Also used : ValueLabelService(org.eclipse.sapphire.services.ValueLabelService) PossibleValuesService(org.eclipse.sapphire.PossibleValuesService) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with ValueLabelService

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

the class NewLiferayPluginProjectOpBase method testPortletFrameworkValueLabel.

@Test
public void testPortletFrameworkValueLabel() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NewLiferayPluginProjectOp op = newProjectOp("test-portlet-framework-value-label");
    final ValueLabelService vls = op.getPortletFramework().service(ValueLabelService.class);
    Set<String> acturalLables = new HashSet<String>();
    for (IPortletFramework pf : ProjectCore.getPortletFrameworks()) {
        acturalLables.add(vls.provide(pf.getShortName()));
    }
    assertNotNull(acturalLables);
    Set<String> exceptedLables = new HashSet<String>();
    exceptedLables.add("Liferay MVC");
    exceptedLables.add("JSF 2.x");
    exceptedLables.add("Vaadin");
    exceptedLables.add("JSF standard");
    exceptedLables.add("ICEfaces");
    exceptedLables.add("Liferay Faces Alloy");
    exceptedLables.add("PrimeFaces");
    exceptedLables.add("RichFaces");
    exceptedLables.add("Spring MVC");
    assertEquals(true, exceptedLables.containsAll(acturalLables));
    assertEquals(true, acturalLables.containsAll(exceptedLables));
}
Also used : ValueLabelService(org.eclipse.sapphire.services.ValueLabelService) IPortletFramework(com.liferay.ide.project.core.IPortletFramework) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with ValueLabelService

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

ValueLabelService (org.eclipse.sapphire.services.ValueLabelService)3 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)2 HashSet (java.util.HashSet)2 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)2 Test (org.junit.Test)2 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)1 ImageData (org.eclipse.sapphire.ImageData)1 Property (org.eclipse.sapphire.Property)1 ValueImageService (org.eclipse.sapphire.services.ValueImageService)1 SwtResourceCache (org.eclipse.sapphire.ui.forms.swt.SwtResourceCache)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Image (org.eclipse.swt.graphics.Image)1 Button (org.eclipse.swt.widgets.Button)1 Bundle (org.osgi.framework.Bundle)1