Work on styling.
[gpl/argeo-suite.git] / org.argeo.suite.ui / src / org / argeo / suite / ui / SuiteUiUtils.java
index be14a823d11b0fefd0c7328430fb921da8c4121f..8e9a9d5d641968693a6364f6cba86696ef0d256b 100644 (file)
@@ -9,7 +9,9 @@ import javax.jcr.Session;
 
 import org.argeo.cms.Localized;
 import org.argeo.cms.ui.CmsEditable;
+import org.argeo.cms.ui.CmsTheme;
 import org.argeo.cms.ui.dialogs.LightweightDialog;
+import org.argeo.cms.ui.util.CmsIcon;
 import org.argeo.cms.ui.util.CmsUiUtils;
 import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.argeo.entity.EntityNames;
@@ -310,6 +312,24 @@ public class SuiteUiUtils {
                return img;
        }
 
+       public static Button createLayerButton(Composite parent, String layer, Localized msg, CmsIcon icon) {
+               CmsTheme theme = CmsTheme.getCmsTheme(parent);
+               Button button = new Button(parent, SWT.PUSH);
+               CmsUiUtils.style(button, SuiteStyle.leadPane);
+               if (icon != null)
+                       button.setImage(icon.getBigIcon(theme));
+               button.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, true, false));
+               // button.setToolTipText(msg.lead());
+               if (msg != null) {
+                       Label lbl = new Label(parent, SWT.NONE);
+                       CmsUiUtils.style(lbl, SuiteStyle.leadPane);
+                       lbl.setText(msg.lead());
+                       lbl.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
+               }
+               CmsUiUtils.sendEventOnSelect(button, SuiteEvent.switchLayer.topic(), SuiteEvent.LAYER, layer);
+               return button;
+       }
+
 //     public static String createAndConfigureEntity(Shell shell, Session referenceSession, String mainMixin,
 //                     String... additionnalProps) {
 //