directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1203174 - in /directory/studio/trunk: ./ application/application-macosx-x86/ application/application-macosx-x86_64/ plugins/ plugins/rcp.fullscreen/ plugins/rcp.fullscreen/src/ plugins/rcp.fullscreen/src/main/ plugins/rcp.fullscreen/src/ma...
Date Thu, 17 Nov 2011 12:48:31 GMT
Author: pamarcelot
Date: Thu Nov 17 12:48:31 2011
New Revision: 1203174

URL: http://svn.apache.org/viewvc?rev=1203174&view=rev
Log:
Part of a fix for DIRSTUDIO-746 (Add support for the Full Screen feature of OS X Lion).
Basic functionality is working but there's still a weird empty gray bar on top of the window.

Added:
    directory/studio/trunk/plugins/rcp.fullscreen/
    directory/studio/trunk/plugins/rcp.fullscreen/plugin.xml
    directory/studio/trunk/plugins/rcp.fullscreen/pom.xml
    directory/studio/trunk/plugins/rcp.fullscreen/src/
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Activator.java
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/BnLWindow.java
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/SO.java
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Startup.java
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenEscapeHandler.java
    directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenHandler.java
Modified:
    directory/studio/trunk/application/application-macosx-x86/pom.xml
    directory/studio/trunk/application/application-macosx-x86_64/pom.xml
    directory/studio/trunk/plugins/pom.xml
    directory/studio/trunk/pom.xml

Modified: directory/studio/trunk/application/application-macosx-x86/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/application/application-macosx-x86/pom.xml?rev=1203174&r1=1203173&r2=1203174&view=diff
==============================================================================
--- directory/studio/trunk/application/application-macosx-x86/pom.xml (original)
+++ directory/studio/trunk/application/application-macosx-x86/pom.xml Thu Nov 17 12:48:31
2011
@@ -155,6 +155,10 @@
                   <groupId>org.eclipse.swt.cocoa</groupId>
                   <artifactId>macosx</artifactId>
                 </artifactItem>
+                <artifactItem>
+                  <groupId>org.apache.directory.studio</groupId>
+                  <artifactId>rcp.fullscreen</artifactId>
+                </artifactItem>
               </artifactItems>
             </configuration>
           </execution>

Modified: directory/studio/trunk/application/application-macosx-x86_64/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/application/application-macosx-x86_64/pom.xml?rev=1203174&r1=1203173&r2=1203174&view=diff
==============================================================================
--- directory/studio/trunk/application/application-macosx-x86_64/pom.xml (original)
+++ directory/studio/trunk/application/application-macosx-x86_64/pom.xml Thu Nov 17 12:48:31
2011
@@ -155,6 +155,10 @@
                   <groupId>org.eclipse.swt.cocoa.macosx</groupId>
                   <artifactId>x86_64</artifactId>
                 </artifactItem>
+                <artifactItem>
+                  <groupId>org.apache.directory.studio</groupId>
+                  <artifactId>rcp.fullscreen</artifactId>
+                </artifactItem>
               </artifactItems>
             </configuration>
           </execution>

Modified: directory/studio/trunk/plugins/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/pom.xml?rev=1203174&r1=1203173&r2=1203174&view=diff
==============================================================================
--- directory/studio/trunk/plugins/pom.xml (original)
+++ directory/studio/trunk/plugins/pom.xml Thu Nov 17 12:48:31 2011
@@ -53,6 +53,7 @@
     <module>ldifeditor</module>
     <module>ldifparser</module>
     <module>rcp</module>
+    <module>rcp.fullscreen</module>
     <module>schemaeditor</module>
     <module>valueeditors</module>
   </modules>

