Revision: 1182
Author: ge0ffrey
Date: 2006-05-27 05:46:29 -0700 (Sat, 27 May 2006)
ViewCVS: http://svn.sourceforge.net/spring-rich-c/?rev=1182&view=rev
Log Message:
-----------
examples of configurable exception handling (the configure exception handling
itself is not yet commited)
Modified Paths:
--------------
trunk/spring-richclient/pom.xml
trunk/spring-richclient/samples/petclinic/gui/pom.xml
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-application-context.xml
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ui/messages.properties
trunk/spring-richclient/tiger/pom.xml
Added Paths:
-----------
trunk/spring-richclient/samples/petclinic/gui/src/main/java/org/springframework/richclient/samples/petclinic/exceptionHandling/
trunk/spring-richclient/samples/petclinic/gui/src/main/java/org/springframework/richclient/samples/petclinic/exceptionHandling/ExceptionHandlingView.java
Modified: trunk/spring-richclient/pom.xml
===================================================================
--- trunk/spring-richclient/pom.xml 2006-05-26 12:50:07 UTC (rev 1181)
+++ trunk/spring-richclient/pom.xml 2006-05-27 12:46:29 UTC (rev 1182)
@@ -737,8 +737,13 @@
<!-- This isn't purely jnlp, it contains sun files... -->
<!--</dependency>-->
- <!-- JDBC -->
+ <!-- Persistence (for samples) -->
<dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>3.1beta9</version>
+ </dependency>
+ <dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.1</version>
Modified: trunk/spring-richclient/samples/petclinic/gui/pom.xml
===================================================================
--- trunk/spring-richclient/samples/petclinic/gui/pom.xml 2006-05-26
12:50:07 UTC (rev 1181)
+++ trunk/spring-richclient/samples/petclinic/gui/pom.xml 2006-05-27
12:46:29 UTC (rev 1182)
@@ -83,6 +83,12 @@
<groupId>org.jdesktop</groupId>
<artifactId>jdnc</artifactId>
</dependency>
+
+ <!-- Validation -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Added:
trunk/spring-richclient/samples/petclinic/gui/src/main/java/org/springframework/richclient/samples/petclinic/exceptionHandling/ExceptionHandlingView.java
===================================================================
---
trunk/spring-richclient/samples/petclinic/gui/src/main/java/org/springframework/richclient/samples/petclinic/exceptionHandling/ExceptionHandlingView.java
(rev 0)
+++
trunk/spring-richclient/samples/petclinic/gui/src/main/java/org/springframework/richclient/samples/petclinic/exceptionHandling/ExceptionHandlingView.java
2006-05-27 12:46:29 UTC (rev 1182)
@@ -0,0 +1,142 @@
+package org.springframework.richclient.samples.petclinic.exceptionHandling;
+
+import org.springframework.richclient.application.support.AbstractView;
+import org.springframework.richclient.layout.TableLayoutBuilder;
+import org.springframework.richclient.util.GuiStandardUtils;
+import org.springframework.richclient.core.UIConstants;
+import org.acegisecurity.AccessDeniedException;
+import org.acegisecurity.BadCredentialsException;
+import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Min;
+import org.hibernate.validator.Max;
+import org.hibernate.validator.ClassValidator;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import javax.swing.JButton;
+import javax.swing.AbstractAction;
+import javax.swing.JLabel;
+import java.awt.event.ActionEvent;
+
+/**
+ * @author Geoffrey De Smet
+ */
+public class ExceptionHandlingView extends AbstractView {
+
+ /**
+ * IMPORTANT: This code isn't a good example of how to write a view.
+ * It's just here to prove how the exception handlers work.
+ * Take a look at the application context to see how the exception
handler(s) are configured.
+ */
+ protected JComponent createControl() {
+ TableLayoutBuilder layoutBuilder = new TableLayoutBuilder();
+
+ layoutBuilder.cell(new JLabel("This page demonstrates the exception
handling."));
+ layoutBuilder.row();
+ layoutBuilder.cell(new JLabel("Push the buttons and see which
exception handler gets choosen."));
+ layoutBuilder.row();
+ layoutBuilder.cell(new JLabel("That defines the log level and the
dialog shown."));
+ layoutBuilder.row();
+ layoutBuilder.unrelatedGapRow();
+
+ JButton badCredentials = new JButton(new AbstractAction("Login with
bad credentials"){
+ public void actionPerformed(ActionEvent e) {
+ loginWithBadCredentials();
+ }
+ });
+ layoutBuilder.cell(badCredentials);
+ layoutBuilder.row();
+ layoutBuilder.relatedGapRow();
+
+ JButton accessDenied = new JButton(new AbstractAction("Do something
you don't have access to"){
+ public void actionPerformed(ActionEvent e) {
+ denyAccess();
+ }
+ });
+ layoutBuilder.cell(accessDenied);
+ layoutBuilder.row();
+ layoutBuilder.relatedGapRow();
+
+ JButton invalidPerson = new JButton(new AbstractAction("Validate a
person with a null name and age 1981"){
+ public void actionPerformed(ActionEvent e) {
+ validateInvalidPerson();
+ }
+ });
+ layoutBuilder.cell(invalidPerson);
+ layoutBuilder.row();
+ layoutBuilder.relatedGapRow();
+
+ JButton nullPointer = new JButton(new AbstractAction("Cause a null
pointer exception"){
+ public void actionPerformed(ActionEvent e) {
+ causeNullPointerException();
+ }
+ });
+ layoutBuilder.cell(nullPointer);
+ layoutBuilder.row();
+ layoutBuilder.relatedGapRow();
+
+ JButton stackOverflow = new JButton(new AbstractAction("Cause a stack
overflow"){
+ public void actionPerformed(ActionEvent e) {
+ causeStackOverflow();
+ }
+ });
+ layoutBuilder.cell(stackOverflow);
+ layoutBuilder.row();
+
+ JPanel panel = layoutBuilder.getPanel();
+
panel.setBorder(GuiStandardUtils.createEvenlySpacedBorder(UIConstants.ONE_SPACE));
+ return panel;
+ }
+
+ private void loginWithBadCredentials() {
+ throw new BadCredentialsException("Wrong username/password");
+ }
+
+ private void denyAccess() {
+ throw new AccessDeniedException("You don't have access to do this");
+ }
+
+ private void validateInvalidPerson() {
+ ClassValidator validator = new ClassValidator(ValidPerson.class);
+ ValidPerson invalidPerson = new ValidPerson();
+ invalidPerson.setAge(1981);
+ validator.assertValid(invalidPerson);
+ }
+
+ public static class ValidPerson {
+
+ private String name;
+ private int age;
+
+ @NotNull
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Min(0) @Max(200)
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ }
+
+ private void causeNullPointerException() {
+ String s = null;
+ s = s.replace(" ", "");
+ }
+
+ /**
+ * Overflows in Sun's JRE after 1024 recursive calls
+ */
+ private int causeStackOverflow() {
+ return causeStackOverflow() + 1 + causeStackOverflow();
+ }
+
+}
Modified:
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-application-context.xml
===================================================================
---
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-application-context.xml
2006-05-26 12:50:07 UTC (rev 1181)
+++
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-application-context.xml
2006-05-27 12:46:29 UTC (rev 1182)
@@ -191,6 +191,18 @@
</map>
</property>
</bean>
+
+ <bean id="exceptionHandlingView"
+
class="org.springframework.richclient.application.support.DefaultViewDescriptor">
+ <property name="viewClass">
+
<value>org.springframework.richclient.samples.petclinic.exceptionHandling.ExceptionHandlingView</value>
+ </property>
+ <!--<property name="viewProperties">-->
+ <!--<map>-->
+ <!--<entry key="ggg" value-ref="ggg"/>-->
+ <!--</map>-->
+ <!--</property>-->
+ </bean>
<bean id="setupWizard"
class="org.springframework.richclient.application.setup.SetupWizard">
Modified:
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ui/messages.properties
===================================================================
---
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ui/messages.properties
2006-05-26 12:50:07 UTC (rev 1181)
+++
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ui/messages.properties
2006-05-27 12:46:29 UTC (rev 1182)
@@ -13,6 +13,9 @@
petManagerView.label=&Pet Manager
petManagerView.caption=Manage man (and woman's) best friend!
+exceptionHandlingView.label=&Exception handling
+exceptionHandlingView.caption=Test out the exception handling
+
newOwnerCommand.label=&[EMAIL PROTECTED] O
newOwnerCommand.caption=Creates a new owner
@@ -89,4 +92,4 @@
doNotAcceptLicenseCommand.label=I do ¬ accept the terms of this license
agreement
preferenceCommand.label=&Preferences
-preferenceCommand.caption=Preferences
\ No newline at end of file
+preferenceCommand.caption=Preferences
Modified: trunk/spring-richclient/tiger/pom.xml
===================================================================
--- trunk/spring-richclient/tiger/pom.xml 2006-05-26 12:50:07 UTC (rev
1181)
+++ trunk/spring-richclient/tiger/pom.xml 2006-05-27 12:46:29 UTC (rev
1182)
@@ -153,6 +153,13 @@
<artifactId>jhelp</artifactId>
</dependency>
+ <!-- Validation -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <optional>true</optional>
+ </dependency>
+
</dependencies>
</project>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs