2009-10-01 18:46:46 +02:00
|
|
|
/*
|
2010-02-04 06:57:00 +01:00
|
|
|
* This file is part of NavalPlan
|
2009-10-01 18:46:46 +02:00
|
|
|
*
|
2010-07-19 09:36:44 +02:00
|
|
|
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
2010-07-19 09:47:20 +02:00
|
|
|
* Desenvolvemento Tecnolóxico de Galicia
|
2011-01-19 18:00:09 +01:00
|
|
|
* Copyright (C) 2010-2011 Igalia, S.L.
|
2009-10-01 18:46:46 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
package org.zkoss.ganttz;
|
|
|
|
|
|
|
|
|
|
import java.beans.PropertyChangeEvent;
|
|
|
|
|
import java.beans.PropertyChangeListener;
|
|
|
|
|
import java.text.DateFormat;
|
2009-07-06 19:13:23 +02:00
|
|
|
import java.util.Arrays;
|
2009-04-14 17:51:03 +02:00
|
|
|
import java.util.Date;
|
2009-06-29 14:36:10 +02:00
|
|
|
import java.util.List;
|
2009-04-14 17:51:03 +02:00
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
2010-10-01 17:40:24 +02:00
|
|
|
import org.joda.time.LocalDate;
|
2010-02-15 01:20:19 +01:00
|
|
|
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
|
2010-10-06 14:22:32 +02:00
|
|
|
import org.zkoss.ganttz.data.GanttDate;
|
2009-07-20 18:00:11 +02:00
|
|
|
import org.zkoss.ganttz.data.Task;
|
2009-09-30 23:30:52 +02:00
|
|
|
import org.zkoss.ganttz.util.ComponentsFinder;
|
2009-06-20 18:32:34 +02:00
|
|
|
import org.zkoss.util.Locales;
|
2009-06-20 18:32:33 +02:00
|
|
|
import org.zkoss.zk.ui.Component;
|
2009-07-06 19:13:23 +02:00
|
|
|
import org.zkoss.zk.ui.event.Event;
|
|
|
|
|
import org.zkoss.zk.ui.event.EventListener;
|
2009-06-29 14:36:10 +02:00
|
|
|
import org.zkoss.zk.ui.event.KeyEvent;
|
2009-07-05 17:15:31 +02:00
|
|
|
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
2009-04-14 17:51:03 +02:00
|
|
|
import org.zkoss.zul.Datebox;
|
|
|
|
|
import org.zkoss.zul.Textbox;
|
2009-07-05 17:15:31 +02:00
|
|
|
import org.zkoss.zul.Treecell;
|
2010-08-17 16:26:01 +02:00
|
|
|
import org.zkoss.zul.api.Label;
|
2009-07-05 17:15:31 +02:00
|
|
|
import org.zkoss.zul.api.Treerow;
|
2009-04-14 17:51:03 +02:00
|
|
|
|
2009-07-20 15:37:39 +02:00
|
|
|
public class LeftTasksTreeRow extends GenericForwardComposer {
|
2009-04-14 17:51:03 +02:00
|
|
|
|
2009-07-20 15:37:39 +02:00
|
|
|
public interface ILeftTasksTreeNavigator {
|
|
|
|
|
LeftTasksTreeRow getBelowRow();
|
2009-07-05 17:15:27 +02:00
|
|
|
|
2009-07-20 15:37:39 +02:00
|
|
|
LeftTasksTreeRow getAboveRow();
|
2009-07-05 17:15:27 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-20 15:37:39 +02:00
|
|
|
private static final Log LOG = LogFactory.getLog(LeftTasksTreeRow.class);
|
2009-04-14 17:51:03 +02:00
|
|
|
|
2009-07-20 18:00:11 +02:00
|
|
|
private final Task task;
|
2009-04-14 17:51:03 +02:00
|
|
|
|
2010-08-17 16:26:01 +02:00
|
|
|
private Label nameLabel;
|
|
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
private Textbox nameBox;
|
|
|
|
|
|
2010-08-17 16:26:01 +02:00
|
|
|
private Label startDateLabel;
|
|
|
|
|
|
2009-06-20 18:32:33 +02:00
|
|
|
private Textbox startDateTextBox;
|
|
|
|
|
|
2010-08-17 16:26:01 +02:00
|
|
|
private Label endDateLabel;
|
|
|
|
|
|
2009-06-20 18:32:33 +02:00
|
|
|
private Textbox endDateTextBox;
|
|
|
|
|
|
2009-06-20 18:32:35 +02:00
|
|
|
private Datebox startDateBox;
|
|
|
|
|
|
|
|
|
|
private Datebox endDateBox;
|
|
|
|
|
|
|
|
|
|
private DateFormat dateFormat;
|
|
|
|
|
|
2009-07-20 15:37:39 +02:00
|
|
|
private final ILeftTasksTreeNavigator leftTasksTreeNavigator;
|
2009-07-05 17:15:27 +02:00
|
|
|
|
2010-02-15 01:20:19 +01:00
|
|
|
private final IDisabilityConfiguration disabilityConfiguration;
|
|
|
|
|
|
|
|
|
|
public static LeftTasksTreeRow create(
|
|
|
|
|
IDisabilityConfiguration disabilityConfiguration, Task bean,
|
2009-07-20 15:37:39 +02:00
|
|
|
ILeftTasksTreeNavigator taskDetailnavigator) {
|
2010-02-15 01:20:19 +01:00
|
|
|
return new LeftTasksTreeRow(disabilityConfiguration, bean,
|
|
|
|
|
taskDetailnavigator);
|
2009-06-20 18:32:35 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-15 01:20:19 +01:00
|
|
|
private LeftTasksTreeRow(IDisabilityConfiguration disabilityConfiguration,
|
|
|
|
|
Task task,
|
2009-07-20 15:37:42 +02:00
|
|
|
ILeftTasksTreeNavigator leftTasksTreeNavigator) {
|
2010-02-15 01:20:19 +01:00
|
|
|
this.disabilityConfiguration = disabilityConfiguration;
|
2009-07-20 18:00:11 +02:00
|
|
|
this.task = task;
|
2009-06-20 18:32:35 +02:00
|
|
|
this.dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locales
|
|
|
|
|
.getCurrent());
|
2009-07-20 15:37:39 +02:00
|
|
|
this.leftTasksTreeNavigator = leftTasksTreeNavigator;
|
2009-06-20 18:32:35 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-20 18:00:11 +02:00
|
|
|
public Task getTask() {
|
|
|
|
|
return task;
|
2009-06-20 18:32:35 +02:00
|
|
|
}
|
|
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
public Textbox getNameBox() {
|
|
|
|
|
return nameBox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setNameBox(Textbox nameBox) {
|
|
|
|
|
this.nameBox = nameBox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Datebox getStartDateBox() {
|
|
|
|
|
return startDateBox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStartDateBox(Datebox startDateBox) {
|
|
|
|
|
this.startDateBox = startDateBox;
|
|
|
|
|
this.startDateBox.setCompact(true);
|
|
|
|
|
this.startDateBox.setFormat("dd/MM/yyyy");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Datebox getEndDateBox() {
|
|
|
|
|
return endDateBox;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 18:00:11 +02:00
|
|
|
public Task getData() {
|
|
|
|
|
return task;
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
|
|
|
|
|
2009-06-20 18:32:33 +02:00
|
|
|
/**
|
2009-06-29 14:36:09 +02:00
|
|
|
* When a text box associated to a datebox is requested to show the datebox,
|
|
|
|
|
* the corresponding datebox is shown
|
2009-06-20 18:32:33 +02:00
|
|
|
* @param component
|
|
|
|
|
* the component that has received focus
|
|
|
|
|
*/
|
2009-06-29 14:36:09 +02:00
|
|
|
public void userWantsDateBox(Component component) {
|
2009-06-20 18:32:33 +02:00
|
|
|
if (component == startDateTextBox) {
|
2010-02-15 01:29:52 +01:00
|
|
|
if (canChangeStartDate()) {
|
|
|
|
|
showDateBox(startDateBox, startDateTextBox);
|
|
|
|
|
}
|
2009-06-20 18:32:33 +02:00
|
|
|
}
|
|
|
|
|
if (component == endDateTextBox) {
|
2010-02-15 01:29:52 +01:00
|
|
|
if (canChangeEndDate()) {
|
|
|
|
|
showDateBox(endDateBox, endDateTextBox);
|
|
|
|
|
}
|
2009-06-20 18:32:33 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showDateBox(Datebox dateBox, Textbox associatedTextBox) {
|
|
|
|
|
associatedTextBox.setVisible(false);
|
|
|
|
|
dateBox.setVisible(true);
|
|
|
|
|
dateBox.setFocus(true);
|
2009-06-29 14:36:09 +02:00
|
|
|
dateBox.setOpen(true);
|
2009-06-20 18:32:33 +02:00
|
|
|
}
|
|
|
|
|
|
2009-06-29 14:36:10 +02:00
|
|
|
private enum Navigation {
|
|
|
|
|
LEFT, UP, RIGHT, DOWN;
|
|
|
|
|
public static Navigation getIntentFrom(KeyEvent keyEvent) {
|
|
|
|
|
return values()[keyEvent.getKeyCode() - 37];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void focusGoUp(int position) {
|
2009-07-20 15:37:39 +02:00
|
|
|
LeftTasksTreeRow aboveDetail = leftTasksTreeNavigator.getAboveRow();
|
2009-06-29 14:36:10 +02:00
|
|
|
if (aboveDetail != null) {
|
2009-06-29 14:36:11 +02:00
|
|
|
aboveDetail.receiveFocus(position);
|
2009-06-29 14:36:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-29 14:36:11 +02:00
|
|
|
public void receiveFocus() {
|
|
|
|
|
receiveFocus(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void receiveFocus(int position) {
|
2009-07-06 19:13:23 +02:00
|
|
|
this.getTextBoxes().get(position).focus();
|
2009-06-29 14:36:11 +02:00
|
|
|
}
|
|
|
|
|
|
2009-06-29 14:36:10 +02:00
|
|
|
public void focusGoDown(int position) {
|
2009-07-20 15:37:39 +02:00
|
|
|
LeftTasksTreeRow belowDetail = leftTasksTreeNavigator.getBelowRow();
|
2009-06-29 14:36:10 +02:00
|
|
|
if (belowDetail != null) {
|
2009-06-29 14:36:11 +02:00
|
|
|
belowDetail.receiveFocus(position);
|
2009-06-29 14:36:12 +02:00
|
|
|
} else {
|
2009-07-20 15:37:42 +02:00
|
|
|
getListDetails().getGoingDownInLastArrowCommand().doAction();
|
2009-06-29 14:36:10 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 15:37:39 +02:00
|
|
|
private LeftTasksTree getListDetails() {
|
2009-07-05 17:15:31 +02:00
|
|
|
Component current = nameBox;
|
2009-07-20 15:37:39 +02:00
|
|
|
while (!(current instanceof LeftTasksTree)) {
|
2009-06-29 14:36:12 +02:00
|
|
|
current = current.getParent();
|
|
|
|
|
}
|
2009-07-20 15:37:39 +02:00
|
|
|
return (LeftTasksTree) current;
|
2009-06-29 14:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
2009-06-29 14:36:10 +02:00
|
|
|
public void userWantsToMove(Textbox textbox, KeyEvent keyEvent) {
|
|
|
|
|
Navigation navigation = Navigation.getIntentFrom(keyEvent);
|
2009-07-06 19:13:23 +02:00
|
|
|
List<Textbox> textBoxes = getTextBoxes();
|
|
|
|
|
int position = textBoxes.indexOf(textbox);
|
2009-06-29 14:36:10 +02:00
|
|
|
switch (navigation) {
|
|
|
|
|
case UP:
|
|
|
|
|
focusGoUp(position);
|
|
|
|
|
break;
|
|
|
|
|
case DOWN:
|
|
|
|
|
focusGoDown(position);
|
|
|
|
|
break;
|
|
|
|
|
case LEFT:
|
|
|
|
|
if (position == 0) {
|
2009-07-06 19:13:23 +02:00
|
|
|
focusGoUp(getTextBoxes().size() - 1);
|
2009-06-29 14:36:10 +02:00
|
|
|
} else {
|
2009-07-06 19:13:23 +02:00
|
|
|
textBoxes.get(position - 1).focus();
|
2009-06-29 14:36:10 +02:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case RIGHT:
|
2009-11-03 20:38:03 +01:00
|
|
|
if (position < textBoxes.size() - 1) {
|
2009-07-06 19:13:23 +02:00
|
|
|
textBoxes.get(position + 1).focus();
|
2009-11-03 20:38:03 +01:00
|
|
|
} else {
|
2009-06-29 14:36:10 +02:00
|
|
|
focusGoDown(0);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new RuntimeException("case not covered: " + navigation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-06 19:13:23 +02:00
|
|
|
private List<Textbox> getTextBoxes() {
|
|
|
|
|
return Arrays.asList(nameBox, startDateTextBox, endDateTextBox);
|
2009-06-29 14:36:10 +02:00
|
|
|
}
|
|
|
|
|
|
2009-06-20 18:32:33 +02:00
|
|
|
/**
|
|
|
|
|
* When the dateBox loses focus the corresponding textbox is shown instead.
|
|
|
|
|
* @param dateBox
|
|
|
|
|
* the component that has lost focus
|
|
|
|
|
*/
|
|
|
|
|
public void dateBoxHasLostFocus(Datebox dateBox) {
|
|
|
|
|
if (dateBox == startDateBox) {
|
|
|
|
|
hideDateBox(startDateBox, startDateTextBox);
|
|
|
|
|
}
|
|
|
|
|
if (dateBox == endDateBox) {
|
|
|
|
|
hideDateBox(endDateBox, endDateTextBox);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void hideDateBox(Datebox dateBoxToDissapear,
|
|
|
|
|
Textbox associatedTextBox) {
|
|
|
|
|
dateBoxToDissapear.setVisible(false);
|
|
|
|
|
associatedTextBox.setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
@Override
|
2009-07-05 17:15:31 +02:00
|
|
|
public void doAfterCompose(Component component) throws Exception {
|
|
|
|
|
super.doAfterCompose(component);
|
|
|
|
|
findComponents((Treerow) component);
|
2009-07-06 19:13:23 +02:00
|
|
|
registerListeners();
|
2009-04-14 17:51:03 +02:00
|
|
|
updateComponents();
|
2009-07-20 18:00:11 +02:00
|
|
|
task
|
2009-07-06 19:13:23 +02:00
|
|
|
.addFundamentalPropertiesChangeListener(new PropertyChangeListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
|
|
updateComponents();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2009-04-14 17:51:03 +02:00
|
|
|
|
2009-07-06 19:13:23 +02:00
|
|
|
private void registerListeners() {
|
2010-08-17 16:26:01 +02:00
|
|
|
if (disabilityConfiguration.isTreeEditable()) {
|
|
|
|
|
registerKeyboardListener(nameBox);
|
|
|
|
|
registerKeyboardListener(startDateTextBox);
|
|
|
|
|
registerKeyboardListener(endDateTextBox);
|
2009-07-06 19:13:23 +02:00
|
|
|
|
2010-08-17 16:26:01 +02:00
|
|
|
registerOnEnterListener(startDateTextBox);
|
|
|
|
|
registerOnEnterListener(endDateTextBox);
|
2009-07-06 19:13:23 +02:00
|
|
|
|
2010-08-17 16:26:01 +02:00
|
|
|
registerOnEnterOpenDateBox(startDateBox);
|
|
|
|
|
registerOnEnterOpenDateBox(endDateBox);
|
2009-07-06 20:01:27 +02:00
|
|
|
|
2010-08-17 16:26:01 +02:00
|
|
|
registerBlurListener(startDateBox);
|
|
|
|
|
registerBlurListener(endDateBox);
|
2009-07-06 19:13:23 +02:00
|
|
|
|
2010-08-17 16:26:01 +02:00
|
|
|
registerOnChange(nameBox);
|
|
|
|
|
registerOnChange(startDateBox);
|
|
|
|
|
registerOnChange(endDateBox);
|
|
|
|
|
}
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-05 17:15:31 +02:00
|
|
|
private void findComponents(Treerow row) {
|
|
|
|
|
List<Object> rowChildren = row.getChildren();
|
2009-09-30 23:30:52 +02:00
|
|
|
List<Treecell> treeCells = ComponentsFinder.findComponentsOfType(Treecell.class,
|
2009-07-05 17:15:31 +02:00
|
|
|
rowChildren);
|
|
|
|
|
assert treeCells.size() == 3;
|
|
|
|
|
findComponentsForNameCell(treeCells.get(0));
|
|
|
|
|
findComponentsForStartDateCell(treeCells.get(1));
|
|
|
|
|
findComponentsForEndDateCell(treeCells.get(2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Datebox findDateBoxOfCell(Treecell treecell) {
|
|
|
|
|
List<Object> children = treecell.getChildren();
|
2009-09-30 23:30:52 +02:00
|
|
|
return ComponentsFinder.findComponentsOfType(Datebox.class, children).get(0);
|
2009-07-05 17:15:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Textbox findTextBoxOfCell(Treecell treecell) {
|
|
|
|
|
List<Object> children = treecell.getChildren();
|
2009-09-30 23:30:52 +02:00
|
|
|
return ComponentsFinder.findComponentsOfType(Textbox.class, children).get(0);
|
2009-07-05 17:15:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void findComponentsForNameCell(Treecell treecell) {
|
2010-08-17 16:26:01 +02:00
|
|
|
if (disabilityConfiguration.isTreeEditable()) {
|
|
|
|
|
nameBox = (Textbox) treecell.getChildren().get(0);
|
|
|
|
|
} else {
|
|
|
|
|
nameLabel = (Label) treecell.getChildren().get(0);
|
|
|
|
|
}
|
2009-07-05 17:15:31 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-06 19:13:23 +02:00
|
|
|
private void registerKeyboardListener(final Textbox textBox) {
|
|
|
|
|
textBox.addEventListener("onCtrlKey", new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
|
|
|
|
userWantsToMove(textBox, (KeyEvent) event);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-15 01:45:30 +01:00
|
|
|
private void registerOnChange(final Component component) {
|
2009-07-06 19:13:23 +02:00
|
|
|
component.addEventListener("onChange", new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
2010-02-15 01:45:30 +01:00
|
|
|
updateBean(component);
|
2009-07-06 19:13:23 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void registerOnEnterListener(final Textbox textBox) {
|
|
|
|
|
textBox.addEventListener("onOK", new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
|
|
|
|
userWantsDateBox(textBox);
|
|
|
|
|
}
|
|
|
|
|
});
|
2009-07-06 20:01:27 +02:00
|
|
|
}
|
2009-07-06 19:13:23 +02:00
|
|
|
|
2009-07-06 20:01:27 +02:00
|
|
|
private void registerOnEnterOpenDateBox(final Datebox datebox) {
|
|
|
|
|
datebox.addEventListener("onOK", new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
|
|
|
|
datebox.setOpen(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
2009-07-06 19:13:23 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-05 17:15:31 +02:00
|
|
|
private void findComponentsForStartDateCell(Treecell treecell) {
|
2010-08-17 16:26:01 +02:00
|
|
|
if (disabilityConfiguration.isTreeEditable()) {
|
|
|
|
|
startDateTextBox = findTextBoxOfCell(treecell);
|
|
|
|
|
startDateBox = findDateBoxOfCell(treecell);
|
|
|
|
|
} else {
|
|
|
|
|
startDateLabel = (Label) treecell.getChildren().get(0);
|
|
|
|
|
}
|
2009-07-05 17:15:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void findComponentsForEndDateCell(Treecell treecell) {
|
2010-08-17 16:26:01 +02:00
|
|
|
if (disabilityConfiguration.isTreeEditable()) {
|
|
|
|
|
endDateBox = findDateBoxOfCell(treecell);
|
|
|
|
|
endDateBox.setDisabled(true);
|
|
|
|
|
endDateTextBox = findTextBoxOfCell(treecell);
|
|
|
|
|
} else {
|
|
|
|
|
endDateLabel = (Label) treecell.getChildren().get(0);
|
|
|
|
|
}
|
2009-07-05 17:15:31 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-06 19:13:23 +02:00
|
|
|
private void registerBlurListener(final Datebox datebox) {
|
|
|
|
|
datebox.addEventListener("onBlur", new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
|
|
|
|
dateBoxHasLostFocus(datebox);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-15 01:45:30 +01:00
|
|
|
public void updateBean(Component updatedComponent) {
|
|
|
|
|
if (updatedComponent == getNameBox()) {
|
|
|
|
|
task.setName(getNameBox().getValue());
|
|
|
|
|
} else if (updatedComponent == getStartDateBox()) {
|
|
|
|
|
Date begin = getStartDateBox().getValue();
|
2010-10-06 14:22:32 +02:00
|
|
|
task.moveTo(GanttDate.createFrom(begin));
|
2010-02-15 01:45:30 +01:00
|
|
|
} else if (updatedComponent == getEndDateBox()) {
|
|
|
|
|
Date newEnd = getEndDateBox().getValue();
|
2010-10-01 17:40:24 +02:00
|
|
|
task.resizeTo(LocalDate.fromDateFields(newEnd));
|
2010-02-15 01:45:30 +01:00
|
|
|
}
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateComponents() {
|
2010-08-17 16:26:01 +02:00
|
|
|
if (disabilityConfiguration.isTreeEditable()) {
|
|
|
|
|
getNameBox().setValue(task.getName());
|
|
|
|
|
getNameBox().setDisabled(!canRenameTask());
|
|
|
|
|
getNameBox().setTooltiptext(task.getName());
|
2010-02-15 01:29:52 +01:00
|
|
|
|
2010-10-06 14:22:32 +02:00
|
|
|
getStartDateBox().setValue(
|
2010-10-08 16:27:56 +02:00
|
|
|
task.getBeginDate().toDayRoundedDate());
|
2010-08-17 16:26:01 +02:00
|
|
|
getStartDateBox().setDisabled(!canChangeStartDate());
|
|
|
|
|
getStartDateTextBox().setDisabled(!canChangeStartDate());
|
2010-02-15 01:29:52 +01:00
|
|
|
|
2010-10-08 16:27:56 +02:00
|
|
|
getEndDateBox().setValue(task.getEndDate().toDayRoundedDate());
|
2010-08-17 16:26:01 +02:00
|
|
|
getEndDateBox().setDisabled(!canChangeEndDate());
|
|
|
|
|
getEndDateTextBox().setDisabled(!canChangeEndDate());
|
2010-02-15 01:29:52 +01:00
|
|
|
|
2010-10-06 14:22:32 +02:00
|
|
|
getStartDateTextBox().setValue(
|
2010-10-08 16:27:56 +02:00
|
|
|
asString(task.getBeginDate().toDayRoundedDate()));
|
2010-10-06 14:22:32 +02:00
|
|
|
getEndDateTextBox().setValue(
|
2010-10-08 16:27:56 +02:00
|
|
|
asString(task.getEndDate().toDayRoundedDate()));
|
2010-08-17 16:26:01 +02:00
|
|
|
} else {
|
|
|
|
|
nameLabel.setValue(task.getName());
|
2010-08-20 12:55:32 +02:00
|
|
|
nameLabel.setTooltiptext(task.getName());
|
2010-10-06 14:22:32 +02:00
|
|
|
startDateLabel.setValue(asString(task.getBeginDate()
|
2010-10-08 16:27:56 +02:00
|
|
|
.toDayRoundedDate()));
|
2010-10-06 14:22:32 +02:00
|
|
|
endDateLabel.setValue(asString(task.getEndDate()
|
2010-10-08 16:27:56 +02:00
|
|
|
.toDayRoundedDate()));
|
2010-08-17 16:26:01 +02:00
|
|
|
}
|
2009-06-20 18:32:33 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-15 01:20:19 +01:00
|
|
|
private boolean canChangeStartDate() {
|
|
|
|
|
return disabilityConfiguration.isMovingTasksEnabled()
|
2010-06-15 12:07:15 +02:00
|
|
|
&& task.canBeExplicitlyMoved();
|
2010-02-15 01:20:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean canChangeEndDate() {
|
|
|
|
|
return disabilityConfiguration.isResizingTasksEnabled()
|
|
|
|
|
&& task.canBeExplicitlyResized();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-23 13:31:35 +02:00
|
|
|
private boolean canRenameTask() {
|
|
|
|
|
return disabilityConfiguration.isRenamingTasksEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-20 18:32:33 +02:00
|
|
|
private String asString(Date date) {
|
|
|
|
|
return dateFormat.format(date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Textbox getStartDateTextBox() {
|
|
|
|
|
return startDateTextBox;
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
2009-06-15 21:48:54 +02:00
|
|
|
|
2009-06-20 18:32:33 +02:00
|
|
|
public void setStartDateTextBox(Textbox startDateTextBox) {
|
|
|
|
|
this.startDateTextBox = startDateTextBox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Textbox getEndDateTextBox() {
|
|
|
|
|
return endDateTextBox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setEndDateTextBox(Textbox endDateTextBox) {
|
|
|
|
|
this.endDateTextBox = endDateTextBox;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|