ItEr29S08CUCreacionProxectoPlanificacionItEr28S09: LeftPane no longer has global commands. They are inserted in plannerLayout.zul instead.

This commit is contained in:
Óscar González Fernández 2009-10-05 18:23:09 +02:00
parent 4b77e4a17e
commit 9410c3e976
4 changed files with 30 additions and 31 deletions

View file

@ -27,7 +27,6 @@ import org.zkoss.ganttz.data.Position;
import org.zkoss.ganttz.data.Task;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.HtmlMacroComponent;
import org.zkoss.zul.Button;
/**
* LeftPane of the planner. Responsible of showing global commands and the
@ -38,8 +37,6 @@ public class LeftPane extends HtmlMacroComponent {
private final List<Task> topLevelTasks;
private List<? extends CommandContextualized<?>> commands;
private LeftTasksTree leftTasksTree;
public void setGoingDownInLastArrowCommand(
@ -48,10 +45,7 @@ public class LeftPane extends HtmlMacroComponent {
.setGoingDownInLastArrowCommand(goingDownInLastArrowCommand);
}
public LeftPane(
List<? extends CommandContextualized<?>> contextualizedCommands,
List<Task> topLevelTasks) {
this.commands = contextualizedCommands;
public LeftPane(List<Task> topLevelTasks) {
this.topLevelTasks = topLevelTasks;
}
@ -59,30 +53,15 @@ public class LeftPane extends HtmlMacroComponent {
public void afterCompose() {
super.afterCompose();
leftTasksTree = new LeftTasksTree(topLevelTasks);
addCommands();
getContainer().appendChild(leftTasksTree);
leftTasksTree.afterCompose();
}
private void addCommands() {
Component commandsContainer = getCommandsContainer();
for (CommandContextualized<?> command : commands) {
Button button = command.toButton();
commandsContainer.appendChild(button);
}
}
private Component getContainer() {
Component commandsContainer = getCommandsContainer();
Component container = commandsContainer.getParent();
Component container = getFellow("listdetails_container");
return container;
}
private Component getCommandsContainer() {
Component commandsContainer = getFellow("leftpane_commands");
return commandsContainer;
}
public void taskRemoved(Task task) {
leftTasksTree.taskRemoved(task);
}

View file

@ -36,8 +36,10 @@ import org.zkoss.ganttz.extensions.IContext;
import org.zkoss.ganttz.util.ComponentsFinder;
import org.zkoss.ganttz.util.OnZKDesktopRegistry;
import org.zkoss.ganttz.util.script.IScriptsRegister;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.HtmlMacroComponent;
import org.zkoss.zul.Separator;
public class Planner extends HtmlMacroComponent {
@ -188,12 +190,35 @@ public class Planner extends HtmlMacroComponent {
}
private void setupComponents() {
this.leftPane = new LeftPane(contextualizedGlobalCommands,
this.diagramGraph.getTopLevelTasks());
insertGlobalCommands();
this.leftPane = new LeftPane(this.diagramGraph.getTopLevelTasks());
this.ganttPanel = new GanttPanel(this.context,
commandsOnTasksContextualized, editTaskCommand);
}
private void insertGlobalCommands() {
Component toolbar = getToolbar();
Component firstSeparator = getFirstSeparatorFromToolbar();
for (CommandContextualized<?> c : contextualizedGlobalCommands) {
toolbar.insertBefore(c.toButton(), firstSeparator);
}
}
@SuppressWarnings("unchecked")
private Component getFirstSeparatorFromToolbar() {
Component toolbar = getToolbar();
List<Component> children = toolbar.getChildren();
List<Separator> separators = ComponentsFinder
.findComponentsOfType(
Separator.class, children);
return separators.get(0);
}
private Component getToolbar() {
Component toolbar = getFellow("toolbar");
return toolbar;
}
void removeTask(Task task) {
TaskList taskList = getTaskList();
taskList.remove(task);

View file

@ -20,7 +20,5 @@
<zk xmlns:n="http://www.zkoss.org/2005/zk/native">
<n:div id="listdetails_container">
<hbox id="leftpane_commands">
</hbox>
</n:div>
</zk>

View file

@ -5,10 +5,7 @@ planner = self;
</zscript>
<borderlayout sclass="plannerlayout" width="auto">
<north height="30px" border="0">
<hbox align="center">
<button label="Save" />
<button label="Back" />
<button label="Company view" />
<hbox align="center" id="toolbar">
<separator/>
<button label="+" onClick="planner.zoomIncrease();"/>
<button label="-" onClick="planner.zoomDecrease();"/>