directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r477206 - in /directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser: controller/actions/ view/views/
Date Mon, 20 Nov 2006 14:49:59 GMT
Author: pamarcelot
Date: Mon Nov 20 06:49:55 2006
New Revision: 477206

URL: http://svn.apache.org/viewvc?view=rev&rev=477206
Log:
Reformating the code using the Eclipse code template and formating features.

Modified:
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeNewAction.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizard.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizardPage.java

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeNewAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeNewAction.java?view=diff&rev=477206&r1=477205&r2=477206
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeNewAction.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/AttributeNewAction.java
Mon Nov 20 06:49:55 2006
@@ -51,7 +51,7 @@
     public void run()
     {
         // Creating the Wizard and opening it
-    	AttributeAddWizard wizard = new AttributeAddWizard();
+        AttributeAddWizard wizard = new AttributeAddWizard();
         WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
wizard );
         dialog.create();
         dialog.open();

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizard.java?view=diff&rev=477206&r1=477205&r2=477206
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizard.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizard.java
Mon Nov 20 06:49:55 2006
@@ -20,26 +20,30 @@
 
 package org.apache.directory.ldapstudio.browser.view.views;
 
+
 import org.eclipse.jface.wizard.Wizard;
 
 
 /**
  * This class implements the Attribute Add Wizard
  */
-public class AttributeAddWizard extends Wizard {
+public class AttributeAddWizard extends Wizard
+{
 
     private AttributeAddWizardPage attributeAddWizardPage;
-    
+
+
     /**
      * Default constructor
      */
-    public AttributeAddWizard() 
+    public AttributeAddWizard()
     {
-    	attributeAddWizardPage = new AttributeAddWizardPage();
+        attributeAddWizardPage = new AttributeAddWizardPage();
         addPage( attributeAddWizardPage );
         setWindowTitle( "Add a new attribute" );
-	}
-	
+    }
+
+
     /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#needsPreviousAndNextButtons()
      */
@@ -48,7 +52,8 @@
     {
         return false;
     }
-    
+
+
     /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#canFinish()
      */
@@ -57,6 +62,7 @@
     {
         return attributeAddWizardPage.canFinish();
     }
+
 
     /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#performFinish()

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizardPage.java?view=diff&rev=477206&r1=477205&r2=477206
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizardPage.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributeAddWizardPage.java
Mon Nov 20 06:49:55 2006
@@ -20,6 +20,7 @@
 
 package org.apache.directory.ldapstudio.browser.view.views;
 
+
 import java.io.File;
 
 import javax.naming.directory.Attributes;
@@ -53,165 +54,170 @@
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 
+
 /**
  * This class implements the Attribute Add Wizard Page of the Attribute Add Wizard
  * TODO Add support for Binary File...
  */
-public class AttributeAddWizardPage  extends WizardPage 
+public class AttributeAddWizardPage extends WizardPage
 {
 
-	private Label nameLabel;
-	private Text nameText;
-	private Group valueGroup;
-	private Button textChoice;
-	private Text textText;
-	private Button binaryFileChoice;
-	private Text binaryFileText;
-	private Button binaryFileBrowseButton;
-
-	/**
-	 * Default constructor
-	 */
-	protected AttributeAddWizardPage() 
-	{
+    private Label nameLabel;
+    private Text nameText;
+    private Group valueGroup;
+    private Button textChoice;
+    private Text textText;
+    private Button binaryFileChoice;
+    private Text binaryFileText;
+    private Button binaryFileBrowseButton;
+
+
+    /**
+     * Default constructor
+     */
+    protected AttributeAddWizardPage()
+    {
         super( "AttributeAddWizardPage" );
         setTitle( "Add a new attribute" );
         setDescription( "Specify information for the new attribute" );
-        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
-            ImageKeys.WIZARD_ATTRIBUTE ) );
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
-	 */
-	public void createControl(Composite parent) 
-	{
-		Composite container = new Composite( parent, SWT.NULL );
+        setImageDescriptor( AbstractUIPlugin
+            .imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.WIZARD_ATTRIBUTE )
);
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        Composite container = new Composite( parent, SWT.NULL );
         GridLayout layout = new GridLayout();
         container.setLayout( layout );
         layout.numColumns = 2;
-        
+
         // Name
         nameLabel = new Label( container, SWT.NONE );
         nameLabel.setText( "Name:" );
         nameText = new Text( container, SWT.BORDER );
         nameText.setText( "" );
         nameText.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, false ) );
