ItEr15S12RFComportamentoGraficoPlanificadorItEr14S13: TaskContainer component support added to plannificator view

* The structure for this entity has been created
   * Basic implementation relays on Task and an empty TascContainerBean
   * For visual presentation the same task div is used with background images for the corners and restyled classes.
This commit is contained in:
Lorenzo Tilve 2009-07-01 17:42:47 +02:00 committed by Javier Moran Rua
parent 39a98934fc
commit 309d895e96
14 changed files with 236 additions and 9 deletions

View file

@ -7,6 +7,7 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.zkoss.ganttz.util.TaskBean;
import org.zkoss.ganttz.util.TaskContainerBean;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.HtmlMacroComponent;
@ -56,6 +57,16 @@ public class ListDetails extends HtmlMacroComponent {
getPlanner().addTask(newTask);
}
public void addTaskContainer() {
TaskContainerBean newTask = new TaskContainerBean();
newTask.setName("Novo Contedor de Tarefas");
newTask.setBeginDate(new Date());
newTask.setEndDate(threeMonthsLater(newTask.getBeginDate()));
TaskDetail newDetail = addTask(newTask);
newDetail.receiveFocus();
getPlanner().addTaskContainer(newTask);
}
private static Date threeMonthsLater(Date now) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
@ -83,4 +94,4 @@ public class ListDetails extends HtmlMacroComponent {
return getFellow("insertionPoint");
}
}
}

View file

@ -5,6 +5,7 @@ import java.util.List;
import org.zkoss.ganttz.util.DependencyRegistry;
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.ext.AfterCompose;
@ -127,6 +128,11 @@ public class Planner extends XulElement implements AfterCompose {
dependencyRegistry.add(newTask);
}
public void addTaskContainer(TaskContainerBean newTaskContainer) {
getTaskList().addTaskContainer(newTaskContainer);
dependencyRegistry.add(newTaskContainer);
}
private void publishDependency(Dependency dependency) {
dependencyRegistry.add(dependency.getDependencyBean());
}

View file

@ -0,0 +1,23 @@
package org.zkoss.ganttz;
import org.zkoss.ganttz.util.TaskContainerBean;
import org.zkoss.zk.ui.ext.AfterCompose;
/**
* This class contains the information of a task container. It can be modified and
* notifies of the changes to the interested parties. <br/>
* Created at Jul 1, 2009
*
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
*
*/
public class TaskContainer extends Task implements AfterCompose {
public static TaskContainer asTask(TaskContainerBean taskContainerBean) {
return new TaskContainer(taskContainerBean);
}
public TaskContainer(TaskContainerBean taskContainerBean) {
super(taskContainerBean);
}
}

View file

