[Ejtools-cvs] libraries/adwt/src/main/net/sourceforge/ejtools/awt/editors ClassEditor.java,NONE,1.1
Brought to you by:
letiemble
From: <let...@us...> - 2002-06-10 07:25:32
|
Update of /cvsroot/ejtools/libraries/adwt/src/main/net/sourceforge/ejtools/awt/editors In directory usw-pr-cvs1:/tmp/cvs-serv8121/adwt/src/main/net/sourceforge/ejtools/awt/editors Modified Files: PropertiesEditor.java Added Files: ClassEditor.java Log Message: Pretty Print --- NEW FILE: ClassEditor.java --- /* * EJT, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.awt.editors; import java.beans.PropertyEditorSupport; /** * Description of the Class * * @author letiemble * @created 6 avril 2002 * @version $Revision: 1.2 $ * @todo Javadoc to complete */ public class ClassEditor extends PropertyEditorSupport { /** Description of the Field */ protected Object value; /** Constructor */ public ClassEditor() { } /** * Getter for the asText attribute * * @return The value */ public String getAsText() { return ((Class)value).getName(); } /** * Getter for the value attribute * * @return The value */ public Object getValue() { return value; } /** * Setter for the asText attribute * * @param s The new value */ public void setAsText(String s) { try { value = Class.forName(s); } catch (Exception e) { } firePropertyChange(); } /** * Setter for the value attribute * * @param obj The new value */ public void setValue(Object obj) { value = obj; firePropertyChange(); } } Index: PropertiesEditor.java =================================================================== RCS file: /cvsroot/ejtools/libraries/adwt/src/main/net/sourceforge/ejtools/awt/editors/PropertiesEditor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PropertiesEditor.java 5 May 2002 20:13:45 -0000 1.3 --- PropertiesEditor.java 10 Jun 2002 07:25:30 -0000 1.4 *************** *** 1,113 **** ! /* ! * EJT, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package net.sourceforge.ejtools.awt.editors; ! ! import java.awt.Component; ! import java.beans.PropertyEditorSupport; ! import java.util.Properties; ! ! import javax.swing.JTable; ! ! /** ! * Description of the Class ! * ! * @author letiemble ! * @created 19 octobre 2001 ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public class PropertiesEditor extends PropertyEditorSupport ! { ! ! /** Description of the Field */ ! protected Object value; ! ! ! /** Constructor for the PropertiesEditor object */ ! public PropertiesEditor() ! { ! value = new Properties(); ! } ! ! ! /** ! * Getter for the asText attribute ! * ! * @return The value of asText attribute ! */ ! public String getAsText() ! { ! return value.toString(); ! } ! ! ! /** ! * Getter for the customEditor attribute ! * ! * @return The value of customEditor attribute ! */ ! public Component getCustomEditor() ! { ! return new PropertiesView(); ! } ! ! ! /** ! * Gets the value attribute of the FileEditor object ! * ! * @return The value value ! */ ! public Object getValue() ! { ! return value; ! } ! ! ! /** ! * Setter for the asText attribute ! * ! * @param s The new value for asText attribute ! */ ! public void setAsText(String s) ! { ! firePropertyChange(); ! } ! ! ! /** ! * Setter for the value attribute ! * ! * @param obj The new value for value attribute ! */ ! public void setValue(Object obj) ! { ! firePropertyChange(); ! } ! ! ! /** ! * Description of the Method ! * ! * @return Description of the Returned Value ! */ ! public boolean supportsCustomEditor() ! { ! return true; ! } ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @created 19 octobre 2001 ! */ ! class PropertiesView extends JTable ! { ! } ! } ! --- 1,128 ---- ! /* ! * EJT, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package net.sourceforge.ejtools.awt.editors; ! ! import java.io.*; ! import java.awt.Component; ! import java.beans.PropertyEditorSupport; ! import java.util.Properties; ! ! import javax.swing.*; ! ! /** ! * Description of the Class ! * ! * @author letiemble ! * @created 19 octobre 2001 ! * @version $Revision$ ! * @todo Javadoc to complete ! */ ! public class PropertiesEditor extends PropertyEditorSupport ! { ! ! /** Description of the Field */ ! protected Object value; ! ! ! /** Constructor for the PropertiesEditor object */ ! public PropertiesEditor() ! { ! value = new Properties(); ! } ! ! ! /** ! * Getter for the asText attribute ! * ! * @return The value of asText attribute ! */ ! public String getAsText() { ! ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); ! try { ! ((Properties)value).store(bytearrayoutputstream, ""); ! } catch ( IOException ioexception ) { ! ioexception.printStackTrace(); ! } ! return bytearrayoutputstream.toString(); ! } ! ! ! /** ! * Getter for the customEditor attribute ! * ! * @return The value of customEditor attribute ! */ ! public Component getCustomEditor() ! { ! return new PropertiesView(); ! } ! ! ! /** ! * Gets the value attribute of the FileEditor object ! * ! * @return The value value ! */ ! public Object getValue() ! { ! return value; ! } ! ! ! /** ! * Setter for the asText attribute ! * ! * @param s The new value for asText attribute ! */ ! public void setAsText(String s) ! { ! try { ! ((Properties)value).load(new ByteArrayInputStream(s.getBytes())); ! firePropertyChange(); ! } catch ( IOException _ex ) { ! throw new IllegalArgumentException( "Illegal value" ); ! } ! } ! ! ! /** ! * Setter for the value attribute ! * ! * @param obj The new value for value attribute ! */ ! public void setValue(Object obj) ! { ! value = obj; ! firePropertyChange(); ! } ! ! ! /** ! * Description of the Method ! * ! * @return Description of the Returned Value ! */ ! public boolean supportsCustomEditor() ! { ! return true; ! } ! ! ! /** ! * Description of the Class ! * ! * @author letiembl ! * @created 19 octobre 2001 ! */ ! class PropertiesView extends JTextArea ! { ! public PropertiesView() { ! super(10, 40); ! setText( getAsText() ); ! } ! } ! } |