ObjectEditorPanel.java :  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3dedit » scenegrapheditor » nodeeditors » Java Open Source

Java Open Source » 6.0 JDK Modules » java 3d 
java 3d » org » jdesktop » j3dedit » scenegrapheditor » nodeeditors » ObjectEditorPanel.java
/*
 *  $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/nodeeditors/ObjectEditorPanel.java,v 1.1 2005/04/20 22:21:01 paulby Exp $
 *
 *                         Sun Public License Notice
 *
 *  The contents of this file are subject to the Sun Public License Version
 *  1.0 (the "License"). You may not use this file except in compliance with
 *  the License. A copy of the License is available at http://www.sun.com/
 *  
 *  The Original Code is the Java 3D(tm) Scene Graph Editor.
 *  The Initial Developer of the Original Code is Paul Byrne.
 *  Portions created by Paul Byrne are Copyright (C) 2002.
 *  All Rights Reserved.
 *  
 *  Contributor(s): Paul Byrne.
 *  
 **/
package org.jdesktop.j3dedit.scenegrapheditor.nodeeditors; 

import java.awt.Frame;
import javax.swing.JPanel;
import javax.media.j3d.NodeComponent;

/**
  * Superclass for all Component Editors
  *
  * @author Paul Byrne
  * @version  1.5, 01/18/02
  */
public abstract class ObjectEditorPanel extends JPanel {

    protected Object node;  // Reference to node which is
          // being edited

    protected NodeEditorPanel parentEditor;  // EditorPanel in which this
          // component editor is working

    private boolean updateFlag;  // Set true each time user changes GUI values
    protected boolean readOnly = false;

    public ObjectEditorPanel() {
  super();
    }

    public void setReadOnly( boolean readOnly ) {
       this.readOnly = readOnly;
       
       for( int i=0; i<getComponentCount(); i++)
         getComponent(i).setEnabled( !readOnly );
    }
    
    public boolean getReadOnly() {
      return readOnly;
    }
    
    /** 
      * Start editing this node
      * Set the GUI components
      * Set the capability bits
      */
    public void startEdit( Object node, NodeEditorPanel parent ) {
  this.node = node;

  parentEditor = parent;
    }

    /**
      * Finish editing this node
      * Set capability bits back to original settings
      */
    public void finishEdit() {
  resetCapabilityBits( node );
  parentEditor = null;
    }

    /** @deprecated
    */
    protected void resetControls() {
      throw new RuntimeException("Dont call reset Controls");
    }

    /**
      * Set the GUI controls for represent node
      */
    protected abstract void setControls();
    
    /**
      * Permanently apply the changes to the node
      */
    protected abstract void applyChanges();
    
    /**
      * Reset the changes to the state when setControls or applyChanges
      * was last called
      */
    protected abstract void resetChanges();

    /**
      * Set capability bits so panel can update node
      */
    protected abstract void setCapabilityBits( Object node );

    /**
      * Reset capability bits to original settings
      */
    protected void resetCapabilityBits( Object node ) {
    }
    
    protected void storeCapabilityBits( Object node ) {
    }

    /**
      * Create the GUI components and layout panel
      */
    protected void createPanel() {
    }

    /**
      * Called by NodeState when the user applies changes
      * or when changes need applying
      */
    protected void setUpdateRequired( boolean update ) {
  updateFlag = update;

        parentEditor.setUpdateRequired( update );
    }

    /**
      * Returns true if the user has changed the state using the GUI
      */
    protected boolean getUpdateRequired() {
  return updateFlag;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.