1 7 8 package org.jdesktop.jdnc.markup.attr; 9 10 import org.jdesktop.swing.data.MetaData; 11 12 import org.jdesktop.swing.decorator.AlternateRowHighlighter; 13 import org.jdesktop.swing.decorator.ConditionalHighlighter; 14 import org.jdesktop.swing.decorator.Highlighter; 15 import org.jdesktop.jdnc.*; 16 import org.jdesktop.jdnc.markup.*; 17 import org.jdesktop.jdnc.markup.elem.ElementProxy; 18 import org.jdesktop.swing.data.*; 19 import org.jdesktop.swing.table.*; 20 21 import java.awt.Color ; 22 23 import net.openmarkup.AttributeApplier; 24 import net.openmarkup.*; 25 26 import org.w3c.dom.Element ; 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.NodeList ; 29 30 35 public class HighlighterAttributes { 36 public static final AttributeApplier backgroundApplier = new AttributeApplier() { 37 40 public void apply(Realizable target, String namespaceURI, 41 String attributeName, String attributeValue) { 42 Color color = Decoder.decodeColor(attributeValue); 43 ((Highlighter) target.getObject()).setBackground(color); 44 } 45 }; 46 47 public static final AttributeApplier highlightColumnApplier = new AttributeApplier() { 48 public void apply(Realizable target, String namespaceURI, 49 String attributeName, String attributeValue) { 50 int columnIndex = TableColumnAttributes.getModelIndex(target, attributeValue); 51 if (columnIndex >= 0) { 52 ((ConditionalHighlighter) target.getObject()).setHighlightColumnIndex(columnIndex); 53 } 54 } 55 }; 56 57 66 public static final AttributeApplier evenRowBackgroundApplier = new AttributeApplier() { 67 70 public void apply(Realizable target, String namespaceURI, 71 String attributeName, String attributeValue) { 72 Color color = Decoder.decodeColor(attributeValue); 73 ((AlternateRowHighlighter) target.getObject()).setEvenRowBackground(color); 74 } 75 }; 76 77 public static final AttributeApplier foregroundApplier = new AttributeApplier() { 78 81 public void apply(Realizable target, String namespaceURI, 82 String attributeName, String attributeValue) { 83 Color color = Decoder.decodeColor(attributeValue); 84 ((Highlighter) target.getObject()).setForeground(color); 85 } 86 }; 87 88 public static final AttributeApplier maskApplier = new AttributeApplier() { 89 92 public void apply(Realizable target, String namespaceURI, 93 String attributeName, String attributeValue) { 94 if (attributeValue.length() > 0) { 95 ((ConditionalHighlighter) target.getObject()).setMask( 96 Integer.parseInt(attributeValue)); 97 } 98 } 99 }; 100 101 public static final AttributeApplier oddRowBackgroundApplier = new AttributeApplier() { 102 105 public void apply(Realizable target, String namespaceURI, 106 String attributeName, String attributeValue) { 107 Color color = Decoder.decodeColor(attributeValue); 108 ((AlternateRowHighlighter) target.getObject()).setOddRowBackground(color); 109 } 110 }; 111 112 public static final AttributeApplier selectedBackgroundApplier = new AttributeApplier() { 113 116 public void apply(Realizable target, String namespaceURI, 117 String attributeName, String attributeValue) { 118 Color color = Decoder.decodeColor(attributeValue); 119 ((Highlighter) target.getObject()).setSelectedBackground(color); 120 } 121 }; 122 123 public static final AttributeApplier selectedForegroundApplier = new AttributeApplier() { 124 127 public void apply(Realizable target, String namespaceURI, 128 String attributeName, String attributeValue) { 129 Color color = Decoder.decodeColor(attributeValue); 130 ((Highlighter) target.getObject()).setSelectedBackground(color); 131 } 132 }; 133 134 public static final AttributeApplier testColumnApplier = new AttributeApplier() { 135 public void apply(Realizable target, String namespaceURI, 136 String attributeName, String attributeValue) { 137 int columnIndex = TableColumnAttributes.getModelIndex(target, attributeValue); 138 if (columnIndex >= 0) { 139 ((ConditionalHighlighter) target.getObject()).setTestColumnIndex(columnIndex); 140 } 141 } 142 }; 143 144 155 } 156 | Popular Tags |