X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=core%2Forg.argeo.suite.ui%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fui%2FSuiteUiUtils.java;h=0cfee182596230c9875f0d87b84a49dc0ea966d5;hp=8e9a9d5d641968693a6364f6cba86696ef0d256b;hb=af8fd089f42ba4848edac72cc0de937e94f24420;hpb=418ea1efbf3f0d6b706603c6ff1c0fdd17314773 diff --git a/core/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUiUtils.java b/core/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUiUtils.java index 8e9a9d5..0cfee18 100644 --- a/core/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUiUtils.java +++ b/core/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUiUtils.java @@ -7,10 +7,14 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.Session; +import org.argeo.cms.LocaleUtils; import org.argeo.cms.Localized; +import org.argeo.cms.auth.CurrentUser; import org.argeo.cms.ui.CmsEditable; import org.argeo.cms.ui.CmsTheme; +import org.argeo.cms.ui.CmsView; import org.argeo.cms.ui.dialogs.LightweightDialog; +import org.argeo.cms.ui.util.CmsEvent; import org.argeo.cms.ui.util.CmsIcon; import org.argeo.cms.ui.util.CmsUiUtils; import org.argeo.eclipse.ui.EclipseUiUtils; @@ -18,6 +22,7 @@ import org.argeo.entity.EntityNames; import org.argeo.entity.EntityType; import org.argeo.jcr.Jcr; import org.argeo.jcr.JcrUtils; +import org.argeo.suite.SuiteRole; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.MouseEvent; @@ -31,6 +36,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.osgi.service.event.Event; /** UI utilities related to the APAF project. */ public class SuiteUiUtils { @@ -312,7 +318,17 @@ public class SuiteUiUtils { return img; } - public static Button createLayerButton(Composite parent, String layer, Localized msg, CmsIcon icon) { + 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 = CmsTheme.getCmsTheme(parent); Button button = new Button(parent, SWT.PUSH); CmsUiUtils.style(button, SuiteStyle.leadPane); @@ -321,9 +337,11 @@ public class SuiteUiUtils { button.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, true, false)); // button.setToolTipText(msg.lead()); if (msg != null) { - Label lbl = new Label(parent, SWT.NONE); + Label lbl = new Label(parent, SWT.CENTER); CmsUiUtils.style(lbl, SuiteStyle.leadPane); - lbl.setText(msg.lead()); + String txt = LocaleUtils.lead(msg, l10nClassLoader); +// String txt = msg.lead(); + lbl.setText(txt); lbl.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false)); } CmsUiUtils.sendEventOnSelect(button, SuiteEvent.switchLayer.topic(), SuiteEvent.LAYER, layer);