Added: directory/studio/trunk/plugins/rcp.fullscreen/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/rcp.fullscreen/plugin.xml?rev=1203174&view=auto
==============================================================================
--- directory/studio/trunk/plugins/rcp.fullscreen/plugin.xml (added)
+++ directory/studio/trunk/plugins/rcp.fullscreen/plugin.xml Thu Nov 17 12:48:31 2011
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.eclipse.ui.startup">
+      <startup
+            class="org.apache.directory.studio.rcp.fullscreen.Startup"></startup>
+   </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <command
+            defaultHandler="org.apache.directory.studio.rcp.fullscreen.ToggleFullScreenHandler"
+            id="org.apache.directory.studio.rcp.fullscreen.ToggleFullScreen"
+            name="Toggle Full Screen">
+      </command>
+      <command
+            defaultHandler="org.apache.directory.studio.rcp.fullscreen.ToggleFullScreenEscapeHandler"
+            id="org.apache.directory.studio.rcp.fullscreen.ToggleFullScreenEscape"
+            name="ToggleFullScreenEscape">
+      </command>
+   </extension>
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            allPopups="false"
+            locationURI="menu:window?after=newEditor">
+                           <command
+                                 commandId="org.apache.directory.studio.rcp.fullscreen.ToggleFullScreen"
+                                 label="Toggle Full Screen"/>
+      </menuContribution>
+   </extension>
+   <extension
+         point="org.eclipse.ui.bindings">
+      <key
+            commandId="org.apache.directory.studio.rcp.fullscreen.ToggleFullScreenEscape"
+            contextId="org.eclipse.ui.contexts.window"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            sequence="Esc">
+      </key>
+   </extension>
+
+</plugin>

Added: directory/studio/trunk/plugins/rcp.fullscreen/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/rcp.fullscreen/pom.xml?rev=1203174&view=auto
==============================================================================
--- directory/studio/trunk/plugins/rcp.fullscreen/pom.xml (added)
+++ directory/studio/trunk/plugins/rcp.fullscreen/pom.xml Thu Nov 17 12:48:31 2011
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!--
+  @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.directory.studio</groupId>
+    <artifactId>parent-plugins</artifactId>
+    <version>2.0.0-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>rcp.fullscreen</artifactId>
+  <name>Apache Directory Studio RCP Fullscreen for OS X Lion</name>
+  <packaging>jar</packaging>
+
+  <description />
+  
+  <build>
+    <resources>
+      <resource>
+        <directory>.</directory>
+        <includes>
+          <include>plugin.properties</include>
+          <include>plugin.xml</include>
+          <include>about.ini</include>
+          <include>studio.png</include>
+        </includes>
+        <filtering>true</filtering>
+      </resource>
+      <resource>
+        <directory>resources</directory>
+        <targetPath>resources</targetPath>
+      </resource>
+      <resource>
+        <directory>src/main/resources</directory>
+      </resource>
+      <resource>
+        <directory>src/main/java</directory>
+        <includes>
+          <include>**/*.properties</include>
+        </includes>
+      </resource>
+    </resources>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <configuration>
+          <skip>false</skip>
+          <pde>true</pde>
+          <projectnatures>
+            <projectnature>org.eclipse.jem.workbench.JavaEMFNature</projectnature>
+            <projectnature>org.eclipse.pde.PluginNature</projectnature>
+            <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+            <projectnature>org.eclipse.jem.beaninfo.BeanInfoNature</projectnature>
+          </projectnatures>
+          <classpathContainers>
+            <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
+            <classpathContainer>org.eclipse.pde.core.requiredPlugins</classpathContainer>
+          </classpathContainers>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.directory.studio</groupId>
+        <artifactId>studio-maven-plugin</artifactId>
+        <configuration>
+          <skip>false</skip>
+          <createManifest>true</createManifest>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>prepare-jar-package</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestFile>META-INF/MANIFEST.MF</manifestFile>
+            <addMavenDescriptor>false</addMavenDescriptor>
+          </archive>
+        </configuration>
+      </plugin>
+     <!-- MANIFEST.MF Generation -->
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <manifestLocation>META-INF</manifestLocation>
+          <instructions>            
+            <Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton:=true</Bundle-SymbolicName>
+            <Bundle-Localization>plugin</Bundle-Localization>
+            <Eclipse-LazyStart>true</Eclipse-LazyStart>
+            <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
+            <Embed-Directory>lib</Embed-Directory>
+            <Embed-StripGroup>true</Embed-StripGroup>
+            <Embed-Transitive>true</Embed-Transitive>
+            <Bundle-Activator>org.apache.directory.studio.rcp.fullscreen.Activator</Bundle-Activator>
+            <Require-Bundle>org.eclipse.core.runtime,
+ org.eclipse.ui</Require-Bundle>
+            <Export-Package>!*</Export-Package>
+            <Import-Package>!</Import-Package>
+            <Private-Package>!</Private-Package>
+          </instructions>
+        </configuration>
+        <executions>
+          <execution>
+            <id>generate-manifest</id>
+            <phase>process-classes</phase>
+            <goals>
+              <goal>manifest</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- No tests to run -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.eclipse.core</groupId>
+      <artifactId>commands</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.core</groupId>
+      <artifactId>runtime</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.equinox</groupId>
+      <artifactId>common</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>jface</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>osgi</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.swt.cocoa.macosx</groupId>
+      <artifactId>x86_64</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>ui</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.ui</groupId>
+      <artifactId>workbench</artifactId>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Added: directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Activator.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Activator.java?rev=1203174&view=auto
==============================================================================
--- directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Activator.java
(added)
+++ directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Activator.java
Thu Nov 17 12:48:31 2011
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2011, Alex Blewitt.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Alex Blewitt - initial API and implementation
+ *******************************************************************************/
+package org.apache.directory.studio.rcp.fullscreen;
+
+
+import org.eclipse.swt.internal.cocoa.NSWindow;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * Set all existing windows to have full-screen behaviour, and also permit new
+ * windows to be registered with same as well.
+ * 
+ * @author Alex Blewitt <alex.blewit@gmail.com>
+ */
+@SuppressWarnings("restriction")
+public class Activator extends AbstractUIPlugin implements IWindowListener
+{
+
+    public static final String PLUGIN_ID = "com.bandlem.eclipse.fullscreen.ui"; //$NON-NLS-1$
+
+
+    public void start( BundleContext context ) throws Exception
+    {
+        super.start( context );
+        PlatformUI.getWorkbench().addWindowListener( this );
+    }
+
+
+    public void stop( BundleContext context ) throws Exception
+    {
+        super.stop( context );
+    }
+
+
+    @Override
+    public void windowActivated( IWorkbenchWindow window )
+    {
+    }
+
+
+    @Override
+    public void windowDeactivated( IWorkbenchWindow window )
+    {
+    }
+
+
+    @Override
+    public void windowClosed( IWorkbenchWindow window )
+    {
+    }
+
+
+    @Override
+    public void windowOpened( IWorkbenchWindow window )
+    {
+        Shell shell = window.getShell();
+        setWindowFullscreen( shell );
+    }
+
+
+    static void setWindowFullscreen( final Shell shell )
+    {
+        NSWindow nswindow = shell.view.window();
+        nswindow.setToolbar( null );
+        SO.Reflect.executeLong( nswindow, "setCollectionBehavior",
+            new Class[]
+                { SO.NSUInteger }, ( int ) ( 1 << 7 ) );
+    }
+}

