Package org.gatein.mop.api.workspace.ui

Examples of org.gatein.mop.api.workspace.ui.UIContainer


        for (UIComponent component : src.getComponents()) {

            // Obtain a model object from the ui component
            ComponentData mo;
            if (component instanceof UIContainer) {
                UIContainer srcContainer = (UIContainer) component;
                Attributes attrs = srcContainer.getAttributes();
                String type = attrs.getValue(MappedAttributes.TYPE);
                if ("dashboard".equals(type)) {
                    Site owner = src.getPage().getSite();
                    TransientApplicationState<Portlet> state = new TransientApplicationState<Portlet>(
                            "dashboard/DashboardPortlet", null, getOwnerType(owner.getObjectType()), owner.getName());

                    //
                    boolean showInfoBar = attrs.getValue(MappedAttributes.SHOW_INFO_BAR, false);
                    boolean showMode = attrs.getValue(MappedAttributes.SHOW_MODE, false);
                    boolean showWindowState = attrs.getValue(MappedAttributes.SHOW_WINDOW_STATE, false);
                    String theme = attrs.getValue(MappedAttributes.THEME, null);

                    Described described = srcContainer.adapt(Described.class);

                    String id = attrs.getValue(MappedAttributes.ID, null);
                    String icon = attrs.getValue(MappedAttributes.ICON, null);
                    String width = attrs.getValue(MappedAttributes.WIDTH, null);
                    String height = attrs.getValue(MappedAttributes.HEIGHT, null);

                    //
                    List<String> a = Collections.singletonList(UserACL.EVERYONE);
                    if (srcContainer.isAdapted(ProtectedResource.class)) {
                        ProtectedResource pr = srcContainer.adapt(ProtectedResource.class);
                        a = pr.getAccessPermissions();
                    }

                    //
                    mo = new ApplicationData<Portlet>(srcContainer.getObjectId(), component.getName(), ApplicationType.PORTLET,
                            state, id, described.getName(), icon, described.getDescription(), showInfoBar, showWindowState,
                            showMode, theme, width, height, Collections.<String, String> emptyMap(), a);
                } else {
                    List<ComponentData> dstChildren = loadChildren(srcContainer);
                    mo = load(srcContainer, dstChildren);
View Full Code Here


        } else {
            changes.add(new ModelChange.Update(src));
        }

        //
        UIContainer rootContainer = dst.getRootComponent();

        // We are creating a new Page with the root container id as this one is lost
        // in the model / ui layer. Not doing this cause a class cast exception later
        // so it's likely the best fix we can do at the moment
        PageData src2 = new PageData(rootContainer.getObjectId(), src.getId(), src.getName(), src.getIcon(), src.getTemplate(),
                null, null, null, src.getWidth(), src.getHeight(), Collections.<String> emptyList(), src.getChildren(),
                src.getOwnerType(), src.getOwnerId(), null, false);

        //
        LinkedList<ModelChange> childrenChanges = saveChildren(src2, rootContainer);
View Full Code Here

                    TransientApplicationState<?> state = (TransientApplicationState<?>) app.getState();
                    String contentId = state.getContentId();
                    if ("dashboard/DashboardPortlet".equals(contentId)) {
                        DashboardData data;
                        if (app.getStorageId() != null) {
                            UIContainer dstDashboard = session.findObjectById(ObjectType.CONTAINER, app.getStorageId());
                            data = loadDashboard(dstDashboard);

                            // Update those attributes as we have to do it now, they don't exist in a container
                            // but do exist in a dashboard container
                            Attributes attrs = dstDashboard.getAttributes();
                            attrs.setValue(MappedAttributes.SHOW_INFO_BAR, app.isShowInfoBar());
                            attrs.setValue(MappedAttributes.SHOW_MODE, app.isShowApplicationMode());
                            attrs.setValue(MappedAttributes.SHOW_WINDOW_STATE, app.isShowApplicationState());
                            attrs.setValue(MappedAttributes.THEME, app.getTheme());
                        } else {
                            data = DashboardData.INITIAL_DASHBOARD;
                            transientDashboardData = (ApplicationData<?>) srcChild;
                        }

                        //
                        String icon = data.getIcon();
                        if (icon == null)
                            icon = app.getIcon();

                        String title = data.getTitle();
                        if (title == null)
                            title = app.getTitle();

                        String description = data.getDescription();
                        if (description == null)
                            description = app.getDescription();

                        String width = data.getWidth();
                        if (width == null)
                            width = app.getWidth();

                        String height = data.getHeight();
                        if (height == null)
                            height = app.getHeight();

                        data = new DashboardData(data.getStorageId(), data.getId(), data.getName(), icon, data.getTemplate(),
                                data.getFactoryId(), title, description, width, height, app.getAccessPermissions(),
                                data.getChildren());

                        //
                        srcChild = data;
                    }
                }
            }

            //
            UIComponent dstChild;
            if (srcChildId != null) {
                dstChild = session.findObjectById(ObjectType.COMPONENT, srcChildId);
                if (dstChild == null) {
                    throw new StaleModelException("Could not find supposed present child with id " + srcChildId);
                }

                // julien : this can fail due to a bug in chromattic not implementing equals method properly
                // and is replaced with the foreach below
                /*
                 * if (!dst.contains(dstChild)) { throw new IllegalArgumentException("Attempt for updating a ui component " +
                 * session.pathOf(dstChild) + "that is not present in the target ui container " + session.pathOf(dst)); }
                 */
                boolean found = false;
                for (UIComponent child : dst.getComponents()) {
                    if (child.getObjectId().equals(srcChildId)) {
                        found = true;
                        break;
                    }
                }

                //
                if (!found) {
                    if (hierarchyRelationships.containsKey(srcChildId)) {
                        String srcId = hierarchyRelationships.get(srcChildId);

                        // It's a move operation, so we move the node first
                        dst.getComponents().add(dstChild);

                        //
                        changes.add(new ModelChange.Move(srcId, dst.getObjectId(), srcChildId));
                    } else {
                        throw new IllegalArgumentException("Attempt for updating a ui component " + session.pathOf(dstChild)
                                + " that is not present in the target ui container " + session.pathOf(dst));
                    }
                }

                //
                changes.add(new ModelChange.Update(srcChild));
            } else {
                String name = srcChild.getStorageName();
                if (name == null) {
                    // We manufacture one name
                    name = UUID.randomUUID().toString();
                }
                if (srcChild instanceof ContainerData) {
                    dstChild = dst.add(ObjectType.CONTAINER, name);
                } else if (srcChild instanceof ApplicationData) {
                    dstChild = dst.add(ObjectType.WINDOW, name);
                } else if (srcChild instanceof BodyData) {
                    dstChild = dst.add(ObjectType.BODY, name);
                } else {
                    throw new StaleModelException("Was not expecting child " + srcChild);
                }
                changes.add(new ModelChange.Create(dst.getObjectId(), srcChild));
            }

            //
            if (transientDashboardData != null) {
                Attributes attrs = dstChild.getAttributes();
                attrs.setValue(MappedAttributes.SHOW_INFO_BAR, transientDashboardData.isShowInfoBar());
                attrs.setValue(MappedAttributes.SHOW_MODE, transientDashboardData.isShowApplicationMode());
                attrs.setValue(MappedAttributes.SHOW_WINDOW_STATE, transientDashboardData.isShowApplicationState());
                attrs.setValue(MappedAttributes.THEME, transientDashboardData.getTheme());
            }
            save(srcChild, dstChild, changes, hierarchyRelationships);

            //
            String dstChildId = dstChild.getObjectId();
            modelObjectMap.put(dstChildId, srcChild);
            orders.add(dstChildId);
        }

        // Take care of move operation that could be seen as a remove otherwise
        for (UIComponent dstChild : dst.getComponents()) {
            String dstChildId = dstChild.getObjectId();
            if (!modelObjectMap.containsKey(dstChildId)) {
                String parentId = hierarchyRelationships.get(dstChildId);
                if (parentId != null) {
                    // Get the new parent
                    UIContainer parent = session.findObjectById(ObjectType.CONTAINER, parentId);

                    // Perform the move
                    parent.getComponents().add(dstChild);

                    //
                    changes.add(new ModelChange.Move(dst.getObjectId(), parentId, dstChildId));

                    // julien : we do not need to create an update operation
View Full Code Here

                } else {
                    Object state = customization.getVirtualState();
                    dstWindow.customize(contentType, contentId, state);
                }
            } else if (srcChild instanceof UIContainer) {
                UIContainer srcContainer = (UIContainer) srcChild;
                UIContainer dstContainer = (UIContainer) dstChild;
                copy(srcPage, dstPage, srcContainer, dstContainer);
            }
        }
    }
