|
From: <jav...@us...> - 2011-07-08 07:55:28
|
Revision: 15663
http://dcm4che.svn.sourceforge.net/dcm4che/?rev=15663&view=rev
Author: javawilli
Date: 2011-07-08 07:55:21 +0000 (Fri, 08 Jul 2011)
Log Message:
-----------
[#WEB-410] Add Fuzzy Patient search to folder and worklist console.
Modified Paths:
--------------
dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/markup/modal/MessageWindow.java
dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/validators/UIDValidator.java
Added Paths:
-----------
dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/exceptions/WicketExceptionWithMsgKey.java
Added: dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/exceptions/WicketExceptionWithMsgKey.java
===================================================================
--- dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/exceptions/WicketExceptionWithMsgKey.java (rev 0)
+++ dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/exceptions/WicketExceptionWithMsgKey.java 2011-07-08 07:55:21 UTC (rev 15663)
@@ -0,0 +1,79 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Agfa-Gevaert AG.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * See listed authors below.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package org.dcm4chee.web.common.exceptions;
+
+/**
+ * @author Franz Willer <fra...@gm...>
+ * @version $Revision$ $Date$
+ * @since Jul 07, 2011
+ */
+public class WicketExceptionWithMsgKey extends RuntimeException{
+ private static final long serialVersionUID = 1L;
+ private String msgKey;
+
+ public WicketExceptionWithMsgKey(String msgKey) {
+ super();
+ this.msgKey = msgKey;
+ }
+
+ public WicketExceptionWithMsgKey(String msgKey, String message) {
+ super(message);
+ this.msgKey = msgKey;
+ }
+
+ public WicketExceptionWithMsgKey(String msgKey, Throwable t) {
+ super(t);
+ this.msgKey = msgKey;
+ }
+
+ public WicketExceptionWithMsgKey(String msgKey, String message,Throwable t) {
+ super(message, t);
+ this.msgKey = msgKey;
+ }
+
+ public String getMsgKey() {
+ return msgKey;
+ }
+
+ @Override
+ public String toString() {
+ return "WicketExceptionWithMsgKey msgKey:'"+msgKey+"' - ExceptionMessage:"+getMessage()+" cause:"+getCause();
+ }
+
+}
Modified: dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/markup/modal/MessageWindow.java
===================================================================
--- dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/markup/modal/MessageWindow.java 2011-07-08 07:55:11 UTC (rev 15662)
+++ dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/markup/modal/MessageWindow.java 2011-07-08 07:55:21 UTC (rev 15663)
@@ -38,6 +38,8 @@
package org.dcm4chee.web.common.markup.modal;
+import java.text.MessageFormat;
+
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
@@ -47,6 +49,9 @@
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.model.StringResourceModel;
+import org.apache.wicket.util.string.interpolator.PropertyVariableInterpolator;
+import org.dcm4chee.web.common.exceptions.WicketExceptionWithMsgKey;
import org.dcm4chee.web.common.markup.modal.AutoOpenModalWindow;
/**
@@ -100,6 +105,44 @@
}
/**
+ * Get Message from Exception
+ * If Exception is of type WicketExceptionWithMsgKey: ResourceKey with the msgKey
+ * For any other Exception: the first getLocalizedMessage()!=null of the Exception hierachie or toString of root cause
+ *
+ * @param x
+ * @param useCauseAsDetail
+ */
+ public void setErrorMessage(Exception x, boolean useCauseAsDetail) {
+ IModel<String> detail = null;
+ if (useCauseAsDetail && x.getCause() != null) {
+ Throwable cause = x.getCause();
+ if (cause instanceof WicketExceptionWithMsgKey) {
+ detail = new ResourceModel(((WicketExceptionWithMsgKey) cause).getMsgKey()).wrapOnAssignment(this);
+ } else {
+ detail = new Model<String>(getExceptionMessage(cause));
+ }
+ }
+ if (x instanceof WicketExceptionWithMsgKey) {
+ msgModel = new StringResourceModel(((WicketExceptionWithMsgKey) x).getMsgKey(), this, detail);
+ } else {
+ String msg = detail == null ? getExceptionMessage(x) :
+ PropertyVariableInterpolator.interpolate(getExceptionMessage(x), detail.getObject());
+ msgModel = new Model<String>(msg);
+ }
+ setTitle(new ResourceModel(TITLE_ERROR,TITLE_DEFAULT));
+ }
+
+ private String getExceptionMessage(Throwable x) {
+ if (x.getLocalizedMessage() != null) {
+ return x.getLocalizedMessage();
+ } else if (x.getCause() == null) {
+ return x.toString();
+ } else {
+ return getExceptionMessage(x.getCause());
+ }
+ }
+
+ /**
* Called by onBeforeRender to check if window should be opened without AJAX for this request.
*
* @return true when window should be opened.
@@ -110,8 +153,10 @@
@Override
public void show(final AjaxRequestTarget target) {
- super.show(target);
- target.focusComponent(this.get("content:close"));
+ if (target != null) {
+ super.show(target);
+ target.focusComponent(this.get("content:close"));
+ }
}
public void show(AjaxRequestTarget target, String msg) {
@@ -127,6 +172,10 @@
this.msgModel = msg;
show(target);
}
+ public void show(AjaxRequestTarget target, Exception x, boolean useCauseAsDetail) {
+ this.setErrorMessage(x, useCauseAsDetail);
+ show(target);
+ }
public class MessageWindowPanel extends Panel {
private static final long serialVersionUID = 0L;
Modified: dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/validators/UIDValidator.java
===================================================================
--- dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/validators/UIDValidator.java 2011-07-08 07:55:11 UTC (rev 15662)
+++ dcm4chee/dcm4chee-web-common/trunk/src/main/java/org/dcm4chee/web/common/validators/UIDValidator.java 2011-07-08 07:55:21 UTC (rev 15663)
@@ -40,10 +40,8 @@
import java.util.HashMap;
import java.util.Map;
-import org.apache.wicket.util.lang.Classes;
import org.apache.wicket.validation.IValidatable;
import org.apache.wicket.validation.validator.AbstractValidator;
-import org.apache.wicket.validation.validator.UrlValidator;
import org.dcm4che2.util.UIDUtils;
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|