Revision 9863

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/fframes/gui/dialogs/FFrameBoxDialog.java
42 42
 *
43 43
 * $Id$
44 44
 * $Log$
45
 * Revision 1.4  2006-12-20 14:42:15  caballero
45
 * Revision 1.5  2007-01-23 13:10:25  caballero
46
 * valor no num?rico
47
 *
48
 * Revision 1.4  2006/12/20 14:42:15  caballero
46 49
 * Remodelado Layout
47 50
 *
48 51
 * Revision 1.3  2006/12/11 17:40:35  caballero
......
88 91

  
89 92
import javax.swing.JLabel;
90 93
import javax.swing.JPanel;
91
import javax.swing.JTextField;
92 94

  
93 95
import org.gvsig.gui.beans.AcceptCancelPanel;
94 96

  
......
98 100
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
99 101
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation;
100 102
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
103
import de.ios.framework.swing.NumberField;
101 104

  
102 105
public class FFrameBoxDialog extends JPanel implements IFFrameDialog{
103 106

  
104 107
	private JPanel jPanel = null;
105 108
	private JLabel jLabel = null;
106 109
	private JLabel jLabel1 = null;
107
	private JTextField txtNumColumns = null;
108
	private JTextField txtNumRows = null;
110
	private NumberField txtNumColumns = null;
111
	private NumberField txtNumRows = null;
109 112
	private Rectangle2D rect = new Rectangle2D.Double();
110 113
	private FFrameTable fframebox;
111 114
	private Layout m_layout;
......
151 154

  
152 155
						public void actionPerformed(java.awt.event.ActionEvent e) {
153 156
							newFFrameBox=(FFrameTable)fframebox.cloneFFrame(m_layout);
157
							if (getTxtNumColumns().getText().equals(""))
158
								getTxtNumColumns().setText("0");
159
							if (getTxtNumRows().getText().equals(""))
160
								getTxtNumRows().setText("0");
154 161
							newFFrameBox.setNumColumns(Integer.parseInt(getTxtNumColumns().getText()));
155 162
							newFFrameBox.setNumRows(Integer.parseInt(getTxtNumRows().getText()));
156 163
							newFFrameBox.setRotation(getPRotation().getRotation());
......
208 215
	 *
209 216
	 * @return javax.swing.JTextField
210 217
	 */
211
	private JTextField getTxtNumColumns() {
218
	private NumberField getTxtNumColumns() {
212 219
		if (txtNumColumns == null) {
213
			txtNumColumns = new JTextField();
220
			txtNumColumns = new NumberField();
214 221
			txtNumColumns.setText(String.valueOf(fframebox.getNumColumns()));
215 222
			txtNumColumns.setBounds(new java.awt.Rectangle(175,8,35,19));
216 223
			txtNumColumns.addKeyListener(new java.awt.event.KeyAdapter() {
217 224
				public void keyReleased(java.awt.event.KeyEvent e) {
218
					if (getTxtNumColumns().getText().equals("") || getTxtNumColumns().getText().equals("0"))return;
219
					thefframebox.setNumColumns(Integer.parseInt(getTxtNumColumns().getText()));
225
					if (txtNumColumns.getIntegerValue()== null || getTxtNumColumns().getText().equals("") || getTxtNumColumns().getText().equals("0"))return;
226
					thefframebox.setNumColumns(txtNumColumns.getIntegerValue().intValue());
220 227
					getPBox().repaint();
221 228
				}
222 229
			});
......
229 236
	 *
230 237
	 * @return javax.swing.JTextField
231 238
	 */
232
	private JTextField getTxtNumRows() {
239
	private NumberField getTxtNumRows() {
233 240
		if (txtNumRows == null) {
234
			txtNumRows = new JTextField();
241
			txtNumRows = new NumberField();
235 242
			txtNumRows.setText(String.valueOf(fframebox.getNumRows()));
236 243
			txtNumRows.setBounds(new java.awt.Rectangle(175,32,35,19));
237 244
			txtNumRows.addKeyListener(new java.awt.event.KeyAdapter() {
238 245
				public void keyReleased(java.awt.event.KeyEvent e) {
239
					if (getTxtNumRows().getText().equals("") || getTxtNumRows().getText().equals("0"))return;
240
					thefframebox.setNumRows(Integer.parseInt(getTxtNumRows().getText()));
246
					if (txtNumRows.getIntegerValue() == null || getTxtNumRows().getText().equals("") || getTxtNumRows().getText().equals("0"))return;
247
						thefframebox.setNumRows(txtNumRows.getIntegerValue().intValue());
241 248
					getPBox().repaint();
242 249
				}
243 250
			});
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/fframes/FFrameTable.java
42 42
 *
43 43
 * $Id$
44 44
 * $Log$
45
 * Revision 1.2  2007-01-03 12:02:54  caballero
45
 * Revision 1.3  2007-01-23 13:10:17  caballero
46
 * valor no num?rico
47
 *
48
 * Revision 1.2  2007/01/03 12:02:54  caballero
46 49
 * Extensibilidad FFrames
47 50
 *
48 51
 * Revision 1.1  2006/12/20 14:42:06  caballero
......
87 90

  
88 91
import com.iver.andami.PluginServices;
89 92
import com.iver.cit.gvsig.AddLayer;
93
import com.iver.cit.gvsig.ProjectExtension;
90 94
import com.iver.cit.gvsig.fmap.DriverException;
95
import com.iver.cit.gvsig.project.Project;
96
import com.iver.cit.gvsig.project.documents.exceptions.OpenException;
91 97
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
92 98
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameBoxDialog;
93 99
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
......
539 545
	public IFFrameDialog getPropertyDialog() {
540 546
		return new FFrameBoxDialog(getLayout(),this);
541 547
	}
548
	public IFFrame cloneFFrame(Layout layout) {
549
        Project p = ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject();
550
        IFFrame frame = null;
542 551

  
552
        try {
553
            frame = createFromXML(this.getXMLEntity(), p,layout);
554
        } catch (OpenException e) {
555
            e.showError();
556
        } catch (SaveException e) {
557
            e.showError();
558
        }
559
        frame.setLayout(layout);
560

  
561
        if (frame instanceof IFFrameViewDependence) {
562
            ((IFFrameViewDependence) frame).initDependence(layout.getLayoutContext().getAllFFrames());
563
        }
564
        frame.setFrameLayoutFactory(factory);
565
        cloneActions(frame);
566
        return frame;
567
    }
543 568
}
trunk/libraries/libUI/src/org/gvsig/gui/beans/controls/comboscale/ComboScale.java
4 4
import java.awt.event.ActionListener;
5 5
import java.text.NumberFormat;
6 6
import java.util.ArrayList;
7
import java.util.BitSet;
7 8
import java.util.Iterator;
8 9

  
9 10
import javax.swing.DefaultComboBoxModel;
......
90 91
			jComboBox.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD,
91 92
					10));
92 93
			jComboBox.setBackground(java.awt.SystemColor.window);
93
			jComboBox
94
					.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
94
			jComboBox.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
95 95
			jComboBox.addActionListener(new java.awt.event.ActionListener() {
96 96
				public void actionPerformed(java.awt.event.ActionEvent e) {
97 97
					if (e.getActionCommand().equals("comboBoxChanged")) {
......
99 99
						// callActionCommandListeners(((Long)jComboBox.getSelectedItem()).longValue());
100 100
						// setScale(((Long)jComboBox.getSelectedItem()).longValue());
101 101
						Object item = jComboBox.getSelectedItem();
102
						long scale;
102
						long scale=0;
103 103
						if (item instanceof String) {
104 104
							StringBuffer sb = new StringBuffer((String) item);
105 105
							// remove any point in the number
106 106
							final String digits = "0123456789";
107 107
							int i = sb.charAt(0) == '-' ? 1 : 0;
108
							while (i < sb.length()-1) {
108
							BitSet deleteChars=new BitSet();
109
							while (i < sb.length()) {
109 110
								if (digits.indexOf(sb.charAt(i))==-1)
110
									sb.deleteCharAt(i);
111
									deleteChars.set(i);
111 112
								i++;
112 113
							}
114
							for (int k=deleteChars.size();k>=0;k--){
115
								if (deleteChars.get(k))
116
									sb.deleteCharAt(k);
117
							}
113 118
							jComboBox.removeItem(item);
114
							scale = Long.parseLong(sb.toString());
119
							try{
120
								scale = Long.parseLong(sb.toString());
121
							}catch (NumberFormatException e1) {
122
							}
115 123
						} else {
116 124
							scale = ((ComboScaleItem) jComboBox.getSelectedItem())
117 125
							.getValue();
trunk/libraries/libUI/src/de/ios/framework/swing/IoSTextField.java
1

  
2

  
3
/*
4
 * $Id$
5
 *
6
 * (c)1997 IoS Gesellschaft fr innovative Softwareentwicklung mbH
7
 * http://www.IoS-Online.de    mailto:info@IoS-Online.de
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License as
11
 * published by the Free Software Foundation; either version 2 of
12
 * the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
 * General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
 *
23
 */
24

  
25

  
26
package de.ios.framework.swing;
27

  
28
import java.awt.*;
29
import java.awt.event.*;
30

  
31
import javax.swing.JTextField;
32

  
33
import de.ios.framework.basic.*;
34

  
35

  
36
/**
37
 * Textfield, ABSTRACT basic class for any Singleline-Input-Fields.
38
 * Includes support for key-substitution (to solve problems with i.e.
39
 * the '@'), limited Charactersets, auto-formating on lost focus,
40
 * automatic selection on gained focus.
41
 * Implementation of several Listener-Interfaces only for internal use!
42
 * @version $Id$
43
 */
44
public abstract class IoSTextField extends JTextField
45
implements KeyListener, FocusListener, MouseListener {
46

  
47

  
48
  /** STATIC: Faster setText-Handling - if true, the Text is only set, if it differs from the current value. */
49
  public static boolean fastSetText = true;
50

  
51
  /** Default for auto-selection-handling. */
52
  public static boolean defaultAutoSelection = false;
53

  
54
  /** Lokal auto-selektion-mode. */
55
  protected Boolean autoSelection = null;
56

  
57
  /** Focus-Handling. Stores "temporary"-flag of the last lostFocus. */
58
  protected boolean lastFTemp = false;
59

  
60
  /** Keys to replace on input. STILL REQUIRED??? Don't know... */
61
  protected String keys        = ""; // "@";
62

  
63
  /** Replacements for keys on input. STILL REQUIRED??? Don't know... */
64
  protected String replace     = ""; // "@";
65

  
66
  /** A String with valid input characters. If null, all characters are valid. */
67
  protected String charSet = null;
68

  
69
  /** Info-Text for this field. */
70
  protected String infoText = null;
71

  
72
  /** Auto-Format-Flag. */
73
  protected boolean autoFormat = true;
74

  
75
  /** Keep-Focus-On-Illegal-Value-Flag. */
76
  protected boolean keepFocus = true;
77

  
78
  /** Disable-Lock for setEnabled(). */
79
  protected boolean lockDisable = false;
80

  
81

  
82
  /**
83
   * Constructor.
84
   */
85
  public IoSTextField() {
86
    super();
87
    initListener();
88
  }
89

  
90

  
91
  /**
92
   * Constructor.
93
   */
94
  public IoSTextField( int cols ) {
95
    super(cols);
96
    initListener();
97
  }
98

  
99

  
100
  /**
101
   * Constructor.
102
   * This constructor is temporary of type 'package', cause it's of the same
103
   * type like a deprecated constructor, but with changed behaviour.
104
   */
105
  IoSTextField( String _charSet ) {
106
    super();
107
    setCharSet( _charSet );
108
    initListener();
109
  }
110

  
111

  
112
  /**
113
   * Constructor defining also the Charset.
114
   */
115
  public IoSTextField( int cols, String _charSet ) {
116
    super(cols);
117
    setCharSet( _charSet );
118
    initListener();
119
  }
120

  
121

  
122
  /**
123
   * Constructor defining the charset, auto-formating and illegal-value-focus-keeping.
124
   */
125
  public IoSTextField( int cols, String _charSet, boolean _autoFormat, boolean _keepFocus ) {
126
    super(cols);
127
    setCharSet( _charSet );
128
    setAutoFormat( _autoFormat );
129
    setKeepFocusOnIllegalValue( _keepFocus );
130
    initListener();
131
  }
132

  
133

  
134
  /**
135
   * Constructor.
136
   */
137
  /* deprecated
138
  public IoSTextField( String text, int cols ) {
139
    super(cols);
140
    setText( text )
141
    initListener();
142
  }
143
  */
144

  
145

  
146
  /**
147
   * Add an ActionListener, set a predefined color for 'Action'-Fields.
148
   */
149
  public void addActionListener(ActionListener l) {
150
    super.addActionListener( l );
151
    //String c = Parameters.getParameter( "textfield.action.color" );
152
    //if ( c != null )
153
    //  setBackground( new Color( Integer.parseInt( c, 16 ) ) );
154
  }
155

  
156

  
157
  /**
158
   * Disable the field and lock it against any setEnable().
159
   */
160
  public void lockDisable( boolean disable ) {
161
    if (!isDisableLocked())
162
      super.setEnabled( false );
163
    lockDisable |= disable;
164
  }
165

  
166

  
167
  /**
168
   * Unlock a the lock on the disable of the field (does not directly enable the field, but realows enabling).
169
   */
170
  public void unlockDisabled() {
171
    lockDisable = false;
172
  }
173

  
174

  
175
  /**
176
   * Check, if the field is locked disabled.
177
   */
178
  public boolean isDisableLocked() {
179
    return lockDisable;
180
  }
181

  
182

  
183
  /**
184
   * setEnabled() protected with the disable-lock.
185
   */
186
  public void setEnabled( boolean en ) {
187
    if (!isDisableLocked())
188
      super.setEnabled( en );
189
  }
190

  
191

  
192
  /**
193
   * Sets the text. Watches the maximal size of the field,
194
   * so that the leading part of the text is always visible,
195
   * handles null-Values.
196
   * (the default-implementation show the trailing part of the text, because
197
   * always the caret is set to the end of the textfield.).
198
   */
199
  public void setText( String text ) {
200
    if (text == null)
201
      text = "";
202
    if ( fastSetText ? (text.compareTo( syncGetText() )!=0) : true )
203
      super.setText( text );
204
    if ( text != null )
205
      if ( text.length() >= getColumns())
206
        if (fastSetText ? (getCaretPosition() != 0) : true)
207
	  setCaretPosition( 0 );
208
    textValueChanged();
209
  }
210

  
211
  /**
212
   * Overloaded, calls syncGetText().
213
   * @see syncGetText()
214
   */
215
  public String getText() {
216
    return syncGetText();
217
  }
218

  
219
  /**
220
   * To solve problem with blocking peers (Bug in Motif/JDK?).
221
   */
222
  public synchronized String syncGetText() {
223
    return super.getText();
224
  }
225

  
226
  /**
227
   * Gets the text.
228
   * We couldn't give that functionality to getText(),
229
   * cause it's internally used by Super-Classes not expecting null-Values.
230
   */
231
  public String getNullText() {
232
    String text = getText();
233
    return (text.length() == 0) ? null : text;
234
  }
235

  
236

  
237
  /**
238
   * Get the text after formating (primary for internal use at inheritances).
239
   * Does (and MUST) not request the focus.
240
   */
241
  public String getFormatedText() {
242
    if (!formatValue())
243
      setText( null );
244
    return getNullText();
245
  }
246

  
247

  
248
  /**
249
   * Request-Method for formating the Data (only for redefinition by inheritances).
250
   * Default-Implementation does nothing.
251
   * @return false, if formating fails due to an illegal Value
252
   * (results in keeping the Focus, if requested by setKeepFocusOnIllegalValue).
253
   */
254
  public boolean formatValue() {
255
    return true;
256
  }
257

  
258

  
259
  /**
260
   * Set a "special" character set. All other characters are ignored on input.
261
   * @see #keyTyped()
262
   * @param s A string with valid characters.
263
   */
264
  public void setCharSet(String s) {
265
    charSet = s;
266
  }
267

  
268

  
269
  /**
270
   * Get the "special" character set.
271
   * @return The "special" character set.
272
   */
273
  public String getCharSet() {
274
    return charSet;
275
  }
276

  
277

  
278
  /**
279
   * Enable/disable the Auto-Selection-Mode.
280
   */
281
  public void setAutoSelection( boolean _autoSelection ) {
282
    autoSelection = new Boolean( _autoSelection );
283
  }
284

  
285

  
286
  /**
287
   * Set the autoformat-mode of this field.
288
   * If autoformat is activated the field is automaticaly formated if the focus
289
   * is lost permanently.
290
   */
291
  public void setAutoFormat( boolean _autoFormat ) {
292
    autoFormat = _autoFormat;
293
  }
294

  
295

  
296
  /**
297
   * Defines, if to keep the Focus on illegal Values (only on active AutoFormat).
298
   */
299
  public void setKeepFocusOnIllegalValue( boolean _keepFocus ) {
300
    keepFocus = _keepFocus;
301
  }
302

  
303

  
304
  /**
305
   * Define the Keys to be handled manually
306
   */
307
  public synchronized IoSTextField manuallyHandle(String _keys, String _replace) {
308
    keys=_keys;
309
    replace=_replace;
310
    if ( keys == null )
311
      keys="";
312
    if ( replace == null )
313
      replace="";
314
    return this;
315
  }
316

  
317

  
318
  /////// Internal Stuff ///////
319

  
320

  
321
  /**
322
   * Init the listeners.
323
   */
324
  protected void initListener() {
325
    addKeyListener  ( this );
326
    addFocusListener( this );
327
    addMouseListener( this );
328
    //addTextListener ( this );
329
  }
330

  
331

  
332
  // Events //
333

  
334
  public static boolean restoreCaretTested = false;
335
  public static boolean restoreCaretPosition;
336

  
337

  
338
  /**
339
   * Implements FocusListener
340
   * Invoked when the component gains the keyboard focus.
341
   * Marks the complet input (but leaves the caret-position).
342
   */
343
  public void focusGained( FocusEvent  evt ) {
344
    if ( ((autoSelection == null) ? defaultAutoSelection : autoSelection.booleanValue())
345
	 && isEditable() && !lastFTemp) {
346
	int l = getText().length();
347
	if (l>0) {
348
	    int p = 0;
349
	    if (!restoreCaretTested) {
350
		p = getCaretPosition();
351
		selectAll();
352
		setCaretPosition( p );
353
		restoreCaretPosition = (getSelectedText().length()==l);
354
	    }
355
	    if (restoreCaretPosition)
356
		p = getCaretPosition();
357
	    selectAll();
358
	    if (restoreCaretPosition)
359
		setCaretPosition( p );
360
	}
361
    }
362
  }
363

  
364

  
365
  /**
366
   * Implements FocusListener
367
   * Invoked when a component loses the keyboard focus.
368
   * Stores the temporary-flag of the event and
369
   * resets selection if autoselection is enabled.
370
   */
371
  public void focusLost( FocusEvent evt ) {
372
    lastFTemp = evt.isTemporary();
373
    if (!lastFTemp) {
374
      if ( autoFormat && isEditable() )
375
	if ( !formatValue() ) {
376
	  if ( keepFocus )
377
	    requestFocus();
378
	  else
379
	    setText( null );
380
	  getToolkit().beep();
381
	}
382
      if ( (autoSelection == null) ? defaultAutoSelection : autoSelection.booleanValue() ) {
383
	int p = getCaretPosition();
384
	select(0,0);
385
	setCaretPosition( p );
386
      }
387
    }
388
  }
389

  
390

  
391
  /**
392
   * Implements MouseListener
393
   * Invoked when the mouse has been clicked on a component.
394
   * Defaultimplementation, does nothing
395
   */
396
  public void mouseClicked(MouseEvent evt) {
397
  }
398

  
399

  
400
  /**
401
   * Implements MouseListener
402
   * Invoked when the mouse enters a component.
403
   * Defaultimplementation, does nothing
404
   */
405
  public void mouseEntered(MouseEvent evt) {
406
  }
407

  
408

  
409
  /**
410
   * Implements MouseListener
411
   * Invoked when the mouse exits a component.
412
   * Defaultimplementation, does nothing
413
   */
414
  public void mouseExited(MouseEvent evt) {
415
  }
416

  
417

  
418
  /**
419
   * Implements MouseListener
420
   * Invoked when a mouse button has been pressed on a component.
421
   * Subpress autoselection for the following focus-event.
422
   */
423
  public void mousePressed(MouseEvent evt ) {
424
    lastFTemp = true;
425
  }
426

  
427

  
428
  /**
429
   * Implements MouseListener
430
   * Invoked when a mouse button has been released on a component.
431
   * Defaultimplementation, does nothing
432
   */
433
  public void mouseReleased(MouseEvent evt ) {
434
  }
435

  
436

  
437
  /**
438
   * Implements KeyListener.
439
   * Invoked when a key has been pressed.
440
   */
441
  public synchronized void keyPressed(KeyEvent evt ) {
442
  }
443

  
444

  
445
  /**
446
   * Implements KeyListener.
447
   * Invoked when a key has been released.
448
   */
449
  public synchronized void keyReleased(KeyEvent evt ) {
450
  }
451

  
452

  
453
  /**
454
   * Implements KeyListener.
455
   * Invoked when a key has been typed. Replaces manualy handled Characters.
456
   */
457
  public synchronized void keyTyped(KeyEvent evt ) {
458
    int pos=keys.indexOf(evt.getKeyChar());
459
    if (pos!=-1) {
460
      String rtext;
461
      String text = getNullText();
462
      int    cpos = getCaretPosition();
463
      if ( text != null ) {
464
	rtext = text.substring(0,cpos-1)+(char)replace.charAt(pos);
465
	if ( text.length()>cpos)
466
	  rtext += text.substring(cpos);
467
	setText( rtext );
468
	setCaretPosition( cpos );
469
      }
470
    }
471
  }
472

  
473

  
474
  /**
475
   * Implements Text-Listener.
476
   */
477
  public void textValueChanged() {
478
    String  val = getNullText();
479
    int     op  = getCaretPosition();
480
    int     p   = op;
481
    int     i;
482
    boolean changed = false;
483

  
484
    if ((charSet != null) && (val != null)) {
485
      for ( i=val.length()-1; i>=0; i-- ) {
486
	if (charSet.indexOf(val.charAt(i)) < 0) {
487
	  if (p>i)
488
	    p--;
489
	  val = val.substring(0,i)+val.substring(i+1);
490
	  changed = true;
491
	}
492
      }
493
      if (changed) {
494
	setText( val );
495
	if (p != op)
496
	  setCaretPosition( p );
497
	getToolkit().beep();
498
      }
499
    }
500
  }
501

  
502
}
503

  
504
/*
505
 * $Log$
506
 * Revision 1.2  2007-01-23 13:11:06  caballero
507
 * valor no num?rico
508
 *
509
 * Revision 1.1.2.1  2007/01/19 13:42:54  caballero
510
 * NumericField
511
 *
512
 * Revision 1.1.1.1  2001/02/07 15:24:00  rtfm
513
 * initial
514
 *
515
 * Revision 1.17  1999/12/16 15:21:55  fw
516
 * TextField: optional coloring of Fields with ActionListeners (property: textfield.action.color=RRGGBB (hex))
517
 * TextArea: no change
518
 *
519
 * Revision 1.16  1999/12/05 22:19:15  bw
520
 * Automatische makrierung gefixed
521
 *
522
 * Revision 1.15  1999/11/26 14:16:30  fw
523
 * added lock-disable-methods
524
 *
525
 * Revision 1.14  1999/11/25 12:07:27  js
526
 * added syncGetText() to solve problem with blocking peers (Bug in Motif/JDK?).
527
 *
528
 * Revision 1.13  1999/10/27 10:57:58  fw
529
 * bugfix due to changed event-order on jdk1.1.7 on illegal characters
530
 *
531
 * Revision 1.12  1999/08/02 09:03:20  js
532
 * Fix for blocking texfields when ENTER was typed (JDK >= 1.1.7).
533
 *
534
 * Revision 1.11  1999/05/20 11:12:15  fw
535
 * removed special handling of @, seems not to be neccessary at current jdk's anymore, caused problems at windows-jdk's
536
 *
537
 * Revision 1.10  1999/01/07 12:29:23  fw
538
 * Speed-Up for setText()-Methods (reduces repaints of Fields, fastSetText-Mode, default: on/true)
539
 *
540
 * Revision 1.9  1998/12/08 18:26:10  fw
541
 * *Field: cleanup; autoFormat-, keepFocus-, limited-Charset-Support for all Fields (enabled by default)
542
 * ViewLayout: Litle change due to changes at the *Fields
543
 * DBListRow: toString()-Method for BigDecimals exchanging the '.' by ','
544
 *
545
 * Revision 1.8  1998/12/02 11:26:54  js
546
 * Support for special character sets added.
547
 *
548
 * Revision 1.7  1998/12/02 08:29:41  js
549
 * doc fixes
550
 *
551
 * Revision 1.6  1998/09/07 11:50:04  bw
552
 * Automatic caret repositioning on "setText", so that always
553
 * the leading part of the text is shown.
554
 *
555
 * Revision 1.5  1998/08/20 15:25:13  bw
556
 * Bugfix (lastFTemp was not set correctly)
557
 *
558
 * Revision 1.4  1998/08/13 09:46:05  bw
559
 * Default for auto-Selection set to false.
560
 *
561
 * Revision 1.3  1998/06/17 19:03:46  bw
562
 * Automativ Info-texts on right-mouse-click.
563
 *
564
 * Revision 1.2  1998/05/29 10:05:10  bw
565
 * Support for automatic selection on focus-gain.
566
 *
567
 * Revision 1.1  1998/05/13 11:55:38  fw
568
 * Added new basic TextField-Component IoSTextField (ExtendedTextField
569
 * with JDK 1.1 Event-Handling), replaced the Base-Class ExtendedTextField
570
 * of all other 'Fields' by IoSTextField
571
 * ExtendedTextField uses now the JDK 1.0 Event-Handling again (due to massive
572
 * Problems with blocked 1.0-Event-Handling at older Projects) - from now
573
 * on the complete Class is DEPRECATED.
574
 *
575
 * Revision 1.4  1998/05/10 05:46:39  bw
576
 * Automativ replacement convertzed to jdk 1.1 norm (using KeyListener).
577
 *
578
 * Revision 1.3  1998/02/06 14:03:10  fw
579
 * ExtendedTextField: removed some old, unused Code
580
 * PrintCanvas: turned debugging off
581
 *
582
 * Revision 1.2  1997/12/10 19:38:41  bb
583
 * Copyright eingefgt.
584
 *
585
 * Revision 1.1  1997/09/16 09:19:37  bw
586
 * Package-nderung von "ios-online" nach "ios".
587
 *
588
 * Revision 1.1  1997/09/09 08:42:00  fw
589
 * moved all framework-stuff of wrede.customer to the new de.ios.framework
590
 *
591
 * Revision 1.2  1997/07/29 11:54:10  fw
592
 * Added the missing CVS-Id and CVS-Log entries...
593
 *
594
 */
595

  
596

  
597

  
598

  
599

  
600

  
601

  
0 602

  
trunk/libraries/libUI/src/de/ios/framework/swing/NumberRange.java
1
/*
2
 * $Id$
3
 * (c)1997 IoS Gesellschaft fr innovative Softwareentwicklung mbH
4
 * http://www.IoS-Online.de    mailto:info@IoS-Online.de
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License as
8
 * published by the Free Software Foundation; either version 2 of
9
 * the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
 * General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
 *
20
 */
21

  
22
package de.ios.framework.swing;
23
import java.awt.*;
24
import java.awt.event.*;
25
import java.util.*;
26
import de.ios.framework.swing.*;
27
import de.ios.framework.basic.*;
28

  
29
/**
30
 * Displays a Textfield with two small buttons in an own panel.
31
 */
32
public class NumberRange extends Panel {
33

  
34
  /** Output debugging mssages, if true */
35
  public static final boolean debug = false;
36

  
37
  /** TextField to hold the current value */
38
  protected NumberField value  = null;
39
  /** Button to increment the current value */
40
  protected Button      plusB  = new Button("+");;
41
  /** Button to decrement the current value */
42
  protected Button      minusB = new Button("-");;
43

  
44
  // Default values
45
  /** Size of NumberField (digits) */
46
  protected int digits   = 3;
47
  /** The smallest allowed value */
48
  protected int minValue = 0;
49
  /** The biggest allowed value */
50
  protected int maxValue = 999;
51

  
52
  /**
53
   * Default Constructor
54
   */
55
  public NumberRange() {
56
    createDialog();
57
    value.setValue( new Integer( minValue ) );
58

  
59
  }
60

  
61
  /**
62
   * Constructor to set an initial value.
63
   *
64
   * @param v Initial value
65
   */
66
  public NumberRange(int v) {
67
    createDialog();
68
    value.setValue( new Integer(v) );
69
  }
70

  
71
  /**
72
   * Constructor to set an initial, minimal and maximal value.
73
   *
74
   * @param v Initial value
75
   * @param min Min. value
76
   * @param max Max. value
77
   */
78
  public NumberRange(int v, int min, int max) {
79
    minValue = min;
80
    maxValue = max;
81
    createDialog();
82
    value.setValue( new Integer(v) );
83
  }
84

  
85
  /**
86
   * Constructor to set the field size (digits) and
87
   * an initial, minimal and maximal value.
88
   *
89
   * @param dig Field size (digits)
90
   * @param v Initial value
91
   * @param min Min. value
92
   * @param max Max. value
93
   */
94
  public NumberRange(int dig, int v, int min, int max) {
95
    digits = dig;
96
    minValue = min;
97
    maxValue = max;
98
    createDialog();
99
    value.setValue( new Integer(v) );
100
  }
101

  
102
  /**
103
   * Arranges the GUI components
104
   */
105
  protected void createDialog() {
106
    value  = new NumberField( digits );
107
    value.setEditable( false );
108
    setLayout( new FlowLayout( FlowLayout.LEFT, 1, 1) );
109
    add( value  );
110
    add( plusB  );
111
    add( minusB );
112

  
113
    // Button events
114
    plusB.addActionListener( new ActionListener() {
115
      public void actionPerformed(ActionEvent e) {
116
	incValue();
117
      }
118
    });
119
    minusB.addActionListener( new ActionListener() {
120
      public void actionPerformed(ActionEvent e) {
121
	decValue();
122
      }
123
    });
124
  }
125

  
126
  /**
127
   * Increment the current value.
128
   */
129
  protected void incValue() {
130
    int v = this.getValue();
131
    if (v < maxValue) {
132
      value.setValue( new Integer(v+1) );
133
    }
134
  }
135

  
136
  /**
137
   * Decrement the current value.
138
   */
139
  protected void decValue() {
140
    int v = this.getValue();
141
    if (v > minValue) {
142
      value.setValue( new Integer(v-1) );
143
    }
144
  }
145

  
146
  /**
147
   * Returns the current value.
148
   */
149
  public int getValue() {
150
    return value.getIntegerValue().intValue();
151
  }
152

  
153
  /**
154
   * Sets the current value
155
   */
156
  public void setValue(int v) {
157
    value.setValue( new Integer(v) );
158
  }
159

  
160
}
161

  
162
/*
163
 * $Log$
164
 * Revision 1.2  2007-01-23 13:11:06  caballero
165
 * valor no num?rico
166
 *
167
 * Revision 1.1.2.1  2007/01/19 13:42:54  caballero
168
 * NumericField
169
 *
170
 * Revision 1.1.1.1  2001/02/07 15:24:01  rtfm
171
 * initial
172
 *
173
 * Revision 1.4  1998/05/15 08:45:04  js
174
 * added setValue
175
 *
176
 * Revision 1.3  1998/04/21 15:39:25  js
177
 * More comments.
178
 *
179
 * Revision 1.2  1998/04/17 12:49:13  js
180
 * Changes for layout of CardViews (missing right line...)
181
 *
182
 * Revision 1.1  1998/04/17 07:58:20  js
183
 * A textfield (NumberField) with two buttons to increment/decrement the
184
 * numerical value.
185
 *
186
 */
187

  
0 188

  
trunk/libraries/libUI/src/de/ios/framework/swing/DateComboBox.java
1
package de.ios.framework.swing;
2

  
3
import java.awt.*;
4
import java.awt.event.*;
5
import java.util.Calendar;
6
import java.text.SimpleDateFormat;
7

  
8
import javax.swing.*;
9
import javax.swing.event.PopupMenuListener;
10
import javax.swing.event.PopupMenuEvent;
11
import javax.swing.plaf.ComboBoxUI;
12
import javax.swing.plaf.basic.ComboPopup;
13
import javax.swing.plaf.metal.MetalComboBoxUI;
14
import javax.swing.border.Border;
15
import javax.swing.border.EtchedBorder;
16
import javax.swing.border.EmptyBorder;
17

  
18
import com.sun.java.swing.plaf.motif.MotifComboBoxUI;
19
import com.sun.java.swing.plaf.windows.WindowsComboBoxUI;
20

  
21
/**
22
 * @version 1.0 11/02/2000
23
 */
24

  
25
//////////////////////////////////////////////////////////////
26

  
27
public class DateComboBox extends JComboBox {
28

  
29
static java.util.ResourceBundle resource = java.util.ResourceBundle.getBundle("resources.Traduction")/*#BundleType=List*/;
30

  
31
    protected SimpleDateFormat dateFormat = new SimpleDateFormat("MMM d, yyyy");
32
    public void setDateFormat(SimpleDateFormat dateFormat) {
33
	this.dateFormat = dateFormat;
34
    }
35
    public void setSelectedItem(Object item) {
36
	// Could put extra logic here or in renderer when item is instanceof Date, Calendar, or String
37
	// Dont keep a list ... just the currently selected item
38
	removeAllItems(); // hides the popup if visible
39
	addItem(item);
40
	super.setSelectedItem(item);
41
    }
42

  
43
    public void updateUI() {
44
	ComboBoxUI cui = (ComboBoxUI) UIManager.getUI(this);
45
	if (cui instanceof MetalComboBoxUI) {
46
	    cui = new MetalDateComboBoxUI();
47
	} else if (cui instanceof MotifComboBoxUI) {
48
	    cui = new MotifDateComboBoxUI();
49
	} else if (cui instanceof WindowsComboBoxUI) {
50
	    cui = new WindowsDateComboBoxUI();
51
	}
52
        setUI(cui);
53
    }
54

  
55
    // Inner classes are used purely to keep DateComboBox component in one file
56
    //////////////////////////////////////////////////////////////
57
    // UI Inner classes -- one for each supported Look and Feel
58
    //////////////////////////////////////////////////////////////
59

  
60
    class MetalDateComboBoxUI extends MetalComboBoxUI {
61
	protected ComboPopup createPopup() {
62
	    return new DatePopup( comboBox );
63
	}
64
    }
65

  
66
    class WindowsDateComboBoxUI extends WindowsComboBoxUI {
67
	protected ComboPopup createPopup() {
68
	    return new DatePopup( comboBox );
69
	}
70
    }
71

  
72
    class MotifDateComboBoxUI extends MotifComboBoxUI {
73
	protected ComboPopup createPopup() {
74
	    return new DatePopup( comboBox );
75
	}
76
    }
77

  
78
    //////////////////////////////////////////////////////////////
79
    // DatePopup inner class
80
    //////////////////////////////////////////////////////////////
81

  
82
    class DatePopup implements ComboPopup, MouseMotionListener,
83
			       MouseListener, KeyListener, PopupMenuListener {
84

  
85
	protected JComboBox comboBox;
86
	protected Calendar calendar;
87
	protected JPopupMenu popup;
88
	protected JLabel monthLabel;
89
	protected JPanel days = null;
90
	protected SimpleDateFormat monthFormat = new SimpleDateFormat("MMM yyyy");
91

  
92
	protected Color selectedBackground;
93
	protected Color selectedForeground;
94
	protected Color background;
95
	protected Color foreground;
96

  
97
	public DatePopup(JComboBox comboBox) {
98
	    this.comboBox = comboBox;
99
	    calendar = Calendar.getInstance();
100
	    // check Look and Feel
101
	    background = UIManager.getColor("ComboBox.background");
102
	    foreground = UIManager.getColor("ComboBox.foreground");
103
	    selectedBackground = UIManager.getColor("ComboBox.selectionBackground");
104
	    selectedForeground = UIManager.getColor("ComboBox.selectionForeground");
105

  
106
	    initializePopup();
107
	}
108

  
109
	//========================================
110
	// begin ComboPopup method implementations
111
	//
112
        public void show() {
113
	    try {
114
		// if setSelectedItem() was called with a valid date, adjust the calendar
115
		calendar.setTime( dateFormat.parse( comboBox.getSelectedItem().toString() ) );
116
	    } catch (Exception e) {}
117
	    updatePopup();
118
	    popup.show(comboBox, 0, comboBox.getHeight());
119
        }
120

  
121
	public void hide() {
122
	    popup.setVisible(false);
123
	}
124

  
125
	protected JList list = new JList();
126
	public JList getList() {
127
	    return list;
128
	}
129

  
130
	public MouseListener getMouseListener() {
131
	    return this;
132
	}
133

  
134
	public MouseMotionListener getMouseMotionListener() {
135
	    return this;
136
	}
137

  
138
	public KeyListener getKeyListener() {
139
	    return this;
140
	}
141

  
142
	public boolean isVisible() {
143
	    return popup.isVisible();
144
	}
145

  
146
	public void uninstallingUI() {
147
	    popup.removePopupMenuListener(this);
148
	}
149

  
150
	//
151
	// end ComboPopup method implementations
152
	//======================================
153

  
154

  
155

  
156
	//===================================================================
157
	// begin Event Listeners
158
	//
159

  
160
	// MouseListener
161

  
162
	public void mousePressed( MouseEvent e ) {}
163
        public void mouseReleased( MouseEvent e ) {}
164
	// something else registered for MousePressed
165
	public void mouseClicked(MouseEvent e) {
166
            if ( !SwingUtilities.isLeftMouseButton(e) )
167
                return;
168
            if ( !comboBox.isEnabled() )
169
                return;
170
	    if ( comboBox.isEditable() ) {
171
		comboBox.getEditor().getEditorComponent().requestFocus();
172
	    } else {
173
		comboBox.requestFocus();
174
	    }
175
	    togglePopup();
176
	}
177

  
178
	protected boolean mouseInside = false;
179
	public void mouseEntered(MouseEvent e) {
180
	    mouseInside = true;
181
	}
182
	public void mouseExited(MouseEvent e) {
183
	    mouseInside = false;
184
	}
185

  
186
	// MouseMotionListener
187
	public void mouseDragged(MouseEvent e) {}
188
	public void mouseMoved(MouseEvent e) {}
189

  
190
	// KeyListener
191
	public void keyPressed(KeyEvent e) {}
192
	public void keyTyped(KeyEvent e) {}
193
	public void keyReleased( KeyEvent e ) {
194
	    if ( e.getKeyCode() == KeyEvent.VK_SPACE ||
195
		 e.getKeyCode() == KeyEvent.VK_ENTER ) {
196
		togglePopup();
197
	    }
198
	}
199

  
200
	/**
201
	 * Variables hideNext and mouseInside are used to
202
	 * hide the popupMenu by clicking the mouse in the JComboBox
203
	 */
204
	public void popupMenuCanceled(PopupMenuEvent e) {}
205
	protected boolean hideNext = false;
206
	public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
207
	    hideNext = mouseInside;
208
	}
209
	public void popupMenuWillBecomeVisible(PopupMenuEvent e) {}
210

  
211
	//
212
	// end Event Listeners
213
	//=================================================================
214

  
215
	//===================================================================
216
	// begin Utility methods
217
	//
218

  
219
	protected void togglePopup() {
220
	    if ( isVisible() || hideNext ) {
221
		hide();
222
	    } else {
223
		show();
224
	    }
225
	    hideNext = false;
226
	}
227

  
228
	//
229
	// end Utility methods
230
	//=================================================================
231

  
232
	// Note *** did not use JButton because Popup closes when pressed
233
	protected JLabel createUpdateButton(final int field, final int amount) {
234
	    final JLabel label = new JLabel();
235
	    final Border selectedBorder = new EtchedBorder();
236
	    final Border unselectedBorder = new EmptyBorder(selectedBorder.getBorderInsets(new JLabel()));
237
	    label.setBorder(unselectedBorder);
238
	    label.setForeground(foreground);
239
	    label.addMouseListener(new MouseAdapter() {
240
		    public void mouseReleased(MouseEvent e) {
241
			calendar.add(field, amount);
242
			updatePopup();
243
		    }
244
		    public void mouseEntered(MouseEvent e) {
245
			label.setBorder(selectedBorder);
246
		    }
247
		    public void mouseExited(MouseEvent e) {
248
			label.setBorder(unselectedBorder);
249
		    }
250
		});
251
	    return label;
252
	}
253

  
254

  
255
	protected void initializePopup() {
256
	    JPanel header = new JPanel(); // used Box, but it wasn't Opaque
257
	    header.setLayout(new BoxLayout(header, BoxLayout.X_AXIS));
258
	    header.setBackground(background);
259
	    header.setOpaque(true);
260

  
261
	    JLabel label;
262
	    label = createUpdateButton(Calendar.YEAR, -1);
263
	    label.setText("<<");
264
	    label.setToolTipText(resource.getString("datecombobox.prevyear"));
265

  
266
	    header.add(Box.createHorizontalStrut(12));
267
	    header.add(label);
268
	    header.add(Box.createHorizontalStrut(12));
269

  
270
	    label = createUpdateButton(Calendar.MONTH, -1);
271
	    label.setText("<");
272
	    label.setToolTipText(resource.getString("datecombobox.prevmonth"));
273
	    header.add(label);
274

  
275
	    monthLabel = new JLabel("", JLabel.CENTER);
276
	    monthLabel.setForeground(foreground);
277
	    header.add(Box.createHorizontalGlue());
278
	    header.add(monthLabel);
279
	    header.add(Box.createHorizontalGlue());
280

  
281
	    label = createUpdateButton(Calendar.MONTH, 1);
282
	    label.setText(">");
283
	    label.setToolTipText(resource.getString("datecombobox.nextmonth"));
284
	    header.add(label);
285

  
286
	    label = createUpdateButton(Calendar.YEAR, 1);
287
	    label.setText(">>");
288
	    label.setToolTipText(resource.getString("datecombobox.nextyear"));
289

  
290
	    header.add(Box.createHorizontalStrut(12));
291
	    header.add(label);
292
	    header.add(Box.createHorizontalStrut(12));
293

  
294
	    popup = new JPopupMenu();
295
	    popup.setBorder(BorderFactory.createLineBorder(Color.black));
296
	    popup.setLayout(new BorderLayout());
297
	    popup.setBackground(background);
298
	    popup.addPopupMenuListener(this);
299
	    popup.add(BorderLayout.NORTH, header);
300
	}
301

  
302
	// update the Popup when either the month or the year of the calendar has been changed
303
	protected void updatePopup() {
304
	    monthLabel.setText( monthFormat.format(calendar.getTime()) );
305
	    if (days != null) {
306
		popup.remove(days);
307
	    }
308
	    days = new JPanel(new GridLayout(0, 7));
309
	    days.setBackground(background);
310
	    days.setOpaque(true);
311

  
312
	    Calendar setupCalendar = (Calendar) calendar.clone();
313
	    setupCalendar.set(Calendar.DAY_OF_WEEK, setupCalendar.getFirstDayOfWeek());
314
	    for (int i = 0; i < 7; i++) {
315
		int dayInt = setupCalendar.get(Calendar.DAY_OF_WEEK);
316
		JLabel label = new JLabel();
317
		label.setHorizontalAlignment(JLabel.CENTER);
318
		label.setForeground(foreground);
319
		if (dayInt == Calendar.SUNDAY) {
320
		    label.setText(resource.getString("datecombobox.sun"));
321
		} else if (dayInt == Calendar.MONDAY) {
322
		    label.setText(resource.getString("datecombobox.mon"));
323
		} else if (dayInt == Calendar.TUESDAY) {
324
		    label.setText(resource.getString("datecombobox.tue"));
325
		} else if (dayInt == Calendar.WEDNESDAY) {
326
		    label.setText(resource.getString("datecombobox.wed"));
327
		} else if (dayInt == Calendar.THURSDAY) {
328
		    label.setText(resource.getString("datecombobox.thu"));
329
		} else if (dayInt == Calendar.FRIDAY) {
330
		    label.setText(resource.getString("datecombobox.fri"));
331
		} else if (dayInt == Calendar.SATURDAY){
332
		    label.setText(resource.getString("datecombobox.sat"));
333
		}
334
		days.add(label);
335
		setupCalendar.roll(Calendar.DAY_OF_WEEK, true);
336
	    }
337

  
338
	    setupCalendar = (Calendar) calendar.clone();
339
	    setupCalendar.set(Calendar.DAY_OF_MONTH, 1);
340
	    int first = setupCalendar.get(Calendar.DAY_OF_WEEK);
341
	    for (int i = 0; i < (first - 1); i++) {
342
		days.add(new JLabel(""));
343
	    }
344
	    for (int i = 1; i <= setupCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); i++) {
345
		final int day = i;
346
		final JLabel label = new JLabel(String.valueOf(day));
347
		label.setHorizontalAlignment(JLabel.CENTER);
348
		label.setForeground(foreground);
349
		label.addMouseListener(new MouseListener() {
350
			public void mousePressed(MouseEvent e) {}
351
			public void mouseClicked(MouseEvent e) {}
352
			public void mouseReleased(MouseEvent e) {
353
			    label.setOpaque(false);
354
			    label.setBackground(background);
355
			    label.setForeground(foreground);
356
			    calendar.set(Calendar.DAY_OF_MONTH, day);
357
			    comboBox.setSelectedItem(dateFormat.format(calendar.getTime()));
358
			    // hide();
359
			    // hide is called with setSelectedItem() ... removeAll()
360
			    comboBox.requestFocus();
361
			}
362
			public void mouseEntered(MouseEvent e) {
363
			    label.setOpaque(true);
364
			    label.setBackground(selectedBackground);
365
			    label.setForeground(selectedForeground);
366
			}
367
			public void mouseExited(MouseEvent e) {
368
			    label.setOpaque(false);
369
			    label.setBackground(background);
370
			    label.setForeground(foreground);
371
			}
372
		    });
373

  
374
		days.add(label);
375
	    }
376

  
377
	    popup.add(BorderLayout.CENTER, days);
378
	    popup.pack();
379
	}
380
    }
381

  
382
    //////////////////////////////////////////////////////////////
383
    // This is only included to provide a sample GUI
384
    //////////////////////////////////////////////////////////////
385
    public static void main(String args[]) {
386
	JFrame f = new JFrame();
387
	Container c = f.getContentPane();
388
	c.setLayout(new FlowLayout());
389
	c.add(new JLabel("Date 1:"));
390
	c.add(new DateComboBox());
391
	c.add(new JLabel("Date 2:"));
392
	DateComboBox dcb = new DateComboBox();
393
	dcb.setEditable(true);
394
	c.add(dcb);
395
	f.addWindowListener(new WindowAdapter() {
396
		public void windowClosing(WindowEvent e) {
397
		    System.exit(0);
398
		}
399
	    });
400
	f.setSize(500, 200);
401
	f.show();
402
    }
403

  
404
}
405

  
406

  
407

  
408

  
409

  
0 410

  
trunk/libraries/libUI/src/de/ios/framework/swing/NumberField.java
1

  
2

  
3
/*
4
 * $Id$
5
 *
6
 * (c)1997 IoS Gesellschaft fr innovative Softwareentwicklung mbH
7
 * http://www.IoS-Online.de    mailto:info@IoS-Online.de
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License as
11
 * published by the Free Software Foundation; either version 2 of
12
 * the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
 * General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
 *
23
 */
24

  
25

  
26
package de.ios.framework.swing;
27

  
28
import java.math.BigInteger;
29
import java.awt.event.*;
30
import java.text.*;
31

  
32
import de.ios.framework.basic.*;
33

  
34

  
35
/**
36
 * Input-Field for Numbers, supported Objects: BigInteger, Long, Integer, (long)
37
 * Implementation of several Listener-Interfaces by the Basic-Class only for internal use!
38
 * For further description
39
 * @see IoSTextField
40
 * @version $Id$
41
 */
42
public class NumberField extends IoSTextField {
43

  
44

  
45
  /** Input-Field-Size in Columns. */
46
  public final static int DEFAULT_LENGTH = 10;
47

  
48
  /** Limited Character-Set of this Field. */
49
  private static final String NUMBER_CHARSET = "-0123456789TMtm";
50

  
51
  /** The Decimal-Format. */
52
  protected DecimalFormat decimalFormat = null;
53

  
54
  /** The Decimal-Format-Pattern. */
55
  protected String dformat = "0";
56

  
57

  
58
  /**
59
   * Default Constructor
60
   */
61
  public NumberField() {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff