Skip to content
Snippets Groups Projects
Commit ece09a1f authored by srosse's avatar srosse
Browse files

OO-291: fine tuning of the wording to access an open group

parent 1c3d3192
No related branches found
No related tags found
No related merge requests found
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* 12.10.2011 by frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.group.ui.main;
import static org.olat.group.ui.main.AbstractBusinessGroupListController.*;
import org.olat.core.gui.components.table.DefaultColumnDescriptor;
import org.olat.core.gui.render.Renderer;
import org.olat.core.gui.render.StringOutput;
import org.olat.core.gui.translator.Translator;
import org.olat.group.model.BGMembership;
/**
*
* Description:<br>
*
* <P>
* Initial Date: 11 oct. 2011 <br>
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
public class AccessActionColumnDescriptor extends DefaultColumnDescriptor {
private final Translator translator;
public AccessActionColumnDescriptor(final String headerKey, final int dataColumn, final Translator translator) {
super(headerKey, dataColumn, null, translator.getLocale());
this.translator = translator;
}
@Override
public String getAction(int row) {
int sortedRow = table.getSortedRow(row);
Object memberObj = table.getTableDataModel().getValueAt(sortedRow, BusinessGroupTableModelWithType.Cols.role.ordinal());
if(memberObj instanceof BGMembership) {
//owner, participant, or in waiting list can leave
return TABLE_ACTION_LEAVE;
}
Object wrapper = table.getTableDataModel().getValueAt(sortedRow, BusinessGroupTableModelWithType.Cols.wrapper.ordinal());
if(wrapper instanceof BGTableItem) {
BGTableItem item = (BGTableItem)wrapper;
if(item.isFull()) {
return null;
}
return TABLE_ACTION_ACCESS;
}
return null;
}
@Override
public void renderValue(StringOutput sb, int row, Renderer renderer) {
int sortedRow = table.getSortedRow(row);
Object memberObj = table.getTableDataModel().getValueAt(sortedRow, BusinessGroupTableModelWithType.Cols.role.ordinal());
if(memberObj instanceof BGMembership) {
switch((BGMembership)memberObj) {
case owner:
case participant:
sb.append(translator.translate("table.header.leave")); break;
case waiting:
sb.append(translator.translate("table.header.leave.waiting")); break;
}
} else {
Object wrapper = table.getTableDataModel().getValueAt(sortedRow, BusinessGroupTableModelWithType.Cols.wrapper.ordinal());
if(wrapper instanceof BGTableItem) {
BGTableItem item = (BGTableItem)wrapper;
if(item.isFull()) {
sb.append(translator.translate("table.header.group.full"));
} else if(item.isWaitingListEnabled()) {
sb.append(translator.translate("table.access.waitingList"));
} else {
sb.append(translator.translate("table.access"));
}
}
}
}
}
...@@ -89,6 +89,21 @@ public class BGTableItem { ...@@ -89,6 +89,21 @@ public class BGTableItem {
public Integer getMaxParticipants() { public Integer getMaxParticipants() {
return businessGroup.getMaxParticipants(); return businessGroup.getMaxParticipants();
} }
public boolean isWaitingListEnabled() {
return businessGroup.isWaitingListEnabled();
}
public boolean isFull() {
Integer maxParticipants = businessGroup.getMaxParticipants();
if(maxParticipants == null || maxParticipants.intValue() <= 0) {
return false;
}
if(maxParticipants.intValue() <= getNumOfParticipants()) {
return true;
}
return false;
}
public String getBusinessGroupDescription() { public String getBusinessGroupDescription() {
return businessGroupDescription; return businessGroupDescription;
...@@ -172,18 +187,21 @@ public class BGTableItem { ...@@ -172,18 +187,21 @@ public class BGTableItem {
private final String name; private final String name;
private final Integer maxParticipants; private final Integer maxParticipants;
private int numOfParticipants; private int numOfParticipants;
private final boolean waitingListEnabled;
public BGShort(BusinessGroup group) { public BGShort(BusinessGroup group) {
this.key = group.getKey(); key = group.getKey();
this.name = group.getName().intern(); name = group.getName().intern();
this.maxParticipants = group.getMaxParticipants(); maxParticipants = group.getMaxParticipants();
waitingListEnabled = group.getWaitingListEnabled() == null ? false : group.getWaitingListEnabled().booleanValue();
} }
public BGShort(BusinessGroupView group) { public BGShort(BusinessGroupView group) {
this.key = group.getKey(); key = group.getKey();
this.name = group.getName().intern(); name = group.getName().intern();
this.maxParticipants = group.getMaxParticipants(); maxParticipants = group.getMaxParticipants();
this.numOfParticipants = group.getNumOfParticipants(); numOfParticipants = group.getNumOfParticipants();
waitingListEnabled = group.getWaitingListEnabled() == null ? false : group.getWaitingListEnabled().booleanValue();
} }
@Override @Override
...@@ -213,6 +231,10 @@ public class BGTableItem { ...@@ -213,6 +231,10 @@ public class BGTableItem {
public int getNumOfParticipants() { public int getNumOfParticipants() {
return numOfParticipants; return numOfParticipants;
} }
public boolean isWaitingListEnabled() {
return waitingListEnabled;
}
@Override @Override
public int hashCode() { public int hashCode() {
......
...@@ -125,6 +125,8 @@ public class BusinessGroupTableModelWithType extends DefaultTableDataModel<BGTab ...@@ -125,6 +125,8 @@ public class BusinessGroupTableModelWithType extends DefaultTableDataModel<BGTab
} }
return "&infin;"; return "&infin;";
} }
case wrapper:
return wrapped;
default: default:
return "ERROR"; return "ERROR";
} }
...@@ -170,7 +172,8 @@ public class BusinessGroupTableModelWithType extends DefaultTableDataModel<BGTab ...@@ -170,7 +172,8 @@ public class BusinessGroupTableModelWithType extends DefaultTableDataModel<BGTab
firstTime("table.header.firstTime"), firstTime("table.header.firstTime"),
lastTime("table.header.lastTime"), lastTime("table.header.lastTime"),
key("table.header.key"), key("table.header.key"),
freePlaces("table.header.freePlaces"); freePlaces("table.header.freePlaces"),
wrapper("");
private final String i18n; private final String i18n;
......
...@@ -83,7 +83,7 @@ public class OpenBusinessGroupsController extends AbstractBusinessGroupListContr ...@@ -83,7 +83,7 @@ public class OpenBusinessGroupsController extends AbstractBusinessGroupListContr
groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.accessTypes.i18n(), Cols.accessTypes.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, acRenderer)); groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.accessTypes.i18n(), Cols.accessTypes.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, acRenderer));
CustomCellRenderer roleRenderer = new BGRoleCellRenderer(getLocale()); CustomCellRenderer roleRenderer = new BGRoleCellRenderer(getLocale());
groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.role.i18n(), Cols.role.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, roleRenderer)); groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.role.i18n(), Cols.role.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, roleRenderer));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.accessControlLaunch.i18n(), Cols.accessControlLaunch.ordinal(), TABLE_ACTION_ACCESS, getLocale())); groupListCtr.addColumnDescriptor(new AccessActionColumnDescriptor(Cols.accessControlLaunch.i18n(), Cols.accessControlLaunch.ordinal(), getTranslator()));
return 8; return 8;
} }
......
...@@ -69,6 +69,8 @@ table.header.description=Beschreibung ...@@ -69,6 +69,8 @@ table.header.description=Beschreibung
table.header.edit=\u00C4ndern table.header.edit=\u00C4ndern
table.header.lastUsage=Zuletzt table.header.lastUsage=Zuletzt
table.header.leave=Verlassen table.header.leave=Verlassen
table.header.leave.waiting=Verlassen
table.header.group.full=Voll belegt
table.header.mark=Favorit table.header.mark=Favorit
table.header.type=Typ table.header.type=Typ
table.header.resources=Kurs table.header.resources=Kurs
...@@ -78,6 +80,7 @@ table.header.lastTime=Zuletzt Besuch ...@@ -78,6 +80,7 @@ table.header.lastTime=Zuletzt Besuch
table.header.key=ID table.header.key=ID
table.header.freePlaces=Plätze table.header.freePlaces=Plätze
table.access=Belegen table.access=Belegen
table.access.waitingList=Warteliste eintragen
table.delete=Löschen table.delete=Löschen
table.email=Email versenden table.email=Email versenden
table.duplicate=Douplizieren table.duplicate=Douplizieren
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment