X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=org.argeo.entity.ui%2Fsrc%2Forg%2Fargeo%2Fentity%2Fui%2Fforms%2FAbstractTermsPart.java;h=973ceb21ae28fa13c4c4cb9c5a14ca024edf09c5;hp=a7f240fe238baf37732611590f27a42f0c3f40a5;hb=3cf66bc01bb8ad4c55139ae01be5a5bdb3759e2c;hpb=5401f7a23b5251bb37514f5495b75f79320bedc0 diff --git a/org.argeo.entity.ui/src/org/argeo/entity/ui/forms/AbstractTermsPart.java b/org.argeo.entity.ui/src/org/argeo/entity/ui/forms/AbstractTermsPart.java index a7f240f..973ceb2 100644 --- a/org.argeo.entity.ui/src/org/argeo/entity/ui/forms/AbstractTermsPart.java +++ b/org.argeo.entity.ui/src/org/argeo/entity/ui/forms/AbstractTermsPart.java @@ -2,16 +2,21 @@ package org.argeo.entity.ui.forms; import javax.jcr.Item; -import org.argeo.cms.ui.CmsTheme; -import org.argeo.cms.ui.util.CmsIcon; +import org.argeo.api.cms.CmsTheme; +import org.argeo.cms.Localized; +import org.argeo.cms.swt.CmsIcon; +import org.argeo.cms.swt.CmsSwtUtils; import org.argeo.cms.ui.viewers.EditablePart; import org.argeo.cms.ui.widgets.ContextOverlay; import org.argeo.cms.ui.widgets.StyledControl; +import org.argeo.entity.Term; import org.argeo.entity.TermsManager; +import org.argeo.entity.Typology; 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; @@ -20,9 +25,9 @@ import org.eclipse.swt.widgets.ToolItem; public abstract class AbstractTermsPart extends StyledControl implements EditablePart { private static final long serialVersionUID = -5497097995341927710L; protected final TermsManager termsManager; - protected final String typology; + protected final Typology typology; - protected final boolean editable; + private final boolean editable; private CmsIcon deleteIcon; private CmsIcon addIcon; @@ -32,17 +37,22 @@ public abstract class AbstractTermsPart extends StyledControl implements Editabl private Composite highlight; protected final CmsTheme theme; - - public AbstractTermsPart(Composite parent, int style, Item item, TermsManager termsManager, - String typology) { + + public AbstractTermsPart(Composite parent, int style, Item item, TermsManager termsManager, String typology) { super(parent, style, item); + if (item == null) + throw new IllegalArgumentException("Item cannot be null"); this.termsManager = termsManager; - this.typology = typology; - this.theme = CmsTheme.getCmsTheme(parent); + 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); @@ -53,18 +63,30 @@ public abstract class AbstractTermsPart extends StyledControl implements Editabl } - protected String getTermLabel(String name) { - return name; + protected String getTermLabel(Term term) { + if (term instanceof Localized) + return ((Localized) term).lead(); + else + return term.getName(); + } protected abstract void refresh(ContextOverlay contextArea, String filter, Text txt); - protected boolean isTermSelectable(String term) { + protected boolean isTermSelectable(Term term) { return true; } - protected void processTermListLabel(String term, Label label) { + 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()); } //