/*************** <auto-copyright.pl BEGIN do not edit this line> **************
 *
 * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
 *
 * Original Authors:
 *   Allen Bierbaum, Christopher Just,
 *   Patrick Hartling, Kevin Meinert,
 *   Carolina Cruz-Neira, Albert Baker
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * -----------------------------------------------------------------
 * File:          $RCSfile$
 * Date modified: $Date$
 * Version:       $Revision$
 * -----------------------------------------------------------------
 *
 *************** <auto-copyright.pl END do not edit this line> ***************/

package org.vrjuggler.vrjconfig.customeditors.display_window;

import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JPanel;
import info.clearthought.layout.*;

import org.vrjuggler.jccl.config.*;
import org.vrjuggler.jccl.config.event.ConfigElementEvent;
import org.vrjuggler.jccl.config.event.ConfigElementListener;
import org.vrjuggler.jccl.editors.PropertyEditorPanel;


public class ViewportUserEditorPanel
   extends JPanel
   implements ConfigElementListener
{
   public ViewportUserEditorPanel()
   {
      this(null);
   }

   public ViewportUserEditorPanel(ConfigElementListener externalListener)
   {
      ConfigBrokerProxy broker = new ConfigBrokerProxy();
      ConfigDefinition vp_def = broker.getRepository().get("surface_viewport");
      ConfigElementFactory factory =
         new ConfigElementFactory(broker.getRepository().getAllLatest());
      ConfigElement elt = factory.create("ViewportUserEditorPanel Junk",
                                         vp_def);
      elt.addConfigElementListener(this);

      if ( externalListener != null )
      {
         elt.addConfigElementListener(externalListener);
      }

      mViewpointEditor =
         new PropertyEditorPanel(elt.getProperty("view", 0),
                                 vp_def.getPropertyDefinition("view"),
                                 elt, 0, Color.white);
      mUserEditor =
         new PropertyEditorPanel(elt.getProperty("user", 0),
                                 vp_def.getPropertyDefinition("user"),
                                 elt, 0, Color.white);

      double[][] layout_size = {{TableLayout.PREFERRED, 5,
                                 TableLayout.PREFERRED},
                                {TableLayout.PREFERRED, 5,
                                 TableLayout.PREFERRED}};
      mLayout = new TableLayout(layout_size);

      try
      {
         jbInit();
      }
      catch(Exception ex)
      {
         ex.printStackTrace();
      }
   }

   public Object getViewpoint()
   {
      return mViewpoint;
   }

   public Object getUser()
   {
      return mUser;
   }

   public void nameChanged(ConfigElementEvent e)
   {
   }

   public void propertyValueChanged(ConfigElementEvent e)
   {
      if ( e.getProperty().equals("view") )
      {
         mViewpoint = e.getValue();
      }
      else if ( e.getProperty().equals("user") )
      {
         mUser = e.getValue();
      }
   }

   public void propertyValueAdded(ConfigElementEvent e)
   {
   }

   public void propertyValueRemoved(ConfigElementEvent e)
   {
   }

   private void jbInit() throws Exception
   {
      this.setLayout(mLayout);
      mViewpointLabel.setLabelFor(mViewpointEditor);
      mViewpointLabel.setText("Viewpoint");
      mUserLabel.setLabelFor(mUserEditor);
      mUserLabel.setText("User");
      this.add(mViewpointLabel, new TableLayoutConstraints(0, 0, 0, 0,
                                                           TableLayout.RIGHT,
                                                           TableLayout.FULL));
      this.add(mViewpointEditor, new TableLayoutConstraints(2, 0, 2, 0,
                                                            TableLayout.FULL,
                                                            TableLayout.FULL));
      this.add(mUserLabel, new TableLayoutConstraints(0, 2, 0, 2,
                                                      TableLayout.RIGHT,
                                                      TableLayout.FULL));
      this.add(mUserEditor, new TableLayoutConstraints(2, 2, 2, 2,
                                                       TableLayout.FULL,
                                                       TableLayout.FULL));
   }

   private Object mViewpoint = null;
   private Object mUser      = null;

   private TableLayout mLayout = null;
   private JLabel mViewpointLabel = new JLabel();
   private PropertyEditorPanel mViewpointEditor = null;
   private JLabel mUserLabel = new JLabel();
   private PropertyEditorPanel mUserEditor = null;
}

@@ -1549,67 +1549,8 @@
 .*;%0A
-import org.vrjuggler.jccl.config.event.ConfigElementEvent;%0A
 impo
@@ -1700,19 +1700,16 @@
 torPanel
-%0A  
  extends
@@ -1720,44 +1720,8 @@
 nel%0A
-   implements ConfigElementListener%0A
 %7B%0A  
@@ -2121,23 +2121,10 @@
     
-ConfigElement e
+mE
 lt =
@@ -2174,98 +2174,15 @@
 nk%22,
-%0A                                         vp_def);%0A      elt.addConfigElementListener(this
+ vp_def
 );%0A%0A
@@ -2236,17 +2236,18 @@
         
-e
+mE
 lt.addCo
@@ -2344,33 +2344,34 @@
 ertyEditorPanel(
-e
+mE
 lt.getProperty(%22
@@ -2477,33 +2477,34 @@
                 
-e
+mE
 lt, 0, Color.whi
@@ -2561,17 +2561,18 @@
 orPanel(
-e
+mE
 lt.getPr
@@ -2694,17 +2694,18 @@
         
-e
+mE
 lt, 0, C
@@ -3173,25 +3173,42 @@
 return m
-Viewpoint
+Elt.getProperty(%22view%22, 0)
 ;%0A   %7D%0A%0A
@@ -3257,470 +3257,35 @@
 rn m
-User;%0A   %7D%0A%0A   public void nameChanged(ConfigElementEvent e)%0A   %7B%0A   %7D%0A%0A   public void propertyValueChanged(ConfigElementEvent e)%0A   %7B%0A      if ( e.getProperty().equals(%22view%22) )%0A      %7B%0A         mViewpoint = e.getValue();%0A      %7D%0A      else if ( e.getProperty().equals(%22user%22) )%0A      %7B%0A         mUser = e.getValue();%0A      %7D%0A   %7D%0A%0A   public void propertyValueAdded(ConfigElementEvent e)%0A   %7B%0A   %7D%0A%0A   public void propertyValueRemoved(ConfigElementEvent e)%0A   %7B
+Elt.getProperty(%22user%22, 0);
 %0A   
@@ -4446,62 +4446,26 @@
 ate 
-Object mViewpoint = null;%0A   private Object mUser     
+ConfigElement mElt
  = n

Simplify code to take advantage of what the ConfigElement class provides by itself. Bug fixed: The value 'null' would be returned for the view if the user did not change it from the default.