Author: kien_nguyen
Date: 2010-11-16 01:54:20 -0500 (Tue, 16 Nov 2010)
New Revision: 5098
Modified:
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
Log:
EXOGTN-139 [PLF] Shouldnt display edit icon with gadgets which havent gadget preferences
Modified:
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl
===================================================================
---
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl 2010-11-16
06:43:36 UTC (rev 5097)
+++
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl 2010-11-16
06:54:20 UTC (rev 5098)
@@ -39,8 +39,10 @@
<div class="<%=isMini ? "RestoreGadget":
"MinimizeGadget";%> MinimizeAction IconControl"
onclick="eXo.gadget.UIGadget.minimizeGadget(this)"
onmousedown="event.cancelBubble=true;" style="display:none;"
title="<%=isMini ? unminiTitle : miniTitle%>"
miniTitle="$miniTitle"
unminiTitle="$unminiTitle"><span></span></div>
- <div class="EditGadget IconControl"
onclick="eXo.gadget.UIGadget.editGadget('$id')"
onmousedown="event.cancelBubble=true;"
title="<%=_ctx.appRes("UIGadget.tooltip.editGadget")%>"><span></span></div>
- <div
class="GadgetDragHandleArea"><span></span></div>
+ <% if(uicomponent.isSettingUserPref()) { %>
+ <div class="EditGadget IconControl"
onclick="eXo.gadget.UIGadget.editGadget('$id')"
onmousedown="event.cancelBubble=true;"
title="<%=_ctx.appRes("UIGadget.tooltip.editGadget")%>"><span></span></div>
+ <% } %>
+ <div
class="GadgetDragHandleArea"><span></span></div>
<div class="GadgetTitle" style="display: none; float: none; width:
auto; margin-right: 75px"><%= uicomponent.getApplicationName()
%></div>
</div>
</div>
Modified:
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
---
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-11-16
06:43:36 UTC (rev 5097)
+++
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-11-16
06:54:20 UTC (rev 5098)
@@ -40,6 +40,7 @@
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.exception.MessageException;
+import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -90,6 +91,16 @@
public static final String HOME_VIEW = "home";
public static final String CANVAS_VIEW = "canvas";
+
+ public static final String METADATA_GADGETS = "gadgets";
+
+ public static final String METADATA_USERPREFS = "userPrefs";
+
+ public static final String METADATA_USERPREFS_TYPE = "type";
+
+ public static final String METADATA_USERPREFS_TYPE_HIDDEN = "hidden";
+
+ public static final String METADATA_USERPREFS_TYPE_LIST = "list";
public String view = HOME_VIEW;
@@ -207,7 +218,7 @@
String strMetadata = GadgetUtil.fetchGagdetMetadata(getUrl());
metadata_ = new JSONObject(strMetadata);
}
- JSONObject obj = metadata_.getJSONArray("gadgets").getJSONObject(0);
+ JSONObject obj = metadata_.getJSONArray(METADATA_GADGETS).getJSONObject(0);
String token = GadgetUtil.createToken(this.getUrl(), new Random().nextLong());
obj.put("secureToken", token);
return metadata_.toString();
@@ -217,6 +228,39 @@
return null;
}
}
+ /**
+ * Check if content of gadget has <UserPref>? (Content is parsed from gadget
specification in .xml file)
+ * @return boolean
+ */
+ public boolean isSettingUserPref()
+ {
+ try
+ {
+ if(metadata_ != null)
+ {
+ JSONObject obj = metadata_.getJSONArray(METADATA_GADGETS).getJSONObject(0);
+ JSONObject userPrefs = obj.getJSONObject(METADATA_USERPREFS);
+ JSONArray names = userPrefs.names();
+ int count = names.length();
+ if(count > 0)
+ {
+ for(int i = 0; i < count; i++)
+ {
+ JSONObject o = (JSONObject) userPrefs.get(names.get(i).toString());
+
if(!(o.get(METADATA_USERPREFS_TYPE).equals(METADATA_USERPREFS_TYPE_HIDDEN) ||
+
o.get(METADATA_USERPREFS_TYPE).equals(METADATA_USERPREFS_TYPE_LIST)))
+ return true;
+ }
+ return false;
+ }
+ }
+ return false;
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
@Override
public boolean isRendered()
Show replies by date