From c0995155ef2c0c48830e4ff22a9a7b15bc070cca Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Wed, 21 Jun 2023 10:41:37 +0200 Subject: [PATCH] Refactor SWT layer --- .../org/argeo/app/swt/forms/FormStyle.java | 29 +++ .../app/swt/terms/AbstractTermsPart.java | 162 +++++++++++++ .../argeo/app/swt/terms/MultiTermsPart.java | 207 +++++++++++++++++ .../argeo/app/swt/terms/SingleTermPart.java | 163 +++++++++++++ .../org/argeo/app/swt/ux/SuiteSwtUtils.java | 170 ++++++++++++++ .../src/org/argeo/app/ui/SuiteUiUtils.java | 216 +----------------- .../argeo/app/ui/dialogs/NewPersonPage.java | 8 +- .../argeo/app/ui/dialogs/NewPersonWizard.java | 6 +- .../argeo/app/ui/people/GroupUiProvider.java | 4 +- .../org/argeo/app/ui/people/NewOrgForm.java | 4 +- .../org/argeo/app/ui/people/NewUserForm.java | 8 +- .../argeo/app/ui/people/PersonUiProvider.java | 12 +- 12 files changed, 764 insertions(+), 225 deletions(-) create mode 100644 swt/org.argeo.app.swt/src/org/argeo/app/swt/forms/FormStyle.java create mode 100644 swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/AbstractTermsPart.java create mode 100644 swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/MultiTermsPart.java create mode 100644 swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/SingleTermPart.java create mode 100644 swt/org.argeo.app.swt/src/org/argeo/app/swt/ux/SuiteSwtUtils.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 index 0000000..6bc3df8 --- /dev/null +++ b/swt/org.argeo.app.swt/src/org/argeo/app/swt/forms/FormStyle.java @@ -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 index 0000000..224b3b8 --- /dev/null +++ b/swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/AbstractTermsPart.java @@ -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 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 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 index 0000000..16f2413 --- /dev/null +++ b/swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/MultiTermsPart.java @@ -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 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 curr = getValue(); + List 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 terms = termsManager.listAllTerms(typology.getId()); + List 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 newValue = new ArrayList<>(); + List curr = getValue(); + if (currentValue != null) + newValue.addAll(curr); + newValue.add(term); + setValue(newValue); + contextArea.hide(); + stopEditing(); + }); + } + contextArea.show(); + } + + protected List getValue() { + String property = typology.getId(); + List curr = getContent().getMultiple(NamespaceUtils.unqualified(property)); +// List curr = Jcr.getMultiple(getNode(), property); + List 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 value) { + String property = typology.getId(); + List 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 index 0000000..c918c25 --- /dev/null +++ b/swt/org.argeo.app.swt/src/org/argeo/app/swt/terms/SingleTermPart.java @@ -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 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 index 0000000..856319a --- /dev/null +++ b/swt/org.argeo.app.swt/src/org/argeo/app/swt/ux/SuiteSwtUtils.java @@ -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(""); + txt.append(label); + txt.append(""); + lbl.setText(txt.toString()); + return lbl; + } + + /** singleton */ + private SuiteSwtUtils() { + } + +} 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 5568201..dce6d13 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 @@ -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(""); - txt.append(label); - txt.append(""); - lbl.setText(txt.toString()); - return lbl; - } - @Deprecated public static Map eventProperties(Node node) { Map 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() { + } } diff --git a/swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonPage.java b/swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonPage.java index 54c94f8..51ab5ba 100644 --- a/swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonPage.java +++ b/swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonPage.java @@ -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)); diff --git a/swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonWizard.java b/swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonWizard.java index 2206c55..841c294 100644 --- a/swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonWizard.java +++ b/swt/org.argeo.app.ui/src/org/argeo/app/ui/dialogs/NewPersonWizard.java @@ -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)); diff --git a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/GroupUiProvider.java b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/GroupUiProvider.java index 5129018..0731e0e 100644 --- a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/GroupUiProvider.java +++ b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/GroupUiProvider.java @@ -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); diff --git a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewOrgForm.java b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewOrgForm.java index b651efa..2b7dc60 100644 --- a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewOrgForm.java +++ b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewOrgForm.java @@ -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)); diff --git a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewUserForm.java b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewUserForm.java index d70c82a..bdaa2e8 100644 --- a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewUserForm.java +++ b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/NewUserForm.java @@ -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)); diff --git a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PersonUiProvider.java b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PersonUiProvider.java index a658898..2cfb7b7 100644 --- a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PersonUiProvider.java +++ b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PersonUiProvider.java @@ -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); -- 2.30.2