2009-10-01 18:46:46 +02:00
|
|
|
/*
|
2011-10-28 08:17:54 +02:00
|
|
|
* This file is part of LibrePlan
|
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;
|
2011-11-11 11:25:53 +01:00
|
|
|
import java.text.ParseException;
|
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
|
|
|
|
2011-11-11 11:25:53 +01:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
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;
|
2011-12-01 15:54:25 +01:00
|
|
|
import org.zkoss.ganttz.data.ITaskFundamentalProperties.IModifications;
|
|
|
|
|
import org.zkoss.ganttz.data.ITaskFundamentalProperties.IUpdatablePosition;
|
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
|
|
|
|
2011-11-11 11:25:53 +01:00
|
|
|
/**
|
|
|
|
|
* Row composer for Tasks details Tree <br />
|
|
|
|
|
*
|
|
|
|
|
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
|
|
|
|
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
|
|
|
|
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
|
|
|
|
*/
|
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;
|
|
|
|
|
|
2011-11-11 11:25:53 +01:00
|
|
|
private Datebox openedDateBox = null;
|
2009-06-20 18:32:35 +02:00
|
|
|
|
|
|
|
|
private DateFormat dateFormat;
|
|
|
|
|
|
2011-11-14 19:18:23 +01:00
|
|
|
private Planner planner;
|
|
|
|
|
|
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,
|
2011-11-14 19:18:23 +01:00
|
|
|
ILeftTasksTreeNavigator taskDetailnavigator, Planner planner) {
|
2010-02-15 01:20:19 +01:00
|
|
|
return new LeftTasksTreeRow(disabilityConfiguration, bean,
|
2011-11-14 19:18:23 +01:00
|
|
|
taskDetailnavigator, planner);
|
2009-06-20 18:32:35 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-15 01:20:19 +01:00
|
|
|
private LeftTasksTreeRow(IDisabilityConfiguration disabilityConfiguration,
|
2011-11-14 19:18:23 +01:00
|
|
|
Task task, ILeftTasksTreeNavigator leftTasksTreeNavigator,
|
|
|
|
|
Planner planner) {
|
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;
|
2011-11-14 19:18:23 +01:00
|
|
|
this.planner = planner;
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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()) {
|
2011-11-11 11:25:53 +01:00
|
|
|
createDateBox(startDateTextBox);
|
2010-02-15 01:29:52 +01:00
|
|
|
}
|
2009-06-20 18:32:33 +02:00
|
|
|
}
|
|
|
|
|
if (component == endDateTextBox) {
|
2010-02-15 01:29:52 +01:00
|
|
|
if (canChangeEndDate()) {
|
2011-11-11 11:25:53 +01:00
|
|
|
createDateBox(endDateTextBox);
|
2010-02-15 01:29:52 +01:00
|
|
|
}
|
2009-06-20 18:32:33 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-11 11:25:53 +01:00
|
|
|
public void createDateBox(Textbox textbox) {
|
|
|
|
|
openedDateBox = new Datebox();
|
|
|
|
|
openedDateBox.setFormat("short");
|
|
|
|
|
openedDateBox.setButtonVisible(false);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
openedDateBox.setValue(dateFormat.parse(textbox.getValue()));
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
registerOnEnterOpenDateBox(openedDateBox);
|
|
|
|
|
registerBlurListener(openedDateBox);
|
|
|
|
|
registerOnChangeDatebox(openedDateBox, textbox);
|
|
|
|
|
|
|
|
|
|
textbox.setVisible(false);
|
|
|
|
|
textbox.getParent().appendChild(openedDateBox);
|
|
|
|
|
openedDateBox.setFocus(true);
|
|
|
|
|
openedDateBox.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;
|
|
|
|
|
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) {
|
2011-11-11 11:25:53 +01:00
|
|
|
dateBox.getPreviousSibling().setVisible(true);
|
|
|
|
|
dateBox.setParent(null);
|
2009-06-20 18:32:33 +02:00
|
|
|
}
|
|
|
|
|
|
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);
|
2011-11-11 11:25:53 +01:00
|
|
|
registerTextboxesListeners();
|
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
|
|
|
|
2011-11-11 11:25:53 +01:00
|
|
|
private void registerTextboxesListeners() {
|
2010-08-17 16:26:01 +02:00
|
|
|
if (disabilityConfiguration.isTreeEditable()) {
|
|
|
|
|
registerKeyboardListener(nameBox);
|
2011-11-11 11:25:53 +01:00
|
|
|
registerOnChange(nameBox);
|
2010-08-17 16:26:01 +02:00
|
|
|
registerKeyboardListener(startDateTextBox);
|
|
|
|
|
registerKeyboardListener(endDateTextBox);
|
|
|
|
|
registerOnEnterListener(startDateTextBox);
|
|
|
|
|
registerOnEnterListener(endDateTextBox);
|
2011-11-11 11:25:53 +01:00
|
|
|
registerOnChange(startDateTextBox);
|
|
|
|
|
registerOnChange(endDateTextBox);
|
2010-08-17 16:26:01 +02:00
|
|
|
}
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
|
|
|
|
|
2011-11-11 11:25:53 +01:00
|
|
|
public void registerDateboxListeners(Datebox datebox) {
|
|
|
|
|
}
|
|
|
|
|
|
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 Textbox findTextBoxOfCell(Treecell treecell) {
|
|
|
|
|
List<Object> children = treecell.getChildren();
|
2011-11-11 11:25:53 +01: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
|
2011-06-06 17:46:26 +02:00
|
|
|
public void onEvent(Event event) {
|
2009-07-06 19:13:23 +02:00
|
|
|
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
|
2011-06-06 17:46:26 +02:00
|
|
|
public void onEvent(Event event) {
|
2010-02-15 01:45:30 +01:00
|
|
|
updateBean(component);
|
2009-07-06 19:13:23 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-11 11:25:53 +01:00
|
|
|
private void registerOnChangeDatebox(final Datebox datebox,
|
|
|
|
|
final Textbox textbox) {
|
|
|
|
|
datebox.addEventListener("onChange", new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) {
|
|
|
|
|
textbox.setValue(dateFormat.format(datebox.getValue()));
|
|
|
|
|
updateBean(textbox);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-06 19:13:23 +02:00
|
|
|
private void registerOnEnterListener(final Textbox textBox) {
|
|
|
|
|
textBox.addEventListener("onOK", new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
2011-06-06 17:46:26 +02:00
|
|
|
public void onEvent(Event event) {
|
2009-07-06 19:13:23 +02:00
|
|
|
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
|
2011-06-06 17:46:26 +02:00
|
|
|
public void onEvent(Event event) {
|
2009-07-06 20:01:27 +02:00
|
|
|
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);
|
|
|
|
|
} 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()) {
|
|
|
|
|
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
|
2011-06-06 17:46:26 +02:00
|
|
|
public void onEvent(Event event) {
|
2009-07-06 19:13:23 +02:00
|
|
|
dateBoxHasLostFocus(datebox);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-15 01:45:30 +01:00
|
|
|
public void updateBean(Component updatedComponent) {
|
|
|
|
|
if (updatedComponent == getNameBox()) {
|
|
|
|
|
task.setName(getNameBox().getValue());
|
2011-11-11 11:25:53 +01:00
|
|
|
if (StringUtils.isEmpty(getNameBox().getValue())) {
|
|
|
|
|
getNameBox().setValue(task.getName());
|
|
|
|
|
}
|
|
|
|
|
} else if (updatedComponent == getStartDateTextBox()) {
|
|
|
|
|
try {
|
2011-12-01 15:54:25 +01:00
|
|
|
final Date begin = dateFormat.parse(getStartDateTextBox()
|
|
|
|
|
.getValue());
|
|
|
|
|
task.doPositionModifications(new IModifications() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doIt(IUpdatablePosition position) {
|
|
|
|
|
position.moveTo(GanttDate.createFrom(begin));
|
|
|
|
|
}
|
|
|
|
|
});
|
2011-11-11 11:25:53 +01:00
|
|
|
} catch (ParseException e) {
|
|
|
|
|
getStartDateTextBox().setValue(
|
|
|
|
|
dateFormat.format(task.getBeginDate()
|
|
|
|
|
.toDayRoundedDate()));
|
|
|
|
|
}
|
|
|
|
|
} else if (updatedComponent == getEndDateTextBox()) {
|
|
|
|
|
try {
|
|
|
|
|
Date newEnd = dateFormat.parse(getEndDateTextBox().getValue());
|
|
|
|
|
task.resizeTo(LocalDate.fromDateFields(newEnd));
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
getEndDateTextBox().setValue(
|
|
|
|
|
asString(task.getEndDate().toDayRoundedDate()));
|
|
|
|
|
}
|
2010-02-15 01:45:30 +01:00
|
|
|
}
|
2011-11-14 19:18:23 +01:00
|
|
|
planner.updateTooltips();
|
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-08-17 16:26:01 +02:00
|
|
|
getStartDateTextBox().setDisabled(!canChangeStartDate());
|
|
|
|
|
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
|
|
|
}
|