Changeset 8169
- Timestamp:
- 2004-09-28T16:04:55+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/GComboBox.java
r8003 r8169 50 50 extends JComboBox { 51 51 52 private boolean editable = true;53 54 52 private Color background = null; 55 53 private Color foreground = null; … … 66 64 public GComboBox(boolean editable) { 67 65 super(); 68 this.editable = editable; 69 super.setEditable(editable); 66 setEditable(editable); 70 67 init(); 71 68 } … … 78 75 public GComboBox(ArrayList data, boolean editable) { 79 76 super(data.toArray()); 80 this.editable = editable; 81 super.setEditable(editable); 77 setEditable(editable); 82 78 init(); 83 79 } … … 90 86 public GComboBox(ComboBoxModel model, boolean editable) { 91 87 super(model); 92 this.editable = editable; 93 super.setEditable(editable); 88 setEditable(editable); 94 89 init(); 95 90 } … … 99 94 super(); 100 95 init(); 101 96 } 102 97 103 98 public GComboBox(Object data[]) { … … 108 103 public GComboBox(Object data[], boolean editable) { 109 104 super(data); 110 this.editable = editable; 111 super.setEditable(editable); 105 setEditable(editable); 112 106 init(); 113 107 } … … 120 114 public GComboBox(Vector data, boolean editable) { 121 115 super(data); 122 this.editable = editable; 123 super.setEditable(editable); 116 setEditable(editable); 124 117 init(); 125 118 } 126 119 127 120 public int add(Object object) { 128 if (dataModel instanceof Model) {129 return ((Model) dataModel).add(object);121 if (dataModel instanceof Model) { 122 return ((Model) dataModel).add(object); 130 123 } 131 124 else { … … 139 132 140 133 public void clear() { 141 if(dataModel instanceof Model) { 142 ((Model)dataModel).clear(); 143 } 144 } 145 146 /** Overridden to do nothing. 147 * @param background 148 */ 149 public void setBackground(Color background) { 150 } 151 152 // public void setBackgroundEditableColor(Color editable_background) { 153 // this.editable_background = editable_background; 154 // setEditor(new Editor()); 155 // setRenderer(new Renderer()); 156 // } 157 158 public void setBackgroundNonSelectionColor(Color background) { 159 this.background = background; 160 setEditor(new Editor()); 161 setRenderer(new Renderer()); 162 } 163 164 public void setBackgroundSelectionColor(Color selection_background) { 165 this.selection_background = selection_background; 166 setEditor(new Editor()); 167 setRenderer(new Renderer()); 168 } 169 170 public void setEditable(boolean editable) { 171 super.setEditable(editable); 172 this.editable = editable; 173 if(editable) { 174 this.setBackground(editable_background); 175 this.setForeground(editable_foreground); 176 } 177 else { 178 this.setBackground(background); 179 this.setForeground(foreground); 180 } 181 setEditor(new Editor()); 182 setRenderer(new Renderer()); 183 updateUI(); 184 } 185 186 // public void setTextEditableColor(Color editable_foreground) { 187 // this.editable_foreground = editable_foreground; 188 // setEditor(new Editor()); 189 // setRenderer(new Renderer()); 190 // } 191 192 public void setTextNonSelectionColor(Color foreground) { 193 this.foreground = foreground; 194 setEditor(new Editor()); 195 setRenderer(new Renderer()); 196 } 197 198 public void setTextSelectionColor(Color selection_foreground) { 199 this.selection_foreground = selection_foreground; 200 setEditor(new Editor()); 201 setRenderer(new Renderer()); 134 if (dataModel instanceof Model) { 135 ((Model) dataModel).clear(); 136 } 202 137 } 203 138 … … 207 142 setModel(model); 208 143 setOpaque(true); 144 209 145 // Restore any data given into our model 210 146 for(int i = 0; i < old_model.getSize(); i++) { 211 147 model.add(old_model.getElementAt(i)); 212 148 } 149 213 150 // Change component 214 151 UI ui = new UI(); 215 152 setUI(ui); 216 153 ui.setButtonBackground(); 154 217 155 // Initialization 218 156 this.background = Gatherer.config.getColor("coloring.collection_tree_background", false); … … 222 160 this.selection_background = Gatherer.config.getColor("coloring.collection_selection_background", false); 223 161 this.selection_foreground = Gatherer.config.getColor("coloring.collection_selection_foreground", false); 224 if (editable) {162 if (isEditable()) { 225 163 this.setBackground(editable_background); 226 164 this.setForeground(editable_foreground); … … 231 169 } 232 170 setBorder(BorderFactory.createLoweredBevelBorder()); 171 setRenderer(new Renderer()); 172 } 173 174 /** Overridden to do nothing. 175 * @param background 176 */ 177 public void setBackground(Color background) { 178 } 179 180 public void setBackgroundEditableColor(Color editable_background) { 181 this.editable_background = editable_background; 182 } 183 184 public void setBackgroundNonSelectionColor(Color background) { 185 this.background = background; 186 } 187 188 public void setBackgroundSelectionColor(Color selection_background) { 189 this.selection_background = selection_background; 190 } 191 192 public void setEditable(boolean editable) { 233 193 setEditor(new Editor()); 234 setRenderer(new Renderer()); 235 } 194 super.setEditable(editable); 195 if (isEditable()) { 196 this.setBackground(editable_background); 197 this.setForeground(editable_foreground); 198 } 199 else { 200 this.setBackground(background); 201 this.setForeground(foreground); 202 } 203 } 204 205 public void setTextEditableColor(Color editable_foreground) { 206 this.editable_foreground = editable_foreground; 207 } 208 209 public void setTextNonSelectionColor(Color foreground) { 210 this.foreground = foreground; 211 } 212 213 public void setTextSelectionColor(Color selection_foreground) { 214 this.selection_foreground = selection_foreground; 215 } 216 236 217 237 218 private class Editor … … 240 221 public Editor() { 241 222 setOpaque(true); 242 if (editable) {223 if (isEditable()) { 243 224 setBackground(editable_background); 244 225 setForeground(editable_foreground); … … 323 304 this.setForeground(selection_foreground); 324 305 } 325 else if (editable) {306 else if (isEditable()) { 326 307 this.setBackground(editable_background); 327 308 this.setForeground(editable_foreground);
Note:
See TracChangeset
for help on using the changeset viewer.