Package org.exoplatform.application.gadget

Examples of org.exoplatform.application.gadget.Gadget


            } else {
                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());

            try {
                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);

                // Send request to invalidate the cache to Shindig
                String gadgetServerUrl = GadgetUtil.getGadgetServerUrl();
                String gadgetUrl = GadgetUtil.reproduceUrl(gadget.getUrl(), gadget.isLocal());
                String metadataUrl = gadgetServerUrl + (gadgetServerUrl.endsWith("/") ? "" : "/") + "metadata";
                String queryString = "{\"context\":{\"ignoreCache\":\"true\"},\"gadgets\":[" + "{\"url\":\"" + gadgetUrl
                        + "\"}]}";
                event.getRequestContext().getJavascriptManager().require("SHARED/base")
                        .addScripts("ajaxRequest('POST', '" + metadataUrl + "', true, '" + queryString + "');");
View Full Code Here


    public static class CancelActionListener extends EventListener<UIGadgetEditor> {

        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

        // Correct IconUrl of gadget
        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

                }
            }
            service.removeGadget(name);
            WebAppController webController = uiManagement.getApplicationComponent(WebAppController.class);
            webController.removeApplication(EXO_GADGET_GROUP + "/" + name);
            Gadget gadget = uiManagement.getGadget(name);
            if (gadget.isLocal()) {
                // get dir path of gadget
                String gadgetUrl = gadget.getUrl();
                String[] gaggetUrlPart = gadgetUrl.split("/");
                String dirPath = gaggetUrlPart[gaggetUrlPart.length - 2];
                SourceStorage sourceStorage = uiManagement.getApplicationComponent(SourceStorage.class);
                sourceStorage.removeSource(dirPath + "/" + name + ".xml");
            }
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 static class EditActionListener extends EventListener<UIGadgetInfo> {

        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);
            selector.setRendered(true);
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

         {
            UIApplication uiApp = context.getUIApplication();
            uiApp.addMessage(new ApplicationMessage("UIAddGadget.label.urlExist", null));
            return;
         }
         Gadget gadget;
         try
         {
            gadget = GadgetUtil.toGadget(name, url, false);
         }
         catch (Exception e)
View Full Code Here

      public void execute(Event<UIAddGadget> event) throws Exception
      {
         UIAddGadget 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

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.