import  java.awt.*;
import java.util.*;
import cnp.ew.list.*;
import cnp.ew.notebook.*;
import cnp.ew.text.*;
import cnp.ew.displayer.*;
import cnp.ew.converter.*;
import cnp.ew.tdemo.*;
import cnp.ew.kdemo.*;
import cnp.ew.lightweight.*;
import cnp.ew.util.*;
import cnp.ew.misc.*;
import cnp.ew.layout.*;
import cnp.ew.properties.*;
import cnp.ew.image.*;

public class CpListDemo extends CpLcApplet
{
    CpPanelLc panelLc;
    CpAbstractNotebookLc notebook;

    CpListboxLc quickenTransactionList;
    CpListboxLc quickenReportList;
    CpColumnarListboxLc columnarList;
    CpTreeListboxLc treeList;

    static int starId;

    static {
         starId = CpToolkit.registerImageName("star.gif");
    }

	public void init () {

        CpAttachments attachments;

        super.init();

        CpImageGetter.getDefault().setApplet(this);

        setBackground(Color.lightGray);

        panelLc = new CpPanelLc();
        setLc(panelLc);
        panelLc.setDrawOffscreen(true);
        CpAttachmentsLayout layout = new CpAttachmentsLayout();
        panelLc.setLayout(layout);

        notebook = new Cp3DNotebookLc();
        attachments = new CpAttachments(10, 10, 10, 10);
        layout.setAttachments(notebook, attachments);
        panelLc.add(notebook);

        addOwnerDrawnListPage(notebook);
        addColumnarListPage(notebook);
        addTreeListPage(notebook);
      //  addPropertyListPage(notebook);

		layout();
	}