Added: directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/BnLWindow.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/BnLWindow.java?rev=1203174&view=auto
==============================================================================
--- directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/BnLWindow.java
(added)
+++ directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/BnLWindow.java
Thu Nov 17 12:48:31 2011
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2011, Alex Blewitt.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Alex Blewitt - initial API and implementation
+ *******************************************************************************/
+package org.apache.directory.studio.rcp.fullscreen;
+
+
+import org.eclipse.swt.internal.cocoa.NSWindow;
+
+import org.apache.directory.studio.rcp.fullscreen.SO.Reflect;
+
+
+/**
+ * Wrapper methods to assist with extensions to NSWindow
+ * 
+ * @author Alex Blewitt <alex.blewitt@gmail.com>
+ */
+@SuppressWarnings("restriction")
+public class BnLWindow
+{
+
+    /**
+     * Toggle the window in and out of fullScreen mode.
+     * 
+     * @param window
+     *            the window, which must not be <code>null</code>.
+     */
+    public static void toggleFullScreen( NSWindow window )
+    {
+        long toggleFullScreen = SO.selector( "toggleFullScreen:" );
+        long target = SO.getID( window );
+        SO.objc_msgSend( target, toggleFullScreen, 0 );
+    }
+
+
+    /**
+     * Returns true if the window is in fullScreen mode already.
+     * 
+     * @param window
+     *            the window, which must not be null.
+     * @return true if the window is in fullScreen mode, false otherwise.
+     */
+    public static boolean isFullScreen( NSWindow window )
+    {
+        long styleMask = Reflect.executeLong( window, "styleMask" );
+        return ( ( ( styleMask >> 14 ) & 1 ) == 1 );
+    }
+
+
+    /**
+     * Sets the window's fullScreen mode, regardless of current setting
+     * 
+     * @param window
+     *            the window, which must not be null.
+     * @param fullScreen
+     *            true if the window is to go into fullScreen mode, false
+     *            otherwise.
+     */
+    public static void setFullScreen( NSWindow window, boolean fullScreen )
+    {
+        if ( isFullScreen( window ) != fullScreen )
+            toggleFullScreen( window );
+    }
+}