@ -18,6 +18,7 @@ import org.zkoss.ganttz.util.MenuBuilder;
import org.zkoss.ganttz.util.TaskBean;
import org.zkoss.ganttz.util.WeakReferencedListeners;
import org.zkoss.ganttz.util.MenuBuilder.ItemAction;
import org.zkoss.ganttz.util.TaskContainerBean;
import org.zkoss.ganttz.util.WeakReferencedListeners.ListenerNotification;
import org.zkoss.ganttz.util.zoom.ZoomLevel;
import org.zkoss.ganttz.util.zoom.ZoomLevelChangedListener;
@ -79,6 +80,10 @@ public class TaskList extends XulElement implements AfterCompose {
addTask(Task.asTask(newTask), true);
}
public void addTaskContainer(TaskContainerBean newTaskContainer) {
addTask(TaskContainer.asTask(newTaskContainer), true);
}
public synchronized void addTask(final Task task, boolean relocate) {
task.setParent(this);
addContextMenu(task);

View file

@ -0,0 +1,13 @@
package org.zkoss.ganttz.util;
/**
* This class contains the information of a task container. It can be modified and
* notifies of the changes to the interested parties. <br/>
* Created at Jul 1, 2009
*
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
*
*/
public class TaskContainerBean extends TaskBean {
}

View file

@ -50,6 +50,15 @@
</mold>
</component>
<component>
<component-name>taskcontainer</component-name>
<component-class>org.zkoss.ganttz.TaskContainer</component-class>
<mold>
<mold-name>default</mold-name>
<mold-uri>~./ganttz/taskcontainer.dsp</mold-uri>
</mold>
</component>
<component>
<component-name>tasklist</component-name>
<component-class>org.zkoss.ganttz.TaskList</component-class>

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

View file

@ -0,0 +1,14 @@
<%@ taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" %>
<%@ taglib uri="http://www.zkoss.org/dsp/zk/core" prefix="z" %>
<c:set var="self" value="${requestScope.arg.self}"/>
<div id="row${self.uuid}" class="row" z.valor="boxid="${self.uuid}">
<div id="${self.uuid}" z.type="ganttz.taskcontainer.TaskContainer" idTask="${self.id}"
z.autoz="true"${self.outerAttrs}" class="taskgroup">
<div class="taskgroup_start"></div>
<div class="taskgroup_end"></div>
</div>
</div>

View file

@ -2,8 +2,12 @@
<zk xmlns:n="http://www.zkoss.org/2005/zk/native">
<button label="${c:l('listdetails.add_task')}"
onClick="insertionPoint.getParent().getParent().addTask();" />
<button label="Engadir Contedor"
onClick="self.getParent().addTaskContainer();" />
<n:div id="listdetails_container">
<vbox class="listdetails" id="insertionPoint">
</vbox>
</n:div>
</zk>
</zk>

View file

@ -1,6 +1,6 @@
/**
*
* ganttz.js
* task.js
*
*/
@ -139,11 +139,12 @@ zkTask.addDependency = function(cmp) {
};
zkTask.setAttr = function(cmp, name, value) {
if ("name" == name) {
var span = YAHOO.util.Selector.query("span", cmp, true);
span.innerHTML = value;
return true;
}
// Obsolete as far as tasks will not show name inside
// if ("name" == name) {
// var span = YAHOO.util.Selector.query("span", cmp, true);
// span.innerHTML = value;
// return true;
// }
return false;
}
@ -210,6 +211,9 @@ zkTask.isOverTask = function(cmp, arrow) {
arrayTasks = zkTask.getElementsByAttribute(
listtasksNode, "div", "z.type","ganttz.task.Task");
arrayTasks = arrayTasks.concat(
zkTask.getElementsByAttribute(listtasksNode, "div", "z.type",
"ganttz.taskcontainer.TaskContainer" ) );
var xpos = zkTask.xMouse - ganttPanelNode.offsetLeft + ganttPanelNode.scrollLeft;
var ypos = zkTask.yMouse - ganttPanelNode.offsetTop + ganttPanelNode.scrollTop

View file

@ -0,0 +1,116 @@
/**
*
* taskContainer.js
*
*/
zkTaskContainer = {};
zkTaskContainer.getDD = function(cmp) {
zkTask.getDD(cmp);
};
zkTaskContainer.relocateAfterAdding = function(cmp) {
zkTask.relocateAfterAdding (cmp);
};
zkTaskContainer.cleanup = function(cmp){
zkTask.cleanup(cmp);
};
zkTaskContainer.init = function(cmp) {
zkTask.init(cmp);
};
zkTaskContainer.xMouse;
zkTaskContainer.yMouse;
// Listen to mousemove events
YAHOO.util.Event.on(document.body, 'mousemove', function(e) {
var arrPos = YAHOO.util.Event.getXY(e);
zkTaskContainer.xMouse = arrPos[0];
zkTaskContainer.yMouse = arrPos[1];
});
zkTaskContainer.setAttr = function(cmp, nm, val) {
zkTask.setAttr(cmp, nm, val);
};
zkTaskContainer.addDependency = function(cmp) {
zkTask.addDependency(cmp);
};
zkTaskContainer.setAttr = function(cmp, name, value) {
zkTask.setAttr(cmp, name, value);
};
zkTaskContainer.addRelatedDependency = function(cmp, dependency) {
zkTask.addRelatedDependency(cmp, dependency);
};
/* Dependencies with origin in a task container will be redrawn with a
* different algorithm */
zkTaskContainer.createArrow = function(cmp) {
zkTask.createArrow(cmp)
};
zkTaskContainer.isOverTask = function(cmp, arrow) {
zkTask.isOverTask(cmp, arrow);
};
zkTaskContainer.getElementsByAttribute = function(oElm, strTagName, strAttributeName,
strAttributeValue) {
zkTask.getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue);
}
YAHOO.example.DDRegion = function(id, sGroup, config) {
this.cont = config.cont;
YAHOO.example.DDRegion.superclass.constructor.apply(this, arguments);
};
var myDom = YAHOO.util.Dom, myEvent = YAHOO.util.Event
YAHOO.extend(YAHOO.example.DDRegion, YAHOO.util.DD, {
cont : null,
init : function() {
//Call the parent's init method
YAHOO.example.DDRegion.superclass.init.apply(this, arguments);
this.initConstraints();
myEvent.on(window, 'resize', function() {
this.initConstraints();
}, this, true);
},
initConstraints : function() {
//Get the top, right, bottom and left positions
var region = myDom.getRegion(this.cont);
// Get the element we are working on
var el = this.getEl();
// Get the xy position of it
var xy = myDom.getXY(el);
// Get the width and height
var width = parseInt(myDom.getStyle(el, 'width'), 10);
var height = parseInt(myDom.getStyle(el, 'height'), 10);
// Set left to x minus left
var left = xy[0] - region.left;
// Set right to right minus x minus width
var right = region.right - xy[0] - width;
// Set top to y minus top
var top = xy[1] - region.top;
// Set bottom to bottom minus y minus height
var bottom = region.bottom - xy[1] - height;
// Set the constraints based on the above calculations
this.setXConstraint(left, right);
this.setYConstraint(top, bottom);
}
});

View file

@ -61,4 +61,4 @@ public class DataForPlanner {
calendar.add(Calendar.MONTH, 2);
return calendar.getTime();
}
}
}

View file

@ -81,6 +81,28 @@ HEIGHT_TIME_TRACKER = 120;
width: 1800px;
}
/* ---------- TaskGroup --------- */
.taskgroup_start {
background-image: url("/navalplanner-webapp/zkau/web/ganttz/img/group_left.png");
height: 10px;
width: 10px;
float:left;
}
.taskgroup_end {
background-image: url("../../zkau/web/ganttz/img/group_right.png");
height: 10px;
width: 10px;
float:right;
}
.taskgroup {
border-top: solid black 2px;
border-bottom: 0px;
border-left: 0px;
border-right: 0px;
background-color: transparent !important;
}
/****** Dependencies *******/
#listdependencies {