Author: thomas.heute(a)jboss.com
Date: 2010-10-27 08:22:03 -0400 (Wed, 27 Oct 2010)
New Revision: 4860
Modified:
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
Log:
JBEPP-587: Shouldn't display edit icon with gadgets which haven't gadget
preferences
Modified:
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl 2010-10-27
12:02:52 UTC (rev 4859)
+++
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl 2010-10-27
12:22:03 UTC (rev 4860)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-10-27
12:02:52 UTC (rev 4859)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-10-27
12:22:03 UTC (rev 4860)
@@ -38,6 +38,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;
@@ -88,6 +89,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;
@@ -205,7 +216,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();
@@ -215,6 +226,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