/[schmitzm]/trunk/src/skrueger/swing/DialogManager.java
ViewVC logotype

Diff of /trunk/src/skrueger/swing/DialogManager.java

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

branches/2.0-RC1/src/skrueger/swing/DialogManager.java revision 604 by alfonx, Wed Dec 9 14:15:53 2009 UTC trunk/src/skrueger/swing/DialogManager.java revision 1041 by alfonx, Wed Sep 22 10:56:20 2010 UTC
# Line 17  public abstract class DialogManager<KEY, Line 17  public abstract class DialogManager<KEY,
17          public abstract class FactoryInterface {          public abstract class FactoryInterface {
18    
19                  public abstract DIALOG create();                  public abstract DIALOG create();
20                    
21                  /** May be overridden to add Listeners **/                  /** May be overridden to add Listeners **/
22                  public void afterCreation(DIALOG newInstance){};                  public void afterCreation(DIALOG newInstance) {
23                    };
24    
25                  /** May be overridden to remove Listeners added earlier **/                  /** May be overridden to remove Listeners added earlier **/
26                  public void beforeDispose(DIALOG newInstance){};                  public void beforeDispose(DIALOG newInstance) {
27                    };
28    
29          }          }
30    
# Line 43  public abstract class DialogManager<KEY, Line 45  public abstract class DialogManager<KEY,
45           * @return           * @return
46           */           */
47          protected DIALOG bringup(DIALOG dialog) {          protected DIALOG bringup(DIALOG dialog) {
48                    if (dialog == null){
49                            // The dialog creation may have been cancelled
50                            return null;
51                    }
52                  if (!dialog.isVisible())                  if (!dialog.isVisible())
53                          dialog.setVisible(true);                          dialog.setVisible(true);
54                  dialog.toFront();                  dialog.toFront();
# Line 51  public abstract class DialogManager<KEY, Line 57  public abstract class DialogManager<KEY,
57          }          }
58    
59          /**          /**
60             * Implementing this should have a <br/>
61             * <code>try { ... return ... } catch (Exception e) {
62                                    ExceptionDialog.show(owner, e);
63                                    return null;
64                            } </code> block.
65             *
66           * @param key           * @param key
67           * @param owner           * @param owner
68           * @param constArgs           * @param constArgs
69           * @return a cached instance or creates a new instance. Instances are always retuned visible and toFront.           * @return a cached instance or creates a new instance. Instances are always
70             *         returned visible and toFront.
71           */           */
72          public abstract DIALOG getInstanceFor(final KEY key, final Component owner,          public abstract DIALOG getInstanceFor(final KEY key, final Component owner,
73                          final Object... constArgs);                          final Object... constArgs);
# Line 115  public abstract class DialogManager<KEY, Line 128  public abstract class DialogManager<KEY,
128                  } else {                  } else {
129    
130                          dialog = factory.create();                          dialog = factory.create();
131                            if (dialog.isDisposed) {
132                                    // The creation of the Dialog may have been cancelled for some reason
133                                    return null;
134                            }
135                          dialogCache.put(key, dialog);                          dialogCache.put(key, dialog);
136                          dialog.setVisible(true);                          dialog.setVisible(true);
137                          dialog.toFront();                          dialog.toFront();
# Line 122  public abstract class DialogManager<KEY, Line 139  public abstract class DialogManager<KEY,
139                          dialog.addWindowListener(new WindowAdapter() {                          dialog.addWindowListener(new WindowAdapter() {
140                                  @Override                                  @Override
141                                  public void windowClosed(final WindowEvent e) {                                  public void windowClosed(final WindowEvent e) {
142                                          dialog.setVisible(false);                                          dialogCache.remove(key);
143                                          factory.beforeDispose(dialog);                                          factory.beforeDispose(dialog);
144                                          disposeInstanceFor(key);                                  }
145    
146                                    @Override
147                                    public void windowClosing(final WindowEvent e) {
148                                  }                                  }
149                          });                          });
150                            
151                          factory.afterCreation(dialog);                          factory.afterCreation(dialog);
152                  }                  }
                   
153    
154                  return dialog;                  return dialog;
155          }          }
# Line 163  public abstract class DialogManager<KEY, Line 182  public abstract class DialogManager<KEY,
182                  return dialogCache.values();                  return dialogCache.values();
183          }          }
184    
   
185  }  }

Legend:
Removed from v.604  
changed lines
  Added in v.1041

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26