ItEr42S17CUGravacionModelosUnidadesTraballoItEr41S20: Building treecols from Columns.
This allows to parametrize the columns shown for each case.
This commit is contained in:
parent
3cf3fd1199
commit
29d6e7a886
4 changed files with 71 additions and 26 deletions
|
|
@ -19,6 +19,11 @@
|
|||
*/
|
||||
package org.navalplanner.web.orders;
|
||||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.web.tree.TreeComponent;
|
||||
|
||||
/**
|
||||
|
|
@ -27,5 +32,17 @@ import org.navalplanner.web.tree.TreeComponent;
|
|||
*/
|
||||
public class OrdersTreeComponent extends TreeComponent {
|
||||
|
||||
public List<Column> getColumns() {
|
||||
List<Column> columns = new ArrayList<Column>();
|
||||
columns.add(new Column(_("Scheduling state"), "scheduling_state"));
|
||||
columns.add(codeColumn);
|
||||
columns.add(new Column(_("Hours"), "hours",
|
||||
_("Total order element hours")));
|
||||
columns.add(nameAndDescriptionColumn);
|
||||
columns.add(new Column(_("Must start after"), "estimated_init"));
|
||||
columns.add(new Column(_("Deadline"), "estimated_end"));
|
||||
columns.add(operationsColumn);
|
||||
return columns;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ package org.navalplanner.web.templates;
|
|||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.web.tree.TreeComponent;
|
||||
|
|
@ -44,12 +44,15 @@ public class TemplatesTreeComponent extends TreeComponent {
|
|||
return _("Delete Template element");
|
||||
}
|
||||
|
||||
public String getHoursTooltip() {
|
||||
return _("Total Template hours");
|
||||
}
|
||||
|
||||
public String getOperationsTooltip() {
|
||||
return _("Click on the icons to execute operation in the template");
|
||||
@Override
|
||||
public List<Column> getColumns() {
|
||||
List<Column> result = new ArrayList<Column>();
|
||||
result.add(codeColumn);
|
||||
result.add(nameAndDescriptionColumn);
|
||||
result.add(new Column(_("Must start after"), "estimated_init"));
|
||||
result.add(new Column(_("Deadline"), "estimated_end"));
|
||||
result.add(operationsColumn);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ package org.navalplanner.web.tree;
|
|||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.web.orders.OrderElementTreeController;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zk.ui.util.Composer;
|
||||
|
|
@ -29,17 +31,55 @@ import org.zkoss.zk.ui.util.Composer;
|
|||
* macro component for order elements tree and similar pages<br />
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public class TreeComponent extends HtmlMacroComponent {
|
||||
public abstract class TreeComponent extends HtmlMacroComponent {
|
||||
|
||||
private static final String CONTROLLER_NAME = "treeController";
|
||||
|
||||
public static class Column {
|
||||
private String label;
|
||||
|
||||
private String cssClass;
|
||||
|
||||
private String tooltip;
|
||||
|
||||
public Column(String label, String cssClass){
|
||||
this(label, cssClass, null);
|
||||
}
|
||||
|
||||
public Column(String label, String cssClass, String tooltip) {
|
||||
this.label = label;
|
||||
this.cssClass = cssClass;
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String getCssClass() {
|
||||
return cssClass;
|
||||
}
|
||||
|
||||
public String getTooltip() {
|
||||
return tooltip;
|
||||
}
|
||||
}
|
||||
|
||||
protected final Column codeColumn = new Column(_("Code"), "code");
|
||||
protected final Column nameAndDescriptionColumn = new Column(
|
||||
_("Name and description"), "name");
|
||||
protected final Column operationsColumn = new Column(_("Operations"),
|
||||
"operations");
|
||||
|
||||
public abstract List<Column> getColumns();
|
||||
|
||||
public void clear() {
|
||||
OrderElementTreeController controller = (OrderElementTreeController) getVariable(
|
||||
CONTROLLER_NAME, true);
|
||||
controller.clear();
|
||||
}
|
||||
|
||||
public void useController(Composer controller) {
|
||||
public void useController(TreeController<?> controller) {
|
||||
doAfterComposeOnController(controller);
|
||||
this.setVariable(CONTROLLER_NAME, controller, true);
|
||||
}
|
||||
|
|
@ -64,12 +104,4 @@ public class TreeComponent extends HtmlMacroComponent {
|
|||
return _("Delete order element");
|
||||
}
|
||||
|
||||
public String getHoursTooltip() {
|
||||
return _("Total order element hours");
|
||||
}
|
||||
|
||||
public String getOperationsTooltip() {
|
||||
return _("Click on the icons to execute operation in the order element");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,15 +54,8 @@
|
|||
sclass="orderTree"
|
||||
zclass="z-dottree">
|
||||
<treecols sizable="true">
|
||||
<treecol label="${i18n:_('Scheduling state')}" class="scheduling_state"/>
|
||||
<treecol label="${i18n:_('Code')}" class="code"/>
|
||||
<treecol label="${i18n:_('Hours')}" class="hours"
|
||||
tooltiptext="${treeComponent.hoursTooltip}" />
|
||||
<treecol label="${i18n:_('Name and description')}" class="name"/>
|
||||
<treecol label="${i18n:_('Must start after')}" class="estimated_init"/>
|
||||
<treecol label="${i18n:_('Deadline')}" class="estimated_end"/>
|
||||
<treecol label="${i18n:_('Operations')}" class="operations"
|
||||
tooltiptext="${treeComponent.operationsTooltip}"/>
|
||||
<treecol label="${each.label}" class="${each.cssClass}" tooltiptext="${each.tooltip}"
|
||||
forEach="${treeComponent.columns}"/>
|
||||
</treecols>
|
||||
</tree>
|
||||
</vbox>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue