ItEr37S18CUCalculoCaminhoCriticoItEr36S20: Added one button on planner to show and hide the critical path.
This commit is contained in:
parent
b1535f7c92
commit
4df4c8201c
7 changed files with 49 additions and 7 deletions
|
|
@ -336,8 +336,19 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
public void showCriticalPath() {
|
||||
List<Task> criticalPath = new CriticalPathCalculator<Task>()
|
||||
.calculateCriticalPath(diagramGraph);
|
||||
for (Task task : criticalPath) {
|
||||
task.setInCriticalPath(true);
|
||||
for (Task task : diagramGraph.getTasks()) {
|
||||
if (criticalPath.contains(task)) {
|
||||
task.setInCriticalPath(true);
|
||||
} else {
|
||||
task.setInCriticalPath(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideCriticalPath() {
|
||||
for (Task task : diagramGraph.getTasks()) {
|
||||
task.setInCriticalPath(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import org.zkoss.zk.ui.Component;
|
|||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zul.Separator;
|
||||
import org.zkoss.zul.api.Button;
|
||||
|
||||
public class Planner extends HtmlMacroComponent {
|
||||
|
||||
|
|
@ -65,6 +66,8 @@ public class Planner extends HtmlMacroComponent {
|
|||
|
||||
private transient IDisabilityConfiguration disabilityConfiguration;
|
||||
|
||||
private boolean isShowingCriticalPath = false;
|
||||
|
||||
public Planner() {
|
||||
registerNeededScripts();
|
||||
}
|
||||
|
|
@ -175,8 +178,9 @@ public class Planner extends HtmlMacroComponent {
|
|||
setAt("insertionPointChart", chartComponent);
|
||||
}
|
||||
|
||||
if (configuration.isCriticalPathEnabled()) {
|
||||
this.context.showCriticalPath();
|
||||
if (!configuration.isCriticalPathEnabled()) {
|
||||
Button showCriticalPathButton = (Button) getFellow("showCriticalPath");
|
||||
showCriticalPathButton.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,4 +294,15 @@ public class Planner extends HtmlMacroComponent {
|
|||
return ganttPanel.getTimeTracker();
|
||||
}
|
||||
|
||||
public void showCriticalPath() {
|
||||
if (disabilityConfiguration.isCriticalPathEnabled()) {
|
||||
if (isShowingCriticalPath) {
|
||||
context.hideCriticalPath();
|
||||
} else {
|
||||
context.showCriticalPath();
|
||||
}
|
||||
isShowingCriticalPath = !isShowingCriticalPath;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,9 +228,7 @@ public class TaskComponent extends Div implements AfterCompose {
|
|||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (task.isInCriticalPath()) {
|
||||
updateClass();
|
||||
}
|
||||
updateClass();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -97,4 +97,9 @@ public class ContextRelativeToOtherComponent<T> implements IContext<T> {
|
|||
context.showCriticalPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideCriticalPath() {
|
||||
context.hideCriticalPath();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,4 +100,9 @@ public class ContextWithPlannerTask<T> implements IContextWithPlannerTask<T> {
|
|||
context.showCriticalPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideCriticalPath() {
|
||||
context.hideCriticalPath();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,4 +110,9 @@ public interface IContext<T> {
|
|||
*/
|
||||
void showCriticalPath();
|
||||
|
||||
/**
|
||||
* Hides the critical path in the planner.
|
||||
*/
|
||||
void hideCriticalPath();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ planner = self;
|
|||
<comboitem label="Critical way" />
|
||||
</combobox>
|
||||
<textbox/>
|
||||
<separator />
|
||||
<button id="showCriticalPath" onClick="planner.showCriticalPath();"
|
||||
label="${i18n:_('Critical path')}" />
|
||||
|
||||
</hbox>
|
||||
</north>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue