Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 67787 invoked from network); 12 Mar 2008 15:48:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Mar 2008 15:48:00 -0000 Received: (qmail 83691 invoked by uid 500); 12 Mar 2008 15:47:58 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 83658 invoked by uid 500); 12 Mar 2008 15:47:57 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 83647 invoked by uid 99); 12 Mar 2008 15:47:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Mar 2008 08:47:57 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Mar 2008 15:47:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 43C421A9832; Wed, 12 Mar 2008 08:47:39 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080312154739.43C421A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. + *

+ * 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 );