directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r636377 - in /directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration: ./ editor/
Date Wed, 12 Mar 2008 15:47:35 GMT
Author: pamarcelot
Date: Wed Mar 12 08:47:30 2008
New Revision: 636377

URL: http://svn.apache.org/viewvc?rev=636377&view=rev
Log:
Fix for DIRSTUDIO-290 (Check creation and proper disposal of SWT Graphics objects)

Modified:
    directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java
    directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java
    directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java
    directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java

Modified: directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java?rev=636377&r1=636376&r2=636377&view=diff
==============================================================================
--- directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java
(original)
+++ directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/Activator.java
Wed Mar 12 08:47:30 2008
@@ -20,11 +20,17 @@
 package org.apache.directory.studio.apacheds.configuration;
 
 
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.graphics.FontMetrics;
 import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
@@ -84,7 +90,8 @@
     {
         return plugin;
     }
-    
+
+
     /**
      * Returns the button with respect to the font metrics.
      *
@@ -100,5 +107,58 @@
 
         int width = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH
);
         return width;
+    }
+
+
+    /**
+     * Use this method to get SWT images. Use the IMG_ constants from
+     * PluginConstants for the key.
+     *
+     * @param key
+     *                The key (relative path to the image in filesystem)
+     * @return The image descriptor or null
+     */
+    public ImageDescriptor getImageDescriptor( String key )
+    {
+        if ( key != null )
+        {
+            URL url = FileLocator.find( getBundle(), new Path( key ), null );
+            if ( url != null )
+                return ImageDescriptor.createFromURL( url );
+            else
+                return null;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Use this method to get SWT images. Use the IMG_ constants from
+     * PluginConstants for the key. A ImageRegistry is used to manage the
+     * the key->Image mapping.
+     * <p>
+     * Note: Don't dispose the returned SWT Image. It is disposed
+     * automatically when the plugin is stopped.
+     *
+     * @param key
+     *                The key (relative path to the image in filesystem)
+     * @return The SWT Image or null
+     */
+    public Image getImage( String key )
+    {
+        Image image = getImageRegistry().get( key );
+        if ( image == null )
+        {
+            ImageDescriptor id = getImageDescriptor( key );
+            if ( id != null )
+            {
+                image = id.createImage();
+                getImageRegistry().put( key, image );
+            }
+        }
+        return image;
     }
 }

Modified: directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java?rev=636377&r1=636376&r2=636377&view=diff
==============================================================================
--- directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java
(original)
+++ directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/ExtendedOperationsMasterDetailsBlock.java
Wed Mar 12 08:47:30 2008
@@ -50,7 +50,6 @@
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
 
 
 /**
@@ -137,8 +136,7 @@
         {
             public Image getImage( Object element )
             {
-                return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-                    PluginConstants.IMG_EXTENDED_OPERATION ).createImage();
+                return Activator.getDefault().getImage( PluginConstants.IMG_EXTENDED_OPERATION
);
             }
         } );
 
@@ -258,7 +256,7 @@
         };
         horizontalAction.setChecked( true );
         horizontalAction.setToolTipText( "Horizontal Orientation" ); //$NON-NLS-1$
-        horizontalAction.setImageDescriptor( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+        horizontalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
             PluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
 
         // Vertical layout Action
@@ -271,7 +269,7 @@
         };
         verticalAction.setChecked( false );
         verticalAction.setToolTipText( "Vertical Orientation" ); //$NON-NLS-1$
-        verticalAction.setImageDescriptor( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+        verticalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
             PluginConstants.IMG_VERTICAL_ORIENTATION ) );
 
         form.getToolBarManager().add( horizontalAction );

Modified: directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java?rev=636377&r1=636376&r2=636377&view=diff
==============================================================================
--- directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java
(original)
+++ directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/InterceptorsMasterDetailsBlock.java
Wed Mar 12 08:47:30 2008
@@ -50,7 +50,6 @@
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
 
 
 /**
@@ -141,8 +140,7 @@
         {
             public Image getImage( Object element )
             {
-                return AbstractUIPlugin
-                    .imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_INTERCEPTOR
).createImage();
+                return Activator.getDefault().getImage( PluginConstants.IMG_INTERCEPTOR );
             }
         } );
 
@@ -344,7 +342,7 @@
         };
         horizontalAction.setChecked( true );
         horizontalAction.setToolTipText( "Horizontal Orientation" ); //$NON-NLS-1$
-        horizontalAction.setImageDescriptor( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+        horizontalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
             PluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
 
         // Vertical layout Action
@@ -357,7 +355,7 @@
         };
         verticalAction.setChecked( false );
         verticalAction.setToolTipText( "Vertical Orientation" ); //$NON-NLS-1$
-        verticalAction.setImageDescriptor( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+        verticalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
             PluginConstants.IMG_VERTICAL_ORIENTATION ) );
 
         form.getToolBarManager().add( horizontalAction );

Modified: directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java?rev=636377&r1=636376&r2=636377&view=diff
==============================================================================
--- directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java
(original)
+++ directory/studio/branches/1.1.0/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/editor/PartitionsMasterDetailsBlock.java
Wed Mar 12 08:47:30 2008
@@ -50,7 +50,6 @@
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
 
 
 /**
@@ -139,10 +138,9 @@
             public Image getImage( Object element )
             {
 
-                return AbstractUIPlugin.imageDescriptorFromPlugin(
-                    Activator.PLUGIN_ID,
+                return Activator.getDefault().getImage(
                     ( ( Partition ) element ).isSystemPartition() ? PluginConstants.IMG_PARTITION_SYSTEM
-                        : PluginConstants.IMG_PARTITION ).createImage();
+                        : PluginConstants.IMG_PARTITION );
             }
         } );
 
@@ -272,7 +270,7 @@
         };
         horizontalAction.setChecked( true );
         horizontalAction.setToolTipText( "Horizontal Orientation" ); //$NON-NLS-1$
-        horizontalAction.setImageDescriptor( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+        horizontalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
             PluginConstants.IMG_HORIZONTAL_ORIENTATION ) );
 
         // Vertical layout Action
@@ -285,7 +283,7 @@
         };
         verticalAction.setChecked( false );
         verticalAction.setToolTipText( "Vertical Orientation" ); //$NON-NLS-1$
-        verticalAction.setImageDescriptor( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+        verticalAction.setImageDescriptor( Activator.getDefault().getImageDescriptor(
             PluginConstants.IMG_VERTICAL_ORIENTATION ) );
 
         form.getToolBarManager().add( horizontalAction );



Mime
View raw message