Package org.itsnat.comp

Examples of org.itsnat.comp.ItsNatComponentManager


        this.itsNatRequest = itsNatRequest;

        try
        {
            ItsNatDocument itsNatDoc = itsNatRequest.getItsNatDocument();
            ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();

            this.listComp = (ItsNatHTMLSelectMult)compMgr.addItsNatComponentById("listId");
            ListSelectionModel selModel = listComp.getListSelectionModel();
            selModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            String action = itsNatRequest.getServletRequest().getParameter("action");
            if (action == null)
                firstTime();
            else
                processAction(action);

            int selectedIndex = listComp.getSelectedIndex();
            if (selectedIndex != -1)
            {
                ItsNatHTMLInputText itemComp = (ItsNatHTMLInputText)compMgr.addItsNatComponentById("itemId");
                itemComp.setText(listComp.getListModel().getElementAt(listComp.getSelectedIndex()).toString());

                ItsNatHTMLInputText posComp = (ItsNatHTMLInputText)compMgr.addItsNatComponentById("posId");
                posComp.setText(Integer.toString(listComp.getSelectedIndex()));
            }
        }
        finally
        {
View Full Code Here


     */
    public TestComponentsDocument(ItsNatHTMLDocument itsNatDoc,ItsNatServletRequest request, ItsNatServletResponse response)
    {
        this.itsNatDoc = itsNatDoc;

        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();

        // Nota: si AutoBuildComponents es true, setSelectionOnComponentsUsesKeyboard no tendr� efecto pues ya se habr�n creado los componentes
        compMgr.setSelectionOnComponentsUsesKeyboard(!BrowserUtil.isMobileBrowser(request));

        Document doc = itsNatDoc.getDocument();
        AbstractView view = ((DocumentView)doc).getDefaultView();
        ((EventTarget)view).addEventListener("load",new TestOnLoadListener(itsNatDoc),false);

        //ItsNatHttpSession session = (ItsNatHttpSession)request.getItsNatSession();
        if (!itsNatDoc.getItsNatDocumentTemplate().isAutoBuildComponents())
        {
            compMgr.buildItsNatComponents();
        }

        new TestHTMLLabel(itsNatDoc);
        new TestFreeLabel(itsNatDoc);

View Full Code Here

    public void initCheckBox()
    {
        Document doc = itsNatDoc.getDocument();
        HTMLInputElement inputElem = (HTMLInputElement)doc.getElementById("checkboxId");
        ItsNatComponentManager componentMgr = itsNatDoc.getItsNatComponentManager();
        ItsNatHTMLInputCheckBox input = (ItsNatHTMLInputCheckBox)componentMgr.findItsNatComponent(inputElem);
        ToggleButtonModel dataModel = new ToggleButtonModel();
        input.setButtonModel(dataModel);

        input.addEventListener("click",this);
        // Los dem�s tipos de eventos ya est�n testeados con el tipo de bot�n normal (default)
View Full Code Here

    }

    public void startExamplePanel()
    {
        ItsNatDocument itsNatDoc = getItsNatDocument();
        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();

        this.useSingleClickComp = (ItsNatHTMLInputCheckBox)compMgr.createItsNatComponentById("useSingleClickId");
        useSingleClickComp.getToggleButtonModel().addItemListener(this);

        this.tableComp = (ItsNatHTMLTable)compMgr.createItsNatComponentById("compId");

        DefaultTableModel dataModel = (DefaultTableModel)tableComp.getTableModel();
        dataModel.addColumn("City");
        dataModel.addColumn("Public square");
        dataModel.addColumn("Monument");
        dataModel.addRow(new String[] {"Madrid","Plaza Mayor","Palacio Real"});
        dataModel.addRow(new String[] {"Sevilla","Plaza de Espa�a","Giralda"});
        dataModel.addRow(new String[] {"Segovia","Plaza del Azoguejo","Acueducto Romano"});

        ListSelectionModel rowSelModel = tableComp.getRowSelectionModel();
        // ListSelectionModel columnSelModel = tableComp.getColumnSelectionModel();

        rowSelModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        // columnSelModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        tableComp.setRowSelectionAllowed(true);
        tableComp.setColumnSelectionAllowed(false);

        rowSelModel.addListSelectionListener(new TableRowSelectionDecoration(tableComp));

        rowSelModel.setSelectionInterval(1,1);

        dataModel.addTableModelListener(this);
        rowSelModel.addListSelectionListener(this);

        ListSelectionModel headSelModel = tableComp.getItsNatTableHeader().getListSelectionModel();
        headSelModel.addListSelectionListener(this);

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

        this.newItemComp = new ItsNatHTMLInputText[dataModel.getColumnCount()];
        for(int i = 0; i < newItemComp.length; i++)
        {
            this.newItemComp[i] = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("itemId" + i);
            newItemComp[i].setText(dataModel.getValueAt(rowSelModel.getMinSelectionIndex(), i).toString());
        }

        this.posComp = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("posId");
        posComp.setText(Integer.toString(rowSelModel.getMinSelectionIndex()));

        this.updateButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("updateId");
        updateButton.addEventListener("click",this);

        this.insertButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("insertId");
        insertButton.addEventListener("click",this);

        this.joystickModeComp = (ItsNatHTMLInputCheckBox)compMgr.createItsNatComponentById("joystickModeId");
        joystickModeComp.getToggleButtonModel().addItemListener(this);
        joystickModeComp.setSelected(isJoystickModePreferred());
    }
View Full Code Here

    }

    public void startExamplePanel()
    {
        ItsNatDocument itsNatDoc = getItsNatDocument();
        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();

        this.buttonComp = (ItsNatFreeButtonNormal)compMgr.createItsNatComponentById("buttonId","freeButtonNormal",null);
        buttonComp.addEventListener("click",this);

        ButtonModel dataModel = buttonComp.getButtonModel();
        dataModel.addActionListener(this);
        dataModel.addChangeListener(this);
View Full Code Here

    }

    public void startExamplePanel()
    {
        ItsNatDocument itsNatDoc = getItsNatDocument();
        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();

        this.formComp = (ItsNatHTMLForm)compMgr.createItsNatComponentById("formId");

        formComp.setEventListenerParams("submit",false,CommMode.XHR_SYNC,null,null,-1);
        formComp.setEventListenerParams("reset",false,CommMode.XHR_SYNC,null,null,-1);

        formComp.addEventListener("submit",this);
        formComp.addEventListener("reset",this);

        this.linkComp = (ItsNatHTMLAnchor)compMgr.createItsNatComponentById("linkId");
        linkComp.addEventListener("click",this);
    }
View Full Code Here

        load();
    }

    public void load()
    {
        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
        ItsNatButton button = (ItsNatButton)compMgr.findItsNatComponentById("testModalLayerId");
        this.button = button;
        button.addEventListener("click",this);

        this.cleanModeCheck1 = (ItsNatHTMLInputCheckBox)compMgr.findItsNatComponentById("cleanModeId1");
        cleanModeCheck1.setSelected(false);
        this.cleanModeCheck2 = (ItsNatHTMLInputCheckBox)compMgr.findItsNatComponentById("cleanModeId2");
        cleanModeCheck2.setSelected(false);
    }
