- 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);
+ public static Control addExternalLink(Composite parent, String label, String url, String plainCssAnchorClass,
+ boolean newWindow) throws RepositoryException {
+ Label lbl = new Label(parent, SWT.NONE);
+ CmsSwtUtils.markup(lbl);
+ StringBuilder txt = new StringBuilder();
+ txt.append("<a class='" + plainCssAnchorClass + "'");
+ txt.append(" href='").append(url).append("'");
+ if (newWindow) {
+ txt.append(" target='blank_'");
+ }
+ txt.append(">");
+ txt.append(label);
+ txt.append("</a>");
+ lbl.setText(txt.toString());
+ return lbl;
+ }
+
+ 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));