-        
+
         // Value Group
         valueGroup = new Group( container, SWT.NONE );
         valueGroup.setText( "Value" );
         valueGroup.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, false, 2,
1 ) );
         valueGroup.setLayout( new GridLayout( 3, false ) );
-        
+
         // Text Choice
         textChoice = new Button( valueGroup, SWT.RADIO );
         textChoice.setText( "Text:" );
         textChoice.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false ) );
-        
+
         // Text 
         textText = new Text( valueGroup, SWT.BORDER );
         textText.setText( "" );
         textText.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, false, 2, 1
) );
-        
+
         // Binary File Choice
         binaryFileChoice = new Button( valueGroup, SWT.RADIO );
         binaryFileChoice.setText( "Binary file:" );
         binaryFileChoice.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false )
);
-        
+
         // Binary File 
         binaryFileText = new Text( valueGroup, SWT.BORDER );
         binaryFileText.setText( "" );
         binaryFileText.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, false
) );
-        
+
         // Binary File Browse
         binaryFileBrowseButton = new Button( valueGroup, SWT.NONE );
         binaryFileBrowseButton.setText( "Browse..." );
         binaryFileBrowseButton.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false
) );
-        
+
         setControl( nameText );
-        
+
         initFields();
-        
+
         initListeners();
-        
+
         verifyPage();
-	}
+    }
+
+
+    /**
+     * Initializes the fields of the UI with default values
+     */
+    private void initFields()
+    {
+        // The default choice is Text, so Binary File Widgets are disabled
+        textChoice.setSelection( true );
+        textText.setEnabled( true );
+        binaryFileChoice.setSelection( false );
+        binaryFileText.setEnabled( false );
+        binaryFileBrowseButton.setEnabled( false );
+    }
+
+
+    /**
+     * Initializes the listeners on SWT widgets
+     */
+    private void initListeners()
+    {
+        // Name
+        nameText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                verifyPage();
+            }
+        } );
 
-	/**
-	 * Initializes the fields of the UI with default values
-	 */
-	private void initFields() 
-	{
-		// The default choice is Text, so Binary File Widgets are disabled
-		textChoice.setSelection( true );
-		textText.setEnabled( true );
-		binaryFileChoice.setSelection( false );
-		binaryFileText.setEnabled( false );
-		binaryFileBrowseButton.setEnabled( false );
-	}
-
-	/**
-	 * Initializes the listeners on SWT widgets
-	 */
-	private void initListeners()
-	{
-		// Name
-		nameText.addModifyListener( new ModifyListener() 
-		{
-			public void modifyText(ModifyEvent e) 
-			{
-				verifyPage();
-			}
-		});
-		
         // Text Choice
         textChoice.addSelectionListener( new SelectionAdapter()
         {
             public void widgetSelected( SelectionEvent e )
             {
-            	textChoice.setSelection(true);
-            	binaryFileChoice.setSelection( false );
-            	binaryFileText.setEnabled( false );
-            	binaryFileBrowseButton.setEnabled( false );
-            	textText.setEnabled( true );
-            	verifyPage();
+                textChoice.setSelection( true );
+                binaryFileChoice.setSelection( false );
+                binaryFileText.setEnabled( false );
+                binaryFileBrowseButton.setEnabled( false );
+                textText.setEnabled( true );
+                verifyPage();
             }
-        });
-		
-		// Text
-		textText.addModifyListener( new ModifyListener() 
-		{
-			public void modifyText(ModifyEvent e) 
-			{
-				verifyPage();
-			}
-		});
-		
-		// Binary File Choice
-		binaryFileChoice.addSelectionListener( new SelectionAdapter()
+        } );
+
+        // Text
+        textText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                verifyPage();
+            }
+        } );
+
+        // Binary File Choice
+        binaryFileChoice.addSelectionListener( new SelectionAdapter()
         {
             public void widgetSelected( SelectionEvent e )
             {
-            	binaryFileChoice.setSelection( true );
-            	textChoice.setSelection( false );
-            	textText.setEnabled( false );
-            	binaryFileText.setEnabled( true );
-            	binaryFileBrowseButton.setEnabled( true );
-            	verifyPage();
+                binaryFileChoice.setSelection( true );
+                textChoice.setSelection( false );
+                textText.setEnabled( false );
+                binaryFileText.setEnabled( true );
+                binaryFileBrowseButton.setEnabled( true );
+                verifyPage();
+            }
+        } );
+
+        // Binary File
+        binaryFileText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                verifyPage();
             }