Added: directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/SO.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/SO.java?rev=1203174&view=auto
==============================================================================
--- directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/SO.java
(added)
+++ directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/SO.java
Thu Nov 17 12:48:31 2011
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2011, Alex Blewitt.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Alex Blewitt - initial API and implementation
+ *******************************************************************************/
+package org.apache.directory.studio.rcp.fullscreen;
+
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.internal.cocoa.OS;
+import org.eclipse.swt.internal.cocoa.id;
+
+
+/**
+ * Handles some of the Objective-C code in a architecture neutral way.
+ * 
+ * Since SWT is compiled for 32-bit or 64-bit access separately (and types like
+ * {@link id} correspond to NSUInteger, which is 32-bit on a 32-bit system and
+ * 64-bit on a 64-bit system), we can't just use the same parameter for all
+ * method invocations.
+ * 
+ * This front-end to the Objective-C runtime uses <code>long</code> for
+ * everything, and maps it to <code>int</code> when running on a 32-bit system.
+ * As a result, code can call this and not have to worry about the distinction
+ * between the two.
+ * 
+ * It also allows access to selectors not normally available in SWT, via the
+ * {@link #selector(String)} call. For example, invoking
+ * <code>selector("toggleFullScreen:")</code> allows that method to be called
+ * even if {@link OS} doesn't provide a handle to that natively, which it
+ * doesn't on at least Eclipse 3.6 and Eclipse 3.7 systems.
+ * 
+ * Finally, since a lot of this uses reflection, it also provides some helper
+ * methods to get a field to make the reflection API a little more sane.
+ * 
+ * @author Alex Blewitt <alex.blewit@gmail.com>
+ */
+@SuppressWarnings(
+    { "rawtypes", "restriction" })
+public class SO
+{
+    /**
+     * Subset of helpers for reflective access to methods
+     */
+    public static class Reflect
+    {
+
+        /**
+         * Executes a method, which returns a <code>long</code> (compatible)
+         * value.
+         * 
+         * @param target
+         *            the instance to execute against (if it is a Class, will be
+         *            static access)
+         * @param method
+         *            the method name
+         * @param types
+         *            the list of argument types (if any)
+         * @param args
+         *            the list of arguments (if any)
+         * @throws RuntimeException
+         *             if any reflection invocation method occurs.
+         * @return the long return value
+         */
+        public static long executeLong( Object target, String method,
+            Object... args )
+        {
+            Class types[] = new Class[args.length];
+            for ( int i = 0; i < args.length; i++ )
+            {
+                types[i] = args[i].getClass();
+            }
+            return executeLong( target, method, types, args );
+        }
+
+
+        /**
+         * Executes a method, which returns a <code>long</code> (compatible)
+         * value.
+         * 
+         * @param target
+         *            the instance to execute against (if it is a Class, will be
+         *            static access)
+         * @param method
+         *            the method name
+         * @param types
+         *            the list of argument types (if any)
+         * @param args
+         *            the list of arguments (if any)
+         * @throws RuntimeException
+         *             if any reflection invocation method occurs.
+         * @return the long return value
+         */
+        @SuppressWarnings("unchecked")
+        public static long executeLong( Object target, String method,
+            Class[] types, Object... args )
+        {
+            Class clazz = ( Class ) ( target instanceof Class ? target : target
+                .getClass() );
+            Object[] newArgs;
+            try
+            {
+                if ( NSUInteger == Long.TYPE )
+                {
+                    newArgs = args;
+                }
+                else
+                {
+                    newArgs = new Object[args.length];
+                    for ( int i = 0; i < args.length; i++ )
+                    {
+                        newArgs[i] = new Integer( ( ( Number ) args[i] ).intValue() );
+                    }
+                }
+                Method m = clazz.getMethod( method, types );
+                Number n = ( ( Number ) m.invoke( target, newArgs ) );
+                return n == null ? -1 : n.longValue();
+            }
+            catch ( Exception e )
+            {
+                throw new RuntimeException( e );
+            }
+        }
+
+
+        /**
+         * Gets a field from the object, which can either be a Class (for static
+         * access) or an instance
+         * 
+         * @param target
+         *            the object/class to obtain the field from
+         * @param field
+         *            the field name
+         * @throws RuntimeException
+         *             if any problems occur with reflection
+         * @return the result
+         */
+        public static Object getField( Object target, String field )
+        {
+            try
+            {
+                return ( target instanceof Class ? ( Class ) target : target
+                    .getClass() ).getField( field ).get( target );
+            }
+            catch ( Exception e )
+            {
+                throw new RuntimeException( e );
+            }
+        }
+
+    }
+
+    /**
+     * This represents the corresponding Java primitive type of NSUInteger, and
+     * can be passed in methods that perform lookups via reflection.
+     * 
+     * On a 32-bit system, this will have the value <code>Integer.TYPE</code>
+     * whilst on a 64-bit system it will have the value <code>Long.TYPE</code>.
+     * 
+     * This is dynamically determined based on the type of {@link OS#class_NSObjectl}
+     * compiled into the SWT library.
+     */
+    public static final Class NSUInteger = Reflect.getField( OS.class,
+        "class_NSObject" ).getClass() == Long.class ? Long.TYPE : Integer.TYPE;
+
+    /**
+     * Private cache of selectors-to-ids.
+     */
+    private static Map<String, Number> selectors = new HashMap<String, Number>();
+
+
+    /**
+     * Gets the id associated with an object of type id (base Cocoa SWT class).
+     * 
+     * @param id
+     *            the object
+     * @return the long value
+     */
+    public static long getID( id id )
+    {
+        return ( ( Number ) Reflect.getField( id, "id" ) ).longValue();
+    }
+
+
+    public static void objc_msgSend( long target, long sel, long arg )
+    {
+        Reflect.executeLong( OS.class, "objc_msgSend", new Class[]
+            { NSUInteger,
+                NSUInteger, NSUInteger }, target, sel, arg );
+    }
+
+
+    public static long selector( String sel )
+    {
+        try
+        {
+            Number selector = selectors.get( sel );
+            if ( selector == null )
+            {
+                selector = ( Number ) ( OS.class.getMethod( "sel_registerName",
+                    String.class ).invoke( null, sel ) );
+                selectors.put( sel, selector );
+            }
+            return selector.longValue();
+        }
+        catch ( Exception e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+}

Added: directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Startup.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Startup.java?rev=1203174&view=auto
==============================================================================
--- directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Startup.java
(added)
+++ directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/Startup.java
Thu Nov 17 12:48:31 2011
@@ -0,0 +1,34 @@
+package org.apache.directory.studio.rcp.fullscreen;
+
+
+import org.eclipse.ui.IStartup;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+
+public class Startup implements Runnable, IStartup
+{
+
+    private IWorkbenchWindow[] windows;
+
+
+    @Override
+    public void earlyStartup()
+    {
+        IWorkbench workbench = PlatformUI.getWorkbench();
+        windows = workbench.getWorkbenchWindows();
+        workbench.getDisplay().asyncExec( this );
+    }
+
+
+    @Override
+    public void run()
+    {
+        for ( int i = 0; i < windows.length; i++ )
+        {
+            IWorkbenchWindow iWorkbenchWindow = windows[i];
+            Activator.setWindowFullscreen( iWorkbenchWindow.getShell() );
+        }
+    }
+}
\ No newline at end of file

Added: directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenEscapeHandler.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenEscapeHandler.java?rev=1203174&view=auto
==============================================================================
--- directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenEscapeHandler.java
(added)
+++ directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenEscapeHandler.java
Thu Nov 17 12:48:31 2011
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2011, Alex Blewitt.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Alex Blewitt - initial API and implementation
+ *******************************************************************************/
+package org.apache.directory.studio.rcp.fullscreen;
+
+
+import org.eclipse.swt.internal.cocoa.NSWindow;
+
+
+/**
+ * Provides mapping for the Escape key, such that it only works when the window
+ * is already in fullscreen mode.
+ * 
+ * @author Alex Blewitt <alex.blewit@gmail.com>
+ */
+@SuppressWarnings("restriction")
+public class ToggleFullScreenEscapeHandler extends ToggleFullScreenHandler
+{
+
+    /**
+     * This is enabled when {@link ToggleFullScreenHandler#isEnabled()}, and
+     * we're in fullScreen mode.
+     */
+    @Override
+    public boolean isEnabled()
+    {
+        NSWindow[] windows = getWindows();
+        return super.isEnabled() && windows != null && windows.length >=
1
+            && BnLWindow.isFullScreen( windows[0] );
+    }
+}

Added: directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenHandler.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenHandler.java?rev=1203174&view=auto
==============================================================================
--- directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenHandler.java
(added)
+++ directory/studio/trunk/plugins/rcp.fullscreen/src/main/java/org/apache/directory/studio/rcp/fullscreen/ToggleFullScreenHandler.java
Thu Nov 17 12:48:31 2011
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2011, Alex Blewitt.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Alex Blewitt - initial API and implementation
+ *******************************************************************************/
+package org.apache.directory.studio.rcp.fullscreen;
+
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.swt.internal.cocoa.NSWindow;
+import org.eclipse.swt.internal.cocoa.OS;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * Provides a handler which can be used for mapping to keystrokes as well as a
+ * menu item to go into and out of fullscreen mode.
+ * 
+ * @author Alex Blewitt <alex.blewitt@gmail.com>
+ */
+@SuppressWarnings("restriction")
+public class ToggleFullScreenHandler extends AbstractHandler
+{
+
+    /**
+     * Toggles the window into fullScreen mode, via
+     * {@link BnLWindow#toggleFullScreen(NSWindow)}.
+     */
+    @Override
+    public Object execute( ExecutionEvent event ) throws ExecutionException
+    {
+        NSWindow[] windows = getWindows();
+        //for (int i = 0; i < windows.length; i++)
+        BnLWindow.toggleFullScreen( windows[0] );
+        return null;
+    }
+
+
+    /**
+     * Helper to get the active window. Returns the windows in the workbench's
+     * array.
+     * 
+     * @return the NSWindow to go into fullScreen mode.
+     */
+    protected NSWindow[] getWindows()
+    {
+        IWorkbenchWindow[] windows = PlatformUI.getWorkbench()
+            .getWorkbenchWindows();
+        NSWindow[] nsWindows = new NSWindow[windows.length];
+        for ( int i = 0; i < windows.length; i++ )
+        {
+            nsWindows[i] = windows[i].getShell().view.window();
+        }
+        return nsWindows;
+    }
+
+
+    /**
+     * This is enabled if we are on OSX 10.7 and above, and there are windows
+     * present.
+     */
+    @Override
+    public boolean isEnabled()
+    {
+        IWorkbenchWindow[] windows = PlatformUI.getWorkbench()
+            .getWorkbenchWindows();
+        return windows.length >= 1 && OS.VERSION >= 0x1070;
+    }
+}

Modified: directory/studio/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/pom.xml?rev=1203174&r1=1203173&r2=1203174&view=diff
==============================================================================
--- directory/studio/trunk/pom.xml (original)
+++ directory/studio/trunk/pom.xml Thu Nov 17 12:48:31 2011
@@ -522,6 +522,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.directory.studio</groupId>
+        <artifactId>rcp.fullscreen</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.directory.studio</groupId>
         <artifactId>rcp.help</artifactId>
         <version>${project.version}</version>
       </dependency>



Mime
View raw message