Package org.exoplatform.application.gadget

Examples of org.exoplatform.application.gadget.Gadget


         {
           gadgetName = uiForm.getUIStringInput(UIGadgetEditor.FIELD_NAME).getValue();
         }

         //
         Gadget gadget = service.getGadget(gadgetName);
        
         if(isEdit) {
           if (gadget == null)
             {
                UIApplication uiApp = event.getRequestContext().getUIApplication();
                uiApp.addMessage(new ApplicationMessage("gadget.msg.changeNotExist", null, ApplicationMessage.WARNING));
                uiManagement.reload();
                return;
             }
         }
         else {
          // If gadget is null we need to create it first
             if (gadget == null)
             {
                gadget = new Gadget();
                gadget.setName(gadgetName);

                // Those data will be taken from the gadget XML anyway
                gadget.setDescription("");
                gadget.setThumbnail("");
                gadget.setLocal(true);
                gadget.setTitle("");
                gadget.setReferenceUrl("");

                // Save gadget with empty data first
                service.saveGadget(gadget);
             }
             else {
             UIApplication uiApp = event.getRequestContext().getUIApplication();
                 uiApp.addMessage(new ApplicationMessage("UIGadgetEditor.gadget.msg.gadgetIsExist", null, ApplicationMessage.WARNING));
                 return;
           }
         }
         //
         Source source = new Source(gadgetName, "application/xml");
         source.setTextContent(text);
         source.setLastModified(Calendar.getInstance());

         sourceStorage.saveSource(gadget, source);

         uiManagement.removeChild(UIGadgetEditor.class);
         // This will update the source and also update the gadget related
         // cached meta data
         // from the source
         uiManagement.initData();
         uiManagement.setSelectedGadget(gadget.getName());
         event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
      }
View Full Code Here


      public void execute(Event<UIGadgetEditor> event) throws Exception
      {
         UIGadgetEditor uiForm = event.getSource();
         UIGadgetManagement uiManagement = uiForm.getParent();
         Gadget selectedGadget = uiManagement.getSelectedGadget();
         if (selectedGadget != null)
         {
            uiManagement.setSelectedGadget(selectedGadget.getName());
         }
         else
            uiManagement.reload();
         event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
      }
View Full Code Here

      public void execute(Event<UIGadgetInfo> event) throws Exception
      {
         UIGadgetInfo uiInfo = event.getSource();
         WebuiRequestContext ctx = event.getRequestContext();
         UIGadgetManagement uiManagement = uiInfo.getParent();
         Gadget gadget = uiInfo.getGadget();
         GadgetRegistryService service = uiInfo.getApplicationComponent(GadgetRegistryService.class);
         if (service.getGadget(gadget.getName()) == null)
         {
            UIApplication uiApp = ctx.getUIApplication();
            uiApp.addMessage(new ApplicationMessage("UIGadgetInfo.msg.gadgetNotExist", null));
            uiManagement.reload();
            return;
         }
         service.saveGadget(GadgetUtil.toGadget(gadget.getName(), gadget.getUrl(), gadget.isLocal()));
         uiManagement.initData();
         uiManagement.setSelectedGadget(gadget.getName());
         ctx.addUIComponentToUpdateByAjax(uiManagement);
      }
View Full Code Here

   {

      public void execute(Event<UIGadgetInfo> event) throws Exception
      {
         UIGadgetInfo uiInfo = event.getSource();
         Gadget gadget = uiInfo.getGadget();

         UIGadgetManagement uiManagement = uiInfo.getParent();
         GadgetRegistryService service = uiInfo.getApplicationComponent(GadgetRegistryService.class);
         if (service.getGadget(gadget.getName()) == null)
         {
            UIApplication uiApp = event.getRequestContext().getUIApplication();
            uiApp.addMessage(new ApplicationMessage("UIGadgetInfo.msg.gadgetNotExist", null));
            uiManagement.reload();
            return;
         }
         SourceStorage sourceStorage = uiManagement.getApplicationComponent(SourceStorage.class);
         UIGadgetEditor uiEditor = uiManagement.createUIComponent(UIGadgetEditor.class, null, null);
         String fileName = gadget.getName() + ".xml";
         // get dir path of gadget
         String gadgetUrl = gadget.getUrl();
         String[] gaggetUrlPart = gadgetUrl.split("/");
         String dirPath = gaggetUrlPart[gaggetUrlPart.length - 2];
         //String dirPath = gaggetUrlPart[gaggetUrlPart.length - 9];
         // get gadget's source: path = dir path + file name
         Source source = sourceStorage.getSource(gadget);
         uiEditor.setSource(source);
         uiEditor.setGadgetName(gadget.getName());
         uiEditor.setDirPath(dirPath);
         uiManagement.getChildren().clear();
         uiManagement.addChild(uiEditor);
         event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
      }
View Full Code Here

            UIApplication uiApp = event.getRequestContext().getUIApplication();
            uiApp.addMessage(new ApplicationMessage("UICategorySelector.msg.NoCategory", null));
            return;
         }
        
         Gadget gadget = gadgetInfo.getGadget();
         gadgetInfo.removeChild(UICategorySelector.class);
         UICategorySelector selector = gadgetInfo.addChild(UICategorySelector.class, null, CATEGORY_ID);
         Application app = new Application();
         app.setApplicationName(gadget.getName());
         app.setType(ApplicationType.GADGET);
         app.setDisplayName(gadget.getTitle());
         app.setContentId(gadget.getName());
         String description =
            (gadget.getDescription() == null || gadget.getDescription().length() < 1) ? gadget.getName() : gadget
               .getDescription();
         app.setDescription(description);
         app.setAccessPermissions(new ArrayList<String>());
        
         selector.setApplication(app);
