Package org.itsnat.feashow.features.comp.shared

Examples of org.itsnat.feashow.features.comp.shared.Person


    public void renderListCell(ItsNatList list, int index, Object value, boolean isSelected, boolean hasFocus, Element cellContentElem, boolean isNew)
    {
        ItsNatListMultSel listMult = (ItsNatListMultSel)list;

        final DefaultListModel listModel = (DefaultListModel)listMult.getListModel();
        final Person person = (Person)listModel.getElementAt(index);

        if (isNew)
        {
            ItsNatDocument itsNatDoc = listMult.getItsNatDocument();

            if (!itsNatDoc.getItsNatDocumentTemplate().isAutoBuildComponents())
            {
                ItsNatComponentManager compMgr = listMult.getItsNatComponentManager();
                compMgr.buildItsNatComponents(cellContentElem);
            }

            final ItsNatHTMLInputText firstNameComp = getInputText("firstNameId",cellContentElem,listMult);
            final ItsNatHTMLInputText lastNameComp = getInputText("lastNameId",cellContentElem,listMult);

            firstNameComp.setText(person.getFirstName());
            lastNameComp.setText(person.getLastName());

            DocumentListener firstNameListener = new DocumentListener()
            {
                public void insertUpdate(DocumentEvent e)
                {
                    update();
                }

                public void removeUpdate(DocumentEvent e)
                {
                    update();
                }

                public void changedUpdate(DocumentEvent e)
                {
                    update();
                }

                public void update()
                {
                    person.setFirstName(firstNameComp.getText());
                }
            };

            firstNameComp.getDocument().addDocumentListener(firstNameListener);

            DocumentListener lastNameListener = new DocumentListener()
            {
                public void insertUpdate(DocumentEvent e)
                {
                    update();
                }

                public void removeUpdate(DocumentEvent e)
                {
                    update();
                }

                public void changedUpdate(DocumentEvent e)
                {
                    update();
                }

                public void update()
                {
                    person.setLastName(lastNameComp.getText());
                }

            };

            lastNameComp.getDocument().addDocumentListener(lastNameListener);
        }
        else
        {
            ItsNatHTMLInputText firstNameComp = getInputText("firstNameId",cellContentElem,listMult);
            ItsNatHTMLInputText lastNameComp = getInputText("lastNameId",cellContentElem,listMult);

            firstNameComp.setText(person.getFirstName());
            lastNameComp.setText(person.getLastName());
        }
    }
View Full Code Here


        listComp.setItsNatListCellRenderer(new PersonRenderer());
        listComp.setItsNatListCellEditor(null);// disable

        DefaultListModel dataModel = (DefaultListModel)listComp.getListModel();

        dataModel.addElement(new Person("Meredith","Grey"));
        dataModel.addElement(new Person("Cristina","Yang"));
        dataModel.addElement(new Person("Izzie","Stevens"));
        dataModel.addElement(new Person("Alex","Karev"));
        dataModel.addElement(new Person("George","O'Malley"));
        dataModel.addElement(new Person("Derek","Shepherd"));

        ListSelectionModel selModel = listComp.getListSelectionModel();
        selModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        selModel.setSelectionInterval(2,3);

        listComp.addEventListener("click",this);
        selModel.addListSelectionListener(this);
        dataModel.addListDataListener(this);

        this.removeButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("removeId");
        removeButton.addEventListener("click",this);

        Person person = (Person)listComp.getListModel().getElementAt(listComp.getSelectedIndex());
        this.personFirstNameComp = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("personFirstNameId");
        personFirstNameComp.setText(person.getFirstName());

        this.personLastNameComp = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("personLastNameId");
        personLastNameComp.setText(person.getLastName());

        this.posComp = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("posId");
        posComp.setText(Integer.toString(listComp.getSelectedIndex()));

        this.updateButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("updateId");
View Full Code Here

            {
                int pos = Integer.parseInt(posComp.getText());
                DefaultListModel dataModel = (DefaultListModel)listComp.getListModel();
                if (currentTarget == updateButton.getHTMLInputElement())
                {
                    Person person = (Person)dataModel.getElementAt(pos);
                    person.setFirstName(firstName);
                    person.setLastName(lastName);
                    dataModel.setElementAt(person,pos); // To notify the changes (fires an event)
                }
                else
                {
                    Person person = new Person(firstName,lastName);
                    dataModel.insertElementAt(person,pos);
                }
            }
            catch(NumberFormatException ex)
            {
View Full Code Here

        log(e.getClass().toString() + " " + fact);

        int index = listComp.getSelectedIndex(); // First selected
        if (index != -1)
        {
            Person person = (Person)listComp.getListModel().getElementAt(index);
            personFirstNameComp.setText(person.getFirstName());
            personLastNameComp.setText(person.getLastName());
            posComp.setText(Integer.toString(index));
        }

        for(int i = first; i <= last; i++)
        {
View Full Code Here

        this.comp = (ItsNatFreeLabel)compMgr.createItsNatComponentById("labelId","freeLabel",null);

        ItsNatLabelRenderer renderer = new PersonCustomLabelRenderer();
        comp.setItsNatLabelRenderer(renderer);

        try { comp.setValue(new Person("Jose M.","Arranz")); }
        catch(PropertyVetoException ex) { throw new RuntimeException(ex); }

        ItsNatLabelEditor editor = new PersonCustomLabelEditor(comp);
        comp.setItsNatLabelEditor(editor);
View Full Code Here

    {
    }

    public void renderLabel(ItsNatLabel label, Object value, Element labelElem,boolean isNew)
    {
        Person person = (Person)value;

        ItsNatDocument itsNatDoc = label.getItsNatDocument();
        Document doc = itsNatDoc.getDocument();
        Element firstNameElem = doc.getElementById("firstNameId");
        ItsNatDOMUtil.setTextContent(firstNameElem,person.getFirstName());
        Element lastNameElem = doc.getElementById("lastNameId");
        ItsNatDOMUtil.setTextContent(lastNameElem,person.getLastName());
    }
View Full Code Here

        this.useSingleClickComp = (ItsNatHTMLInputCheckBox)compMgr.createItsNatComponentById("useSingleClickId");
        useSingleClickComp.addEventListener("click",this);

        this.comp = (ItsNatFreeLabel)compMgr.createItsNatComponentById("labelId","freeLabel",null);
        try { comp.setValue(new Person("Jose M.","Arranz")); }
        catch(PropertyVetoException ex) { throw new RuntimeException(ex); }

        ItsNatLabelEditor editor = new PersonCustomLabelEditor(comp);
        comp.setItsNatLabelEditor(editor);
View Full Code Here

TOP

Related Classes of org.itsnat.feashow.features.comp.shared.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.