1f371823aa1211c958d4ae27377b6041298cec5d
[gpl/argeo-suite.git] / org.argeo.suite.ui / src / org / argeo / suite / ui / DefaultLeadPane.java
1 package org.argeo.suite.ui;
2
3 import java.util.Map;
4
5 import javax.jcr.Node;
6 import javax.jcr.RepositoryException;
7
8 import org.argeo.cms.Localized;
9 import org.argeo.cms.ui.CmsTheme;
10 import org.argeo.cms.ui.CmsUiProvider;
11 import org.argeo.cms.ui.CmsView;
12 import org.argeo.cms.ui.util.CmsIcon;
13 import org.argeo.cms.ui.util.CmsUiUtils;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.layout.GridData;
16 import org.eclipse.swt.layout.GridLayout;
17 import org.eclipse.swt.widgets.Button;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Label;
21
22 /** Side pane listing various perspectives. */
23 public class DefaultLeadPane implements CmsUiProvider {
24         // private final static Log log = LogFactory.getLog(DefaultLeadPane.class);
25
26         @Override
27         public Control createUi(Composite parent, Node node) throws RepositoryException {
28                 CmsView cmsView = CmsView.getCmsView(parent);
29                 GridLayout layout = new GridLayout();
30                 layout.verticalSpacing = 10;
31                 layout.marginTop = 10;
32                 layout.marginLeft = 10;
33                 layout.marginRight = 10;
34                 parent.setLayout(layout);
35
36                 Button dashboardB = createButton(parent, SuiteMsg.dashboard.name(), SuiteMsg.dashboard, SuiteIcon.dashboard);
37                 if (!cmsView.isAnonymous()) {
38 //                      createButton(parent, SuiteMsg.documents.name(), SuiteMsg.documents, SuiteIcon.documents);
39 //                      createButton(parent, SuiteMsg.people.name(), SuiteMsg.people, SuiteIcon.people);
40 //                      createButton(parent, SuiteMsg.locations.name(), SuiteMsg.locations, SuiteIcon.location);
41                 }
42                 return dashboardB;
43         }
44
45         protected Button createButton(Composite parent, String layer, Localized msg, CmsIcon icon) {
46                 CmsTheme theme = CmsTheme.getCmsTheme(parent);
47                 Button button = new Button(parent, SWT.PUSH);
48                 CmsUiUtils.style(button, SuiteStyle.leadPane);
49                 button.setImage(icon.getBigIcon(theme));
50                 button.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, true, false));
51                 // button.setToolTipText(msg.lead());
52                 Label lbl = new Label(parent, SWT.NONE);
53                 CmsUiUtils.style(lbl, SuiteStyle.leadPane);
54                 lbl.setText(msg.lead());
55                 lbl.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
56                 CmsUiUtils.sendEventOnSelect(button, SuiteEvent.switchLayer.topic(), SuiteEvent.LAYER, layer);
57                 return button;
58         }
59
60         public void init(Map<String, String> properties) {
61
62         }
63 }