Search in sources :

Example 6 with ImageData

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

the class PortletFrameworkValueImageService method provide.

@Override
public ImageData provide(String value) {
    ImageData data = null;
    IPortletFramework framework = ProjectCore.getPortletFramework(value);
    if (framework != null) {
        String name = framework.getShortName();
        Result<ImageData> result = ImageData.readFromClassLoader(framework.getClass(), "images/" + name + ".png");
        data = result.optional();
    }
    return data;
}
Also used : IPortletFramework(com.liferay.ide.project.core.IPortletFramework) ImageData(org.eclipse.sapphire.ImageData)

Example 7 with ImageData

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

ImageData (org.eclipse.sapphire.ImageData)7 Element (org.eclipse.sapphire.Element)2 CustomPortletMode (com.liferay.ide.portlet.core.model.CustomPortletMode)1 CustomWindowState (com.liferay.ide.portlet.core.model.CustomWindowState)1 PortletMode (com.liferay.ide.portlet.core.model.PortletMode)1 WindowState (com.liferay.ide.portlet.core.model.WindowState)1 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)1 Column (com.liferay.ide.service.core.model.Column)1 Event (org.eclipse.sapphire.Event)1 Listener (org.eclipse.sapphire.Listener)1 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)1 Property (org.eclipse.sapphire.Property)1 ValueImageService (org.eclipse.sapphire.services.ValueImageService)1 ValueLabelService (org.eclipse.sapphire.services.ValueLabelService)1 ListSelectionService (org.eclipse.sapphire.ui.ListSelectionService)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