001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/nodeeditors/ObjectEditorPanel.java,v 1.1 2005/04/20 22:21:01 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is the Java 3D(tm) Scene Graph Editor.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dedit.scenegrapheditor.nodeeditors;
019:
020: import java.awt.Frame;
021: import javax.swing.JPanel;
022: import javax.media.j3d.NodeComponent;
023:
024: /**
025: * Superclass for all Component Editors
026: *
027: * @author Paul Byrne
028: * @version 1.5, 01/18/02
029: */
030: public abstract class ObjectEditorPanel extends JPanel {
031:
032: protected Object node; // Reference to node which is
033: // being edited
034:
035: protected NodeEditorPanel parentEditor; // EditorPanel in which this
036: // component editor is working
037:
038: private boolean updateFlag; // Set true each time user changes GUI values
039: protected boolean readOnly = false;
040:
041: public ObjectEditorPanel() {
042: super ();
043: }
044:
045: public void setReadOnly(boolean readOnly) {
046: this .readOnly = readOnly;
047:
048: for (int i = 0; i < getComponentCount(); i++)
049: getComponent(i).setEnabled(!readOnly);
050: }
051:
052: public boolean getReadOnly() {
053: return readOnly;
054: }
055:
056: /**
057: * Start editing this node
058: * Set the GUI components
059: * Set the capability bits
060: */
061: public void startEdit(Object node, NodeEditorPanel parent) {
062: this .node = node;
063:
064: parentEditor = parent;
065: }
066:
067: /**
068: * Finish editing this node
069: * Set capability bits back to original settings
070: */
071: public void finishEdit() {
072: resetCapabilityBits(node);
073: parentEditor = null;
074: }
075:
076: /** @deprecated
077: */
078: protected void resetControls() {
079: throw new RuntimeException("Dont call reset Controls");
080: }
081:
082: /**
083: * Set the GUI controls for represent node
084: */
085: protected abstract void setControls();
086:
087: /**
088: * Permanently apply the changes to the node
089: */
090: protected abstract void applyChanges();
091:
092: /**
093: * Reset the changes to the state when setControls or applyChanges
094: * was last called
095: */
096: protected abstract void resetChanges();
097:
098: /**
099: * Set capability bits so panel can update node
100: */
101: protected abstract void setCapabilityBits(Object node);
102:
103: /**
104: * Reset capability bits to original settings
105: */
106: protected void resetCapabilityBits(Object node) {
107: }
108:
109: protected void storeCapabilityBits(Object node) {
110: }
111:
112: /**
113: * Create the GUI components and layout panel
114: */
115: protected void createPanel() {
116: }
117:
118: /**
119: * Called by NodeState when the user applies changes
120: * or when changes need applying
121: */
122: protected void setUpdateRequired(boolean update) {
123: updateFlag = update;
124:
125: parentEditor.setUpdateRequired(update);
126: }
127:
128: /**
129: * Returns true if the user has changed the state using the GUI
130: */
131: protected boolean getUpdateRequired() {
132: return updateFlag;
133: }
134: }
|