/[schmitzm]/trunk/src/skrueger/i8n/Translation.java
ViewVC logotype

Diff of /trunk/src/skrueger/i8n/Translation.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 244 by alfonx, Wed Jul 29 09:33:33 2009 UTC revision 292 by alfonx, Wed Aug 5 12:34:15 2009 UTC
# Line 2  Line 2 
2   * Copyright (c) 2009 Martin O. J. Schmitz.   * Copyright (c) 2009 Martin O. J. Schmitz.
3   *   *
4   * This file is part of the SCHMITZM library - a collection of utility   * This file is part of the SCHMITZM library - a collection of utility
5   * classes based on Java 1.6, focussing (not only) on Java Swing   * classes based on Java 1.6, focusing (not only) on Java Swing
6   * and the Geotools library.   * and the Geotools library.
7   *   *
8   * The SCHMITZM project is hosted at:   * The SCHMITZM project is hosted at:
# Line 29  Line 29 
29   ******************************************************************************/   ******************************************************************************/
30  package skrueger.i8n;  package skrueger.i8n;
31    
32    import java.awt.event.ActionEvent;
33    import java.awt.event.ActionListener;
34  import java.beans.PropertyChangeEvent;  import java.beans.PropertyChangeEvent;
35  import java.beans.PropertyChangeListener;  import java.beans.PropertyChangeListener;
36  import java.util.ArrayList;  import java.util.ArrayList;
37  import java.util.HashMap;  import java.util.HashMap;
38  import java.util.List;  import java.util.List;
39  import java.util.Locale;  import java.util.Locale;
40    import java.util.Random;
41    
42  import javax.swing.JComponent;  import javax.swing.JComponent;
 import javax.swing.JTable;  
43    
44  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
45    
# Line 54  public class Translation extends HashMap Line 56  public class Translation extends HashMap
56          public static final String NO_TRANSLATION = "NO TRANSLATION";          public static final String NO_TRANSLATION = "NO TRANSLATION";
57          public static final String DEFAULT_KEY = "default";          public static final String DEFAULT_KEY = "default";
58          static final Logger log = Logger.getLogger(Translation.class);          static final Logger log = Logger.getLogger(Translation.class);
59          static String activeLang = "fr";          static String activeLang = Locale.getDefault().getLanguage();
60    
61          static protected List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();          static protected List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
62    
# Line 68  public class Translation extends HashMap Line 70  public class Translation extends HashMap
70                  setActiveLang(locale.getLanguage());                  setActiveLang(locale.getLanguage());
71          }          }
72    
73            private List<ActionListener> actionListeners = new ArrayList<ActionListener>();
74    
75          @Override          @Override
76          /*          /*
77           * @comment To make a copy of a translation see methods toOneLine() and           * @comment To make a copy of a translation see methods toOneLine() and
# Line 303  public class Translation extends HashMap Line 307  public class Translation extends HashMap
307                  }                  }
308          }          }
309    
310            public void addTranslationChangeListener(ActionListener actionListener) {
311                    actionListeners.add(actionListener);
312            }
313            
314            public boolean removeTranslationChangeListener(ActionListener actionListener) {
315                    return actionListeners.remove(actionListener);
316            }
317    
318            public void fireTranslationChangedEvents() {
319                    ActionEvent ae = new ActionEvent(this, new Random().nextInt(),  "");
320                    
321                    for (ActionListener al : actionListeners) {
322                            al.actionPerformed( ae);
323                    }
324            }
325            
326            @Override
327            public String put(String key, String value) {
328                    String result = super.put(key, value);
329                    fireTranslationChangedEvents();
330                    return result;
331            }
332            
333            
334  }  }

Legend:
Removed from v.244  
changed lines
  Added in v.292

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26