org-netbeans-core

16:39:39.648 INFO  jd.cli.Main - Decompiling org-netbeans-core.jar
package org.netbeans.beaninfo.editors;

import java.beans.PropertyEditorSupport;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Date;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import org.netbeans.core.UIExceptions;
import org.openide.explorer.propertysheet.ExPropertyEditor;
import org.openide.explorer.propertysheet.PropertyEnv;
import org.openide.explorer.propertysheet.editors.XMLPropertyEditor;
import org.openide.util.NbBundle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

abstract class ArrayOfIntSupport
  extends PropertyEditorSupport
  implements XMLPropertyEditor, ExPropertyEditor
{
  private static final String VALUE_FORMAT = NbBundle.getBundle(ArrayOfIntSupport.class).getString("EXC_BadFormatValue");
  private int count;
  private String className;
  PropertyEnv env;
  public static final String ATTR_VALUE = "value";
  
  public ArrayOfIntSupport(String paramString, int paramInt)
  {
    className = paramString;
    count = paramInt;
  }
  
  public void attachEnv(PropertyEnv paramPropertyEnv)
  {
    env = paramPropertyEnv;
  }
  
  public String getJavaInitializationString()
  {
    int[] arrayOfInt = getValues();
    StringBuffer localStringBuffer = new StringBuffer("new ");
    
    localStringBuffer.append(className);
    localStringBuffer.append("(");
    addArray(localStringBuffer, arrayOfInt);
    localStringBuffer.append(")");
    return localStringBuffer.toString();
  }
  
  abstract int[] getValues();
  
  abstract void setValues(int[] paramArrayOfInt);
  
  public String getAsText()
  {
    if (getValue() == null) {
      return "null";
    }
    int[] arrayOfInt = getValues();
    if (arrayOfInt == null) {
      return null;
    }
    StringBuffer localStringBuffer = new StringBuffer("[");
    addArray(localStringBuffer, arrayOfInt);
    localStringBuffer.append("]");
    return localStringBuffer.toString();
  }
  
  private void addArray(StringBuffer paramStringBuffer, int[] paramArrayOfInt)
  {
    for (int i = 0; i < count; i++)
    {
      if (paramArrayOfInt == null) {
        paramStringBuffer.append("0");
      } else {
        paramStringBuffer.append(paramArrayOfInt[i]);
      }
      if (i < count - 1) {
        paramStringBuffer.append(", ");
      }
    }
  }
  
  public void setAsText(String paramString)
    throws IllegalArgumentException
  {
    if (("null".equals(paramString)) || ("".equals(paramString)))
    {
      setValue(null);
      return;
    }
    int[] arrayOfInt = new int[count];
    NumberFormatException localNumberFormatException1 = 0;
    
    StringTokenizer localStringTokenizer = new StringTokenizer(paramString, "[] ,;", false);
    while (localStringTokenizer.hasMoreTokens())
    {
      String str = localStringTokenizer.nextToken();
      if (localNumberFormatException1 >= count) {
        badFormat(null);
      }
      try
      {
        arrayOfInt[localNumberFormatException1] = new Integer(str).intValue();
        localNumberFormatException1++;
      }
      catch (NumberFormatException localNumberFormatException2)
      {
        badFormat(localNumberFormatException2);
      }
    }
    if ((localNumberFormatException1 != count) && 
      (localNumberFormatException1 > 0))
    {
      int i = arrayOfInt[(localNumberFormatException1 - 1)];
      for (localNumberFormatException2 = localNumberFormatException1; localNumberFormatException2 < count; localNumberFormatException2++) {
        arrayOfInt[localNumberFormatException2] = i;
      }
    }
    setValues(arrayOfInt);
  }
  
  private void badFormat(Exception paramException)
    throws IllegalArgumentException
  {
    String str = new MessageFormat(VALUE_FORMAT).format(new Object[] { className, getHintFormat() });
    
    IllegalArgumentException localIllegalArgumentException = new IllegalArgumentException(str);
    UIExceptions.annotateUser(localIllegalArgumentException, paramException == null ? "" : paramException.getMessage(), str, paramException, new Date());
    
    throw localIllegalArgumentException;
  }
  
  String getHintFormat()
  {
    StringBuffer localStringBuffer = new StringBuffer("[");
    for (int i = 0; i < count; i++)
    {
      localStringBuffer.append("<n");
      localStringBuffer.append(i);
      localStringBuffer.append(">");
      if (i < count - 1) {
        localStringBuffer.append(", ");
      }
    }
    localStringBuffer.append("]");
    
    return localStringBuffer.toString();
  }
  
  protected abstract String getXMLValueTag();
  
  public void readFromXML(Node paramNode)
    throws IOException
  {
    if (!getXMLValueTag().equals(paramNode.getNodeName())) {
      throw new IOException();
    }
    NamedNodeMap localNamedNodeMap = paramNode.getAttributes();
    try
    {
      String str = localNamedNodeMap.getNamedItem("value").getNodeValue();
      setAsText(str);
    }
    catch (Exception localException)
    {
      throw new IOException();
    }
  }
  
  public Node storeToXML(Document paramDocument)
  {
    Element localElement = paramDocument.createElement(getXMLValueTag());
    localElement.setAttribute("value", getAsText());
    return localElement;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ArrayOfIntSupport
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.beans.FeatureDescriptor;
import org.openide.explorer.propertysheet.PropertyEnv;
import org.openide.util.NbBundle;

public class BoolEditor
  extends ExPropertyEditorSupport
{
  String[] stringValues = null;
  
  protected void attachEnvImpl(PropertyEnv paramPropertyEnv)
  {
    stringValues = ((String[])paramPropertyEnv.getFeatureDescriptor().getValue("stringValues"));
  }
  
  protected void validateEnv(PropertyEnv paramPropertyEnv)
  {
    if ((stringValues != null) && 
      (stringValues.length != 2)) {
      throw new ExPropertyEditorSupport.EnvException("String value hint for boolean editor must contain exactly 2 items.  The supplied value contains " + stringValues.length + " items: " + arrToStr(stringValues));
    }
  }
  
  private String getStringRep(boolean paramBoolean)
  {
    if (stringValues != null) {
      return stringValues[1];
    }
    String str;
    if (paramBoolean) {
      str = NbBundle.getMessage(BoolEditor.class, "TRUE");
    } else {
      str = NbBundle.getMessage(BoolEditor.class, "FALSE");
    }
    return str;
  }
  
  private Boolean stringVal(String paramString)
  {
    String str1 = paramString.trim().toUpperCase();
    String str2 = getStringRep(true).toUpperCase();
    if (str2.equals(str1)) {
      return Boolean.TRUE;
    }
    str2 = getStringRep(false).toUpperCase();
    if (str2.equals(str1)) {
      return Boolean.FALSE;
    }
    return null;
  }
  
  public String getJavaInitializationString()
  {
    Boolean localBoolean = (Boolean)getValue();
    if (localBoolean == null) {
      return "null";
    }
    return Boolean.TRUE.equals(getValue()) ? "true" : "false";
  }
  
  public String[] getTags()
  {
    return new String[] { getStringRep(true), getStringRep(false) };
  }
  
  public String getAsText()
  {
    Boolean localBoolean = (Boolean)getValue();
    if (localBoolean == null) {
      return NbBundle.getMessage(BoolEditor.class, "NULL");
    }
    return getStringRep(Boolean.TRUE.equals(getValue()));
  }
  
  public void setAsText(String paramString)
  {
    Boolean localBoolean = stringVal(paramString);
    boolean bool = localBoolean == null ? false : localBoolean.booleanValue();
    setValue(bool ? Boolean.TRUE : Boolean.FALSE);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.BoolEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

public class BooleanEditor
  extends WrappersEditor
{
  public BooleanEditor()
  {
    super(Boolean.TYPE);
  }
  
  public String getJavaInitializationString()
  {
    Boolean localBoolean = (Boolean)getValue();
    return Boolean.TRUE.equals(localBoolean) ? "java.lang.Boolean.TRUE" : "java.lang.Boolean.FALSE";
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.BooleanEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

public class ByteEditor
  extends WrappersEditor
{
  public ByteEditor()
  {
    super(Byte.TYPE);
  }
  
  public String getJavaInitializationString()
  {
    return "new java.lang.Byte((byte)" + getAsText() + ")";
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ByteEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.awt.Component;
import java.beans.PropertyEditorSupport;
import org.openide.explorer.propertysheet.editors.EnhancedPropertyEditor;

public class CharEditor
  extends PropertyEditorSupport
  implements EnhancedPropertyEditor
{
  public String getAsText()
  {
    char c = ((Character)getValue()).charValue();
    StringBuffer localStringBuffer = new StringBuffer(6);
    switch (c)
    {
    case '\b': 
      localStringBuffer.append("\\b"); break;
    case '\t': 
      localStringBuffer.append("\\t"); break;
    case '\n': 
      localStringBuffer.append("\\n"); break;
    case '\f': 
      localStringBuffer.append("\\f"); break;
    case '\r': 
      localStringBuffer.append("\\r"); break;
    case '\\': 
      localStringBuffer.append("\\\\"); break;
    default: 
      if ((c >= ' ') && (c <= ''))
      {
        localStringBuffer.append(c);
      }
      else
      {
        localStringBuffer.append("\\u");
        String str = Integer.toHexString(c);
        for (int i = 0; i < 4 - str.length(); i++) {
          localStringBuffer.append('0');
        }
        localStringBuffer.append(str);
      }
      break;
    }
    return localStringBuffer.toString();
  }
  
  public void setAsText(String paramString)
    throws IllegalArgumentException
  {
    if (paramString.length() < 1) {
      return;
    }
    char c = '\000';
    if (paramString.charAt(0) == '\\')
    {
      int i = paramString.length() >= 2 ? paramString.charAt(1) : 92;
      switch (i)
      {
      case 98: 
        c = '\b'; break;
      case 116: 
        c = '\t'; break;
      case 110: 
        c = '\n'; break;
      case 102: 
        c = '\f'; break;
      case 114: 
        c = '\r'; break;
      case 92: 
        c = '\\'; break;
      case 117: 
        String str = paramString.substring(2, paramString.length());
        if (str.length() > 4) {
          return;
        }
        try
        {
          int j = Integer.parseInt(str, 16);
          c = (char)j;
        }
        catch (NumberFormatException localNumberFormatException)
        {
          return;
        }
      default: 
        return;
      }
    }
    else
    {
      c = paramString.charAt(0);
    }
    setValue(Character.valueOf(c));
  }
  
  public void setValue(Object paramObject)
    throws IllegalArgumentException
  {
    if ((paramObject instanceof Character))
    {
      super.setValue(paramObject);
      return;
    }
    if ((paramObject instanceof String))
    {
      String str = (String)paramObject;
      if (str.length() >= 1)
      {
        super.setValue(Character.valueOf(str.charAt(0)));
        return;
      }
    }
    if (paramObject == null)
    {
      super.setValue(Character.valueOf('\000'));
      return;
    }
    throw new IllegalArgumentException();
  }
  
  public String getJavaInitializationString()
  {
    if (((Character)getValue()).charValue() == '\'') {
      return "'\\''";
    }
    return "'" + getAsText() + "'";
  }
  
  public Component getInPlaceCustomEditor()
  {
    return null;
  }
  
  public boolean hasInPlaceCustomEditor()
  {
    return false;
  }
  
  public boolean supportsEditingTaggedValues()
  {
    return true;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.CharEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

public class CharacterEditor
  extends WrappersEditor
{
  public CharacterEditor()
  {
    super(Character.TYPE);
  }
  
  public String getJavaInitializationString()
  {
    if (((Character)getValue()).charValue() == '\'') {
      return "new java.lang.Character('\\'')";
    }
    return "new java.lang.Character('" + getAsText() + "')";
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.CharacterEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.beans.PropertyEditorSupport;
import java.text.MessageFormat;
import java.util.Date;
import org.netbeans.core.UIExceptions;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;

public class ClassEditor
  extends PropertyEditorSupport
{
  public String getJavaInitializationString()
  {
    Class localClass = (Class)getValue();
    if (localClass == null) {
      return "null";
    }
    return "Class.forName (\"" + localClass.getName() + "\")";
  }
  
  public String getAsText()
  {
    Class localClass = (Class)getValue();
    if (localClass == null) {
      return "null";
    }
    return localClass.getName();
  }
  
  public void setAsText(String paramString)
    throws IllegalArgumentException
  {
    try
    {
      ClassLoader localClassLoader = (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class);
      setValue(localClassLoader.loadClass(paramString));
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      IllegalArgumentException localIllegalArgumentException = new IllegalArgumentException(localClassNotFoundException.getMessage());
      String str = MessageFormat.format(NbBundle.getMessage(ClassEditor.class, "FMT_EXC_CANT_LOAD_CLASS"), new Object[] { paramString });
      
      UIExceptions.annotateUser(localIllegalArgumentException, localClassNotFoundException.getMessage(), str, localClassNotFoundException, new Date());
      
      throw localIllegalArgumentException;
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ClassEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

final class ColorEditor$1
  implements PropertyChangeListener
{
  public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
  {
    ColorEditor.access$002(null);
    ColorEditor.access$102(null);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ColorEditor.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.awt.Color;
import javax.swing.colorchooser.DefaultColorSelectionModel;

final class ColorEditor$2
  extends DefaultColorSelectionModel
{
  ColorEditor$2(Color paramColor)
  {
    super(paramColor);
  }
  
  public void setSelectedColor(Color paramColor)
  {
    if ((paramColor instanceof ColorEditor.SuperColor)) {
      super.setSelectedColor((ColorEditor.SuperColor)paramColor);
    } else if ((paramColor instanceof Color)) {
      super.setSelectedColor(new ColorEditor.SuperColor(paramColor));
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ColorEditor.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.awt.Color;
import javax.swing.JColorChooser;
import javax.swing.colorchooser.ColorSelectionModel;

final class ColorEditor$3
  extends JColorChooser
{
  ColorEditor$3(ColorSelectionModel paramColorSelectionModel)
  {
    super(paramColorSelectionModel);
  }
  
  public void setColor(Color paramColor)
  {
    if (paramColor == null) {
      return;
    }
    super.setColor(paramColor);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ColorEditor.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.accessibility.AccessibleContext;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

class ColorEditor$NbColorChooser
  extends JPanel
  implements ChangeListener
{
  private final ColorEditor editor;
  private final ColorSelectionModel selectionModel;
  static final long serialVersionUID = -6230228701104365037L;
  
  public ColorEditor$NbColorChooser(ColorEditor paramColorEditor, JColorChooser paramJColorChooser)
  {
    editor = paramColorEditor;
    selectionModel = paramJColorChooser.getSelectionModel();
    setLayout(new BorderLayout());
    add(paramJColorChooser, "Center");
    paramJColorChooser.setColor((Color)paramColorEditor.getValue());
    selectionModel.addChangeListener(this);
    
    getAccessibleContext().setAccessibleDescription(ColorEditor.access$600("ACSD_CustomColorEditor"));
  }
  
  public void removeNotify()
  {
    super.removeNotify();
    selectionModel.removeChangeListener(this);
  }
  
  public Dimension getPreferredSize()
  {
    Dimension localDimension = super.getPreferredSize();
    return new Dimension(width + 50, height + 10);
  }
  
  public void stateChanged(ChangeEvent paramChangeEvent)
  {
    editor.setValue(selectionModel.getSelectedColor());
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ColorEditor.NbColorChooser
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.accessibility.AccessibleContext;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;

final class ColorEditor$NbColorChooserPanel$MyListCellRenderer
  extends JPanel
  implements ListCellRenderer
{
  private boolean selected;
  private boolean hasFocus;
  private int index;
  static final long serialVersionUID = -8877709520578055594L;
  
  public ColorEditor$NbColorChooserPanel$MyListCellRenderer(ColorEditor.NbColorChooserPanel paramNbColorChooserPanel)
  {
    setOpaque(true);
    setBorder(new EmptyBorder(1, 1, 1, 1));
  }
  
  public Dimension getPreferredSize()
  {
    try
    {
      FontMetrics localFontMetrics = getFontMetrics(getFont());
      return new Dimension(localFontMetrics.stringWidth(this$0.names[index]) + 30, localFontMetrics.getHeight() + 4);
    }
    catch (NullPointerException localNullPointerException) {}
    return new Dimension(10, 10);
  }
  
  public void paint(Graphics paramGraphics)
  {
    ((Graphics2D)paramGraphics).setRenderingHints(ColorEditor.access$900());
    
    Dimension localDimension = getSize();
    Color localColor = paramGraphics.getColor();
    if (selected) {
      paramGraphics.setColor(UIManager.getColor("List.selectionBackground"));
    } else {
      paramGraphics.setColor(UIManager.getColor("List.background"));
    }
    paramGraphics.fillRect(0, 0, width - 1, height - 1);
    if (hasFocus)
    {
      paramGraphics.setColor(Color.black);
      paramGraphics.drawRect(0, 0, width - 1, height - 1);
    }
    paramGraphics.setColor(Color.black);
    paramGraphics.drawRect(6, height / 2 - 5, 10, 10);
    paramGraphics.setColor(this$0.colors[index]);
    paramGraphics.fillRect(7, height / 2 - 4, 9, 9);
    if (selected) {
      paramGraphics.setColor(UIManager.getColor("List.selectionForeground"));
    } else {
      paramGraphics.setColor(UIManager.getColor("List.foreground"));
    }
    FontMetrics localFontMetrics = paramGraphics.getFontMetrics();
    paramGraphics.drawString(this$0.names[index], 22, (height - localFontMetrics.getHeight()) / 2 + localFontMetrics.getAscent());
    paramGraphics.setColor(localColor);
  }
  
  public Component getListCellRendererComponent(JList paramJList, Object paramObject, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
  {
    index = paramInt;
    selected = paramBoolean1;
    hasFocus = paramBoolean2;
    getAccessibleContext().setAccessibleName(this$0.names[paramInt]);
    return this;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ColorEditor.NbColorChooserPanel.MyListCellRenderer
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.accessibility.AccessibleContext;
import javax.swing.Icon;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

final class ColorEditor$NbColorChooserPanel
  extends AbstractColorChooserPanel
  implements ListSelectionListener
{
  static final long serialVersionUID = -2792992315444428631L;
  private JList list;
  String[] names;
  Color[] colors;
  int palette;
  ColorEditor ce;
  private String displayName;
  
  ColorEditor$NbColorChooserPanel(int paramInt, String[] paramArrayOfString, Color[] paramArrayOfColor, String paramString, ColorEditor paramColorEditor)
  {
    names = paramArrayOfString;
    colors = paramArrayOfColor;
    palette = paramInt;
    displayName = paramString;
    ce = paramColorEditor;
  }
  
  protected void buildChooser()
  {
    setLayout(new BorderLayout());
    add("Center", new JScrollPane(list = new JList(names)));
    
    list.setCellRenderer(new MyListCellRenderer());
    list.addListSelectionListener(this);
    
    list.getAccessibleContext().setAccessibleName(displayName);
  }
  
  public void updateChooser()
  {
    ColorEditor.SuperColor localSuperColor = ColorEditor.access$700(ce);
    if ((localSuperColor != null) && (palette == ColorEditor.SuperColor.access$500(localSuperColor)))
    {
      int i = ColorEditor.access$800(names, ColorEditor.SuperColor.access$200(localSuperColor));
      list.setSelectedIndex(i);
    }
    else
    {
      list.clearSelection();
    }
  }
  
  public String getDisplayName()
  {
    return displayName;
  }
  
  public Icon getSmallDisplayIcon()
  {
    return null;
  }
  
  public Icon getLargeDisplayIcon()
  {
    return null;
  }
  
  public void valueChanged(ListSelectionEvent paramListSelectionEvent)
  {
    if (!list.isSelectionEmpty())
    {
      int i = list.getSelectedIndex();
      getColorSelectionModel().setSelectedColor(new ColorEditor.SuperColor(names[i], palette, colors[i]));
    }
  }
  
  public void setColor(Color paramColor)
  {
    getColorSelectionModel().setSelectedColor(paramColor);
  }
  
  public Color getColor()
  {
    return getColorFromModel();
  }
  
  private final class MyListCellRenderer
    extends JPanel
    implements ListCellRenderer
  {
    private boolean selected;
    private boolean hasFocus;
    private int index;
    static final long serialVersionUID = -8877709520578055594L;
    
    public MyListCellRenderer()
    {
      setOpaque(true);
      setBorder(new EmptyBorder(1, 1, 1, 1));
    }
    
    public Dimension getPreferredSize()
    {
      try
      {
        FontMetrics localFontMetrics = getFontMetrics(getFont());
        return new Dimension(localFontMetrics.stringWidth(names[index]) + 30, localFontMetrics.getHeight() + 4);
      }
      catch (NullPointerException localNullPointerException) {}
      return new Dimension(10, 10);
    }
    
    public void paint(Graphics paramGraphics)
    {
      ((Graphics2D)paramGraphics).setRenderingHints(ColorEditor.access$900());
      
      Dimension localDimension = getSize();
      Color localColor = paramGraphics.getColor();
      if (selected) {
        paramGraphics.setColor(UIManager.getColor("List.selectionBackground"));
      } else {
        paramGraphics.setColor(UIManager.getColor("List.background"));
      }
      paramGraphics.fillRect(0, 0, width - 1, height - 1);
      if (hasFocus)
      {
        paramGraphics.setColor(Color.black);
        paramGraphics.drawRect(0, 0, width - 1, height - 1);
      }
      paramGraphics.setColor(Color.black);
      paramGraphics.drawRect(6, height / 2 - 5, 10, 10);
      paramGraphics.setColor(colors[index]);
      paramGraphics.fillRect(7, height / 2 - 4, 9, 9);
      if (selected) {
        paramGraphics.setColor(UIManager.getColor("List.selectionForeground"));
      } else {
        paramGraphics.setColor(UIManager.getColor("List.foreground"));
      }
      FontMetrics localFontMetrics = paramGraphics.getFontMetrics();
      paramGraphics.drawString(names[index], 22, (height - localFontMetrics.getHeight()) / 2 + localFontMetrics.getAscent());
      paramGraphics.setColor(localColor);
    }
    
    public Component getListCellRendererComponent(JList paramJList, Object paramObject, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
    {
      index = paramInt;
      selected = paramBoolean1;
      hasFocus = paramBoolean2;
      getAccessibleContext().setAccessibleName(names[paramInt]);
      return this;
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ColorEditor.NbColorChooserPanel
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.awt.Color;

class ColorEditor$SuperColor
  extends Color
{
  static final long serialVersionUID = 6147637669184334151L;
  private String id = null;
  private int palette = 0;
  private Color color;
  
  ColorEditor$SuperColor(Color paramColor)
  {
    super(paramColor.getRed(), paramColor.getGreen(), paramColor.getBlue());
    color = paramColor;
  }
  
  ColorEditor$SuperColor(String paramString, int paramInt, Color paramColor)
  {
    super(paramColor.getRed(), paramColor.getGreen(), paramColor.getBlue());
    color = paramColor;
    id = paramString;
    palette = paramInt;
  }
  
  public boolean equals(Object paramObject)
  {
    boolean bool = super.equals(paramObject);
    String str = null;
    int i = -1;
    if ((paramObject instanceof SuperColor))
    {
      str = ((SuperColor)paramObject).getID();
      i = ((SuperColor)paramObject).getPalette();
    }
    else
    {
      return bool;
    }
    if (str != null) {
      return (bool) && (str.equals(getID())) && (i == getPalette());
    }
    return (bool) && (null == getID()) && (i == getPalette());
  }
  
  private String getID()
  {
    return id;
  }
  
  private int getPalette()
  {
    return palette;
  }
  
  private Color getColor()
  {
    return color;
  }
  
  private String getAsText()
  {
    if (id != null) {
      return id;
    }
    return "[" + getRed() + "," + getGreen() + "," + getBlue() + "]";
  }
}

/* Location:
 * Qualified Name:     org.netbeans.beaninfo.editors.ColorEditor.SuperColor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.beaninfo.editors;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.SystemColor;
import java.awt.Toolkit;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyEditor;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.TreeSet;
import javax.accessibility.AccessibleContext;
import javax.swing.Icon;
import javax.swing.JColorChooser;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.LookAndFeel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.colorchooser.DefaultColorSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.netbeans.core.UIExceptions;
import org.openide.explorer.propertysheet.editors.XMLPropertyEditor;
import org.openide.util.NbBundle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public final class ColorEditor
  implements PropertyEditor, XMLPropertyEditor
{
  private static final Color[] awtColors = { 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 static final String[] awtGenerate = { "white", "lightGray", "gray", "darkGray", "black", "red", "pink", "orange", "yellow", "green", "magenta", "cyan", "blue" };
  private static final String[] systemGenerate = { "activeCaption", "activeCaptionBorder", "activeCaptionText", "control", "controlDkShadow", "controlHighlight", "controlLtHighlight", "controlShadow", "controlText", "desktop", "inactiveCaption", "inactiveCaptionBorder", "inactiveCaptionText", "info", "infoText", "menu", "menuText", "scrollbar", "text", "textHighlight", "textHighlightText", "textInactiveText", "textText", "window", "windowBorder", "windowText" };
  private static final Color[] systemColors = { SystemColor.activeCaption, SystemColor.activeCaptionBorder, SystemColor.activeCaptionText, SystemColor.control, SystemColor.controlDkShadow, SystemColor.controlHighlight, SystemColor.controlLtHighlight, SystemColor.controlShadow, SystemColor.controlText, SystemColor.desktop, SystemColor.inactiveCaption, SystemColor.inactiveCaptionBorder, SystemColor.inactiveCaptionText, SystemColor.info, SystemColor.infoText, SystemColor.menu, SystemColor.menuText, SystemColor.scrollbar, SystemColor.text, SystemColor.textHighlight, SystemColor.textHighlightText, SystemColor.textInactiveText, SystemColor.textText, SystemColor.window, SystemColor.windowBorder, SystemColor.windowText };
  static final boolean GTK = "GTK".equals(UIManager.getLookAndFeel().getID());
  static final boolean AQUA = "Aqua".equals(UIManager.getLookAndFeel().getID());
  private static final boolean antialias = (Boolean.getBoolean("nb.cellrenderer.antialiasing")) || (Boolean.getBoolean("swing.aatext")) || ((GTK) && (gtkShouldAntialias())) || (AQUA);
  
  static
  {
    UIManager.addPropertyChangeListener(new PropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent paramAnonymousPropertyChangeEvent)
      {
        ColorEditor.access$002(null);
        ColorEditor.access$102(null);
      }
    });
  }
  
  private static String[] swingColorNames = null;
  private static Color[] swingColors = null;
  public static final int AWT_PALETTE = 1;
  public static final int SYSTEM_PALETTE = 2;
  public static final int SWING_PALETTE = 3;
  static String[] awtColorNames;
  private static String[] systemColorNames;
  private static Boolean gtkAA;
  private static Map hintsMap;
  private SuperColor superColor;
  private PropertyChangeSupport support;
  public static final String XML_COLOR = "Color";
  public static final String ATTR_TYPE = "type";
  public static final String ATTR_RED = "red";
  public static final String ATTR_GREEN = "green";
  public static final String ATTR_BLUE = "blue";
  public static final String ATTR_ID = "id";
  public static final String ATTR_PALETTE = "palette";
  public static final String VALUE_PALETTE = "palette";
  public static final String VALUE_RGB = "rgb";
  public static final String VALUE_NULL = "null";
  
  public static JColorChooser getStaticChooser(ColorEditor paramColorEditor)
  {
    JColorChooser local3 = new JColorChooser(new DefaultColorSelectionModel(Color.white)
    {
      public void setSelectedColor(Color paramAnonymousColor)
      {
        if ((paramAnonymousColor instanceof ColorEditor.SuperColor)) {
          super.setSelectedColor((ColorEditor.SuperColor)paramAnonymousColor);
        } else if ((paramAnonymousColor instanceof Color)) {
          super.setSelectedColor(new ColorEditor.SuperColor(paramAnonymousColor));
        }
      }
    })
    {
      public void setColor(Color paramAnonymousColor)
      {
        if (paramAnonymousColor == null) {
          return;
        }
        super.setColor(paramAnonymousColor);
      }
    };
    local3.addChooserPanel(new NbColorChooserPanel(1, getAWTColorNames(), awtColors, getString("CTL_AWTPalette"), paramColorEditor));
    
    initSwingConstants();
    local3.addChooserPanel(new NbColorChooserPanel(3, swingColorNames, swingColors, getString("CTL_SwingPalette"), paramColorEditor));
    
    local3.addChooserPanel(new NbColorChooserPanel(2, getSystemColorNames(), systemColors, getString("CTL_SystemPalette"), paramColorEditor));
    
    return local3;
  }
  
  public ColorEditor()
  {
    support = new PropertyChangeSupport(this);
  }
  
  public Object getValue()
  {
    if (superColor != null)
    {
      if (superColor.getID() != null) {
        return superColor;
      }
      return superColor.getColor();
    }
    return null;
  }
  
  public void setValue(Object paramObject)
  {
    if (paramObject != null)
    {
      if ((paramObject instanceof SuperColor)) {
        superColor = ((SuperColor)paramObject);
      } else if ((paramObject instanceof Color)) {
        superColor = new SuperColor((Color)paramObject);
      }
    }
    else {
      superColor = null;
    }
    support.firePropertyChange("", null, null);
  }
  
  public String getAsText()
  {
    if (superColor == null) {
      return "null";
    }
    return superColor.getAsText();
  }
  
  public void setAsText(String paramString)
    throws IllegalArgumentException
  {
    if (paramString == null) {
      throw new IllegalArgumentException("null parameter");
    }
    paramString = paramString.trim();
    if ("null".equals(paramString))
    {
      setValue(null);
      return;
    }
    try
    {
      int i = paramString.length();
      if (i > 0)
      {
        k = -1;
        int m = -1;
        
        int n = paramString.charAt(0);
        int i1 = paramString.charAt(i - 1);
        if ((n == 91) && (i1 == 93))
        {
          k = 1;
          m = i - 1;
        }
        else if ((n >= 48) && (n <= 57) && (i1 >= 48) && (i1 <= 57))
        {
          k = 0;
          m = i;
        }
        if (k >= 0)
        {
          int i2 = paramString.indexOf(',');
          int i3 = i2 < 0 ? -1 : paramString.indexOf(',', i2 + 1);
          if ((i2 >= 0) && (i3 >= 0))
          {
            int i4 = Integer.parseInt(paramString.substring(k, i2).trim());
            
            int i5 = Integer.parseInt(paramString.substring(i2 + 1, i3).trim());
            
            int i6 = Integer.parseInt(paramString.substring(i3 + 1, m).trim());
            try
            {
              setValue(new SuperColor(null, 0, new Color(i4, i5, i6)));
              
              return;
            }
            catch (IllegalArgumentException localIllegalArgumentException2)
            {
              UIExceptions.annotateUser(localIllegalArgumentException2, null, localIllegalArgumentException2.getLocalizedMessage(), null, null);
              
              throw localIllegalArgumentException2;
            }
          }
        }
      }
    }
    catch (NumberFormatException localNumberFormatException) {}
    int k = 0;
    Color localColor = null;
    int j;
    if ((j = getIndex(getAWTColorNames(), paramString)) >= 0)
    {
      k = 1;
      localColor = awtColors[j];
    }
    if ((j < 0) && ((j = getIndex(getSystemColorNames(), paramString)) >= 0))
    {
      k = 2;
      localColor = systemColors[j];
    }
    if (j < 0)
    {
      initSwingConstants();
      if ((j = getIndex(swingColorNames, paramString)) >= 0)
      {
        k = 3;
        localColor = swingColors[j];
      }
    }
    if (j < 0)
    {
      String str = MessageFormat.format(NbBundle.getMessage(ColorEditor.class, "FMT_IllegalEntry"), new Object[] { paramString });
      
      IllegalArgumentException localIllegalArgumentException1 = new IllegalArgumentException(paramString);
      UIExceptions.annotateUser(localIllegalArgumentException1, paramString, str, null, null);
      throw localIllegalArgumentException1;
    }
    setValue(new SuperColor(paramString, k, localColor));
  }
  
  public String getJavaInitializationString()
  {
    if (superColor == null) {
      return "null";
    }
    if (superColor.getID() == null) {
      return "new java.awt.Color(" + superColor.getRed() + ", " + superColor.getGreen() + ", " + superColor.getBlue() + ")";
    }
    switch (superColor.getPalette())
    {
    case 1: 
    default: 
      return "java.awt.Color." + awtGenerate[getIndex(getAWTColorNames(), superColor.getID())];
    case 2: 
      return "java.awt.SystemColor." + systemGenerate[getIndex(getSystemColorNames(), superColor.getID())];
    }
    if (superColor.getID() == null) {
      return "new java.awt.Color(" + superColor.getRed() + ", " + superColor.getGreen() + ", " + superColor.getBlue() + ")";
    }
    return "javax.swing.UIManager.getDefaults().getColor(\"" + superColor.getID() + "\")";
  }
  
  public String[] getTags()
  {
    if (superColor == null) {
      return getAWTColorNames();
    }
    switch (superColor.getPalette())
    {
    case 1: 
      return getAWTColorNames();
    case 2: 
      return getSystemColorNames();
    case 3: 
      initSwingConstants();
      return swingColorNames;
    }
    return null;
  }
  
  public boolean isPaintable()
  {
    return true;
  }
  
  public void paintValue(Graphics paramGraphics, Rectangle paramRectangle)
  {
    ((Graphics2D)paramGraphics).setRenderingHints(getHints());
    int i;
    if (superColor != null)
    {
      localObject = paramGraphics.getColor();
      paramGraphics.drawRect(x, y + height / 2 - 5, 10, 10);
      paramGraphics.setColor(superColor);
      paramGraphics.fillRect(x + 1, y + height / 2 - 4, 9, 9);
      paramGraphics.setColor((Color)localObject);
      i = 18;
    }
    else
    {
      i = 0;
    }
    Object localObject = paramGraphics.getFontMetrics();
    paramGraphics.drawString(getAsText(), x + i, y + (height - ((FontMetrics)localObject).getHeight()) / 2 + ((FontMetrics)localObject).getAscent());
  }
  
  public boolean supportsCustomEditor()
  {
    return true;
  }
  
  public Component getCustomEditor()
  {
    return new NbColorChooser(this, getStaticChooser(this));
  }
  
  public void addPropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    support.addPropertyChangeListener(paramPropertyChangeListener);
  }
  
  public void removePropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    support.removePropertyChangeListener(paramPropertyChangeListener);
  }
  
  private static synchronized String[] getAWTColorNames()
  {
    if (awtColorNames == null) {
      awtColorNames = new String[] { getString("LAB_White"), getString("LAB_LightGray"), getString("LAB_Gray"), getString("LAB_DarkGray"), getString("LAB_Black"), getString("LAB_Red"), getString("LAB_Pink"), getString("LAB_Orange"), getStrin
1 2 3 4 5 6 7 8 9 10 11 12 13 14

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd