Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
SAK-17868 updated to adjust the way the min and max tabs is handled
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/user/trunk@75829 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
aaronz@vt.edu committed Apr 8, 2010
1 parent c82479c commit fdd7840
Showing 1 changed file with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public void setValue(String value)
private List prefLocales = new ArrayList();

private int DEFAULT_TAB_COUNT = 4;
private int MAX_TAB_COUNT = 20;

private String prefTabCount = null;

Expand Down Expand Up @@ -397,10 +398,17 @@ public String getTabCount()
* @return the listing of valid tab choices
*/
public List<SelectItem> getTabsChoices() {
List<SelectItem> l = new ArrayList<SelectItem>(DEFAULT_TAB_COUNT);
for (int i = 0; i < DEFAULT_TAB_COUNT; i++) {
String value = String.valueOf(i+1);
l.add( new SelectItem( value, value ) );
if (MAX_TAB_COUNT <= DEFAULT_TAB_COUNT) {
// force max to be larger than default
MAX_TAB_COUNT = DEFAULT_TAB_COUNT + 10;
}
List<SelectItem> l = new ArrayList<SelectItem>(MAX_TAB_COUNT);
for (int i = 0; i < MAX_TAB_COUNT; i++) {
int tabNum = i + 1;
if (tabNum >= DEFAULT_TAB_COUNT) {
String value = String.valueOf(tabNum);
l.add( new SelectItem( value, value ) );
}
}
return l;
}
Expand All @@ -411,10 +419,10 @@ public List<SelectItem> getTabsChoices() {
**/
public void setTabCount( String count )
{
if ( count == null || count.trim().equals("") ) {
prefTabCount = String.valueOf(DEFAULT_TAB_COUNT);
if ( count == null || "".equals(count.trim()) ) {
count = String.valueOf(DEFAULT_TAB_COUNT);
} else {
prefTabCount = count.trim();
count = count.trim();
}
// make sure this is a valid number
int countInt;
Expand All @@ -423,8 +431,10 @@ public void setTabCount( String count )
} catch (NumberFormatException e) {
countInt = DEFAULT_TAB_COUNT;
}
if ( countInt > 0 && countInt < DEFAULT_TAB_COUNT ) {
prefTabCount = count;
if ( countInt > 0 && countInt >= DEFAULT_TAB_COUNT && countInt < MAX_TAB_COUNT ) {
this.prefTabCount = count;
} else {
this.prefTabCount = String.valueOf(DEFAULT_TAB_COUNT);
}
}

Expand Down Expand Up @@ -766,6 +776,16 @@ public UserPrefsTool()
} catch (NumberFormatException e) {
LOG.warn("Invalid portal.default.tabs value specified ("+tabCountConfig+") must specify a number between 0 and 100, default to "+DEFAULT_TAB_COUNT+": "+e);
}
String tabCountMaxConfig = ServerConfigurationService.getString ("portal.max.tabs", String.valueOf(MAX_TAB_COUNT));
try {
int value = Integer.valueOf(tabCountMaxConfig.trim());
if (value <= 0 || value > 100 || value <= DEFAULT_TAB_COUNT) {
throw new NumberFormatException(tabCountMaxConfig + " is out of valid range (0 .. 100) OR <= default tab count ("+DEFAULT_TAB_COUNT+")");
}
MAX_TAB_COUNT = value;
} catch (NumberFormatException e) {
LOG.warn("Invalid portal.default.tabs value specified ("+tabCountConfig+") must specify a number between 0 and 100, default to "+MAX_TAB_COUNT+": "+e);
}

LOG.debug("new UserPrefsTool()");
}
Expand Down

0 comments on commit fdd7840

Please sign in to comment.