Revision 17812

View differences:

trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/filterPanel/AbstractFilterQueryJPanel.java
34 34

  
35 35
import org.gvsig.gui.beans.Messages;
36 36
import org.gvsig.gui.beans.controls.MultiLineToolTip;
37
import org.gvsig.gui.beans.editabletextcomponent.JEditableTextArea;
37 38
import org.gvsig.gui.beans.filterPanel.filterButtons.FilterButtonsJPanel;
38
import org.gvsig.gui.beans.jEditableTextComponent.JEditableTextArea;
39 39
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
40 40

  
41 41
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/editabletextcomponent/EditableTextDecorator.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.gui.beans.editabletextcomponent;
42

  
43
import java.awt.event.KeyAdapter;
44
import java.awt.event.KeyEvent;
45
import java.awt.event.KeyListener;
46
import java.awt.event.MouseAdapter;
47
import java.awt.event.MouseEvent;
48
import java.beans.PropertyChangeEvent;
49
import java.beans.PropertyChangeListener;
50

  
51
import javax.swing.ComboBoxEditor;
52
import javax.swing.event.UndoableEditEvent;
53
import javax.swing.event.UndoableEditListener;
54
import javax.swing.text.BadLocationException;
55
import javax.swing.text.JTextComponent;
56
import javax.swing.text.PlainDocument;
57
import javax.swing.undo.CannotRedoException;
58
import javax.swing.undo.CannotUndoException;
59
import javax.swing.undo.UndoManager;
60

  
61
import org.gvsig.gui.beans.editionpopupmenu.JOptionsEditionByMousePopupMenu;
62

  
63
/**
64
 * <p>Extra functionality that allows a {@link JTextComponent JTextComponent} having graphical edition options,
65
 * which allows user to select any: <i>COPY, CUT, PASTE, SELECT ALL, REMOVE, UNDO, REDO</i> in a popup menu.</p>
66
 * 
67
 * <p>All options will be about the edtion of the text in the component.</p>
68
 *  
69
 * <p><b><i>How select an edition option using the mouse:</i></b> press the right button of the mouse on the text area, and a popup with the options will be displayed. Select and option.<br>
70
 * <b><i>How select an edition option using the keyboard:</i></b> 
71
 * <ul>
72
 *  <li><b>COPY:</b> </li> CTRL + C. Copies from the text field to the clipboard.
73
 *  <li><b>CUT:</b> </li> CTRL + X. Cuts from the text field to the clipboad.
74
 *  <li><b>PASTE:</b> </li> CTRL + V. Copies from the clipboard to the text field.
75
 *  <li><b>REMOVE:</b> </li> SUPR (in spanish keyboard). Removes the selected text.
76
 *  <li><b>SELECT ALL:</b> </li> CTRL + A. Selects all the text.
77
 *  <li><b>UNDO:</b> </li> CTRL + Z. Undoes.
78
 *  <li><b>REDO:</b> </li> SHIFT + CTRL + Z. Redoes.
79
 * </ul></p>
80
 * 
81
 * <p>This component by default stores 10 undo/redo actions. This value can be modified.</p>
82
 * 
83
 * @version 03/01/2008
84
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
85
 */
