home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 3.0 KB | 107 lines |
- /*
- * @(#ConnectionInfoEditor.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.*;
- import java.util.*;
-
- /**
- * Supports editing the ConnectionInfo property.
- */
- public class ConnectionInfoEditor extends PropertyEditorSupport
- {
-
- /**
- * Constructs a ConnectionInfoEditor object.
- */
- public ConnectionInfoEditor() {
- }
-
- /**
- * 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";
- if (value instanceof String) {
- name = (String)value;
- }
- else if (value instanceof ConnectionInfo) {
- try {
- name = ((ConnectionInfo)value).getName();
- }
- catch (Exception ex) {
- }
- }
- firePropertyChange();
- }
-
- /**
- * @return The value of the property.
- */
-
- public Object getValue() {
- if (name.equals("null")) {
- return null;
- }
- ConnectionInfo conn = new ConnectionInfo("");
- conn.setName(name);
- return conn;
- }
-
- //----------------------------------------------------------------------
-
- /**
- * 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";
-
- }
-