LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  February 2015

HPS-SVN February 2015

Subject:

r2028 - in /java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model: AbstractModel.java Configuration.java ConfigurationModel.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Tue, 3 Feb 2015 03:04:42 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (112 lines)

Author: [log in to unmask]
Date: Mon Feb  2 19:04:37 2015
New Revision: 2028

Log:
Add a couple of tweaks to how the base model works.

Modified:
    java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java
    java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/Configuration.java
    java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java

Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java
 =============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java	(original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java	Mon Feb  2 19:04:37 2015
@@ -54,9 +54,11 @@
 
     // FIXME: This method is kind of a hack. Any other good way to do this?
     public void fireAllChanged() {
+        System.out.println("AbstractModel.fireAllChanged");
         if (!listenersEnabled)
             return;
-       propertyLoop: for (String property : getPropertyNames()) {            
+       propertyLoop: for (String property : getPropertyNames()) {
+           System.out.println("  prop = " + property);
             Method getMethod = null;
             for (Method method : getClass().getMethods()) {
                 if (method.getName().equals("get" + property)) {
@@ -68,12 +70,13 @@
                 Object value = null;
                 try {
                     value = getMethod.invoke(this, (Object[]) null);
+                    System.out.println("  value = " + value);
                 } catch (NullPointerException e) {
                     // This means there is no get method for the property which is a throwable error.
                     throw new RuntimeException("Property " + property + " is missing a get method.", e);
                 } catch (InvocationTargetException e) {
                     // Is the cause of the problem an illegal argument to the method?
-                    System.out.println("cause: " + e.getCause().getClass().getCanonicalName());
+                    System.out.println("cause: " + e.getCause().getMessage());
                     if (e.getCause() instanceof IllegalArgumentException) {
                         // For this error, assume that the key itself is missing from the configuration which is a warning.
                         System.err.println("The key " + property + " is not set in the configuration.");
@@ -82,18 +85,18 @@
                         throw new RuntimeException(e);
                     }
                 }
-                // Is the value non-null?  Null values are actually okay.
-                //if (value != null) {
-                firePropertyChange(property, value, value);
-                for (PropertyChangeListener listener : propertyChangeSupport.getPropertyChangeListeners()) {
-                    // FIXME: For some reason calling the propertyChangeSupport methods directly here doesn't work!
-                    listener.propertyChange(new PropertyChangeEvent(this, property, value, value));
+                if (value != null) {
+                    firePropertyChange(property, value, value);
+                    for (PropertyChangeListener listener : propertyChangeSupport.getPropertyChangeListeners()) {
+                        // FIXME: For some reason calling the propertyChangeSupport methods directly here doesn't work!
+                        listener.propertyChange(new PropertyChangeEvent(this, property, value, value));
+                    }
                 }
-                //}
             } catch (IllegalAccessException | IllegalArgumentException e) {
                 throw new RuntimeException(e);
             }
-        }
+            System.out.println();
+        }                
     }
     
     /**

Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/Configuration.java
 =============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/Configuration.java	(original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/Configuration.java	Mon Feb  2 19:04:37 2015
@@ -85,9 +85,11 @@
      */
     String get(String key) {
         if (checkKey(key)) {
+            // Return the key value for properties that are set.
             return properties.getProperty(key);
         } else {
-            throw new IllegalArgumentException("The key " + key + " does not exist in this configuration with a valid value.");
+            // Return null for unset properties.
+            return null;
         }
     }
 

Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java
 =============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java	(original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java	Mon Feb  2 19:04:37 2015
@@ -449,10 +449,12 @@
     }
 
     public void remove(String property) {
-        Object oldValue = config.get(property);
-        if (oldValue != null) {
-            config.remove(property);
-            firePropertyChange(property, oldValue, null);
+        if (hasPropertyKey(property)) {
+            Object oldValue = config.get(property);
+            if (oldValue != null) {
+                config.remove(property);
+                firePropertyChange(property, oldValue, null);
+            }
         }
     }
     

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use