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"); } }
@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 } }
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()); } }
protected void setValueImpl(final RadContainer component, final ColorDescriptor value) throws Exception { if (myTitleColor) { component.setBorderTitleColor(value); } else { component.setBorderColor(value); } }
@NotNull public PropertyRenderer<ColorDescriptor> getRenderer() { if (myRenderer == null) { myRenderer = new ColorRenderer(); } return myRenderer; }
@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; }
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); } }
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; }
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; }
public ColorDescriptor getSelectedValue() { final Color color = myColorChooser.getColor(); if (color instanceof ColorDescriptorWrapper) { return ((ColorDescriptorWrapper) color).getDescriptor(); } return new ColorDescriptor(color); }
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()]); }
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); }
public ColorDescriptor getValue(final RadContainer component) { return myTitleColor ? component.getBorderTitleColor() : component.getBorderColor(); }
public void write(@NotNull ColorDescriptor value, XmlWriter writer) { writer.writeColorDescriptor(value); }
@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()); } }
public JComponent getComponent(RadRootContainer rootContainer, ColorDescriptor value, boolean selected, boolean hasFocus) { prepareComponent(value, selected); return this; }
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { prepareComponent((ColorDescriptor) value, selected); }
public ColorDescriptor getValue() throws Exception { return myValue; }
public JComponent getComponent(RadComponent component, ColorDescriptor value, InplaceContext inplaceContext) { myValue = value != null ? value : new ColorDescriptor(JBColor.BLACK); updateTextField(); return myTextField; }