X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.app.ui%2Fsrc%2Forg%2Fargeo%2Fapp%2Fui%2FDefaultEditionLayer.java;h=9e399f0e8d6eeaba335b72c60f4058809c935b5a;hb=f1b87af2e0de38f1f49ab8fe68f9988018914811;hp=579157dd90795289e2b46a5482ea49b1302e1153;hpb=942fd932e1f6ed3319575c4c1d944912dfca9fa5;p=gpl%2Fargeo-suite.git diff --git a/org.argeo.app.ui/src/org/argeo/app/ui/DefaultEditionLayer.java b/org.argeo.app.ui/src/org/argeo/app/ui/DefaultEditionLayer.java index 579157d..9e399f0 100644 --- a/org.argeo.app.ui/src/org/argeo/app/ui/DefaultEditionLayer.java +++ b/org.argeo.app.ui/src/org/argeo/app/ui/DefaultEditionLayer.java @@ -4,15 +4,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import javax.jcr.Node; -import javax.jcr.RepositoryException; - -import org.argeo.api.cms.CmsTheme; -import org.argeo.app.ui.widgets.TabbedArea; +import org.argeo.api.acr.Content; import org.argeo.cms.Localized; +import org.argeo.cms.swt.CmsSwtTheme; import org.argeo.cms.swt.CmsSwtUtils; -import org.argeo.cms.ui.CmsUiProvider; -import org.argeo.jcr.JcrException; +import org.argeo.cms.swt.acr.SwtTabbedArea; +import org.argeo.cms.swt.acr.SwtUiProvider; import org.argeo.util.LangUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; @@ -20,13 +17,15 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; import org.osgi.framework.wiring.BundleWiring; /** An app layer based on an entry area and an editor area. */ public class DefaultEditionLayer implements SuiteLayer { - private CmsUiProvider entryArea; - private CmsUiProvider defaultView; - private CmsUiProvider workArea; + private String id; + private SwtUiProvider entryArea; + private SwtUiProvider defaultView; + private SwtUiProvider workArea; private List weights = new ArrayList<>(); private boolean startMaximized = false; private boolean fixedEntryArea = false; @@ -34,12 +33,12 @@ public class DefaultEditionLayer implements SuiteLayer { private Localized title = null; @Override - public Control createUi(Composite parent, Node context) throws RepositoryException { + public Control createUiPart(Composite parent, Content context) { // TODO Factorize more, or split into more specialised classes? if (entryArea != null) { if (fixedEntryArea) { FixedEditionArea editionArea = new FixedEditionArea(parent, parent.getStyle()); - Control entryAreaC = entryArea.createUi(editionArea.getEntryArea(), context); + Control entryAreaC = entryArea.createUiPart(editionArea.getEntryArea(), context); CmsSwtUtils.style(entryAreaC, SuiteStyle.entryArea); if (this.defaultView != null) { editionArea.getTabbedArea().view(defaultView, context); @@ -47,7 +46,7 @@ public class DefaultEditionLayer implements SuiteLayer { return editionArea; } else { SashFormEditionArea editionArea = new SashFormEditionArea(parent, parent.getStyle()); - entryArea.createUi(editionArea.getEntryArea(), context); + entryArea.createUiPart(editionArea.getEntryArea(), context); if (this.defaultView != null) { editionArea.getTabbedArea().view(defaultView, context); } @@ -56,30 +55,26 @@ public class DefaultEditionLayer implements SuiteLayer { } else { if (this.workArea != null) { Composite area = new Composite(parent, SWT.NONE); - this.workArea.createUi(area, context); + this.workArea.createUiPart(area, context); return area; } - CmsTheme theme = CmsSwtUtils.getCmsTheme(parent); - TabbedArea tabbedArea = createTabbedArea(parent, theme); + CmsSwtTheme theme = CmsSwtUtils.getCmsTheme(parent); + SwtTabbedArea tabbedArea = createTabbedArea(parent, theme); return tabbedArea; } } @Override - public void view(CmsUiProvider uiProvider, Composite workAreaC, Node context) { + public void view(SwtUiProvider uiProvider, Composite workAreaC, Content context) { if (workArea != null) { - try { - CmsSwtUtils.clear(workAreaC); - workArea.createUi(workAreaC, context); - workAreaC.layout(true, true); - return; - } catch (RepositoryException e) { - throw new JcrException("Cannot rebuild work area", e); - } + CmsSwtUtils.clear(workAreaC); + workArea.createUiPart(workAreaC, context); + workAreaC.layout(true, true); + return; } // tabbed area - TabbedArea tabbedArea = findTabbedArea(workAreaC); + SwtTabbedArea tabbedArea = findTabbedArea(workAreaC); if (tabbedArea == null) throw new IllegalArgumentException("Unsupported work area " + workAreaC.getClass().getName()); if (uiProvider == null) { @@ -94,28 +89,28 @@ public class DefaultEditionLayer implements SuiteLayer { } @Override - public Node getCurrentContext(Composite workArea) { - TabbedArea tabbedArea = findTabbedArea(workArea); + public Content getCurrentContext(Composite workArea) { + SwtTabbedArea tabbedArea = findTabbedArea(workArea); if (tabbedArea == null) return null; return tabbedArea.getCurrentContext(); } - private TabbedArea findTabbedArea(Composite workArea) { - TabbedArea tabbedArea = null; + private SwtTabbedArea findTabbedArea(Composite workArea) { + SwtTabbedArea tabbedArea = null; if (workArea instanceof SashFormEditionArea) { tabbedArea = ((SashFormEditionArea) workArea).getTabbedArea(); } else if (workArea instanceof FixedEditionArea) { tabbedArea = ((FixedEditionArea) workArea).getTabbedArea(); - } else if (workArea instanceof TabbedArea) { - tabbedArea = (TabbedArea) workArea; + } else if (workArea instanceof SwtTabbedArea) { + tabbedArea = (SwtTabbedArea) workArea; } return tabbedArea; } @Override - public void open(CmsUiProvider uiProvider, Composite workArea, Node context) { - TabbedArea tabbedArea = ((SashFormEditionArea) workArea).getTabbedArea(); + public void open(SwtUiProvider uiProvider, Composite workArea, Content context) { + SwtTabbedArea tabbedArea = ((SashFormEditionArea) workArea).getTabbedArea(); tabbedArea.open(uiProvider, context); } @@ -124,7 +119,15 @@ public class DefaultEditionLayer implements SuiteLayer { return title; } + @Override + public String getId() { + return id; + } + public void init(BundleContext bundleContext, Map properties) { + String pid = (String) properties.get(Constants.SERVICE_PID); + id = pid; + weights = LangUtils.toStringList(properties.get(Property.weights.name())); startMaximized = properties.containsKey(Property.startMaximized.name()) && "true".equals(properties.get(Property.startMaximized.name())); @@ -164,25 +167,25 @@ public class DefaultEditionLayer implements SuiteLayer { } - public void setEntryArea(CmsUiProvider entryArea) { + public void setEntryArea(SwtUiProvider entryArea) { this.entryArea = entryArea; } - public void setWorkArea(CmsUiProvider workArea) { + public void setWorkArea(SwtUiProvider workArea) { this.workArea = workArea; } - public void setDefaultView(CmsUiProvider defaultView) { + public void setDefaultView(SwtUiProvider defaultView) { this.defaultView = defaultView; } - TabbedArea createTabbedArea(Composite parent, CmsTheme theme) { - TabbedArea tabbedArea = new TabbedArea(parent, SWT.NONE); + SwtTabbedArea createTabbedArea(Composite parent, CmsSwtTheme theme) { + SwtTabbedArea tabbedArea = new SwtTabbedArea(parent, SWT.NONE); tabbedArea.setSingleTab(singleTab); tabbedArea.setBodyStyle(SuiteStyle.mainTabBody.style()); tabbedArea.setTabStyle(SuiteStyle.mainTab.style()); tabbedArea.setTabSelectedStyle(SuiteStyle.mainTabSelected.style()); - tabbedArea.setCloseIcon(SuiteIcon.close.getSmallIcon(theme)); + tabbedArea.setCloseIcon(theme.getSmallIcon(SuiteIcon.close)); tabbedArea.setLayoutData(CmsSwtUtils.fillAll()); return tabbedArea; } @@ -190,12 +193,12 @@ public class DefaultEditionLayer implements SuiteLayer { // /** A work area based on an entry area and and a tabbed area. */ class SashFormEditionArea extends SashForm { private static final long serialVersionUID = 2219125778722702618L; - private TabbedArea tabbedArea; + private SwtTabbedArea tabbedArea; private Composite entryC; SashFormEditionArea(Composite parent, int style) { super(parent, SWT.HORIZONTAL); - CmsTheme theme = CmsSwtUtils.getCmsTheme(parent); + CmsSwtTheme theme = CmsSwtUtils.getCmsTheme(parent); Composite editorC; if (SWT.RIGHT_TO_LEFT == (style & SWT.RIGHT_TO_LEFT)) {// arabic, hebrew, etc. @@ -231,7 +234,7 @@ public class DefaultEditionLayer implements SuiteLayer { tabbedArea = createTabbedArea(editorC, theme); } - TabbedArea getTabbedArea() { + SwtTabbedArea getTabbedArea() { return tabbedArea; } @@ -243,12 +246,12 @@ public class DefaultEditionLayer implements SuiteLayer { class FixedEditionArea extends Composite { private static final long serialVersionUID = -5525672639277322465L; - private TabbedArea tabbedArea; + private SwtTabbedArea tabbedArea; private Composite entryC; public FixedEditionArea(Composite parent, int style) { super(parent, style); - CmsTheme theme = CmsSwtUtils.getCmsTheme(parent); + CmsSwtTheme theme = CmsSwtUtils.getCmsTheme(parent); setLayout(CmsSwtUtils.noSpaceGridLayout(2)); @@ -274,7 +277,7 @@ public class DefaultEditionLayer implements SuiteLayer { tabbedArea = createTabbedArea(editorC, theme); } - TabbedArea getTabbedArea() { + SwtTabbedArea getTabbedArea() { return tabbedArea; }