View Full Code Here

        {
            ItsNatListStructure customStruc = new CityListCustomStructure();
            itsNatDoc.registerArtifact("cityCustomStruc",customStruc);
        }

        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
        compMgr.buildItsNatComponents(parentElem);

        // Normal Buttons

        ItsNatHTMLInputButton inputButton = (ItsNatHTMLInputButton)compMgr.findItsNatComponentById("inputButtonId");
        check(inputButton);
        inputButton.setLabelValue("Input Button");

        ItsNatHTMLInputImage inputImage = (ItsNatHTMLInputImage)compMgr.findItsNatComponentById("inputImageId");
        check(inputImage);

        ItsNatHTMLInputSubmit inputSubmit = (ItsNatHTMLInputSubmit)compMgr.findItsNatComponentById("inputSubmitId");
        check(inputSubmit);
        inputSubmit.setLabelValue("Input Submit");

        ItsNatHTMLInputReset inputReset = (ItsNatHTMLInputReset)compMgr.findItsNatComponentById("inputResetId");
        check(inputReset);
        inputReset.setLabelValue("Input Reset");

        ItsNatHTMLButton button = (ItsNatHTMLButton)compMgr.findItsNatComponentById("buttonId");
        check(button);

        ItsNatHTMLButtonLabel buttonLabel = (ItsNatHTMLButtonLabel)compMgr.findItsNatComponentById("buttonLabelId");
        check(buttonLabel);
        buttonLabel.setLabelValue("Button With Label");

        ItsNatHTMLAnchor anchor = (ItsNatHTMLAnchor)compMgr.findItsNatComponentById("anchorId");
        check(anchor);

        ItsNatHTMLAnchorLabel anchorLabel = (ItsNatHTMLAnchorLabel)compMgr.findItsNatComponentById("anchorLabelId");
        check(anchorLabel);
        buttonLabel.setLabelValue("Anchor With Label");


        ItsNatFreeButtonNormal freeButtonNormal = (ItsNatFreeButtonNormal)compMgr.findItsNatComponentById("freeButtonNormalId");
        check(freeButtonNormal);

        ItsNatFreeButtonNormalLabel freeButtonNormalLabel = (ItsNatFreeButtonNormalLabel)compMgr.findItsNatComponentById("freeButtonNormalLabelId");
        check(freeButtonNormalLabel);
        freeButtonNormalLabel.setLabelValue("Free Button Normal Label");


        // Toggle Buttons

        ItsNatHTMLInputCheckBox inputCheckBox = (ItsNatHTMLInputCheckBox)compMgr.findItsNatComponentById("inputCheckBoxId");
        check(inputCheckBox);

        ItsNatHTMLInputRadio inputRadio = (ItsNatHTMLInputRadio)compMgr.findItsNatComponentById("inputRadioButtonId");
        check(inputRadio);

        ItsNatFreeCheckBox freeCheckBox = (ItsNatFreeCheckBox)compMgr.findItsNatComponentById("freeCheckBoxId");
        check(freeCheckBox);

        ItsNatFreeCheckBoxLabel freeCheckBoxLabel = (ItsNatFreeCheckBoxLabel)compMgr.findItsNatComponentById("freeCheckBoxLabelId");
        check(freeCheckBoxLabel);
        freeCheckBoxLabel.setLabelValue("Free Check Box Label");


        ItsNatFreeRadioButton freeRadioButton = (ItsNatFreeRadioButton)compMgr.findItsNatComponentById("freeRadioButtonId");
        check(freeRadioButton);

        ItsNatFreeRadioButtonLabel freeRadioButtonLabel = (ItsNatFreeRadioButtonLabel)compMgr.findItsNatComponentById("freeRadioButtonLabelId");
        check(freeRadioButtonLabel);
        freeRadioButtonLabel.setLabelValue("Free Radio Button Label");


        // Text Fields

        ItsNatHTMLInputText inputText = (ItsNatHTMLInputText)compMgr.findItsNatComponentById("inputTextId");
        check(inputText);
        inputText.setText("Input Text");

        ItsNatHTMLInputPassword inputPassword = (ItsNatHTMLInputPassword)compMgr.findItsNatComponentById("inputPasswordId");
        check(inputPassword);
        inputPassword.setText("Input Password");

        ItsNatHTMLInputHidden inputHidden = (ItsNatHTMLInputHidden)compMgr.findItsNatComponentById("inputHiddenId");
        check(inputHidden);

        ItsNatHTMLInputFile inputFile = (ItsNatHTMLInputFile)compMgr.findItsNatComponentById("inputFileId");
        check(inputFile);

        ItsNatHTMLInputTextFormatted inputTextFormat = (ItsNatHTMLInputTextFormatted)compMgr.findItsNatComponentById("inputTextFormattedId");
        check(inputTextFormat);
        try{ inputTextFormat.setValue("Input Text Formatted"); }catch(Exception ex) { }

        // Text Area
        ItsNatHTMLTextArea textArea = (ItsNatHTMLTextArea)compMgr.findItsNatComponentById("textAreaId");
        check(textArea);
        textArea.setText("Text Area");

        // Labels

        ItsNatLabel label = (ItsNatLabel)compMgr.findItsNatComponentById("labelId");
        check(label);
        try{ label.setValue("Label"); }catch(Exception ex) { }

        ItsNatFreeLabel freeLabel = (ItsNatFreeLabel)compMgr.findItsNatComponentById("freeLabelId");
        check(freeLabel);
        try{ freeLabel.setValue("Free Label"); }catch(Exception ex) { }

        // Lists

        ItsNatHTMLSelectComboBox selectCombo = (ItsNatHTMLSelectComboBox)compMgr.findItsNatComponentById("selectComboId");
        check(selectCombo);
        ((MutableComboBoxModel)selectCombo.getComboBoxModel()).addElement("Option 1");
        ((MutableComboBoxModel)selectCombo.getComboBoxModel()).addElement("Option 2");

        ItsNatHTMLSelectMult selectList = (ItsNatHTMLSelectMult)compMgr.findItsNatComponentById("selectListId");
        check(selectList);
        ((DefaultListModel)selectList.getListModel()).addElement("Option 1");
        ((DefaultListModel)selectList.getListModel()).addElement("Option 2");

        ItsNatFreeComboBox freeCombo = (ItsNatFreeComboBox)compMgr.findItsNatComponentById("freeComboBoxId");
        check(freeCombo);
        ((MutableComboBoxModel)freeCombo.getComboBoxModel()).addElement("Option 1");
        ((MutableComboBoxModel)freeCombo.getComboBoxModel()).addElement("Option 2");

        ItsNatFreeListMultSel freeList = (ItsNatFreeListMultSel)compMgr.findItsNatComponentById("freeListId");
        check(freeList);
        ((DefaultListModel)freeList.getListModel()).addElement("Option 1");
        ((DefaultListModel)freeList.getListModel()).addElement("Option 2");

        // Tables

        ItsNatHTMLTable table = (ItsNatHTMLTable)compMgr.findItsNatComponentById("tableId");
        check(table);
        ((DefaultTableModel)table.getTableModel()).addColumn("Col 1");
        ((DefaultTableModel)table.getTableModel()).addColumn("Col 2");
        ((DefaultTableModel)table.getTableModel()).addRow(new String[]{"Item 1,1","Item 1,2"});
        ((DefaultTableModel)table.getTableModel()).addRow(new String[]{"Item 2,1","Item 2,2"});

        ItsNatFreeTable freeTable = (ItsNatFreeTable)compMgr.findItsNatComponentById("freeTableId");
        check(freeTable);
        ((DefaultTableModel)freeTable.getTableModel()).addColumn("Col 1");
        ((DefaultTableModel)freeTable.getTableModel()).addColumn("Col 2");
        ((DefaultTableModel)freeTable.getTableModel()).addRow(new String[]{"Item 1,1","Item 1,2"});
        ((DefaultTableModel)freeTable.getTableModel()).addRow(new String[]{"Item 2,1","Item 2,2"});
        // Trees
        ItsNatFreeTree freeTree = (ItsNatFreeTree)compMgr.findItsNatComponentById("freeTreeId");
        check(freeTree);
        ((DefaultTreeModel)freeTree.getTreeModel()).setRoot(new DefaultMutableTreeNode("Free Tree"));

        ItsNatFreeTree freeTreeRootless = (ItsNatFreeTree)compMgr.findItsNatComponentById("freeTreeRootlessId");
        check(freeTreeRootless);
        DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root (hidden)");
        root.add(new DefaultMutableTreeNode("Free Tree Rootless"));
        ((DefaultTreeModel)freeTreeRootless.getTreeModel()).setRoot(root);

        ItsNatFreeTree freeTreeTable = (ItsNatFreeTree)compMgr.findItsNatComponentById("freeTreeTableId");
        check(freeTreeTable);
        ((DefaultTreeModel)freeTreeTable.getTreeModel()).setRoot(new DefaultMutableTreeNode("Free Tree Table"));

        ItsNatHTMLForm form = (ItsNatHTMLForm)compMgr.findItsNatComponentById("formId");
        check(form);

        ItsNatFreeInclude freeInclude = (ItsNatFreeInclude)compMgr.findItsNatComponentById("freeIncludeId");
        check(freeInclude);

        LoginComponent customComp = (LoginComponent)compMgr.findItsNatComponentById("customCompId");
        check(customComp);

        ItsNatFreeListMultSel listCustomStruc = (ItsNatFreeListMultSel)compMgr.findItsNatComponentById("listCustomStructureId");
        check(listCustomStruc);
        check(listCustomStruc.getItsNatListStructure() instanceof CityListCustomStructure);
        ((DefaultListModel)listCustomStruc.getListModel()).addElement("Madrid");
        ((DefaultListModel)listCustomStruc.getListModel()).addElement("Barcelona");

        compMgr.removeItsNatComponents(parentElem,true);// Disables/destroys all

        if (adaptor != null) adaptor.setModeAuto(false);
    }