	void addOwnerDrawnListPage(CpAbstractNotebookLc notebook)
    {
        CpPanelLc panel = new CpPanelLc();
        CpAttachmentsLayout layout = new CpAttachmentsLayout();
        panel.setLayout(layout);

        quickenTransactionList = new CpQuickenListboxLc(false);
        CpAttachments attachments = new CpAttachments(10, 10, 10, -1);
        attachments.setHeight(150);
        layout.setAttachments(quickenTransactionList, attachments);
        panel.add(quickenTransactionList);
        quickenTransactionList.setDisplayer(null);
        quickenTransactionList.setConverter(null);
        quickenTransactionList.setCellSize(new Dimension(1000, 34));
		quickenTransactionList.setFont(CpFonts.dialogPlainTen()); //new Font("Times Roman", Font.PLAIN, 12));
        Vector v = new Vector();
        v.addElement(new CpQuickenTransaction("101", "Travel:Air", "Sales Meeting in Dallas", "*", -82599, "American Airlines", new Date()));
        v.addElement(new CpQuickenTransaction("102", "Expense:Hardware", "Laserjet Printer", "*", -59500, "Office Depot", new Date()));
        v.addElement(new CpQuickenTransaction("103", "Telecom", "ISDN Connection", "*", -15000, "BBN Planet", new Date()));
        v.addElement(new CpQuickenTransaction("EFT", "Income:Salary", "Salary Draw", "*", 600000, "June Income", new Date()));
        v.addElement(new CpQuickenTransaction("104", "Travel:Meals", "Dinner at the Outback", "*", -3422, "The Outback", new Date()));
        v.addElement(new CpQuickenTransaction("DEP", "Income:Reimburse", "Reimbursement, May t/e", "*", 143322, "Reimbursement", new Date()));
        v.addElement(new CpQuickenTransaction("105", "Gifts", "Flowers for Secretary", "*", -8832, "Palo Alto Flowers", new Date()));
        v.addElement(new CpQuickenTransaction("106", "Travel:Air", "Consulting in Manchester", "*", -323325, "American Airlines", new Date()));
        v.addElement(new CpQuickenTransaction("107", "Capital:Hardware", "Personal Web Server", "*", -543358, "Computer City", new Date()));

        int total = 0;
        for (int i = 0; i < v.size(); i++) {
            total = ((CpQuickenTransaction)v.elementAt(i)).runningTotal(total);
        }
        quickenTransactionList.setItems(v);

        quickenReportList = new CpListboxLc(false);
        attachments = new CpAttachments(10, -1, 10, 10);
        attachments.setTopAttachment(10, quickenTransactionList);
        layout.setAttachments(quickenReportList, attachments);
        panel.add(quickenReportList);
        quickenReportList.setDisplayer(null);
        quickenReportList.setConverter(null);
        quickenReportList.setCellSize(new Dimension(1000, 17));
		quickenReportList.setFont(CpFonts.dialogPlainTen());
		quickenReportList.setBackground(Color.white);
        v = new Vector();
        v.addElement(new CpReportLine(null, 0, "INFLOWS", 0, false));
        v.addElement(new CpReportLine(null, 1, "[Credit Reserve]", 21360000, true));
        v.addElement(new CpReportLine(null, 1, "[First State]", 453600, true));
        v.addElement(new CpReportLine(null, 1, "[VISA]", 91776, true));
        v.addElement(new CpReportLine(null, 1, "[Checking]", 6764987, true));
        v.addElement(new CpReportLine(null, 1, "[Contracting]", 5000, true));
        v.addElement(new CpReportLine(null, 1, "[326 Rio Grande]", 4325000, true));
        v.addElement(new CpReportLine(null, 1, "[Land Mortgage]", 1350000, true));
        v.addElement(new CpReportLine(null, 1, "[Payments]", 2018033, true));
        v.addElement(new CpReportLine(null, 1, "Uncategorized Inflows", 7304, true));
        v.addElement(new CpReportLine(null, 1, "-", 0, false));
        v.addElement(new CpReportLine(null, 0, "TOTAL INFLOWS", 36383004, true));
        v.addElement(new CpReportLine(null, 0, "", 0, false));
        v.addElement(new CpReportLine(null, 0, "OUTFLOWS", 0, false));
        v.addElement(new CpReportLine(null, 1, "Building:Materials:", 0, false));
        v.addElement(new CpReportLine(null, 2, "Cabinets", 140829, true));
        v.addElement(new CpReportLine(null, 2, "Building:Materials-Other", 138114, true));
        v.addElement(new CpReportLine(null, 2, "-", 0, false));
        v.addElement(new CpReportLine(null, 1, "Total Building:Materials", 278943, true));
        v.addElement(new CpReportLine(null, 1, "Building:Materials:Landscaping", 61525, true));
        v.addElement(new CpReportLine(null, 1, "Classes", 1008360, true));
        v.addElement(new CpReportLine(null, 1, "Tax:State95", 216000, true));
        v.addElement(new CpReportLine(null, 1, "Building:Subdivision", 871687, true));
        v.addElement(new CpReportLine(null, 1, "Building:Materials:Insulation", 245049, true));
        v.addElement(new CpReportLine(null, 1, "Tax:Fed", 712300, true));
        v.addElement(new CpReportLine(null, 1, "Bank Chrg", 2450, true));
        v.addElement(new CpReportLine(null, 1, "Truck:Loan", 129603, true));
        v.addElement(new CpReportLine(null, 1, "Utilities:Electricity", 416, true));
        v.addElement(new CpReportLine(null, 1, "Building:Services", 1564199, true));
        v.addElement(new CpReportLine(null, 1, "Entertain", 5000, true));
        v.addElement(new CpReportLine(null, 1, "Rent", 258952, true));
        v.addElement(new CpReportLine(null, 1, "Uncategorized Outflows", 21800, true));
        v.addElement(new CpReportLine(null, 1, "Building:PermitsFees", 600000, true));
        v.addElement(new CpReportLine(null, 1, "Uncategorized Outflows", 21800, true));
        v.addElement(new CpReportLine(null, 1, "-", 0, false));
        v.addElement(new CpReportLine(null, 0, "TOTAL OUTFLOWS", 5859970, true));
        v.addElement(new CpReportLine(null, 0, "", 0, false));
        v.addElement(new CpReportLine(null, 1, "-", 0, false));
        v.addElement(new CpReportLine(null, 0, "OVERALL TOTAL", 42242974, true));
        v.addElement(new CpReportLine(null, 1, "=", 0, false));

        quickenReportList.setItems(v);

        notebook.addPage("Owner-Drawn Lists", panel);
    }

