Package org.exoplatform.application.gadget

Examples of org.exoplatform.application.gadget.SourceStorage


         {
            // 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");
         }
         uiManagement.reload();

         // update to ApplicationOrganizer
         removeFromApplicationRegistry(name);
View Full Code Here


            UIGadgetEditor uiForm = event.getSource();
            UIGadgetManagement uiManagement = uiForm.getParent();
            String gadgetName;
            String text = uiForm.getUIFormTextAreaInput(UIGadgetEditor.FIELD_SOURCE).getValue();
            GadgetRegistryService service = uiForm.getApplicationComponent(GadgetRegistryService.class);
            SourceStorage sourceStorage = uiForm.getApplicationComponent(SourceStorage.class);
            boolean isEdit = uiForm.isEdit();
            if (isEdit) {
                gadgetName = uiForm.getSourceFullName();
            } 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();
View Full Code Here

            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");
            }
            uiManagement.reload();

            // update to ApplicationOrganizer
            removeFromApplicationRegistry(name);
View Full Code Here

                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);
View Full Code Here

         UIGadgetEditor uiForm = event.getSource();
         UIGadgetManagement uiManagement = uiForm.getParent();
         String gadgetName;
         String text = uiForm.getUIFormTextAreaInput(UIGadgetEditor.FIELD_SOURCE).getValue();
         GadgetRegistryService service = uiForm.getApplicationComponent(GadgetRegistryService.class);
         SourceStorage sourceStorage = uiForm.getApplicationComponent(SourceStorage.class);
         boolean isEdit = uiForm.isEdit();
         if (isEdit)
         {
           gadgetName = uiForm.getSourceFullName();
         }
         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());

         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
View Full Code Here

            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);
View Full Code Here

TOP

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

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.