home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 3.7 KB | 121 lines |
- /*
- * @(#RelationViewEditor.java
- *
- * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
- *
- */
-
-
- package symantec.itools.db.awt;
-
- import java.awt.*;
- import java.beans.*;
- import symantec.itools.db.pro.*;
-
- /**
- * Supports editing the RelationView property.
- */
- public class RelationViewEditor extends PropertyEditorSupport {
-
- /**
- * Constructs a default RelationViewEditor.
- */
- public RelationViewEditor() {
- }
-
- /**
- * Set (or change) the object that is to be edited.
- * @param value The new target object to be edited. Note that this
- * object should not be modified by the PropertyEditor, rather
- * the PropertyEditor should create a new object to hold any
- * modified value.
- */
- public void setValue(Object value) {
- name = "null";
- try {
- if (value != null) {
- if (value instanceof RelationView) {
- name = ((RelationView)value).getName();
- }
- else {
- System.out.println("RelationViewEditor.setValue (value is not a RelationView)");
- System.out.println("Class: [" + value.getClass().getName() + "]");
- System.out.println("Value: [" + value.toString() + "]");
- Thread.dumpStack();
- if (value instanceof String) {
- name = (String)value;
- }
- }
- }
- }
- catch (Exception ex) {
- System.out.print("RelationViewEditor: setValue: exception " + ex.getMessage());
- }
- firePropertyChange();
- }
-
- /**
- * @return The value of the property.
- */
-
- public Object getValue() {
- if (name.equals("null")) {
- return null;
- }
- RelationView rv = null;
- try {
- Session sess = new Session("");
- ConnectionInfo conn = new ConnectionInfo("");
- Request rvRequest = new Request(sess, conn);
- rv = new RelationView(rvRequest);
- rv.setName(name);
- } catch (Exception ex) {
- System.out.print("RelationViewEditor: getValue: exception " + ex.getMessage());
- }
- return rv;
- }
-
- //----------------------------------------------------------------------
-
- /**
- * This method is intended for use when generating Java code to set
- * the value of the property. It should return a fragment of Java code
- * that can be used to initialize a variable with the current property
- * value.
- * <p>
- * Example results are "2", "new Color(127,127,34)", "Color.orange", etc.
- *
- * @return A fragment of Java code representing an initializer for the
- * current value.
- */
- public String getJavaInitializationString() {
- return name;
- }
-
- //----------------------------------------------------------------------
-
- /**
- * @return The property value as a string suitable for presentation
- * to a human to edit.
- * <p> Returns "null" is the value can't be expressed as a string.
- * <p> If a non-null value is returned, then the PropertyEditor should
- * be prepared to parse that string back in setAsText().
- */
- public String getAsText() {
- return name;
- }
-
- /**
- * Set the property value by parsing a given String. May raise
- * java.lang.IllegalArgumentException if either the String is
- * badly formatted or if this kind of property can't be expressed
- * as text.
- * @param text The string to be parsed.
- */
- public void setAsText(String text) throws java.lang.IllegalArgumentException {
- name = text;
- }
-
- private String name = "null";
- }
-