Package org.itsnat.comp.layer

Examples of org.itsnat.comp.layer.ItsNatModalLayer


        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)
            {
                selectComp.dispose();
                inputTextComp.dispose();
                textAreaComp.dispose();
                inputCheckComp.dispose();
                inputRadioComp1.dispose();
                inputRadioComp2.dispose();

                ((EventTarget)linkExit).removeEventListener("click",this,false);
                doc.getBody().removeChild(elem);
                modalLayer.dispose();
            }
        };

        ((EventTarget)linkExit).addEventListener("click",listenerExit,false);
    }
View Full Code Here


        float opacity = (float)0.1; // Semitransparent
        String background = "black";

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

        // Note:  right:X%; alongside width and left fools BlackBerry
        String code = "<p style='position:absolute; z-index:" + zIndex + "; background:yellow; width:70%; height:70%; left:15%; top:15%; padding:10px;'>" +
                      "<b>Modal Layer 2</b><br /><br />" +
                      "<a href='javascript:;'>Click To Exit</a>" +
                      "</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);

        EventListener listenerExit = new EventListener()
        {
            public void handleEvent(Event evt)
            {
                ((EventTarget)linkExit).removeEventListener("click",this,false);
                doc.getBody().removeChild(elem);
                modalLayer.dispose();
            }
        };

        ((EventTarget)linkExit).addEventListener("click",listenerExit,false);
    }
View Full Code Here

        final ItsNatDocument itsNatDoc = null;
        float opacity = (float)0.1; // Semitransparent
        String background = "black";

        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
        final ItsNatModalLayer modalLayer = compMgr.createItsNatModalLayer(null,false,opacity,background,null);
        int zIndex = modalLayer.getZIndex();

        // Note:  right:X%; alongside width and left fools BlackBerry
        String code = "<p style='position:absolute; z-index:" + zIndex + "; background:yellow; width:70%; height:70%; left:15%; top:15%; padding:10px;'>" +
                      "<b>Modal Layer 2</b><br /><br />" +
                      "<a href='javascript:;'>Click To Exit</a>" +
                      "</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);

        EventListener listenerExit = new EventListener()
        {
            public void handleEvent(Event evt)
            {
                ((EventTarget)linkExit).removeEventListener("click",this,false);
                doc.getBody().removeChild(elem);
                modalLayer.dispose();
            }
        };

        ((EventTarget)linkExit).addEventListener("click",listenerExit,false);
    }
View Full Code Here

    }

    public void showModalView(String code,boolean cleanMode,float opacity,String background)
    {
        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
        final ItsNatModalLayer modalLayer = compMgr.createItsNatModalLayer(null,cleanMode,opacity,background,null);

        EventListener unexpEvtListener = new EventListenerSerial()
        {
            // Por si acaso aunque en general el z-order funciona bien en los casos
            // de soporte SVG decente.
            public void handleEvent(Event evt)
            {
                StringBuilder code = new StringBuilder();
                code.append("if (true == confirm('Received an unexpected event by a hidden element. Reload?')) ")// (true == ...) es para Batik porque confirm devuelve un objeto Boolean no un primitivo
                code.append("   window.location.href = window.location.href; "); // El window.location.reload(true) no funciona en ASV y el Batik esta sentencia funciona como un reload (simulado en el applet para ItsNat)
                itsNatDoc.addCodeToSend(code.toString());
            }
        };
        modalLayer.addUnexpectedEventListener(unexpEvtListener);

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

        NodeList links = elem.getElementsByTagName("a");
        final Element linkExit = (Element)links.item(0);
        final Element linkCheckServ = (Element)links.item(1);

        // Link simplemente para actualizar el cliente con cambios en el servidor
        final EventListener listenerNothing = new EventListenerSerial()
        {
            public void handleEvent(Event evt)
            {
            }
        };
        ((EventTarget)linkCheckServ).addEventListener("click",listenerNothing,false);

        EventListener listenerExit = new EventListenerSerial()
        {
            public void handleEvent(Event evt)
            {
                ((EventTarget)linkCheckServ).removeEventListener("click",listenerNothing,false);
                //((EventTarget)elem).removeEventListener("click",this,false);
                ((EventTarget)linkExit).removeEventListener("click",this,false);
                doc.getDocumentElement().removeChild(elem);
                modalLayer.dispose();
            }
        };

//        ((EventTarget)elem).addEventListener("click",listenerExit,false);
        ((EventTarget)linkExit).addEventListener("click",listenerExit,false);
View Full Code Here

    public static void Modal_Layers_Detection_of_unexpected_events()
    {
    final ItsNatDocument itsNatDoc = null;
    ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
    final ItsNatModalLayer modalLayer = compMgr.createItsNatModalLayer(null,false,0.1f,"black",null);

    EventListener listener = new EventListener()
    {
        public void handleEvent(Event evt)
        {
            StringBuilder code = new StringBuilder();
            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(listener);
    }
View Full Code Here

    }

    public void showModalView(String code,boolean cleanMode,final int x,final int y)
    {
        ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
        final ItsNatModalLayer modalLayer = compMgr.createItsNatModalLayer(null,cleanMode,0.7f,"green",null);

        EventListener unexpEvtListener = new EventListenerSerial()
        {
            public void handleEvent(Event evt)
            {
                StringBuilder code = new StringBuilder();
                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);


        final Element panel = modalLayer.getElement();

        panel.setAttribute("left",Integer.toString(x));
        panel.setAttribute("top",Integer.toString(y));

        DocumentFragment frag = itsNatDoc.toDOM(code);
        final Element elem = (Element)frag.getFirstChild(); // vbox
        panel.appendChild(elem);

        NodeList buttons = elem.getElementsByTagName("button");
        final Element buttonExit = (Element)buttons.item(0);
        final Element buttonCheckServ = (Element)buttons.item(1);

        // Link simplemente para actualizar el cliente con cambios en el servidor
        final EventListener listenerNothing = new EventListenerSerial()
        {
            public void handleEvent(Event evt)
            {
            }
        };
        ((EventTarget)buttonCheckServ).addEventListener("command",listenerNothing,false);

        final EventListener listenerExit = new EventListenerSerial()
        {
            public void handleEvent(Event evt)
            {
                ((EventTarget)buttonCheckServ).removeEventListener("command",listenerNothing,false);
                ((EventTarget)buttonExit).removeEventListener("command",this,false);
                modalLayer.dispose(); // Removes the <panel>
            }
        };

        ((EventTarget)buttonExit).addEventListener("command",listenerExit,false);

        EventListener listenerExit2 = new EventListenerSerial()
        {
            public void handleEvent(Event evt)
            {
                ((EventTarget)buttonCheckServ).removeEventListener("command",listenerNothing,false);
                ((EventTarget)buttonExit).removeEventListener("command",listenerExit,false);
            }
        };
        modalLayer.addEventListener("popuphidden",listenerExit2,true); // before

        EventListener listenerExit3 = new EventListenerSerial()
        {
            public void handleEvent(Event evt)
            {
                if (!modalLayer.isDisposed()) throw new RuntimeException("TEST ERROR");
            }
        };
        modalLayer.addEventListener("popuphidden",listenerExit3,false); // after
    }
View Full Code Here

TOP

Related Classes of org.itsnat.comp.layer.ItsNatModalLayer

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.