+ public static boolean isCoworker(CmsView cmsView) {
+ boolean coworker = cmsView.doAs(() -> CurrentUser.isInRole(SuiteRole.coworker.dn()));
+ return coworker;
+ }
+
+ public static boolean isTopic(Event event, CmsEvent cmsEvent) {
+ return event.getTopic().equals(cmsEvent.topic());
+ }
+
+ public static Button createLayerButton(Composite parent, String layer, Localized msg, CmsIcon icon,
+ ClassLoader l10nClassLoader) {
+ CmsTheme theme = CmsSwtUtils.getCmsTheme(parent);
+ Button button = new Button(parent, SWT.PUSH);
+ CmsSwtUtils.style(button, SuiteStyle.leadPane);
+ if (icon != null)
+ button.setImage(icon.getBigIcon(theme));
+ button.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, true, false));
+ // button.setToolTipText(msg.lead());
+ if (msg != null) {
+ Label lbl = new Label(parent, SWT.CENTER);
+ CmsSwtUtils.style(lbl, SuiteStyle.leadPane);
+ String txt = LocaleUtils.lead(msg, l10nClassLoader);
+// String txt = msg.lead();
+ lbl.setText(txt);
+ lbl.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
+ }
+ CmsSwtUtils.sendEventOnSelect(button, SuiteEvent.switchLayer.topic(), SuiteEvent.LAYER, layer);
+ return button;
+ }
+
+// public static String createAndConfigureEntity(Shell shell, Session referenceSession, String mainMixin,
+// String... additionnalProps) {
+//
+// Session tmpSession = null;
+// Session mainSession = null;
+// try {
+// // FIXME would not work if home is another physical workspace
+// tmpSession = referenceSession.getRepository().login(NodeConstants.HOME_WORKSPACE);
+// Node draftNode = null;
+// for (int i = 0; i < additionnalProps.length - 1; i += 2) {
+// draftNode.setProperty(additionnalProps[i], additionnalProps[i + 1]);
+// }
+// Wizard wizard = null;
+// CmsWizardDialog dialog = new CmsWizardDialog(shell, wizard);
+// // WizardDialog dialog = new WizardDialog(shell, wizard);
+// if (dialog.open() == Window.OK) {
+// String parentPath = null;// "/" + appService.getBaseRelPath(mainMixin);
+// // FIXME it should be possible to specify the workspace
+// mainSession = referenceSession.getRepository().login();
+// Node parent = mainSession.getNode(parentPath);
+// Node task = null;// appService.publishEntity(parent, mainMixin, draftNode);
+//// task = appService.saveEntity(task, false);
+// referenceSession.refresh(true);
+// return task.getPath();
+// }
+// return null;
+// } catch (RepositoryException e1) {
+// throw new JcrException(
+// "Unable to create " + mainMixin + " entity with session " + referenceSession.toString(), e1);
+// } finally {
+// JcrUtils.logoutQuietly(tmpSession);
+// JcrUtils.logoutQuietly(mainSession);
+// }
+// }
+