From: <jav...@us...> - 2011-06-30 08:36:26
|
Revision: 15639 http://dcm4che.svn.sourceforge.net/dcm4che/?rev=15639&view=rev Author: javawilli Date: 2011-06-30 08:36:16 +0000 (Thu, 30 Jun 2011) Log Message: ----------- [#WEB-405] Change BaseForm and TooltipBehavior to use option of generating prefix based on component tree. Modified Paths: -------------- dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/behaviours/TooltipBehaviour.java dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/markup/BaseForm.java Modified: dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/behaviours/TooltipBehaviour.java =================================================================== --- dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/behaviours/TooltipBehaviour.java 2011-06-30 06:58:51 UTC (rev 15638) +++ dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/behaviours/TooltipBehaviour.java 2011-06-30 08:36:16 UTC (rev 15639) @@ -45,6 +45,7 @@ import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.model.AbstractReadOnlyModel; import org.apache.wicket.model.IModel; +import org.dcm4chee.web.common.markup.BaseForm; /** * @author Franz Willer <fra...@gm...> @@ -63,6 +64,7 @@ private IModel<?> substitutionModel; private AbstractReadOnlyModel<Boolean> showTooltipModel; + private boolean generateComponentTreePrefix; /* * Create a TooltipBehaviour with given prefix. * <p> @@ -92,11 +94,18 @@ this.showTooltipModel = showTooltipModel; } + public TooltipBehaviour setGenerateComponentTreePrefix() { + this.generateComponentTreePrefix = true; + return this; + } + public void onComponentTag(Component c, ComponentTag tag) { tag.put("title", getLocalizer().getStringIgnoreSettings(getResourceKey(c), c, substitutionModel, "")); } private String getResourceKey(Component c) { + if (generateComponentTreePrefix) + prefix = generateComponentTreePrefix(c); StringBuilder sb = new StringBuilder(); if ( prefix != null ) sb.append(prefix); @@ -109,6 +118,20 @@ return sb.toString(); } + private String generateComponentTreePrefix(Component c) { + generateComponentTreePrefix = false; + StringBuilder sb = new StringBuilder(""); + Component parent = c.getParent(); + while ((parent != null) && !parent.equals("") && !(parent instanceof BaseForm)) { + sb.insert(0, "."); + sb.insert(0, parent.getId()); + parent = parent.getParent(); + } + if ((prefix != null) && (!prefix.equals(""))) + sb.insert(0, prefix); + return sb.toString(); + } + public Localizer getLocalizer() { if ( localizer == null ) localizer = Application.get().getResourceSettings().getLocalizer(); Modified: dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/markup/BaseForm.java =================================================================== --- dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/markup/BaseForm.java 2011-06-30 06:58:51 UTC (rev 15638) +++ dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/markup/BaseForm.java 2011-06-30 08:36:16 UTC (rev 15639) @@ -200,8 +200,7 @@ return enabledModel == null ? true : enabledModel.getObject(); } }; - parent.add(dtf); - dtf.add(new TooltipBehaviour(generateResourcePrefix(dtf), id, + dtf.add(new TooltipBehaviour(resourceIdPrefix, id, new AbstractReadOnlyModel<String>(){ private static final long serialVersionUID = 1L; @@ -210,7 +209,7 @@ return DateUtils.getDatePattern(dtf); } } - )); + ).setGenerateComponentTreePrefix()); return dtf; } @@ -330,7 +329,7 @@ public Object component(Component c) { if (componentHasNoTooltip(c)) - c.add(new TooltipBehaviour(generateResourcePrefix(c), c.getId())); + c.add(new TooltipBehaviour(resourceIdPrefix, c.getId()).setGenerateComponentTreePrefix()); if (c instanceof FormComponent<?>) { c.add(markInvalidBehaviour); c.setOutputMarkupId(true); @@ -347,20 +346,6 @@ return true; } - private String generateResourcePrefix(Component c) { - - StringBuffer prefix = new StringBuffer(""); - Component parent = c.getParent(); - while ((parent != null) && !parent.equals("") && !(parent instanceof BaseForm)) { - prefix.insert(0, "."); - prefix.insert(0, parent.getId()); - parent = parent.getParent(); - } - if ((resourceIdPrefix != null) && (!resourceIdPrefix.equals(""))) - prefix.insert(0, resourceIdPrefix); - return prefix.toString(); - } - public FormComponent<?> getDicomObjectField(String id, DicomObject dcmObj, int[] tagPath) { VR vr = DicomElementModel.getVRof(dcmObj, tagPath); FormComponent<?> fc; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |