aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Amerson2013-10-03 15:37:43 (EDT)
committerKonstantin Komissarchik2013-10-03 15:37:43 (EDT)
commit444d7bb043940006377105f2034711ddc1e7a2ee (patch)
treeaab2140215183a156facac6494a5fe5b2b185058
parent42fab9e30d613fbd6abb7877a72fe526ddb6de22 (diff)
downloadorg.eclipse.sapphire-444d7bb043940006377105f2034711ddc1e7a2ee.zip
org.eclipse.sapphire-444d7bb043940006377105f2034711ddc1e7a2ee.tar.gz
org.eclipse.sapphire-444d7bb043940006377105f2034711ddc1e7a2ee.tar.bz2
Enhancement : Radio buttons property editor should show images
If ValueImageService provides an image, the radio buttons property editor presentation should display that image when rendering the radio button. Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=418602 Signed-off-by: Gregory Amerson <gregory.amerson@liferay.com>
-rw-r--r--plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroup.java17
-rw-r--r--plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroupBinding.java12
2 files changed, 23 insertions, 6 deletions
diff --git a/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroup.java b/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroup.java
index de34814..545ee33 100644
--- a/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroup.java
+++ b/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroup.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2013 Oracle
+ * Copyright (c) 2013 Oracle and Liferay
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* Konstantin Komissarchik - initial implementation and ongoing maintenance
* Ling Hao - [329102] excess scroll space in editor sections
+ * Gregory Amerson - [418602] Radio buttons property editor should show images
******************************************************************************/
package org.eclipse.sapphire.ui.internal.binding;
@@ -35,6 +36,7 @@ import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@@ -43,6 +45,7 @@ import org.eclipse.swt.widgets.Label;
/**
* @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
+ * @author <a href="gregory.amerson@liferay.com">Gregory Amerson</a>
*/
public class RadioButtonsGroup extends Composite
@@ -111,11 +114,12 @@ public class RadioButtonsGroup extends Composite
public Button addRadioButton( final String text )
{
- return addRadioButton( text, null );
+ return addRadioButton( text, null, null );
}
public Button addRadioButton( final String text,
- final String auxText )
+ final String auxText,
+ final Image image )
{
final Button button = new Button( this, SWT.RADIO );
button.setLayoutData( this.vertical ? gd() : null );
@@ -157,7 +161,12 @@ public class RadioButtonsGroup extends Composite
this.auxTextControls.put( button, auxTextComposite );
}
-
+
+ if( image != null )
+ {
+ button.setImage( image );
+ }
+
return button;
}
diff --git a/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroupBinding.java b/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroupBinding.java
index 00b5b09..df76a21 100644
--- a/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroupBinding.java
+++ b/plugins/org.eclipse.sapphire.ui/src/org/eclipse/sapphire/ui/internal/binding/RadioButtonsGroupBinding.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2013 Oracle
+ * Copyright (c) 2013 Oracle and Liferay
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,25 +7,30 @@
*
* Contributors:
* Konstantin Komissarchik - initial implementation and ongoing maintenance
+ * Gregory Amerson - [418602] Radio buttons property editor should show images
******************************************************************************/
package org.eclipse.sapphire.ui.internal.binding;
+import org.eclipse.sapphire.ImageData;
import org.eclipse.sapphire.MasterConversionService;
import org.eclipse.sapphire.Property;
import org.eclipse.sapphire.modeling.CapitalizationType;
import org.eclipse.sapphire.modeling.EnumValueType;
import org.eclipse.sapphire.modeling.util.MiscUtil;
+import org.eclipse.sapphire.services.ValueImageService;
import org.eclipse.sapphire.ui.PropertyEditorPart;
import org.eclipse.sapphire.ui.SapphireRenderingContext;
import org.eclipse.sapphire.ui.def.PropertyEditorDef;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
/**
* @author <a href="mailto:konstantin.komissarchik@oracle.com">Konstantin Komissarchik</a>
+ * @author <a href="gregory.amerson@liferay.com">Gregory Amerson</a>
*/
public final class RadioButtonsGroupBinding extends AbstractEnumBinding
@@ -57,7 +62,10 @@ public final class RadioButtonsGroupBinding extends AbstractEnumBinding
{
final String enumItemStr = property.service( MasterConversionService.class ).convert( enumItem, String.class );
final String auxText = editor.getRenderingHint( PropertyEditorDef.HINT_AUX_TEXT + "." + enumItemStr, null );
- final Button button = this.buttonsGroup.addRadioButton( enumValueType.getLabel( enumItem, false, CapitalizationType.FIRST_WORD_ONLY, true ), auxText );
+ final ValueImageService imageService = property.service( ValueImageService.class );
+ final ImageData imageData = imageService.provide( enumItemStr );
+ final Image image = context.getImageCache().image( imageData );
+ final Button button = this.buttonsGroup.addRadioButton( enumValueType.getLabel( enumItem, false, CapitalizationType.FIRST_WORD_ONLY, true ), auxText, image );
button.setData( enumItem );
}