View Full Code Here

    {
        ItsNatDocument itsNatDoc = getItsNatDocument();
        this.link = itsNatDoc.getDocument().getElementById("linkToStartId");
        ((EventTarget)link).addEventListener("click",this,false);

        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
        this.cleanModeCheck = (ItsNatHTMLInputCheckBox)compMgr.createItsNatComponentById("cleanModeId");
        cleanModeCheck.setSelected(false);
    }
View Full Code Here

    {
        float opacity = (float)0.5;
        String background = "black";

        final ItsNatDocument itsNatDoc = getItsNatDocument();
        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
        final ItsNatModalLayer modalLayer = compMgr.createItsNatModalLayer(null,cleanModeCheck.isSelected(),opacity,background,null);

        EventListener unexpEvtListener = new EventListener()
        {
            public void handleEvent(Event evt)
            {
                StringBuilder code = new StringBuilder();
                ItsNatServletRequest request = ((ItsNatEvent)evt).getItsNatServletRequest();
                code.append("if (confirm('Received an unexpected event by a hidden element. Reload?')) ");
                code.append("  window.location.reload(true);");               
                itsNatDoc.addCodeToSend(code.toString());
            }
        };
        modalLayer.addUnexpectedEventListener(unexpEvtListener);

        int zIndex = modalLayer.getZIndex();

        // Note:  right:X%; alongside width and left fools BlackBerry
        String code = "<p style='position:absolute; z-index:" + zIndex + "; background:aqua; width:90%; height:90%; left:5%; top:5%; padding:10px;' >" +
                      "<b>Modal Layer 1</b><br /><br />" +
                      "These form controls do nothing, the are included to test whether " +
                      "they can be touched below a modal layer.<br /><br />" +
                      "<a href='javascript:;'>Click To Exit</a><br /><br />" +
                      "<select size='5'></select><br />" +
                      "<input type='text' /><br />" +
                      "<textarea/><br />" +
                      "<input type='checkbox' /><br />" +
                      "<input type='radio' name='radioTest' /><input type='radio' name='radioTest' /><br />" +
                      "<input type=\"button\" onclick=\"alert('click')\" value='Button'/><br />" +
                      "<button onclick=\"alert('click')\">Button</button>" +
                      "</p>";

        final HTMLDocument doc = (HTMLDocument)itsNatDoc.getDocument();
        DocumentFragment frag = itsNatDoc.toDOM(code);
        final Element elem = (Element)frag.getFirstChild();
        doc.getBody().appendChild(elem);

        NodeList links = elem.getElementsByTagName("a");
        final HTMLAnchorElement linkExit = (HTMLAnchorElement)links.item(0);

        final HTMLSelectElement select = (HTMLSelectElement)elem.getElementsByTagName("select").item(0);
        final ItsNatHTMLSelectComboBox selectComp = (ItsNatHTMLSelectComboBox)compMgr.createItsNatComponent(select);
        DefaultComboBoxModel model = (DefaultComboBoxModel)selectComp.getComboBoxModel();
        model.addElement("One");
        model.addElement("Two");
        model.addElement("Three");
        model.addElement("Four");
        model.addElement("Five");

        NodeList inputList = elem.getElementsByTagName("input");

        HTMLInputElement inputText = (HTMLInputElement)inputList.item(0);
        final ItsNatHTMLInputText inputTextComp = (ItsNatHTMLInputText)compMgr.createItsNatComponent(inputText);
        inputTextComp.setText("Hello");

        HTMLTextAreaElement textArea = (HTMLTextAreaElement)elem.getElementsByTagName("textarea").item(0);
        final ItsNatHTMLTextArea textAreaComp = (ItsNatHTMLTextArea)compMgr.createItsNatComponent(textArea);
        textAreaComp.setText("Hello");

        HTMLInputElement inputCheck = (HTMLInputElement)inputList.item(1);
        final ItsNatHTMLInputCheckBox inputCheckComp = (ItsNatHTMLInputCheckBox)compMgr.createItsNatComponent(inputCheck);
        inputCheckComp.setSelected(false);

        HTMLInputElement inputRadio1 = (HTMLInputElement)inputList.item(2);
        final ItsNatHTMLInputRadio inputRadioComp1 = (ItsNatHTMLInputRadio)compMgr.createItsNatComponent(inputRadio1);
        inputRadioComp1.setSelected(false);

        HTMLInputElement inputRadio2 = (HTMLInputElement)inputList.item(3);
        final ItsNatHTMLInputRadio inputRadioComp2 = (ItsNatHTMLInputRadio)compMgr.createItsNatComponent(inputRadio2);
        inputRadioComp2.setSelected(false);

        EventListener listenerExit = new EventListener()
        {
            public void handleEvent(Event evt)
View Full Code Here

TOP

Related Classes of org.itsnat.comp.ItsNatComponentManager

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.