Changeset 6321
- Timestamp:
- 2003-12-19T14:49:04+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/GComboBox.java
r5789 r6321 50 50 extends JComboBox { 51 51 52 private boolean editable = true; 53 52 54 private Color background = null; 53 55 private Color foreground = null; 56 private Color editable_background = null; 57 private Color editable_foreground = null; 54 58 private Color selection_background = null; 55 59 private Color selection_foreground = null; … … 60 64 } 61 65 66 public GComboBox(boolean editable) { 67 super(); 68 this.editable = editable; 69 super.setEditable(editable); 70 init(); 71 } 72 62 73 public GComboBox(ArrayList data) { 63 74 super(data.toArray()); … … 65 76 } 66 77 78 public GComboBox(ArrayList data, boolean editable) { 79 super(data.toArray()); 80 this.editable = editable; 81 super.setEditable(editable); 82 init(); 83 } 84 67 85 public GComboBox(ComboBoxModel model) { 68 86 super(model); 87 init(); 88 } 89 90 public GComboBox(ComboBoxModel model, boolean editable) { 91 super(model); 92 this.editable = editable; 93 super.setEditable(editable); 69 94 init(); 70 95 } … … 81 106 } 82 107 108 public GComboBox(Object data[], boolean editable) { 109 super(data); 110 this.editable = editable; 111 super.setEditable(editable); 112 init(); 113 } 114 83 115 public GComboBox(Vector data) { 84 116 super(data); 117 init(); 118 } 119 120 public GComboBox(Vector data, boolean editable) { 121 super(data); 122 this.editable = editable; 123 super.setEditable(editable); 85 124 init(); 86 125 } … … 109 148 } 110 149 150 /** Overridden to do nothing. 151 * @param background 152 */ 153 public void setBackground(Color background) { 154 } 155 156 public void setBackgroundEditableColor(Color editable_background) { 157 this.editable_background = editable_background; 158 setEditor(new Editor()); 159 setRenderer(new Renderer()); 160 } 161 111 162 public void setBackgroundNonSelectionColor(Color background) { 112 163 this.background = background; … … 115 166 } 116 167 168 public void setBackgroundSelectionColor(Color selection_background) { 169 this.selection_background = selection_background; 170 setEditor(new Editor()); 171 setRenderer(new Renderer()); 172 } 173 174 public void setEditable(boolean editable) { 175 super.setEditable(editable); 176 this.editable = editable; 177 setEditor(new Editor()); 178 setRenderer(new Renderer()); 179 } 180 181 public void setTextEditableColor(Color editable_foreground) { 182 this.editable_foreground = editable_foreground; 183 setEditor(new Editor()); 184 setRenderer(new Renderer()); 185 } 186 117 187 public void setTextNonSelectionColor(Color foreground) { 118 188 this.foreground = foreground; 119 setEditor(new Editor());120 setRenderer(new Renderer());121 }122 123 public void setBackgroundSelectionColor(Color selection_background) {124 this.selection_background = selection_background;125 189 setEditor(new Editor()); 126 190 setRenderer(new Renderer()); … … 148 212 this.background = Gatherer.config.getColor("coloring.collection_tree_background", false); 149 213 this.foreground = Gatherer.config.getColor("coloring.collection_tree_foreground", false); 214 this.editable_background = Gatherer.config.getColor("coloring.editable_background", false); 215 this.editable_foreground = Gatherer.config.getColor("coloring.editable_foreground", false); 150 216 this.selection_background = Gatherer.config.getColor("coloring.collection_selection_background", false); 151 217 this.selection_foreground = Gatherer.config.getColor("coloring.collection_selection_foreground", false); 152 setEditor(new Editor()); 218 if(editable) { 219 this.setBackground(editable_background); 220 this.setForeground(editable_foreground); 221 } 222 else { 223 this.setBackground(background); 224 this.setForeground(foreground); 225 } 226 setBorder(BorderFactory.createLoweredBevelBorder()); 227 setEditor(new Editor()); 228 setOpaque(true); 153 229 setRenderer(new Renderer()); 154 230 } … … 158 234 implements ComboBoxEditor { 159 235 public Editor() { 160 setBackground(background); 161 setForeground(foreground); 162 setSelectionColor(selection_background); 163 setSelectedTextColor(selection_foreground); 236 setBackground(editable_background); 237 setForeground(editable_foreground); 238 setOpaque(true); 239 if(editable) { 240 setSelectionColor(selection_background); 241 setSelectedTextColor(selection_foreground); 242 } 164 243 } 165 244 … … 221 300 implements ListCellRenderer { 222 301 public Renderer() { 302 super(""); 303 this.setBackground(background); 304 this.setForeground(foreground); 305 this.setOpaque(true); 223 306 } 224 307 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 225 308 if(value != null) { 226 setText(value.toString());309 this.setText(value.toString()); 227 310 } 228 311 else { 229 setText(""); 230 } 231 setBackground(isSelected ? selection_background : background); 232 setForeground(isSelected ? selection_foreground : foreground); 233 setOpaque(true); 312 this.setText(""); 313 } 314 if(editable) { 315 this.setBackground(editable_background); 316 this.setForeground(editable_foreground); 317 } 318 else { 319 this.setBackground(background); 320 this.setForeground(foreground); 321 } 234 322 return this; 235 323 } -
trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java
r6087 r6321 62 62 public class OptionsPane 63 63 extends JPanel 64 implements AppendLineOnlyFileDocumentOwner {64 implements AppendLineOnlyFileDocumentOwner, MouseListener { 65 65 66 66 static final public char SUCCESSFUL = 's'; … … 72 72 public JTextArea log_textarea = null; 73 73 74 private ArrayList current_controls; 75 74 76 /** The <strong>BuildOptions</strong> data object contains all the option settings we wish to persist between Gatherer sessions (and thus is stored in <strong>Collection</strong>). */ 75 77 private BuildOptions build_options = null; 76 78 77 79 private FileEntry file_entry = null; 80 78 81 /** the log pane - we only create it once now, not each time */ 79 82 private JPanel log_pane = null; … … 93 96 public OptionsPane(BuildOptions build_options) { 94 97 this.build_options = build_options; 98 this.current_controls = new ArrayList(); 95 99 this.writing_documents = new Vector(); 96 100 … … 104 108 */ 105 109 public JPanel buildBuild() { 110 current_controls.clear(); 106 111 JPanel pane = new JPanel(); 107 112 pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); … … 117 122 ArgumentControl argument_control = new ArgumentControl(BUILD, argument, enabled, value); 118 123 pane.add(argument_control); 119 } 124 current_controls.add(argument_control); 125 } 126 pane.addMouseListener(this); 120 127 return pane; 121 128 } … … 124 131 */ 125 132 public JPanel buildImport() { 133 current_controls.clear(); 126 134 JPanel pane = new JPanel(); 127 135 pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); … … 137 145 ArgumentControl argument_control = new ArgumentControl(IMPORT, argument, enabled, value); 138 146 pane.add(argument_control); 139 } 147 current_controls.add(argument_control); 148 } 149 pane.addMouseListener(this); 140 150 return pane; 141 151 } … … 153 163 File children[] = log_directory.listFiles(); 154 164 for(int i = 0; children != null && i < children.length; i++) { 155 if(children[i].getName().startsWith("build_log") && children[i].getName().endsWith(".txt") ) { 156 FileEntry entry = new FileEntry(children[i].getName(), children[i].getAbsolutePath()); 157 // We are about to insert it. But where. 158 boolean found = false; 159 for(int j = 0; !found && j < contents.size(); j++) { 160 FileEntry sibling = (FileEntry) contents.getElementAt(j); 161 int order = entry.compareTo(sibling); 162 if(order > 0) { 163 contents.insertElementAt(entry, j); 164 found = true; 165 String filename = children[i].getName(); 166 if(filename.startsWith("build_log.") && filename.endsWith(".txt") ) { 167 String datestamp = filename.substring(filename.indexOf(".") + 1, filename.lastIndexOf(".")).toLowerCase(); 168 if(datestamp.indexOf("s") == -1 && datestamp.indexOf("u") == -1 && datestamp.indexOf("c") == -1 && datestamp.indexOf("x") == -1) { 169 FileEntry entry = new FileEntry(children[i].getName(), children[i].getAbsolutePath()); 170 // We are about to insert it. But where. 171 boolean found = false; 172 for(int j = 0; !found && j < contents.size(); j++) { 173 FileEntry sibling = (FileEntry) contents.getElementAt(j); 174 int order = entry.compareTo(sibling); 175 if(order > 0) { 176 contents.insertElementAt(entry, j); 177 found = true; 178 } 165 179 } 166 }167 if(!found) {168 contents.addElement(entry);180 if(!found) { 181 contents.addElement(entry); 182 } 169 183 } 170 184 } … … 250 264 } 251 265 266 /** Implementation side-effect 267 * @param e a MouseEvent 268 */ 269 public void mouseClicked(MouseEvent e) {} 270 271 /** Implementation side-effect 272 * @param e a MouseEvent 273 */ 274 public void mouseEntered(MouseEvent e) {} 275 276 /** Implemented to ensure that, by the time the mouse pointer leaves the current build options screen, ang changes to the value the JSpinners have been commited 277 * @param e a MouseEvent 278 */ 279 public void mouseExited(MouseEvent e) { 280 // Loop through the controls, and if the current control is a JSpinner, commit its current editing 281 for(int i = 0; i < current_controls.size(); i++) { 282 ArgumentControl control = (ArgumentControl) current_controls.get(i); 283 JComponent value_control = control.getValueControl(); 284 if(value_control instanceof JSpinner) { 285 try { 286 ((JSpinner)value_control).commitEdit(); 287 } 288 catch(Exception exception) { 289 Gatherer.println("Exception in OptionsPane.mouseExited() - unexpected"); 290 Gatherer.printStackTrace(exception); 291 } 292 } 293 value_control = null; 294 control = null; 295 } 296 } 297 298 /** Implementation side-effect 299 * @param e a MouseEvent 300 */ 301 public void mousePressed(MouseEvent e) {} 302 303 /** Implementation side-effect 304 * @param e a MouseEvent 305 */ 306 public void mouseReleased(MouseEvent e) {} 307 252 308 private class ArgumentControl 253 309 extends JPanel { … … 389 445 add(enabled, BorderLayout.WEST); 390 446 } 447 } 448 449 /** Retrieve the control used for storing values. 450 * @return JComponent 451 */ 452 public JComponent getValueControl() { 453 return value_control; 391 454 } 392 455
Note:
See TracChangeset
for help on using the changeset viewer.