X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=org.argeo.suite.ui%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fui%2FDefaultLeadPane.java;h=77ba555e3b1af3e636f8cb1e9c9ea014c28135aa;hp=d84f69d5dd7b2a682ccd845c2c4fe1b857e5d655;hb=dec8c11591d7525c4be934406326823348daa461;hpb=a5ba54441da727f3965105a71b3a114b31dd34de diff --git a/org.argeo.suite.ui/src/org/argeo/suite/ui/DefaultLeadPane.java b/org.argeo.suite.ui/src/org/argeo/suite/ui/DefaultLeadPane.java index d84f69d..77ba555 100644 --- a/org.argeo.suite.ui/src/org/argeo/suite/ui/DefaultLeadPane.java +++ b/org.argeo.suite.ui/src/org/argeo/suite/ui/DefaultLeadPane.java @@ -1,31 +1,39 @@ package org.argeo.suite.ui; -import java.util.Dictionary; import java.util.Map; import javax.jcr.Node; import javax.jcr.RepositoryException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.argeo.cms.Localized; import org.argeo.cms.ui.CmsTheme; import org.argeo.cms.ui.CmsUiProvider; +import org.argeo.cms.ui.CmsView; import org.argeo.cms.ui.util.CmsIcon; import org.argeo.cms.ui.util.CmsUiUtils; import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.osgi.service.cm.ConfigurationException; -import org.osgi.service.cm.ManagedService; +import org.eclipse.swt.widgets.Label; /** Side pane listing various perspectives. */ -public class DefaultLeadPane implements CmsUiProvider, ManagedService { - private CmsTheme theme; +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 { - theme = CmsTheme.getCmsTheme(parent); + CmsView cmsView = CmsView.getCmsView(parent); GridLayout layout = new GridLayout(); layout.verticalSpacing = 10; layout.marginTop = 10; @@ -33,27 +41,42 @@ public class DefaultLeadPane implements CmsUiProvider, ManagedService { layout.marginRight = 10; parent.setLayout(layout); - Button dashboardB = createButton(parent, WorkMsg.dashboard, ArgeoSuiteIcon.dashboard); - createButton(parent, WorkMsg.people, ArgeoSuiteIcon.people); - createButton(parent, WorkMsg.documents, ArgeoSuiteIcon.documents); - return dashboardB; + 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); + } + return first; } - protected Button createButton(Composite parent, Localized msg, CmsIcon icon) { - Button button = new Button(parent, SWT.FLAT); - CmsUiUtils.style(button, WorkStyles.leadPane); - button.setToolTipText(msg.lead()); + protected Button createButton(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); 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); + 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; } - @Override - public void updated(Dictionary properties) throws ConfigurationException { - // TODO Auto-generated method stub - - } - - public void init(Map properties) { - + public void init(Map 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); } }