	void addColumnarListPage(CpAbstractNotebookLc notebook)
    {
        CpPanelLc panel = new CpPanelLc();
        CpAttachmentsLayout layout = new CpAttachmentsLayout();
        panel.setLayout(layout);

        columnarList = new CpColumnarListboxLc(true, true);
        CpAttachments attachments = new CpAttachments(10, 10, 10, 10);
        layout.setAttachments(columnarList, attachments);
        panel.add(columnarList);
		columnarList.setBackground(Color.white);
		columnarList.setFont(CpFonts.dialogPlainTen());
		columnarList.setCellSelect(true);
        columnarList.setConverter(null);

		Vector v = new Vector();
		CpColumnModel col1;
		// This is bogus.  Should pass int to cpcolumnmodel?  Should make getPropeties static?  Something else than this.
		CpEmployee junk = new CpEmployee("", 0, new Date(), false, 0, 0);
		Vector props = junk.getProperties();

		CpGeneralStringDisplayer displayer = new CpGeneralStringDisplayer();
		displayer.setMargin(4, 0);
        displayer.setSelectionExpansion(2);
		displayer.selectionBackColor = null;
		CpGeneralStringDisplayer rightDisplayer = new CpGeneralStringDisplayer();
		rightDisplayer.setMargin(4, 0);
        rightDisplayer.setSelectionExpansion(2);
		rightDisplayer.selectionBackColor = null;
		rightDisplayer.setHorizontalAlignment(CpAlignable.ALIGN_RIGHT);

		v.addElement(col1 = new CpColumnModel("Name", 120, (CpProperty)props.elementAt(CpEmployee.NAME_PROP), true, true));
		col1.setDisplayer(displayer);

        CpEntryFieldLc entry = new CpEntryFieldLc();
        entry.setBorderStyle(CpAbstractLc.BORDER_INWARD3D);
        col1.setEditor(entry);

		v.addElement(col1 = new CpColumnModel("Age", 50, (CpProperty)props.elementAt(CpEmployee.AGE_PROP), true, true));
		col1.setDisplayer(rightDisplayer);
		v.addElement(col1 = new CpColumnModel("Hire Date", 80, (CpProperty)props.elementAt(CpEmployee.BIRTHDAY_PROP), true, true));
		col1.setDisplayer(displayer);
		v.addElement(col1 = new CpColumnModel("Salary", 80, (CpProperty)props.elementAt(CpEmployee.SALARY_PROP), true, true));
		col1.setDisplayer(rightDisplayer);
		v.addElement(col1 = new CpColumnModel("Married", 50, (CpProperty)props.elementAt(CpEmployee.MARRIED_PROP), true, true));
		col1.setDisplayer(displayer);
		v.addElement(col1 = new CpColumnModel("Rating", 90, (CpProperty)props.elementAt(CpEmployee.RATING_PROP), true, true));
		CpImageValueDisplayer imageDisplayer = new CpImageValueDisplayer(CpToolkit.getImage(starId));
		col1.setDisplayer(imageDisplayer);
		col1.setConverter(null);
		//tempDisplayer.setHorizontalAlignment(tempDisplayer.ALIGN_RIGHT
		//tempDisplayer.selectionDisplayStyle = tempDisplayer.SELECT_NONE;);
		columnarList.setColumns(v);

		v = new Vector();
        v.addElement(new CpEmployee("James, Spencer", 24, new Date(95, 0, 15), false, 34000, 5));
        v.addElement(new CpEmployee("Taylor, Mike", 35, new Date(95, 1, 21), true, 41000, 3));
        v.addElement(new CpEmployee("Reeves, Ann", 31, new Date(95, 3, 1), true, 42000, 5));
        v.addElement(new CpEmployee("Whitney, Roger", 45, new Date(95, 6, 3), false, 54500, 5));
        v.addElement(new CpEmployee("Applegarth, Mark", 33, new Date(95, 0, 15), false, 64000, 4));
        v.addElement(new CpEmployee("Hancock, Joanna", 45, new Date(95, 1, 21), true, 48000, 4));
        v.addElement(new CpEmployee("Volansky, David", 56, new Date(95, 3, 1), true, 47000, 3));
        v.addElement(new CpEmployee("Liu, Cricket", 54, new Date(95, 6, 3), false, 56500, 4));
        v.addElement(new CpEmployee("O'Neil, Patrick", 22, new Date(95, 0, 15), false, 35000, 1));
        v.addElement(new CpEmployee("Adrian, Greg", 29, new Date(95, 1, 21), true, 44000, 2));
        v.addElement(new CpEmployee("Furie, Ken", 37, new Date(95, 3, 1), true, 44000, 2));
        v.addElement(new CpEmployee("Rike, Paige", 61, new Date(95, 6, 3), false, 52500, 2));
        v.addElement(new CpEmployee("Okamoto, Penny", 62, new Date(95, 0, 15), false, 31000, 2));
        v.addElement(new CpEmployee("Goebel, Jim", 55, new Date(95, 1, 21), true, 41400, 1));
        v.addElement(new CpEmployee("Collins, Dave", 43, new Date(95, 3, 1), true, 42500, 3));
        v.addElement(new CpEmployee("Adams, Sam", 40, new Date(95, 6, 3), false, 54540, 4));
        v.addElement(new CpEmployee("Clinton, George", 21, new Date(95, 0, 15), false, 34600, 5));
        v.addElement(new CpEmployee("Lynden, Carrie", 25, new Date(95, 1, 21), true, 47000, 1));
        v.addElement(new CpEmployee("Geiger, Geoff", 31, new Date(95, 3, 1), true, 48000, 2));
        v.addElement(new CpEmployee("Yerex, Robert", 61, new Date(95, 6, 3), false, 57500, 3));
        v.addElement(new CpEmployee("Huard, Brock", 51, new Date(95, 0, 15), false, 34000, 2));
        v.addElement(new CpEmployee("Lavin, Christine", 52, new Date(95, 1, 21), true, 46000, 5));
        v.addElement(new CpEmployee("Fantazia, Jill", 54, new Date(95, 3, 1), true, 47000, 4));
        v.addElement(new CpEmployee("Dillon, Corey", 34, new Date(95, 6, 3), false, 57700, 3));
        v.addElement(new CpEmployee("Lebert, Berthold", 33, new Date(95, 0, 15), false, 34000, 2));
        v.addElement(new CpEmployee("Lotz, Gloria", 35, new Date(95, 1, 21), true, 41000, 2));
        v.addElement(new CpEmployee("Goodheart, Anne", 31, new Date(95, 3, 1), true, 72000, 3));
        v.addElement(new CpEmployee("Mersch, Joan", 32, new Date(95, 6, 3), false, 58500, 4));
        v.addElement(new CpEmployee("McGooogan, Jim", 37, new Date(95, 0, 15), false, 74000, 3));
        v.addElement(new CpEmployee("Gottrocks, J.B.", 35, new Date(95, 1, 21), true, 181000, 5));
        v.addElement(new CpEmployee("Wolf, Kirk", 31, new Date(95, 3, 1), true, 12000, 1));
        v.addElement(new CpEmployee("Gerstner, Bill", 28, new Date(95, 6, 3), false, 54500, 2));
        v.addElement(new CpEmployee("Gates, Lou", 26, new Date(95, 0, 15), false, 74000, 3));
        v.addElement(new CpEmployee("McNealy, Mav", 25, new Date(95, 1, 21), true, 21000, 4));
        v.addElement(new CpEmployee("Goetze, Steve", 31, new Date(95, 3, 1), true, 12000, 3));
        v.addElement(new CpEmployee("Mueller, Rene", 48, new Date(95, 6, 3), false, 54900, 3));
        columnarList.setItems(v);

        notebook.addPage("Columnar List", panel);
    }

