• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.clients
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Change
  • Next Change →

Changeset 5526 for branches/OmeroEditor/src/ui/formFields/FormField.java

Show
Ignore:
Timestamp:
07/04/08 11:49:37 (5 months ago)
Author:
will
Message:

Text-changed and focus listeners for text fields, which update the dataField with new values, have been extracted into a new class, AttributeEditorListeners?, used by (eg) AttributeTextEditor? and AttributeTextAreaEditor?

Files:
1 modified

  • branches/OmeroEditor/src/ui/formFields/FormField.java (modified) (7 diffs)

Legend:

Unmodified
Added
Removed
  • branches/OmeroEditor/src/ui/formFields/FormField.java

    r5483 r5526  
    6969// Subclasses have eg TextFields etc 
    7070 
    71 public abstract class FormField extends JPanel implements DataFieldObserver{ 
     71public abstract class FormField  
     72        extends JPanel  
     73        implements DataFieldObserver{ 
    7274         
    7375        IDataFieldObservable dataFieldObs; 
    … …  
    8486        public static final String HAS_FOCUS = "hasFocus"; 
    8587         
    86         boolean textChanged = false; 
    87         TextChangedListener textChangedListener = new TextChangedListener(); 
    88         FocusListener focusChangedListener = new FocusChangedListener(); 
     88        /** 
     89         * Add this listener to various buttons etc, so that if they are clicked. 
     90         * this field will become selected. 
     91         */ 
    8992        FocusListener componentFocusListener = new FormFieldComponentFocusListener(); 
    9093         
    … …  
    128131        Icon spacerIcon;                // A blank icon to replace collapsedIcon if there are no children. 
    129132         
    130         // used in Diff (comparing two trees), to get a ref to all components, to colour red if different! 
    131         ArrayList<JComponent> visibleAttributes = new ArrayList<JComponent>(); 
    132133                 
    133134        boolean showDescription = false;        // not saved, just used to toggle 
    … …  
    205206                descriptionLabel = new JLabel(); 
    206207                descriptionLabel.setBackground(null); 
    207                 visibleAttributes.add(descriptionLabel); 
     208                 
    208209                infoIcon = ImageFactory.getInstance().getIcon(ImageFactory.INFO_ICON); 
    209210                descriptionButton = new JButton(infoIcon); 
    … …  
    559560                        if(evt.getPropertyName().equals(FormField.HAS_FOCUS)) { 
    560561                                panelClicked(true); 
     562                                System.out.println("FormField. FocusGainedPropertyChangedListener"); 
    561563                        } 
    562564                } 
    … …  
    761763        } 
    762764 
    763         public ArrayList<JComponent> getVisibleAttributes() { 
    764                 return visibleAttributes; 
    765         } 
    766765         
    767766        private String addHtmlTagsForNameLabel(String text) { 
    … …  
    770769        } 
    771770         
    772          
    773         public class TextChangedListener implements KeyListener { 
    774                  
    775                 public void keyTyped(KeyEvent event) { 
    776                         textChanged = true;             // some character was typed, so set this flag 
    777                 } 
    778                 public void keyPressed(KeyEvent event) {} 
    779                 public void keyReleased(KeyEvent event) {} 
    780          
    781         } 
    782          
    783         public class FocusChangedListener implements FocusListener { 
    784                  
    785                 public void focusLost(FocusEvent event) { 
    786                         if (textChanged) { 
    787                                 JTextComponent source = (JTextComponent)event.getSource(); 
    788                                  
    789                                 setDataFieldAttribute(source.getName(), source.getText(), true); 
    790                                  
    791                                 textChanged = false; 
    792                         } 
    793                 } 
    794                 public void focusGained(FocusEvent event) {} 
    795         } 
    796          
    797  
    798771        // called to update dataField with attribute 
    799772        protected void setDataFieldAttribute(String attributeName, String value, boolean notifyUndoRedo) { 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/