Java 类com.intellij.uiDesigner.lw.ColorDescriptor 实例源码

项目:intellij-ce-playground    文件:ColorPropertyCodeGenerator.java   
public void generatePushValue(final GeneratorAdapter generator, final Object value) {
  ColorDescriptor descriptor = (ColorDescriptor) value;
  if (descriptor.getColor() != null) {
    generator.newInstance(ourColorType);
    generator.dup();
    generator.push(descriptor.getColor().getRGB());
    generator.invokeConstructor(ourColorType, ourInitMethod);
  }
  else if (descriptor.getSwingColor() != null) {
    generator.push(descriptor.getSwingColor());
    generator.invokeStatic(ourUIManagerType, ourGetColorMethod);
  }
  else if (descriptor.getSystemColor() != null) {
    generator.getStatic(ourSystemColorType, descriptor.getSystemColor(), ourSystemColorType);
  }
  else if (descriptor.getAWTColor() != null) {
    generator.getStatic(ourColorType, descriptor.getAWTColor(), ourColorType);
  }
  else if (descriptor.isColorSet()) {
    throw new IllegalStateException("Unknown color type");
  }
}
项目:intellij-ce-playground    文件:IntroColorProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    if (component.getParent() != null) {
      Color componentColor = (Color) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
      Color parentColor = (Color) myReadMethod.invoke(component.getParent(), EMPTY_OBJECT_ARRAY);
      ColorDescriptor defaultColor = getDefaultValue(component);
      if (componentColor != null && !Comparing.equal(componentColor, parentColor) && !Comparing.equal(componentColor, defaultColor)) {
        setValue(radComponent, new ColorDescriptor(componentColor));
      }
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:tools-idea    文件:ColorPropertyCodeGenerator.java   
public void generatePushValue(final GeneratorAdapter generator, final Object value) {
  ColorDescriptor descriptor = (ColorDescriptor) value;
  if (descriptor.getColor() != null) {
    generator.newInstance(ourColorType);
    generator.dup();
    generator.push(descriptor.getColor().getRGB());
    generator.invokeConstructor(ourColorType, ourInitMethod);
  }
  else if (descriptor.getSwingColor() != null) {
    generator.push(descriptor.getSwingColor());
    generator.invokeStatic(ourUIManagerType, ourGetColorMethod);
  }
  else if (descriptor.getSystemColor() != null) {
    generator.getStatic(ourSystemColorType, descriptor.getSystemColor(), ourSystemColorType);
  }
  else if (descriptor.getAWTColor() != null) {
    generator.getStatic(ourColorType, descriptor.getAWTColor(), ourColorType);
  }
  else if (descriptor.isColorSet()) {
    throw new IllegalStateException("Unknown color type");
  }
}
项目:tools-idea    文件:IntroColorProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    if (component.getParent() != null) {
      Color componentColor = (Color) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
      Color parentColor = (Color) myReadMethod.invoke(component.getParent(), EMPTY_OBJECT_ARRAY);
      ColorDescriptor defaultColor = getDefaultValue(component);
      if (componentColor != null && !Comparing.equal(componentColor, parentColor) && !Comparing.equal(componentColor, defaultColor)) {
        setValue(radComponent, new ColorDescriptor(componentColor));
      }
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:consulo-ui-designer    文件:IntroColorProperty.java   
@Override
public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
  try {
    if (component.getParent() != null) {
      Color componentColor = (Color) myReadMethod.invoke(component, EMPTY_OBJECT_ARRAY);
      Color parentColor = (Color) myReadMethod.invoke(component.getParent(), EMPTY_OBJECT_ARRAY);
      ColorDescriptor defaultColor = getDefaultValue(component);
      if (componentColor != null && !Comparing.equal(componentColor, parentColor) && !Comparing.equal(componentColor, defaultColor)) {
        setValue(radComponent, new ColorDescriptor(componentColor));
      }
    }
  }
  catch (Exception e) {
    // ignore
  }
}
项目:intellij-ce-playground    文件:XmlWriter.java   
public void writeColorDescriptor(final ColorDescriptor value) {
  Color color = value.getColor();
  if (color != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_COLOR, color.getRGB());
  }
  else if (value.getSwingColor() != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_SWING_COLOR, value.getSwingColor());
  }
  else if (value.getSystemColor() != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_SYSTEM_COLOR, value.getSystemColor());
  }
  else if (value.getAWTColor() != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_AWT_COLOR, value.getAWTColor());
  }
}
项目:intellij-ce-playground    文件:BorderProperty.java   
protected void setValueImpl(final RadContainer component, final ColorDescriptor value) throws Exception {
  if (myTitleColor) {
    component.setBorderTitleColor(value);
  }
  else {
    component.setBorderColor(value);
  }
}
项目:intellij-ce-playground    文件:BorderProperty.java   
@NotNull
public PropertyRenderer<ColorDescriptor> getRenderer() {
  if (myRenderer == null) {
    myRenderer = new ColorRenderer();
  }
  return myRenderer;
}
项目:intellij-ce-playground    文件:IntroColorProperty.java   
@Override public ColorDescriptor getValue(final RadComponent component) {
  final ColorDescriptor colorDescriptor = (ColorDescriptor)component.getDelegee().getClientProperty(CLIENT_PROPERTY_KEY_PREFIX + getName());
  if (colorDescriptor == null) {
    return new ColorDescriptor((Color) invokeGetter(component));
  }
  return colorDescriptor;
}
项目:intellij-ce-playground    文件:ColorRenderer.java   
private void prepareComponent(final ColorDescriptor value, final boolean selected) {
  myColorDescriptor = value;
  clear();
  setIcon(UIDesignerIcons.Empty);
  setBackground(selected ? UIUtil.getTableSelectionBackground() : UIUtil.getTableBackground());
  if (myColorDescriptor != null) {
    append(myColorDescriptor.toString(),
           selected ? SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
  }
}
项目:tools-idea    文件:XmlWriter.java   
public void writeColorDescriptor(final ColorDescriptor value) {
  Color color = value.getColor();
  if (color != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_COLOR, color.getRGB());
  }
  else if (value.getSwingColor() != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_SWING_COLOR, value.getSwingColor());
  }
  else if (value.getSystemColor() != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_SYSTEM_COLOR, value.getSystemColor());
  }
  else if (value.getAWTColor() != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_AWT_COLOR, value.getAWTColor());
  }
}
项目:tools-idea    文件:BorderProperty.java   
protected void setValueImpl(final RadContainer component, final ColorDescriptor value) throws Exception {
  if (myTitleColor) {
    component.setBorderTitleColor(value);
  }
  else {
    component.setBorderColor(value);
  }
}
项目:tools-idea    文件:BorderProperty.java   
@NotNull
public PropertyRenderer<ColorDescriptor> getRenderer() {
  if (myRenderer == null) {
    myRenderer = new ColorRenderer();
  }
  return myRenderer;
}
项目:tools-idea    文件:IntroColorProperty.java   
@Override public ColorDescriptor getValue(final RadComponent component) {
  final ColorDescriptor colorDescriptor = (ColorDescriptor)component.getDelegee().getClientProperty(CLIENT_PROPERTY_KEY_PREFIX + getName());
  if (colorDescriptor == null) {
    return new ColorDescriptor((Color) invokeGetter(component));
  }
  return colorDescriptor;
}
项目:tools-idea    文件:ColorRenderer.java   
private void prepareComponent(final ColorDescriptor value, final boolean selected) {
  myColorDescriptor = value;
  clear();
  setIcon(UIDesignerIcons.Empty);
  setBackground(selected ? UIUtil.getTableSelectionBackground() : UIUtil.getTableBackground());
  if (myColorDescriptor != null) {
    append(myColorDescriptor.toString(),
           selected ? SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
  }
}
项目:tools-idea    文件:ColorEditor.java   
private List<ColorDescriptor> collectSwingColorDescriptors() {
  ArrayList<ColorDescriptor> result = new ArrayList<ColorDescriptor>();
  UIDefaults defaults = UIManager.getDefaults();
  Enumeration e = defaults.keys ();
  while(e.hasMoreElements()) {
    Object key = e.nextElement();
    Object value = defaults.get(key);
    if (key instanceof String && value instanceof Color) {
      result.add(ColorDescriptor.fromSwingColor((String) key));
    }
  }
  return result;
}
项目:tools-idea    文件:ColorEditor.java   
private List<ColorDescriptor> collectColorFields(final Class aClass, final boolean isSystem) {
  ArrayList<ColorDescriptor> result = new ArrayList<ColorDescriptor>();
  Field[] colorFields = aClass.getDeclaredFields();
  for(Field field: colorFields) {
    if ((field.getModifiers() & Modifier.STATIC) != 0 &&
        Color.class.isAssignableFrom(field.getType()) &&
        Character.isLowerCase(field.getName().charAt(0))) {
      final ColorDescriptor color = isSystem
                                    ? ColorDescriptor.fromSystemColor(field.getName())
                                    : ColorDescriptor.fromAWTColor(field.getName());
      result.add(color);
    }
  }
  return result;
}
项目:tools-idea    文件:ColorEditor.java   
public ColorDescriptor getSelectedValue() {
  final Color color = myColorChooser.getColor();
  if (color instanceof ColorDescriptorWrapper) {
    return ((ColorDescriptorWrapper) color).getDescriptor();
  }
  return new ColorDescriptor(color);
}
项目:tools-idea    文件:ColorEditor.java   
public MyDescriptorChooserPanel(final String displayName, List<ColorDescriptor> colorDescriptorList) {
  myDisplayName = displayName;

  Collections.sort(colorDescriptorList, new Comparator<ColorDescriptor>() {
    public int compare(final ColorDescriptor o1, final ColorDescriptor o2) {
      return o1.toString().compareTo(o2.toString());
    }
  });

  myColorDescriptors = colorDescriptorList.toArray(new ColorDescriptor[colorDescriptorList.size()]);
}
项目:tools-idea    文件:ColorEditor.java   
protected void buildChooser() {
  setLayout(new BorderLayout());
  myDescriptorList = new JBList(myColorDescriptors);
  myDescriptorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myDescriptorList.setVisibleRowCount(15);
  myDescriptorList.setCellRenderer(new ColorRenderer());
  myDescriptorList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      ColorDescriptor descriptor = (ColorDescriptor)myDescriptorList.getSelectedValue();
      getColorSelectionModel().setSelectedColor(new ColorDescriptorWrapper(descriptor));
    }
  });
  new ListSpeedSearch(myDescriptorList);
  add(ScrollPaneFactory.createScrollPane(myDescriptorList), BorderLayout.CENTER);
}
项目:consulo-ui-designer    文件:XmlWriter.java   
public void writeColorDescriptor(final ColorDescriptor value) {
  Color color = value.getColor();
  if (color != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_COLOR, color.getRGB());
  }
  else if (value.getSwingColor() != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_SWING_COLOR, value.getSwingColor());
  }
  else if (value.getSystemColor() != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_SYSTEM_COLOR, value.getSystemColor());
  }
  else if (value.getAWTColor() != null) {
    addAttribute(UIFormXmlConstants.ATTRIBUTE_AWT_COLOR, value.getAWTColor());
  }
}
项目:consulo-ui-designer    文件:BorderProperty.java   
protected void setValueImpl(final RadContainer component, final ColorDescriptor value) throws Exception {
  if (myTitleColor) {
    component.setBorderTitleColor(value);
  }
  else {
    component.setBorderColor(value);
  }
}
项目:consulo-ui-designer    文件:BorderProperty.java   
@NotNull
public PropertyRenderer<ColorDescriptor> getRenderer() {
  if (myRenderer == null) {
    myRenderer = new ColorRenderer();
  }
  return myRenderer;
}
项目:consulo-ui-designer    文件:IntroColorProperty.java   
@Override public ColorDescriptor getValue(final RadComponent component) {
  final ColorDescriptor colorDescriptor = (ColorDescriptor)component.getDelegee().getClientProperty(CLIENT_PROPERTY_KEY_PREFIX + getName());
  if (colorDescriptor == null) {
    return new ColorDescriptor((Color) invokeGetter(component));
  }
  return colorDescriptor;
}
项目:consulo-ui-designer    文件:ColorRenderer.java   
private void prepareComponent(final ColorDescriptor value, final boolean selected) {
  myColorDescriptor = value;
  clear();
  setIcon(UIDesignerIcons.Empty);
  setBackground(selected ? UIUtil.getTableSelectionBackground() : UIUtil.getTableBackground());
  if (myColorDescriptor != null) {
    append(myColorDescriptor.toString(),
           selected ? SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
  }
}
项目:consulo-ui-designer    文件:ColorEditor.java   
private List<ColorDescriptor> collectSwingColorDescriptors() {
  ArrayList<ColorDescriptor> result = new ArrayList<ColorDescriptor>();
  UIDefaults defaults = UIManager.getDefaults();
  Enumeration e = defaults.keys ();
  while(e.hasMoreElements()) {
    Object key = e.nextElement();
    Object value = defaults.get(key);
    if (key instanceof String && value instanceof Color) {
      result.add(ColorDescriptor.fromSwingColor((String) key));
    }
  }
  return result;
}
项目:consulo-ui-designer    文件:ColorEditor.java   
private List<ColorDescriptor> collectColorFields(final Class aClass, final boolean isSystem) {
  ArrayList<ColorDescriptor> result = new ArrayList<ColorDescriptor>();
  Field[] colorFields = aClass.getDeclaredFields();
  for(Field field: colorFields) {
    if ((field.getModifiers() & Modifier.STATIC) != 0 &&
        Color.class.isAssignableFrom(field.getType()) &&
        Character.isLowerCase(field.getName().charAt(0))) {
      final ColorDescriptor color = isSystem
                                    ? ColorDescriptor.fromSystemColor(field.getName())
                                    : ColorDescriptor.fromAWTColor(field.getName());
      result.add(color);
    }
  }
  return result;
}
项目:consulo-ui-designer    文件:ColorEditor.java   
public ColorDescriptor getSelectedValue() {
  final Color color = myColorChooser.getColor();
  if (color instanceof ColorDescriptorWrapper) {
    return ((ColorDescriptorWrapper) color).getDescriptor();
  }
  return new ColorDescriptor(color);
}
项目:consulo-ui-designer    文件:ColorEditor.java   
public MyDescriptorChooserPanel(final String displayName, List<ColorDescriptor> colorDescriptorList) {
  myDisplayName = displayName;

  Collections.sort(colorDescriptorList, new Comparator<ColorDescriptor>() {
    public int compare(final ColorDescriptor o1, final ColorDescriptor o2) {
      return o1.toString().compareTo(o2.toString());
    }
  });

  myColorDescriptors = colorDescriptorList.toArray(new ColorDescriptor[colorDescriptorList.size()]);
}
项目:consulo-ui-designer    文件:ColorEditor.java   
protected void buildChooser() {
  setLayout(new BorderLayout());
  myDescriptorList = new JBList(myColorDescriptors);
  myDescriptorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myDescriptorList.setVisibleRowCount(15);
  myDescriptorList.setCellRenderer(new ColorRenderer());
  myDescriptorList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      ColorDescriptor descriptor = (ColorDescriptor)myDescriptorList.getSelectedValue();
      getColorSelectionModel().setSelectedColor(new ColorDescriptorWrapper(descriptor));
    }
  });
  new ListSpeedSearch(myDescriptorList);
  add(ScrollPaneFactory.createScrollPane(myDescriptorList), BorderLayout.CENTER);
}
项目:intellij-ce-playground    文件:BorderProperty.java   
public ColorDescriptor getValue(final RadContainer component) {
  return myTitleColor ? component.getBorderTitleColor() : component.getBorderColor();
}
项目:intellij-ce-playground    文件:IntroColorProperty.java   
public void write(@NotNull ColorDescriptor value, XmlWriter writer) {
  writer.writeColorDescriptor(value);
}
项目:intellij-ce-playground    文件:IntroColorProperty.java   
@Override protected void setValueImpl(final RadComponent component, final ColorDescriptor value) throws Exception {
  component.getDelegee().putClientProperty(CLIENT_PROPERTY_KEY_PREFIX + getName(), value);
  if (value != null && value.isColorSet()) {
    invokeSetter(component, value.getResolvedColor());
  }
}
项目:intellij-ce-playground    文件:ColorRenderer.java   
public JComponent getComponent(RadRootContainer rootContainer, ColorDescriptor value, boolean selected, boolean hasFocus) {
  prepareComponent(value, selected);
  return this;
}
项目:intellij-ce-playground    文件:ColorRenderer.java   
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
  prepareComponent((ColorDescriptor) value, selected);
}
项目:intellij-ce-playground    文件:ColorEditor.java   
public ColorDescriptor getValue() throws Exception {
  return myValue;
}
项目:intellij-ce-playground    文件:ColorEditor.java   
public JComponent getComponent(RadComponent component, ColorDescriptor value, InplaceContext inplaceContext) {
  myValue = value != null ? value : new ColorDescriptor(JBColor.BLACK);
  updateTextField();
  return myTextField;
}
项目:tools-idea    文件:BorderProperty.java   
public ColorDescriptor getValue(final RadContainer component) {
  return myTitleColor ? component.getBorderTitleColor() : component.getBorderColor();
}
项目:tools-idea    文件:IntroColorProperty.java   
public void write(@NotNull ColorDescriptor value, XmlWriter writer) {
  writer.writeColorDescriptor(value);
}
项目:tools-idea    文件:IntroColorProperty.java   
@Override protected void setValueImpl(final RadComponent component, final ColorDescriptor value) throws Exception {
  component.getDelegee().putClientProperty(CLIENT_PROPERTY_KEY_PREFIX + getName(), value);
  if (value != null && value.isColorSet()) {
    invokeSetter(component, value.getResolvedColor());
  }
}