Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 312 invoked from network); 17 Jun 2007 22:44:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jun 2007 22:44:19 -0000 Received: (qmail 50997 invoked by uid 500); 17 Jun 2007 22:44:21 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 50959 invoked by uid 500); 17 Jun 2007 22:44:21 -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 50948 invoked by uid 99); 17 Jun 2007 22:44:21 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Jun 2007 15:44:21 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME 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; Sun, 17 Jun 2007 15:44:16 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 51DCE1A981A; Sun, 17 Jun 2007 15:43:56 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r548132 - in /directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors: ValueEditorsConstants.java address/AddressDialog.java address/AddressValueEditor.java dn/DnDialog.java image/ImageDialog.java Date: Sun, 17 Jun 2007 22:43:55 -0000 To: commits@directory.apache.org From: seelmann@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070617224356.51DCE1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: seelmann Date: Sun Jun 17 15:43:52 2007 New Revision: 548132 URL: http://svn.apache.org/viewvc?view=rev&rev=548132 Log: Cleanups and Javadocs Modified: directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java Modified: directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java?view=diff&rev=548132&r1=548131&r2=548132 ============================================================================== --- directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java (original) +++ directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java Sun Jun 17 15:43:52 2007 @@ -1,32 +1,37 @@ package org.apache.directory.studio.valueeditors; +/** + * Contains constants for the value editors. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public interface ValueEditorsConstants { - public static final String PREFERENCE_SYNTAX_VALUEPROVIDER_RELATIONS = "syntaxValueProviderRelations"; - - public static final String PREFERENCE_ATTRIBUTE_VALUEPROVIDER_RELATIONS = "attributeValueProviderRelations"; - - public static final String PREFERENCE_SHOW_RAW_VALUES = "showRawValues"; - - + /** The relative path to the image editor icon */ public static final String IMG_IMAGEEDITOR = "resources/icons/imageeditor.gif"; + /** The relative path to the address editor icon */ public static final String IMG_ADDRESSEDITOR = "resources/icons/addresseditor.gif"; + /** The relative path to the DN editor icon */ public static final String IMG_DNEDITOR = "resources/icons/dneditor.gif"; + /** The relative path to the password editor icon */ public static final String IMG_PASSWORDEDITOR = "resources/icons/passwordeditor.gif"; - public static final String IMG_INPLACE_OCEDITOR = "resources/icons/inplace_oceditor.gif"; - + /** The relative path to the generalized time editor icon */ public static final String IMG_INPLACE_GENERALIZEDTIMEEDITOR = "resources/icons/inplace_generalizedtimeeditor.gif"; + /** The relative path to the object class editor icon */ public static final String IMG_OCDEDITOR = "resources/icons/objectclasseditor.png"; + /** The relative path to the integer editor icon */ public static final String IMG_INTEGEREDITOR = "resources/icons/integereditor.gif"; + /** The relative path to the administrative role editor icon */ public static final String IMG_ADMINISTRATIVEROLEEDITOR = "resources/icons/administrativeroleeditor.gif"; } Modified: directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java?view=diff&rev=548132&r1=548131&r2=548132 ============================================================================== --- directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java (original) +++ directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java Sun Jun 17 15:43:52 2007 @@ -34,45 +34,54 @@ import org.eclipse.swt.widgets.Text; +/** + * The AddressDialog is used from the address value editor to edit an address. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class AddressDialog extends Dialog { - public static final String DIALOG_TITLE = "Address Editor"; + /** The initial address. */ + private String initialAddress; - public static final double MAX_WIDTH = 250.0; - - public static final double MAX_HEIGHT = 250.0; - - private String initialValue; - - private String returnValue; + /** The return address. */ + private String returnAddress; + /** The text widget. */ private Text text; - public AddressDialog( Shell parentShell, String initialValue ) + /** + * Creates a new instance of AddressDialog. + * + * @param parentShell the parent shell + * @param initialAddress the initial address + */ + public AddressDialog( Shell parentShell, String initialAddress ) { super( parentShell ); super.setShellStyle( super.getShellStyle() | SWT.RESIZE ); - this.initialValue = initialValue; - this.returnValue = null; - } - - - public boolean close() - { - return super.close(); + this.initialAddress = initialAddress; + this.returnAddress = null; } + /** + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ protected void configureShell( Shell shell ) { super.configureShell( shell ); - shell.setText( DIALOG_TITLE ); + shell.setText( "Address Editor" ); shell.setImage( ValueEditorsActivator.getDefault().getImage( ValueEditorsConstants.IMG_ADDRESSEDITOR ) ); } + /** + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ protected void createButtonsForButtonBar( Composite parent ) { createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false ); @@ -80,16 +89,22 @@ } + /** + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ protected void okPressed() { - this.returnValue = this.text.getText(); - this.returnValue = this.returnValue.replaceAll( "\n", "\\$" ); - this.returnValue = this.returnValue.replaceAll( "\r", "\\$" ); - this.returnValue = this.returnValue.replaceAll( "\\$\\$", "\\$" ); + returnAddress = text.getText(); + returnAddress = returnAddress.replaceAll( "\n", "\\$" ); + returnAddress = returnAddress.replaceAll( "\r", "\\$" ); + returnAddress = returnAddress.replaceAll( "\\$\\$", "\\$" ); super.okPressed(); } + /** + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ protected Control createDialogArea( Composite parent ) { // create composite @@ -99,7 +114,7 @@ // text widget text = new Text( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL ); - text.setText( this.initialValue.replaceAll( "\\$", BrowserCoreConstants.LINE_SEPARATOR ) ); + text.setText( initialAddress.replaceAll( "\\$", BrowserCoreConstants.LINE_SEPARATOR ) ); // GridData gd = new GridData(GridData.GRAB_HORIZONTAL | // GridData.HORIZONTAL_ALIGN_FILL); gd = new GridData( GridData.FILL_BOTH ); @@ -112,9 +127,14 @@ } - public String getText() + /** + * Gets the address. + * + * @return the address + */ + public String getAddress() { - return this.returnValue; + return returnAddress; } } Modified: directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java?view=diff&rev=548132&r1=548131&r2=548132 ============================================================================== --- directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java (original) +++ directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java Sun Jun 17 15:43:52 2007 @@ -50,9 +50,9 @@ if ( value != null && value instanceof String ) { AddressDialog dialog = new AddressDialog( shell, ( String ) value ); - if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getText() ) ) + if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getAddress() ) ) { - setValue( dialog.getText() ); + setValue( dialog.getAddress() ); return true; } } Modified: directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java?view=diff&rev=548132&r1=548131&r2=548132 ============================================================================== --- directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java (original) +++ directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java Sun Jun 17 15:43:52 2007 @@ -38,18 +38,33 @@ import org.eclipse.swt.widgets.Shell; -public class DnDialog extends Dialog implements WidgetModifyListener -{ +/** + * The DnDialog is used from the DN value editor to edit and select a DN. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ - public static final String DIALOG_TITLE = "DN Editor"; +public class DnDialog extends Dialog +{ + /** The entry widget. */ private EntryWidget entryWidget; + /** The connection. */ private IConnection connection; + /** The dn. */ private DN dn; + /** + * Creates a new instance of DnDialog. + * + * @param parentShell the parent shell + * @param connection the connection + * @param dn the dn + */ public DnDialog( Shell parentShell, IConnection connection, DN dn ) { super( parentShell ); @@ -59,37 +74,42 @@ } + /** + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ protected void configureShell( Shell shell ) { super.configureShell( shell ); - shell.setText( DIALOG_TITLE ); + shell.setText( "DN Editor" ); shell.setImage( ValueEditorsActivator.getDefault().getImage( ValueEditorsConstants.IMG_DNEDITOR ) ); } - public boolean close() - { - this.entryWidget.removeWidgetModifyListener( this ); - return super.close(); - } - - + /** + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ protected void okPressed() { - this.dn = this.entryWidget.getDn(); - this.entryWidget.saveDialogSettings(); + dn = entryWidget.getDn(); + entryWidget.saveDialogSettings(); super.okPressed(); } + /** + * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite) + */ protected Control createButtonBar( Composite parent ) { Control control = super.createButtonBar( parent ); - widgetModified( null ); + updateWidgets(); return control; } + /** + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ protected Control createDialogArea( Composite parent ) { @@ -99,28 +119,42 @@ composite.setLayoutData( gd ); Composite innerComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1 ); - this.entryWidget = new EntryWidget( connection, dn ); - this.entryWidget.addWidgetModifyListener( this ); - this.entryWidget.createWidget( innerComposite ); + entryWidget = new EntryWidget( connection, dn ); + entryWidget.addWidgetModifyListener( new WidgetModifyListener() + { + public void widgetModified( WidgetModifyEvent event ) + { + updateWidgets(); + } + } ); + entryWidget.createWidget( innerComposite ); applyDialogFont( composite ); return composite; } - public void widgetModified( WidgetModifyEvent event ) + /** + * Updates the widgets. + */ + private void updateWidgets() { if ( getButton( IDialogConstants.OK_ID ) != null ) { getButton( IDialogConstants.OK_ID ).setEnabled( - this.entryWidget.getDn() != null && !"".equals( this.entryWidget.getDn().toString() ) ); + entryWidget.getDn() != null && !"".equals( entryWidget.getDn().toString() ) ); } } + /** + * Gets the dn. + * + * @return the dn + */ public DN getDn() { - return this.dn; + return dn; } } Modified: directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java?view=diff&rev=548132&r1=548131&r2=548132 ============================================================================== --- directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java (original) +++ directory/studio/trunk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java Sun Jun 17 15:43:52 2007 @@ -58,23 +58,25 @@ import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; - +/** + * The ImageDialog is used from the image value editor to view the current image + * and to select a new image. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ public class ImageDialog extends Dialog { - public static final String DIALOG_TITLE = "Image Editor"; - - // public static final String[] IMAGE_FILE_EXTENSIONS = {"*.jpg; *.jpeg; - // *.gif; *.bmp; *.png"}; - public static final int MAX_WIDTH = 250; + private static final int MAX_WIDTH = 250; - public static final int MAX_HEIGHT = 250; + private static final int MAX_HEIGHT = 250; - public static final int CURRENT_TAB = 0; + private static final int CURRENT_TAB = 0; - public static final int NEW_TAB = 1; + private static final int NEW_TAB = 1; - public static final String SELECTED_TAB_DIALOGSETTINGS_KEY = ImageDialog.class.getName() + ".tab"; + private static final String SELECTED_TAB_DIALOGSETTINGS_KEY = ImageDialog.class.getName() + ".tab"; private TabFolder tabFolder; @@ -127,6 +129,13 @@ private Button okButton; + /** + * Creates a new instance of ImageDialog. + * + * @param parentShell the parent shell + * @param currentImageRawData the current image raw data + * @param requiredImageType the required image type + */ public ImageDialog( Shell parentShell, byte[] currentImageRawData, int requiredImageType ) { super( parentShell ); @@ -138,72 +147,83 @@ } + /** + * @see org.eclipse.jface.dialogs.Dialog#close() + */ public boolean close() { - if ( this.currentImage != null && !this.currentImage.isDisposed() ) + if ( currentImage != null && !currentImage.isDisposed() ) { - this.currentImage.dispose(); + currentImage.dispose(); } - if ( this.newImage != null && !this.newImage.isDisposed() ) + if ( newImage != null && !newImage.isDisposed() ) { - this.newImage.dispose(); + newImage.dispose(); } // save selected tab to dialog settings ValueEditorsActivator.getDefault().getDialogSettings().put( SELECTED_TAB_DIALOGSETTINGS_KEY, - this.tabFolder.getSelectionIndex() ); + tabFolder.getSelectionIndex() ); return super.close(); } + /** + * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) + */ protected void buttonPressed( int buttonId ) { if ( buttonId == IDialogConstants.OK_ID ) { - if ( this.newImageRawData != null ) + if ( newImageRawData != null ) { try { - ImageData imageData = new ImageData( new ByteArrayInputStream( this.newImageRawData ) ); - if ( imageData.type != this.requiredImageType ) + ImageData imageData = new ImageData( new ByteArrayInputStream( newImageRawData ) ); + if ( imageData.type != requiredImageType ) { ImageLoader imageLoader = new ImageLoader(); imageLoader.data = new ImageData[] { imageData }; ByteArrayOutputStream baos = new ByteArrayOutputStream(); - imageLoader.save( baos, this.requiredImageType ); - this.newImageRawDataInRequiredFormat = baos.toByteArray(); + imageLoader.save( baos, requiredImageType ); + newImageRawDataInRequiredFormat = baos.toByteArray(); } else { - this.newImageRawDataInRequiredFormat = this.newImageRawData; + newImageRawDataInRequiredFormat = newImageRawData; } } catch ( SWTException swte ) { - this.newImageRawDataInRequiredFormat = null; + newImageRawDataInRequiredFormat = null; } } - } else { - this.newImageRawDataInRequiredFormat = null; + newImageRawDataInRequiredFormat = null; } super.buttonPressed( buttonId ); } + /** + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ protected void configureShell( Shell shell ) { super.configureShell( shell ); - shell.setText( DIALOG_TITLE ); + shell.setText( "Image Editor" ); shell.setImage( ValueEditorsActivator.getDefault().getImage( ValueEditorsConstants.IMG_IMAGEEDITOR ) ); } + /** + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ protected void createButtonsForButtonBar( Composite parent ) { okButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false ); @@ -213,7 +233,7 @@ try { int tabIndex = ValueEditorsActivator.getDefault().getDialogSettings().getInt( SELECTED_TAB_DIALOGSETTINGS_KEY ); - this.tabFolder.setSelection( tabIndex ); + tabFolder.setSelection( tabIndex ); } catch ( Exception e ) { @@ -224,22 +244,24 @@ } + /** + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ protected Control createDialogArea( Composite parent ) { - Composite composite = ( Composite ) super.createDialogArea( parent ); GridData gd1 = new GridData( GridData.FILL_BOTH ); gd1.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); gd1.heightHint = convertVerticalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); composite.setLayoutData( gd1 ); - this.tabFolder = new TabFolder( composite, SWT.TOP ); + tabFolder = new TabFolder( composite, SWT.TOP ); GridLayout mainLayout = new GridLayout(); mainLayout.marginWidth = 0; mainLayout.marginHeight = 0; - this.tabFolder.setLayout( mainLayout ); - this.tabFolder.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - this.tabFolder.addSelectionListener( new SelectionAdapter() + tabFolder.setLayout( mainLayout ); + tabFolder.setLayoutData( new GridData( GridData.FILL_BOTH ) ); + tabFolder.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { @@ -248,9 +270,9 @@ } ); // current image - if ( this.currentImageRawData != null && this.currentImageRawData.length > 0 ) + if ( currentImageRawData != null && currentImageRawData.length > 0 ) { - currentImageContainer = new Composite( this.tabFolder, SWT.NONE ); + currentImageContainer = new Composite( tabFolder, SWT.NONE ); GridLayout currentLayout = new GridLayout( 1, false ); currentLayout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN ); currentLayout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN ); @@ -310,13 +332,13 @@ } } ); - this.currentTab = new TabItem( this.tabFolder, SWT.NONE ); - this.currentTab.setText( "Current Image" ); - this.currentTab.setControl( currentImageContainer ); + currentTab = new TabItem( tabFolder, SWT.NONE ); + currentTab.setText( "Current Image" ); + currentTab.setControl( currentImageContainer ); } // new image - newImageContainer = new Composite( this.tabFolder, SWT.NONE ); + newImageContainer = new Composite( tabFolder, SWT.NONE ); GridLayout newLayout = new GridLayout( 1, false ); newLayout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN ); newLayout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN ); @@ -362,21 +384,22 @@ } } ); - this.newTab = new TabItem( this.tabFolder, SWT.NONE ); - this.newTab.setText( "New Image" ); - this.newTab.setControl( newImageContainer ); + newTab = new TabItem( tabFolder, SWT.NONE ); + newTab.setText( "New Image" ); + newTab.setControl( newImageContainer ); applyDialogFont( composite ); return composite; } + /** + * Update current image tab. + */ private void updateCurrentImageGroup() { - if ( currentTab != null ) { - if ( currentImage != null && !currentImage.isDisposed() ) { currentImage.dispose(); @@ -405,7 +428,6 @@ currentImageWidthText.setText( "-" ); currentImageHeightText.setText( "-" ); } - // currentImageGroup.setVisible(true); } else { @@ -418,15 +440,15 @@ } currentImageSaveButton.setEnabled( currentImageRawData != null && currentImageRawData.length > 0 ); - - // super.initializeBounds(); } } + /** + * Update new image tab. + */ private void updateNewImageGroup() { - if ( newImage != null && !newImage.isDisposed() ) { newImage.dispose(); @@ -446,7 +468,7 @@ { out.write( buf, 0, len ); } - this.newImageRawData = out.toByteArray(); + newImageRawData = out.toByteArray(); out.close(); in.close(); } @@ -493,7 +515,7 @@ if ( imageData.type != requiredImageType ) { newImageTypeText.setText( newImageTypeText.getText() + " (will be converted to " - + getImageType( this.requiredImageType ) + ")" ); + + getImageType( requiredImageType ) + ")" ); } newImageSizeText.setText( getSizeString( newImageRawData.length ) ); newImageWidthText.setText( imageData.width + " Pixel" ); @@ -517,12 +539,12 @@ newImageLabel.getParent().layout(); newImageTypeText.getParent().layout(); - // newImageGroup.layout(); - // super.initializeBounds(); - } + /** + * Update tab folder and the tabs. + */ private void updateTabFolder() { if ( currentImageSaveButton != null ) @@ -545,6 +567,13 @@ } + /** + * Resizes the image. + * + * @param imageData the image data to resize + * + * @return the resized image data + */ private ImageData resizeImage( ImageData imageData ) { double widthScaleFactor = 1.0; @@ -575,6 +604,13 @@ } + /** + * Creates the image label. + * + * @param parent the parent + * + * @return the image label + */ private Label createImageLabel( Composite parent ) { Composite labelComposite = new Composite( parent, SWT.BORDER ); @@ -593,6 +629,13 @@ } + /** + * Creates the image info container. + * + * @param parent the parent + * + * @return the image info container + */ private Composite createImageInfoContainer( Composite parent ) { Composite imageInfoContainer = new Composite( parent, SWT.NONE ); @@ -604,6 +647,14 @@ } + /** + * Creates the image info. + * + * @param label the label + * @param parent the parent + * + * @return the image info + */ private Text createImageInfo( Composite parent, String label ) { BaseWidgetUtils.createLabel( parent, label, 1 ); @@ -612,6 +663,14 @@ } + /** + * Creates the button. + * + * @param label the label + * @param parent the parent + * + * @return the button + */ private Button createButton( Composite parent, String label ) { Button button = BaseWidgetUtils.createButton( parent, label, 1 ); @@ -619,17 +678,37 @@ } - public static String getSizeString( int length ) + /** + * Gets the size string. + * + * @param length the length + * + * @return the size string + */ + private static String getSizeString( int length ) { if ( length > 1000000 ) + { return ( length / 1000000 ) + " MB (" + length + " bytes)"; + } else if ( length > 1000 ) + { return ( length / 1000 ) + " KB (" + length + " bytes)"; + } else + { return length + " bytes"; + } } + /** + * Gets the image info. + * + * @param imageRawData the image raw data + * + * @return the image info + */ public static String getImageInfo( byte[] imageRawData ) { @@ -659,28 +738,45 @@ } - public static String getImageType( int swtCode ) + /** + * Gets the image type. + * + * @param swtCode the swt code + * + * @return the image type + */ + private static String getImageType( int swtCode ) { String type = ""; + if ( swtCode == SWT.IMAGE_JPEG ) + { type = "JPEG"; + } else if ( swtCode == SWT.IMAGE_GIF ) + { type = "GIF"; + } else if ( swtCode == SWT.IMAGE_PNG ) + { type = "PNG"; + } else if ( swtCode == SWT.IMAGE_BMP || swtCode == SWT.IMAGE_BMP_RLE ) + { type = "BMP"; + } + return type; } /** - * + * Gets the iimage data in required format. * * @return Returns the image data in required format or null. */ public byte[] getNewImageRawData() { - return this.newImageRawDataInRequiredFormat; + return newImageRawDataInRequiredFormat; } }