X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=swt%2Forg.argeo.app.ui%2Fsrc%2Forg%2Fargeo%2Fapp%2Fui%2FSuiteUiUtils.java;h=5568201651cef091af430c1ed66be5559c574302;hb=618968cf9d259ccded45a9455a26c516dbfe828f;hp=2ba43145cbe245d1b29f524ddea4eccc2c238584;hpb=2362aefd312e04eea437824f37cb6e63389cd361;p=gpl%2Fargeo-suite.git diff --git a/swt/org.argeo.app.ui/src/org/argeo/app/ui/SuiteUiUtils.java b/swt/org.argeo.app.ui/src/org/argeo/app/ui/SuiteUiUtils.java index 2ba4314..5568201 100644 --- a/swt/org.argeo.app.ui/src/org/argeo/app/ui/SuiteUiUtils.java +++ b/swt/org.argeo.app.ui/src/org/argeo/app/ui/SuiteUiUtils.java @@ -5,7 +5,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.Objects; +import java.util.HashMap; +import java.util.Map; import javax.jcr.Node; import javax.jcr.RepositoryException; @@ -13,16 +14,15 @@ import javax.jcr.Session; import org.apache.commons.io.IOUtils; import org.argeo.api.acr.Content; -import org.argeo.api.cms.CmsEvent; import org.argeo.api.cms.ux.CmsEditable; -import org.argeo.api.cms.ux.CmsIcon; import org.argeo.api.cms.ux.CmsStyle; import org.argeo.app.api.EntityNames; import org.argeo.app.api.EntityType; -import org.argeo.cms.LocaleUtils; +import org.argeo.app.swt.ux.SwtArgeoApp; +import org.argeo.app.ux.SuiteStyle; +import org.argeo.app.ux.SuiteUxEvent; import org.argeo.cms.Localized; import org.argeo.cms.jcr.acr.JcrContent; -import org.argeo.cms.swt.CmsSwtTheme; import org.argeo.cms.swt.CmsSwtUtils; import org.argeo.cms.swt.dialogs.LightweightDialog; import org.argeo.cms.ui.util.CmsLink; @@ -71,6 +71,10 @@ public class SuiteUiUtils { } } + public static Label addFormLabel(Composite parent, Localized msg) { + return addFormLabel(parent, msg.lead()); + } + public static Label addFormLabel(Composite parent, String label) { Label lbl = new Label(parent, SWT.WRAP); lbl.setText(label); @@ -238,7 +242,8 @@ public class SuiteUiUtils { boolean test = false; if (test) { try (InputStream in = JcrUtils.getFileAsStream(fileNode); - OutputStream out = Files.newOutputStream(Paths.get("/home/mbaudier/tmp/" + fileNode.getName()));) { + OutputStream out = Files.newOutputStream( + Paths.get(System.getProperty("user.home") + "/tmp/" + fileNode.getName()));) { // BufferedImage img = ImageIO.read(in); // System.out.println(fileNode.getName() + ": width=" + img.getWidth() + ", height=" + img.getHeight()); IOUtils.copy(in, out); @@ -358,11 +363,11 @@ public class SuiteUiUtils { } public static String toLink(Content node) { - return node != null ? "#" + CmsSwtUtils.cleanPathForUrl(SuiteApp.nodeToState(node)) : null; + return node != null ? "#" + CmsSwtUtils.cleanPathForUrl(SwtArgeoApp.nodeToState(node)) : null; } public static String toLink(Node node) { - return node != null ? "#" + CmsSwtUtils.cleanPathForUrl(SuiteApp.nodeToState(JcrContent.nodeToContent(node))) + return node != null ? "#" + CmsSwtUtils.cleanPathForUrl(SwtArgeoApp.nodeToState(JcrContent.nodeToContent(node))) : null; } @@ -392,35 +397,12 @@ public class SuiteUiUtils { return lbl; } -// public static boolean isCoworker(CmsView cmsView) { -// boolean coworker = cmsView.doAs(() -> CurrentUser.isInRole(SuiteRole.coworker.dn())); -// return coworker; -// } - - public static boolean isTopic(String topic, CmsEvent cmsEvent) { - Objects.requireNonNull(topic); - return topic.equals(cmsEvent.topic()); - } - - public static Button createLayerButton(Composite parent, String layer, Localized msg, CmsIcon icon, - ClassLoader l10nClassLoader) { - CmsSwtTheme theme = CmsSwtUtils.getCmsTheme(parent); - Button button = new Button(parent, SWT.PUSH); - CmsSwtUtils.style(button, SuiteStyle.leadPane); - if (icon != null) - button.setImage(theme.getBigIcon(icon)); - 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, SuiteUxEvent.switchLayer.topic(), SuiteUxEvent.LAYER, layer); - return button; + @Deprecated + public static Map eventProperties(Node node) { + Map properties = new HashMap<>(); + String contentPath = '/' + Jcr.getWorkspaceName(node) + Jcr.getPath(node); + properties.put(SuiteUxEvent.CONTENT_PATH, contentPath); + return properties; } // public static String createAndConfigureEntity(Shell shell, Session referenceSession, String mainMixin,