home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
JDateMaskedFieldTypeEditor.java
< prev
next >
Wrap
Text File
|
1998-12-09
|
4KB
|
124 lines
/*
* @(#JDateMaskedFieldTypeEditor.java
*
* Copyright (c) 1998 Symantec Corporation. All Rights Reserved.
*
*/
// package statement
package com.symantec.itools.swing;
import java.beans.*;
import com.symantec.itools.swing.*;
import java.util.*;
/**
* Property editor for setting the type of JDateMaskedField.
*
* @author Vasudev J. Rao
* @version 1.0
*/
public class JDateMaskedFieldTypeEditor extends PropertyEditorSupport {
// static variables
//private static BRLEditorsResourceLoader loader;
//private static ResourceBundle bundle;
//static {
//loader = BRLEditorsResourceLoader.getInstance();
//bundle = loader.getBundle();
//}
/**
* return the property value as a text
*
* @return the value as text
*/
public String getAsText() {
Integer value = (Integer)getValue();
int intValue = value.intValue();
String text = null;
if ( intValue == JDateMaskedField.DATE_TYPE ) {
text = JDateMaskedField.DATE_TYPE_STRING;
}
else if ( intValue == JDateMaskedField.TIME_TYPE ) {
text = JDateMaskedField.TIME_TYPE_STRING;
}
else if ( intValue == JDateMaskedField.TIMESTAMP_TYPE ) {
text = JDateMaskedField.TIMESTAMP_TYPE_STRING;
}
else {
text = "Illegal Value" ;
}
return text;
}
/**
* getTags() method
*
* @return array of tags
*/
public String[] getTags() {
String[] tags = new String[ JDateMaskedField.NUMBER_OF_TYPES ];
tags[0] = new String( JDateMaskedField.DATE_TYPE_STRING );
tags[1] = new String( JDateMaskedField.TIME_TYPE_STRING );
tags[2] = new String( JDateMaskedField.TIMESTAMP_TYPE_STRING );
return tags;
}
/**
* setAsText() method
*
* @param text set to String
*/
public void setAsText( String text ) throws IllegalArgumentException {
int type = 0;
if ( text.equals ( JDateMaskedField.DATE_TYPE_STRING ) ) {
type = JDateMaskedField.DATE_TYPE;
}
else if ( text.equals ( JDateMaskedField.TIME_TYPE_STRING ) ) {
type = JDateMaskedField.TIME_TYPE;
}
else {
type = JDateMaskedField.TIMESTAMP_TYPE;
}
setValue( new Integer( type ) );
}
/**
* 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() {
StringBuffer buf = new StringBuffer();
Integer value = (Integer)getValue();
int intValue = value.intValue();
buf.append ( "com.symantec.itools.swing.JDateMaskedField" ).append (".");
if ( intValue == JDateMaskedField.DATE_TYPE ) {
buf.append ( JDateMaskedField.DATE_TYPE_STRING ) ;
}
else if ( intValue == JDateMaskedField.TIME_TYPE ) {
buf.append ( JDateMaskedField.TIME_TYPE_STRING );
}
else if ( intValue == JDateMaskedField.TIMESTAMP_TYPE ) {
buf.append (JDateMaskedField.TIMESTAMP_TYPE_STRING );
}
else {
buf = new StringBuffer("0");
}
return buf.toString();
}
}