Author: theute
Date: 2011-08-18 15:06:18 -0400 (Thu, 18 Aug 2011)
New Revision: 7178
Modified:
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
Log:
JBEPP-1088
Use list instead of textfield in page management when adding a page
Modified:
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18
18:49:41 UTC (rev 7177)
+++
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2011-08-18
19:06:18 UTC (rev 7178)
@@ -35,6 +35,8 @@
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
+import org.exoplatform.portal.webui.portal.UIPortal;
+import org.exoplatform.portal.webui.portal.UIPortalComponent;
import org.exoplatform.portal.webui.portal.UIPortalComposer;
import org.exoplatform.portal.webui.util.PortalDataMapper;
import org.exoplatform.portal.webui.util.Util;
@@ -83,6 +85,8 @@
protected UIFormInputSet uiPermissionSetting;
protected UIFormSelectBox groupIdSelectBox = null;
+
+ protected UIFormSelectBox portalIdSelectBox = null;
protected UIFormStringInput ownerIdInput = null;
@@ -99,14 +103,6 @@
List<SelectItemOption<String>> ownerTypes = new
ArrayList<SelectItemOption<String>>();
ownerTypes.add(new SelectItemOption<String>(PortalConfig.USER_TYPE));
- UserPortalConfig userPortalConfig =
- configService.getUserPortalConfig(pcontext.getPortalOwner(),
pcontext.getRemoteUser());
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- UserACL acl = (UserACL)container.getComponentInstanceOfType(UserACL.class);
- if (acl.hasEditPermission(userPortalConfig.getPortalConfig()))
- {
- ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
- }
ownerIdInput = new UIFormStringInput(OWNER_ID, OWNER_ID, null);
ownerIdInput.setEditable(false).setValue(pcontext.getRemoteUser());
@@ -146,6 +142,27 @@
//TODO: This following line is fixed for bug PORTAL-2127
uiListPermissionSelector.getChild(UIFormPopupWindow.class).setId("UIPageFormPopupGroupMembershipSelector");
+ List<String> portals = configService.getAllPortalNames();
+ Collections.sort(portals);
+ List<SelectItemOption<String>> portalsItem = new
ArrayList<SelectItemOption<String>>();
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ UserACL acl = (UserACL)container.getComponentInstanceOfType(UserACL.class);
+ for (String p : portals)
+ {
+ UserPortalConfig userPortalConfig = configService.getUserPortalConfig(p,
pcontext.getRemoteUser());
+ if (acl.hasEditPermission(userPortalConfig.getPortalConfig()))
+ {
+ portalsItem.add(new SelectItemOption<String>(p));
+ }
+ }
+ if(portalsItem.size() > 0)
+ {
+ ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
+ portalIdSelectBox = new UIFormSelectBox(OWNER_ID, OWNER_ID, portalsItem);
+ portalIdSelectBox.setOnChange("ChangeOwnerId");
+ portalIdSelectBox.setParent(uiSettingSet);
+ }
+
List<String> groups =
configService.getMakableNavigations(pcontext.getRemoteUser(), true);
if (groups.size() > 0)
{
@@ -160,6 +177,7 @@
groupIdSelectBox.setOnChange("ChangeOwnerId");
groupIdSelectBox.setParent(uiSettingSet);
}
+
setActions(new String[]{"Save", "Close"});
}
@@ -201,11 +219,6 @@
uiTemplate.setValue(uiPage.getFactoryId());
}
- public void setEditPermission(String per)
- {
-
- }
-
public void invokeSetBindingBean(Object bean) throws Exception
{
String ownerType = getUIFormSelectBox("ownerType").getValue();
@@ -287,6 +300,43 @@
applications.add(PortalDataMapper.buildModelObject(uiPortlet));
}
+ if (Page.DESKTOP_PAGE.equals(uiPage.getFactoryId()) &&
!Page.DESKTOP_PAGE.equals(page.getFactoryId()))
+ {
+ page.setShowMaxWindow(false);
+ uiPage.getChildren().clear();
+ page.setChildren(applications);
+
+ PortalDataMapper.toUIPage(uiPage, page);
+ if (page.getChildren() == null)
+ page.setChildren(new ArrayList<ModelObject>());
+
+ pcontext.setFullRender(true);
+ UIWorkingWorkspace uiWorkingWS =
uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+ pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
+
pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
+ return;
+ }
+
+ if (Page.DESKTOP_PAGE.equals(page.getFactoryId()))
+ {
+ uiPage.getChildren().clear();
+ page.setChildren(applications);
+
+ PortalDataMapper.toUIPage(uiPage, page);
+ if (page.getChildren() == null)
+ page.setChildren(new ArrayList<ModelObject>());
+
+ UIPortalToolPanel toolPanel = Util.getUIPortalToolPanel();
+ toolPanel.setShowMaskLayer(true);
+ pcontext.setFullRender(true);
+ UIWorkingWorkspace uiWorkingWS =
uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
+ pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
+
pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
+ DataStorage dataService =
uiPageForm.getApplicationComponent(DataStorage.class);
+ dataService.save(page);
+ return;
+ }
+
List<UIComponent> uiChildren = uiPage.getChildren();
if (uiChildren == null)
{
@@ -315,7 +365,6 @@
}
uiPage.setStorageId(storageId);
- // if(page.getTemplate() == null) page.setTemplate(uiPage.getTemplate()) ;
if (page.getChildren() == null)
page.setChildren(new ArrayList<ModelObject>());
}
@@ -361,12 +410,28 @@
if (PortalConfig.PORTAL_TYPE.equals(ownerType))
{
list.remove(2);
- list.add(2, uiForm.ownerIdInput);
- uiForm.ownerIdInput.setValue(prContext.getPortalOwner());
- uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(
- Util.getUIPortal().getAccessPermissions());
- uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(
- Util.getUIPortal().getEditPermission());
+ list.add(2, uiForm.portalIdSelectBox);
+ String portalIdSelected = uiForm.portalIdSelectBox.getValue();
+ String[] accessPermissions = {};
+ String editPermission = "";
+
+ UserPortalConfigService service =
uiForm.getApplicationComponent(UserPortalConfigService.class);
+ UserPortalConfig userConfig =
service.getUserPortalConfig(portalIdSelected, prContext.getRemoteUser());
+ if (userConfig != null)
+ {
+ PortalConfig config = userConfig.getPortalConfig();
+ accessPermissions = config.getAccessPermissions();
+ editPermission = config.getEditPermission();
+ }
+ else
+ {
+ UIPortal uiPortal =
Util.getUIPortalApplication().getCachedUIPortal(ownerType, portalIdSelected);
+ accessPermissions = uiPortal.getAccessPermissions();
+ editPermission = uiPortal.getEditPermission();
+ }
+
+
uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(accessPermissions);
+
uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(editPermission);
}
else
{
@@ -390,13 +455,33 @@
public void execute(Event<UIPageForm> event) throws Exception
{
UIPageForm uiForm = event.getSource();
- String groupIdSelected = uiForm.groupIdSelectBox.getValue();
- groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected :
"/" + groupIdSelected;
- String permission = "*:" + groupIdSelected;
- uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(new
String[]{permission});
- UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
- permission = userACL.getMakableMT() + ":" + groupIdSelected;
-
uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
+ UIFormSelectBox uiSelectBox = uiForm.getUIFormSelectBox(OWNER_TYPE);
+ String ownerType = uiSelectBox.getValue();
+ if(PortalConfig.PORTAL_TYPE.equals(ownerType)) {
+ String[] accessPermissions = {};
+ String editPermission = "";
+ String portalIdSelected = uiForm.portalIdSelectBox.getValue();
+ UserPortalConfigService service =
uiForm.getApplicationComponent(UserPortalConfigService.class);
+ UserPortalConfig userConfig = service.getUserPortalConfig(portalIdSelected,
Util.getPortalRequestContext().getRemoteUser());
+ if (userConfig != null)
+ {
+ PortalConfig config = userConfig.getPortalConfig();
+ accessPermissions = config.getAccessPermissions();
+ editPermission = config.getEditPermission();
+
uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(accessPermissions);
+
uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(editPermission);
+ }
+ }
+ else
+ {
+ String groupIdSelected = uiForm.groupIdSelectBox.getValue();
+ groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected
: "/" + groupIdSelected;
+ String permission = "*:" + groupIdSelected;
+ uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(new
String[]{permission});
+ UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
+ permission = userACL.getMakableMT() + ":" + groupIdSelected;
+
uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
+ }
event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
}
}
@@ -406,13 +491,6 @@
public void execute(Event<UIGroupMembershipSelector> event) throws Exception
{
UIPageForm uiForm = event.getSource().getAncestorOfType(UIPageForm.class);
- /*if
(!uiForm.getUIStringInput(OWNER_TYPE).getValue().equals(PortalConfig.GROUP_TYPE))
- return;
- String editPer =
uiForm.findFirstComponentOfType(UIPermissionSelector.class).getValue();
- if (editPer == null || editPer.length() < 1)
- return;
- String group = editPer.substring(editPer.indexOf("/") + 1);
- uiForm.ownerIdInput.setValue(group);*/
event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
}
}