changeset 2040:cd9bcdcf6597

Make only newest CrossSection intially active in diagrams. flys-artifacts/trunk@3526 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 22 Dec 2011 12:52:12 +0000
parents f7e2a84a6d88
children e5f01f2325c9
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java
diffstat 2 files changed, 33 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Dec 22 12:50:52 2011 +0000
+++ b/flys-artifacts/ChangeLog	Thu Dec 22 12:52:12 2011 +0000
@@ -1,3 +1,9 @@
+2011-12-22	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java
+	  (getInitialFacetActivity): Only newest CrossSection is initially
+				     active.
+
 2011-12-22	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/CrossSectionFactory.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Thu Dec 22 12:50:52 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java	Thu Dec 22 12:52:12 2011 +0000
@@ -47,9 +47,12 @@
     /** Name of data item keeping the database id of this c.s.. */
     public static final String DATA_DBID = "cross_section.dbid";
 
-    /** Name of data item keeping the database id of this c.s.. */
+    /** Name of data item flagging whether we think that we are master. */
     public static final String DATA_IS_MASTER = "cross_section.master?";
 
+    /** Name of data item flagging whether we are the newest. */
+    public static final String DATA_IS_NEWEST = "cross_section.newest?";
+
     /** Own logger. */
     private static final Logger logger =
         Logger.getLogger(CrossSectionArtifact.class);
@@ -86,9 +89,6 @@
             throw new IllegalArgumentException("No attribute 'ids' found!");
         }
 
-        
-        addStringData(DATA_IS_MASTER, "0");
-
         List<Facet> fs = new ArrayList<Facet>();
         CrossSection cs = CrossSectionFactory.getCrossSection(Integer.valueOf(ids));
         CrossSectionLine csl = cs.getLines().get(0);
@@ -101,6 +101,12 @@
         }
         fs.add(new CrossSectionFacet(0, cs.getDescription()));
 
+        // Find out if we are newest.
+        boolean isNewest = CrossSectionFactory.isNewest(cs);
+        String newString = (isNewest) ? "1" : "0";
+        addStringData(DATA_IS_NEWEST, newString);
+        addStringData(DATA_IS_MASTER, newString);
+
         StaticState state = (StaticState) getCurrentState(context);
 
         if (!fs.isEmpty()) {
@@ -252,5 +258,22 @@
         }
         return oldLine;
     }
+
+
+    /**
+     * Determines Facets initial disposition regarding activity (think of
+     * selection in Client ThemeList GUI). This will be checked one time
+     * when the facet enters a collections describe document.
+     *
+     * @param outputName Ignored.
+     * @param facetName Ignored.
+     * @param index     Ignored.
+     * @return 0 if not active
+     */
+    @Override
+    public int getInitialFacetActivity(String outputName, String facetName, int index) {
+        return (getDataAsString(DATA_IS_NEWEST) != null
+            && getDataAsString(DATA_IS_NEWEST).equals("1")) ? 1 : 0;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org