ItEr43S18CUMarcarUnidadeTraballoExportableItEr42S25: Added cancel option to task properties form.
This commit is contained in:
parent
1819a042d7
commit
3556f16735
3 changed files with 68 additions and 45 deletions
|
|
@ -22,7 +22,6 @@ package org.zkoss.ganttz;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.zkoss.ganttz.data.ITaskFundamentalProperties;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
|
|
@ -39,6 +38,7 @@ public class TaskEditFormComposer extends GenericForwardComposer {
|
|||
private Window window;
|
||||
|
||||
private Task currentTask;
|
||||
private TaskDTO taskDTO;
|
||||
|
||||
private Textbox name;
|
||||
|
||||
|
|
@ -56,39 +56,68 @@ public class TaskEditFormComposer extends GenericForwardComposer {
|
|||
|
||||
public void showEditFormFor(Component openRelativeTo, Task task) {
|
||||
this.currentTask = task;
|
||||
this.taskDTO = toDTO(task);
|
||||
try {
|
||||
window.setMode("modal");
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
updateComponentValuesForTask(currentTask);
|
||||
updateComponentValuesForTask(taskDTO);
|
||||
}
|
||||
|
||||
private void updateComponentValuesForTask(
|
||||
ITaskFundamentalProperties currentTask) {
|
||||
name.setValue(currentTask.getName());
|
||||
startDateBox.setValue(currentTask.getBeginDate());
|
||||
endDateBox.setValue(new Date(currentTask.getBeginDate().getTime()
|
||||
+ currentTask.getLengthMilliseconds()));
|
||||
notes.setValue(currentTask.getNotes());
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
if (currentTask == null) {
|
||||
return null;
|
||||
}
|
||||
return currentTask.getEndDate();
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
if (currentTask != null) {
|
||||
currentTask.setLengthMilliseconds(endDate.getTime()
|
||||
- currentTask.getBeginDate().getTime());
|
||||
}
|
||||
TaskDTO taskDTO) {
|
||||
name.setValue(taskDTO.name);
|
||||
startDateBox.setValue(taskDTO.beginDate);
|
||||
endDateBox.setValue(taskDTO.endDate);
|
||||
notes.setValue(taskDTO.notes);
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
copyFromDTO(taskDTO, currentTask);
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
||||
}
|
||||
public void cancel() {
|
||||
window.setVisible(false);
|
||||
currentTask = null;
|
||||
taskDTO = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* DTO to manage edition before changes are accepted.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
*/
|
||||
public class TaskDTO {
|
||||
public String name;
|
||||
public Date beginDate;
|
||||
public Date endDate;
|
||||
public String notes;
|
||||
}
|
||||
|
||||
private TaskDTO toDTO(Task task) {
|
||||
TaskDTO result = new TaskDTO();
|
||||
|
||||
result.name = task.getName();
|
||||
result.beginDate = task.getBeginDate();
|
||||
result.endDate = new Date(task.getBeginDate().getTime()
|
||||
+ task.getLengthMilliseconds());
|
||||
result.notes = task.getNotes();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void copyFromDTO(TaskDTO taskDTO, Task currentTask) {
|
||||
currentTask.setName(taskDTO.name);
|
||||
currentTask.setBeginDate(taskDTO.beginDate);
|
||||
currentTask.setLengthMilliseconds(taskDTO.endDate.getTime()
|
||||
- taskDTO.beginDate.getTime());
|
||||
currentTask.setNotes(taskDTO.notes);
|
||||
}
|
||||
|
||||
public TaskDTO getTaskDTO() {
|
||||
return this.taskDTO;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.navalplanner.web.common.Util;
|
|||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.ganttz.TaskEditFormComposer;
|
||||
import org.zkoss.ganttz.TaskEditFormComposer.TaskDTO;
|
||||
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
|
|
@ -257,15 +258,11 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
});
|
||||
}
|
||||
|
||||
public TaskElement getTaskElement() {
|
||||
return currentTaskElement;
|
||||
}
|
||||
|
||||
public org.zkoss.ganttz.data.Task getGanttTask() {
|
||||
if (currentContext == null) {
|
||||
public TaskDTO getGanttTaskDTO() {
|
||||
if (taskEditFormComposer == null) {
|
||||
return null;
|
||||
}
|
||||
return currentContext.getTask();
|
||||
return taskEditFormComposer.getTaskDTO();
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
|
|
@ -278,15 +275,8 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
if (taskEditFormComposer == null) {
|
||||
return null;
|
||||
}
|
||||
return taskEditFormComposer.getEndDate();
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
taskEditFormComposer.setEndDate(endDate);
|
||||
public void cancel() {
|
||||
taskEditFormComposer.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,21 +51,21 @@
|
|||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Name')}" />
|
||||
<textbox id="name" value="@{propertiesController.ganttTask.name}" />
|
||||
<textbox id="name" value="@{propertiesController.ganttTaskDTO.name}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Start')}" />
|
||||
<datebox id="startDateBox" disabled="true"
|
||||
value="@{propertiesController.ganttTask.beginDate}" />
|
||||
value="@{propertiesController.ganttTaskDTO.beginDate}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('End')}" />
|
||||
<datebox id="endDateBox" disabled="true"
|
||||
value="@{propertiesController.endDate}" />
|
||||
value="@{propertiesController.ganttTaskDTO.endDate}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Notes')}" />
|
||||
<textbox id="notes" value="@{propertiesController.ganttTask.notes}" />
|
||||
<textbox id="notes" value="@{propertiesController.ganttTaskDTO.notes}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Hours')}" />
|
||||
|
|
@ -85,8 +85,12 @@
|
|||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<button id="ok" label="${i18n:_('Accept')}"
|
||||
onClick="propertiesController.accept();" />
|
||||
<hbox>
|
||||
<button id="ok" label="${i18n:_('Accept')}"
|
||||
onClick="propertiesController.accept();" />
|
||||
<button id="cancel" label="${i18n:_('Cancel')}"
|
||||
onClick="propertiesController.cancel();" />
|
||||
</hbox>
|
||||
</window>
|
||||
|
||||
<window id="resourceAllocationWindow"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue