You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dw...@apache.org on 2009/01/19 19:06:28 UTC

svn commit: r735763 - in /geronimo/server/trunk/plugins/console: console-core/src/main/java/org/apache/geronimo/console/ console-core/src/main/java/org/apache/geronimo/console/message/ console-portal-driver/src/main/webapp/

Author: dwoods
Date: Mon Jan 19 10:06:27 2009
New Revision: 735763

URL: http://svn.apache.org/viewvc?rev=735763&view=rev
Log:
GERONIMO-4517 Apply unified message display style(G-4484) to javascript alert messages. Together with the localization of these messages.  Applied js-localization-core.patch from Gang Yin.

Added:
    geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/BaseRemoteProxy.java   (with props)
    geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/message/JSCommonMessage.java   (with props)
Modified:
    geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/CommonMsg.js

Added: geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/BaseRemoteProxy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/BaseRemoteProxy.java?rev=735763&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/BaseRemoteProxy.java (added)
+++ geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/BaseRemoteProxy.java Mon Jan 19 10:06:27 2009
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console;
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class BaseRemoteProxy {
+
+    public final String getLocalizedString(HttpServletRequest request, ClassLoader loader, String bundleName, String key, Object... vars) {
+        String value = ResourceBundle.getBundle(bundleName, request.getLocale(), loader).getString(key);
+        if (null == value || 0 == value.length()) return key;     
+        return MessageFormat.format(value, vars);
+    }
+    
+}

Propchange: geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/BaseRemoteProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/message/JSCommonMessage.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/message/JSCommonMessage.java?rev=735763&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/message/JSCommonMessage.java (added)
+++ geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/message/JSCommonMessage.java Mon Jan 19 10:06:27 2009
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.message;
+
+import org.directwebremoting.annotations.DataTransferObject;
+import org.directwebremoting.annotations.RemoteProperty;
+
+@DataTransferObject
+public final class JSCommonMessage {
+
+    public static final String ERROR = "error";
+    public static final String WARN = "warn";
+    public static final String INFO = "info";
+
+    private static final long serialVersionUID = 0L;
+
+    private final CommonMessage.Type type;
+    private final String abbr;
+    private final String detail;
+
+    public JSCommonMessage(CommonMessage.Type type, String abbr, String detail) {
+        this.type = type;
+        this.abbr = abbr;
+        this.detail = detail;
+    }
+
+    @RemoteProperty
+    public String getType() {
+        String ret = "info";
+        switch (type) {
+        case Error:
+            ret = ERROR;
+            break;
+        case Warn:
+            ret = WARN;
+            break;
+        case Info:
+            ret = INFO;
+            break;
+        }
+        return ret;
+    }
+
+    @RemoteProperty
+    public String getAbbr() {
+        return this.abbr;
+    }
+
+    @RemoteProperty
+    public String getDetail() {
+        return this.detail;
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/message/JSCommonMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/CommonMsg.js
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/CommonMsg.js?rev=735763&r1=735762&r2=735763&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/CommonMsg.js (original)
+++ geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/CommonMsg.js Mon Jan 19 10:06:27 2009
@@ -14,19 +14,125 @@
 //   See the License for the specific language governing permissions and
 //   limitations under the License.
 //======================================================================
+function addErrorMessage(namespace, message){
+    var msg = {};
+    msg.type = "error";
+    msg.abbr = message;
+    addCommonMessage(namespace, msg);
+}
+
+function addWarningMessage(namespace, message){
+    var msg = {};
+    msg.type="warn";
+    msg.abbr = message;
+    addCommonMessage(namespace, msg);
+}
+
+function addInfoMessage(namespace, message){
+    var msg = {};
+    msg.type="info";
+    msg.abbr = message;
+    addCommonMessage(namespace, msg);
+}
+
+function addCommonMessage(namespace, msg){
+    var container = document.getElementById(namespace+"CommonMsgContainer");
+    while(container.firstChild) {
+        container.removeChild(container.firstChild);
+    }
+    var table = document.createElement("table");
+    container.appendChild(table);
+    table.align="center"; table.vAlign="top"; table.width="100%"; table.border="0"; table.cellSpacing="0"; table.cellPadding="0"; table.className="messagePortlet"; table.summary="Inline Messages";
+    var tbody =  document.createElement("tbody");
+    table.appendChild(tbody);
+    var tr = document.createElement("tr");
+    tbody.appendChild(tr);    
+    tr.vAlign="top";
+    var td1 = document.createElement("td");
+    tr.appendChild(td1);    
+    td1.style.width="20px";
+    if (msg.detail) {
+        var a = document.createElement("a");
+        td1.appendChild(a);
+        a.className="expand-task"; a.href="javascript:showHideSection('"+namespace+"org_apache_geronimo_abbreviateMessages');showHideSection('"+namespace+"org_apache_geronimo_detailedMessages');"; a.tabIndex="1";
+        var img = document.createElement("img");
+        a.appendChild(img);
+        img.id=namespace+"org_apache_geronimo_abbreviateMessagesImg"; img.border="0"; img.align="absmiddle"; img.alt="show/hide"; img.src="/console/images/arrow_collapsed.gif"; img.title="show/hide";
+    }
+    var td2 = document.createElement("td");
+    tr.appendChild(td2);    
+    td2.style.width="20px";
+    var img2 = document.createElement("img");
+    td2.appendChild(img2);
+    img2.height="16"; img2.width="16"; img2.align="baseline";
+    switch (msg.type)
+    {
+        case "error":
+            img2.src="/console/images/msg_error.gif"; img2.alt="Error"; img2.title="Error";
+            break;
+        case "warn":
+            img2.src="/console/images/msg_warn.gif"; img2.alt="Warn"; img2.title="Warning";
+            break;
+        case "info":
+        default:
+            img2.src="/console/images/msg_info.gif"; img2.alt="Info"; img2.title="Infomation";
+    }
+    var td3 = document.createElement("td");
+    tr.appendChild(td3);
+    var span1 = document.createElement("span");
+    td3.appendChild(span1);
+    span1.id=namespace+"org_apache_geronimo_abbreviateMessages"; span1.style.display="inline";
+    switch (msg.type)
+    {
+        case "error":
+            span1.className="validation-error";
+            break;
+        case "warn":
+            span1.className="validation-warn";
+            break;
+        case "info":
+        default:
+            span1.className="validation-info";
+    }
+    span1.appendChild(document.createTextNode(msg.abbr));
+    if (msg.detail) {
+        var span2 = document.createElement("span");
+        td3.appendChild(span2);
+        span2.id=namespace+"org_apache_geronimo_detailedMessages"; span2.style.display="none";
+        switch (msg.type)
+        {
+            case "error":
+                span2.className="validation-error";
+                break;
+            case "warn":
+                span2.className="validation-warn";
+                break;
+            case "info":
+            default:
+                span2.className="validation-info";
+        }
+        var pre = document.createElement("pre");
+        span2.appendChild(pre);
+        pre.appendChild(document.createTextNode(msg.abbr));
+        pre.appendChild(document.createElement("br"));
+        pre.appendChild(document.createTextNode(msg.detail));
+        pre.appendChild(document.createElement("br"));
+    }
+}
+
 function showHideSection(id){
-	if(document.getElementById(id)!=null){
-		if(document.getElementById(id).style.display=="none"){
-			document.getElementById(id).style.display="inline";
-			if(document.getElementById(id+"Img")){
-				document.getElementById(id+"Img").src="/console/images/arrow_collapsed.gif";
-			}
-		}
-		else{
-			document.getElementById(id).style.display="none";
-			if(document.getElementById(id+"Img")){
-				document.getElementById(id+"Img").src="/console/images/arrow_expanded.gif";
-			}
-		}
-	}
+    if(document.getElementById(id)!=null){
+        if(document.getElementById(id).style.display=="none"){
+            document.getElementById(id).style.display="inline";
+            if(document.getElementById(id+"Img")){
+                document.getElementById(id+"Img").src="/console/images/arrow_collapsed.gif";
+            }
+        }
+        else{
+            document.getElementById(id).style.display="none";
+            if(document.getElementById(id+"Img")){
+                document.getElementById(id+"Img").src="/console/images/arrow_expanded.gif";
+            }
+        }
+    }
 }    
\ No newline at end of file