View Full Code Here

    }

    private void addPage(Page page) {
        PageInfo pageInfo = new PageInfo(page);
        pageInfos.put(pageInfo.getId(), pageInfo);
        UIContainer container = page.getRootComponent();
        processContainer(container, pageInfo);

        Collection<Page> children = page.getChildren();
        if (ParameterValidation.existsAndIsNotEmpty(children)) {
            for (Page child : children) {
View Full Code Here

                  dstWindow.customize(contentType, contentId, state);
               }
            }
            else if (srcChild instanceof UIContainer)
            {
               UIContainer srcContainer = (UIContainer)srcChild;
               UIContainer dstContainer = (UIContainer)dstChild;
               copy(srcPage, dstPage, srcContainer, dstContainer);
            }
         }
      }
View Full Code Here

      Attributes attrs = src.getAttributes();

      //
      Templatized templarized = src.getRootNavigation().getTemplatized();
      org.gatein.mop.api.workspace.Page template = templarized.getTemplate();
      UIContainer srcLayout = template.getRootComponent();

      //
      Map<String, String> properties = new HashMap<String, String>();
      load(attrs, properties, portalPropertiesBlackList);
View Full Code Here

         template = templates.addChild("default");
      }

      //
      ContainerData srcContainer = src.getPortalLayout();
      UIContainer dstContainer = template.getRootComponent();

      //
      save(srcContainer, dstContainer);
      saveChildren(srcContainer, dstContainer);
