More side areas in simple ergonomy.
<implementation class="org.argeo.cms.e4.rap.CmsE4AdminApp"/>
<service>
<provide interface="org.eclipse.rap.rwt.application.ApplicationConfiguration"/>
- <property name="contextName" type="String" value="cms"/>
+ <property name="contextName" type="String" value="cmsXXX"/>
</service>
</scr:component>
<implementation class="org.argeo.cms.e4.rap.CmsE4DemoApp"/>
<service>
<provide interface="org.eclipse.rap.rwt.application.ApplicationConfiguration"/>
- <property name="contextName" type="String" value="demo"/>
+ <property name="contextName" type="String" value="demoXXX"/>
</service>
</scr:component>
Service-Component: OSGI-INF/cms-admin-rap.xml,\
OSGI-INF/cms-demo-rap.xml
+Bundle-Activator: org.argeo.cms.script.ScriptAppActivator
+
Import-Package: org.argeo.node,\
org.eclipse.swt,\
org.eclipse.swt.graphics,\
org.eclipse.e4.ui.workbench,\
org.eclipse.rap.rwt.client,\
+org.argeo.cms.script,\
*
--- /dev/null
+// Standard CMS App
+APP.webPath = 'cms'
+
+// Common
+APP.pageTitle = 'Argeo CMS';
+
+APP.ui['devops'] = new org.argeo.cms.script.AppUi(APP, new org.argeo.cms.e4.rap.CmsE4EntryPointFactory('org.argeo.cms.e4/e4xmi/cms-devops.e4xmi'));
+APP.ui['devops'].pageTitle = 'Argeo CMS DevOps';
import org.eclipse.rap.rwt.client.service.JavaScriptExecutor;
public class CmsE4EntryPointFactory extends E4EntryPointFactory {
+ public final static String DEFAULT_LIFECYCLE_URI = "bundleclass://org.argeo.cms.e4.rap/org.argeo.cms.e4.rap.CmsLoginLifecycle";
public CmsE4EntryPointFactory(E4ApplicationConfig config) {
super(config);
}
+ public CmsE4EntryPointFactory(String e4Xmi, String lifeCycleUri) {
+ super(defaultConfig(e4Xmi, lifeCycleUri));
+ }
+
+ public CmsE4EntryPointFactory(String e4Xmi) {
+ this(e4Xmi, DEFAULT_LIFECYCLE_URI);
+ }
+
+ public static E4ApplicationConfig defaultConfig(String e4Xmi, String lifeCycleUri) {
+ E4ApplicationConfig config = new E4ApplicationConfig(e4Xmi, lifeCycleUri, null, null, false, true, true);
+ return config;
+ }
+
@Override
public EntryPoint create() {
EntryPoint ep = createEntryPoint();
protected EntryPoint createEntryPoint() {
return super.create();
}
-
- // private boolean login(Subject subject) {
- // Display display = new Display();
- // CmsView cmsView = new E4CmsView(subject);
- // CmsLoginShell loginShell = new CmsLoginShell(cmsView);
- // loginShell.setSubject(subject);
- // try {
- // // try pre-auth
- // LoginContext loginContext = new
- // LoginContext(NodeConstants.LOGIN_CONTEXT_USER, subject, loginShell);
- // loginContext.login();
- // } catch (LoginException e) {
- // loginShell.createUi();
- // loginShell.open();
- //
- // while (!loginShell.getShell().isDisposed()) {
- // if (!display.readAndDispatch())
- // display.sleep();
- // }
- // } finally {
- // display.dispose();
- // }
- // if (CurrentUser.getUsername(subject) == null)
- // return false;
- // return true;
- // }
- //
- // private class E4CmsView implements CmsView {
- // private LoginContext loginContext;
- // private UxContext uxContext;
- // private Subject subject;
- //
- // public E4CmsView(Subject subject) {
- // this.subject = subject;
- // uxContext = new SimpleUxContext();
- // }
- //
- // @Override
- // public UxContext getUxContext() {
- // return uxContext;
- // }
- //
- // @Override
- // public void navigateTo(String state) {
- // // TODO Auto-generated method stub
- //
- // }
- //
- // @Override
- // public void authChange(LoginContext loginContext) {
- // if (loginContext == null)
- // throw new CmsException("Login context cannot be null");
- // // logout previous login context
- // // if (this.loginContext != null)
- // // try {
- // // this.loginContext.logout();
- // // } catch (LoginException e1) {
- // // System.err.println("Could not log out: " + e1);
- // // }
- // this.loginContext = loginContext;
- // }
- //
- // @Override
- // public void logout() {
- // if (loginContext == null)
- // throw new CmsException("Login context should not bet null");
- // try {
- // CurrentUser.logoutCmsSession(loginContext.getSubject());
- // loginContext.logout();
- // } catch (LoginException e) {
- // throw new CmsException("Cannot log out", e);
- // }
- // }
- //
- // @Override
- // public void exception(Throwable e) {
- // log.error("Unexpected exception in Eclipse 4 RAP", e);
- // }
- //
- // @Override
- // public CmsImageManager getImageManager() {
- // // TODO Auto-generated method stub
- // return null;
- // }
- //
- // protected Subject getSubject() {
- // return subject;
- // }
- //
- // @Override
- // public boolean isAnonymous() {
- // return CurrentUser.isAnonymous(getSubject());
- // }
- // }
}
private String script;
// private Branding branding = new Branding();
+ private EntryPointFactory factory;
+
// Branding
private String themeId;
private String additionalHeaders;
this.ui = uiProvider;
}
+ public AppUi(CmsScriptApp app, EntryPointFactory factory) {
+ this.app = app;
+ this.factory = factory;
+ }
+
public void apply(Repository repository, Application application, Branding appBranding, String path) {
Map<String, String> factoryProperties = new HashMap<>();
if (appBranding != null)
appBranding.applyBranding(factoryProperties);
applyBranding(factoryProperties);
- EntryPointFactory entryPointFactory = new EntryPointFactory() {
- @Override
- public EntryPoint create() {
- SimpleErgonomics ergonomics = new SimpleErgonomics(repository, "main", "/home/root/argeo:keyring",
- AppUi.this, factoryProperties);
- return ergonomics;
- }
- };
- application.addEntryPoint("/" + path, entryPointFactory, factoryProperties);
+ if (factory != null) {
+ application.addEntryPoint("/" + path, factory, factoryProperties);
+ } else {
+ EntryPointFactory entryPointFactory = new EntryPointFactory() {
+ @Override
+ public EntryPoint create() {
+ SimpleErgonomics ergonomics = new SimpleErgonomics(repository, "main", "/home/root/argeo:keyring",
+ AppUi.this, factoryProperties);
+// CmsUiProvider header = app.getHeader();
+// if (header != null)
+// ergonomics.setHeader(header);
+ app.applySides(ergonomics);
+ Integer headerHeight = app.getHeaderHeight();
+ if (headerHeight != null)
+ ergonomics.setHeaderHeight(headerHeight);
+ return ergonomics;
+ }
+ };
+ application.addEntryPoint("/" + path, entryPointFactory, factoryProperties);
+ }
}
public void setUi(CmsUiProvider uiProvider) {
@Override
public Control createUi(Composite parent, Node context) throws RepositoryException {
CmsPane cmsPane = new CmsPane(parent, SWT.NONE);
- // QA
- CmsUtils.style(cmsPane.getQaArea(), "qa");
- Button reload = new Button(cmsPane.getQaArea(), SWT.FLAT);
- CmsUtils.style(reload, "qa");
- reload.setText("Reload");
- reload.addSelectionListener(new Selected() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- new Thread() {
- @Override
- public void run() {
- app.reload();
- }
- }.start();
- RWT.getClient().getService(JavaScriptExecutor.class).execute("setTimeout('location.reload()',1000)");
- }
- });
- // Support
- CmsUtils.style(cmsPane.getSupportArea(), "support");
- Label msg = new Label(cmsPane.getSupportArea(), SWT.NONE);
- CmsUtils.style(msg, "support");
- msg.setText("UNSUPPORTED DEVELOPMENT VERSION");
+ if (false) {
+ // QA
+ CmsUtils.style(cmsPane.getQaArea(), "qa");
+ Button reload = new Button(cmsPane.getQaArea(), SWT.FLAT);
+ CmsUtils.style(reload, "qa");
+ reload.setText("Reload");
+ reload.addSelectionListener(new Selected() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ new Thread() {
+ @Override
+ public void run() {
+ app.reload();
+ }
+ }.start();
+ RWT.getClient().getService(JavaScriptExecutor.class)
+ .execute("setTimeout('location.reload()',1000)");
+ }
+ });
+
+ // Support
+ CmsUtils.style(cmsPane.getSupportArea(), "support");
+ Label msg = new Label(cmsPane.getSupportArea(), SWT.NONE);
+ CmsUtils.style(msg, "support");
+ msg.setText("UNSUPPORTED DEVELOPMENT VERSION");
+ }
if (ui != null) {
ui.createUi(cmsPane.getMainArea(), context);
import org.apache.commons.logging.LogFactory;
import org.argeo.cms.CmsException;
import org.argeo.cms.ui.CmsConstants;
+import org.argeo.cms.ui.CmsUiProvider;
import org.argeo.cms.util.BundleResourceLoader;
import org.argeo.cms.util.CmsUtils;
+import org.argeo.cms.util.SimpleErgonomics;
import org.eclipse.rap.rwt.application.Application;
import org.eclipse.rap.rwt.application.Application.OperationMode;
import org.eclipse.rap.rwt.application.ApplicationConfiguration;
private Map<String, AppUi> ui = new HashMap<>();
+ private CmsUiProvider header;
+ private Integer headerHeight = null;
+ private CmsUiProvider lead;
+ private CmsUiProvider end;
+ private CmsUiProvider footer;
+
// Branding
private String themeId;
private String additionalHeaders;
}
+ public void applySides(SimpleErgonomics simpleErgonomics) {
+ simpleErgonomics.setHeader(header);
+ simpleErgonomics.setLead(lead);
+ simpleErgonomics.setEnd(end);
+ simpleErgonomics.setFooter(footer);
+ }
+
public void register(BundleContext bundleContext, ApplicationConfiguration appConfig) {
Hashtable<String, String> props = new Hashtable<>();
props.put(CONTEXT_NAME, webPath);
this.favicon = favicon;
}
+ public CmsUiProvider getHeader() {
+ return header;
+ }
+
+ public void setHeader(CmsUiProvider header) {
+ this.header = header;
+ }
+
+ public Integer getHeaderHeight() {
+ return headerHeight;
+ }
+
+ public void setHeaderHeight(Integer headerHeight) {
+ this.headerHeight = headerHeight;
+ }
+
+ public CmsUiProvider getLead() {
+ return lead;
+ }
+
+ public void setLead(CmsUiProvider lead) {
+ this.lead = lead;
+ }
+
+ public CmsUiProvider getEnd() {
+ return end;
+ }
+
+ public void setEnd(CmsUiProvider end) {
+ this.end = end;
+ }
+
+ public CmsUiProvider getFooter() {
+ return footer;
+ }
+
+ public void setFooter(CmsUiProvider footer) {
+ this.footer = footer;
+ }
+
}
public class Theme {
private final static Log log = LogFactory.getLog(Theme.class);
- private String themeId;
+ private final String themeId;
private Map<String, ResourceLoader> css = new HashMap<>();
private Map<String, ResourceLoader> resources = new HashMap<>();
private String headerCss;
private List<String> fonts = new ArrayList<>();
+ private String basePath;
+ private String cssPath;
+
+ public Theme(BundleContext bundleContext) {
+ this(bundleContext, null);
+ }
+
public Theme(BundleContext bundleContext, String symbolicName) {
- this.themeId = symbolicName;
- Bundle themeBundle = ThemeUtils.findThemeBundle(bundleContext, symbolicName);
+ Bundle themeBundle;
+ if (symbolicName == null) {
+ themeBundle = bundleContext.getBundle();
+ basePath = "/theme/internal/";
+ cssPath = basePath;
+ } else {
+ themeBundle = ThemeUtils.findThemeBundle(bundleContext, symbolicName);
+ basePath = "/";
+ cssPath = "/rap/";
+ }
+ this.themeId = themeBundle.getSymbolicName();
addStyleSheets(themeBundle, new BundleResourceLoader(themeBundle));
BundleResourceLoader themeBRL = new BundleResourceLoader(themeBundle);
addResources(themeBRL, "*.png");
addResources(themeBRL, "*.ico");
// fonts
- URL fontsUrl = themeBundle.getEntry("fonts.txt");
+ URL fontsUrl = themeBundle.getEntry(basePath + "fonts.txt");
if (fontsUrl != null) {
loadFontsUrl(fontsUrl);
}
// common CSS header (plain CSS)
- URL headerCssUrl = themeBundle.getEntry("header.css");
+ URL headerCssUrl = themeBundle.getEntry(basePath + "header.css");
if (headerCssUrl != null) {
try (BufferedReader buffer = new BufferedReader(new InputStreamReader(headerCssUrl.openStream(), UTF_8))) {
headerCss = buffer.lines().collect(Collectors.joining("\n"));
}
void addStyleSheets(Bundle themeBundle, ResourceLoader ssRL) {
- Enumeration<URL> themeResources = themeBundle.findEntries("/rap", "*.css", true);
+ Enumeration<URL> themeResources = themeBundle.findEntries(cssPath, "*.css", true);
if (themeResources == null)
return;
while (themeResources.hasMoreElements()) {
void addResources(BundleResourceLoader themeBRL, String pattern) {
Bundle themeBundle = themeBRL.getBundle();
- Enumeration<URL> themeResources = themeBundle.findEntries("/", pattern, true);
+ Enumeration<URL> themeResources = themeBundle.findEntries(basePath, pattern, true);
if (themeResources == null)
return;
while (themeResources.hasMoreElements()) {
return themeId;
}
+ public String getBasePath() {
+ return basePath;
+ }
+
+ public void setBasePath(String basePath) {
+ this.basePath = basePath;
+ }
+
+ public String getCssPath() {
+ return cssPath;
+ }
+
+ public void setCssPath(String cssPath) {
+ this.cssPath = cssPath;
+ }
+
}
-//var CmsUiProvider = Java.type('org.argeo.cms.ui.CmsUiProvider');
+// CMS
var CmsScriptApp = Java.type('org.argeo.cms.script.CmsScriptApp');
var AppUi = Java.type('org.argeo.cms.script.AppUi');
var Theme = Java.type('org.argeo.cms.script.Theme');
var ScriptUi = Java.type('org.argeo.cms.script.ScriptUi');
var CmsUtils = Java.type('org.argeo.cms.util.CmsUtils');
+var SimpleCmsHeader = Java.type('org.argeo.cms.util.SimpleCmsHeader');
+var CmsLink = Java.type('org.argeo.cms.util.CmsLink');
+var MenuLink = Java.type('org.argeo.cms.util.MenuLink');
+var UserMenuLink = Java.type('org.argeo.cms.util.UserMenuLink');
// SWT
var SWT = Java.type('org.eclipse.swt.SWT');
Node newNode = null;
if (session.nodeExists(newNodePath))
newNode = session.getNode(newNodePath);
- else
- throw new CmsException("Data " + newNodePath + " does not exist");
+ else {
+// throw new CmsException("Data " + newNodePath + " does not exist");
+ newNode = null;
+ }
setNode(newNode);
}
String title = publishMetaData(getNode());
private String publishMetaData(Node node) throws RepositoryException {
// Title
String title;
- if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_TITLE))
+ if (node!=null && node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_TITLE))
title = node.getProperty(Property.JCR_TITLE).getString() + " - " + getBaseTitle();
else
title = getBaseTitle();
public final static String CMS_HEADER_LEAD = "cms_header-lead";
public final static String CMS_HEADER_CENTER = "cms_header-center";
public final static String CMS_HEADER_END = "cms_header-end";
+
+ public final static String CMS_LEAD = "cms_lead";
+ public final static String CMS_END = "cms_end";
+ public final static String CMS_FOOTER = "cms_footer";
+
public final static String CMS_USER_MENU = "cms_user_menu";
public final static String CMS_USER_MENU_LINK = "cms_user_menu-link";
public final static String CMS_USER_MENU_ITEM = "cms_user_menu-item";
private String image;
private MouseListener mouseListener;
+ private int horizontalAlignment = SWT.CENTER;
private int verticalAlignment = SWT.CENTER;
private String loggedInLabel = null;
public void init() {
if (image != null) {
ImageData image = loadImage();
- imageWidth = image.width;
- imageHeight = image.height;
+ if (imageHeight == null && imageWidth == null) {
+ imageWidth = image.width;
+ imageHeight = image.height;
+ } else if (imageHeight == null) {
+ imageHeight = (imageWidth * image.height) / image.width;
+ } else if (imageWidth == null) {
+ imageWidth = (imageHeight * image.width) / image.height;
+ }
}
}
/** @return {@link Composite} with a single {@link Label} child. */
@Override
public Control createUi(final Composite parent, Node context) {
- if (image != null && (imageWidth == null || imageHeight == null)) {
- throw new CmsException("Image is not properly configured."
- + " Make sure bundleContext property is set and init() method has been called.");
- }
+// if (image != null && (imageWidth == null || imageHeight == null)) {
+// throw new CmsException("Image is not properly configured."
+// + " Make sure bundleContext property is set and init() method has been called.");
+// }
Composite comp = new Composite(parent, SWT.BOTTOM);
comp.setLayout(CmsUtils.noSpaceGridLayout());
Label link = new Label(comp, SWT.NONE);
link.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
- GridData layoutData = new GridData(SWT.CENTER, verticalAlignment, true, true);
+ GridData layoutData = new GridData(horizontalAlignment, verticalAlignment, false, false);
if (image != null) {
- layoutData.heightHint = imageHeight;
+ if (imageHeight != null)
+ layoutData.heightHint = imageHeight;
if (label == null)
- layoutData.widthHint = imageWidth;
+ if (imageWidth != null)
+ layoutData.widthHint = imageWidth;
}
link.setLayoutData(layoutData);
if (image != null) {
registerImageIfNeeded();
String imageLocation = RWT.getResourceManager().getLocation(image);
- labelText.append("<img width='").append(imageWidth).append("' height='").append(imageHeight)
- .append("' src=\"").append(imageLocation).append("\"/>");
+ labelText.append("<img");
+ if (imageWidth != null)
+ labelText.append(" width='").append(imageWidth).append('\'');
+ if (imageHeight != null)
+ labelText.append(" height='").append(imageHeight).append('\'');
+ labelText.append(" src=\"").append(imageLocation).append("\"/>");
}
return !CurrentUser.isAnonymous();
}
+ public void setImageWidth(Integer imageWidth) {
+ this.imageWidth = imageWidth;
+ }
+
+ public void setImageHeight(Integer imageHeight) {
+ this.imageHeight = imageHeight;
+ }
+
}
public CmsPane(Composite parent, int style) {
parent.setLayout(CmsUtils.noSpaceGridLayout());
- qaArea = new Composite(parent, SWT.NONE);
- qaArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- RowLayout qaLayout = new RowLayout();
- qaLayout.spacing = 0;
- qaArea.setLayout(qaLayout);
+// qaArea = new Composite(parent, SWT.NONE);
+// qaArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+// RowLayout qaLayout = new RowLayout();
+// qaLayout.spacing = 0;
+// qaArea.setLayout(qaLayout);
mainArea = new Composite(parent, SWT.NONE);
mainArea.setLayout(new GridLayout());
mainArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- supportArea = new Composite(parent, SWT.NONE);
- supportArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- RowLayout supportLayout = new RowLayout();
- supportLayout.spacing = 0;
- supportArea.setLayout(supportLayout);
+// supportArea = new Composite(parent, SWT.NONE);
+// supportArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+// RowLayout supportLayout = new RowLayout();
+// supportLayout.spacing = 0;
+// supportArea.setLayout(supportLayout);
}
public Composite getMainArea() {
public MenuLink() {
setCustom(CmsStyles.CMS_MENU_LINK);
}
+
+ public MenuLink(String label, String target, String custom) {
+ super(label, target, custom);
+ }
+
+ public MenuLink(String label, String target) {
+ super(label, target, CmsStyles.CMS_MENU_LINK);
+ }
+
}
private Boolean subPartsSameWidth = false;
@Override
- public Control createUi(Composite parent, Node context)
- throws RepositoryException {
+ public Control createUi(Composite parent, Node context) throws RepositoryException {
Composite header = new Composite(parent, SWT.NONE);
header.setData(RWT.CUSTOM_VARIANT, CmsStyles.CMS_HEADER);
header.setBackgroundMode(SWT.INHERIT_DEFAULT);
return header;
}
- protected void configurePart(Node context, Composite parent,
- List<CmsUiProvider> partProviders) throws RepositoryException {
+ protected void configurePart(Node context, Composite parent, List<CmsUiProvider> partProviders)
+ throws RepositoryException {
final int style;
final String custom;
if (lead == partProviders) {
style = SWT.END;
custom = CmsStyles.CMS_HEADER_END;
} else {
- throw new CmsException("Unsupported part providers "
- + partProviders);
+ throw new CmsException("Unsupported part providers " + partProviders);
}
Composite part = new Composite(parent, SWT.NONE);
part.setData(RWT.CUSTOM_VARIANT, custom);
GridData gridData = new GridData(style, SWT.FILL, true, true);
part.setLayoutData(gridData);
- part.setLayout(CmsUtils.noSpaceGridLayout(new GridLayout(partProviders
- .size(), subPartsSameWidth)));
+ part.setLayout(CmsUtils.noSpaceGridLayout(new GridLayout(partProviders.size(), subPartsSameWidth)));
for (CmsUiProvider uiProvider : partProviders) {
Control subPart = uiProvider.createUi(part, context);
- subPart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true));
+ subPart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
}
}
this.subPartsSameWidth = subPartsSameWidth;
}
+ public List<CmsUiProvider> getLead() {
+ return lead;
+ }
+
+ public List<CmsUiProvider> getCenter() {
+ return center;
+ }
+
+ public List<CmsUiProvider> getEnd() {
+ return end;
+ }
+
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
private boolean uiInitialized = false;
private Composite headerArea;
+ private Composite leftArea;
+ private Composite rightArea;
+ private Composite footerArea;
private Composite bodyArea;
private final CmsUiProvider uiProvider;
private CmsUiProvider header;
private Integer headerHeight = 0;
+ private CmsUiProvider lead;
+ private CmsUiProvider end;
+ private CmsUiProvider footer;
private CmsImageManager imageManager = new ImageManagerImpl();
private UxContext uxContext = null;
@Override
protected void initUi(Composite parent) {
parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- parent.setLayout(CmsUtils.noSpaceGridLayout());
+ parent.setLayout(CmsUtils.noSpaceGridLayout(new GridLayout(3, false)));
uxContext = new SimpleUxContext();
if (!getUxContext().isMasterData())
createAdminArea(parent);
headerArea = new Composite(parent, SWT.NONE);
headerArea.setLayout(new FillLayout());
- GridData headerData = new GridData(SWT.FILL, SWT.FILL, false, false);
+ GridData headerData = new GridData(SWT.FILL, SWT.FILL, false, false, 3, 1);
headerData.heightHint = headerHeight;
headerArea.setLayoutData(headerData);
+ // TODO: bi-directional
+ leftArea = new Composite(parent, SWT.NONE);
+ leftArea.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, false, false));
+ leftArea.setLayout(CmsUtils.noSpaceGridLayout());
+
bodyArea = new Composite(parent, SWT.NONE);
bodyArea.setData(RWT.CUSTOM_VARIANT, CmsStyles.CMS_BODY);
bodyArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
bodyArea.setLayout(CmsUtils.noSpaceGridLayout());
+
+ // TODO: bi-directional
+ rightArea = new Composite(parent, SWT.NONE);
+ rightArea.setLayoutData(new GridData(SWT.END, SWT.TOP, false, false));
+ rightArea.setLayout(CmsUtils.noSpaceGridLayout());
+
+ footerArea = new Composite(parent, SWT.NONE);
+ // footerArea.setLayout(new FillLayout());
+ GridData footerData = new GridData(SWT.FILL, SWT.FILL, false, false, 3, 1);
+ footerData.heightHint = headerHeight;
+ footerArea.setLayoutData(footerData);
+
uiInitialized = true;
refresh();
}
return;
if (getState() == null)
setState("");
- refreshHeader();
+ refreshSides();
refreshBody();
if (log.isTraceEnabled())
log.trace("UI refreshed " + getNode());
protected void createAdminArea(Composite parent) {
}
+ @Deprecated
protected void refreshHeader() {
if (header == null)
return;
headerArea.layout(true, true);
}
+ protected void refreshSides() {
+ refresh(headerArea, header, CmsStyles.CMS_HEADER);
+ refresh(leftArea, lead, CmsStyles.CMS_LEAD);
+ refresh(rightArea, end, CmsStyles.CMS_END);
+ refresh(footerArea, footer, CmsStyles.CMS_FOOTER);
+ }
+
+ private void refresh(Composite area, CmsUiProvider uiProvider, String style) {
+ if (uiProvider == null)
+ return;
+
+ for (Control child : area.getChildren())
+ child.dispose();
+ CmsUtils.style(area, style);
+ try {
+ uiProvider.createUi(area, getNode());
+ } catch (RepositoryException e) {
+ throw new CmsException("Cannot refresh header", e);
+ }
+ area.layout(true, true);
+ }
+
protected void refreshBody() {
// Exception
Throwable exception = getException();
try {
Node node = getNode();
- if (node == null)
- log.error("Context cannot be null");
- else
- uiProvider.createUi(bodyArea, node);
+// if (node == null)
+// log.error("Context cannot be null");
+// else
+ uiProvider.createUi(bodyArea, node);
} catch (RepositoryException e) {
throw new CmsException("Cannot refresh body", e);
}
public void setImageManager(CmsImageManager imageManager) {
this.imageManager = imageManager;
}
+
+ public CmsUiProvider getLead() {
+ return lead;
+ }
+
+ public void setLead(CmsUiProvider lead) {
+ this.lead = lead;
+ }
+
+ public CmsUiProvider getEnd() {
+ return end;
+ }
+
+ public void setEnd(CmsUiProvider end) {
+ this.end = end;
+ }
+
+ public CmsUiProvider getFooter() {
+ return footer;
+ }
+
+ public void setFooter(CmsUiProvider footer) {
+ this.footer = footer;
+ }
+
+ public CmsUiProvider getHeader() {
+ return header;
+ }
+
}
--- /dev/null
+package org.argeo.cms.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.cms.ui.CmsUiProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public class VerticalMenu implements CmsUiProvider {
+ private List<CmsUiProvider> items = new ArrayList<CmsUiProvider>();
+
+ @Override
+ public Control createUi(Composite parent, Node context) throws RepositoryException {
+ Composite part = new Composite(parent, SWT.NONE);
+ part.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, false, false));
+// part.setData(RWT.CUSTOM_VARIANT, custom);
+ part.setLayout(CmsUtils.noSpaceGridLayout());
+ for (CmsUiProvider uiProvider : items) {
+ Control subPart = uiProvider.createUi(part, context);
+ subPart.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, false, false));
+ }
+ return part;
+ }
+
+ public void add(CmsUiProvider uiProvider) {
+ items.add(uiProvider);
+ }
+
+ public List<CmsUiProvider> getItems() {
+ return items;
+ }
+
+ public void setItems(List<CmsUiProvider> items) {
+ this.items = items;
+ }
+
+}
Locale locale = localeChoice == null ? this.defaultLocale : localeChoice.getSelectedLocale();
credentialsBlock = new Composite(parent, SWT.NONE);
credentialsBlock.setLayout(new GridLayout());
- credentialsBlock.setLayoutData(CmsUtils.fillAll());
+ // credentialsBlock.setLayoutData(CmsUtils.fillAll());
specificUserUi(credentialsBlock);
// We need a composite for the traversal
credentialsBlock = new Composite(parent, SWT.NONE);
credentialsBlock.setLayout(new GridLayout());
- credentialsBlock.setLayoutData(CmsUtils.fillAll());
+ // credentialsBlock.setLayoutData(CmsUtils.fillAll());
+ CmsUtils.style(credentialsBlock, CMS_LOGIN_DIALOG);
Integer textWidth = 120;
- CmsUtils.style(parent, CMS_USER_MENU);
+ if (parent instanceof Shell)
+ CmsUtils.style(parent, CMS_USER_MENU);
// new Label(this, SWT.NONE).setText(CmsMsg.username.lead());
usernameT = new Text(credentialsBlock, SWT.BORDER);
usernameT.setMessage(username.lead(locale));
protected Composite createLocalesBlock(final Composite parent) {
Composite c = new Composite(parent, SWT.NONE);
+ CmsUtils.style(c, CMS_USER_MENU_ITEM);
c.setLayout(CmsUtils.noSpaceGridLayout());
c.setLayoutData(CmsUtils.fillAll());
for (Integer i = 0; i < locales.size(); i++) {
Locale locale = locales.get(i);
Button button = new Button(c, SWT.RADIO);
+ CmsUtils.style(button, CMS_USER_MENU_ITEM);
button.setData(i);
button.setText(LocaleUtils.lead(locale.getDisplayName(locale), locale) + " (" + locale + ")");
// button.addListener(SWT.Selection, listener);