Improve multi-layers and introduce documents layer.
[gpl/argeo-suite.git] / org.argeo.suite.ui / src / org / argeo / suite / ui / DefaultLeadPane.java
index 6c6047492901242c8e1e1f5058aa87b42af521c5..77ba555e3b1af3e636f8cb1e9c9ea014c28135aa 100644 (file)
@@ -25,6 +25,12 @@ import org.eclipse.swt.widgets.Label;
 public class DefaultLeadPane implements CmsUiProvider {
        private final static Log log = LogFactory.getLog(DefaultLeadPane.class);
 
+       public static enum Property {
+               defaultLayers;
+       }
+
+       private String[] defaultLayers;
+
        @Override
        public Control createUi(Composite parent, Node node) throws RepositoryException {
                CmsView cmsView = CmsView.getCmsView(parent);
@@ -35,13 +41,20 @@ public class DefaultLeadPane implements CmsUiProvider {
                layout.marginRight = 10;
                parent.setLayout(layout);
 
-               Button dashboardB = createButton(parent, SuiteMsg.dashboard.name(), SuiteMsg.dashboard, SuiteIcon.dashboard);
+               Button first = null;
+               for (String layerId : defaultLayers) {
+                       Button b = createButton(parent, layerId, SuiteMsg.dashboard, SuiteIcon.dashboard);
+                       if (first == null)
+                               first = b;
+               }
+
+//             Button dashboardB = createButton(parent, SuiteMsg.dashboard.name(), SuiteMsg.dashboard, SuiteIcon.dashboard);
                if (!cmsView.isAnonymous()) {
 //                     createButton(parent, SuiteMsg.documents.name(), SuiteMsg.documents, SuiteIcon.documents);
 //                     createButton(parent, SuiteMsg.people.name(), SuiteMsg.people, SuiteIcon.people);
-                       createButton(parent, SuiteMsg.locations.name(), SuiteMsg.locations, SuiteIcon.location);
+//                     createButton(parent, SuiteMsg.locations.name(), SuiteMsg.locations, SuiteIcon.location);
                }
-               return dashboardB;
+               return first;
        }
 
        protected Button createButton(Composite parent, String layer, Localized msg, CmsIcon icon) {
@@ -50,8 +63,8 @@ public class DefaultLeadPane implements CmsUiProvider {
                CmsUiUtils.style(button, SuiteStyle.leadPane);
                button.setImage(icon.getBigIcon(theme));
                button.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, true, false));
-               //button.setToolTipText(msg.lead());
-               Label lbl = new Label(parent,SWT.NONE);
+               // button.setToolTipText(msg.lead());
+               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));
@@ -59,7 +72,11 @@ public class DefaultLeadPane implements CmsUiProvider {
                return button;
        }
 
-       public void init(Map<String, String> properties) {
-
+       public void init(Map<String, Object> properties) {
+               defaultLayers = (String[]) properties.get(Property.defaultLayers.toString());
+               if (defaultLayers == null)
+                       throw new IllegalArgumentException("Default layers must be set.");
+               if (log.isDebugEnabled())
+                       log.debug("Default layers: " + defaultLayers);
        }
 }