ItEr15S12RFComportamentoGraficoPlanificadorItEr14S13: Adding columns to left pane tree.
This commit is contained in:
parent
ff89434f23
commit
9bba8fdcc7
5 changed files with 68 additions and 43 deletions
|
|
@ -12,6 +12,8 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.zkoss.ganttz.TaskDetail.ITaskDetailNavigator;
|
||||
import org.zkoss.ganttz.util.TaskBean;
|
||||
import org.zkoss.ganttz.util.TaskContainerBean;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
|
@ -20,10 +22,8 @@ import org.zkoss.zul.SimpleTreeModel;
|
|||
import org.zkoss.zul.SimpleTreeNode;
|
||||
import org.zkoss.zul.Tree;
|
||||
import org.zkoss.zul.TreeModel;
|
||||
import org.zkoss.zul.Treecell;
|
||||
import org.zkoss.zul.Treeitem;
|
||||
import org.zkoss.zul.TreeitemRenderer;
|
||||
import org.zkoss.zul.Treerow;
|
||||
|
||||
public class ListDetails extends HtmlMacroComponent {
|
||||
|
||||
|
|
@ -31,11 +31,7 @@ public class ListDetails extends HtmlMacroComponent {
|
|||
public void render(Treeitem item, Object data) throws Exception {
|
||||
SimpleTreeNode node = (SimpleTreeNode) data;
|
||||
TaskBean taskBean = (TaskBean) node.getData();
|
||||
Treerow treerow = new Treerow();
|
||||
treerow.setParent(item);
|
||||
item.setOpen(isOpened(taskBean));
|
||||
Treecell treecell = new Treecell();
|
||||
treecell.setParent(treerow);
|
||||
final int[] path = tasksTreeModel.getPath(tasksTreeModel.getRoot(),
|
||||
node);
|
||||
TaskDetail taskDetail = TaskDetail.create(taskBean,
|
||||
|
|
@ -43,9 +39,10 @@ public class ListDetails extends HtmlMacroComponent {
|
|||
if (taskBean instanceof TaskContainerBean) {
|
||||
expandWhenOpened((TaskContainerBean) taskBean, item);
|
||||
}
|
||||
taskDetail.setParent(treecell);
|
||||
Component row = Executions.getCurrent().createComponents(
|
||||
"~./ganttz/zul/taskdetail.zul", item, null);
|
||||
taskDetail.doAfterCompose(row);
|
||||
detailsForBeans.put(taskBean, taskDetail);
|
||||
taskDetail.afterCompose();
|
||||
}
|
||||
|
||||
private void expandWhenOpened(final TaskContainerBean taskBean,
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.zkoss.ganttz.util.TaskBean;
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zk.ui.event.KeyEvent;
|
||||
import org.zkoss.zk.ui.ext.AfterCompose;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Datebox;
|
||||
import org.zkoss.zul.Textbox;
|
||||
import org.zkoss.zul.Treecell;
|
||||
import org.zkoss.zul.api.Treerow;
|
||||
|
||||
public class TaskDetail extends HtmlMacroComponent implements AfterCompose {
|
||||
public class TaskDetail extends GenericForwardComposer {
|
||||
|
||||
public interface ITaskDetailNavigator {
|
||||
TaskDetail getBelowDetail();
|
||||
|
|
@ -149,7 +150,7 @@ public class TaskDetail extends HtmlMacroComponent implements AfterCompose {
|
|||
}
|
||||
|
||||
private ListDetails getListDetails() {
|
||||
Component current = getParent();
|
||||
Component current = nameBox;
|
||||
while (!(current instanceof ListDetails)) {
|
||||
current = current.getParent();
|
||||
}
|
||||
|
|
@ -214,9 +215,12 @@ public class TaskDetail extends HtmlMacroComponent implements AfterCompose {
|
|||
associatedTextBox.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterCompose() {
|
||||
super.afterCompose();
|
||||
public void doAfterCompose(Component component) throws Exception {
|
||||
super.doAfterCompose(component);
|
||||
component.setVariable("top", this, true);
|
||||
findComponents((Treerow) component);
|
||||
updateComponents();
|
||||
taskBean.addFundamentalPropertiesChangeListener(new PropertyChangeListener() {
|
||||
|
||||
|
|
@ -227,6 +231,40 @@ public class TaskDetail extends HtmlMacroComponent implements AfterCompose {
|
|||
});
|
||||
}
|
||||
|
||||
private void findComponents(Treerow row) {
|
||||
List<Object> rowChildren = row.getChildren();
|
||||
List<Treecell> treeCells = Planner.findComponentsOfType(Treecell.class,
|
||||
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();
|
||||
return Planner.findComponentsOfType(Datebox.class, children).get(0);
|
||||
}
|
||||
|
||||
private static Textbox findTextBoxOfCell(Treecell treecell) {
|
||||
List<Object> children = treecell.getChildren();
|
||||
return Planner.findComponentsOfType(Textbox.class, children).get(0);
|
||||
}
|
||||
|
||||
private void findComponentsForNameCell(Treecell treecell) {
|
||||
nameBox = (Textbox) treecell.getChildren().get(0);
|
||||
}
|
||||
|
||||
private void findComponentsForStartDateCell(Treecell treecell) {
|
||||
startDateTextBox = findTextBoxOfCell(treecell);
|
||||
startDateBox = findDateBoxOfCell(treecell);
|
||||
}
|
||||
|
||||
private void findComponentsForEndDateCell(Treecell treecell) {
|
||||
endDateBox = findDateBoxOfCell(treecell);
|
||||
endDateTextBox = findTextBoxOfCell(treecell);
|
||||
}
|
||||
|
||||
public void updateBean() {
|
||||
if (getEndDateBox().getValue().before(getStartDateBox().getValue())) {
|
||||
updateComponents();
|
||||
|
|
|
|||
|
|
@ -26,12 +26,6 @@
|
|||
<macro-uri>~./ganttz/zul/listdetails.zul</macro-uri>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-name>taskdetail</component-name>
|
||||
<component-class>org.zkoss.ganttz.TaskDetail</component-class>
|
||||
<macro-uri>~./ganttz/zul/taskdetail.zul</macro-uri>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-name>ganttpanel</component-name>
|
||||
<component-class>org.zkoss.ganttz.GanttPanel</component-class>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,13 @@
|
|||
onClick="self.getParent().addTask();" />
|
||||
<button label="Engadir Contedor"
|
||||
onClick="self.getParent().addTaskContainer();" />
|
||||
<n:div id="listdetails_container">
|
||||
<n:div id="listdetails_container">
|
||||
<tree id="tasksTree">
|
||||
<treecols sizable="false">
|
||||
<treecol label="Name" />
|
||||
<treecol label="Start Date" />
|
||||
<treecol label="End Date" />
|
||||
</treecols>
|
||||
</tree>
|
||||
</n:div>
|
||||
</zk>
|
||||
|
|
@ -1,22 +1,13 @@
|
|||
<zk>
|
||||
<zscript><![CDATA[
|
||||
top = self;
|
||||
]]>
|
||||
</zscript>
|
||||
<hbox class="taskdetail_grid">
|
||||
<textbox id="nameBox" ctrlKeys="#down#up#right#left" onCtrlKey="top.userWantsToMove(self,event);" value="" onChange="top.updateBean();" class="task_title"/>
|
||||
<textbox id="startDateTextBox" value="" ctrlKeys="#down#up#right#left" onCtrlKey="top.userWantsToMove(self,event);" onChange="top.updateBean();" onOK="top.userWantsDateBox(self);" />
|
||||
<datebox id="startDateBox" compact="true" onChange="top.updateBean();" visible="${false}" onBlur="top.dateBoxHasLostFocus(self);"/>
|
||||
<textbox id="endDateTextBox" ctrlKeys="#down#up#right#left" onCtrlKey="top.userWantsToMove(self,event);" value="" onChange="top.updateBean();" onOK="top.userWantsDateBox(self);"/>
|
||||
<datebox id="endDateBox" compact="true" onChange="top.updateBean();" visible ="${false}" onBlur="top.dateBoxHasLostFocus(self);" ctrlKeys="#down" onCtrlKey="top.userWantsDateBox(self)"/>
|
||||
</hbox>
|
||||
|
||||
<zscript><![CDATA[
|
||||
top.nameBox = nameBox;
|
||||
top.startDateBox = startDateBox;
|
||||
top.endDateBox = endDateBox;
|
||||
top.startDateTextBox = startDateTextBox;
|
||||
top.endDateTextBox = endDateTextBox;
|
||||
]]>
|
||||
</zscript>
|
||||
</zk>
|
||||
<treerow sclass="taskdetail_grid">
|
||||
<treecell>
|
||||
<textbox ctrlKeys="#down#up#right#left" onCtrlKey="top.userWantsToMove(self,event);" value="" onChange="top.updateBean();" class="task_title"/>
|
||||
</treecell>
|
||||
<treecell>
|
||||
<textbox value="" ctrlKeys="#down#up#right#left" onCtrlKey="top.userWantsToMove(self,event);" onChange="top.updateBean();" onOK="top.userWantsDateBox(self);" />
|
||||
<datebox compact="true" onChange="top.updateBean();" visible="${false}" onBlur="top.dateBoxHasLostFocus(self);"/>
|
||||
</treecell>
|
||||
<treecell>
|
||||
<textbox ctrlKeys="#down#up#right#left" onCtrlKey="top.userWantsToMove(self,event);" value="" onChange="top.updateBean();" onOK="top.userWantsDateBox(self);"/>
|
||||
<datebox compact="true" onChange="top.updateBean();" visible ="${false}" onBlur="top.dateBoxHasLostFocus(self);" ctrlKeys="#down" onCtrlKey="top.userWantsDateBox(self)"/>
|
||||
</treecell>
|
||||
</treerow>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue