ItEr44S09SoporteImpresionMultiplesPaxinasItEr43S10: Calculating the tasks number based on the expanded parameter.
Limiting the padding too.
This commit is contained in:
parent
7ec09e6f59
commit
6a769de3fa
2 changed files with 32 additions and 7 deletions
|
|
@ -25,10 +25,12 @@ import static org.zkoss.ganttz.i18n.I18nHelper._;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
|
||||
import org.zkoss.ganttz.adapters.PlannerConfiguration;
|
||||
|
|
@ -70,6 +72,20 @@ public class Planner extends HtmlMacroComponent {
|
|||
.retrieve();
|
||||
}
|
||||
|
||||
public static boolean guessContainersExpandedByDefaultGivenPrintParameters(
|
||||
Map<String, String> printParameters) {
|
||||
return guessContainersExpandedByDefault(convertToURLParameters(printParameters));
|
||||
}
|
||||
|
||||
private static Map<String, String[]> convertToURLParameters(
|
||||
Map<String, String> printParameters) {
|
||||
Map<String, String[]> result = new HashMap<String, String[]>();
|
||||
for (Entry<String, String> each : printParameters.entrySet()) {
|
||||
result.put(each.getKey(), new String[] { each.getValue() });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean guessContainersExpandedByDefault(
|
||||
Map<String, String[]> queryURLParameters) {
|
||||
String[] values = queryURLParameters.get("expanded");
|
||||
|
|
@ -125,6 +141,10 @@ public class Planner extends HtmlMacroComponent {
|
|||
return getTaskList().getTasksNumber();
|
||||
}
|
||||
|
||||
public int getAllTasksNumber() {
|
||||
return diagramGraph.getTasks().size();
|
||||
}
|
||||
|
||||
public String getContextPath() {
|
||||
return Executions.getCurrent().getContextPath();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class CutyPrint {
|
|||
// Taskdetails left padding
|
||||
private static int TASKDETAILS_WIDTH = 310;
|
||||
private static int TASK_HEIGHT = 25;
|
||||
private static int PRINT_VERTICAL_PADDING = 1500;
|
||||
private static int PRINT_VERTICAL_PADDING = 50;
|
||||
|
||||
public static void print(Order order) {
|
||||
print("/planner/index.zul", entryPointForShowingOrder(order),
|
||||
|
|
@ -148,9 +148,14 @@ public class CutyPrint {
|
|||
// Static width and time delay parameters (FIX)
|
||||
captureString += " --delay=3000 ";
|
||||
|
||||
String generatedCSSFile = createCSSFile(absolutePath
|
||||
+ "/planner/css/print.css", plannerWidth, planner, parameters
|
||||
.get("labels"), parameters.get("resources"));
|
||||
String generatedCSSFile = createCSSFile(
|
||||
absolutePath + "/planner/css/print.css",
|
||||
plannerWidth,
|
||||
planner,
|
||||
parameters.get("labels"),
|
||||
parameters.get("resources"),
|
||||
Planner
|
||||
.guessContainersExpandedByDefaultGivenPrintParameters(parameters));
|
||||
|
||||
// Relative user styles
|
||||
captureString += "--user-styles=" + generatedCSSFile;
|
||||
|
|
@ -198,7 +203,6 @@ public class CutyPrint {
|
|||
}
|
||||
|
||||
private static String heightCSS(int tasksNumber) {
|
||||
|
||||
int height = (tasksNumber * TASK_HEIGHT) + PRINT_VERTICAL_PADDING;
|
||||
String heightCSS = "";
|
||||
heightCSS += " body div#scroll_container { height: " + height
|
||||
|
|
@ -213,7 +217,7 @@ public class CutyPrint {
|
|||
}
|
||||
|
||||
private static String createCSSFile(String srFile, int width,
|
||||
Planner planner, String labels, String resources) {
|
||||
Planner planner, String labels, String resources, boolean expanded) {
|
||||
File generatedCSS = null;
|
||||
try {
|
||||
generatedCSS = File.createTempFile("print", ".css");
|
||||
|
|
@ -236,7 +240,8 @@ public class CutyPrint {
|
|||
if ((resources != null) && (resources.equals("all"))) {
|
||||
includeCSSLines += " .task-resources { display: inline !important;} \n";
|
||||
}
|
||||
includeCSSLines += heightCSS(planner.getTaskNumber());
|
||||
includeCSSLines += heightCSS(expanded ? planner.getAllTasksNumber()
|
||||
: planner.getTaskNumber());
|
||||
|
||||
out.write(includeCSSLines.getBytes());
|
||||
in.close();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue