Revision: 3842
Author: [email protected]
Date: Thu Aug  5 12:36:09 2010
Log: Fixed up the OS X build so that the app works nicely in OS X (ie can be assigned to spaces, can open files by DnD onto the Dock)
http://code.google.com/p/power-architect/source/detail?r=3842

Modified:
 /trunk/osx_packaging_utils/ca/sqlpower/architect/swingui/OSXAdapter.java
 /trunk/osx_packaging_utils/osx_adapter.jar
 /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java /trunk/src/main/java/ca/sqlpower/architect/swingui/action/OpenProjectAction.java

=======================================
--- /trunk/osx_packaging_utils/ca/sqlpower/architect/swingui/OSXAdapter.java Tue Mar 25 07:38:28 2008 +++ /trunk/osx_packaging_utils/ca/sqlpower/architect/swingui/OSXAdapter.java Thu Aug 5 12:36:09 2010
@@ -77,12 +77,14 @@
     private final Action quitAction;
     private final Action prefsAction;
     private final Action aboutAction;
+    private final Action openAction;


- private OSXAdapter (Action quitAction, Action prefsAction, Action aboutAction) { + private OSXAdapter (Action quitAction, Action prefsAction, Action aboutAction, Action openAction) {
         this.quitAction = quitAction;
         this.prefsAction = prefsAction;
         this.aboutAction = aboutAction;
+        this.openAction = openAction;
     }

// implemented handler methods. These are basically hooks into existing
@@ -123,18 +125,21 @@

     @Override
     public void handleOpenFile(ApplicationEvent ae) {
- throw new IllegalStateException("Drag'n'Drop files on the dock not supported yet.");
+        if (openAction != null) {
+            ae.setHandled(true);
+ openAction.actionPerformed(new ActionEvent(this, 0, "file:" + ae.getFilename()));
+        }
     }

// The main entry-point for this functionality. This is the only method
     // that needs to be called at runtime, and it can easily be done using
     // reflection (see MyApp.java)
- public static void registerMacOSXApplication(Action quitAction, Action prefsAction, Action aboutAction) { + public static void registerMacOSXApplication(Action quitAction, Action prefsAction, Action aboutAction, Action openAction) {
         if (theApplication == null) {
             theApplication = new com.apple.eawt.Application();
         }
         if (theAdapter == null) {
- theAdapter = new OSXAdapter(quitAction, prefsAction, aboutAction); + theAdapter = new OSXAdapter(quitAction, prefsAction, aboutAction, openAction);
         }
         theApplication.addApplicationListener(theAdapter);
     }
=======================================
--- /trunk/osx_packaging_utils/osx_adapter.jar  Fri Nov 10 12:39:01 2006
+++ /trunk/osx_packaging_utils/osx_adapter.jar  Thu Aug  5 12:36:09 2010
@@ -2,47 +2,38 @@
 s{j5  META-INF/PK
 r{j5P?{s^jMETA-INF/MANIFEST.MFóMÌËLK-.Ñ
 K-*ÎÌϳR0Ô3àårÌCq,HLÎHUŠ%ÍôŒx¹œ‹RKRSt*AêMõâ
-ÌtÍL4”

-rRœósJKR‹t<ó’õ”4y¹x¹PK
+rR<ó’õ4y¹x¹PK
 j{j5ca/PK
 q{j5ca/sqlpower/PK
 q{j5ca/sqlpower/architect/PK
 s{j5
 ca/sqlpower/architect/swingui/PK
s{j5­DE33Š.ca/sqlpower/architect/swingui/OSXAdapter.class”ßSÔVÇ¿ww%K6
-®ˆB•
-Ý%€ÑVÛVEÁŠ.¢ÃŒ#¾]’Dc“¬Ø¿¨Ïba§e¦}«3þQŽçÞ,4Së>ܓœœó9?÷~üôç_®â‘Ž3˜èÅ)LÊcJ
-—uظ¢áªŽ
-|WÁ÷¸¦áz?èèŏeüTÆt3ÒtVÃ
-
-ýág
-7u’·¤æ¶<æ4ÜaÐÓM1çò(1ƒÕt¸¼ö£pKÄ6M/Nj'[^°Ñòìå•g
-ÛY†Ò3Š| Ïá© çšnøÊ椶à[©ûjöú떗Î9�...@óÃßfd;ӒM%ŠÅz²oTákaëÀ¥ç†xéM†[nÎ_«ÊPºº‚ø›<p}1'£0Œ5¾ÿ¤Ê÷dæô˜±
-‘Pi™î  H}É^–#Üó|
-3‹
-/¡¦-qGv0߳иZF#N©ñ|ü©w
-œÃy#ò¨á¼†y°†eI¶ÌNȔ:U©ô¤ã=
-¿¸E†š²ô9•¾èûbƒû+)OÅÂ[GDYðÑ\ý3¦j¶ÉÏô3hù¾D>`¨ªyÆT“ú9ý·3¦
-ø!‹+ó1ߨõù8ŒÌujPbÒgÚ%Ó
-—f¦fҊ¢0N
-kþ*Òˆñ
-~ôpœÅCãk—WV5jà!š–dSGfü7Š
-9ýÚÿ¬íB"Òûª      .¥”­j6
-åµ”ÏìbNµ’Æ”œÚ«êá]eè˺÷XÄëaüJk
-b×
-P Óî¹ëæÒmʕdeõ/-þ¾™BQmjaÝÜ.,‰ 
-Qº[ÎЭuºœ=érn$«r••
-éȚ’
-r`ø–ÞLz+‘
-°Ú`ÖÄ
-ÖäŠÖÔJï 0Ö±ž¦�...@rÊú
-¥02qÚÅ1ù¼‡žu«ÈÚ�...@¹€ßp|½«U½Êßû˜‹]1Å
-¦xÆÈc.uÅ$¦˜a
-G`Žç1õÌ Š
-£+£ÒHÙô¢qЦijpQ†ÚF߉ë_mãä{ôm£úý{8µjML¶1ð
-Õm¥ÝÅéw
-Ì8¬fŒ1’gcú†w1˜yà3PK
+îüö¹ÏÜÙ¼~óç_.ã
+gp¥I\åáñð±†O𩊜q\Çg*nÄð¹
+_İÃMKq%†[
+—yËmž}Ʉ;*V4Œô»*¾Ò(æye•‡¯U¬)мm¹XOVyK˜µ'N¥¼+«¦¨ZÛ¶'-ϬíÚîVÝ6×
+[¹
+NðÎJű-áÙeWÁé¼UÞ1-ISŠ]Ïìø/åkOê¶·h¹#ùÇâ©xÍ`•r╪ܬµ“âb£\?Ü¢•+Òm?ô]·]Û»¡ îEú?ksD–Ê%I¶
+[rä"ËP0~OËO¥ëù{
+ž°~]•ûbÃ!ÈpY§ÊdUº–¬Q-ÁÚ=r„Œ
+Ö¨¼Û6ïHVå–]#—W
+Ŗwš
+—.c™FœHúÑÜ
+³X×qçuLóp‡œWqOÇ7¸¬`‚ë4Y²d­R}ͼ» â¾ŽoAê'ýLG+Ž#·„Cåxrù™%+‚©Sr)ÿˆRÂç¥ìZÊ­;#¿S0ÛUx.åŸï;éôÒ#;r)n“®ŒSG²
+^•NëfÝvJܳÑMò,§ã!Š:
+á{
+?ðÂ•}üyé8‹IéÿÚð\SZǏøIÇÏléÔñìÃûNsCLþK×P;Ô¤wÇ· D’‚ŽŠ]ÛxLzVòïÖï·Z¢»} Þ­Ëêf¹ºÃÄɱçùû Ñtïô‘lé"Û+¡k©u(| ‘·¤ÇÍìŠ
+jè‘tw.%żr0W0&J¥_òÜþ.[8û¾K×Nóµ&ÉÄeÿr”:ZnUºuLчï}nûèÓIÇN3„b‚¯§[ñB+ÎøQEˆ
+
+æèi†ž¢'Œ&#³1¿°‘ÝGÄHFö}þ£/)2­=KôÖŬñ;"/q6i çP‹FXi"öúCø
+Њ‰xúßÏ}È<„ÎõÓ<Ûô^ì        10
+CÇOôš‡À»¾mÀ5‚D_âR[a4
+`°ØÄPb¸D¦“i¿å
+†rý¸thÿ-¡xq£¯XÌqN½Àè
+Æ_aøÉ¢‘™Ï61ñã{þr¼¥tè$?¤ß݀˜%
+ÅñnâèD§ß3üPK
 s{j5  íAMETA-INF/PK
 r{j5P?{s^j¤'META-INF/MANIFEST.MFPK
 j{j5íA·ca/PK
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java Thu Aug 5 08:12:31 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java Thu Aug 5 12:36:09 2010
@@ -1526,6 +1526,10 @@
     public JMenuItem getEnterpriseLinkButton() {
         return enterpriseLinkButton;
     }
+
+    public OpenProjectAction getOpenProjectAction() {
+        return openProjectAction;
+    }

     public Action getOpenServerManagerAction() {
         return openServerManagerAction;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java Wed Aug 4 13:00:45 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java Thu Aug 5 12:36:09 2010
@@ -521,20 +521,22 @@
         Action exitAction = frame.getExitAction();
         PreferencesAction prefAction = frame.getPrefAction();
         AboutAction aboutAction = frame.getAboutAction();
+        Action openProjectAction = frame.getOpenProjectAction();

// Whether or not this is OS X, the three actions we're referencing must have been initialized by now. if (exitAction == null) throw new IllegalStateException("Exit action has not been initialized"); //$NON-NLS-1$ if (prefAction == null) throw new IllegalStateException("Prefs action has not been initialized"); //$NON-NLS-1$ if (aboutAction == null) throw new IllegalStateException("About action has not been initialized"); //$NON-NLS-1$ + if (openProjectAction == null) throw new IllegalStateException("Open Project action has not been initialized"); //$NON-NLS-1$

         if (context.isMacOSX()) {
             try {
Class<?> osxAdapter = ArchitectSwingSessionImpl.class.getClassLoader().loadClass("ca.sqlpower.architect.swingui.OSXAdapter"); //$NON-NLS-1$

- // The main registration method. Takes quitAction, prefsAction, aboutAction. - Class<?>[] defArgs = { Action.class, Action.class, Action.class }; + // The main registration method. Takes quitAction, prefsAction, aboutAction, openAction. + Class<?>[] defArgs = { Action.class, Action.class, Action.class, Action.class }; Method registerMethod = osxAdapter.getDeclaredMethod("registerMacOSXApplication", defArgs); //$NON-NLS-1$
-                Object[] args = { exitAction, prefAction, aboutAction };
+ Object[] args = { exitAction, prefAction, aboutAction, openProjectAction };
                 registerMethod.invoke(osxAdapter, args);

                 // The enable prefs method.  Takes a boolean.
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/action/OpenProjectAction.java Wed Jul 28 09:52:56 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/action/OpenProjectAction.java Thu Aug 5 12:36:09 2010
@@ -103,17 +103,24 @@
     }

     public void actionPerformed(ActionEvent e) {
- JFileChooser chooser = new JFileChooser(getSession().getRecentMenu().getMostRecentFile());
-        chooser.addChoosableFileFilter(SPSUtils.ARCHITECT_FILE_FILTER);
-        int returnVal = chooser.showOpenDialog(frame);
-        if (returnVal == JFileChooser.APPROVE_OPTION) {
-            File f = chooser.getSelectedFile();
-            try {
- fileLoader.openAsynchronously(getSession().getContext().createSession(), f, getSession());
-            } catch (SQLObjectException ex) {
- SPSUtils.showExceptionDialogNoReport(getSession().getArchitectFrame(), - Messages.getString("OpenProjectAction.failedToOpenProjectFile"), ex); //$NON-NLS-1$
-            }
+        File f;
+        if (!e.getActionCommand().startsWith("file:")) {
+ JFileChooser chooser = new JFileChooser(getSession().getRecentMenu().getMostRecentFile());
+            chooser.addChoosableFileFilter(SPSUtils.ARCHITECT_FILE_FILTER);
+            int returnVal = chooser.showOpenDialog(frame);
+            if (returnVal == JFileChooser.APPROVE_OPTION) {
+                f = chooser.getSelectedFile();
+            } else {
+                return;
+            }
+        } else {
+            f = new File(e.getActionCommand().substring("file:".length()));
+        }
+        try {
+ fileLoader.openAsynchronously(getSession().getContext().createSession(), f, getSession());
+        } catch (SQLObjectException ex) {
+ SPSUtils.showExceptionDialogNoReport(getSession().getArchitectFrame(), + Messages.getString("OpenProjectAction.failedToOpenProjectFile"), ex); //$NON-NLS-1$
         }
     }

Reply via email to