	void addTreeListPage(CpAbstractNotebookLc notebook)
    {
        CpPanelLc panel = new CpPanelLc();
        CpAttachmentsLayout layout = new CpAttachmentsLayout();
        panel.setLayout(layout);

        CpTreeListboxLc treeList = new CpTreeListboxLc();

        CpAttachments attachments = new CpAttachments(10, 10, 10, 10);
        layout.setAttachments(treeList, attachments);
        panel.add(treeList);
		treeList.setBackground(Color.white);
		treeList.setFont(CpFonts.dialogPlainTen());
        treeList.setConverter(null);

		Vector v = new Vector();
		// This is bogus.  Should pass int to cpcolumnmodel?  Should make getPropeties static?  Something else than this.
		CpFileModel junk = new CpFileModel(false, "", 0, "", new Date());
		Vector props = junk.getProperties();

		CpGeneralStringDisplayer displayer = new CpGeneralStringDisplayer();
		displayer.setMargin(4, 0);
        displayer.setSelectionExpansion(2);
		displayer.selectionDisplayStyle = CpGeneralStringDisplayer.SELECT_NONE;
		CpGeneralStringDisplayer rightDisplayer = new CpGeneralStringDisplayer();
		rightDisplayer.setMargin(4, 0);
        rightDisplayer.setSelectionExpansion(2);
		rightDisplayer.selectionDisplayStyle = CpGeneralStringDisplayer.SELECT_NONE;
		rightDisplayer.setHorizontalAlignment(CpAlignable.ALIGN_RIGHT);

        CpTreeColumnModel col;
		v.addElement(col = new CpTreeColumnModel("Name", 170, (CpProperty)props.elementAt(CpFileModel.THIS_PROP), true, true));
        CpGeneralStringDisplayer labelDisplayer = new CpGeneralStringDisplayer();
        labelDisplayer.setSelectionExpansion(2);
        CpImageDisplayer imageDisplayer = new CpImageDisplayer();
	    CpTreeIconTextDisplayer compositeDisplayer = new CpTreeIconTextDisplayer();
	    compositeDisplayer.setDisplayers(labelDisplayer, imageDisplayer);
        col.setDisplayer(compositeDisplayer);
        CpFileNameEditorLc entry = new CpFileNameEditorLc();
        entry.setSizeToFit(true);
        entry.setBorderStyle(CpAbstractLc.BORDER_LINE);
        entry.setBorderMargin(1);
        col.setEditor(entry);

		CpColumnModel col1;
		v.addElement(col1 = new CpColumnModel("Size", 60, (CpProperty)props.elementAt(CpFileModel.SIZE_PROP), true, false));
		col1.setDisplayer(rightDisplayer);
		CpNumberToStringConverter converter = new CpNumberToStringConverter("#KB;-");
		col1.setConverter(converter);
		v.addElement(col1 = new CpColumnModel("Type", 100, (CpProperty)props.elementAt(CpFileModel.TYPE_PROP), true, false));
		col1.setDisplayer(displayer);
		v.addElement(col1 = new CpColumnModel("Modified", 130, (CpProperty)props.elementAt(CpFileModel.MODIFIED_PROP), true, false));
		col1.setDisplayer(displayer);
		CpDateToStringConverter dateConverter = new CpDateToStringConverter("m/d/yy h:s AM/PM");
		col1.setConverter(dateConverter);

		treeList.setColumns(v);

		v = new Vector();
		CpFileModel item, item2;
        v.addElement(item = new CpFileModel(true, "Download", -1, "File Folder", new Date(36446L)));
            item.addChild(new CpFileModel(false, "Spencer.jpg", 67, "JPEG Image", new Date(999134424L)));
            item.addChild(new CpFileModel(false, "Hugeorama.zip", 3100, "SuperZip File", new Date(999134424L)));
            item.addChild(item2 = new CpFileModel(true, "Looked At", -1, "File Folder", new Date(888253525L)));
              item2.addChild(new CpFileModel(false, "NavigatorPlatinum.zip", 5344, "Zip File", new Date(666443243L)));
              item2.addChild(new CpFileModel(false, "activeydevtools.zip", 1500, "Zip File", new Date(555545632L)));
              item2.addChild(new CpFileModel(false, "SmartSheets.zippo", 1203, "SuperZip File", new Date(5559953434L)));
            item.addChild(new CpFileModel(false, "FamousArt.gif", 82, "GIF Image", new Date(777343434L)));
        v.addElement(new CpFileModel(true, "Internet", -1, "File Folder", new Date(99998845300L)));
        v.addElement(new CpFileModel(true, "Mail", -1, "File Folder", new Date(88886655555L)));
        v.addElement(new CpFileModel(true, "My Documents", -1, "File Folder", new Date(77777744444L)));
        v.addElement(item = new CpFileModel(true, "Programs", -1, "File Folder", new Date(88886541000L)));
            item.addChild(new CpFileModel(false, "PowerPresenter", 565, "Application", new Date(77775549999L)));
            item.addChild(new CpFileModel(false, "SuperWord", 1223, "Application", new Date(66664488888L)));
            item.addChild(new CpFileModel(false, "Navigating NetBrowser", 1374, "Application", new Date(99993377777L)));
        v.addElement(new CpFileModel(true, "Navigator", -1, "File Folder", new Date(8899966666L)));
        v.addElement(new CpFileModel(true, "Temp", -1, "File Folder", new Date(664666667676L)));
        v.addElement(new CpFileModel(true, "Util", -1, "File Folder", new Date(8899966666L)));
        v.addElement(new CpFileModel(true, "Windows", -1, "File Folder", new Date(664666667676L)));
            item.addChild(new CpFileModel(false, "Vbrun500.dll", 390, "Application Extension", new Date(666111188882L)));
            item.addChild(new CpFileModel(false, "Memmaker.exe", 117, "Application", new Date(444444488111L)));
            item.addChild(new CpFileModel(false, "Memmaker.hlp", 14, "Help File", new Date(566665533888L)));
        v.addElement(item = new CpFileModel(true, "WinZip", -1, "File Folder", new Date(66636663111L)));

        treeList.setItems(v);

        notebook.addPage("Tree List", panel);
    }

	void addPropertyListPage(CpAbstractNotebookLc notebook)
    {
        CpPanelLc panel = new CpPanelLc();
        CpAttachmentsLayout layout = new CpAttachmentsLayout();
        panel.setLayout(layout);

        notebook.addPage("Property", panel);
    }
}

