Field

Changeset 144:d6db753b7c78

Show
Ignore:
Timestamp:
08/02/2008 10:18:23 AM (4 months ago)
Author:
marc@f1.local
branch:
default
Message:

tweaked focus policy for bug #90

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • development/java/field/core/ui/FloatingPalettes.java

    r78 r144  
    11package field.core.ui; 
    22 
     3import java.awt.Component; 
    34import java.awt.Frame; 
     5import java.awt.KeyboardFocusManager; 
    46import java.awt.Window; 
    57import java.awt.event.WindowEvent; 
    68import java.awt.event.WindowListener; 
    79import java.lang.ref.WeakReference; 
    8 import java.nio.channels.OverlappingFileLockException; 
    910import java.util.ArrayList; 
    1011import java.util.List; 
    1112 
    12 import javax.swing.JFrame
    13  
     13import field.bytecode.protect.Woven
     14import field.bytecode.protect.annotations.NextUpdate; 
    1415import field.core.ui.Quaqua15TigerLookAndFeelField.ToolPalette; 
    15 import field.graphics.windowing.OverlayCanvas; 
    1616import field.launch.Launcher; 
    1717import field.launch.iUpdateable; 
     
    2222        static List<WeakReference<Frame>> palettes = new ArrayList<WeakReference<Frame>>(); 
    2323        static MutableFloat in = new MutableFloat(0); 
    24          
     24 
    2525        static public boolean suspendRegistration = false; 
    2626 
    2727        static public void registerFloatingPalette(Frame frame) { 
    28                 if (suspendRegistration) return; 
    29                  
     28                if (suspendRegistration) 
     29                        return; 
     30 
    3031                palettes.add(new WeakReference<Frame>(frame)); 
    3132                frame.addWindowListener(new WindowListener() { 
     
    3334                        List<WeakReference<Frame>> palettes = FloatingPalettes.palettes; 
    3435                        MutableFloat in = FloatingPalettes.in; 
    35                          
     36 
    3637                        public void windowActivated(WindowEvent e) { 
    3738                                if (e.getOppositeWindow() != null && (e.getOppositeWindow().getClass().getName().contains("OverlayCanvas") || e.getOppositeWindow().getClass().getName().contains("PopupInfoWindow"))) { 
     
    4950 
    5051                        public void windowDeactivated(WindowEvent e) { 
    51                                 if (e.getOppositeWindow() != null && (e.getOppositeWindow().getClass().getName().contains("OverlayCanvas") || e.getOppositeWindow().getClass().getName().contains("PopupInfoWindow"))) { 
     52                                if (e.getOppositeWindow() != null && (e.getOppositeWindow().getClass().getName().contains("OverlayCanvas") || e.getOppositeWindow().getClass().getName().contains("PopupInfoWindow"))) { 
    5253                                } else if (palletteOf(e.getOppositeWindow(), palettes)) { 
    5354                                } else { 
     
    7172 
    7273                FloatingPalettes.palettes = new ArrayList<WeakReference<Frame>>(); 
    73                 FloatingPalettes.in= new MutableFloat(1); 
     74                FloatingPalettes.in = new MutableFloat(1); 
    7475 
    7576                Launcher.getLauncher().registerUpdateable(new iUpdateable() { 
    7677                        List<WeakReference<Frame>> palettes = FloatingPalettes.palettes; 
    7778                        MutableFloat in = FloatingPalettes.in; 
    78                          
     79 
     80                        boolean edge = false; 
     81 
     82                        Component focus = null; 
     83 
    7984                        public void update() { 
    8085                                if (in.d > 0) { 
     86                                        if (!edge) { 
     87                                                restoreFocus(focus); 
     88                                        } 
     89                                        Component focus2 = saveFocus(); 
     90                                        if (focus2 != null) 
     91                                                focus = focus2; 
     92                                        edge = true; 
    8193                                        moveIn(palettes); 
    82                                 } else 
     94                                } else { 
     95                                        if (edge) { 
     96                                        } 
     97                                        edge = false; 
    8398                                        moveOut(palettes); 
     99                                } 
    84100                                if (in.d < 0) 
    85101                                        in.d = 0; 
     
    87103                                        in.d = 1; 
    88104                        } 
     105 
     106                        @Woven 
     107                        @NextUpdate(delay = 5) 
     108                        private void restoreFocus(final Component focus2) { 
     109                                if (focus2 != null) { 
     110                                        // completely crazy! Why do I have to 
     111                                        // keep asking for the focus until I get 
     112                                        // it? 
     113                                        Launcher.getLauncher().registerUpdateable(new iUpdateable() { 
     114 
     115                                                int n = 0; 
     116 
     117                                                public void update() { 
     118 
     119                                                        n++; 
     120                                                        focus2.requestFocus(); 
     121                                                        if (focus2.isFocusOwner() || n > 5) { 
     122                                                                Launcher.getLauncher().deregisterUpdateable(this); 
     123                                                        } 
     124                                                } 
     125                                        }); 
     126                                } 
     127                        } 
     128 
     129                        private Component saveFocus() { 
     130                                return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); 
     131                        } 
    89132                }); 
    90                  
     133 
    91134                FloatingPalettes.palettes.add(new WeakReference<Frame>(frame)); 
    92135                frame.addWindowListener(new WindowListener() { 
     
    96139 
    97140                        public void windowActivated(WindowEvent e) { 
    98                                 if (e.getOppositeWindow() != null && (e.getOppositeWindow().getClass().getName().contains("OverlayCanvas") || e.getOppositeWindow().getClass().getName().contains("PopupInfoWindow"))) { 
     141                                if (e.getOppositeWindow() != null && (e.getOppositeWindow().getClass().getName().contains("OverlayCanvas") || e.getOppositeWindow().getClass().getName().contains("PopupInfoWindow"))) { 
    99142                                } else if (palletteOf(e.getOppositeWindow(), palettes)) { 
    100143                                } else { 
    101144                                        in.d++; 
    102145                                } 
     146// 
     147//                              if (e.getOppositeWindow()!=null) 
     148//                              { 
     149//                                      System.out.println(" oposite is <"+e.getOppositeWindow()+"> <"+e.getSource()+">"); 
     150//                              } 
    103151                        } 
    104152 
     
    110158 
    111159                        public void windowDeactivated(WindowEvent e) { 
    112                                 if (e.getOppositeWindow() != null && (e.getOppositeWindow().getClass().getName().contains("OverlayCanvas") || e.getOppositeWindow().getClass().getName().contains("PopupInfoWindow"))) { 
     160                                if (e.getOppositeWindow() != null && (e.getOppositeWindow().getClass().getName().contains("OverlayCanvas") || e.getOppositeWindow().getClass().getName().contains("PopupInfoWindow"))) { 
    113161                                } else if (palletteOf(e.getOppositeWindow(), palettes)) { 
    114162                                } else { 
  • development/java/field/core/ui/Quaqua15TigerLookAndFeelField.java

    r81 r144  
    7474                float lastOpacity = -1f; 
    7575 
     76                boolean hadFocusOnHide = false; 
    7677 
    7778                public ToolPalette(String title) throws HeadlessException { 
     
    101102                                        if (opacity < 1e-2 && opacity<lastOpacity) 
    102103                                                if (ToolPalette.super.isVisible()) 
     104                                                { 
    103105                                                        ToolPalette.super.show(false); 
     106                                                } 
    104107                                        if (opacity > 1e-2 && opacity>lastOpacity) 
    105108                                                if (!ToolPalette.super.isVisible()) 
     109                                                { 
    106110                                                        ToolPalette.super.show(true); 
     111                                                } 
    107112 
    108113                                        if (Math.abs(lastOpacity-opacity)>0.01 || (opacity==0 && lastOpacity!=0) || (opacity==1 && lastOpacity!=1)) 
  • development/java/field/core/ui/text/BaseTextEditor2.java

    r143 r144  
    617617                        } 
    618618 
     619                        @Override 
     620                        public boolean isFocusable() { 
     621                                return true; 
     622                        } 
    619623                }; 
    620624 
  • distribution/application/field.app/Contents/Info.plist

    r86 r144  
    145145                        <key>forceNativeBuffers</key> 
    146146                        <string>1</string> 
     147                        <key>java.library.path</key> 
     148                        <string>$JAVAROOT:$JAVAROOT/../../../../extensions/</string> 
    147149                        <key>java.source.paths</key> 
    148150                        <string>$JAVAROOT/../../../../../../development/java:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/src.jar</string> 
     
    167169                </dict> 
    168170                <key>VMOptions</key> 
    169                 <string>-Xms500m -Xmx2000m -noverify -XX:ReservedCodeCacheSize 50m -XX:+UseDefaultStackSize -Xss256K</string> 
     171                <string>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n -Xms500m -Xmx2000m -noverify -XX:ReservedCodeCacheSize 50m -XX:+UseDefaultStackSize -Xss256K</string> 
    170172                <key>WorkingDirectory</key> 
    171173                <string>$APP_PACKAGE/Contents/Resources/Java</string>