86
public class EditableTextDecorator {
87
	// CONSTANTS
88
	public static final int DEFAULT_UNDO_REDO_LIMIT_ACTIONS = 10;
89
	// END CONSTANTS
90

  
91
	// A POPUPMENU FOR EDITION OPTIONS
92
	private JOptionsEditionByMousePopupMenu optionsEditionByMouse;
93
    // END A POPUPMENU FOR EDITION OPTIONS
94
	
95
	// UNDO-REDO
96
	private UndoManager undoManager;
97
	private int undoRedoLimitActions;
98
	// END UNDO-REDO
99
	
100
	// LISTENERS
101
	private KeyListener editorKeyListener;
102
	private MouseAdapter editorMouseListener;
103
	private PropertyChangeListener editionMenuListener;
104
	// END LISTENERS
105
	
106
	// REFERENCE TO THE JTEXTCOMPONENT
107
	private JTextComponent jTextComponent;
108
	// END REFERENCE TO THE JTEXTCOMPONENT
109
	
110
	/**
111
	 * Default constructor
112
	 */
113
	public EditableTextDecorator(JTextComponent jTextComponent) {
114
		super();
115

  
116
		// Reference to the JTextComponent
117
		this.jTextComponent = jTextComponent;
118
		
119
		initialize();
120
		
121
		// Other configuration tasks
122
		this.createDefaultListeners();
123
		this.configure();
124
	}
125
	
126
	/**
127
	 * This method sets the start values of inner attributes and creates the necessary inner objects
128
	 */
129
	private void initialize() {
130
        // Allows user to edit
131
		jTextComponent.setEditable(true);
132
		
133
		// Text options edition popupmenu initialization
134
		optionsEditionByMouse = new JOptionsEditionByMousePopupMenu();
135
		
136
		// Undo-Redo initialization
137
		undoManager = new UndoManager();
138
		undoRedoLimitActions = DEFAULT_UNDO_REDO_LIMIT_ACTIONS; // By default is 1
139
		undoManager.setLimit(undoRedoLimitActions);
140
	}
141
	
142
	/**
143
	 * Creation of default listeners that will use the component
144
	 */
145
	private void createDefaultListeners() {
146
		// Defines a listener for the PopupMenu of text edition options: when a change is produced in that component, it fires an event
147
		//   and this listener captures it
148
		defineEditionMenuPropertyChangeListener();
149

  
150
        // Defines a key listener for the editor of this component
151
        defineEditorKeyListener();
152

  
153
        // Defines a mouse listener for the editor of this component
154
        defineEditorMouseListener();
155
	}
156
	
157
	/**
158
	 * Defines a listener for the PopupMenu of text edition options: when a change is produced in that component, it fires an event
159
	 *    and this listener captures and treats it
160
	 */
161
	private void defineEditionMenuPropertyChangeListener() {
162
		editionMenuListener = new PropertyChangeListener() {
163
			/*
164
			 * (non-Javadoc)
165
			 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
166
			 */
167
			public void propertyChange(PropertyChangeEvent arg0) {
168
				if (arg0.getPropertyName().equals(JOptionsEditionByMousePopupMenu.SELECTEDOPTION)) {
169
	            						
170
			          switch(Integer.parseInt(arg0.getNewValue().toString()))
171
			          {
172
				          case JOptionsEditionByMousePopupMenu.UNDO:
173
				        	  undoOperationLogic();
174
				        	  break;
175
				          case JOptionsEditionByMousePopupMenu.REDO:
176
				        	  redoOperationLogic();
177
				        	  break;
178
				          case JOptionsEditionByMousePopupMenu.CUT:
179
				        	  jTextComponent.cut();
180
				        	  break;
181
				          case JOptionsEditionByMousePopupMenu.COPY:
182
				        	  jTextComponent.copy();
183
				        	  break;
184
				          case JOptionsEditionByMousePopupMenu.PASTE:
185
				        	  jTextComponent.paste();
186
				        	  break;
187
				          case JOptionsEditionByMousePopupMenu.DELETE:
188
				        	  deleteTextLogic();
189
				        	  break;
190
				          case JOptionsEditionByMousePopupMenu.SELECT_ALL:
191
				        	  jTextComponent.selectAll();
192
				        	  break;
193
				          default: // do anything
194
			          }
195
				}
196
/*
197
				else
198
				{
199
					if (arg0.getPropertyName().equals(JOptionsEditionByMousePopupMenu.VISIBILITYCHANGED))
200
					{
201
						// First True, after False (when false -> optionsEditorWasVisible = true)
202
						if (!optionsEditionByMouse.isVisible())
203
							optionsEditorWasVisible = true;
204
						else
205
							optionsEditorWasVisible = false;
206

  
207
					}
208
				}
209
*/
210
			}			
211
		};
212
	}
213

  
214
	/**
215
	 * Defines a key listener for the editor of the text component.
216
	 */
217
	private void defineEditorKeyListener() {
218
		editorKeyListener = new KeyAdapter() {
219
			/*
220
			 * (non-Javadoc)
221
			 * @see java.awt.event.KeyAdapter#keyPressed(java.awt.event.KeyEvent)
222
			 */
223
			public void keyPressed(KeyEvent ke)  // Executed on the Start view state or Search view state
224
			{
225
				// COPY, CUT, PASTE, SELECT ALL, UNDO AND REDO WITH THE KEYBOARD (Combination of keys; REMOVE is implemented after: KV_DELETE (supr spanish key))
226
				if (ke.isControlDown())
227
				{
228
					// COPY
229
				    if (ke.getKeyCode() == KeyEvent.VK_C) {
230
				    	jTextComponent.copy();
231
				    	ke.consume();
232
				    	return;
233
				    }
234
				    
235
				    // CUT
236
				    if (ke.getKeyCode() == KeyEvent.VK_X) {
237
				    	jTextComponent.cut();
238
				    	ke.consume();
239
				    	return;
240
				    }
241
				    
242
				    // PASTE
243
				    if (ke.getKeyCode() == KeyEvent.VK_V) {
244
				    	jTextComponent.paste();
245
				    	ke.consume();
246
				    	return;
247
				    }
248
				    
249
				    // SELECT ALL
250
				    if (ke.getKeyCode() == KeyEvent.VK_A) {
251
				    	jTextComponent.selectAll();
252
				    	ke.consume();
253
				    	return;
254
				    }
255

  
256
				    // UNDO OR REDO
257
				    if (ke.getKeyCode() == KeyEvent.VK_Z) {
258
				    	if (ke.isShiftDown()) // REDO
259
				    		redoOperationLogic();					    		
260
				    	else //UNDO
261
				    		undoOperationLogic();
262
				    	
263
				    	ke.consume();
264
				    	return;
265
			 	    }
266
				}
267
				
268
				// According the key pressed, do some actions or others
269
				switch (ke.getKeyCode())
270
				{
271
					case KeyEvent.VK_DELETE : // 'supr' key in spanish keyboard
272
						deleteTextLogic();
273
						ke.consume();
274
					break;
275
				}
276
			}
277
		};
278
	}
279

  
280
	/**
281
	 * Defines a mouse listener for the editor of the text component.
282
	 */
283
	private void defineEditorMouseListener() {
284
		editorMouseListener = new MouseAdapter() {
285
			/*
286
			 * (non-Javadoc)
287
			 * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
288
			 */
289
			public void mouseClicked(MouseEvent e) {
290
	
291
				if (e.getButton() == MouseEvent.BUTTON3) {	            	
292
	            	// By default disable all options
293
	            	optionsEditionByMouse.setEnabledAllOptions(false);
294
	            	
295
	            	// Enable the "Undo" option if there is any previous state to restore
296
	            	if (undoManager.canUndo())
297
	            		optionsEditionByMouse.setEnabledUndoOption(true);
298
	            	
299
	            	// Enable the "Redo" option if there is any later state to restore
300
	            	if (undoManager.canRedo())
301
	            		optionsEditionByMouse.setEnabledRedoOption(true);
302
	            	
303
	            	// Enable the "Copy", "Cut" and "Delete" options if there is text selected
304
	            	if (jTextComponent.getCaretPosition() != jTextComponent.getCaret().getMark())
305
	            	{
306
	            		optionsEditionByMouse.setEnabledCopyOption(true);
307
	            		optionsEditionByMouse.setEnabledCutOption(true);
308
	            		optionsEditionByMouse.setEnabledDeleteOption(true);
309
	            	}
310
	            	
311
	            	// Enable the "Paste" option if there is text on the system's clipboard
312
	            	if ( jTextComponent.getToolkit().getSystemClipboard().getContents(this).toString().length() > 0 )
313
	            		optionsEditionByMouse.setEnabledPasteOption(true);//
314
	            	
315
	            	// Enable the "Select-All" option (by default it's always enabled)
316
	            	optionsEditionByMouse.setEnabledSelectAllOption(true);
317
	            	
318
					optionsEditionByMouse.setLocation((int)jTextComponent.getLocationOnScreen().getX() + e.getX(), (int)jTextComponent.getLocationOnScreen().getY() + e.getY());
319
	            	optionsEditionByMouse.setInvoker(jTextComponent);
320
	            	optionsEditionByMouse.setVisible(true);
321
	            }
322
	        }
323
		};
324
	}
325
	
326
	/**
327
	 * Configures the component and some of its parts
328
	 */
329
	private void configure() {
330
		// Configures the document of the editor of this component
331
		PlainDocument document = this.configureDocument();
332

  
333
		// Configures the editor (ComboBoxEditor) of this component
334
		configureEditor(document);
335
		
336
		// Configures the text-edition-options popupmenu
337
		configureOptionsEditionByMouse();
338
	}
339
	
340

  
341
	/**
342
	 * Configures the document of the editor of the text component
343
	 */
344
	private PlainDocument configureDocument() {
345
		// Creates the document of the editor of this component
346
		PlainDocument document = new PlainDocument();
347
        
348
		// Configures the document
349
		configureUndoManager(document);
350
		
351
		return document;
352
	}
353
	
354
	/**
355
	 * Configures the editor {@link ComboBoxEditor ComboBoxEditor} of the text component.
356
	 * 
357
	 * @param document the document to display/edit
358
	 */
359
	private void configureEditor(PlainDocument document) {
360
        if (jTextComponent != null) {
361
           	// Removes some prevous listeners and adds some new others:     
362
        	
363
        	// Adds the new Key Listener (tries to remove it if it existed before)
364
        	jTextComponent.removeKeyListener(this.editorKeyListener);
365
        	jTextComponent.addKeyListener(this.editorKeyListener);
366
        	
367
           	// Adds the new Mouse Listener (tries to remove it if it existed before)
368
        	jTextComponent.removeMouseListener(this.editorMouseListener);
369
        	jTextComponent.addMouseListener(this.editorMouseListener);
370
        	
371
        	// Adds the new document (tries to remove it if it existed before)
372
        	jTextComponent.setDocument(document);
373
        }
374
	}
375

  
376
	/** 
377
	 * Configures the text-edition-options popup menu.
378
	 */
379
	private void configureOptionsEditionByMouse() {
380
		this.optionsEditionByMouse.addPropertyChangeListener(editionMenuListener);
381
	}
382
	
383
	/**
384
	 * Configures the UndoManager for Undo-Redo operations.
385
	 */
386
	private void configureUndoManager(PlainDocument document) {
387
		final UndoManager undo_Manager = undoManager; 
388
		
389
        // Listen for undo and redo events
390
        document.addUndoableEditListener(new UndoableEditListener() {
391
        	/*
392
        	 * (non-Javadoc)
393
        	 * @see javax.swing.event.UndoableEditListener#undoableEditHappened(javax.swing.event.UndoableEditEvent)
394
        	 */
395
            public void undoableEditHappened(UndoableEditEvent evt) {
396
				undo_Manager.addEdit(evt.getEdit());
397
            }
398
        });
399
	}
400
	
401
	/**
402
	 * This method has the logic for a "undo" operation.
403
	 */
404
	private void undoOperationLogic() {
405
		try {
406
            if (undoManager.canUndo()) {
407
            	undoManager.undo();
408
            }
409
		} catch (CannotUndoException e) {
410
        	e.printStackTrace();
411
        }
412
	}
413
	
414
	/**
415
	 * This method has the logic for a "redo" operation.
416
	 */
417
	private void redoOperationLogic() {
418
        try {
419
            if (undoManager.canRedo()) {
420
         	   	undoManager.redo();
421
            }
422
	    } catch (CannotRedoException e) {
423
	    	e.printStackTrace();
424
	    }
425
	}
426
	
427
    ////// OTHER METHODS //////
428
	
429
	/**
430
     * Sets the limit of actions that can hold the UndoManager of this component.
431
     * 
432
     * @param limit sets the limit of actions that can hold
433
     */
434
	public void setUndoRedoLimitActions(int limit) {
435
    	this.undoRedoLimitActions = limit;
436
    	undoManager.setLimit(undoRedoLimitActions);
437
    }
438
    
439
	/**
440
     * Gets the limit of actions that can hold the UndoManager.
441
     * 
442
     * @return int limit of actions that can hold
443
     */
444
	public int getUndoRedoLimitActions() {
445
    	return this.undoRedoLimitActions;
446
    }
447
     
448
	/**
449
	 * This method is invoked when some text has to be removed: With the 'Delete' option of the text-edition-popupmenu or with the 'delete' ('supr'
450
	 *    in spanish keyboard) key.
451
	 */
452
	private void deleteTextLogic() {
453
		//		 Get the new text:		
454
	  	try {
455
	  		PlainDocument document = (PlainDocument)jTextComponent.getDocument();
456
	  		int caretPosition = jTextComponent.getCaretPosition();
457
	  		int markPosition = jTextComponent.getCaret().getMark();
458
	  		  
459
	  		int min_index = Math.min(caretPosition, markPosition);
460
	  		int length = Math.abs(caretPosition - markPosition);
461
	  		  
462
	  		document.remove(min_index, length);
463
	  	} catch (BadLocationException e) {
464
	  		e.printStackTrace();
465
	  	}
466
	}
467
    ////// END OTHER METHODS //////
468
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/editabletextcomponent/JEditableTextArea.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.gui.beans.editabletextcomponent;
21

  
22
import javax.swing.JTextArea;
23
import javax.swing.text.Document;
24

  
25
/**
26
 * <p>Text area with options to edit its text easily.</p>
27
 * 
28
 * @see JTextArea
29
 * 
30
 * @version 03/01/2008
31
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
32
 */
33
public class JEditableTextArea extends JTextArea implements IEditableText {
34
	private static final long serialVersionUID = -5781124255103773189L;
35

  
36
	// REFERENCE TO THE TEXT EDITOR DECORATOR
37
	private EditableTextDecorator editableTextDecorator;
38
	// END REFERENCE TO THE TEXT EDITOR DECORATOR
39
	
40
	/**
41
	 * @see JEditableTextArea#JEditableTextArea()
42
	 */
43
	public JEditableTextArea() {
44
		super();
45
		
46
		initialize();
47
	}
48

  
49
	/**
50
	 * @see JEditableTextArea#JEditableTextArea(Document, String, int, int)
51
	 */
52
	public JEditableTextArea(Document doc, String text, int rows, int columns) {
53
		super(doc, text, rows, columns);
54
		
55
		initialize();
56
	}
57

  
58
	/**
59
	 * @see JEditableTextArea#JEditableTextArea(Document)
60
	 */
61
	public JEditableTextArea(Document doc) {
62
		super(doc);
63
		
64
		initialize();
65
	}
66

  
67
	/**
68
	 * @see JEditableTextArea#JEditableTextArea(int, int)
69
	 */
70
	public JEditableTextArea(int rows, int columns) {
71
		super(rows, columns);
72
		
73
		initialize();
74
	}
75

  
76
	/**
77
	 * @see JEditableTextArea#JEditableTextArea(String, int, int)
78
	 */
79
	public JEditableTextArea(String text, int rows, int columns) {
80
		super(text, rows, columns);
81
		
82
		initialize();
83
	}
84

  
85
	/**
86
	 * @see JEditableTextArea#JEditableTextArea(String)
87
	 */
88
	public JEditableTextArea(String text) {
89
		super(text);
90
		
91
		initialize();
92
	}
93

  
94
	/**
95
	 * <p>Fits this component to be ready to be used.</p>
96
	 */
97
	protected void initialize() {
98
		editableTextDecorator = new EditableTextDecorator(this);
99
	}
100

  
101
	/*
102
	 * (non-Javadoc)
103
	 * @see org.gvsig.gui.beans.editabletextcomponent.IEditableText#getUndoRedoLimitActions()
104
	 */
105
	public int getUndoRedoLimitActions() {
106
		return editableTextDecorator.getUndoRedoLimitActions();
107
	}
108

  
109
	/*
110
	 * (non-Javadoc)
111
	 * @see org.gvsig.gui.beans.editabletextcomponent.IEditableText#setUndoRedoLimitActions(int)
112
	 */
113
	public void setUndoRedoLimitActions(int limit) {
114
		editableTextDecorator.setUndoRedoLimitActions(limit);
115
	}
116
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/editabletextcomponent/IEditableText.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19

  
20
package org.gvsig.gui.beans.editabletextcomponent;
21

  
22
import javax.swing.text.JTextComponent;
23

  
24
/**
25
 * <p>All graphical components which inherit from {@link JTextComponent JTextComponent}
26
 *  can enhance their functionality with graphical edition options support implementing
27
 *  this interface.</p>
28
 * 
29
 * @version 03/01/2008
30
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
31
 */
32
public interface IEditableText {
33
	/**
34
	 * @see EditableTextDecorator#setUndoRedoLimitActions(int)
35
	 */
36
	public void setUndoRedoLimitActions(int limit);
37

  
38
	/**
39
	 * @see EditableTextDecorator#getUndoRedoLimitActions()
40
	 */
41
	public int getUndoRedoLimitActions();
42
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/editabletextcomponent/JEditableTextField.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.gui.beans.editabletextcomponent;
42

  
43
import javax.swing.JTextField;
44
import javax.swing.text.Document;
45

  
46
/**
47
 * <p>Text field with options to edit its text easily.</p>
48
 * 
49
 * @see JTextField
50
 * 
51
 * @version 03/01/2008
52
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
53
 */
54
public class JEditableTextField extends JTextField implements IEditableText {
55
	private static final long serialVersionUID = 8354404390274654997L;
56

  
57
	// REFERENCE TO THE TEXT EDITOR DECORATOR
58
	private EditableTextDecorator editableTextDecorator;
59
	// END REFERENCE TO THE TEXT EDITOR DECORATOR
60

  
61
	/**
62
	 * @see JTextField#JTextField()
63
	 */
64
	public JEditableTextField() {
65
		super();
66
		
67
		initialize();
68
	}
69

  
70
	/**
71
	 * @see JTextField#JTextField(Document, String, int)
72
	 */
73
	public JEditableTextField(Document doc, String text, int columns) {
74
		super(doc, text, columns);
75
		
76
		initialize();
77
	}
78

  
79
	/**
80
	 * @see JTextField#JTextField(int)
81
	 */
82
	public JEditableTextField(int columns) {
83
		super(columns);
84
		
85
		initialize();
86
	}
87

  
88
	/**
89
	 * @see JTextField#JTextField(String, int)
90
	 */
91
	public JEditableTextField(String text, int columns) {
92
		super(text, columns);
93
		
94
		initialize();
95
	}
96

  
97
	/**
98
	 * @see JTextField#JTextField(String)
99
	 */
100
	public JEditableTextField(String text) {
101
		super(text);
102
		
103
		initialize();
104
	}
105

  
106
	/**
107
	 * <p>Fits this component to be ready to be used.</p>
108
	 */
109
	protected void initialize() {
110
		editableTextDecorator = new EditableTextDecorator(this);
111
	}
112

  
113
	/*
114
	 * (non-Javadoc)
115
	 * @see org.gvsig.gui.beans.editabletextcomponent.IEditableText#getUndoRedoLimitActions()
116
	 */
117
	public int getUndoRedoLimitActions() {
118
		return editableTextDecorator.getUndoRedoLimitActions();
119
	}
120

  
121
	/*
122
	 * (non-Javadoc)
123
	 * @see org.gvsig.gui.beans.editabletextcomponent.IEditableText#setUndoRedoLimitActions(int)
124
	 */
125
	public void setUndoRedoLimitActions(int limit) {
126
		editableTextDecorator.setUndoRedoLimitActions(limit);
127
	}
128
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/editionpopupmenu/JOptionsEditionByMousePopupMenu.java
1
package org.gvsig.gui.beans.editionpopupmenu;
2

  
3
import java.awt.event.ActionEvent;
4
import java.awt.event.ActionListener;
5
import java.beans.PropertyChangeListener;
6
import java.beans.PropertyChangeSupport;
7
import java.io.Serializable;
8
import java.util.HashMap;
9

  
10
import javax.swing.ImageIcon;
11
import javax.swing.JMenuItem;
12
import javax.swing.JPopupMenu;
13
import javax.swing.border.BevelBorder;
14

  
15
import org.gvsig.gui.beans.Messages;
16

  
17
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
18
*
19
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
20
*
21
* This program is free software; you can redistribute it and/or
22
* modify it under the terms of the GNU General Public License
23
* as published by the Free Software Foundation; either version 2
24
* of the License, or (at your option) any later version.
25
*
26
* This program is distributed in the hope that it will be useful,
27
* but WITHOUT ANY WARRANTY; without even the implied warranty of
28
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
* GNU General Public License for more details.
30
*
31
* You should have received a copy of the GNU General Public License
32
* along with this program; if not, write to the Free Software
33
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
34
*
35
* For more information, contact:
36
*
37
*  Generalitat Valenciana
38
*   Conselleria d'Infraestructures i Transport
39
*   Av. Blasco Ib??ez, 50
40
*   46010 VALENCIA
41
*   SPAIN
42
*
43
*      +34 963862235
44
*   gvsig@gva.es
45
*      www.gvsig.gva.es
46
*
47
*    or
48
*
49
*   IVER T.I. S.A
50
*   Salamanca 50
51
*   46005 Valencia
52
*   Spain
53
*
54
*   +34 963163400
55
*   dac@iver.es
56
*/
57

  
58

  
59
/**
60
 * <p>This class is a JPopupMenu that can be used with another component.</p>
61
 * <p>The items showed in this menu are for editing: UNDO, REDO, CUT, COPY, PASTE, DELETE and SELECT ALL.</p>
62
 * <p>When the user clicks on a item, this Component fires a property change event that its value allows identify the item clicked.</p>
63
 * <p>(The icons used are from the open-source 'Tango Icon Library' project: (http://tango.freedesktop.org/Tango_Icon_Library)).</p>
64
 *  
65
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
66
 */
67
public class JOptionsEditionByMousePopupMenu extends JPopupMenu implements Serializable{
68
	private static final long serialVersionUID = -142360699557710223L;
69

  
70
	// Items of this JPopupMenu
71
	private JMenuItem jMenuItemUndo = null;
72
	private JMenuItem jMenuItemRedo = null;
73
	private JMenuItem jMenuItemCut = null;
74
	private JMenuItem jMenuItemCopy = null;
75
	private JMenuItem jMenuItemPaste = null;
76
	private JMenuItem jMenuItemDelete = null;
77
	private JMenuItem jMenuItemSelectAll = null;
78
	
79
	// Values of the events fired when has been clicked an item
80
	public static final int DEFAULT = 0;
81
	public static final int UNDO = 1;
82
	public static final int REDO = 2;
83
	public static final int CUT = 3;
84
	public static final int COPY = 4;
85
	public static final int PASTE = 5;
86
	public static final int DELETE = 6;
87
	public static final int SELECT_ALL = 7;
88
	
89
	// Values of the type of event fired
90
	public static final int VISIBILITY = 8;
91
	public static final String SELECTEDOPTION = "SelectedOption";
92
	public static final String VISIBILITYCHANGED = "Visibility";
93
	
94
	// Hash map for the items
95
	private HashMap<String, String> map;
96

  
97
	// Action listener for notify (fire) some events that had happened to this component
98
	private ActionListener menuListener = null;
99

  
100
	// Listener for property change support
101
	private PropertyChangeSupport changes = new PropertyChangeSupport(this);
102

  
103
 	/**
104
	 * Default constructor 
105
	 */
106
	public JOptionsEditionByMousePopupMenu() {
107
		super();
108
		initialize();
109
	}
110

  
111
	/**
112
	 * This method initializes this component 
113
	 */
114
	private void initialize() {
115
        map = new HashMap<String, String>();
116
        this.add(getJMenuItemUndo());
117
        this.add(getJMenuItemRedo());
118
        this.addSeparator();
119
        this.add(getJMenuItemCut());
120
        this.add(getJMenuItemCopy());
121
        this.add(getJMenuItemPaste());
122
        this.add(getJMenuItemDelete());
123
        this.addSeparator();
124
        this.add(getJMenuItemSelectAll());
125
        this.setLabel("Edition");
126
        this.setBorder(new BevelBorder(BevelBorder.RAISED));
127
	}
128
	
129
	/**
130
	 * This method initializes jMenuItemUndo	
131
	 * 	
132
	 * @return javax.swing.JMenuItem
133
	 */
134
	private JMenuItem getJMenuItemUndo() {
135
		if (jMenuItemUndo == null) {
136
			ImageIcon undoIcon = new ImageIcon(JOptionsEditionByMousePopupMenu.class.getResource("images/edit-undo.png"), Messages.getText("edit_undo"));
137
			jMenuItemUndo = new JMenuItem(Messages.getText("edit_undo"), undoIcon);
138
			jMenuItemUndo.setHorizontalTextPosition(JMenuItem.RIGHT);
139
			jMenuItemUndo.addActionListener(this.getMenuListener());
140
			map.put(Messages.getText("edit_undo"), Integer.toString(JOptionsEditionByMousePopupMenu.UNDO));
141
		}
142
		return jMenuItemUndo;
143
	}
144

  
145
	/**
146
	 * This method initializes jMenuItemRedo	
147
	 * 	
148
	 * @return javax.swing.JMenuItem	
149
	 */
150
	private JMenuItem getJMenuItemRedo() {
151
		if (jMenuItemRedo == null) {
152
			ImageIcon redoIcon = new ImageIcon(JOptionsEditionByMousePopupMenu.class.getResource("images/edit-redo.png"), Messages.getText("edit_redo"));
153
			jMenuItemRedo = new JMenuItem(Messages.getText("edit_redo"), redoIcon);
154
			jMenuItemRedo.setHorizontalTextPosition(JMenuItem.RIGHT);
155
			jMenuItemRedo.addActionListener(this.getMenuListener());
156
			map.put(Messages.getText("edit_redo"), Integer.toString(JOptionsEditionByMousePopupMenu.REDO));
157
		}
158
		return jMenuItemRedo;
159
	}
160

  
161
	/**
162
	 * This method initializes jMenuItemCut	
163
	 * 	
164
	 * @return javax.swing.JMenuItem	
165
	 */
166
	private JMenuItem getJMenuItemCut() {
167
		if (jMenuItemCut == null) {
168
			ImageIcon cutIcon = new ImageIcon(JOptionsEditionByMousePopupMenu.class.getResource("images/edit-cut.png"), Messages.getText("edit_cut"));
169
			jMenuItemCut = new JMenuItem(Messages.getText("edit_cut"), cutIcon);
170
			jMenuItemCut.setHorizontalTextPosition(JMenuItem.RIGHT);
171
			jMenuItemCut.addActionListener(this.getMenuListener());
172
			map.put(Messages.getText("edit_cut"), Integer.toString(JOptionsEditionByMousePopupMenu.CUT));
173
		}
174
		return jMenuItemCut;
175
	}
176
	
177
	/**
178
	 * This method initializes jMenuItemCopy	
179
	 * 	
180
	 * @return javax.swing.JMenuItem	
181
	 */
182
	private JMenuItem getJMenuItemCopy() {
183
		if (jMenuItemCopy == null) {
184
			ImageIcon copyIcon = new ImageIcon(JOptionsEditionByMousePopupMenu.class.getResource("images/edit-copy.png"), Messages.getText("edit_copy"));
185
			jMenuItemCopy = new JMenuItem(Messages.getText("edit_copy"), copyIcon);
186
			jMenuItemCopy.setHorizontalTextPosition(JMenuItem.RIGHT);
187
			jMenuItemCopy.addActionListener(this.getMenuListener());
188
			map.put(Messages.getText("edit_copy"), Integer.toString(JOptionsEditionByMousePopupMenu.COPY));
189
		}
190
		return jMenuItemCopy;
191
	}
192

  
193
	/**
194
	 * This method initializes jMenuItemPaste	
195
	 * 	
196
	 * @return javax.swing.JMenuItem	
197
	 */
198
	private JMenuItem getJMenuItemPaste() {
199
		if (jMenuItemPaste == null) {
200
			ImageIcon pasteIcon = new ImageIcon(JOptionsEditionByMousePopupMenu.class.getResource("images/edit-paste.png"), Messages.getText("edit_paste"));
201
			jMenuItemPaste = new JMenuItem(Messages.getText("edit_paste"), pasteIcon);
202
			jMenuItemPaste.setHorizontalTextPosition(JMenuItem.RIGHT);
203
			jMenuItemPaste.addActionListener(this.getMenuListener());
204
			map.put(Messages.getText("edit_paste"), Integer.toString(JOptionsEditionByMousePopupMenu.PASTE));
205
		}
206
		return jMenuItemPaste;
207
	}
208

  
209
	/**
210
	 * This method initializes jMenuItemDelete	
211
	 * 	
212
	 * @return javax.swing.JMenuItem	
213
	 */
214
	private JMenuItem getJMenuItemDelete() {
215
		if (jMenuItemDelete == null) {
216
			ImageIcon deleteIcon = new ImageIcon(JOptionsEditionByMousePopupMenu.class.getResource("images/edit-delete.png"), Messages.getText("edit_delete"));
217
			jMenuItemDelete = new JMenuItem(Messages.getText("edit_delete"), deleteIcon);
218
			jMenuItemDelete.setHorizontalTextPosition(JMenuItem.RIGHT);
219
			jMenuItemDelete.addActionListener(this.getMenuListener());
220
			map.put(Messages.getText("edit_delete"), Integer.toString(JOptionsEditionByMousePopupMenu.DELETE));
221
		}
222
		return jMenuItemDelete;
223
	}	
224

  
225
	/**
226
	 * This method initializes jMenuItemSelectAll	
227
	 * 	
228
	 * @return javax.swing.JMenuItem	
229
	 */
230
	private JMenuItem getJMenuItemSelectAll() {
231
		if (jMenuItemSelectAll == null) {
232
			ImageIcon selectAllIcon = new ImageIcon(JOptionsEditionByMousePopupMenu.class.getResource("images/edit-select-all.png"), Messages.getText("edit_select_all"));
233
			jMenuItemSelectAll = new JMenuItem(Messages.getText("edit_select_all"), selectAllIcon);
234
			jMenuItemSelectAll.setHorizontalTextPosition(JMenuItem.RIGHT);
235
			jMenuItemSelectAll.addActionListener(this.getMenuListener());
236
			map.put(Messages.getText("edit_select_all"), Integer.toString(JOptionsEditionByMousePopupMenu.SELECT_ALL));
237
		}
238
		return jMenuItemSelectAll;
239
	}
240
	
241
	/**
242
	 * This method initializes the "menuListener" ActionListener
243
	 * 
244
	 * @return ActionListener
245
	 */
246
	private ActionListener getMenuListener() {
247
		if (menuListener == null) {
248
		    menuListener = new ActionListener() {
249
		    	/*
250
		    	 * (non-Javadoc)
251
		    	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
252
		    	 */
253
		        public void actionPerformed(ActionEvent event) {
254
		        	// Notifies that the Visibility of this component has changed
255
		        	if (event.getActionCommand().equals(JOptionsEditionByMousePopupMenu.VISIBILITYCHANGED))
256
		           		changes.firePropertyChange(JOptionsEditionByMousePopupMenu.VISIBILITYCHANGED, JOptionsEditionByMousePopupMenu.DEFAULT, JOptionsEditionByMousePopupMenu.VISIBILITY);
257
		         	else // Notifies that has been clicked on an item
258
		           		changes.firePropertyChange(JOptionsEditionByMousePopupMenu.SELECTEDOPTION, JOptionsEditionByMousePopupMenu.DEFAULT, map.get(event.getActionCommand()));
259
		        }
260
		    };
261
		}
262
		return menuListener;
263
	} 
264

  
265
	/**
266
	 * Enables or disables the undo option item
267
	 * 
268
	 * @param b Value true or false
269
	 */
270
	public void setEnabledUndoOption(boolean b) {
271
		jMenuItemUndo.setEnabled(b);
272
	}
273
	
274
	/**
275
	 * Returns if the undo option item is enabled or not
276
	 * 
277
	 * @return Value true or false
278
	 */
279
	public boolean isEnabledUndoOption() {
280
		return jMenuItemUndo.isEnabled();
281
	}
282
	
283
	/**
284
	 * Enables or disables the redo option item
285
	 * 
286
	 * @param b Value true or false
287
	 */
288
	public void setEnabledRedoOption(boolean b) {
289
		jMenuItemRedo.setEnabled(b);
290
	}
291
	
292
	/**
293
	 * Returns if the redo option item is enabled or not
294
	 * 
295
	 * @return Value true or false
296
	 */
297
	public boolean isEnabledRedoOption() {
298
		return jMenuItemRedo.isEnabled();
299
	}
300
	
301
	/**
302
	 * Enables or disables the cut option item
303
	 * 
304
	 * @param b Value true or false
305
	 */
306
	public void setEnabledCutOption(boolean b) {
307
		jMenuItemCut.setEnabled(b);
308
	}
309
	
310
	/**
311
	 * Returns if the cut option item is enabled or not
312
	 * 
313
	 * @return Value true or false
314
	 */
315
	public boolean isEnabledCutOption() {
316
		return jMenuItemCut.isEnabled();
317
	}
318
	
319
	/**
320
	 * Enables or disables the copy option item
321
	 * 
322
	 * @param b Value true or false
323
	 */
324
	public void setEnabledCopyOption(boolean b) {
325
		jMenuItemCopy.setEnabled(b);
326
	}
327
	
328
	/**
329
	 * Returns if the copy option item is enabled or not
330
	 * 
331
	 * @return Value true or false
332
	 */
333
	public boolean isEnabledCopyOption() {
334
		return jMenuItemCopy.isEnabled();
335
	}
336
	
337
	/**
338
	 * Enables or disables the paste option item
339
	 * 
340
	 * @param b Value true or false
341
	 */
342
	public void setEnabledPasteOption(boolean b) {
343
		jMenuItemPaste.setEnabled(b);
344
	}
345
	
346
	/**
347
	 * Returns if the paste option item is enabled or not
348
	 * 
349
	 * @return Value true or false
350
	 */
351
	public boolean isEnabledPasteOption() {
352
		return jMenuItemPaste.isEnabled();
353
	}
354
	
355
	/**
356
	 * Enables or disables the delete option item
357
	 * 
358
	 * @param b Value true or false
359
	 */
360
	public void setEnabledDeleteOption(boolean b) {
361
		jMenuItemDelete.setEnabled(b);
362
	}
363
	
364
	/**
365
	 * Returns if the delete option item is enabled or not
366
	 * 
367
	 * @return Value true or false
368
	 */
369
	public boolean isEnabledDeleteOption() {
370
		return jMenuItemDelete.isEnabled();
371
	}
372
	
373
	/**
374
	 * Enables or disables the select all option item
375
	 * 
376
	 * @param b Value true or false
377
	 */
378
	public void setEnabledSelectAllOption(boolean b) {
379
		jMenuItemSelectAll.setEnabled(b);
380
	}
381
	
382
	/**
383
	 * Returns if the select all option item is enabled or not
384
	 * 
385
	 * @return Value true or false
386
	 */
387
	public boolean isEnabledelectAllOption() {
388
		return jMenuItemSelectAll.isEnabled();
389
	}	
390

  
391
	/**
392
	 * Enables or disables all option items
393
	 * 
394
	 * @param b Value true or false
395
	 */
396
	public void setEnabledAllOptions(boolean b) {
397
		this.setEnabledUndoOption(b);
398
		this.setEnabledRedoOption(b);
399
		this.setEnabledCutOption(b);
400
		this.setEnabledCopyOption(b);
401
		this.setEnabledPasteOption(b);
402
		this.setEnabledDeleteOption(b);
403
		this.setEnabledSelectAllOption(b);
404
	}	
405
	
406
	/* 
407
	 * (non-Javadoc)
408
	 * @see javax.swing.JPopupMenu#setVisible(boolean)
409
	 */
410
	public void setVisible(boolean b) {
411
		// Notifies that has changed the visibility of this component
412
		super.setVisible(b);
413
		this.getMenuListener().actionPerformed(new ActionEvent(this, JOptionsEditionByMousePopupMenu.VISIBILITY, JOptionsEditionByMousePopupMenu.VISIBILITYCHANGED));
414
	}
415
	   
416
    /**
417
     * Adds a "Property Change Listener"
418
     */
419
    public void addPropertyChangeListener(PropertyChangeListener l) {
420
    	changes.addPropertyChangeListener(l);
421
    }
422

  
423
    /**
424
     * Removes a "Property Change Listener"
425
     */
426
    public void removePropertyChangeListener(PropertyChangeListener l) {
427
    	changes.removePropertyChangeListener(l);
428
    }    
429
}
trunk/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/editabletextcomponent/TestJEditableTextArea.java
1
package org.gvsig.gui.beans.editabletextcomponent;
2

  
3
import java.awt.Dimension;
4

  
5
import javax.swing.JFrame;
6

  
7
import org.gvsig.gui.beans.editabletextcomponent.JEditableTextArea;
8

  
9

  
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
 *
12
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License
16
 * as published by the Free Software Foundation; either version 2
17
 * of the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
 *
28
 * For more information, contact:
29
 *
30
 *  Generalitat Valenciana
31
 *   Conselleria d'Infraestructures i Transport
32
 *   Av. Blasco Ib??ez, 50
33
 *   46010 VALENCIA
34
 *   SPAIN
35
 *
36
 *      +34 963862235
37
 *   gvsig@gva.es
38
 *      www.gvsig.gva.es
39
 *
40
 *    or
41
 *
42
 *   IVER T.I. S.A
43
 *   Salamanca 50
44
 *   46005 Valencia
45
 *   Spain
46
 *
47
 *   +34 963163400
48
 *   dac@iver.es
49
 */
50

  
51
/**
52
 * Tests for JEditableTextArea
53
 * 
54
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
55
 */
56
public class TestJEditableTextArea {
57
	private static JEditableTextArea jTCA;
58
	
59
	/**
60
	 * Test method for the TestJEditableTextArea class
61
	 * 
62
	 * @param args
63
	 */
64
	public static void main(String[] args)
65
	{
66
		final int height = 40;
67
		final int width = 300;
68
		
69
		// Objects creation
70
		JFrame jF = new JFrame();		
71

  
72
		jTCA = new JEditableTextArea();
73
		jTCA.setPreferredSize(new Dimension(width, height));
74

  
75
	    // Set properties
76
		jF.setTitle("Test JEditableTextArea");
77
	    jF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
78
	    jF.setSize(jTCA.getPreferredSize());
79
	    jF.getContentPane().add(jTCA);	
80
	    
81
		jF.setVisible(true);
82
	}
83
}
trunk/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/editabletextcomponent/TestJEditableTextField.java
1
package org.gvsig.gui.beans.editabletextcomponent;
2

  
3
import java.awt.Dimension;
4

  
5
import javax.swing.JFrame;
6

  
7
import org.gvsig.gui.beans.editabletextcomponent.JEditableTextField;
8

  
9

  
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
 *
12
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License
16
 * as published by the Free Software Foundation; either version 2
17
 * of the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
 *
28
 * For more information, contact:
29
 *
30
 *  Generalitat Valenciana
31
 *   Conselleria d'Infraestructures i Transport
32
 *   Av. Blasco Ib??ez, 50
33
 *   46010 VALENCIA
34
 *   SPAIN
35
 *
36
 *      +34 963862235
37
 *   gvsig@gva.es
38
 *      www.gvsig.gva.es
39
 *
40
 *    or
41
 *
42
 *   IVER T.I. S.A
43
 *   Salamanca 50
44
 *   46005 Valencia
45
 *   Spain
46
 *
47
 *   +34 963163400
48
 *   dac@iver.es
49
 */
50

  
51
/**
52
 * Tests for JEditableTextField
53
 * 
54
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
55
 */
56
public class TestJEditableTextField {
57
	private static JEditableTextField jTCE;
58
	
59
	/**
60
	 * Test method for the TestJEditableTextField class
61
	 * 
62
	 * @param args
63
	 */
64
	public static void main(String[] args)
65
	{
66
		final int height = 40;
67
		final int width = 300;
68
		
69
		// Objects creation
70
		JFrame jF = new JFrame();		
71

  
72
		jTCE = new JEditableTextField();
73
		jTCE.setPreferredSize(new Dimension(width, height));
74

  
75
	    // Set properties
76
		jF.setTitle("Test JEditableTextField");
77
	    jF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
78
	    jF.setSize(jTCE.getPreferredSize());
79
	    jF.getContentPane().add(jTCE);	
80
	    
81
		jF.setVisible(true);
82
	}
83
}
trunk/libraries/libUIComponent/config/text.properties
4 4
all_and_maintain_order=Todos los items y Mantener \u00f3rden
5 5
all_and_ordered=Todos los items y Ordenados
6 6
allowedMEditionPMConfigurationLabel=Permite edici\u00f3n texto con rat\u00f3n
7
allowedRepeatedItemsConfigurationLabel=Permite items repetidos
8 7
Anadir_al_conjunto=A\u00f1adir al conjunto
9 8
beepConfigurationLabel=Beep (Sonido de alerta)
10 9
calendarBackOneMonth=Retrocede un mes
......
17 16
cancel=Cancelar
18 17
cantTestThisMethod=La aplicaci\u00f3n no puede testear esta operaci\u00f3n.
19 18
caseSensitiveConfigurationLabel=Distingue May\u00fasculas / Min\u00fasculas
20
completeMatchedItemConfigurationLabel=Completar con item que coincide
21
configurationParameters=Par\u00e1metros Configuraci\u00f3n de Constructores
19
configurationParameters=Par\u00e1metros de Configuraci\u00f3n
22 20
constructors=Constructores
23 21
creaction=Creacci\u00f3n
24 22
date=Fecha
......
42 40
fill=Rellenar
43 41
filterOnALayer=Filtro sobre una capa
44 42
filter_by_sentence=Filtrado por sentencia
45
forceCoincidencesConfigurationLabel=Forzar a coincidencia
46 43
help=Ayuda
47 44
incorrectNumberOfParametersWritten=N\u00famero incorrecto de par\u00e1metros escritos
48 45
incorrectParameter=Par\u00e1metro incorrecto
......
52 49
jOPMessageFileWithoutReadPermissions=No tienes permisos de lectura para leer el fichero fuente
53 50
jOPMessageIncorrectFile=El archivo fuente no es un fichero
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff