ItEr42S15SoporteImpresionMultiplesPaxinasItEr41S18: Show generic criterions in resource allocations next to the schedulled tasks

This commit is contained in:
Lorenzo Tilve 2010-01-07 10:16:31 +01:00 committed by Javier Moran Rua
parent 5a6fb6b1fe
commit 2db546c326
10 changed files with 116 additions and 36 deletions

View file

@ -380,23 +380,27 @@ public class Planner extends HtmlMacroComponent {
public void showAllLabels() {
Button showAllLabelsButton = (Button) getFellow("showAllLabels");
if (showAllLabelsButton.getSclass().equals("planner-command")) {
if (showAllLabelsButton.getSclass().equals(
"planner-command show-labels")) {
Clients.evalJavaScript("zkTasklist.showAllTooltips();");
showAllLabelsButton.setSclass("planner-command clicked");
showAllLabelsButton
.setSclass("planner-command show-labels clicked");
} else {
Clients.evalJavaScript("zkTasklist.hideAllTooltips();");
showAllLabelsButton.setSclass("planner-command");
showAllLabelsButton.setSclass("planner-command show-labels");
}
}
public void showAllResources() {
Button showAllLabelsButton = (Button) getFellow("showAllResources");
if (showAllLabelsButton.getSclass().equals("planner-command")) {
if (showAllLabelsButton.getSclass().equals(
"planner-command show-resources")) {
Clients.evalJavaScript("zkTasklist.showResourceTooltips();");
showAllLabelsButton.setSclass("planner-command clicked");
showAllLabelsButton
.setSclass("planner-command show-resources clicked");
} else {
Clients.evalJavaScript("zkTasklist.hideResourceTooltips();");
showAllLabelsButton.setSclass("planner-command");
showAllLabelsButton.setSclass("planner-command show-resources");
}
}

View file

@ -28,6 +28,7 @@ import java.util.List;
import org.zkoss.ganttz.util.WeakReferencedListeners;
import org.zkoss.ganttz.util.WeakReferencedListeners.IListenerNotification;
import org.zkoss.zk.ui.util.Clients;
/**
* This class contains the information of a task container. It can be modified
@ -174,6 +175,13 @@ public class TaskContainer extends Task {
}
});
}
refreshTooltips();
}
private void refreshTooltips() {
// Could be optimized asking planner for tooltips display state to
// create expanded elements with the proper state
Clients.evalJavaScript("zkTasklist.refreshTooltips();");
}
@Override

View file

@ -11,7 +11,9 @@
onMouseover="zkTasklist.showTooltip('tasktooltip${self.uuid}');"
onMouseOut="zkTasklist.hideTooltip('tasktooltip${self.uuid}');">
<div class="task-labels">${self.labelsText}</div>
<div class="task-resources">${self.resourcesText}</div>
<div class="task-resources">
<div class="task-resources-inner">${self.resourcesText}</div>
</div>
<div class="completion"></div>
<div class="completion2"></div>
<div id="tasktooltip${self.uuid}" class="task_tooltip">${self.tooltipText}</div>

View file

@ -8,12 +8,16 @@
<div id="${self.uuid}" z.type="ganttz.taskcontainer.TaskContainer" idTask="${self.id}"
z.autoz="true"${self.outerAttrs}" class="taskgroup">
<div class="task-labels">${self.labelsText}</div>
<div class="task-resources">${self.resourcesText}</div>
<div class="taskcontainer_completion">
<div class="task-resources">
<div class="task-resources-inner">${self.resourcesText}</div>
</div>
<div class="taskcontainer_completion">
<div class="completion"></div>
<div class="completion2"></div>
</div>
<div class="taskgroup_start"></div>
<div class="taskgroup_end"></div>
</div>
<div class="border-container">
<div class="taskgroup_start"></div>
<div class="taskgroup_end"></div>
</div>
</div>
</div>

View file

@ -33,10 +33,10 @@ planner = self;
label="${i18n:_('Critical path')}" />
<button id="showAllLabels" onClick="planner.showAllLabels();"
label="${i18n:_('Show all labels')}" class="planner-command" sclass="planner-command" />
label="${i18n:_('Show all labels')}" sclass="planner-command show-labels" />
<button id="showAllResources" onClick="planner.showAllResources();"
label="${i18n:_('Show all resources')}" class="planner-command" sclass="planner-command" />
label="${i18n:_('Show all resources')}" sclass="planner-command show-resources" />
<button id="btnPrint" onClick="planner.print()"
label="${i18n:_('Print')}" />

View file

@ -85,6 +85,19 @@ zkTasklist.hideResourceTooltips = function(elem) {
}
}
/* Refreshes
* Can be optimized creating the new tasks with
*/
zkTasklist.refreshTooltips = function(elem) {
var resourcesButton = YAHOO.util.Selector.query('.show-resources')[0];
if (resourcesButton.className.indexOf("clicked") != -1 ) {
zkTasklist.showResourceTooltips();
}
var resourcesButton = YAHOO.util.Selector.query('.show-labels')[0];
if (resourcesButton.className.indexOf("clicked") != -1 ) {
zkTasklist.showAllTooltips();
}
}
zkTasklist.hideTooltip = function(elem) {

View file

@ -55,4 +55,7 @@ public interface IResourceAllocationDAO extends
Map<Criterion, List<GenericResourceAllocation>> findGenericAllocationsByCriterionFor(
List<Task> task);
List<Criterion> findCriterionByResourceAllocation(
ResourceAllocation allocation);
}

View file

@ -123,6 +123,20 @@ public class ResourceAllocationDAO extends
return stripAllocationsWithoutAssignations(byCriterion(results));
}
@SuppressWarnings("unchecked")
@Override
public List<Criterion> findCriterionByResourceAllocation(
ResourceAllocation allocation) {
List<Criterion> results = getSession()
.createQuery(
"select criterion "
+ "from GenericResourceAllocation as generic "
+ "join generic.criterions as criterion where generic in(:allocation)")
.setParameter("allocation", allocation)
.list();
return results;
}
@SuppressWarnings("unchecked")
@Override
public Map<Criterion, List<GenericResourceAllocation>> findGenericAllocationsByCriterionFor(

View file

@ -43,10 +43,12 @@ import org.navalplanner.business.labels.entities.Label;
import org.navalplanner.business.orders.daos.IOrderElementDAO;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.planner.daos.IResourceAllocationDAO;
import org.navalplanner.business.planner.daos.ITaskElementDAO;
import org.navalplanner.business.planner.entities.Dependency;
import org.navalplanner.business.planner.entities.DerivedAllocation;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
import org.navalplanner.business.planner.entities.StartConstraintType;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
@ -54,6 +56,7 @@ import org.navalplanner.business.planner.entities.TaskMilestone;
import org.navalplanner.business.planner.entities.TaskStartConstraint;
import org.navalplanner.business.planner.entities.Dependency.Type;
import org.navalplanner.business.resources.daos.IResourceDAO;
import org.navalplanner.business.resources.entities.Criterion;
import org.navalplanner.business.resources.entities.Machine;
import org.navalplanner.business.resources.entities.MachineWorkersConfigurationUnit;
import org.navalplanner.business.resources.entities.Resource;
@ -112,6 +115,9 @@ public class TaskElementAdapter implements ITaskElementAdapter {
@Autowired
private IResourceDAO resourceDAO;
@Autowired
private IResourceAllocationDAO resourceAllocationDAO;
private List<IOnMoveListener> listeners = new ArrayList<IOnMoveListener>();
@Override
@ -419,23 +425,36 @@ public class TaskElementAdapter implements ITaskElementAdapter {
private String buildResourcesText() {
StringBuilder result = new StringBuilder();
List<Resource> foundResources = new ArrayList<Resource>();
if (taskElement.getResourceAllocations() != null) {
for (ResourceAllocation each : taskElement.getResourceAllocations()) {
List<Resource> list = each.getAssociatedResources();
if (!list.isEmpty()) {
for (Resource r : list) {
if (!foundResources.contains(r)) {
result.append(r.getName()).append(",");
foundResources.add(r);
if (each instanceof SpecificResourceAllocation) {
List<Resource> list = each.getAssociatedResources();
if (!list.isEmpty()) {
for (Resource r : list) {
if (!foundResources.contains(r)) {
result.append(r.getName()).append(", ");
foundResources.add(r);
}
}
}
} else {
List<Criterion> listCriterions = resourceAllocationDAO
.findCriterionByResourceAllocation(each);
result.append("[");
if (!listCriterions.isEmpty()) {
for (Criterion r : listCriterions) {
result.append(r.getName()).append(", ");
}
} else {
result.append(_("All workers")).append(", ");
}
result.delete(result.length() - 2, result.length());
result.append("], ");
}
}
}
if (result.length() > 1) {
result.delete(result.length() - 1, result.length());
result.delete(result.length() - 2, result.length());
}
}
return result.toString();

View file

@ -181,7 +181,6 @@ min-width:200px;
}
.taskgroup_start,.taskgroup_end {
position: relative;
top: -12px; /* zkTasklist.HEIGHT_PER_TASK */
}
@ -209,7 +208,7 @@ min-width:200px;
width: 10px;
position:absolute;
right:0;
top:-1px;
top:0;
}
.taskgroup,.row .expanded {
@ -220,9 +219,15 @@ min-width:200px;
background-color: transparent !important;
}
.box.expanded, .box.closed {
.border-container {
overflow:hidden;
padding-right:2px;
heigth: 12px !important;
position: relative;
top: -12px;
left:10;
display: block;
clear: both;
}
.milestone_end {
@ -599,9 +604,15 @@ div.z-tree {
left: 10px;
z-index: 6;
background-color: rgb(255, 202, 135);
background-color: rgba(255, 202, 135, 0.75);
background-color: rgba(255, 202, 135, 0.9);
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
padding: 0 3px;
}
.box.expanded .task-labels,
.box.expanded .task-resources {
display: none !important;
}
.task-labels span {
@ -611,17 +622,19 @@ div.z-tree {
.task-resources {
display: none;
float: right;
white-space: nowrap;
font-size: 9px;
position: relative;
color: #FFFFFF;
top: 8px;
top: -2px;
left: 10px;
z-index: 6;
background-color: rgb(170, 128, 213);
background-color: rgba(170, 128, 213, 0.75);
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
}
.task-resources-inner {
position: absolute;
left: 0px;
font-size: 9px;
white-space: nowrap;
color: #000000;
padding: 1px 3px;
}
.task-resources span {