directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r514392 - in /directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui: widgets/ wizards/
Date Sun, 04 Mar 2007 12:49:22 GMT
Author: seelmann
Date: Sun Mar  4 04:49:21 2007
New Revision: 514392

URL: http://svn.apache.org/viewvc?view=rev&rev=514392
Log:
Small refactorings, code cleaning, Javadocs

Removed:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ObjectClassWidget.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ModWidget.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ViewFormWidget.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyEvent.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyListener.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationModifyWizardPage.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java?view=diff&rev=514392&r1=514391&r2=514392
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/DnBuilderWidget.java
Sun Mar  4 04:49:21 2007
@@ -40,7 +40,6 @@
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
@@ -169,7 +168,7 @@
                     rdnLineList.get( i ).rdnValueText.setText( parts[i].getUnencodedValue()
);
                     if ( i == 0 )
                     {
-                        if("".equals(rdnLineList.get( i ).rdnNameCombo))
+                        if ( "".equals( rdnLineList.get( i ).rdnNameCombo ) )
                         {
                             rdnLineList.get( i ).rdnNameCombo.setFocus();
                         }
@@ -287,7 +286,7 @@
 
 
     /**
-     * Validate.
+     * Validates the input elements.
      */
     public void validate()
     {
@@ -432,7 +431,6 @@
             rdnLineList.add( rdnLine );
         }
 
-        rdnComposite.layout( true, true );
         shell.layout( true, true );
     }
 
@@ -482,7 +480,7 @@
 
         rdnLine.rdnAddButton = new Button( rdnComposite, SWT.PUSH );
         rdnLine.rdnAddButton.setText( "  +   " );
-        rdnLine.rdnAddButton.addSelectionListener( new SelectionListener()
+        rdnLine.rdnAddButton.addSelectionListener( new SelectionAdapter()
         {
             public void widgetSelected( SelectionEvent e )
             {
@@ -499,11 +497,6 @@
 
                 validate();
             }
-
-
-            public void widgetDefaultSelected( SelectionEvent e )
-            {
-            }
         } );
 
         rdnLine.rdnDeleteButton = new Button( rdnComposite, SWT.PUSH );
@@ -558,38 +551,45 @@
 
             if ( !rdnComposite.isDisposed() )
             {
-                rdnComposite.layout( true, true );
                 shell.layout( true, true );
             }
         }
     }
 
     /**
-     * The Class RdnLine.
+     * The Class RdnLine is a wrapper for all input elements
+     * of an RDN line. It contains a combo for the RDN attribute, 
+     * an input field for the RDN value and + and - buttons
+     * to add and remove other RDN lines. It looks like this:
+     * <pre>
+     * --------------------------------------------------
+     * | attribute type v | = | attribute value | + | - |
+     * --------------------------------------------------
+     * </pre>
      */
