themeinstaller/source/src/com/nokia/tools/themeinstaller/cssparser/ElementTypeResolver.java
branchRCL_3
changeset 32 fe49e33862e2
parent 31 b685c59de105
child 33 04b7640f6fb5
equal deleted inserted replaced
31:b685c59de105 32:fe49e33862e2
     1 /*
       
     2 * Copyright (c) 2007 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:  ElementTypeResolver for Different element types
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 package com.nokia.tools.themeinstaller.cssparser;
       
    20 
       
    21 import java.util.Hashtable;
       
    22 
       
    23 /**
       
    24  * Resolves different element types by element name.
       
    25  *
       
    26  * Constants copied from Symbian side files:
       
    27  *   ..\EComElement\XnDomVisitor\src\xndomvisitor.cpp
       
    28  * and
       
    29  *   ..\EComElement\XnDomVisitor\inc\xnliteral.h
       
    30  *
       
    31  */
       
    32 public class ElementTypeResolver
       
    33     {
       
    34     public static final String STRING_NONE                  = "none";
       
    35     public static final String STRING_UNSPECIFIED           = "unspecified";
       
    36     public static final String KProperty                    = "property";
       
    37 
       
    38     //Ui
       
    39     public static final String KXmluiml                     = "xmluiml";
       
    40     public static final String KInclude                     = "include";
       
    41     public static final String KViews                       = "views";
       
    42     public static final String KView                        = "view";
       
    43     public static final String KPanes                       = "panes";
       
    44     public static final String KStatusPane                  = "statuspane";
       
    45     public static final String KMainPane                    = "mainpane";
       
    46     public static final String KControlPane                 = "controlpane";
       
    47     public static final String KDialogs                     = "dialogs";
       
    48     public static final String KDialog                      = "dialog";
       
    49     public static final String KNote                        = "note";
       
    50 
       
    51     //Header
       
    52     public static final String KUiDefinition                = "uidefinition";
       
    53     public static final String KApplication                 = "application";
       
    54     public static final String KDesc                        = "desc";
       
    55 
       
    56     //Control
       
    57     public static final String KButton                      = "button";
       
    58     public static final String KGrid                        = "grid";
       
    59     public static final String KListItem                    = "listitem";
       
    60     public static final String KDataGrid                    = "datagrid";
       
    61     public static final String KGridCellTemplate            = "gridcelltemplate";
       
    62     public static final String KList                        = "list";
       
    63     public static final String KDataList                    = "datalist";
       
    64     public static final String KListRowTemplate             = "listrowtemplate";
       
    65     public static final String KMenuBar                     = "menubar";
       
    66     public static final String KMenu                        = "menu";
       
    67     public static final String KMenuItem                    = "menuitem";
       
    68     public static final String KText                        = "text";
       
    69     public static final String KImage                       = "image";
       
    70     public static final String KEditor                      = "editor";
       
    71     public static final String KMarquee                     = "marquee";
       
    72     public static final String KNewsticker                  = "newsticker";
       
    73     public static final String KTooltip                     = "tooltip";
       
    74 
       
    75     //XHTML
       
    76     public static final String KObject                      = "object";
       
    77     public static final String KParam                       = "param";
       
    78 
       
    79     //Box
       
    80     public static final String KBox                         = "box";
       
    81 
       
    82     //Interaction
       
    83     public static final String KAction                      = "action";
       
    84     public static final String KTrigger                     = "trigger";
       
    85     public static final String KEvent                       = "event";
       
    86 
       
    87     public static final String VIEW_ELEMENT                 = "viewElement";
       
    88     public static final String COMMON_ELEMENT               = "commonElement";
       
    89     public static final String TEXT_ELEMENT                 = "textElement";
       
    90     public static final String GRID_AND_DATAGRID_ELEMENT    = "gridAndDataGridelement";
       
    91     public static final String GRID_AND_LIST_ELEMENT        = "gridAndListElement";
       
    92 
       
    93     private Hashtable iElementTypeTable;
       
    94 
       
    95     /**
       
    96      * Instantiates a new element type resolver.
       
    97      */
       
    98     public ElementTypeResolver()
       
    99         {
       
   100         iElementTypeTable = new Hashtable();
       
   101         iElementTypeTable.put( KXmluiml,           STRING_UNSPECIFIED           );
       
   102         iElementTypeTable.put( KProperty,          STRING_UNSPECIFIED           );
       
   103         iElementTypeTable.put( KXmluiml,           STRING_UNSPECIFIED           );
       
   104         iElementTypeTable.put( KInclude,           STRING_UNSPECIFIED           );
       
   105         iElementTypeTable.put( KViews,             STRING_UNSPECIFIED           );
       
   106         iElementTypeTable.put( KView,              VIEW_ELEMENT                 );
       
   107         iElementTypeTable.put( KPanes,             COMMON_ELEMENT               );
       
   108         iElementTypeTable.put( KStatusPane,        COMMON_ELEMENT               );
       
   109         iElementTypeTable.put( KMainPane,          COMMON_ELEMENT               );
       
   110         iElementTypeTable.put( KControlPane,       COMMON_ELEMENT               );
       
   111         iElementTypeTable.put( KDialogs,           COMMON_ELEMENT               );
       
   112         iElementTypeTable.put( KDialog,            COMMON_ELEMENT               );
       
   113         iElementTypeTable.put( KNote,              TEXT_ELEMENT                 );
       
   114         iElementTypeTable.put( KUiDefinition,      STRING_UNSPECIFIED           );
       
   115         iElementTypeTable.put( KApplication,       STRING_UNSPECIFIED           );
       
   116         iElementTypeTable.put( KDesc,              STRING_UNSPECIFIED           );
       
   117         iElementTypeTable.put( KButton,            TEXT_ELEMENT                 );
       
   118         iElementTypeTable.put( KGrid,              GRID_AND_DATAGRID_ELEMENT    );
       
   119         iElementTypeTable.put( KListItem,          TEXT_ELEMENT                 );
       
   120         iElementTypeTable.put( KDataGrid,          GRID_AND_DATAGRID_ELEMENT    );
       
   121         iElementTypeTable.put( KGridCellTemplate,  COMMON_ELEMENT               );
       
   122         iElementTypeTable.put( KList,              GRID_AND_LIST_ELEMENT        );
       
   123         iElementTypeTable.put( KDataList,          GRID_AND_LIST_ELEMENT        );
       
   124         iElementTypeTable.put( KListRowTemplate,   COMMON_ELEMENT               );
       
   125         iElementTypeTable.put( KMenuBar,           STRING_UNSPECIFIED           );
       
   126         iElementTypeTable.put( KMenu,              STRING_UNSPECIFIED           );
       
   127         iElementTypeTable.put( KMenuItem,          STRING_UNSPECIFIED           );
       
   128         iElementTypeTable.put( KText,              TEXT_ELEMENT                 );
       
   129         iElementTypeTable.put( KImage,             COMMON_ELEMENT               );
       
   130         iElementTypeTable.put( KEditor,            TEXT_ELEMENT                 );
       
   131         iElementTypeTable.put( KMarquee,           TEXT_ELEMENT                 );
       
   132         iElementTypeTable.put( KNewsticker,        TEXT_ELEMENT                 );
       
   133         iElementTypeTable.put( KObject,            STRING_UNSPECIFIED           );
       
   134         iElementTypeTable.put( KParam,             STRING_UNSPECIFIED           );
       
   135         iElementTypeTable.put( KTooltip,           TEXT_ELEMENT                 );
       
   136         iElementTypeTable.put( KBox,               COMMON_ELEMENT               );
       
   137         iElementTypeTable.put( KAction,            STRING_UNSPECIFIED           );
       
   138         iElementTypeTable.put( KTrigger,           STRING_UNSPECIFIED           );
       
   139         iElementTypeTable.put( KEvent,             STRING_UNSPECIFIED           );
       
   140         }
       
   141 
       
   142     /**
       
   143      * Gets the elements type.
       
   144      *
       
   145      * @param aKey Elements name
       
   146      *
       
   147      * @return The elements type
       
   148      */
       
   149     public String getValue( String aKey )
       
   150         {
       
   151         if ( iElementTypeTable.containsKey( aKey ) )
       
   152             {
       
   153             return ( String ) iElementTypeTable.get( aKey );
       
   154             }
       
   155         return STRING_NONE;
       
   156         }
       
   157 
       
   158     /**
       
   159      * Resolves if element can have inherited properties.
       
   160      *
       
   161      * @param aKey Elements name
       
   162      *
       
   163      * @return true, Element with given name can inherit properties
       
   164      */
       
   165     public boolean canInherit( String aKey )
       
   166         {
       
   167         if ( !iElementTypeTable.containsKey( aKey ) )
       
   168             {
       
   169             return false;
       
   170             }
       
   171         if ( iElementTypeTable.get( aKey ).equals( STRING_UNSPECIFIED ) )
       
   172             {
       
   173             return false;
       
   174             }
       
   175         return true;
       
   176         }
       
   177     }