-        });
-		
-		// Binary File
-		binaryFileText.addModifyListener( new ModifyListener() 
-		{
-			public void modifyText(ModifyEvent e) 
-			{
-				verifyPage();
-			}
-		});
-		
-		// Binary File Button
+        } );
+
+        // Binary File Button
         // Input File Browse Button
         binaryFileBrowseButton.addSelectionListener( new SelectionAdapter()
         {
@@ -232,32 +238,33 @@
                 verifyPage();
             }
         } );
-	}
+    }
+
+
+    /**
+     * Verifies the status of the page and updates the complete state
+     */
+    private void verifyPage()
+    {
+        // Reseting previous message
+        setErrorMessage( null );
+        setPageComplete( true );
 
-	/**
-	 * Verifies the status of the page and updates the complete state
-	 */
-	private void verifyPage() 
-	{
-		// Reseting previous message
-	    setErrorMessage( null );
-	    setPageComplete( true );
-	    
         if ( ( nameText.getText() == null ) || ( "".equals( nameText.getText() ) ) )
-	    {
+        {
             setErrorMessage( "Name can't be empty." );
             setPageComplete( false );
             return;
-	    }
-        
+        }
+
         if ( binaryFileChoice.getSelection() )
         {
             if ( ( binaryFileText.getText() == null ) || ( "".equals( binaryFileText.getText()
) ) )
-    	    {
+            {
                 setErrorMessage( "A binary file must be provided." );
                 setPageComplete( false );
                 return;
-    	    }
+            }
             else
             {
                 File checkFile = new File( binaryFileText.getText() );
@@ -270,8 +277,9 @@
                 }
             }
         }
-	}
-	
+    }
+
+
     /**
      * Indicates if the Wizard is able to finish
      * @return true if the Wizard is able to finish
@@ -280,8 +288,8 @@
     {
         return isPageComplete();
     }
-    
-    
+
+
     /**
      * Adds the new attribute and its value to the entry
      */
