You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/10/08 14:55:08 UTC
svn commit: r1395534 - in /incubator/isis/trunk/framework/viewer/wicket:
wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/
wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/
Author: danhaywood
Date: Mon Oct 8 12:55:08 2012
New Revision: 1395534
URL: http://svn.apache.org/viewvc?rev=1395534&view=rev
Log:
ISIS-232: entity link improvements
* always render as a link if in view mode (even if have choices/autocomplete)
* remove the 'details' drill down link; not needed now have recent pages (breadcrumbs) list
* fixed bug when hit clear with autocomplete
* refactored the way that pending adapter is held (in model rather than the EntityLinkSelect2 component)
Modified:
incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java
incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.css
incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.html
incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.java
incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/FindUsingLinkFactory.java
Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java?rev=1395534&r1=1395533&r2=1395534&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/EntityModel.java Mon Oct 8 12:55:08 2012
@@ -24,6 +24,7 @@ import java.util.Map;
import com.google.common.collect.Maps;
+import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -84,6 +85,8 @@ public class EntityModel extends Bookmar
return pageParameters;
}
+
+
public enum RenderingHint {
REGULAR,
COMPACT
@@ -98,6 +101,7 @@ public class EntityModel extends Bookmar
private RenderingHint renderingHint = RenderingHint.REGULAR;
private final Map<PropertyMemento, ScalarModel> propertyScalarModels = Maps.newHashMap();
+
/**
* Toggled by 'entityDetailsButton'.
*/
@@ -113,6 +117,7 @@ public class EntityModel extends Bookmar
// //////////////////////////////////////////////////////////
public EntityModel() {
+ pendingModel = new PendingModel(this);
}
public EntityModel(final PageParameters pageParameters) {
@@ -126,6 +131,7 @@ public class EntityModel extends Bookmar
public EntityModel(final ObjectAdapterMemento adapterMemento) {
this.adapterMemento = adapterMemento;
+ pendingModel = new PendingModel(this);
}
private static String oidStr(final PageParameters pageParameters) {
@@ -342,6 +348,83 @@ public class EntityModel extends Bookmar
// //////////////////////////////////////////////////////////
+ // Pending
+ // //////////////////////////////////////////////////////////
+
+ private static final class PendingModel extends Model<ObjectAdapterMemento> {
+ private static final long serialVersionUID = 1L;
+
+ private final EntityModel entityModel;
+
+ /**
+ * Whether pending has been set (could have been set to null)
+ */
+ private boolean hasPending;
+ /**
+ * The new value (could be set to null; hasPending is used to distinguish).
+ */
+ private ObjectAdapterMemento pending;
+
+
+ public PendingModel(EntityModel entityModel) {
+ this.entityModel = entityModel;
+ }
+
+ @Override
+ public ObjectAdapterMemento getObject() {
+ if (hasPending) {
+ return pending;
+ }
+ final ObjectAdapter adapter = entityModel.getObject();
+ return ObjectAdapterMemento.createOrNull(adapter);
+ }
+
+ @Override
+ public void setObject(final ObjectAdapterMemento adapterMemento) {
+ pending = adapterMemento;
+ hasPending = true;
+ }
+
+ public void clearPending() {
+ this.hasPending = false;
+ this.pending = null;
+ }
+
+ private ObjectAdapter getPendingAdapter() {
+ final ObjectAdapterMemento memento = getObject();
+ return memento != null ? memento.getObjectAdapter(ConcurrencyChecking.NO_CHECK) : null;
+ }
+
+ public ObjectAdapter getPendingElseCurrentAdapter() {
+ return hasPending ? getPendingAdapter() : entityModel.getObject();
+ }
+
+ public void setPending(ObjectAdapterMemento selectedAdapterMemento) {
+ this.pending = selectedAdapterMemento;
+ hasPending=true;
+ }
+ }
+
+ private final PendingModel pendingModel;
+
+ public ObjectAdapter getPendingElseCurrentAdapter() {
+ return pendingModel.getPendingElseCurrentAdapter();
+ }
+
+ public ObjectAdapter getPendingAdapter() {
+ return pendingModel.getPendingAdapter();
+ }
+
+ public void setPending(ObjectAdapterMemento selectedAdapterMemento) {
+ pendingModel.setPending(selectedAdapterMemento);
+ }
+
+ public void clearPending() {
+ pendingModel.clearPending();
+ }
+
+
+ // //////////////////////////////////////////////////////////
// Dependencies (from context)
// //////////////////////////////////////////////////////////
@@ -354,4 +437,6 @@ public class EntityModel extends Bookmar
}
+
+
}
Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java?rev=1395534&r1=1395533&r2=1395534&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-model/src/main/java/org/apache/isis/viewer/wicket/model/models/ScalarModel.java Mon Oct 8 12:55:08 2012
@@ -294,7 +294,6 @@ public class ScalarModel extends EntityM
public abstract String getDescribedAs(ScalarModel scalarModel);
}
-
private final Kind kind;
private final ObjectAdapterMemento parentObjectAdapterMemento;
Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.css
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.css?rev=1395534&r1=1395533&r2=1395534&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.css (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.css Mon Oct 8 12:55:08 2012
@@ -34,27 +34,6 @@ div.entityLink > div {
font-size: smaller;
}
-a.entityDetailsLink {
- text-align: left;
- border: 1px #00477F solid;
- white-space:nowrap;
- margin:0em;
-
- margin-left: 5px;
- font-weight: normal;
- cursor:default;
- font-size: smaller;
-
- color: #00477F;
- background-color: #EEEEEE;
- text-decoration:none;
- /*
- -moz-border-radius: 6px;
- -webkit-border-radius: 6px;
- border-radius: 6px;
- */
-}
-
a.entityClearLink {
display:inline-table;
margin-left: 0px;
@@ -62,30 +41,5 @@ a.entityClearLink {
padding-right: 0px;
font-size: smaller;
}
-a.entityDetailsLink {
- display:inline;
- font-family: monospace;
- margin-left: 20px;
- padding-right: 3px;
- padding-left: 3px;
- padding-top: 1px;
- padding-bottom: 1px;
-}
-
-a.entityDetailsLink:hover {
- color: #D7E7F5;
- background-color: #407098;
-}
-
-
-.entityDetails {
- width: 400px;
- padding-top: 20px;
- margin-left: -30px;
-}
-
-.entityDetails a.entityDetailsLink {
- display:none; /* don't nest forever */
-}
Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.html
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.html?rev=1395534&r1=1395533&r2=1395534&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.html (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.html Mon Oct 8 12:55:08 2012
@@ -30,15 +30,10 @@
<body>
<wicket:panel>
<div class="entityLink">
- <input type="text" wicket:id="entityOid"/>
-
<div>
<input wicket:id="autoComplete" type="hidden" class="autoComplete" />
<span wicket:id="entityIconAndTitle">[icon and title]</span>
<span wicket:id="entityTitleNull">(null)</span>
- <a href="#" wicket:id="entityDetailsLink" class="entityDetailsLink">
- <span wicket:id="entityDetailsLinkLabel">[+/-]</span>
- </a>
<div class="findUsingClearDetails">
<table wicket:id="findUsing" class="findUsing">
<tbody>
@@ -54,8 +49,6 @@
</a>
</div>
<div class="clear"/>
- <div wicket:id="entityDetails" class="entityDetails">
- </div>
</div>
<div class="feedbackPanel">
<span wicket:id="feedback"/>
Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.java?rev=1395534&r1=1395533&r2=1395534&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/EntityLinkSelect2.java Mon Oct 8 12:55:08 2012
@@ -72,9 +72,6 @@ public class EntityLinkSelect2 extends E
private static final String ID_ENTITY_TITLE_NULL = "entityTitleNull";
private static final String ID_FIND_USING = "findUsing";
private static final String ID_ENTITY_CLEAR_LINK = "entityClearLink";
- private static final String ID_ENTITY_DETAILS_LINK = "entityDetailsLink";
- private static final String ID_ENTITY_DETAILS_LINK_LABEL = "entityDetailsLinkLabel";
- private static final String ID_ENTITY_DETAILS = "entityDetails";
private static final String ID_FEEDBACK = "feedback";
@@ -89,15 +86,8 @@ public class EntityLinkSelect2 extends E
private PanelAbstract<?> actionFindUsingComponent;
- /**
- * Whether pending has been set (could have been set to null)
- */
- private boolean hasPending;
- /**
- * The new value (could be set to null; hasPending is used to distinguish).
- */
- private ObjectAdapterMemento pending;
- private TextField<ObjectAdapterMemento> pendingOid;
+ // REVIEW: can we remove, since pending info has now moved into the model.
+ // private TextField<ObjectAdapterMemento> pendingOid;
public EntityLinkSelect2(final String id, final EntityModel entityModel) {
@@ -115,47 +105,47 @@ public class EntityLinkSelect2 extends E
* Builds the parts of the GUI that are not dynamic.
*/
private void buildGui() {
- addOrReplaceOidField();
+ //addOrReplaceOidField();
rebuildFindUsingMenu();
addOrReplace(new ComponentFeedbackPanel(ID_FEEDBACK, this));
syncWithInput();
}
- private void addOrReplaceOidField() {
- pendingOid = new TextField<ObjectAdapterMemento>(ID_ENTITY_OID, new Model<ObjectAdapterMemento>() {
-
- private static final long serialVersionUID = 1L;
-
-
- @Override
- public ObjectAdapterMemento getObject() {
- if (hasPending) {
- return pending;
- }
- final ObjectAdapter adapter = EntityLinkSelect2.this.getModelObject();
- return ObjectAdapterMemento.createOrNull(adapter);
- }
-
- @Override
- public void setObject(final ObjectAdapterMemento adapterMemento) {
- pending = adapterMemento;
- hasPending = true;
- }
-
- }) {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onModelChanged() {
- super.onModelChanged();
- syncWithInput();
- }
- };
- pendingOid.setType(ObjectAdapterMemento.class);
- addOrReplace(pendingOid);
- pendingOid.setVisible(false);
- }
+// private void addOrReplaceOidField() {
+// pendingOid = new TextField<ObjectAdapterMemento>(ID_ENTITY_OID, new Model<ObjectAdapterMemento>() {
+//
+// private static final long serialVersionUID = 1L;
+//
+//
+// @Override
+// public ObjectAdapterMemento getObject() {
+// if (hasPending) {
+// return pending;
+// }
+// final ObjectAdapter adapter = EntityLinkSelect2.this.getModelObject();
+// return ObjectAdapterMemento.createOrNull(adapter);
+// }
+//
+// @Override
+// public void setObject(final ObjectAdapterMemento adapterMemento) {
+// pending = adapterMemento;
+// hasPending = true;
+// }
+//
+// }) {
+// private static final long serialVersionUID = 1L;
+//
+// @Override
+// protected void onModelChanged() {
+// super.onModelChanged();
+// syncWithInput();
+// }
+// };
+// pendingOid.setType(ObjectAdapterMemento.class);
+// addOrReplace(pendingOid);
+// pendingOid.setVisible(false);
+// }
void rebuildFindUsingMenu() {
final EntityModel entityModel = getEntityModel();
@@ -207,13 +197,8 @@ public class EntityLinkSelect2 extends E
autoCompleteField.setEnabled(mutability);
}
- if(hasAutoCompleteOrChoicesAndNotCompactRendering()) {
+ if(isEditableWithEitherAutoCompleteOrChoices()) {
permanentlyHide(ID_ENTITY_ICON_AND_TITLE);
-
- if(getEntityModel().isEditMode()) {
- // TODO: haven't figured out how to keep in sync..
- permanentlyHide(ID_ENTITY_DETAILS_LINK);
- }
}
}
@@ -222,13 +207,8 @@ public class EntityLinkSelect2 extends E
autoCompleteField.setEnabled(mutability);
}
- if(hasAutoCompleteOrChoicesAndNotCompactRendering()) {
+ if(isEditableWithEitherAutoCompleteOrChoices()) {
permanentlyHide(ID_ENTITY_ICON_AND_TITLE);
-
- if(getEntityModel().isEditMode()) {
- // TODO: haven't figured out how to keep in sync..
- permanentlyHide(ID_ENTITY_DETAILS_LINK);
- }
}
}
@@ -240,27 +220,23 @@ public class EntityLinkSelect2 extends E
*/
@Override
public String getInput() {
- return pendingOid.getInput();
+ final ObjectAdapter pendingElseCurrentAdapter = getEntityModel().getPendingElseCurrentAdapter();
+ return pendingElseCurrentAdapter != null? pendingElseCurrentAdapter.titleString(): "[null]";
}
@Override
protected void convertInput() {
- if(getEntityModel().isEditMode() && hasAutoCompleteOrChoicesAndNotCompactRendering()) {
+ if(getEntityModel().isEditMode() && isEditableWithEitherAutoCompleteOrChoices()) {
// flush changes to pending
- onSelected(autoCompleteField.getConvertedInput().getObjectAdapter(ConcurrencyChecking.NO_CHECK));
+ onSelected(autoCompleteField.getConvertedInput());
}
- final ObjectAdapter pendingAdapter = getPendingAdapter();
+ final ObjectAdapter pendingAdapter = getEntityModel().getPendingAdapter();
setConvertedInput(pendingAdapter);
}
- private ObjectAdapter getPendingAdapter() {
- final ObjectAdapterMemento memento = pendingOid.getModelObject();
- return memento != null ? memento.getObjectAdapter(ConcurrencyChecking.NO_CHECK) : null;
- }
-
@Override
protected void onBeforeRender() {
syncWithInput();
@@ -279,15 +255,12 @@ public class EntityLinkSelect2 extends E
doSyncWithInputIfAutoCompleteOrChoices();
- syncEntityDetailsLinksWithInput(adapter);
- syncEntityDetailsWithInput(adapter);
-
syncVisibilityAndUsability();
}
private void doSyncWithInputIfAutoCompleteOrChoices() {
- if(!hasAutoCompleteOrChoicesAndNotCompactRendering()) {
+ if(!isEditableWithEitherAutoCompleteOrChoices()) {
permanentlyHide(ID_AUTO_COMPLETE);
return;
}
@@ -413,24 +386,6 @@ public class EntityLinkSelect2 extends E
}
}
- private void syncEntityDetailsLinksWithInput(final ObjectAdapter adapter) {
- if (adapter == null) {
- permanentlyHide(ID_ENTITY_DETAILS_LINK);
- return;
- }
- entityDetailsLink = new Link<String>(ID_ENTITY_DETAILS_LINK) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick() {
- getEntityModel().toggleDetails();
- }
-
- };
- addOrReplace(entityDetailsLink);
- entityDetailsLink.add(new Label(ID_ENTITY_DETAILS_LINK_LABEL, buildEntityDetailsModel()));
- }
-
private void syncEntityClearLinksWithInput(final ObjectAdapter adapter) {
if (adapter == null) {
@@ -448,23 +403,6 @@ public class EntityLinkSelect2 extends E
addOrReplace(entityClearLink);
}
- private Model<String> buildEntityDetailsModel() {
- final String label = getEntityModel().isEntityDetailsVisible() ? "-" : "+";
- return Model.of(label);
- }
-
- private void syncEntityDetailsWithInput(final ObjectAdapter adapter) {
- if (adapter != null && getEntityModel().isEntityDetailsVisible()) {
- final EntityModel entityModel = new EntityModel(adapter);
-
- final ComponentFactory componentFactory = getComponentFactoryRegistry().findComponentFactory(ComponentType.ENTITY_PROPERTIES, entityModel);
- final Component entityPanel = componentFactory.createComponent(ID_ENTITY_DETAILS, entityModel);
-
- addOrReplace(entityPanel);
- } else {
- permanentlyHide(ID_ENTITY_DETAILS);
- }
- }
private void addOrReplaceIconAndTitle(ObjectAdapter pendingOrCurrentAdapter) {
final EntityModel entityModelForLink = new EntityModel(pendingOrCurrentAdapter);
@@ -494,13 +432,8 @@ public class EntityLinkSelect2 extends E
actionFindUsingComponent.replaceWith(actionPanel);
}
- public void onSelected(final ObjectAdapter selectedAdapter) {
- final ObjectAdapterMemento selectedAdapterMemento = ObjectAdapterMemento.createOrNull(selectedAdapter);
- onSelected(selectedAdapterMemento);
- }
-
- private void onSelected(final ObjectAdapterMemento selectedAdapterMemento) {
- pendingOid.setDefaultModelObject(selectedAdapterMemento);
+ public void onSelected(final ObjectAdapterMemento selectedAdapterMemento) {
+ getEntityModel().setPending(selectedAdapterMemento);
rebuildFindUsingMenu();
renderSamePage();
}
@@ -512,24 +445,26 @@ public class EntityLinkSelect2 extends E
@Override
public void onCancel() {
- pendingOid.clearInput();
- this.hasPending = false;
- this.pending = null;
+ getEntityModel().clearPending();
}
private ObjectAdapter getPendingElseCurrentAdapter() {
- return hasPending ? getPendingAdapter() : getEntityModel().getObject();
+ return getEntityModel().getPendingElseCurrentAdapter();
}
private void renderSamePage() {
setResponsePage(getPage());
}
- private boolean hasAutoCompleteOrChoicesAndNotCompactRendering() {
- // doesn't apply in compact rendering contexts (ie tables)
+ private boolean isEditableWithEitherAutoCompleteOrChoices() {
+ // never doesn't apply in compact rendering contexts (ie tables)
if(getEntityModel().getRenderingHint() == RenderingHint.COMPACT) {
return false;
}
+ // doesn't apply if not editable, either
+ if(getEntityModel().isViewMode()) {
+ return false;
+ }
return hasChoices() || hasAutoComplete();
}
Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/FindUsingLinkFactory.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/FindUsingLinkFactory.java?rev=1395534&r1=1395533&r2=1395534&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/FindUsingLinkFactory.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/entitylink/FindUsingLinkFactory.java Mon Oct 8 12:55:08 2012
@@ -36,7 +36,7 @@ import org.apache.isis.viewer.wicket.ui.
public final class FindUsingLinkFactory implements CssMenuLinkFactory {
public interface Callback {
- public void onSelected(ObjectAdapter adapter);
+ public void onSelected(ObjectAdapterMemento adapterMemento);
public void onNoResults();
public void onClick(ActionModel actionModel);
}
@@ -60,7 +60,8 @@ public final class FindUsingLinkFactory
@Override
public void onSelected(final Component context, final ObjectAdapter selectedAdapter) {
- callback.onSelected(selectedAdapter);
+ final ObjectAdapterMemento selectedAdapterMemento = ObjectAdapterMemento.createOrNull(selectedAdapter);
+ callback.onSelected(selectedAdapterMemento);
}
});
actionModel.setNoResultsHandler(new NoResultsHandler() {