// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) deadcode 
// Source File Name:   TutorialMenuBuilder.java

package com.ptc.windchill.enterprise.tutorials.server;

import java.io.PrintStream;
import java.util.*;

public class TutorialMenuBuilder
{

    public TutorialMenuBuilder()
    {
    }

    public String createTutorialMenus(Vector menus, String processDirectory)
    {
        StringBuffer sb = new StringBuffer();
        int i = 0;
        for(Enumeration e = menus.elements(); e.hasMoreElements(); sb.append(processMenu((HashMap)e.nextElement(), processDirectory)))
        {
            sb.append(",");
            sb.append("\n");
        }

        return sb.toString();
    }

    private String processMenu(HashMap menu, String processDirectory)
    {
        StringBuffer sb = new StringBuffer("new tutorialMenu(");
        String level = (String)menu.get("Level");
        String parent = (String)menu.get("Parent");
        String label = (String)menu.get("Label");
        String resource = (String)menu.get("Resource");
        if(level != null)
        {
            sb.append("\"" + level + "\",");
            if(parent != null)
                sb.append("\"" + parent + "\",");
            else
                sb.append("\"" + processDirectory + "mainMenu\",");
            if(label != null)
            {
                sb.append("\"" + label + "\"");
            } else
            {
                System.err.println("There was no Label specified for Resource " + resource);
                return null;
            }
            if(resource != null)
                sb.append(",\"" + resource + "\"");
        } else
        {
            System.err.println("There was no level specified for " + label);
            return null;
        }
        sb.append(")");
        return sb.toString();
    }
}
