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=3c47b96a6053a187abb123cbdc95af5bfc1c4305;hb=af8fd089f42ba4848edac72cc0de937e94f24420;hpb=f3eb8b1fe54100344c6455543b44043684235daa 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 3c47b96..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,11 +7,15 @@ 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; import org.argeo.entity.EntityNames; @@ -32,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 { @@ -318,6 +323,31 @@ public class SuiteUiUtils { 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); + 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); + CmsUiUtils.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)); + } + CmsUiUtils.sendEventOnSelect(button, SuiteEvent.switchLayer.topic(), SuiteEvent.LAYER, layer); + return button; + } + // public static String createAndConfigureEntity(Shell shell, Session referenceSession, String mainMixin, // String... additionnalProps) { //