View Full Code Here

      GadgetRegistryService gadgetService = getApplicationComponent(GadgetRegistryService.class);
      for (Application app : applications)
      {
         if (ApplicationType.GADGET.equals(app.getType()))
         {
            Gadget gadget = gadgetService.getGadget(app.getApplicationName());
            if (gadget != null)
               app.setIconURL(gadget.getThumbnail());
         }
      }

      setSelectedApplication(applications.get(0));
   }
View Full Code Here

            url = url.trim();
            if (!url.matches(URLValidator.URL_REGEX)) {
                uiApplication.addMessage(new ApplicationMessage("UIDashboard.msg.notUrl", null));
                return;
            }
            Gadget gadget;
            UIGadget uiGadget;

            // TODO check the way we create the unique ID, is it really unique?
            try {
                String name = "gadget" + url.hashCode();
                gadget = GadgetUtil.toGadget(name, url, false);
                service.saveGadget(gadget);
                uiGadget = uiForm.createUIComponent(context, UIGadget.class, null, null);
                uiGadget.setState(new TransientApplicationState<org.exoplatform.portal.pom.spi.gadget.Gadget>(gadget.getName()));
            } catch (Exception e) {
                String aggregatorId = uiDashboard.getAggregatorId();
                gadget = service.getGadget(aggregatorId);
                // TODO make sure it's an rss feed
                // TODO make sure that we did not add it already
                uiGadget = uiForm.createUIComponent(context, UIGadget.class, null, null);

                org.exoplatform.portal.pom.spi.gadget.Gadget contentState = new org.exoplatform.portal.pom.spi.gadget.Gadget();
                contentState.addUserPref("{'rssurl':'" + url + "'}");
                TransientApplicationState<org.exoplatform.portal.pom.spi.gadget.Gadget> applicationState = new TransientApplicationState<org.exoplatform.portal.pom.spi.gadget.Gadget>(
                        gadget.getName(), contentState);

                uiGadget.setState(applicationState);
            }

            uiContainer.addUIGadget(uiGadget, 0, 0);
View Full Code Here

      {
         if (ApplicationType.GADGET.equals(app.getType()))
         {
            try
            {
               Gadget gadget;
               gadget = gadgetService.getGadget(app.getApplicationName());
               if (gadget != null)
                  app.setIconURL(gadget.getThumbnail());
            }
            catch (Exception e)
            {
            }
         }
View Full Code Here

      return new GadgetApplication(model.getName(), model.getUrl(), model.isLocal());
   }

   static public Gadget toGadget(String name, String path, boolean isLocal) throws Exception
   {
      Gadget gadget = new Gadget();
      gadget.setName(name);
      gadget.setUrl(path);
      gadget.setLocal(isLocal);
      Map<String, String> metaData = getMapMetadata(reproduceUrl(path, isLocal));
      if (metaData.containsKey("errors"))
         throw new Exception("error on the server: " + metaData.get("errors"));
      String title = metaData.get("directoryTitle");
      if (title == null || title.trim().length() < 1)
         title = metaData.get("title");
      if (title == null || title.trim().length() < 1)
         title = gadget.getName();
      gadget.setTitle(title);
      gadget.setDescription(metaData.get("description"));
      gadget.setReferenceUrl(metaData.get("titleUrl"));
      gadget.setThumbnail(metaData.get("thumbnail"));
      return gadget;
   }
View Full Code Here

      WebAppController webController = getApplicationComponent(WebAppController.class);
      GadgetApplication application = webController.getApplication("eXoGadgets/" + gadgetId);
      if (application == null)
      {
         GadgetRegistryService gadgetService = getApplicationComponent(GadgetRegistryService.class);
         Gadget model;
         try
         {
            model = gadgetService.getGadget(gadgetId);
         }
         catch (Exception ex)
View Full Code Here

TOP

Related Classes of org.exoplatform.application.gadget.Gadget

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.