// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:06:16
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/commands/ListCommand

package com.macromedia.generator.commands;

import com.macromedia.generator.api.*;
import com.macromedia.generator.app.*;
import java.util.*;

public class ListCommand extends GenericCommand
{

    public ListCommand()
    {
    }

    public void doCommand(FlashEnvironment flashenvironment, Script script, Context context, int i, Properties properties)
        throws FlashCommandException
    {
        _fld0144 = context;
        _fld0145 = properties;
        _fld0109 = new GenVector(16);
        try
        {
            Script script1 = (Script)_fld0109.add(script.getCommandScript(i));
            if(script1 == null)
                throw new FlashCommandException("movie clip missing");
            String s = getStringParamEmpty(_fld0144, _fld0145, "datasource");
            boolean flag = getStringParamEmpty(_fld0144, _fld0145, "orient").equalsIgnoreCase(getResourceString(flashenvironment, "horizontal"));
            boolean flag1 = getStringParamEmpty(_fld0144, _fld0145, "spacing").equalsIgnoreCase(getResourceString(flashenvironment, "auto"));
            String s1 = getStringParamEmpty(_fld0144, _fld0145, "halign");
            String s2 = getStringParamEmpty(_fld0144, _fld0145, "valign");
            int j = getIntParam(_fld0144, _fld0145, "itemspace", 0) * 20;
            boolean flag2 = getBoolParam(_fld0144, _fld0145, "mask");
            String s3 = getStringParamEmpty(_fld0144, _fld0145, "instancename");
            UrlDataSource urldatasource = new UrlDataSource();
            urldatasource.setEnvironment(flashenvironment);
            _fld0113 = urldatasource.getData(s);
            if(_fld0113 == null || _fld0113.length < 2)
            {
                logError(flashenvironment, "DataSourceFormatError", s);
                _fld0109.release();
                return;
            }
            int k = findColumn(_fld0113, getStringParam(_fld0144, _fld0145, "clip", "clip"));
            int l = findColumn(_fld0113, getStringParam(_fld0144, _fld0145, "space", "space"));
            int i1 = findColumn(_fld0113, "instancename");
            if(k < 0)
            {
                logError(flashenvironment, "ClipColumnNotFound", s);
                _fld0109.release();
                return;
            }
            Rect rect = (Rect)_fld0109.add(script.getCommandRect(i));
            int j1 = rect.getXMin();
            int k1 = rect.getYMin();
            int l1 = rect.getXMax();
            int i2 = rect.getYMax();
            Script ascript[] = new Script[_fld0113.length];
            for(int j2 = 1; j2 < _fld0113.length; j2++)
            {
                Context context1 = (Context)_fld0109.add(new Context());
                context1.setParent(_fld0144);
                for(int k2 = 0; k2 < _fld0113[j2].length; k2++)
                    context1.setValue(_fld0113[0][k2], _fld0113[j2][k2]);

                ascript[j2] = (Script)_fld0109.add(script.findScript(_fld0113[j2][k]));
                if(ascript[j2] == null)
                    ascript[j2] = (Script)_fld0109.add(flashenvironment.getTemplate().findScript(_fld0113[j2][k]));
                if(ascript[j2] != null)
                {
                    ascript[j2] = (Script)_fld0109.add(ascript[j2].copyScript());
                    flashenvironment.processScript(ascript[j2], context1);
                } else
                {
                    logError(flashenvironment, "UnableToFindSymbol", _fld0113[j2][k]);
                }
                _fld0109.release(context1);
            }

            Script script2 = (Script)_fld0109.add(new Script());
            script2.setFileVersion(script.getFileVersion());
            int l2 = 0;
            for(int i3 = 1; i3 < _fld0113.length; i3++)
                if(ascript[i3] != null)
                {
                    int j3 = j;
                    if(l >= 0)
                        j3 += convertStringToInt(_fld0113[i3][l], 0) * 20;
                    if(flag1)
                    {
                        Rect rect1 = ascript[i3].getBounds();
                        int k3 = flag ? rect1.getXMin() : rect1.getYMin();
                        int l3 = flag ? rect1.getXMax() : rect1.getYMax();
                        if(k3 > 0)
                            k3 = 0;
                        if(l3 < 0)
                            l3 = 0;
                        j3 += l3 - k3;
                    }
                    Matrix matrix1 = (Matrix)_fld0109.add(new Matrix());
                    if(s1.equalsIgnoreCase(getResourceString(flashenvironment, "left")))
                    {
                        if(flag)
                            matrix1.setXOffset(j1 + l2);
                        else
                            matrix1.setXOffset(j1);
                    } else
                    if(s1.equalsIgnoreCase(getResourceString(flashenvironment, "right")))
                    {
                        if(flag)
                            matrix1.setXOffset(j1 + l2 + j3);
                        else
                            matrix1.setXOffset(l1);
                    } else
                    if(flag)
                        matrix1.setXOffset(j1 + l2 + j3 / 2);
                    else
                        matrix1.setXOffset((j1 + l1) / 2);
                    if(s2.equalsIgnoreCase(getResourceString(flashenvironment, "top")))
                    {
                        if(flag)
                            matrix1.setYOffset(k1);
                        else
                            matrix1.setYOffset(k1 + l2);
                    } else
                    if(s2.equalsIgnoreCase(getResourceString(flashenvironment, "bottom")))
                    {
                        if(flag)
                            matrix1.setYOffset(i2);
                        else
                            matrix1.setYOffset(k1 + l2 + j3);
                    } else
                    if(flag)
                        matrix1.setYOffset((k1 + i2) / 2);
                    else
                        matrix1.setYOffset(k1 + l2 + j3 / 2);
                    String s5 = null;
                    if(i1 != -1)
                        s5 = _fld0113[i3][i1];
                    else
                        s5 = _fld0113[i3][k];
                    script2.insertObject(ascript[i3], 0, 0, matrix1, ascript[i3].getLastFrame(), matrix1, null, s5);
                    l2 += j3;
                }

            Matrix matrix = (Matrix)_fld0109.add(new Matrix());
            String s4 = ResourceBundle.getBundle(getClass().getName().concat("Data"), Locale.getDefault()).getString("contents");
            if(script2 != null)
                script1.insertObject(script2, 0, 0, matrix, 1, matrix, null, s4);
            if(flag2)
                script.setCommandMask(i, getMask(_fld0109, rect));
            if(s3 != null)
                script.setCommandLabel(i, s3);
        }
        catch(GeneratorApiException _ex)
        {
            logError(flashenvironment, "ErrorCreatingList", null);
        }
        _fld0109.release();
    }

    GenVector _fld0109;
    Context _fld0144;
    Properties _fld0145;
    String _fld0113[][];
}