Modify calendars controllers to show information about edited entity
BaseCalendarCRUDController is reused in workers edition so it is not easy to extend BaseCRUDController. Implement a specific solution to show calendars name in edit window title. FEA: ItEr75S14ShowInformationEditedEntity
This commit is contained in:
parent
f87c4cb316
commit
243a1260bc
3 changed files with 51 additions and 4 deletions
|
|
@ -39,15 +39,16 @@ import org.joda.time.LocalDate;
|
|||
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
||||
import org.navalplanner.business.calendars.entities.AvailabilityTimeLine.IVetoer;
|
||||
import org.navalplanner.business.calendars.entities.CalendarData.Days;
|
||||
import org.navalplanner.business.common.IHumanIdentifiable;
|
||||
import org.navalplanner.business.common.IntegrationEntity;
|
||||
import org.navalplanner.business.common.entities.EntitySequence;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.resources.entities.VirtualWorker;
|
||||
import org.navalplanner.business.workingday.EffortDuration;
|
||||
import org.navalplanner.business.workingday.IntraDayDate;
|
||||
import org.navalplanner.business.workingday.ResourcesPerDay;
|
||||
import org.navalplanner.business.workingday.EffortDuration.IEffortFrom;
|
||||
import org.navalplanner.business.workingday.IntraDayDate;
|
||||
import org.navalplanner.business.workingday.IntraDayDate.PartialDay;
|
||||
import org.navalplanner.business.workingday.ResourcesPerDay;
|
||||
|
||||
/**
|
||||
* Represents a calendar with some exception days. A calendar is valid till the
|
||||
|
|
@ -56,7 +57,8 @@ import org.navalplanner.business.workingday.IntraDayDate.PartialDay;
|
|||
* some exceptions of its parent calendar.
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
*/
|
||||
public class BaseCalendar extends IntegrationEntity implements ICalendar {
|
||||
public class BaseCalendar extends IntegrationEntity implements ICalendar,
|
||||
IHumanIdentifiable {
|
||||
|
||||
private static final Capacity DEFAULT_VALUE = Capacity.zero()
|
||||
.overAssignableWithoutLimit();
|
||||
|
|
@ -1233,4 +1235,9 @@ public class BaseCalendar extends IntegrationEntity implements ICalendar {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanId() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,11 +25,13 @@ import static org.navalplanner.web.I18nHelper._;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.calendars.entities.CalendarData;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.web.common.BaseCRUDController.CRUDControllerState;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Level;
|
||||
import org.navalplanner.web.common.MessagesForUser;
|
||||
|
|
@ -81,6 +83,8 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
|
||||
private BaseCalendarEditionController editionController;
|
||||
|
||||
private CRUDControllerState state = CRUDControllerState.LIST;
|
||||
|
||||
public BaseCalendar getBaseCalendar() {
|
||||
return baseCalendarModel.getBaseCalendar();
|
||||
}
|
||||
|
|
@ -99,17 +103,20 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void goToList() {
|
||||
state = CRUDControllerState.LIST;
|
||||
Util.reloadBindings(listWindow);
|
||||
getVisibility().showOnly(listWindow);
|
||||
}
|
||||
|
||||
public void goToEditForm(BaseCalendar baseCalendar) {
|
||||
state = CRUDControllerState.EDIT;
|
||||
baseCalendarModel.initEdit(baseCalendar);
|
||||
assignEditionController();
|
||||
setSelectedDay(new LocalDate());
|
||||
highlightDaysOnCalendar();
|
||||
getVisibility().showOnly(editWindow);
|
||||
Util.reloadBindings(editWindow);
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
private void highlightDaysOnCalendar() {
|
||||
|
|
@ -145,12 +152,14 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void goToCreateForm() {
|
||||
state = CRUDControllerState.CREATE;
|
||||
baseCalendarModel.initCreate();
|
||||
assignCreateController();
|
||||
setSelectedDay(new LocalDate());
|
||||
highlightDaysOnCalendar();
|
||||
getVisibility().showOnly(editWindow);
|
||||
Util.reloadBindings(editWindow);
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
public void setSelectedDay(LocalDate date) {
|
||||
|
|
@ -238,12 +247,14 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void goToCreateDerivedForm(BaseCalendar baseCalendar) {
|
||||
state = CRUDControllerState.CREATE;
|
||||
baseCalendarModel.initCreateDerived(baseCalendar);
|
||||
assignCreateController();
|
||||
setSelectedDay(new LocalDate());
|
||||
highlightDaysOnCalendar();
|
||||
getVisibility().showOnly(editWindow);
|
||||
Util.reloadBindings(editWindow);
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
public boolean isEditing() {
|
||||
|
|
@ -251,12 +262,14 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void goToCreateCopyForm(BaseCalendar baseCalendar) {
|
||||
state = CRUDControllerState.CREATE;
|
||||
baseCalendarModel.initCreateCopy(baseCalendar);
|
||||
assignCreateController();
|
||||
setSelectedDay(new LocalDate());
|
||||
highlightDaysOnCalendar();
|
||||
getVisibility().showOnly(editWindow);
|
||||
Util.reloadBindings(editWindow);
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
public BaseCalendarsTreeModel getBaseCalendarsTreeModel() {
|
||||
|
|
@ -486,4 +499,30 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
this.createController.validateCalendarExceptionCodes();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateWindowTitle() {
|
||||
if (editWindow != null && state != CRUDControllerState.LIST) {
|
||||
String entityType = _("Calendar");
|
||||
String humanId = getBaseCalendar().getHumanId();
|
||||
|
||||
String title;
|
||||
switch (state) {
|
||||
case CREATE:
|
||||
if (StringUtils.isEmpty(humanId)) {
|
||||
title = _("Create {0}", entityType);
|
||||
} else {
|
||||
title = _("Create {0}: {1}", entityType, humanId);
|
||||
}
|
||||
break;
|
||||
case EDIT:
|
||||
title = _("Edit {0}: {1}", entityType, humanId);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException(
|
||||
"You should be in creation or edition mode to use this method");
|
||||
}
|
||||
editWindow.setTitle(title);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@
|
|||
<label value="${i18n:_('Name')}" />
|
||||
<textbox
|
||||
value="@{calendarController.editionController.baseCalendar.name}"
|
||||
width="300px" constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
width="300px" constraint="no empty:${i18n:_('cannot be null or empty')}"
|
||||
onBlur="calendarController.updateWindowTitle()" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Type')}" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue