mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-05 04:38:10 +08:00
OptimisticException handler added
Entities' names in DeletePolicyHandler's message added
This commit is contained in:
parent
c63db7cdaa
commit
a5ec42f545
37
cuba.ipr
37
cuba.ipr
@ -132,11 +132,8 @@
|
||||
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
||||
</component>
|
||||
<component name="EclipseCompilerSettings">
|
||||
<option name="DEBUGGING_INFO" value="true" />
|
||||
<option name="GENERATE_NO_WARNINGS" value="true" />
|
||||
<option name="DEPRECATION" value="false" />
|
||||
<option name="ADDITIONAL_OPTIONS_STRING" value="" />
|
||||
<option name="MAXIMUM_HEAP_SIZE" value="128" />
|
||||
</component>
|
||||
<component name="EclipseEmbeddedCompilerSettings">
|
||||
<option name="DEBUGGING_INFO" value="true" />
|
||||
@ -184,6 +181,18 @@
|
||||
</component>
|
||||
<component name="IdProvider" IDEtalkID="99EE4594F0AAAC224547C8FE93321E41" />
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profiles>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
<option name="myLocal" value="false" />
|
||||
<inspection_tool class="SerializableHasSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="superClassString" value="java.awt.Component" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</profiles>
|
||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
<list size="5">
|
||||
<item index="0" class="java.lang.String" itemvalue="SERVER PROBLEM" />
|
||||
<item index="1" class="java.lang.String" itemvalue="INFO" />
|
||||
@ -192,13 +201,6 @@
|
||||
<item index="4" class="java.lang.String" itemvalue="ERROR" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="DEBUGGING_INFO" value="true" />
|
||||
<option name="GENERATE_NO_WARNINGS" value="false" />
|
||||
<option name="DEPRECATION" value="true" />
|
||||
<option name="ADDITIONAL_OPTIONS_STRING" value="" />
|
||||
<option name="MAXIMUM_HEAP_SIZE" value="128" />
|
||||
</component>
|
||||
<component name="JavadocGenerationManager">
|
||||
<option name="OUTPUT_DIRECTORY" />
|
||||
<option name="OPTION_SCOPE" value="protected" />
|
||||
@ -216,14 +218,6 @@
|
||||
<option name="LOCALE" />
|
||||
<option name="OPEN_IN_BROWSER" value="true" />
|
||||
</component>
|
||||
<component name="JikesSettings">
|
||||
<option name="JIKES_PATH" value="" />
|
||||
<option name="DEBUGGING_INFO" value="true" />
|
||||
<option name="DEPRECATION" value="true" />
|
||||
<option name="GENERATE_NO_WARNINGS" value="false" />
|
||||
<option name="IS_EMACS_ERRORS_MODE" value="true" />
|
||||
<option name="ADDITIONAL_OPTIONS_STRING" value="" />
|
||||
</component>
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
@ -374,13 +368,6 @@
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RmicSettings">
|
||||
<option name="IS_EANABLED" value="false" />
|
||||
<option name="DEBUGGING_INFO" value="true" />
|
||||
<option name="GENERATE_NO_WARNINGS" value="false" />
|
||||
<option name="GENERATE_IIOP_STUBS" value="false" />
|
||||
<option name="ADDITIONAL_OPTIONS_STRING" value="" />
|
||||
</component>
|
||||
<component name="SvnBranchConfigurationManager">
|
||||
<option name="myConfigurationMap">
|
||||
<map>
|
||||
|
@ -8,6 +8,8 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="groovy" level="application" />
|
||||
<orderEntry type="library" name="common" level="project" />
|
||||
<orderEntry type="library" name="common" level="project" />
|
||||
<orderEntry type="library" name="chile" level="project" />
|
||||
<orderEntry type="library" name="test" level="project" />
|
||||
|
@ -147,6 +147,7 @@ public class App extends Application implements ConnectionListener, ApplicationC
|
||||
exceptionHandlers.addHandler(new NoSuchScreenHandler());
|
||||
exceptionHandlers.addHandler(new DeletePolicyHandler());
|
||||
exceptionHandlers.addHandler(new NumericOverflowExceptionHandler());
|
||||
exceptionHandlers.addHandler(new OptimisticExceptionHandler());
|
||||
} else {
|
||||
exceptionHandlers.getHandlers().clear();
|
||||
}
|
||||
|
@ -10,19 +10,32 @@
|
||||
*/
|
||||
package com.haulmont.cuba.web.exception;
|
||||
|
||||
import com.haulmont.cuba.core.global.AccessDeniedException;
|
||||
import com.haulmont.cuba.core.global.MessageProvider;
|
||||
import com.haulmont.cuba.core.global.DeletePolicyException;
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.cuba.core.global.*;
|
||||
import com.haulmont.cuba.web.App;
|
||||
import com.vaadin.ui.Window;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DeletePolicyHandler extends AbstractExceptionHandler<DeletePolicyException> {
|
||||
public DeletePolicyHandler() {
|
||||
super(DeletePolicyException.class);
|
||||
}
|
||||
|
||||
protected void doHandle(DeletePolicyException t, App app) {
|
||||
Matcher matcher = Pattern.compile("there are references from (.*)")
|
||||
.matcher(t.getMessage());
|
||||
String localizedEntityName = "";
|
||||
if (matcher.find()) {
|
||||
String entityName = matcher.group(1);
|
||||
MetaClass metaClass = MetadataProvider.getSession().getClass(entityName);
|
||||
localizedEntityName = MessageProvider.getMessage(metaClass.getJavaClass(),
|
||||
entityName.substring(entityName.lastIndexOf("$") + 1));
|
||||
}
|
||||
String msg = MessageProvider.getMessage(getClass(), "deletePolicy.message");
|
||||
app.getAppWindow().showNotification(msg, Window.Notification.TYPE_ERROR_MESSAGE);
|
||||
String references = MessageProvider.getMessage(getClass(), "deletePolicy.references.message");
|
||||
app.getAppWindow().showNotification(msg + "<br>" + references + " \"" + localizedEntityName + "\"",
|
||||
Window.Notification.TYPE_ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Haulmont Technology Ltd. All Rights Reserved.
|
||||
* Haulmont Technology proprietary and confidential.
|
||||
* Use is subject to license terms.
|
||||
|
||||
* Author: FIRSTNAME LASTNAME
|
||||
* Created: 25.12.2009 10:22:36
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
package com.haulmont.cuba.web.exception;
|
||||
|
||||
import com.haulmont.cuba.core.global.MessageProvider;
|
||||
import com.haulmont.cuba.web.App;
|
||||
import com.vaadin.ui.Window;
|
||||
import org.apache.openjpa.util.OptimisticException;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class OptimisticExceptionHandler extends AbstractExceptionHandler<OptimisticException>{
|
||||
public OptimisticExceptionHandler() {
|
||||
super(OptimisticException.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHandle(OptimisticException e, App app) {
|
||||
Pattern pattern = Pattern.compile("\\[([^-]*)-");
|
||||
Matcher matcher = pattern.matcher(e.getMessage());
|
||||
String entityClassName = "";
|
||||
if (matcher.find()) {
|
||||
entityClassName = matcher.group(1);
|
||||
}
|
||||
|
||||
String localizedEntityName = "";
|
||||
try {
|
||||
String entityName = entityClassName.substring(entityClassName.lastIndexOf(".") + 1);
|
||||
localizedEntityName = MessageProvider.getMessage(Class.forName(entityClassName), entityName);
|
||||
} catch (ClassNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
String msg = MessageProvider.getMessage(getClass(), "optimisticException.message");
|
||||
msg = msg.replace("$1", "\"" + localizedEntityName + "\"");
|
||||
app.getAppWindow().showNotification(msg, Window.Notification.TYPE_ERROR_MESSAGE);
|
||||
}
|
||||
}
|
@ -100,8 +100,10 @@ uniqueConstraintViolation.message=Unique constraint violation occured
|
||||
accessDenied.message=Access denied
|
||||
noSuchScreen.message=No such screen
|
||||
deletePolicy.message=Delete impossible
|
||||
deletePolicy.references.message = There are references from
|
||||
noUserSession.message=User session expired. Click "OK" to login again.
|
||||
numericFieldOverflow.message=Numberic field overflow
|
||||
optimisticException.message=Object was modified in another transaction
|
||||
|
||||
numericFieldOverflow.marker=Numeric field overflow
|
||||
|
||||
|
@ -103,6 +103,7 @@ closeUnsaved.caption=
|
||||
accessDenied.message=Доступ запрещен
|
||||
noSuchScreen.message=Экран не определен
|
||||
deletePolicy.message=Удаление невозможно
|
||||
deletePolicy.references.message = Èìåþòñÿ ñâÿçè îò
|
||||
noUserSession.message=Пользовательская сессия истекла. Нажмите "OK" чтобы войти снова.
|
||||
|
||||
upload.submit=Загрузить
|
||||
@ -125,3 +126,4 @@ label.SearchParameters=
|
||||
#Date formats
|
||||
dateFormat=dd.MM.yyyy
|
||||
dateTimeFormat=dd.MM.yyyy HH:mm
|
||||
optimisticException.message=Îáúåêò $1 áûë èçìåí¸í â äðóãîé òðàíçàêöèè
|
||||
|
Loading…
Reference in New Issue
Block a user