Search in sources :

Example 1 with SizePerItemTable

use of net.sourceforge.processdash.tool.probe.SizePerItemTable in project processdash by dtuma.

the class SizeEstimatingTemplate2 method initSizeTypeData.

private void initSizeTypeData() {
    StringBuffer options = new StringBuffer("<option>\n");
    StringBuffer sizeData = new StringBuffer("<script>DashSET.itemSizes = { \n");
    String sizeUnits = new ProcessUtil(getDataContext()).getSizeUnits();
    SortedMap<String, SizePerItemTable> tables = SizePerItemTable.getDefinedTables(getDataRepository(), sizeUnits);
    for (Entry<String, SizePerItemTable> e : tables.entrySet()) {
        String sizePerItemTableName = e.getKey();
        SizePerItemTable sizePerItemTable = e.getValue();
        String valuePrefix = getCategoryValuePrefix(sizePerItemTableName);
        options.append("<optgroup label=\"").append(esc(sizePerItemTableName)).append("\">\n");
        for (String category : sizePerItemTable.getCategoryNames()) {
            String fullCat = valuePrefix + category;
            options.append("<option value=\"").append(esc(fullCat)).append("\">").append(esc(category)).append("\n");
            for (RelativeSize relSize : RelativeSize.values()) {
                sizeData.append('"').append(StringUtils.javaEncode(fullCat)).append("/").append(REL_SIZE_NAMES[relSize.ordinal()]).append("\" : ").append(sizePerItemTable.getSize(category, relSize)).append(",\n");
            }
        }
        options.append("</optgroup>\n");
    }
    if (tables.isEmpty()) {
        String messageHtml = resources.getHTML("SizePerItem.Errors.No_Types_Message");
        String tooltip = resources.format("SizePerItem.Errors.No_Types_Tooltip_FMT", sizeUnits);
        options.append("<option value=\"-\" title=\"").append(esc(tooltip)).append("\">").append(messageHtml).append("\n");
    }
    sizeData.setLength(sizeData.length() - 2);
    sizeData.append(" };\n");
    if (USE_COMMA)
        sizeData.append("DashSET.useCommaForDecimal = true;\n");
    if (freezePlan || Settings.getBool("sizeEst.disableBasePartsGraph", false))
        sizeData.append("DashSET.disableBasePartsGraph = true;\n");
    sizeData.append("</script>\n");
    this.sizeTypeInit = sizeData.toString();
    this.sizeTypeOptions = options.toString();
}
Also used : SizePerItemTable(net.sourceforge.processdash.tool.probe.SizePerItemTable) RelativeSize(net.sourceforge.processdash.tool.probe.SizePerItemTable.RelativeSize) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil)

Aggregations

ProcessUtil (net.sourceforge.processdash.process.ProcessUtil)1 SizePerItemTable (net.sourceforge.processdash.tool.probe.SizePerItemTable)1 RelativeSize (net.sourceforge.processdash.tool.probe.SizePerItemTable.RelativeSize)1