// 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:   CreateTemplateDocumentURLActionDelegate.java

package com.ptc.windchill.pdmlink.doc.server.processors;

import com.ptc.core.HTMLtemplateutil.server.processors.WindowUtils;
import java.beans.PropertyChangeEvent;
import java.io.Externalizable;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import wt.fc.Persistable;
import wt.fc.ReferenceFactory;
import wt.httpgw.GatewayServletHelper;
import wt.introspection.PropertyDisplayName;
import wt.templateutil.processor.*;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;

// Referenced classes of package com.ptc.windchill.pdmlink.doc.server.processors:
//            CreateTemplateDocument1ActionDelegate

public class CreateTemplateDocumentURLActionDelegate extends CreateTemplateDocument1ActionDelegate
    implements NavBarURLActionDelegate, Externalizable
{

    public CreateTemplateDocumentURLActionDelegate()
    {
        actionName = null;
        classURL = null;
        helper = null;
        helper = new NavBarURLActionDelegateHelper();
    }

    public boolean isURLProvider(HashMap queryValueMap, Object object)
    {
        return helper.isURLProvider(queryValueMap, object);
    }

    public void setResourceKey(String key)
    {
        helper.setResourceKey(key);
    }

    public void setResourceBundleStr(String resourceBundle)
    {
        helper.setResourceBundleStr(resourceBundle);
    }

    public void setState(HTTPState state)
    {
        helper.setState(state);
    }

    public void setMethod(String method)
    {
        helper.setMethod(method);
    }

    public String getClassURL()
    {
        return classURL;
    }

    public void setClassURL(String a_ClassURL)
        throws WTPropertyVetoException
    {
        classURLValidate(a_ClassURL);
        classURL = a_ClassURL;
    }

    private void classURLValidate(String a_ClassURL)
        throws WTPropertyVetoException
    {
        if(a_ClassURL != null && a_ClassURL.length() > 200)
        {
            Object args[] = {
                new PropertyDisplayName(CLASSNAME, "classURL"), "200"
            };
            throw new WTPropertyVetoException("wt.introspection.introspectionResource", "20", args, new PropertyChangeEvent(this, "classURL", classURL, a_ClassURL));
        } else
        {
            return;
        }
    }

    public String URL(Object object)
        throws WTException
    {
        String gwUrl = null;
        if(enableable(object).booleanValue())
            try
            {
                wt.httpgw.URLFactory urlFactory = getState().getURLFactory();
                HashMap map = new HashMap();
                map.put("action", "CreateTemplateDocumentGeneral");
                ReferenceFactory rf = new ReferenceFactory();
                String oidStr = rf.getReferenceString((Persistable)object);
                map.put("oid", oidStr);
                URL url = GatewayServletHelper.buildAuthenticatedURL(urlFactory, "wt.enterprise.URLProcessor", "generateForm", map);
                String gwURL = url.toExternalForm();
                gwUrl = getLaunchWindowURLWrapper(gwURL, "createTemplateDocWindow", 700, 500);
            }
            catch(Exception e)
            {
                throw new WTException(CLASSNAME + ".URL() - exception creating link to " + "CreateTemplateDocumentGeneral");
            }
        return gwUrl;
    }

    public static String getLaunchWindowURLWrapper(String url, String windowName, int width, int height)
    {
        String props = "directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes";
        return WindowUtils.getLaunchWindowURLWrapper(url, windowName, "launchWindow", width, height, props);
    }

    public String getURLLabel(Locale locale)
    {
        return helper.getURLLabel(locale);
    }

    public void setActionName(String action)
    {
        try
        {
            helper.setActionName(action);
        }
        catch(WTPropertyVetoException wpve)
        {
            wpve.printStackTrace();
        }
    }

    public String getActionName()
    {
        return helper.getActionName();
    }

    public HTTPState getState()
    {
        return helper.getState();
    }

    static Class _mthclass$(String x0)
    {
        return Class.forName(x0);
        ClassNotFoundException x1;
        x1;
        throw (new NoClassDefFoundError()).initCause(x1);
    }

    private static final String RESOURCE = "com.ptc.windchill.pdmlink.doc.server.processors.processorsResource";
    private static final String CLASSNAME;
    private String actionName;
    private String classURL;
    protected NavBarURLActionDelegateHelper helper;

    static 
    {
        CLASSNAME = (com.ptc.windchill.pdmlink.doc.server.processors.CreateTemplateDocumentURLActionDelegate.class).getName();
    }
}
