Refactor SWT layer
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 21 Jun 2023 08:41:37 +0000 (10:41 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 21 Jun 2023 08:41:37 +0000 (10:41 +0200)
12 files changed:
swt/org.argeo.app.swt/src/org/argeo/app/swt/forms/FormStyle.java [new file with mode: 0644]
swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/AbstractTermsPart.java [new file with mode: 0644]
swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/MultiTermsPart.java [new file with mode: 0644]
swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/SingleTermPart.java [new file with mode: 0644]
swt/org.argeo.app.swt/src/org/argeo/app/swt/ux/SuiteSwtUtils.java [new file with mode: 0644]
swt/org.argeo.app.ui/src/org/argeo/app/ui/SuiteUiUtils.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonPage.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonWizard.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/GroupUiProvider.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewOrgForm.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewUserForm.java
swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PersonUiProvider.java

diff --git a/swt/org.argeo.app.swt/src/org/argeo/app/swt/forms/FormStyle.java b/swt/org.argeo.app.swt/src/org/argeo/app/swt/forms/FormStyle.java
new file mode 100644 (file)
index 0000000..6bc3df8
--- /dev/null
@@ -0,0 +1,29 @@
+package org.argeo.app.swt.forms;
+
+import org.argeo.api.cms.ux.CmsStyle;
+
+/** Syles used */
+public enum FormStyle implements CmsStyle {
+       // Main
+       form, title,
+       // main part
+       header, headerBtn, headerCombo, section, sectionHeader,
+       // Property fields
+       propertyLabel, propertyText, propertyMessage, errorMessage,
+       // Date
+       popupCalendar,
+       // Buttons
+       starred, unstarred, starOverlay, editOverlay, deleteOverlay, updateOverlay, deleteOverlaySmall, calendar, delete,
+       // Contacts
+       email, address, phone, website,
+       // Social Media
+       facebook, twitter, linkedIn, instagram;
+
+       @Override
+       public String getClassPrefix() {
+               return "argeo-form";
+       }
+
+       // TODO clean button style management
+       public final static String BUTTON_SUFFIX = "_btn";
+}
diff --git a/swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/AbstractTermsPart.java b/swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/AbstractTermsPart.java
new file mode 100644 (file)
index 0000000..224b3b8
--- /dev/null
@@ -0,0 +1,162 @@
+package org.argeo.app.swt.terms;
+
+import org.argeo.api.acr.Content;
+import org.argeo.api.cms.ux.CmsIcon;
+import org.argeo.app.api.Term;
+import org.argeo.app.api.TermsManager;
+import org.argeo.app.api.Typology;
+import org.argeo.cms.Localized;
+import org.argeo.cms.swt.CmsSwtTheme;
+import org.argeo.cms.swt.CmsSwtUtils;
+import org.argeo.cms.swt.SwtEditablePart;
+import org.argeo.cms.swt.widgets.ContextOverlay;
+import org.argeo.cms.swt.widgets.StyledControl;
+import org.argeo.cms.ux.acr.ContentPart;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+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.eclipse.swt.widgets.ToolItem;
+
+/** Common logic between single and mutliple terms editable part. */
+public abstract class AbstractTermsPart extends StyledControl implements SwtEditablePart, ContentPart {
+       private static final long serialVersionUID = -5497097995341927710L;
+       protected final TermsManager termsManager;
+       protected final Typology typology;
+
+       private final boolean editable;
+
+       private CmsIcon deleteIcon;
+       private CmsIcon addIcon;
+       private CmsIcon cancelIcon;
+
+       private Color highlightColor;
+       private Composite highlight;
+
+       private boolean canDelete = true;
+
+       protected final CmsSwtTheme theme;
+
+       @SuppressWarnings("rawtypes")
+       private Class<? extends Enum> localized;
+
+       public AbstractTermsPart(Composite parent, int style, Content item, TermsManager termsManager, String typology) {
+               super(parent, style);
+               if (item == null)
+                       throw new IllegalArgumentException("Item cannot be null");
+               setData(item);
+               this.termsManager = termsManager;
+               this.typology = termsManager.getTypology(typology);
+               this.theme = CmsSwtUtils.getCmsTheme(parent);
+               editable = !(SWT.READ_ONLY == (style & SWT.READ_ONLY));
+               highlightColor = parent.getDisplay().getSystemColor(SWT.COLOR_GRAY);
+       }
+
+       public boolean isEditable() {
+               return editable;
+       }
+
+       protected void createHighlight(Composite block) {
+               highlight = new Composite(block, SWT.NONE);
+               highlight.setBackground(highlightColor);
+               GridData highlightGd = new GridData(SWT.FILL, SWT.FILL, false, false);
+               highlightGd.widthHint = 5;
+               highlightGd.heightHint = 3;
+               highlight.setLayoutData(highlightGd);
+
+       }
+
+       protected String getTermLabel(Term term) {
+               if (term instanceof Localized) {
+                       return ((Localized) term).lead();
+               } else {
+                       if (localized != null) {
+                               @SuppressWarnings("unchecked")
+                               String msg = ((Localized) Enum.valueOf(localized, term.getName())).lead();
+                               return msg;
+                       } else {
+                               return term.getName();
+                       }
+               }
+
+       }
+
+       protected abstract void refresh(ContextOverlay contextArea, String filter, Text txt);
+
+       protected boolean isTermSelectable(Term term) {
+               return true;
+       }
+
+       protected void processTermListLabel(Term term, Label label) {
+
+       }
+
+       protected void setControlLayoutData(Control control) {
+               control.setLayoutData(CmsSwtUtils.fillAll());
+       }
+
+       protected void setContainerLayoutData(Composite composite) {
+               composite.setLayoutData(CmsSwtUtils.fillAll());
+       }
+
+       //
+       // STYLING
+       //
+       public void setDeleteIcon(CmsIcon deleteIcon) {
+               this.deleteIcon = deleteIcon;
+       }
+
+       public void setAddIcon(CmsIcon addIcon) {
+               this.addIcon = addIcon;
+       }
+
+       public void setCancelIcon(CmsIcon cancelIcon) {
+               this.cancelIcon = cancelIcon;
+       }
+
+       protected TermsManager getTermsManager() {
+               return termsManager;
+       }
+
+       protected void styleDelete(ToolItem deleteItem) {
+               if (deleteIcon != null)
+                       deleteItem.setImage(theme.getSmallIcon(deleteIcon));
+               else
+                       deleteItem.setText("-");
+       }
+
+       protected void styleCancel(ToolItem cancelItem) {
+               if (cancelIcon != null)
+                       cancelItem.setImage(theme.getSmallIcon(cancelIcon));
+               else
+                       cancelItem.setText("X");
+       }
+
+       protected void styleAdd(ToolItem addItem) {
+               if (addIcon != null)
+                       addItem.setImage(theme.getSmallIcon(addIcon));
+               else
+                       addItem.setText("+");
+       }
+
+       @Override
+       public Content getContent() {
+               return (Content) getData();
+       }
+
+       public void setCanDelete(boolean canDelete) {
+               this.canDelete = canDelete;
+       }
+
+       public boolean isCanDelete() {
+               return canDelete;
+       }
+
+       public void setLocalized(Class<? extends Enum> localized) {
+               this.localized = localized;
+       }
+
+}
diff --git a/swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/MultiTermsPart.java b/swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/MultiTermsPart.java
new file mode 100644 (file)
index 0000000..16f2413
--- /dev/null
@@ -0,0 +1,207 @@
+package org.argeo.app.swt.terms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.argeo.api.acr.Content;
+import org.argeo.api.acr.NamespaceUtils;
+import org.argeo.api.cms.CmsLog;
+import org.argeo.app.api.Term;
+import org.argeo.app.api.TermsManager;
+import org.argeo.app.swt.forms.FormStyle;
+import org.argeo.cms.swt.CmsSwtUtils;
+import org.argeo.cms.swt.MouseDoubleClick;
+import org.argeo.cms.swt.MouseDown;
+import org.argeo.cms.swt.Selected;
+import org.argeo.cms.swt.SwtEditablePart;
+import org.argeo.cms.swt.widgets.ContextOverlay;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+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.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+/** {@link SwtEditablePart} for multiple terms. */
+public class MultiTermsPart extends AbstractTermsPart {
+       private static final long serialVersionUID = -4961135649177920808L;
+       private final static CmsLog log = CmsLog.getLog(MultiTermsPart.class);
+
+       public MultiTermsPart(Composite parent, int style, Content item, TermsManager termsManager, String typology) {
+               super(parent, style, item, termsManager, typology);
+       }
+
+       @Override
+       protected Control createControl(Composite box, String style) {
+               Composite placeholder = new Composite(box, SWT.NONE);
+
+               boolean vertical = SWT.VERTICAL == (getStyle() & SWT.VERTICAL);
+               RowLayout rl = new RowLayout(vertical ? SWT.VERTICAL : SWT.HORIZONTAL);
+               rl = CmsSwtUtils.noMarginsRowLayout(rl);
+//             rl.wrap = true;
+//             rl.justify = true;
+               placeholder.setLayout(rl);
+               List<Term> currentValue = getValue();
+               if (currentValue != null && !currentValue.isEmpty()) {
+                       for (Term value : currentValue) {
+                               Composite block = new Composite(placeholder, SWT.NONE);
+                               block.setLayout(CmsSwtUtils.noSpaceGridLayout(3));
+                               Label lbl = new Label(block, SWT.NONE);
+                               String display = getTermLabel(value);
+                               lbl.setText(display);
+                               CmsSwtUtils.style(lbl, style == null ? FormStyle.propertyText.style() : style);
+                               processTermListLabel(value, lbl);
+                               if (isEditable())
+                                       lbl.addMouseListener((MouseDoubleClick) (e) -> {
+                                               startEditing();
+                                       });
+                               if (isEditing()) {
+                                       ToolBar toolBar = new ToolBar(block, SWT.HORIZONTAL);
+                                       ToolItem deleteItem = new ToolItem(toolBar, SWT.FLAT);
+                                       styleDelete(deleteItem);
+                                       deleteItem.addSelectionListener((Selected) (e) -> {
+                                               // we retrieve them again here because they may have changed
+                                               List<Term> curr = getValue();
+                                               List<Term> newValue = new ArrayList<>();
+                                               for (Term v : curr) {
+                                                       if (!v.equals(value))
+                                                               newValue.add(v);
+                                               }
+                                               setValue(newValue);
+                                               block.dispose();
+                                               layout(true, true);
+                                       });
+
+                               }
+                       }
+               } else {// empty
+                       if (isEditable() && !isEditing()) {
+                               ToolBar toolBar = new ToolBar(placeholder, SWT.HORIZONTAL);
+                               ToolItem addItem = new ToolItem(toolBar, SWT.FLAT);
+                               styleAdd(addItem);
+                               addItem.addSelectionListener((Selected) (e) -> {
+                                       startEditing();
+                               });
+                       }
+               }
+
+               if (isEditing()) {
+                       Composite block = new Composite(placeholder, SWT.NONE);
+                       block.setLayout(CmsSwtUtils.noSpaceGridLayout(3));
+
+                       createHighlight(block);
+
+                       Text txt = new Text(block, SWT.SINGLE | SWT.BORDER);
+                       txt.setLayoutData(CmsSwtUtils.fillWidth());
+//                     txt.setMessage("[new]");
+
+                       CmsSwtUtils.style(txt, style == null ? FormStyle.propertyText.style() : style);
+
+                       ToolBar toolBar = new ToolBar(block, SWT.HORIZONTAL);
+                       ToolItem cancelItem = new ToolItem(toolBar, SWT.FLAT);
+                       styleCancel(cancelItem);
+                       cancelItem.addSelectionListener((Selected) (e) -> {
+                               stopEditing();
+                       });
+
+                       ContextOverlay contextOverlay = new ContextOverlay(txt, SWT.NONE) {
+                               private static final long serialVersionUID = -7980078594405384874L;
+
+                               @Override
+                               protected void onHide() {
+                                       stopEditing();
+                               }
+                       };
+                       contextOverlay.setLayout(new GridLayout());
+                       // filter
+                       txt.addModifyListener((e) -> {
+                               String filter = txt.getText().toLowerCase();
+                               if ("".equals(filter.trim()))
+                                       filter = null;
+                               refresh(contextOverlay, filter, txt);
+                       });
+                       txt.addFocusListener(new FocusListener() {
+                               private static final long serialVersionUID = -6024501573409619949L;
+
+                               @Override
+                               public void focusLost(FocusEvent event) {
+//                                     if (!contextOverlay.isDisposed() && contextOverlay.isShellVisible())
+//                                             getDisplay().asyncExec(() -> stopEditing());
+                               }
+
+                               @Override
+                               public void focusGained(FocusEvent event) {
+                                       // txt.setText("");
+                                       if (!contextOverlay.isDisposed() && !contextOverlay.isShellVisible())
+                                               refresh(contextOverlay, null, txt);
+                               }
+                       });
+                       layout(new Control[] { txt });
+                       // getDisplay().asyncExec(() -> txt.setFocus());
+               }
+               return placeholder;
+       }
+
+       @Override
+       protected void refresh(ContextOverlay contextArea, String filter, Text txt) {
+               CmsSwtUtils.clear(contextArea);
+               List<? extends Term> terms = termsManager.listAllTerms(typology.getId());
+               List<Term> currentValue = getValue();
+               terms: for (Term term : terms) {
+                       if (currentValue != null && currentValue.contains(term))
+                               continue terms;
+                       String display = getTermLabel(term);
+                       if (filter != null && !display.toLowerCase().contains(filter))
+                               continue terms;
+                       Label termL = new Label(contextArea, SWT.WRAP);
+                       termL.setText(display);
+                       processTermListLabel(term, termL);
+                       if (isTermSelectable(term))
+                               termL.addMouseListener((MouseDown) (e) -> {
+                                       List<Term> newValue = new ArrayList<>();
+                                       List<Term> curr = getValue();
+                                       if (currentValue != null)
+                                               newValue.addAll(curr);
+                                       newValue.add(term);
+                                       setValue(newValue);
+                                       contextArea.hide();
+                                       stopEditing();
+                               });
+               }
+               contextArea.show();
+       }
+
+       protected List<Term> getValue() {
+               String property = typology.getId();
+               List<String> curr = getContent().getMultiple(NamespaceUtils.unqualified(property));
+//             List<String> curr = Jcr.getMultiple(getNode(), property);
+               List<Term> res = new ArrayList<>();
+               if (curr != null)
+                       terms: for (String str : curr) {
+                               Term term = termsManager.getTerm(str);
+                               if (term == null) {
+                                       log.warn("Ignoring term " + str + " for " + getContent() + ", as it was not found.");
+                                       continue terms;
+                               }
+                               res.add(term);
+                       }
+               return res;
+       }
+
+       protected void setValue(List<Term> value) {
+               String property = typology.getId();
+               List<String> ids = new ArrayList<>();
+               for (Term term : value) {
+                       ids.add(term.getId());
+               }
+               getContent().put(property, ids);
+//             Jcr.set(getNode(), property, ids);
+//             Jcr.save(getNode());
+       }
+
+}
diff --git a/swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/SingleTermPart.java b/swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/SingleTermPart.java
new file mode 100644 (file)
index 0000000..c918c25
--- /dev/null
@@ -0,0 +1,163 @@
+package org.argeo.app.swt.terms;
+
+import java.util.List;
+
+import org.argeo.api.acr.Content;
+import org.argeo.app.api.Term;
+import org.argeo.app.api.TermsManager;
+import org.argeo.app.swt.forms.FormStyle;
+import org.argeo.cms.swt.CmsSwtUtils;
+import org.argeo.cms.swt.MouseDoubleClick;
+import org.argeo.cms.swt.MouseDown;
+import org.argeo.cms.swt.Selected;
+import org.argeo.cms.swt.SwtEditablePart;
+import org.argeo.cms.swt.widgets.ContextOverlay;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.layout.GridLayout;
+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.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+/** {@link SwtEditablePart} for terms. */
+public class SingleTermPart extends AbstractTermsPart {
+       private static final long serialVersionUID = -4961135649177920808L;
+
+       public SingleTermPart(Composite parent, int style, Content item, TermsManager termsManager, String typology) {
+               super(parent, style, item, termsManager, typology);
+       }
+
+       @Override
+       protected Control createControl(Composite box, String style) {
+               if (isEditing()) {
+                       Composite block = new Composite(box, SWT.NONE);
+                       block.setLayout(CmsSwtUtils.noSpaceGridLayout(3));
+
+                       createHighlight(block);
+
+                       Text txt = new Text(block, SWT.SINGLE | SWT.BORDER);
+                       CmsSwtUtils.style(txt, style == null ? FormStyle.propertyText.style() : style);
+
+                       ToolBar toolBar = new ToolBar(block, SWT.HORIZONTAL);
+                       if (isCanDelete()) {
+                               ToolItem deleteItem = new ToolItem(toolBar, SWT.PUSH);
+                               styleDelete(deleteItem);
+                               deleteItem.addSelectionListener((Selected) (e) -> {
+                                       setValue(null);
+                                       stopEditing();
+                               });
+                       }
+                       ToolItem cancelItem = new ToolItem(toolBar, SWT.PUSH);
+                       styleCancel(cancelItem);
+                       cancelItem.addSelectionListener((Selected) (e) -> {
+                               stopEditing();
+                       });
+
+                       ContextOverlay contextOverlay = new ContextOverlay(txt, SWT.NONE) {
+                               private static final long serialVersionUID = -7980078594405384874L;
+
+                               @Override
+                               protected void onHide() {
+                                       stopEditing();
+                               }
+                       };
+                       contextOverlay.setLayout(new GridLayout());
+                       // filter
+                       txt.addModifyListener((e) -> {
+                               String filter = txt.getText().toLowerCase();
+                               if ("".equals(filter.trim()))
+                                       filter = null;
+                               refresh(contextOverlay, filter, txt);
+                       });
+                       txt.addFocusListener(new FocusListener() {
+                               private static final long serialVersionUID = -6024501573409619949L;
+
+                               @Override
+                               public void focusLost(FocusEvent event) {
+//                                     if (!contextOverlay.isDisposed() && contextOverlay.isShellVisible())
+//                                             getDisplay().asyncExec(() -> stopEditing());
+                               }
+
+                               @Override
+                               public void focusGained(FocusEvent event) {
+                                       // txt.setText("");
+                                       if (!contextOverlay.isDisposed() && !contextOverlay.isShellVisible())
+                                               refresh(contextOverlay, null, txt);
+                               }
+                       });
+                       layout(new Control[] { block });
+                       getDisplay().asyncExec(() -> txt.setFocus());
+                       return block;
+               } else {
+                       Composite block = new Composite(box, SWT.NONE);
+                       block.setLayout(CmsSwtUtils.noSpaceGridLayout(2));
+                       Term currentValue = getValue();
+                       if (currentValue != null) {
+                               Label lbl = new Label(block, SWT.SINGLE);
+                               String display = getTermLabel(currentValue);
+                               lbl.setText(display);
+                               CmsSwtUtils.style(lbl, style == null ? FormStyle.propertyText.style() : style);
+                               processTermListLabel(currentValue, lbl);
+                               if (isEditable()) {
+                                       lbl.addMouseListener((MouseDoubleClick) (e) -> {
+                                               startEditing();
+                                       });
+                               }
+                       } else {
+                               if (isEditable()) {
+                                       ToolBar toolBar = new ToolBar(block, SWT.HORIZONTAL);
+                                       ToolItem addItem = new ToolItem(toolBar, SWT.FLAT);
+                                       styleAdd(addItem);
+                                       addItem.addSelectionListener((Selected) (e) -> {
+                                               startEditing();
+                                       });
+                               }
+                       }
+                       return block;
+               }
+       }
+
+       @Override
+       protected void refresh(ContextOverlay contextArea, String filter, Text txt) {
+               CmsSwtUtils.clear(contextArea);
+               List<? extends Term> terms = termsManager.listAllTerms(typology.getId());
+               terms: for (Term term : terms) {
+                       String display = getTermLabel(term);
+                       if (filter != null && !display.toLowerCase().contains(filter))
+                               continue terms;
+                       Label termL = new Label(contextArea, SWT.WRAP);
+                       termL.setText(display);
+                       processTermListLabel(term, termL);
+                       if (isTermSelectable(term))
+                               termL.addMouseListener((MouseDown) (e) -> {
+                                       setValue(term);
+                                       contextArea.hide();
+                                       stopEditing();
+                               });
+               }
+               contextArea.show();
+               // txt.setFocus();
+       }
+
+       protected Term getValue() {
+               String property = typology.getId();
+               String id = getContent().attr(property);
+               Term term = termsManager.getTerm(id);
+
+               return term;
+       }
+
+       protected void setValue(Term value) {
+               String property = typology.getId();
+               if (value == null)
+                       getContent().remove(property);
+               else
+                       getContent().put(property, value.getId());
+//             Jcr.set(getNode(), property, value != null ? value.getId() : null);
+//             Jcr.save(getNode());
+       }
+}
diff --git a/swt/org.argeo.app.swt/src/org/argeo/app/swt/ux/SuiteSwtUtils.java b/swt/org.argeo.app.swt/src/org/argeo/app/swt/ux/SuiteSwtUtils.java
new file mode 100644 (file)
index 0000000..856319a
--- /dev/null
@@ -0,0 +1,170 @@
+package org.argeo.app.swt.ux;
+
+import org.argeo.api.acr.Content;
+import org.argeo.app.ux.SuiteStyle;
+import org.argeo.cms.Localized;
+import org.argeo.cms.swt.CmsSwtUtils;
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/** Static utilities implementing the look and feel of Argeo Suite with SWT. */
+public class SuiteSwtUtils {
+       /** creates a title bar composite with label and optional button */
+       public static void addTitleBar(Composite parent, String title, Boolean isEditable) {
+               Composite titleBar = new Composite(parent, SWT.NONE);
+               titleBar.setLayoutData(CmsSwtUtils.fillWidth());
+               CmsSwtUtils.style(titleBar, SuiteStyle.titleContainer);
+
+               titleBar.setLayout(CmsSwtUtils.noSpaceGridLayout(new GridLayout(2, false)));
+               Label titleLbl = new Label(titleBar, SWT.NONE);
+               titleLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
+               CmsSwtUtils.style(titleLbl, SuiteStyle.titleLabel);
+               titleLbl.setText(title);
+
+               if (isEditable) {
+                       Button editBtn = new Button(titleBar, SWT.PUSH);
+                       editBtn.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
+                       CmsSwtUtils.style(editBtn, SuiteStyle.inlineButton);
+                       editBtn.setText("Edit");
+               }
+       }
+
+       public static Label addFormLabel(Composite parent, String label) {
+               Label lbl = new Label(parent, SWT.WRAP);
+               lbl.setText(label);
+               // lbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, true, true));
+               CmsSwtUtils.style(lbl, SuiteStyle.simpleLabel);
+               return lbl;
+       }
+
+       public static Label addFormLabel(Composite parent, Localized msg) {
+               return addFormLabel(parent, msg.lead());
+       }
+
+       public static Text addFormTextField(Composite parent, String text, String message, int style) {
+               Text txt = new Text(parent, style);
+               if (text != null)
+                       txt.setText(text);
+               if (message != null)
+                       txt.setMessage(message);
+               txt.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, true, true));
+               CmsSwtUtils.style(txt, SuiteStyle.simpleText);
+               return txt;
+       }
+
+       public static Text addFormTextField(Composite parent, String text, String message) {
+               return addFormTextField(parent, text, message, SWT.NONE);
+       }
+
+       public static Text addFormInputField(Composite parent, String placeholder) {
+               Text txt = new Text(parent, SWT.BORDER);
+
+               GridData gridData = CmsSwtUtils.fillWidth();
+               txt.setLayoutData(gridData);
+
+               if (placeholder != null)
+                       txt.setText(placeholder);
+
+               CmsSwtUtils.style(txt, SuiteStyle.simpleInput);
+               return txt;
+       }
+
+       public static Composite addLineComposite(Composite parent, int columns) {
+               Composite lineComposite = new Composite(parent, SWT.NONE);
+               lineComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               lineComposite.setLayout(new GridLayout(columns, false));
+               CmsSwtUtils.style(lineComposite, SuiteStyle.formLine);
+               return lineComposite;
+       }
+
+       /** creates a single horizontal-block composite for key:value display */
+       public static Text addFormLine(Composite parent, String label, String text) {
+               Composite lineComposite = addLineComposite(parent, 2);
+               CmsSwtUtils.style(lineComposite, SuiteStyle.formLine);
+               addFormLabel(lineComposite, label);
+               Text txt = addFormTextField(lineComposite, text, null);
+               txt.setEditable(false);
+               txt.setLayoutData(CmsSwtUtils.fillWidth());
+               return txt;
+       }
+
+       public static Text addFormInput(Composite parent, String label, String placeholder) {
+               Composite lineComposite = addLineComposite(parent, 2);
+               addFormLabel(lineComposite, label);
+               Text txt = addFormInputField(lineComposite, placeholder);
+               txt.setLayoutData(CmsSwtUtils.fillWidth());
+               return txt;
+       }
+
+       /**
+        * creates a single horizontal-block composite for key:value display, with
+        * offset value
+        */
+       public static Text addFormLine(Composite parent, String label, String text, Integer offset) {
+               Composite lineComposite = addLineComposite(parent, 3);
+               Label offsetLbl = new Label(lineComposite, SWT.NONE);
+               GridData gridData = new GridData();
+               gridData.widthHint = offset;
+               offsetLbl.setLayoutData(gridData);
+               addFormLabel(lineComposite, label);
+               Text txt = addFormTextField(lineComposite, text, null);
+               txt.setLayoutData(CmsSwtUtils.fillWidth());
+               return txt;
+       }
+
+       /** creates a single vertical-block composite for key:value display */
+       public static Text addFormColumn(Composite parent, String label, String text) {
+               // Composite columnComposite = new Composite(parent, SWT.NONE);
+               // columnComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
+               // false));
+               // columnComposite.setLayout(new GridLayout(1, false));
+               addFormLabel(parent, label);
+               Text txt = addFormTextField(parent, text, null);
+               txt.setEditable(false);
+               txt.setLayoutData(CmsSwtUtils.fillWidth());
+               return txt;
+       }
+
+       public static Label createBoldLabel(Composite parent, Localized localized) {
+               Label label = new Label(parent, SWT.LEAD);
+               label.setText(localized.lead());
+               label.setFont(EclipseUiUtils.getBoldFont(parent));
+               label.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
+               return label;
+       }
+
+       public static String toLink(Content node) {
+               return node != null ? "#" + CmsSwtUtils.cleanPathForUrl(SwtArgeoApp.nodeToState(node)) : null;
+       }
+
+       public static Control addExternalLink(Composite parent, String label, String url, String plainCssAnchorClass,
+                       boolean newWindow) {
+               Label lbl = new Label(parent, SWT.NONE);
+               CmsSwtUtils.markup(lbl);
+               StringBuilder txt = new StringBuilder();
+               txt.append("<a");
+               if (plainCssAnchorClass != null)
+                       txt.append(" 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;
+       }
+
+       /** singleton */
+       private SuiteSwtUtils() {
+       }
+
+}
index 5568201651cef091af430c1ed66be5559c574302..dce6d13822ef5dd0309b20f214f9c22a2679dd03 100644 (file)
@@ -13,21 +13,18 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.apache.commons.io.IOUtils;
-import org.argeo.api.acr.Content;
 import org.argeo.api.cms.ux.CmsEditable;
 import org.argeo.api.cms.ux.CmsStyle;
 import org.argeo.app.api.EntityNames;
 import org.argeo.app.api.EntityType;
