Changeset 1358

Show
Ignore:
Timestamp:
07/16/08 13:41:34 (4 years ago)
Author:
eitan
Message:

merged a bug fix in alternatelistview from trunk into this branch

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  
    88import java.awt.event.ActionListener; 
    99import java.util.HashMap; 
    10 import java.util.Iterator; 
    1110import java.util.Map; 
    1211import javax.swing.*; 
     
    4847      buildControlPane(); 
    4948      buildViewPane(); 
    50       buildPickPane(); 
    5149 
    5250      setLayout(new BorderLayout()); 
     
    5452      add(_controlPane, BorderLayout.NORTH); 
    5553      add(_viewPane, BorderLayout.CENTER); 
    56       add(_pickPane, BorderLayout.SOUTH); 
    57  
    58       _pickPane.setVisible(false); 
     54 
    5955      stateChanged(null);  // setup initial state.. 
    6056      _leo.addChangeListener(this); 
     
    6763      _controlPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); 
    6864      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)); 
    7470      } 
    7571   } 
     
    173169   public void detach() 
    174170   { 
    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               } 
    184183            } 
    185184         } 
    186185      } 
    187       for (Iterator itr = _map.keySet().iterator(); itr.hasNext(); ) 
    188       { 
    189          String key = (String) itr.next(); 
     186      for (String key : _map.keySet()) 
     187      { 
    190188         EView view = (EView) _map.get(key); 
    191189         view.detach(); 
     
    199197   public void intervalRemoved(ListDataEvent e) {} 
    200198 
    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      } 
    204210   } 
    205211 
     
    210216      Command newCmd = _leo.command("New"); 
    211217      Command typeNewCmd = _leo.type().command("New"); 
    212       if (newCmd != null && !typeNewCmd.isForbidden(_leo.type())) 
     218      if (newCmd != null && typeNewCmd!=null && !typeNewCmd.isForbidden(_leo.type())) 
    213219      { 
    214220         CommandAdapter action = new CommandAdapter(newCmd, _leo, this);