Changeset 1358
- Timestamp:
- 07/16/08 13:41:34 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
jmatter-complet/branches/TRY-JPA/modules/swingvm/src/com/u2d/view/swing/list/AlternateListView.java
r1347 r1358 8 8 import java.awt.event.ActionListener; 9 9 import java.util.HashMap; 10 import java.util.Iterator;11 10 import java.util.Map; 12 11 import javax.swing.*; … … 48 47 buildControlPane(); 49 48 buildViewPane(); 50 buildPickPane();51 49 52 50 setLayout(new BorderLayout()); … … 54 52 add(_controlPane, BorderLayout.NORTH); 55 53 add(_viewPane, BorderLayout.CENTER); 56 add(_pickPane, BorderLayout.SOUTH); 57 58 _pickPane.setVisible(false); 54 59 55 stateChanged(null); // setup initial state.. 60 56 _leo.addChangeListener(this); … … 67 63 _controlPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); 68 64 Icon icon, rolloverIcon; 69 for ( int i=0; i<_viewNames.length; i++)70 { 71 icon = icon( _viewNames[i]);72 rolloverIcon = rolloverIcon( _viewNames[i]);73 _controlPane.add(button(icon, rolloverIcon, _viewNames[i]));65 for (String viewName : _viewNames) 66 { 67 icon = icon(viewName); 68 rolloverIcon = rolloverIcon(viewName); 69 _controlPane.add(button(icon, rolloverIcon, viewName)); 74 70 } 75 71 } … … 173 169 public void detach() 174 170 { 175 for (int i=0; i<_pickPane.getComponentCount(); i++) 176 { 177 Component c = _pickPane.getComponent(i); 178 if (c instanceof JButton) 179 { 180 Action action = ((JButton) c).getAction(); 181 if (action instanceof CommandAdapter) 182 { 183 ((CommandAdapter) action).detach(); 171 if (_pickPane != null) 172 { 173 for (int i=0; i<_pickPane.getComponentCount(); i++) 174 { 175 Component c = _pickPane.getComponent(i); 176 if (c instanceof JButton) 177 { 178 Action action = ((JButton) c).getAction(); 179 if (action instanceof CommandAdapter) 180 { 181 ((CommandAdapter) action).detach(); 182 } 184 183 } 185 184 } 186 185 } 187 for (Iterator itr = _map.keySet().iterator(); itr.hasNext(); ) 188 { 189 String key = (String) itr.next(); 186 for (String key : _map.keySet()) 187 { 190 188 EView view = (EView) _map.get(key); 191 189 view.detach(); … … 199 197 public void intervalRemoved(ListDataEvent e) {} 200 198 201 public void stateChanged(ChangeEvent e) 202 { 203 _pickPane.setVisible(_leo.isPickState()); 199 public synchronized void stateChanged(ChangeEvent e) 200 { 201 if (_leo.isPickState() && _pickPane == null) 202 { 203 buildPickPane(); 204 add(_pickPane, BorderLayout.SOUTH); 205 } 206 if (_pickPane != null) 207 { 208 _pickPane.setVisible(_leo.isPickState()); 209 } 204 210 } 205 211 … … 210 216 Command newCmd = _leo.command("New"); 211 217 Command typeNewCmd = _leo.type().command("New"); 212 if (newCmd != null && !typeNewCmd.isForbidden(_leo.type()))218 if (newCmd != null && typeNewCmd!=null && !typeNewCmd.isForbidden(_leo.type())) 213 219 { 214 220 CommandAdapter action = new CommandAdapter(newCmd, _leo, this);