-    public class RdnLine
+    private class RdnLine
     {
 
         /** The rdn name combo. */
-        public DecoratedField rdnNameComboField;
+        private DecoratedField rdnNameComboField;
 
         /** The rdn name combo. */
-        public Combo rdnNameCombo;
+        private Combo rdnNameCombo;
 
         /** The content proposal adapter */
-        public ContentProposalAdapter rdnNameCPA;
+        private ContentProposalAdapter rdnNameCPA;
 
         /** The rdn value text. */
-        public Text rdnValueText;
+        private Text rdnValueText;
 
         /** The rdn equals label. */
-        public Label rdnEqualsLabel;
+        private Label rdnEqualsLabel;
 
         /** The rdn add button. */
-        public Button rdnAddButton;
+        private Button rdnAddButton;
 
         /** The rdn delete button. */
-        public Button rdnDeleteButton;
+        private Button rdnDeleteButton;
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java?view=diff&rev=514392&r1=514391&r2=514392
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/LineSeparatorInput.java
Sun Mar  4 04:49:21 2007
@@ -96,6 +96,7 @@
      * 
      * @return the other display values
      */
+    @SuppressWarnings("unchecked")
     private static String[] getOtherDisplayValues()
     {
         Map<String, String> lsMap = Platform.knownPlatformLineSeparators();
@@ -116,6 +117,7 @@
      * 
      * @return the other raw values
      */
+    @SuppressWarnings("unchecked")
     private static String[] getOtherRawValues()
     {
         Map<String, String> lsMap = Platform.knownPlatformLineSeparators();

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ModWidget.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ModWidget.java?view=diff&rev=514392&r1=514391&r2=514392
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ModWidget.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ModWidget.java
Sun Mar  4 04:49:21 2007
@@ -23,133 +23,135 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
 
 import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants;
 import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
-
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.fieldassist.ComboContentAdapter;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.DecoratedField;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.IControlCreator;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 
 
-public class ModWidget implements ModifyListener
+/**
+ * The ModWidget provides input elements to define an LDAP modify 
+ * operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModWidget extends BrowserWidget implements ModifyListener
 {
 
+    /** The schema with the possible attribute types */
     private Schema schema;
 
+    /** The shell */
     private Shell shell;
 
+    /** The composite that contains the ModSpecs */
     private Composite modComposite;
 
-    private ArrayList modGroupList;
-
-    private int modCompositeHeight = -1;
+    /** The list of ModSpecs */
+    private ArrayList<ModSpec> modSpecList;
 
+    /** The resulting LDIF */
     private String ldif;
 
 
+    /**
+     * Creates a new instance of ModWidget.
+     *
+     * @param schema the schema with the possible attribute types
+     */
     public ModWidget( Schema schema )
     {
         this.schema = schema;
-        this.modGroupList = new ArrayList();
+        this.modSpecList = new ArrayList<ModSpec>();
         this.ldif = null;
     }
 
 
+    /**
+     * Disposes this widget.
+     */
     public void dispose()
     {
     }
 
 
+    /**
+     * Gets the ldif.
+     * 
+     * @return the ldif
+     */
     public String getLdif()
     {
-        return this.ldif;
+        return ldif;
     }
 
 
+    /**
+     * Creates the contents.
+     * 
+     * @param parent the parent composite
+     * 
+     * @return the created composite
+     */
     public Composite createContents( Composite parent )
     {
-        this.shell = parent.getShell();
+        shell = parent.getShell();
 
         modComposite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 );
-        addModGroup( this.modComposite, 0 );
+        addModSpec( modComposite, 0 );
 
         return modComposite;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void modifyText( ModifyEvent e )
     {
-        this.validate();
-    }
-
-    private List listeners;
-
-
-    public void addPropertyChangeListener( IPropertyChangeListener listener )
-    {
-        if ( listeners == null )
-            listeners = new ArrayList();
-
-        if ( !listeners.contains( listener ) )
-            listeners.add( listener );
-    }
-
-
-    public void removePropertyChangeListener( IPropertyChangeListener listener )
-    {
-        if ( listeners == null )
-            return;
-
-        if ( listeners.contains( listener ) )
-            listeners.remove( listener );
-    }
-
-
-    private void fire( String property, Object oldValue, Object newValue )
-    {
-        if ( listeners == null )
-            return;
-
-        for ( Iterator it = listeners.iterator(); it.hasNext(); )
-        {
-            ( ( IPropertyChangeListener ) it.next() ).propertyChange( new PropertyChangeEvent(
this, property,
-                oldValue, newValue ) );
-        }
+        validate();
     }
 
 
+    /**
+     * Validates the input elements.
+     */
     public void validate()
     {
-
-        for ( int i = 0; i < this.modGroupList.size(); i++ )
+        for ( int i = 0; i < modSpecList.size(); i++ )
         {
-            ModGroup modGroup = ( ModGroup ) this.modGroupList.get( i );
-            if ( this.modGroupList.size() > 1 )
+            ModSpec modSpec = ( ModSpec ) modSpecList.get( i );
+            if ( modSpecList.size() > 1 )
             {
-                modGroup.modDeleteButton.setEnabled( true );
+                modSpec.modDeleteButton.setEnabled( true );
             }
             else
             {
-                modGroup.modDeleteButton.setEnabled( false );
+                modSpec.modDeleteButton.setEnabled( false );
             }
-            for ( int k = 0; k < modGroup.valueLineList.size(); k++ )
+            for ( int k = 0; k < modSpec.valueLineList.size(); k++ )
             {
-                ValueLine valueLine = ( ValueLine ) modGroup.valueLineList.get( k );
-                if ( modGroup.valueLineList.size() > 1 )
+                ValueLine valueLine = ( ValueLine ) modSpec.valueLineList.get( k );
+                if ( modSpec.valueLineList.size() > 1 )
                 {
                     valueLine.valueDeleteButton.setEnabled( true );
                 }
@@ -160,174 +162,204 @@
             }
         }
 
-        fire( "ldif", null, null );
+        notifyListeners();
     }
 
 
-    private void addModGroup( Composite modComposite, int index )
+    /**
+     * Adds a modification spec at the given index.
+     * 
+     * @param modComposite the composite
+     * @param index the index
+     */
+    private void addModSpec( Composite modComposite, int index )
     {
 
-        ModGroup[] modGroups = ( ModGroup[] ) modGroupList.toArray( new ModGroup[modGroupList.size()]
);
+        ModSpec[] modSpecs = ( ModSpec[] ) modSpecList.toArray( new ModSpec[modSpecList.size()]
);
 
-        if ( modGroups.length > 0 )
+        if ( modSpecs.length > 0 )
         {
-            for ( int i = 0; i < modGroups.length; i++ )
+            for ( int i = 0; i < modSpecs.length; i++ )
             {
-                ModGroup oldModGroup = modGroups[i];
+                ModSpec oldModSpec = modSpecs[i];
 
                 // remember values
-                String oldType = oldModGroup.modType.getText();
-                String oldAttribute = oldModGroup.modAttribute.getText();
-                String[] oldValues = new String[oldModGroup.valueLineList.size()];
+                String oldType = oldModSpec.modType.getText();
+                String oldAttribute = oldModSpec.modAttributeCombo.getText();
+                String[] oldValues = new String[oldModSpec.valueLineList.size()];
                 for ( int k = 0; k < oldValues.length; k++ )
                 {
-                    oldValues[k] = ( ( ValueLine ) oldModGroup.valueLineList.get( k ) ).valueText.getText();
+                    oldValues[k] = ( ( ValueLine ) oldModSpec.valueLineList.get( k ) ).valueText.getText();
                 }
 
                 // delete old
-                oldModGroup.modGroup.dispose();
-                oldModGroup.modAddButton.dispose();
-                oldModGroup.modDeleteButton.dispose();
-                modGroupList.remove( oldModGroup );
+                oldModSpec.modGroup.dispose();
+                oldModSpec.modAddButton.dispose();
+                oldModSpec.modDeleteButton.dispose();
+                modSpecList.remove( oldModSpec );
 
                 // add new
-                ModGroup newModGroup = createModGroup( modComposite );
-                modGroupList.add( newModGroup );
+                ModSpec newModSpec = createModSpec( modComposite );
+                modSpecList.add( newModSpec );
 
                 // restore values
-                newModGroup.modType.setText( oldType );
-                newModGroup.modAttribute.setText( oldAttribute );
-                deleteValueLine( newModGroup, 0 );
+                newModSpec.modType.setText( oldType );
+                newModSpec.modAttributeCombo.setText( oldAttribute );
+                deleteValueLine( newModSpec, 0 );
                 for ( int k = 0; k < oldValues.length; k++ )
                 {
-                    addValueLine( newModGroup, k );
-                    ValueLine newValueLine = ( ValueLine ) newModGroup.valueLineList.get(
k );
+                    addValueLine( newModSpec, k );
+                    ValueLine newValueLine = ( ValueLine ) newModSpec.valueLineList.get(
k );
                     newValueLine.valueText.setText( oldValues[k] );
                 }
 
                 // check
                 if ( index == i + 1 )
                 {
-                    ModGroup modGroup = createModGroup( modComposite );
-                    modGroupList.add( modGroup );
-
+                    ModSpec modSpec = createModSpec( modComposite );
+                    modSpecList.add( modSpec );
                 }
             }
         }
         else
         {
-            ModGroup modGroup = createModGroup( modComposite );
-            modGroupList.add( modGroup );
+            ModSpec modSpec = createModSpec( modComposite );
+            modSpecList.add( modSpec );
         }
+
+        shell.layout( true, true );
     }
 
 
-    private ModGroup createModGroup( final Composite modComposite )
+    /**
+     * Creates and returns a modification spec.
+     * 
+     * @param modComposite the composite
+     * 
+     * @return the created modification spec
+     */
+    private ModSpec createModSpec( final Composite modComposite )
     {
-        final ModGroup modGroup = new ModGroup();
+        final ModSpec modSpec = new ModSpec();
 
-        // this.connection.getSchema().getAttributeTypeDescriptionNames()
-        modGroup.modGroup = BaseWidgetUtils.createGroup( modComposite, "", 1 );
-        Composite modGroupComposite = BaseWidgetUtils.createColumnContainer( modGroup.modGroup,
2, 1 );
-        modGroup.modType = BaseWidgetUtils.createCombo( modGroupComposite, new String[]
+        modSpec.modGroup = BaseWidgetUtils.createGroup( modComposite, "", 1 );
+        Composite modSpecComposite = BaseWidgetUtils.createColumnContainer( modSpec.modGroup,
2, 1 );
+        modSpec.modType = BaseWidgetUtils.createCombo( modSpecComposite, new String[]
             { "add", "replace", "delete" }, 0, 1 );
-        modGroup.modType.addModifyListener( this );
+        modSpec.modType.addModifyListener( this );
         String[] attributeDescriptions = schema.getAttributeTypeDescriptionNames();
         Arrays.sort( attributeDescriptions );
-        modGroup.modAttribute = BaseWidgetUtils.createCombo( modGroupComposite, attributeDescriptions,
-1, 1 );
-        modGroup.modAttribute.addModifyListener( this );
 
-        modGroup.modAddButton = new Button( modComposite, SWT.PUSH );
-        modGroup.modAddButton.setText( "  +   " );
-        modGroup.modAddButton.addSelectionListener( new SelectionListener()
+        // attribute combo with field decoration
+        final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(
+            FieldDecorationRegistry.DEC_CONTENT_PROPOSAL );
+        modSpec.modAttributeComboField = new DecoratedField( modSpecComposite, SWT.NONE,
new IControlCreator()
+        {
+            public Control createControl( Composite parent, int style )
+            {
+                Combo combo = BaseWidgetUtils.createCombo( parent, new String[0], -1, 1 );
+                combo.setVisibleItemCount( 20 );
+                return combo;
+            }
+        } );
+        modSpec.modAttributeComboField.addFieldDecoration( fieldDecoration, SWT.TOP | SWT.LEFT,
true );
+        modSpec.modAttributeComboField.getLayoutControl().setLayoutData(
+            new GridData( SWT.FILL, SWT.CENTER, true, false ) );
+        modSpec.modAttributeCombo = ( Combo ) modSpec.modAttributeComboField.getControl();
+        modSpec.modAttributeCombo.setItems( attributeDescriptions );
+        modSpec.modAttributeCombo.addModifyListener( this );
+
+        // content proposal adapter
+        modSpec.modAttributeCPA = new ContentProposalAdapter( modSpec.modAttributeCombo,
new ComboContentAdapter(),
+            new ListContentProposalProvider( attributeDescriptions ), null, null );
+        modSpec.modAttributeCPA.setFilterStyle( ContentProposalAdapter.FILTER_NONE );
+        modSpec.modAttributeCPA.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE
);
+
+        // add button with listener
+        modSpec.modAddButton = new Button( modComposite, SWT.PUSH );
+        modSpec.modAddButton.setText( "  +   " );
+        modSpec.modAddButton.addSelectionListener( new SelectionAdapter()
         {
             public void widgetSelected( SelectionEvent e )
             {
-                int index = modGroupList.size();
-                for ( int i = 0; i < modGroupList.size(); i++ )
+                int index = modSpecList.size();
+                for ( int i = 0; i < modSpecList.size(); i++ )
                 {
-                    ModGroup modGroup = ( ModGroup ) modGroupList.get( i );
-                    if ( modGroup.modAddButton == e.widget )
+                    ModSpec modSpec = modSpecList.get( i );
+                    if ( modSpec.modAddButton == e.widget )
                     {
                         index = i + 1;
                     }
                 }
-                addModGroup( modComposite, index );
 
-                Point shellSize = shell.getSize();
-                Point modCompositeSize = modComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT,
true );
-                int newModCompositeSize = modCompositeSize.y;
-                shell.setSize( shellSize.x, shellSize.y + newModCompositeSize - modCompositeHeight
);
-                modComposite.layout( true, true );
-                shell.layout( true, true );
-                modCompositeHeight = newModCompositeSize;
+                addModSpec( modComposite, index );
 
                 validate();
             }
-
-
-            public void widgetDefaultSelected( SelectionEvent e )
-            {
-            }
         } );
 
-        modGroup.modDeleteButton = new Button( modComposite, SWT.PUSH );
-        modGroup.modDeleteButton.setText( "  \u2212  " ); // \u2013
-        modGroup.modDeleteButton.addSelectionListener( new SelectionListener()
+        // delete button with listener
+        modSpec.modDeleteButton = new Button( modComposite, SWT.PUSH );
+        modSpec.modDeleteButton.setText( "  \u2212  " ); // \u2013
+        modSpec.modDeleteButton.addSelectionListener( new SelectionAdapter()
         {
             public void widgetSelected( SelectionEvent e )
             {
                 int index = 0;
-                for ( int i = 0; i < modGroupList.size(); i++ )
+                for ( int i = 0; i < modSpecList.size(); i++ )
                 {
-                    ModGroup modGroup = ( ModGroup ) modGroupList.get( i );
-                    if ( modGroup.modDeleteButton == e.widget )
+                    ModSpec modSpec = modSpecList.get( i );
+                    if ( modSpec.modDeleteButton == e.widget )
                     {
                         index = i;
                     }
                 }
-                deleteModGroup( modComposite, index );
 
-                Point shellSize = shell.getSize();
-                Point groupSize = modComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true
);
-                int newModCompositeSize = groupSize.y;
-                shell.setSize( shellSize.x, shellSize.y + newModCompositeSize - modCompositeHeight
);
-                modComposite.layout( true, true );
-                shell.layout( true, true );
-                modCompositeHeight = newModCompositeSize;
+                deleteModSpec( modComposite, index );
 
                 validate();
             }
-
-
-            public void widgetDefaultSelected( SelectionEvent e )
-            {
-            }
         } );
 
-        addValueLine( modGroup, 0 );
+        addValueLine( modSpec, 0 );
 
-        return modGroup;
+        return modSpec;
     }
 
 
-    private void deleteModGroup( Composite modComposite, int index )
+    /**
+     * Delets a modification spec.
+     *
+     * @param modComposite the composite
+     * @param index the index
+     */
+    private void deleteModSpec( Composite modComposite, int index )
     {
-        ModGroup modGroup = ( ModGroup ) modGroupList.remove( index );
-        if ( modGroup != null )
+        ModSpec modSpec = modSpecList.remove( index );
+        if ( modSpec != null )
         {
-            modGroup.modGroup.dispose();
-            modGroup.modAddButton.dispose();
-            modGroup.modDeleteButton.dispose();
+            modSpec.modGroup.dispose();
+            modSpec.modAddButton.dispose();
+            modSpec.modDeleteButton.dispose();
+
+            if ( !modComposite.isDisposed() )
+            {
+                shell.layout( true, true );
+            }
         }
     }
 
 
-    private void addValueLine( ModGroup modGroup, int index )
+    /**
+     * Adds a value line to the given modification spec.
+     * 
+     * @param modSpec the modification spec
+     * @param index the index
+     */
+    private void addValueLine( ModSpec modSpec, int index )
     {
 
-        ValueLine[] valueLines = ( ValueLine[] ) modGroup.valueLineList.toArray( new ValueLine[modGroup.valueLineList
-            .size()] );
+        ValueLine[] valueLines = modSpec.valueLineList.toArray( new ValueLine[modSpec.valueLineList.size()]
);
 
         if ( valueLines.length > 0 )
         {
@@ -340,11 +372,11 @@
 
                 // delete old
                 oldValueLine.valueComposite.dispose();
-                modGroup.valueLineList.remove( oldValueLine );
+                modSpec.valueLineList.remove( oldValueLine );
 
                 // add new
-                ValueLine newValueLine = createValueLine( modGroup );
-                modGroup.valueLineList.add( newValueLine );
+                ValueLine newValueLine = createValueLine( modSpec );
+                modSpec.valueLineList.add( newValueLine );
 
                 // restore value
                 newValueLine.valueText.setText( oldValue );
@@ -352,131 +384,134 @@
                 // check
                 if ( index == i + 1 )
                 {
-                    ValueLine valueLine = createValueLine( modGroup );
-                    modGroup.valueLineList.add( valueLine );
+                    ValueLine valueLine = createValueLine( modSpec );
+                    modSpec.valueLineList.add( valueLine );
                 }
             }
         }
         else
         {
-            ValueLine valueLine = createValueLine( modGroup );
-            modGroup.valueLineList.add( valueLine );
+            ValueLine valueLine = createValueLine( modSpec );
+            modSpec.valueLineList.add( valueLine );
         }
+
+        shell.layout( true, true );
     }
 
 
-    private ValueLine createValueLine( final ModGroup modGroup )
+    /**
+     * Creates the value line.
+     * 
+     * @param modSpec the modification spec
+     * 
+     * @return the value line
+     */
+    private ValueLine createValueLine( final ModSpec modSpec )
     {
         final ValueLine valueLine = new ValueLine();
 
-        // this.connection.getSchema().getAttributeTypeDescriptionNames()
-        valueLine.valueComposite = BaseWidgetUtils.createColumnContainer( modGroup.modGroup,
3, 1 );
+        // text field
+        valueLine.valueComposite = BaseWidgetUtils.createColumnContainer( modSpec.modGroup,
3, 1 );
         valueLine.valueText = BaseWidgetUtils.createText( valueLine.valueComposite, "", 1
);
         valueLine.valueText.addModifyListener( this );
 
+        // add button with listener
         valueLine.valueAddButton = new Button( valueLine.valueComposite, SWT.PUSH );
         valueLine.valueAddButton.setText( "  +   " );
-        valueLine.valueAddButton.addSelectionListener( new SelectionListener()
+        valueLine.valueAddButton.addSelectionListener( new SelectionAdapter()
         {
             public void widgetSelected( SelectionEvent e )
             {
-                int index = modGroup.valueLineList.size();
-                for ( int i = 0; i < modGroup.valueLineList.size(); i++ )
+                int index = modSpec.valueLineList.size();
+                for ( int i = 0; i < modSpec.valueLineList.size(); i++ )
                 {
-                    ValueLine valueLine = ( ValueLine ) modGroup.valueLineList.get( i );
+                    ValueLine valueLine = modSpec.valueLineList.get( i );
                     if ( valueLine.valueAddButton == e.widget )
                     {
                         index = i + 1;
                     }
                 }
-                addValueLine( modGroup, index );
 
-                Point shellSize = shell.getSize();
-                Point modCompositeSize = modComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT,
true );
-                int newModCompositeSize = modCompositeSize.y;
-                shell.setSize( shellSize.x, shellSize.y + newModCompositeSize - modCompositeHeight
);
-                modComposite.layout( true, true );
-                shell.layout( true, true );
-                modCompositeHeight = newModCompositeSize;
+                addValueLine( modSpec, index );
 
                 validate();
             }
-
-
-            public void widgetDefaultSelected( SelectionEvent e )
-            {
-            }
         } );
 
+        // delete button with listener
         valueLine.valueDeleteButton = new Button( valueLine.valueComposite, SWT.PUSH );
         valueLine.valueDeleteButton.setText( "  \u2212  " ); // \u2013
-        valueLine.valueDeleteButton.addSelectionListener( new SelectionListener()
+        valueLine.valueDeleteButton.addSelectionListener( new SelectionAdapter()
         {
             public void widgetSelected( SelectionEvent e )
             {
                 int index = 0;
-                for ( int i = 0; i < modGroup.valueLineList.size(); i++ )
+                for ( int i = 0; i < modSpec.valueLineList.size(); i++ )
                 {
-                    ValueLine valueLine = ( ValueLine ) modGroup.valueLineList.get( i );
+                    ValueLine valueLine = modSpec.valueLineList.get( i );
                     if ( valueLine.valueDeleteButton == e.widget )
                     {
                         index = i;
                     }
                 }
-                deleteValueLine( modGroup, index );
 
-                Point shellSize = shell.getSize();
-                Point groupSize = modComposite.computeSize( SWT.DEFAULT, SWT.DEFAULT, true
);
-                int newModCompositeSize = groupSize.y;
-                shell.setSize( shellSize.x, shellSize.y + newModCompositeSize - modCompositeHeight
);
-                modComposite.layout( true, true );
-                shell.layout( true, true );
-                modCompositeHeight = newModCompositeSize;
+                deleteValueLine( modSpec, index );
 
                 validate();
             }
-
-
-            public void widgetDefaultSelected( SelectionEvent e )
-            {
-            }
         } );
 
         return valueLine;
     }
 
 
-    private void deleteValueLine( ModGroup modGroup, int index )
+    /**
+     * Delete value line.
+     * 
+     * @param modSpec the mod spec
+     * @param index the index
+     */
+    private void deleteValueLine( ModSpec modSpec, int index )
     {
-        ValueLine valueLine = ( ValueLine ) modGroup.valueLineList.remove( index );
+        ValueLine valueLine = ( ValueLine ) modSpec.valueLineList.remove( index );
         if ( valueLine != null )
         {
             valueLine.valueComposite.dispose();
+
+            if ( !modComposite.isDisposed() )
+            {
+                shell.layout( true, true );
+            }
         }
     }
 
 
+    /**
+     * Gets the LDIF fragment.
+     * 
+     * @return the LDIF fragment
+     */
     public String getLdifFragment()
     {
 
         StringBuffer sb = new StringBuffer();
         sb.append( "changetype: modify" ).append( BrowserCoreConstants.LINE_SEPARATOR );
 
-        ModGroup[] modGroups = ( ModGroup[] ) modGroupList.toArray( new ModGroup[modGroupList.size()]
);
+        ModSpec[] modSpecs = ( ModSpec[] ) modSpecList.toArray( new ModSpec[modSpecList.size()]
);
 
-        if ( modGroups.length > 0 )
+        if ( modSpecs.length > 0 )
         {
-            for ( int i = 0; i < modGroups.length; i++ )
+            for ( int i = 0; i < modSpecs.length; i++ )
             {
-                ModGroup modGroup = modGroups[i];
+                ModSpec modSpec = modSpecs[i];
 
                 // get values
-                String type = modGroup.modType.getText();
-                String attribute = modGroup.modAttribute.getText();
-                String[] values = new String[modGroup.valueLineList.size()];
+                String type = modSpec.modType.getText();
+                String attribute = modSpec.modAttributeCombo.getText();
+                String[] values = new String[modSpec.valueLineList.size()];
                 for ( int k = 0; k < values.length; k++ )
                 {
-                    values[k] = ( ( ValueLine ) modGroup.valueLineList.get( k ) ).valueText.getText();
+                    values[k] = ( ( ValueLine ) modSpec.valueLineList.get( k ) ).valueText.getText();
                 }
 
                 // build ldif
@@ -497,30 +532,73 @@
         return sb.toString();
     }
 
-    public class ModGroup
-    {
-        public Group modGroup;
-
-        public Combo modType;
-
-        public Combo modAttribute;
-
-        public Button modAddButton;
-
-        public Button modDeleteButton;
-
-        public ArrayList valueLineList = new ArrayList();;
-    }
-
-    public class ValueLine
-    {
-        public Composite valueComposite;
+    /**
+     * The Class ModSpec is a wrapper for all input elements
+     * of an modification. It contains a combo for the modify
+     * operation, a combo for the attribute to modify, 
+     * value lines and + and - buttons to add and remove 
+     * other modifications. It looks like this:
+     * <pre>
+     * ----------------------------------
+     * | operation v | attribute type v |--------
+     * ------------------------ --------| + | - |
+     * | value                  | + | - |--------
+     * ----------------------------------
+     * </pre>
+     */
+    private class ModSpec
+    {
+
+        /** The mod group. */
+        private Group modGroup;
+
+        /** The mod type. */
+        private Combo modType;
+
+        /** The modification attribute field. */
+        private DecoratedField modAttributeComboField;
+
+        /** The modification attribute. */
+        private Combo modAttributeCombo;
+
+        /** The modification content proposal adapter */
+        private ContentProposalAdapter modAttributeCPA;
+
+        /** The mod add button. */
+        private Button modAddButton;
+
+        /** The mod delete button. */
+        private Button modDeleteButton;
+
+        /** The value line list. */
+        private ArrayList<ValueLine> valueLineList = new ArrayList<ValueLine>();;
+    }
+
+    /**
+     * The Class ValueLine is a wrapper for all input elements
+     * of an value line. It contains an input field for the value
+     * and + and - buttons to add and remove other value lines. 
+     * It looks like this:
+     * <pre>
+     * -------------------------------------
+     * | value                     | + | - |
+     * -------------------------------------
+     * </pre>
+     */
+    private class ValueLine
+    {
+
+        /** The value composite. */
+        private Composite valueComposite;
 
-        public Text valueText;
+        /** The value text. */
+        private Text valueText;
 
-        public Button valueAddButton;
+        /** The value add button. */
+        private Button valueAddButton;
 
-        public Button valueDeleteButton;
+        /** The value delete button. */
+        private Button valueDeleteButton;
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ViewFormWidget.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ViewFormWidget.java?view=diff&rev=514392&r1=514391&r2=514392
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ViewFormWidget.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/ViewFormWidget.java
Sun Mar  4 04:49:21 2007
@@ -42,24 +42,54 @@
 import org.eclipse.swt.widgets.ToolItem;
 
 
+/**
+ * The ViewFormWidget is a widget that provides an info text,
+ * a tool bar, a menu and a main content composite including
+ * a context menu. 
+ * It looks like this:
+ * <pre>
+ * -----------------------------------
+ * | info text     | tool bar | menu |
+ * -----------------------------------
+ * |                                 |
+ * |          main content           |
+ * |                                 |
+ * -----------------------------------
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public abstract class ViewFormWidget
 {
 
+    /** The view form control */
     protected ViewForm control;
 
+    /** The info text, positioned at the top left */
     protected Text infoText;
 
+    /** The action tool bar */
     protected ToolBar actionToolBar;
 
+    /** The action tool bar manager */
     protected IToolBarManager actionToolBarManager;
 
+    /** The menu tool bar. */
     protected ToolBar menuToolBar;
 
+    /** The menu manager. */
     protected MenuManager menuManager;
 
+    /** The context menu manager. */
     protected MenuManager contextMenuManager;
 
 
+    /**
+     * Creates the widget.
+     *
+     * @param parent the parent composite
+     */
     public void createWidget( Composite parent )
     {
 
@@ -115,9 +145,20 @@
     }
 
 
+    
+    /**
+     * Creates the content.
+     * 
+     * @param control the control
+     * 
+     * @return the control
+     */
     protected abstract Control createContent( Composite control );
 
 
+    /**
+     * Shows the local view menu.
+     */
     private void showViewMenu()
     {
         Menu aMenu = menuManager.createContextMenu( control );
@@ -129,62 +170,85 @@
     }
 
 
+    /**
+     * Disposes this widget.
+     */
     public void dispose()
     {
-        if ( this.control != null )
+        if ( control != null )
         {
 
-            if ( this.contextMenuManager != null )
+            if ( contextMenuManager != null )
             {
-                this.contextMenuManager.removeAll();
-                this.contextMenuManager.dispose();
-                this.contextMenuManager = null;
+                contextMenuManager.removeAll();
+                contextMenuManager.dispose();
+                contextMenuManager = null;
             }
-            if ( this.menuToolBar != null )
+            if ( menuToolBar != null )
             {
-                this.menuToolBar.dispose();
-                this.menuToolBar = null;
-                this.menuManager.dispose();
-                this.menuManager = null;
+                menuToolBar.dispose();
+                menuToolBar = null;
+                menuManager.dispose();
+                menuManager = null;
             }
-            if ( this.actionToolBar != null )
+            if ( actionToolBar != null )
             {
-                this.actionToolBar.dispose();
-                this.actionToolBar = null;
-                this.actionToolBarManager.removeAll();
-                this.actionToolBarManager = null;
+                actionToolBar.dispose();
+                actionToolBar = null;
+                actionToolBarManager.removeAll();
+                actionToolBarManager = null;
             }
 
-            if ( this.infoText != null )
+            if ( infoText != null )
             {
-                this.infoText.dispose();
-                this.infoText = null;
+                infoText.dispose();
+                infoText = null;
             }
 
-            this.control.dispose();
-            this.control = null;
+            control.dispose();
+            control = null;
         }
     }
 
 
+    /**
+     * Gets the info text.
+     * 
+     * @return the info text
+     */
     public Text getInfoText()
     {
         return infoText;
     }
 
 
+    /**
+     * Gets the tool bar manager.
+     * 
+     * @return the tool bar manager
+     */
     public IToolBarManager getToolBarManager()
     {
         return this.actionToolBarManager;
     }
 
 
+    /**
+     * Gets the menu manager.
+     * 
+     * @return the menu manager
+     */
     public IMenuManager getMenuManager()
     {
         return menuManager;
     }
 
 
+    /**
+     * Gets the context menu manager.
+     * 
+     * @return the context menu manager
+     */
     public IMenuManager getContextMenuManager()
     {
         return this.contextMenuManager;

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyEvent.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyEvent.java?view=diff&rev=514392&r1=514391&r2=514392
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyEvent.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyEvent.java
Sun Mar  4 04:49:21 2007
@@ -24,12 +24,25 @@
 import java.util.EventObject;
 
 
+/**
+ * A WidgetModifyEvent indicates that a {@link BrowserWidget} has
+ * been modified.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class WidgetModifyEvent extends EventObject
 {
 
+    /** The serialVersionUID */
     private static final long serialVersionUID = 2421335730580648878L;
 
 
+    /**
+     * Creates a new instance of WidgetModifyEvent.
+     *
+     * @param source the event source
+     */
     public WidgetModifyEvent( Object source )
     {
         super( source );

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyListener.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyListener.java?view=diff&rev=514392&r1=514391&r2=514392
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyListener.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/WidgetModifyListener.java
Sun Mar  4 04:49:21 2007
@@ -21,9 +21,21 @@
 package org.apache.directory.ldapstudio.browser.ui.widgets;
 
 
+/**
+ * A WidgetModifyListener listens for modifications of a
+ * {@link BrowserWidget}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public interface WidgetModifyListener
 {
 
+    /**
+     * Notified about the modification of a {@link BrowserWidget}.
+     * 
+     * @param event the event
+     */
     public void widgetModified( WidgetModifyEvent event );
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationModifyWizardPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationModifyWizardPage.java?view=diff&rev=514392&r1=514391&r2=514392
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationModifyWizardPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/BatchOperationModifyWizardPage.java
Sun Mar  4 04:49:21 2007
@@ -27,6 +27,8 @@
 import org.apache.directory.ldapstudio.browser.core.model.ldif.parser.LdifParser;
 import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
 import org.apache.directory.ldapstudio.browser.ui.widgets.ModWidget;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
+import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
 
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
@@ -37,7 +39,7 @@
 import org.eclipse.swt.widgets.Composite;
 
 
-public class BatchOperationModifyWizardPage extends WizardPage implements IPropertyChangeListener
+public class BatchOperationModifyWizardPage extends WizardPage implements WidgetModifyListener
 {
 
     private BatchOperationWizard wizard;
@@ -93,7 +95,7 @@
         modWidget = new ModWidget( wizard.getConnection() != null ? wizard.getConnection().getSchema()
             : Schema.DEFAULT_SCHEMA );
         modWidget.createContents( composite );
-        modWidget.addPropertyChangeListener( this );
+        modWidget.addWidgetModifyListener( this );
 
         validate();
 
@@ -107,10 +109,9 @@
         return modWidget.getLdifFragment();
     }
 
-
-    public void propertyChange( PropertyChangeEvent event )
+    public void widgetModified( WidgetModifyEvent event )
     {
-        this.validate();
+        validate();
     }
 
 }



Mime
View raw message