javauis/m2g_qt/javasrc/com/nokia/microedition/m2g/M2GSVGElementWrapper.java
changeset 80 d6dafc5d983f
parent 56 abc41079b313
child 87 1627c337e51e
equal deleted inserted replaced
78:71ad690e91f5 80:d6dafc5d983f
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 package com.nokia.microedition.m2g;
       
    19 
       
    20 import org.w3c.dom.events.*;
       
    21 import org.w3c.dom.DOMException;
       
    22 import com.nokia.mj.impl.utils.Logger;
       
    23 
       
    24 public class M2GSVGElementWrapper extends M2GObject implements EventTarget
       
    25 {
       
    26     //--------------------------------------------------
       
    27     // VARIABLES
       
    28     //--------------------------------------------------
       
    29     private M2GSVGElement iElement;
       
    30 
       
    31     //--------------------------------------------------
       
    32     // METHODS
       
    33     //--------------------------------------------------
       
    34     /**
       
    35      * Constructor
       
    36      * @param aElement Element to be wrapped
       
    37      */
       
    38     M2GSVGElementWrapper(M2GSVGElement aElement)
       
    39     {
       
    40         super();
       
    41         iElement = aElement;
       
    42     }
       
    43 
       
    44     /**
       
    45      * Cleanup operations.
       
    46      */
       
    47     void doCleanup()
       
    48     {
       
    49     }
       
    50 
       
    51     /**
       
    52      * Construct operations.
       
    53      */
       
    54     void doConstruct()
       
    55     {
       
    56         if (iElement != null)
       
    57         {
       
    58             setHandle(iElement.getHandle());
       
    59         }
       
    60     }
       
    61 
       
    62     /**
       
    63      * @see org.w3c.dom.events.EventTarget#addEventListener()
       
    64      */
       
    65     public void addEventListener(String type, EventListener listener, boolean useCapture)
       
    66     {
       
    67         if (type == null || type.equals(""))
       
    68         {
       
    69             throw new NullPointerException(M2GSVGElement.TYPE_IS_NULL_ESTR);
       
    70         }
       
    71         if (listener == null)
       
    72         {
       
    73             throw new NullPointerException(M2GSVGElement.LISTENER_IS_NULL_ESTR);
       
    74         }
       
    75         if (useCapture == true)
       
    76         {
       
    77             throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
       
    78                                    M2GSVGElement.CAPTURE_NOT_SUPPORTED_ESTR);
       
    79         }
       
    80         try
       
    81         {
       
    82             iElement.getDocument().register(iElement, type, listener);
       
    83         }
       
    84         catch (Exception e)
       
    85         {
       
    86             Logger.ELOG(Logger.EJavaUI, "addEventListener() exception:" + e.toString());
       
    87         }
       
    88     }
       
    89 
       
    90     /**
       
    91      * Get wrapped target element
       
    92      * @return Event target
       
    93      */
       
    94     public EventTarget getWrappedTarget()
       
    95     {
       
    96         return iElement;
       
    97     }
       
    98 
       
    99     /**
       
   100      * @see org.w3c.dom.events.EventTarget#removeEventListener()
       
   101      */
       
   102     public void removeEventListener(String type, EventListener listener, boolean useCapture)
       
   103     {
       
   104         if (type == null || type.equals(""))
       
   105         {
       
   106             throw new NullPointerException(M2GSVGElement.TYPE_IS_NULL_ESTR);
       
   107         }
       
   108         if (listener == null)
       
   109         {
       
   110             throw new NullPointerException(M2GSVGElement.LISTENER_IS_NULL_ESTR);
       
   111         }
       
   112         if (useCapture == true)
       
   113         {
       
   114             throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
       
   115                                    M2GSVGElement.CAPTURE_NOT_SUPPORTED_ESTR);
       
   116         }
       
   117         try
       
   118         {
       
   119             iElement.getDocument().unregister(iElement, type, listener);
       
   120         }
       
   121         catch (Exception e)
       
   122         {
       
   123             Logger.ELOG(Logger.EJavaUI, "removeEventListener() exception:" + e.toString());
       
   124         }
       
   125     }
       
   126 }