Refactor UX
[gpl/argeo-suite.git] / swt / org.argeo.app.ui / src / org / argeo / app / ui / SuiteUiUtils.java
index 7cda3f89299a5e634a55bd5a4de453fb9ee78cbf..c98847a0dd8b143f93c89fa63778d1c715fb6fd5 100644 (file)
@@ -5,6 +5,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Objects;
 
 import javax.jcr.Node;
@@ -19,6 +21,8 @@ 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.app.ux.SuiteStyle;
+import org.argeo.app.ux.SuiteUxEvent;
 import org.argeo.cms.LocaleUtils;
 import org.argeo.cms.Localized;
 import org.argeo.cms.jcr.acr.JcrContent;
@@ -71,6 +75,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 +246,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);
@@ -419,10 +428,18 @@ public class SuiteUiUtils {
                        lbl.setText(txt);
                        lbl.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));
                }
-               CmsSwtUtils.sendEventOnSelect(button, SuiteEvent.switchLayer.topic(), SuiteEvent.LAYER, layer);
+               CmsSwtUtils.sendEventOnSelect(button, SuiteUxEvent.switchLayer.topic(), SuiteUxEvent.LAYER, layer);
                return button;
        }
 
+       @Deprecated
+       public static Map<String, Object> eventProperties(Node node) {
+               Map<String, Object> 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,
 //                     String... additionnalProps) {
 //