@@ -289,72 +297,70 @@
     {
         try
         {
-	    	// Getting the Browser View
-	        BrowserView browserView = ( BrowserView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
-	            .getActivePage().findView( BrowserView.ID );
-	    	
-	        EntryWrapper entryWrapper = ( EntryWrapper ) ( ( TreeSelection ) browserView.getViewer().getSelection()
)
-	        .getFirstElement();
-	        Connection connection = entryWrapper.getConnection();
-	        SearchResultEntry entry = entryWrapper.getEntry();
-	        
-	        
-	        // Initialization of the DSML Engine and the DSML Response Parser
-	        Dsmlv2Engine engine = new Dsmlv2Engine( connection.getHost(), connection.getPort(),
connection.getUserDN()
-	            .getNormName(), connection.getPassword() );
-	        Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
-	        
-	        String request = "<batchRequest>" + "	<modifyRequest dn=\""
-            + entry.getObjectName().getNormName().toString() + "\">" + "		<modification
name=\""
-            + nameText.getText() + "\" operation=\"add\">" + "       	<value>" +
textText.getText() + "</value>"
-            + "       </modification>" + "	</modifyRequest>" + "</batchRequest>";
-
-        parser.setInput( engine.processDSML( request ) );
-        parser.parse();
+            // Getting the Browser View
+            BrowserView browserView = ( BrowserView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                .getActivePage().findView( BrowserView.ID );
+
+            EntryWrapper entryWrapper = ( EntryWrapper ) ( ( TreeSelection ) browserView.getViewer().getSelection()
)
+                .getFirstElement();
+            Connection connection = entryWrapper.getConnection();
+            SearchResultEntry entry = entryWrapper.getEntry();
+
+            // Initialization of the DSML Engine and the DSML Response Parser
+            Dsmlv2Engine engine = new Dsmlv2Engine( connection.getHost(), connection.getPort(),
connection.getUserDN()
+                .getNormName(), connection.getPassword() );
+            Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
+
+            String request = "<batchRequest>" + "	<modifyRequest dn=\""
+                + entry.getObjectName().getNormName().toString() + "\">" + "		<modification
name=\""
+                + nameText.getText() + "\" operation=\"add\">" + "       	<value>"
+ textText.getText() + "</value>"
+                + "       </modification>" + "	</modifyRequest>" + "</batchRequest>";
 
-        LdapResponse ldapResponse = parser.getBatchResponse().getCurrentResponse();
+            parser.setInput( engine.processDSML( request ) );
+            parser.parse();
 
-        if ( ldapResponse instanceof ModifyResponse )
-        {
-            ModifyResponse modifyResponse = ( ModifyResponse ) ldapResponse;
+            LdapResponse ldapResponse = parser.getBatchResponse().getCurrentResponse();
 
-            if ( modifyResponse.getLdapResult().getResultCode() == 0 )
+            if ( ldapResponse instanceof ModifyResponse )
             {
-                // Adding the provided attribute value
-                Attributes attributes = entry.getPartialAttributeList();
-                
-                attributes.put( nameText.getText(), textText.getText() );
-
-                
-                // refreshing the UI
-    	        AttributesView attributesView = ( AttributesView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
-    	            .getActivePage().findView( AttributesView.ID );
-    	        attributesView.setInput( entryWrapper );
-    	        attributesView.resizeColumsToFit();
+                ModifyResponse modifyResponse = ( ModifyResponse ) ldapResponse;
+
+                if ( modifyResponse.getLdapResult().getResultCode() == 0 )
+                {
+                    // Adding the provided attribute value
+                    Attributes attributes = entry.getPartialAttributeList();
+
+                    attributes.put( nameText.getText(), textText.getText() );
+
+                    // refreshing the UI
+                    AttributesView attributesView = ( AttributesView ) PlatformUI.getWorkbench()
+                        .getActiveWorkbenchWindow().getActivePage().findView( AttributesView.ID
);
+                    attributesView.setInput( entryWrapper );
+                    attributesView.resizeColumsToFit();
+                }
+                else
+                {
+                    // Displaying an error
+                    MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+                        "Error !", "An error has ocurred.\n" + modifyResponse.getLdapResult().getErrorMessage()
);
+                }
             }
-            else
+            else if ( ldapResponse instanceof ErrorResponse )
             {
+                ErrorResponse errorResponse = ( ErrorResponse ) ldapResponse;
+
                 // Displaying an error
-                MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
-                    "Error !", "An error has ocurred.\n" + modifyResponse.getLdapResult().getErrorMessage()
);
+                MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Error !",
+                    "An error has ocurred.\n" + errorResponse.getMessage() );
             }
         }
-        else if ( ldapResponse instanceof ErrorResponse )
-        {
-            ErrorResponse errorResponse = ( ErrorResponse ) ldapResponse;
-
-            // Displaying an error
-            MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Error !",
-                "An error has ocurred.\n" + errorResponse.getMessage() );
-        }
-        }
         catch ( Exception e )
         {
             // Displaying an error
             MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Error !",
                 "An error has ocurred.\n" + e.getMessage() );
         }
-        
-    	return true;
+
+        return true;
     }
 }



Mime
View raw message