feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
76
jdkSrc/jdk8/com/sun/beans/editors/BooleanEditor.java
Normal file
76
jdkSrc/jdk8/com/sun/beans/editors/BooleanEditor.java
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
/**
|
||||
* Property editor for a java builtin "boolean" type.
|
||||
*/
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
public class BooleanEditor extends PropertyEditorSupport {
|
||||
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
Object value = getValue();
|
||||
return (value != null)
|
||||
? value.toString()
|
||||
: "null";
|
||||
}
|
||||
|
||||
public String getAsText() {
|
||||
Object value = getValue();
|
||||
return (value instanceof Boolean)
|
||||
? getValidName((Boolean) value)
|
||||
: null;
|
||||
}
|
||||
|
||||
public void setAsText(String text) throws java.lang.IllegalArgumentException {
|
||||
if (text == null) {
|
||||
setValue(null);
|
||||
} else if (isValidName(true, text)) {
|
||||
setValue(Boolean.TRUE);
|
||||
} else if (isValidName(false, text)) {
|
||||
setValue(Boolean.FALSE);
|
||||
} else {
|
||||
throw new java.lang.IllegalArgumentException(text);
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getTags() {
|
||||
return new String[] {getValidName(true), getValidName(false)};
|
||||
}
|
||||
|
||||
// the following method should be localized (4890258)
|
||||
|
||||
private String getValidName(boolean value) {
|
||||
return value ? "True" : "False";
|
||||
}
|
||||
|
||||
private boolean isValidName(boolean value, String name) {
|
||||
return getValidName(value).equalsIgnoreCase(name);
|
||||
}
|
||||
}
|
||||
48
jdkSrc/jdk8/com/sun/beans/editors/ByteEditor.java
Normal file
48
jdkSrc/jdk8/com/sun/beans/editors/ByteEditor.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
/**
|
||||
* Property editor for a java builtin "byte" type.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
public class ByteEditor extends NumberEditor {
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
Object value = getValue();
|
||||
return (value != null)
|
||||
? "((byte)" + value + ")"
|
||||
: "null";
|
||||
}
|
||||
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue((text == null) ? null : Byte.decode(text));
|
||||
}
|
||||
|
||||
}
|
||||
214
jdkSrc/jdk8/com/sun/beans/editors/ColorEditor.java
Normal file
214
jdkSrc/jdk8/com/sun/beans/editors/ColorEditor.java
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
import java.awt.*;
|
||||
import java.beans.*;
|
||||
|
||||
public class ColorEditor extends Panel implements PropertyEditor {
|
||||
private static final long serialVersionUID = 1781257185164716054L;
|
||||
|
||||
public ColorEditor() {
|
||||
setLayout(null);
|
||||
|
||||
ourWidth = hPad;
|
||||
|
||||
// Create a sample color block bordered in black
|
||||
Panel p = new Panel();
|
||||
p.setLayout(null);
|
||||
p.setBackground(Color.black);
|
||||
sample = new Canvas();
|
||||
p.add(sample);
|
||||
sample.reshape(2, 2, sampleWidth, sampleHeight);
|
||||
add(p);
|
||||
p.reshape(ourWidth, 2, sampleWidth+4, sampleHeight+4);
|
||||
ourWidth += sampleWidth + 4 + hPad;
|
||||
|
||||
text = new TextField("", 14);
|
||||
add(text);
|
||||
text.reshape(ourWidth,0,100,30);
|
||||
ourWidth += 100 + hPad;
|
||||
|
||||
choser = new Choice();
|
||||
int active = 0;
|
||||
for (int i = 0; i < colorNames.length; i++) {
|
||||
choser.addItem(colorNames[i]);
|
||||
}
|
||||
add(choser);
|
||||
choser.reshape(ourWidth,0,100,30);
|
||||
ourWidth += 100 + hPad;
|
||||
|
||||
resize(ourWidth,40);
|
||||
}
|
||||
|
||||
public void setValue(Object o) {
|
||||
Color c = (Color)o;
|
||||
changeColor(c);
|
||||
}
|
||||
|
||||
public Dimension preferredSize() {
|
||||
return new Dimension(ourWidth, 40);
|
||||
}
|
||||
|
||||
public boolean keyUp(Event e, int key) {
|
||||
if (e.target == text) {
|
||||
try {
|
||||
setAsText(text.getText());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// Quietly ignore.
|
||||
}
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
public void setAsText(String s) throws java.lang.IllegalArgumentException {
|
||||
if (s == null) {
|
||||
changeColor(null);
|
||||
return;
|
||||
}
|
||||
int c1 = s.indexOf(',');
|
||||
int c2 = s.indexOf(',', c1+1);
|
||||
if (c1 < 0 || c2 < 0) {
|
||||
// Invalid string.
|
||||
throw new IllegalArgumentException(s);
|
||||
}
|
||||
try {
|
||||
int r = Integer.parseInt(s.substring(0,c1));
|
||||
int g = Integer.parseInt(s.substring(c1+1, c2));
|
||||
int b = Integer.parseInt(s.substring(c2+1));
|
||||
Color c = new Color(r,g,b);
|
||||
changeColor(c);
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalArgumentException(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean action(Event e, Object arg) {
|
||||
if (e.target == choser) {
|
||||
changeColor(colors[choser.getSelectedIndex()]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
return (this.color != null)
|
||||
? "new java.awt.Color(" + this.color.getRGB() + ",true)"
|
||||
: "null";
|
||||
}
|
||||
|
||||
|
||||
private void changeColor(Color c) {
|
||||
|
||||
if (c == null) {
|
||||
this.color = null;
|
||||
this.text.setText("");
|
||||
return;
|
||||
}
|
||||
|
||||
color = c;
|
||||
|
||||
text.setText("" + c.getRed() + "," + c.getGreen() + "," + c.getBlue());
|
||||
|
||||
int active = 0;
|
||||
for (int i = 0; i < colorNames.length; i++) {
|
||||
if (color.equals(colors[i])) {
|
||||
active = i;
|
||||
}
|
||||
}
|
||||
choser.select(active);
|
||||
|
||||
sample.setBackground(color);
|
||||
sample.repaint();
|
||||
|
||||
support.firePropertyChange("", null, null);
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public boolean isPaintable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) {
|
||||
Color oldColor = gfx.getColor();
|
||||
gfx.setColor(Color.black);
|
||||
gfx.drawRect(box.x, box.y, box.width-3, box.height-3);
|
||||
gfx.setColor(color);
|
||||
gfx.fillRect(box.x+1, box.y+1, box.width-4, box.height-4);
|
||||
gfx.setColor(oldColor);
|
||||
}
|
||||
|
||||
public String getAsText() {
|
||||
return (this.color != null)
|
||||
? this.color.getRed() + "," + this.color.getGreen() + "," + this.color.getBlue()
|
||||
: null;
|
||||
}
|
||||
|
||||
public String[] getTags() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.awt.Component getCustomEditor() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
|
||||
private String colorNames[] = { " ", "white", "lightGray", "gray", "darkGray",
|
||||
"black", "red", "pink", "orange",
|
||||
"yellow", "green", "magenta", "cyan",
|
||||
"blue"};
|
||||
private Color colors[] = { null, Color.white, Color.lightGray, Color.gray, Color.darkGray,
|
||||
Color.black, Color.red, Color.pink, Color.orange,
|
||||
Color.yellow, Color.green, Color.magenta, Color.cyan,
|
||||
Color.blue};
|
||||
|
||||
private Canvas sample;
|
||||
private int sampleHeight = 20;
|
||||
private int sampleWidth = 40;
|
||||
private int hPad = 5;
|
||||
private int ourWidth;
|
||||
|
||||
private Color color;
|
||||
private TextField text;
|
||||
private Choice choser;
|
||||
|
||||
private PropertyChangeSupport support = new PropertyChangeSupport(this);
|
||||
}
|
||||
41
jdkSrc/jdk8/com/sun/beans/editors/DoubleEditor.java
Normal file
41
jdkSrc/jdk8/com/sun/beans/editors/DoubleEditor.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
/**
|
||||
* Property editor for a java builtin "double" type.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
public class DoubleEditor extends NumberEditor {
|
||||
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue((text == null) ? null : Double.valueOf(text));
|
||||
}
|
||||
|
||||
}
|
||||
143
jdkSrc/jdk8/com/sun/beans/editors/EnumEditor.java
Normal file
143
jdkSrc/jdk8/com/sun/beans/editors/EnumEditor.java
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.beans.editors;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyEditor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Property editor for java.lang.Enum subclasses.
|
||||
*
|
||||
* @see PropertyEditor
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @author Sergey A. Malenkov
|
||||
*/
|
||||
public final class EnumEditor implements PropertyEditor {
|
||||
private final List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
|
||||
|
||||
private final Class type;
|
||||
private final String[] tags;
|
||||
|
||||
private Object value;
|
||||
|
||||
public EnumEditor( Class type ) {
|
||||
Object[] values = type.getEnumConstants();
|
||||
if ( values == null ) {
|
||||
throw new IllegalArgumentException( "Unsupported " + type );
|
||||
}
|
||||
this.type = type;
|
||||
this.tags = new String[values.length];
|
||||
for ( int i = 0; i < values.length; i++ ) {
|
||||
this.tags[i] = ( ( Enum )values[i] ).name();
|
||||
}
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue( Object value ) {
|
||||
if ( ( value != null ) && !this.type.isInstance( value ) ) {
|
||||
throw new IllegalArgumentException( "Unsupported value: " + value );
|
||||
}
|
||||
Object oldValue;
|
||||
PropertyChangeListener[] listeners;
|
||||
synchronized ( this.listeners ) {
|
||||
oldValue = this.value;
|
||||
this.value = value;
|
||||
|
||||
if ( ( value == null ) ? oldValue == null : value.equals( oldValue ) ) {
|
||||
return; // do not fire event if value is not changed
|
||||
}
|
||||
int size = this.listeners.size();
|
||||
if ( size == 0 ) {
|
||||
return; // do not fire event if there are no any listener
|
||||
}
|
||||
listeners = this.listeners.toArray( new PropertyChangeListener[size] );
|
||||
}
|
||||
PropertyChangeEvent event = new PropertyChangeEvent( this, null, oldValue, value );
|
||||
for ( PropertyChangeListener listener : listeners ) {
|
||||
listener.propertyChange( event );
|
||||
}
|
||||
}
|
||||
|
||||
public String getAsText() {
|
||||
return ( this.value != null )
|
||||
? ( ( Enum )this.value ).name()
|
||||
: null;
|
||||
}
|
||||
|
||||
public void setAsText( String text ) {
|
||||
setValue( ( text != null )
|
||||
? Enum.valueOf( this.type, text )
|
||||
: null );
|
||||
}
|
||||
|
||||
public String[] getTags() {
|
||||
return this.tags.clone();
|
||||
}
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
String name = getAsText();
|
||||
return ( name != null )
|
||||
? this.type.getName() + '.' + name
|
||||
: "null";
|
||||
}
|
||||
|
||||
public boolean isPaintable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void paintValue( Graphics gfx, Rectangle box ) {
|
||||
}
|
||||
|
||||
public boolean supportsCustomEditor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Component getCustomEditor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener( PropertyChangeListener listener ) {
|
||||
synchronized ( this.listeners ) {
|
||||
this.listeners.add( listener );
|
||||
}
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener( PropertyChangeListener listener ) {
|
||||
synchronized ( this.listeners ) {
|
||||
this.listeners.remove( listener );
|
||||
}
|
||||
}
|
||||
}
|
||||
48
jdkSrc/jdk8/com/sun/beans/editors/FloatEditor.java
Normal file
48
jdkSrc/jdk8/com/sun/beans/editors/FloatEditor.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
/**
|
||||
* Property editor for a java builtin "float" type.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
public class FloatEditor extends NumberEditor {
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
Object value = getValue();
|
||||
return (value != null)
|
||||
? value + "F"
|
||||
: "null";
|
||||
}
|
||||
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue((text == null) ? null : Float.valueOf(text));
|
||||
}
|
||||
|
||||
}
|
||||
219
jdkSrc/jdk8/com/sun/beans/editors/FontEditor.java
Normal file
219
jdkSrc/jdk8/com/sun/beans/editors/FontEditor.java
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
import java.awt.*;
|
||||
import java.beans.*;
|
||||
|
||||
public class FontEditor extends Panel implements java.beans.PropertyEditor {
|
||||
private static final long serialVersionUID = 6732704486002715933L;
|
||||
|
||||
public FontEditor() {
|
||||
setLayout(null);
|
||||
|
||||
toolkit = Toolkit.getDefaultToolkit();
|
||||
fonts = toolkit.getFontList();
|
||||
|
||||
familyChoser = new Choice();
|
||||
for (int i = 0; i < fonts.length; i++) {
|
||||
familyChoser.addItem(fonts[i]);
|
||||
}
|
||||
add(familyChoser);
|
||||
familyChoser.reshape(20, 5, 100, 30);
|
||||
|
||||
styleChoser = new Choice();
|
||||
for (int i = 0; i < styleNames.length; i++) {
|
||||
styleChoser.addItem(styleNames[i]);
|
||||
}
|
||||
add(styleChoser);
|
||||
styleChoser.reshape(145, 5, 70, 30);
|
||||
|
||||
sizeChoser = new Choice();
|
||||
for (int i = 0; i < pointSizes.length; i++) {
|
||||
sizeChoser.addItem("" + pointSizes[i]);
|
||||
}
|
||||
add(sizeChoser);
|
||||
sizeChoser.reshape(220, 5, 70, 30);
|
||||
|
||||
resize(300,40);
|
||||
}
|
||||
|
||||
|
||||
public Dimension preferredSize() {
|
||||
return new Dimension(300, 40);
|
||||
}
|
||||
|
||||
public void setValue(Object o) {
|
||||
font = (Font) o;
|
||||
if (this.font == null)
|
||||
return;
|
||||
|
||||
changeFont(font);
|
||||
// Update the current GUI choices.
|
||||
for (int i = 0; i < fonts.length; i++) {
|
||||
if (fonts[i].equals(font.getFamily())) {
|
||||
familyChoser.select(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < styleNames.length; i++) {
|
||||
if (font.getStyle() == styles[i]) {
|
||||
styleChoser.select(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < pointSizes.length; i++) {
|
||||
if (font.getSize() <= pointSizes[i]) {
|
||||
sizeChoser.select(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void changeFont(Font f) {
|
||||
font = f;
|
||||
if (sample != null) {
|
||||
remove(sample);
|
||||
}
|
||||
sample = new Label(sampleText);
|
||||
sample.setFont(font);
|
||||
add(sample);
|
||||
Component p = getParent();
|
||||
if (p != null) {
|
||||
p.invalidate();
|
||||
p.layout();
|
||||
}
|
||||
invalidate();
|
||||
layout();
|
||||
repaint();
|
||||
support.firePropertyChange("", null, null);
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return (font);
|
||||
}
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
if (this.font == null)
|
||||
return "null";
|
||||
|
||||
return "new java.awt.Font(\"" + font.getName() + "\", " +
|
||||
font.getStyle() + ", " + font.getSize() + ")";
|
||||
}
|
||||
|
||||
public boolean action(Event e, Object arg) {
|
||||
String family = familyChoser.getSelectedItem();
|
||||
int style = styles[styleChoser.getSelectedIndex()];
|
||||
int size = pointSizes[sizeChoser.getSelectedIndex()];
|
||||
try {
|
||||
Font f = new Font(family, style, size);
|
||||
changeFont(f);
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Couldn't create font " + family + "-" +
|
||||
styleNames[style] + "-" + size);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
public boolean isPaintable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) {
|
||||
// Silent noop.
|
||||
Font oldFont = gfx.getFont();
|
||||
gfx.setFont(font);
|
||||
FontMetrics fm = gfx.getFontMetrics();
|
||||
int vpad = (box.height - fm.getAscent())/2;
|
||||
gfx.drawString(sampleText, 0, box.height-vpad);
|
||||
gfx.setFont(oldFont);
|
||||
}
|
||||
|
||||
public String getAsText() {
|
||||
if (this.font == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(this.font.getName());
|
||||
sb.append(' ');
|
||||
|
||||
boolean b = this.font.isBold();
|
||||
if (b) {
|
||||
sb.append("BOLD");
|
||||
}
|
||||
boolean i = this.font.isItalic();
|
||||
if (i) {
|
||||
sb.append("ITALIC");
|
||||
}
|
||||
if (b || i) {
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append(this.font.getSize());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue((text == null) ? null : Font.decode(text));
|
||||
}
|
||||
|
||||
public String[] getTags() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.awt.Component getCustomEditor() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean supportsCustomEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
support.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
support.removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
private Font font;
|
||||
private Toolkit toolkit;
|
||||
private String sampleText = "Abcde...";
|
||||
|
||||
private Label sample;
|
||||
private Choice familyChoser;
|
||||
private Choice styleChoser;
|
||||
private Choice sizeChoser;
|
||||
|
||||
private String fonts[];
|
||||
private String[] styleNames = { "plain", "bold", "italic" };
|
||||
private int[] styles = { Font.PLAIN, Font.BOLD, Font.ITALIC };
|
||||
private int[] pointSizes = { 3, 5, 8, 10, 12, 14, 18, 24, 36, 48 };
|
||||
|
||||
private PropertyChangeSupport support = new PropertyChangeSupport(this);
|
||||
|
||||
}
|
||||
42
jdkSrc/jdk8/com/sun/beans/editors/IntegerEditor.java
Normal file
42
jdkSrc/jdk8/com/sun/beans/editors/IntegerEditor.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
/**
|
||||
* Property editor for a java builtin "int" type.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
public class IntegerEditor extends NumberEditor {
|
||||
|
||||
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue((text == null) ? null : Integer.decode(text));
|
||||
}
|
||||
|
||||
}
|
||||
48
jdkSrc/jdk8/com/sun/beans/editors/LongEditor.java
Normal file
48
jdkSrc/jdk8/com/sun/beans/editors/LongEditor.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
/**
|
||||
* Property editor for a java builtin "long" type.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
public class LongEditor extends NumberEditor {
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
Object value = getValue();
|
||||
return (value != null)
|
||||
? value + "L"
|
||||
: "null";
|
||||
}
|
||||
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue((text == null) ? null : Long.decode(text));
|
||||
}
|
||||
|
||||
}
|
||||
44
jdkSrc/jdk8/com/sun/beans/editors/NumberEditor.java
Normal file
44
jdkSrc/jdk8/com/sun/beans/editors/NumberEditor.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
/**
|
||||
* Abstract Property editor for a java builtin number types.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
abstract public class NumberEditor extends PropertyEditorSupport {
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
Object value = getValue();
|
||||
return (value != null)
|
||||
? value.toString()
|
||||
: "null";
|
||||
}
|
||||
|
||||
}
|
||||
49
jdkSrc/jdk8/com/sun/beans/editors/ShortEditor.java
Normal file
49
jdkSrc/jdk8/com/sun/beans/editors/ShortEditor.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
/**
|
||||
* Property editor for a java builtin "short" type.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
public class ShortEditor extends NumberEditor {
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
Object value = getValue();
|
||||
return (value != null)
|
||||
? "((short)" + value + ")"
|
||||
: "null";
|
||||
}
|
||||
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue((text == null) ? null : Short.decode(text));
|
||||
}
|
||||
|
||||
}
|
||||
74
jdkSrc/jdk8/com/sun/beans/editors/StringEditor.java
Normal file
74
jdkSrc/jdk8/com/sun/beans/editors/StringEditor.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.beans.editors;
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
public class StringEditor extends PropertyEditorSupport {
|
||||
|
||||
public String getJavaInitializationString() {
|
||||
Object value = getValue();
|
||||
if (value == null)
|
||||
return "null";
|
||||
|
||||
String str = value.toString();
|
||||
int length = str.length();
|
||||
StringBuilder sb = new StringBuilder(length + 2);
|
||||
sb.append('"');
|
||||
for (int i = 0; i < length; i++) {
|
||||
char ch = str.charAt(i);
|
||||
switch (ch) {
|
||||
case '\b': sb.append("\\b"); break;
|
||||
case '\t': sb.append("\\t"); break;
|
||||
case '\n': sb.append("\\n"); break;
|
||||
case '\f': sb.append("\\f"); break;
|
||||
case '\r': sb.append("\\r"); break;
|
||||
case '\"': sb.append("\\\""); break;
|
||||
case '\\': sb.append("\\\\"); break;
|
||||
default:
|
||||
if ((ch < ' ') || (ch > '~')) {
|
||||
sb.append("\\u");
|
||||
String hex = Integer.toHexString((int) ch);
|
||||
for (int len = hex.length(); len < 4; len++) {
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(hex);
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
sb.append('"');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void setAsText(String text) {
|
||||
setValue(text);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user