Package com.cosmo.ui.widgets

Examples of com.cosmo.ui.widgets.MenuItem


      Node menuNode;
      Element eElement;
      Element menuElement;
      NodeList menuList;
      NodeList nList;
      MenuItem menuitem;
      ArrayList<MenuItem> menuItems = new ArrayList<MenuItem>();

      try
      {
         fileName = File.separator + "WEB-INF" + File.separator + WorkspaceProperties.PROPERTIES_FILENAME;
         is = new FileInputStream(workspace.getServerContext().getRealPath(fileName));

         DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
         Document doc = dBuilder.parse(is);
         doc.getDocumentElement().normalize();

         // Obtiene los elementos de men�
         menuList = doc.getElementsByTagName(CosmoStaticMenuProvider.XML_NODE_MENU);
         for (int menuId = 0; menuId < menuList.getLength(); menuId++)
         {
            menuNode = menuList.item(menuId);
            if (menuNode.getNodeType() == Node.ELEMENT_NODE)
            {
               menuElement = (Element) menuNode;
               if (MenuWidget.convertToMenuType(menuElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_TYPE)) == type)
               {
                  mtype = MenuWidget.convertToMenuType(menuElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_TYPE));
                  if (mtype == type)
                  {
                     // Obtiene los elementos de men� est�ticos
                     nList = menuElement.getElementsByTagName(CosmoStaticMenuProvider.XML_NODE_MENUITEM);
                     for (int temp = 0; temp < nList.getLength(); temp++)
                     {
                        nNode = nList.item(temp);
                        if (nNode.getNodeType() == Node.ELEMENT_NODE)
                        {
                           eElement = (Element) nNode;
                           menuitem = new MenuItem(eElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_ID),
                                                   eElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_NAME),
                                                   eElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_HREF),
                                                   eElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_PARENT));

                           // Si existe icono especificado, lo agrega
                           if (eElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_ICON) != null)
                           {
                              menuitem.setIcon(eElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_ICON));
                           }

                           menuItems.add(menuitem);
                        }
                     }

                     // Obtiene las secciones din�micas
                     String source;
                     nList = menuElement.getElementsByTagName(CosmoStaticMenuProvider.XML_NODE_MENUSECTION);
                     for (int temp = 0; temp < nList.getLength(); temp++)
                     {
                        nNode = nList.item(temp);
                        if (nNode.getNodeType() == Node.ELEMENT_NODE)
                        {
                           eElement = (Element) nNode;
                           source = eElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_SOURCE);

                           if (!StringUtils.isNullOrEmptyTrim(source))
                           {
                              if (source.equalsIgnoreCase("corm-apps"))
                              {
                                 for (OrmApplication app : workspace.getProperties().getOrmProperties().getOrmApplications())
                                 {
                                    menuitem = new MenuItem(app.getId(),
                                                            app.getTitle(),
                                                            app.getApplicationUrl(workspace),
                                                            "");

                                    // Si existe icono especificado, lo agrega
                                    if (!StringUtils.isNullOrEmptyTrim(eElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_ICON)))
                                    {
                                       menuitem.setIcon(eElement.getAttribute(CosmoStaticMenuProvider.XML_ATT_ICON));
                                    }

                                    menuItems.add(menuitem);
                                 }
                              }
View Full Code Here

TOP

Related Classes of com.cosmo.ui.widgets.MenuItem

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.