Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ERD2W tab switching behaviour #696

Merged
merged 4 commits into from
Nov 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,27 @@ public String toString() {
sb.append(keys);
return sb.toString();
}

public boolean equals(Object something) {
boolean equals = true;
if (something == null) {
equals = false;
}
if (equals && !getClass().equals(something.getClass())) {
equals = false;
}
if (equals) {
ERD2WContainer other = (ERD2WContainer) something;
// verify name equality
if (name == null && other.name != null) {
equals = false;
}
if (equals && name != null && !name.equals(other.name)) {
equals = false;
}
// we don't verify display name and keys equality
}
return equals;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.webobjects.foundation.NSDictionary;
import com.webobjects.foundation.NSValidation;

import er.directtoweb.ERD2WContainer;
import er.directtoweb.ERD2WFactory;
import er.directtoweb.interfaces.ERDEditPageInterface;
import er.directtoweb.interfaces.ERDFollowPageInterface;
Expand Down Expand Up @@ -136,6 +137,15 @@ public WOComponent editAction() {
EOEnterpriseObject object = ERXEOControlUtilities.editableInstanceOfObject(object(), createNestedContext);
editPage.setObject(object);
editPage.setNextPage(nextPage());
if (currentTab() != null && editPage instanceof ERD2WPage) {
// try to keep the current tab selection
ERD2WPage tabPage = (ERD2WPage) editPage;
for (ERD2WContainer aTab : tabPage.tabSectionsContents()) {
if (aTab.equals(currentTab())) {
tabPage.setCurrentTab(aTab);
}
}
}
returnPage = (WOComponent)editPage;
}
return returnPage != null ? returnPage : previousPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,6 @@ public NSArray<ERD2WContainer> tabSectionsContents() {
_tabSectionsContents = tabSectionsContentsFromRuleResult(tabSectionContentsFromRule);
ERXStats.markEnd("D2W", statsKey);

d2wContext().takeValueForKey(tabSectionContentsFromRule, "tabSectionsContents");
// Once calculated we then determine any displayNameForTabKey
String currentTabKey = (String) d2wContext().valueForKey(Keys.tabKey);
for (Enumeration e = _tabSectionsContents.objectEnumerator(); e.hasMoreElements();) {
Expand All @@ -977,6 +976,7 @@ public NSArray<ERD2WContainer> tabSectionsContents() {
*/
protected void clearTabSectionsContents() {
_tabSectionsContents = null;
_currentTab = null;
}

/** Dummy denoting to sections. */
Expand All @@ -992,14 +992,16 @@ public NSArray sectionsForCurrentTab() {

/** Returns the {@link er.directtoweb.ERD2WContainer} defining the current tab. */
public ERD2WContainer currentTab() {
if (_currentTab == null && tabSectionsContents() != null && tabSectionsContents().count() > 0) {
//If firstTab is not null, then try to find the tab named firstTab
Integer tabIndex = (Integer) d2wContext().valueForKey(Keys.tabIndex);
if(tabIndex!=null && tabIndex.intValue() <= tabSectionsContents().count()){
setCurrentTab(tabSectionsContents().objectAtIndex(tabIndex.intValue()));
}
if(_currentTab==null)
setCurrentTab(tabSectionsContents().objectAtIndex(0));
String tabName = (String) d2wContext().valueForKey(Keys.tabKey);
if (_currentTab == null && !ERXStringUtilities.stringIsNullOrEmpty(tabName)) {
for (ERD2WContainer aTab : tabSectionsContents()) {
if (tabName.equals(aTab.name)) {
setCurrentTab(aTab);
}
}
}
if (_currentTab == null) {
_currentTab = tabSectionsContents().objectAtIndex(0);
}
return _currentTab;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.webobjects.eocontrol.EOEditingContext;
import com.webobjects.eocontrol.EOEnterpriseObject;

import er.directtoweb.ERD2WContainer;
import er.directtoweb.pages.templates.ERD2WTabInspectPageTemplate;
import er.extensions.eof.ERXEC;
import er.extensions.eof.ERXEOControlUtilities;
Expand Down Expand Up @@ -114,11 +113,7 @@ private void resetTask() {
*/
@Override
public void setObject(EOEnterpriseObject eoenterpriseobject) {
// If we are getting a new EO, then reset the current step.
if (eoenterpriseobject != null && !eoenterpriseobject.equals(object())) {
ERD2WContainer tab = tabSectionsContents().objectAtIndex(0);
setTabByName(tab.name);
}
clearTabSectionsContents();
super.setObject(eoenterpriseobject);
}

Expand Down