View Full Code Here

         // Obtain a model object from the ui component
         ComponentData mo;
         if (component instanceof UIContainer)
         {
            UIContainer srcContainer = (UIContainer)component;
            Attributes attrs = srcContainer.getAttributes();
            String type = attrs.getValue(MappedAttributes.TYPE);
            if ("dashboard".equals(type))
            {
               Site owner = src.getPage().getSite();
               TransientApplicationState<Portlet> state = new TransientApplicationState<Portlet>(
                  "dashboard/DashboardPortlet",
                  null,
                  getOwnerType(owner.getObjectType()),
                  owner.getName(),
                  null
               );

               //
               boolean showInfoBar = attrs.getValue(MappedAttributes.SHOW_INFO_BAR, false);
               boolean showMode = attrs.getValue(MappedAttributes.SHOW_MODE, false);
               boolean showWindowState = attrs.getValue(MappedAttributes.SHOW_WINDOW_STATE, false);
               String theme = attrs.getValue(MappedAttributes.THEME, null);

               //
               mo = new ApplicationData<Portlet>(
                  srcContainer.getObjectId(),
                  component.getName(),
                  ApplicationType.PORTLET,
                  state,
                  null,
                  null,
View Full Code Here

      Attributes attrs = dst.getAttributes();
      attrs.setValue(MappedAttributes.FACTORY_ID, src.getFactoryId());
      attrs.setValue(MappedAttributes.SHOW_MAX_WINDOW, src.isShowMaxWindow());

      //
      UIContainer rootContainer = dst.getRootComponent();
      LinkedList<ModelChange> childrenChanges = saveChildren(src, rootContainer);

      //
      changes.addAll(childrenChanges);
View Full Code Here

TOP

Related Classes of org.gatein.mop.api.workspace.ui.UIContainer

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.