+import org.argeo.app.swt.ux.SuiteSwtUtils;
 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.CmsSwtUtils;
 import org.argeo.cms.swt.dialogs.LightweightDialog;
 import org.argeo.cms.ui.util.CmsLink;
 import org.argeo.cms.ui.util.CmsUiUtils;
-import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.argeo.jcr.Jcr;
 import org.argeo.jcr.JcrUtils;
 import org.eclipse.swt.SWT;
@@ -38,102 +35,20 @@ import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
-/** UI utilities related to the APAF project. */
+/** UI utilities around SWT and JCR. */
 public class SuiteUiUtils {
-
-       /** Singleton. */
-       private SuiteUiUtils() {
-       }
-
-       /** creates a title bar composite with label and optional button */
-       public static void addTitleBar(Composite parent, String title, Boolean isEditable) {
-               Composite titleBar = new Composite(parent, SWT.NONE);
-               titleBar.setLayoutData(CmsSwtUtils.fillWidth());
-               CmsSwtUtils.style(titleBar, SuiteStyle.titleContainer);
-
-               titleBar.setLayout(CmsSwtUtils.noSpaceGridLayout(new GridLayout(2, false)));
-               Label titleLbl = new Label(titleBar, SWT.NONE);
-               titleLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
-               CmsSwtUtils.style(titleLbl, SuiteStyle.titleLabel);
-               titleLbl.setText(title);
-
-               if (isEditable) {
-                       Button editBtn = new Button(titleBar, SWT.PUSH);
-                       editBtn.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
-                       CmsSwtUtils.style(editBtn, SuiteStyle.inlineButton);
-                       editBtn.setText("Edit");
-               }
-       }
-
-       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);
-               // lbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, true, true));
-               CmsSwtUtils.style(lbl, SuiteStyle.simpleLabel);
-               return lbl;
-       }
-
-       public static Text addFormTextField(Composite parent, String text, String message) {
-               return addFormTextField(parent, text, message, SWT.NONE);
-       }
-
-       public static Text addFormTextField(Composite parent, String text, String message, int style) {
-               Text txt = new Text(parent, style);
-               if (text != null)
-                       txt.setText(text);
-               if (message != null)
-                       txt.setMessage(message);
-               txt.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, true, true));
-               CmsSwtUtils.style(txt, SuiteStyle.simpleText);
-               return txt;
-       }
-
-       public static Text addFormInputField(Composite parent, String placeholder) {
-               Text txt = new Text(parent, SWT.BORDER);
-
-               GridData gridData = CmsSwtUtils.fillWidth();
-               txt.setLayoutData(gridData);
-
-               if (placeholder != null)
-                       txt.setText(placeholder);
-
-               CmsSwtUtils.style(txt, SuiteStyle.simpleInput);
-               return txt;
-       }
-
-       /** creates a single horizontal-block composite for key:value display */
-       public static Text addFormLine(Composite parent, String label, String text) {
-               Composite lineComposite = new Composite(parent, SWT.NONE);
-               lineComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-               lineComposite.setLayout(new GridLayout(2, false));
-               CmsSwtUtils.style(lineComposite, SuiteStyle.formLine);
-               addFormLabel(lineComposite, label);
-               Text txt = addFormTextField(lineComposite, text, null);
-               txt.setEditable(false);
-               txt.setLayoutData(CmsSwtUtils.fillWidth());
-               return txt;
-       }
-
        public static Text addFormLine(Composite parent, String label, Node node, String property,
                        CmsEditable cmsEditable) {
-               Composite lineComposite = new Composite(parent, SWT.NONE);
-               lineComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-               lineComposite.setLayout(new GridLayout(2, false));
-               CmsSwtUtils.style(lineComposite, SuiteStyle.formLine);
-               addFormLabel(lineComposite, label);
+               Composite lineComposite = SuiteSwtUtils.addLineComposite(parent, 2);
+               SuiteSwtUtils.addFormLabel(lineComposite, label);
                String text = Jcr.get(node, property);
 //             int style = cmsEditable.isEditing() ? SWT.WRAP : SWT.WRAP;
-               Text txt = addFormTextField(lineComposite, text, null, SWT.WRAP);
+               Text txt = SuiteSwtUtils.addFormTextField(lineComposite, text, null, SWT.WRAP);
                if (cmsEditable != null && cmsEditable.isEditing()) {
                        txt.addModifyListener((e) -> {
                                Jcr.set(node, property, txt.getText());
@@ -146,57 +61,15 @@ public class SuiteUiUtils {
                return txt;
        }
 
-       public static Text addFormInput(Composite parent, String label, String placeholder) {
-               Composite lineComposite = new Composite(parent, SWT.NONE);
-               lineComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-               lineComposite.setLayout(new GridLayout(2, false));
-               CmsSwtUtils.style(lineComposite, SuiteStyle.formLine);
-               addFormLabel(lineComposite, label);
-               Text txt = addFormInputField(lineComposite, placeholder);
-               txt.setLayoutData(CmsSwtUtils.fillWidth());
-               return txt;
-       }
-
-       /**
-        * creates a single horizontal-block composite for key:value display, with
-        * offset value
-        */
-       public static Text addFormLine(Composite parent, String label, String text, Integer offset) {
-               Composite lineComposite = new Composite(parent, SWT.NONE);
-               lineComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-               lineComposite.setLayout(new GridLayout(3, false));
-               CmsSwtUtils.style(lineComposite, SuiteStyle.formLine);
-               Label offsetLbl = new Label(lineComposite, SWT.NONE);
-               GridData gridData = new GridData();
-               gridData.widthHint = offset;
-               offsetLbl.setLayoutData(gridData);
-               addFormLabel(lineComposite, label);
-               Text txt = addFormTextField(lineComposite, text, null);
-               txt.setLayoutData(CmsSwtUtils.fillWidth());
-               return txt;
-       }
-
-       /** creates a single vertical-block composite for key:value display */
-       public static Text addFormColumn(Composite parent, String label, String text) {
-//             Composite columnComposite = new Composite(parent, SWT.NONE);
-//             columnComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-//             columnComposite.setLayout(new GridLayout(1, false));
-               addFormLabel(parent, label);
-               Text txt = addFormTextField(parent, text, null);
-               txt.setEditable(false);
-               txt.setLayoutData(CmsSwtUtils.fillWidth());
-               return txt;
-       }
-
        public static Text addFormColumn(Composite parent, String label, Node node, String property,
                        CmsEditable cmsEditable) {
 //             Composite columnComposite = new Composite(parent, SWT.NONE);
 //             columnComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 //             columnComposite.setLayout(new GridLayout(1, false));
-               addFormLabel(parent, label);
+               SuiteSwtUtils.addFormLabel(parent, label);
                String text = Jcr.get(node, property);
 //             int style = cmsEditable.isEditing() ? SWT.WRAP : SWT.WRAP;
-               Text txt = addFormTextField(parent, text, null, SWT.WRAP);
+               Text txt = SuiteSwtUtils.addFormTextField(parent, text, null, SWT.WRAP);
                if (cmsEditable != null && cmsEditable.isEditing()) {
                        txt.addModifyListener((e) -> {
                                Jcr.set(node, property, txt.getText());
@@ -209,20 +82,9 @@ public class SuiteUiUtils {
                return txt;
        }
 
-       public static Label createBoldLabel(Composite parent, Localized localized) {
-               Label label = new Label(parent, SWT.LEAD);
-               label.setText(localized.lead());
-               label.setFont(EclipseUiUtils.getBoldFont(parent));
-               label.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
-               return label;
-       }
-
        public static Label addFormPicture(Composite parent, String label, Node fileNode) throws RepositoryException {
-               Composite lineComposite = new Composite(parent, SWT.NONE);
-               lineComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-               lineComposite.setLayout(new GridLayout(2, true));
-               CmsSwtUtils.style(lineComposite, SuiteStyle.formLine);
-               addFormLabel(lineComposite, label);
+               Composite lineComposite = SuiteSwtUtils.addLineComposite(parent, 2);
+               SuiteSwtUtils.addFormLabel(lineComposite, label);
 
                return addPicture(lineComposite, fileNode);
        }
@@ -362,10 +224,6 @@ public class SuiteUiUtils {
                return img;
        }
 
-       public static String toLink(Content node) {
-               return node != null ? "#" + CmsSwtUtils.cleanPathForUrl(SwtArgeoApp.nodeToState(node)) : null;
-       }
-
        public static String toLink(Node node) {
                return node != null ? "#" + CmsSwtUtils.cleanPathForUrl(SwtArgeoApp.nodeToState(JcrContent.nodeToContent(node)))
                                : null;
@@ -378,25 +236,6 @@ public class SuiteUiUtils {
                return link.createUi(parent, node);
        }
 
-       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");
-               if (plainCssAnchorClass != null)
-                       txt.append(" 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;
-       }
-
        @Deprecated
        public static Map<String, Object> eventProperties(Node node) {
                Map<String, Object> properties = new HashMap<>();
@@ -405,39 +244,8 @@ public class SuiteUiUtils {
                return properties;
        }
 
-//     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);
-//             }
-//     }
+       /** Singleton. */
+       private SuiteUiUtils() {
+       }
 
 }
index 54c94f8abf538be0c5586944ee4c4c153b621021..51ab5ba3403eac8c87f9aa9ae0139b1e82f1adbe 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.app.ui.dialogs;
 
-import org.argeo.app.ui.SuiteUiUtils;
+import org.argeo.app.swt.ux.SuiteSwtUtils;
 import org.argeo.app.ux.SuiteMsg;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
@@ -27,16 +27,16 @@ public class NewPersonPage extends WizardPage {
                parent.setLayout(new GridLayout(2, false));
 
                // FirstName
-               SuiteUiUtils.createBoldLabel(parent, SuiteMsg.firstName);
+               SuiteSwtUtils.createBoldLabel(parent, SuiteMsg.firstName);
                firstNameTxt = new Text(parent, SWT.BORDER);
                firstNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
                // LastName
-               SuiteUiUtils.createBoldLabel(parent, SuiteMsg.lastName);
+               SuiteSwtUtils.createBoldLabel(parent, SuiteMsg.lastName);
                lastNameTxt = new Text(parent, SWT.BORDER);
                lastNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
-               SuiteUiUtils.createBoldLabel(parent, SuiteMsg.email);
+               SuiteSwtUtils.createBoldLabel(parent, SuiteMsg.email);
                emailTxt = new Text(parent, SWT.BORDER);
                emailTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
index 2206c55cc5a5c6b47d0e79799b12bd05c3215a7f..841c294f21d26cc3100979b796edb3bcc1528706 100644 (file)
@@ -4,7 +4,7 @@ import static org.argeo.eclipse.ui.EclipseUiUtils.isEmpty;
 
 import javax.jcr.Node;
 
-import org.argeo.app.ui.SuiteUiUtils;
+import org.argeo.app.swt.ux.SuiteSwtUtils;
 import org.argeo.app.ux.SuiteMsg;
 import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -97,13 +97,13 @@ public class NewPersonWizard extends Wizard {
                        parent.setLayout(new GridLayout(2, false));
 
                        // FirstName
-                       SuiteUiUtils.createBoldLabel(parent, SuiteMsg.firstName);
+                       SuiteSwtUtils.createBoldLabel(parent, SuiteMsg.firstName);
                        firstNameTxt = new Text(parent, SWT.BORDER);
                        // firstNameTxt.setMessage("a first name");
                        firstNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
                        // LastName
-                       SuiteUiUtils.createBoldLabel(parent, SuiteMsg.lastName);
+                       SuiteSwtUtils.createBoldLabel(parent, SuiteMsg.lastName);
                        lastNameTxt = new Text(parent, SWT.BORDER);
                        // lastNameTxt.setMessage("a last name");
                        lastNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
index 512901867ef1cfc5bc5ec4dc49891dc115c8b155..0731e0ef97f11b56509b1c690eaa133a8a2c76b5 100644 (file)
@@ -10,7 +10,7 @@ import org.argeo.api.cms.directory.CmsGroup;
 import org.argeo.api.cms.directory.CmsUser;
 import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.api.cms.directory.HierarchyUnit;
-import org.argeo.app.ui.SuiteUiUtils;
+import org.argeo.app.swt.ux.SuiteSwtUtils;
 import org.argeo.app.ux.SuiteIcon;
 import org.argeo.app.ux.SuiteMsg;
 import org.argeo.cms.CurrentUser;
@@ -75,7 +75,7 @@ public class GroupUiProvider implements SwtUiProvider {
                String title = (context.hasContentClass(LdapObj.organization) ? SuiteMsg.org.lead() : SuiteMsg.group.lead())
                                + " " + LdapAcrUtils.getLocalized(context, LdapAttr.cn.qName(), CurrentUser.locale()) + " ("
                                + hierarchyUnit.getHierarchyUnitLabel(CurrentUser.locale()) + ")";
-               SuiteUiUtils.addFormLabel(area, title);
+               SuiteSwtUtils.addFormLabel(area, title);
 
                // toolbar
                ToolBar toolBar = new ToolBar(area, SWT.NONE);
index b651efa90efc4d6dbe8e1edbd361cfc4293ea6a6..2b7dc60cdfdc634653adba8ed26a752106dc3012 100644 (file)
@@ -13,7 +13,7 @@ import org.argeo.api.acr.ldap.LdapObj;
 import org.argeo.api.cms.directory.CmsGroup;
 import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.api.cms.directory.HierarchyUnit;
-import org.argeo.app.ui.SuiteUiUtils;
+import org.argeo.app.swt.ux.SuiteSwtUtils;
 import org.argeo.app.ux.SuiteMsg;
 import org.argeo.cms.swt.dialogs.CmsFeedback;
 import org.argeo.cms.swt.widgets.SwtGuidedFormPage;
@@ -97,7 +97,7 @@ public class NewOrgForm extends AbstractGuidedForm {
                        parent.setLayout(new GridLayout(2, false));
 
                        // FirstName
-                       SuiteUiUtils.createBoldLabel(parent, SuiteMsg.org);
+                       SuiteSwtUtils.createBoldLabel(parent, SuiteMsg.org);
                        orgNameT = new Text(parent, SWT.BORDER);
                        // firstNameTxt.setMessage("a first name");
                        orgNameT.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
index d70c82a232662e03cc17cded315963c3030d49af..bdaa2e8b2cffac6895fe11703b7f0344e94024c8 100644 (file)
@@ -15,7 +15,7 @@ import org.argeo.api.cms.directory.CmsUser;
 import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.api.cms.directory.HierarchyUnit;
 import org.argeo.app.core.SuiteUtils;
-import org.argeo.app.ui.SuiteUiUtils;
+import org.argeo.app.swt.ux.SuiteSwtUtils;
 import org.argeo.app.ux.SuiteMsg;
 import org.argeo.cms.swt.dialogs.CmsFeedback;
 import org.argeo.cms.swt.widgets.SwtGuidedFormPage;
@@ -127,18 +127,18 @@ public class NewUserForm extends AbstractGuidedForm {
                        parent.setLayout(new GridLayout(2, false));
 
                        // FirstName
-                       SuiteUiUtils.createBoldLabel(parent, SuiteMsg.firstName);
+                       SuiteSwtUtils.createBoldLabel(parent, SuiteMsg.firstName);
                        firstNameT = new Text(parent, SWT.BORDER);
                        // firstNameTxt.setMessage("a first name");
                        firstNameT.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
                        // LastName
-                       SuiteUiUtils.createBoldLabel(parent, SuiteMsg.lastName);
+                       SuiteSwtUtils.createBoldLabel(parent, SuiteMsg.lastName);
                        lastNameT = new Text(parent, SWT.BORDER);
                        // lastNameTxt.setMessage("a last name");
                        lastNameT.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
-                       SuiteUiUtils.createBoldLabel(parent, SuiteMsg.email);
+                       SuiteSwtUtils.createBoldLabel(parent, SuiteMsg.email);
                        emailT = new Text(parent, SWT.BORDER);
                        emailT.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
index a658898ffa17ac0a5da151816130fb1c2ca9ba17..2cfb7b72d17bb502b55c9854bca3bf382d3b0571 100644 (file)
@@ -14,7 +14,7 @@ import org.argeo.api.cms.directory.CmsUserManager;
 import org.argeo.api.cms.directory.HierarchyUnit;
 import org.argeo.api.cms.directory.HierarchyUnit.Type;
 import org.argeo.app.api.SuiteRole;
-import org.argeo.app.ui.SuiteUiUtils;
+import org.argeo.app.swt.ux.SuiteSwtUtils;
 import org.argeo.app.ux.SuiteMsg;
 import org.argeo.app.ux.SuiteStyle;
 import org.argeo.cms.CmsMsg;
@@ -95,12 +95,12 @@ public class PersonUiProvider implements SwtUiProvider {
                                changePasswordSection.setLayout(new GridLayout(2, false));
 //                             SuiteUiUtils.addFormLabel(changePasswordSection, CmsMsg.changePassword)
 //                                             .setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false, 2, 1));
-                               SuiteUiUtils.addFormLabel(changePasswordSection, CmsMsg.newPassword);
-                               Text newPasswordT = SuiteUiUtils.addFormTextField(changePasswordSection, null, null,
+                               SuiteSwtUtils.addFormLabel(changePasswordSection, CmsMsg.newPassword);
+                               Text newPasswordT = SuiteSwtUtils.addFormTextField(changePasswordSection, null, null,
                                                SWT.PASSWORD | SWT.BORDER);
                                newPasswordT.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-                               SuiteUiUtils.addFormLabel(changePasswordSection, CmsMsg.repeatNewPassword);
-                               Text repeatNewPasswordT = SuiteUiUtils.addFormTextField(changePasswordSection, null, null,
+                               SuiteSwtUtils.addFormLabel(changePasswordSection, CmsMsg.repeatNewPassword);
+                               Text repeatNewPasswordT = SuiteSwtUtils.addFormTextField(changePasswordSection, null, null,
                                                SWT.PASSWORD | SWT.BORDER);
                                repeatNewPasswordT.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
                                Button apply = new Button(changePasswordSection, SWT.FLAT);
@@ -127,7 +127,7 @@ public class PersonUiProvider implements SwtUiProvider {
        }
 
        private void addFormLine(SwtSection parent, Localized msg, Content content, QNamed attr) {
-               SuiteUiUtils.addFormLabel(parent, msg.lead());
+               SuiteSwtUtils.addFormLabel(parent, msg.lead());
                EditableText text = new EditableText(parent, SWT.SINGLE | SWT.FLAT);
                text.setLayoutData(CmsSwtUtils.fillWidth());
                text.setStyle(SuiteStyle.simpleInput);