directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r518330 - /directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/
Date Wed, 14 Mar 2007 21:25:08 GMT
Author: seelmann
Date: Wed Mar 14 14:25:07 2007
New Revision: 518330

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

Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPage.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryDnWizardPage.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryObjectclassWizardPage.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryTypeWizardPage.java
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryWizard.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPage.java?view=diff&rev=518330&r1=518329&r2=518330
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryAttributesWizardPage.java
Wed Mar 14 14:25:07 2007
@@ -44,58 +44,85 @@
 import org.eclipse.swt.widgets.Composite;
 
 
+/**
+ * The NewEntryAttributesWizardPage is used to fill the attributes of
+ * the new entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class NewEntryAttributesWizardPage extends WizardPage implements EntryUpdateListener
 {
 
+    /** The wizard. */
     private NewEntryWizard wizard;
 
+    /** The configuration. */
     private EntryEditorWidgetConfiguration configuration;
 
+    /** The action group. */
     private EntryEditorWidgetActionGroup actionGroup;
 
+    /** The main widget. */
     private EntryEditorWidget mainWidget;
 
+    /** The universal listener. */
     private EntryEditorWidgetUniversalListener universalListener;
 
 
+    /**
+     * Creates a new instance of NewEntryAttributesWizardPage.
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
     public NewEntryAttributesWizardPage( String pageName, NewEntryWizard wizard )
     {
         super( pageName );
-        super.setTitle( "Attributes" );
-        super.setDescription( "Please enter the attributes for the entry. Enter at least
the MUST attributes." );
-        super
-            .setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD
) );
-        super.setPageComplete( false );
+        setTitle( "Attributes" );
+        setDescription( "Please enter the attributes for the entry. Enter at least the MUST
attributes." );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD
) );
+        setPageComplete( false );
+
         this.wizard = wizard;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
-        if ( this.configuration != null )
+        if ( configuration != null )
         {
             EventRegistry.removeEntryUpdateListener( this );
-            this.universalListener.dispose();
-            this.universalListener = null;
-            this.mainWidget.dispose();
-            this.mainWidget = null;
-            this.actionGroup.dispose();
-            this.actionGroup = null;
-            this.configuration.dispose();
-            this.configuration = null;
+            universalListener.dispose();
+            universalListener = null;
+            mainWidget.dispose();
+            mainWidget = null;
+            actionGroup.dispose();
+            actionGroup = null;
+            configuration.dispose();
+            configuration = null;
         }
         super.dispose();
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation initializes the must attributes of the 
+     * protoype entry and initializes the entry widget when this
+     * page becomes visible.
+     */
     public void setVisible( boolean visible )
     {
         super.setVisible( visible );
 
         if ( visible )
         {
-
-            DummyEntry newEntry = wizard.getNewEntry();
+            DummyEntry newEntry = wizard.getPrototypeEntry();
             IValue editValue = null;
 
             try
@@ -103,6 +130,8 @@
                 EventRegistry.suspendEventFireingInCurrentThread();
 
                 // remove empty must attributes
+                // necessary when navigating back, modifying object classes
+                // and DN and navigation forward again.
                 String[] oldMust = newEntry.getSubschema().getMustAttributeNames();
                 for ( int i = 0; i < oldMust.length; i++ )
                 {
@@ -150,14 +179,15 @@
                 EventRegistry.resumeEventFireingInCurrentThread();
             }
 
-            this.mainWidget.getViewer().setInput( newEntry );
-            this.mainWidget.getViewer().refresh();
+            // set the input
+            mainWidget.getViewer().setInput( newEntry );
+            mainWidget.getViewer().refresh();
             validate();
 
             // set focus to the viewer
             mainWidget.getViewer().getControl().setFocus();
 
-            // start editing
+            // start editing if there is an empty value
             if ( editValue != null )
             {
                 mainWidget.getViewer().setSelection( new StructuredSelection( editValue ),
true );
@@ -170,50 +200,55 @@
         }
         else
         {
-            this.mainWidget.getViewer().setInput( "" );
-            this.mainWidget.getViewer().refresh();
+            mainWidget.getViewer().setInput( "" );
+            mainWidget.getViewer().refresh();
             setPageComplete( false );
         }
     }
 
 
+    /**
+     * Checks if the prototype entry is completed.
+     */
     private void validate()
     {
-        if ( this.wizard.getNewEntry() != null && this.wizard.getNewEntry().isConsistent()
)
+        if ( wizard.getPrototypeEntry() != null && wizard.getPrototypeEntry().isConsistent()
)
         {
-            super.setPageComplete( true );
+            setPageComplete( true );
         }
         else
         {
-            super.setPageComplete( false );
+            setPageComplete( false );
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void createControl( Composite parent )
     {
-
         Composite composite = new Composite( parent, SWT.NONE );
         GridLayout gl = new GridLayout( 1, false );
         composite.setLayout( gl );
         composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
 
         // create configuration
-        this.configuration = new EntryEditorWidgetConfiguration();
+        configuration = new EntryEditorWidgetConfiguration();
 
         // create main widget
-        this.mainWidget = new EntryEditorWidget( this.configuration );
-        this.mainWidget.createWidget( composite );
-        this.mainWidget.getViewer().getTree().setFocus();
+        mainWidget = new EntryEditorWidget( this.configuration );
+        mainWidget.createWidget( composite );
+        mainWidget.getViewer().getTree().setFocus();
 
         // create actions
-        this.actionGroup = new NewEntryAttributesWizardPageActionGroup( this.mainWidget,
this.configuration );
-        this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
-        this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
-        this.actionGroup.fillContextMenu( this.mainWidget.getContextMenuManager() );
+        actionGroup = new NewEntryAttributesWizardPageActionGroup( mainWidget, configuration
);
+        actionGroup.fillToolBar( mainWidget.getToolBarManager() );
+        actionGroup.fillMenu( mainWidget.getMenuManager() );
+        actionGroup.fillContextMenu( mainWidget.getContextMenuManager() );
 
         // create the listener
-        this.universalListener = new EntryEditorWidgetUniversalListener( this.mainWidget.getViewer(),
this.actionGroup
+        universalListener = new EntryEditorWidgetUniversalListener( mainWidget.getViewer(),
actionGroup
             .getOpenDefaultEditorAction() );
         EventRegistry.addEntryUpdateListener( this );
 
@@ -221,18 +256,26 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void entryUpdated( EntryModificationEvent event )
     {
-        if ( event.getModifiedEntry() == this.wizard.getNewEntry() && !this.isDisposed()
&& getControl().isVisible() )
+        if ( event.getModifiedEntry() == wizard.getPrototypeEntry() && !isDisposed()
&& getControl().isVisible() )
         {
-            this.validate();
+            validate();
         }
     }
 
 
-    public boolean isDisposed()
+    /**
+     * Checks if is disposed.
+     * 
+     * @return true, if is disposed
+     */
+    private boolean isDisposed()
     {
-        return this.configuration == null;
+        return configuration == null;
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryDnWizardPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryDnWizardPage.java?view=diff&rev=518330&r1=518329&r2=518330
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryDnWizardPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryDnWizardPage.java
Wed Mar 14 14:25:07 2007
@@ -48,57 +48,80 @@
 import org.eclipse.swt.widgets.Composite;
 
 
+/**
+ * The NewEntryDnWizardPage is used to compose the new entry's 
+ * distinguished name.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class NewEntryDnWizardPage extends WizardPage implements WidgetModifyListener
 {
 
+    /** The wizard. */
     private NewEntryWizard wizard;
 
+    /** The DN builder widget. */
     private DnBuilderWidget dnBuilderWidget;
 
 
+    /**
+     * Creates a new instance of NewEntryDnWizardPage.
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
     public NewEntryDnWizardPage( String pageName, NewEntryWizard wizard )
     {
         super( pageName );
-        super.setTitle( "Distinguished Name" );
-        super.setDescription( "Please select the parent of the new entry and enter the RDN."
);
-        super
-            .setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD
) );
-        super.setPageComplete( false );
+        setTitle( "Distinguished Name" );
+        setDescription( "Please select the parent of the new entry and enter the RDN." );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD
) );
+        setPageComplete( false );
 
         this.wizard = wizard;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
-        if ( this.dnBuilderWidget != null )
+        if ( dnBuilderWidget != null )
         {
-            this.dnBuilderWidget.removeWidgetModifyListener( this );
-            this.dnBuilderWidget.dispose();
-            this.dnBuilderWidget = null;
+            dnBuilderWidget.removeWidgetModifyListener( this );
+            dnBuilderWidget.dispose();
+            dnBuilderWidget = null;
         }
         super.dispose();
     }
 
 
+    /**
+     * Validates the input fields.
+     */
     private void validate()
     {
-        if ( this.dnBuilderWidget.getRdn() != null && this.dnBuilderWidget.getParentDn()
!= null )
+        if ( dnBuilderWidget.getRdn() != null && dnBuilderWidget.getParentDn() !=
null )
         {
-            super.setPageComplete( true );
+            setPageComplete( true );
             saveState();
         }
         else
         {
-            super.setPageComplete( false );
+            setPageComplete( false );
         }
     }
 
 
+    /**
+     * Initializes the DN builder widget with the DN of 
+     * the prototype entry. Called when this page becomes visible.
+     */
     private void loadState()
     {
-
-        DummyEntry newEntry = this.wizard.getNewEntry();
+        DummyEntry newEntry = wizard.getPrototypeEntry();
 
         Subschema subschema = newEntry.getSubschema();
         String[] attributeNames = subschema.getAllAttributeNames();
@@ -115,13 +138,16 @@
 
         RDN rdn = newEntry.getRdn();
 
-        this.dnBuilderWidget.setInput( wizard.getSelectedConnection(), attributeNames, rdn,
parentDn );
+        dnBuilderWidget.setInput( wizard.getSelectedConnection(), attributeNames, rdn, parentDn
);
     }
 
 
+    /**
+     * Saves the DN of the DN builder widget to the prototype entry.
+     */
     private void saveState()
     {
-        DummyEntry newEntry = wizard.getNewEntry();
+        DummyEntry newEntry = wizard.getPrototypeEntry();
 
         try
         {
@@ -146,7 +172,7 @@
             }
 
             // set new DN
-            DN dn = new DN( this.dnBuilderWidget.getRdn(), this.dnBuilderWidget.getParentDn()
);
+            DN dn = new DN( dnBuilderWidget.getRdn(), dnBuilderWidget.getParentDn() );
             newEntry.setDn( dn );
 
             // add new RDN
@@ -179,6 +205,12 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation initializes DN builder widghet with the
+     * DN of the protoype entry.
+     */
     public void setVisible( boolean visible )
     {
         super.setVisible( visible );
@@ -191,20 +223,33 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation just checks if this page is complete. It 
+     * doesn't call {@link #getNextPage()} to avoid unneeded 
+     * invokings of {@link ReadEntryJob}s.
+     */
     public boolean canFlipToNextPage()
     {
         return isPageComplete();
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation invokes a {@link ReadEntryJob} to check if an
+     * entry with the composed DN already exists.
+     */
     public IWizardPage getNextPage()
     {
 
-        this.dnBuilderWidget.validate();
+        dnBuilderWidget.validate();
         final RDN[] rdns = new RDN[]
-            { this.dnBuilderWidget.getRdn() };
+            { dnBuilderWidget.getRdn() };
         final DN[] parentDns = new DN[]
-            { this.dnBuilderWidget.getParentDn() };
+            { dnBuilderWidget.getParentDn() };
         final DN dn = new DN( rdns[0], parentDns[0] );
 
         // check if parent exists or new entry already exists
@@ -242,31 +287,34 @@
     }
 
 
-    public IWizardPage getPreviousPage()
-    {
-        return super.getPreviousPage();
-    }
-
-
+    /**
+     * {@inheritDoc}
+     */
     public void createControl( Composite parent )
     {
-        this.dnBuilderWidget = new DnBuilderWidget( true, true );
-        this.dnBuilderWidget.addWidgetModifyListener( this );
-        Composite composite = this.dnBuilderWidget.createContents( parent );
+        dnBuilderWidget = new DnBuilderWidget( true, true );
+        dnBuilderWidget.addWidgetModifyListener( this );
+        Composite composite = dnBuilderWidget.createContents( parent );
 
         setControl( composite );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void widgetModified( WidgetModifyEvent event )
     {
         validate();
     }
 
 
+    /**
+     * Saves the dialogs settings.
+     */
     public void saveDialogSettings()
     {
-        this.dnBuilderWidget.saveDialogSettings();
+        dnBuilderWidget.saveDialogSettings();
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryObjectclassWizardPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryObjectclassWizardPage.java?view=diff&rev=518330&r1=518329&r2=518330
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryObjectclassWizardPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryObjectclassWizardPage.java
Wed Mar 14 14:25:07 2007
@@ -53,7 +53,6 @@
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -69,61 +68,87 @@
 import org.eclipse.swt.widgets.Text;
 
 
+/**
+ * The NewEntryTypeWizardPage is used to select the entry's object classes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class NewEntryObjectclassWizardPage extends WizardPage
 {
 
+    /** The Constant SIZING_SELECTION_WIDGET_HEIGHT. */
     private final static int SIZING_SELECTION_WIDGET_HEIGHT = 250;
 
+    /** The Constant SIZING_SELECTION_WIDGET_WIDTH. */
     private final static int SIZING_SELECTION_WIDGET_WIDTH = 400;
 
+    /** The wizard. */
     private NewEntryWizard wizard;
 
+    /** The available object classes. */
     private List<ObjectClassDescription> availableObjectClasses;
 
-    private Text availabeObjectClassesInstantSearch;
+    /** The available object classes instant search. */
+    private Text availableObjectClassesInstantSearch;
 
+    /** The available object classes viewer. */
     private ListViewer availableObjectClassesViewer;
 
+    /** The selected object classes. */
     private List<ObjectClassDescription> selectedObjectClasses;
 
+    /** The selected object classes viewer. */
     private ListViewer selectedObjectClassesViewer;
 
+    /** The add button. */
     private Button addButton;
 
+    /** The remove button. */
     private Button removeButton;
 
 
+    /**
+     * Creates a new instance of NewEntryObjectclassWizardPage.
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
     public NewEntryObjectclassWizardPage( String pageName, NewEntryWizard wizard )
     {
         super( pageName );
-        super.setTitle( "Object Classes" );
-        super
-            .setDescription( "Please select object classes of the new entry. Select at least
one structural object class." );
-        super
-            .setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD
) );
-        super.setPageComplete( false );
+        setTitle( "Object Classes" );
+        setDescription( "Please select object classes of the new entry. Select at least one
structural object class." );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD
) );
+        setPageComplete( false );
 
         this.wizard = wizard;
-
         this.availableObjectClasses = new ArrayList<ObjectClassDescription>();
         this.selectedObjectClasses = new ArrayList<ObjectClassDescription>();
     }
 
 
+    /**
+     * Validates the input fields.
+     */
     private void validate()
     {
-        if ( !this.selectedObjectClasses.isEmpty() )
+        if ( !selectedObjectClasses.isEmpty() )
         {
-            super.setPageComplete( true );
+            setPageComplete( true );
             saveState();
         }
         else
         {
-            super.setPageComplete( false );
+            setPageComplete( false );
         }
     }
 
 
+    /**
+     * Loads the state of selected and available object classes from
+     * the prototype entry. Called when this page becomes visible.
+     */
     private void loadState()
     {
         availableObjectClasses.clear();
@@ -134,7 +159,7 @@
             availableObjectClasses.addAll( Arrays.asList( wizard.getSelectedConnection().getSchema()
                 .getObjectClassDescriptions() ) );
 
-            DummyEntry newEntry = wizard.getNewEntry();
+            DummyEntry newEntry = wizard.getPrototypeEntry();
             IAttribute ocAttribute = newEntry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE
);
             if ( ocAttribute != null )
             {
@@ -155,9 +180,12 @@
     }
 
 
+    /**
+     * Saves the state of selected object classes to the entry.
+     */
     private void saveState()
     {
-        DummyEntry newEntry = wizard.getNewEntry();
+        DummyEntry newEntry = wizard.getPrototypeEntry();
 
         try
         {
@@ -180,7 +208,6 @@
                 ObjectClassDescription ocd = it.next();
                 ocAttribute.addValue( new Value( ocAttribute, ocd.getNames()[0] ) );
             }
-
         }
         catch ( ModelModificationException e )
         {
@@ -193,6 +220,12 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation initializes the list of available and selected
+     * object classes when this page becomes visible.
+     */
     public void setVisible( boolean visible )
     {
         super.setVisible( visible );
@@ -201,29 +234,14 @@
         {
             loadState();
             validate();
-            availabeObjectClassesInstantSearch.setFocus();
+            availableObjectClassesInstantSearch.setFocus();
         }
     }
 
 
-    public boolean canFlipToNextPage()
-    {
-        return isPageComplete();
-    }
-
-
-    public IWizardPage getNextPage()
-    {
-        return super.getNextPage();
-    }
-
-
-    public IWizardPage getPreviousPage()
-    {
-        return super.getPreviousPage();
-    }
-
-
+    /**
+     * {@inheritDoc}
+     */
     public void createControl( Composite parent )
     {
 
@@ -261,8 +279,8 @@
         availabeObjectClassesInstantSearchField.addFieldDecoration( fieldDecoration, SWT.TOP
| SWT.LEFT, true );
         availabeObjectClassesInstantSearchField.getLayoutControl().setLayoutData(
             new GridData( SWT.FILL, SWT.CENTER, true, false ) );
-        availabeObjectClassesInstantSearch = ( Text ) availabeObjectClassesInstantSearchField.getControl();
-        availabeObjectClassesInstantSearch.addModifyListener( new ModifyListener()
+        availableObjectClassesInstantSearch = ( Text ) availabeObjectClassesInstantSearchField.getControl();
+        availableObjectClassesInstantSearch.addModifyListener( new ModifyListener()
         {
             public void modifyText( ModifyEvent e )
             {
@@ -283,7 +301,7 @@
         availableObjectClassesViewer.setContentProvider( new ArrayContentProvider() );
         availableObjectClassesViewer.setLabelProvider( new LabelProvider() );
         availableObjectClassesViewer.setSorter( new ViewerSorter() );
-        availableObjectClassesViewer.addFilter( new InstantSearchFilter( availabeObjectClassesInstantSearch
) );
+        availableObjectClassesViewer.addFilter( new InstantSearchFilter( availableObjectClassesInstantSearch
) );
         availableObjectClassesViewer.setInput( availableObjectClasses );
         availableObjectClassesViewer.addDoubleClickListener( new IDoubleClickListener()
         {
@@ -351,13 +369,19 @@
     }
 
 
+    /**
+     * Adds the selected object classes to the list of selected 
+     * object classes.
+     * 
+     * @param iselection the selection
+     */
     private void add( ISelection iselection )
     {
         IStructuredSelection selection = ( IStructuredSelection ) iselection;
-        Iterator<ObjectClassDescription> it = selection.iterator();
+        Iterator it = selection.iterator();
         while ( it.hasNext() )
         {
-            ObjectClassDescription ocd = it.next();
+            ObjectClassDescription ocd = ( ObjectClassDescription ) it.next();
             if ( availableObjectClasses.contains( ocd ) && !selectedObjectClasses.contains(
ocd ) )
             {
                 availableObjectClasses.remove( ocd );
@@ -374,23 +398,29 @@
 
         availableObjectClassesViewer.refresh();
         selectedObjectClassesViewer.refresh();
-        this.validate();
+        validate();
 
-        if ( !"".equals( availabeObjectClassesInstantSearch.getText() ) )
+        if ( !"".equals( availableObjectClassesInstantSearch.getText() ) )
         {
-            availabeObjectClassesInstantSearch.setText( "" );
-            availabeObjectClassesInstantSearch.setFocus();
+            availableObjectClassesInstantSearch.setText( "" );
+            availableObjectClassesInstantSearch.setFocus();
         }
     }
 
 
+    /**
+     * Removes the selected object classes from the list of selected
+     * object classes.
+     * 
+     * @param iselection the iselection
+     */
     private void remove( ISelection iselection )
     {
         IStructuredSelection selection = ( IStructuredSelection ) iselection;
-        Iterator<ObjectClassDescription> it = selection.iterator();
+        Iterator it = selection.iterator();
         while ( it.hasNext() )
         {
-            ObjectClassDescription ocd = it.next();
+            ObjectClassDescription ocd = ( ObjectClassDescription ) it.next();
             if ( !availableObjectClasses.contains( ocd ) && selectedObjectClasses.contains(
ocd ) )
             {
                 selectedObjectClasses.remove( ocd );
@@ -407,20 +437,33 @@
 
         availableObjectClassesViewer.refresh();
         selectedObjectClassesViewer.refresh();
-        this.validate();
+        validate();
     }
 
 
+    /**
+     * Saves dialog settings.
+     */
     public void saveDialogSettings()
     {
 
     }
 
+    /**
+     * The Class InstantSearchFilter.
+     */
     private class InstantSearchFilter extends ViewerFilter
     {
+
+        /** The filter text. */
         private Text filterText;
 
 
+        /**
+         * Creates a new instance of InstantSearchFilter.
+         * 
+         * @param filterText the filter text
+         */
         private InstantSearchFilter( Text filterText )
         {
             this.filterText = filterText;
@@ -435,7 +478,7 @@
             if ( element instanceof ObjectClassDescription )
             {
                 ObjectClassDescription ocd = ( ObjectClassDescription ) element;
-                Set lowerCaseIdentifierSet = ocd.getLowerCaseIdentifierSet();
+                Set<String> lowerCaseIdentifierSet = ocd.getLowerCaseIdentifierSet();
                 for ( Iterator<String> it = lowerCaseIdentifierSet.iterator(); it.hasNext();
)
                 {
                     String s = it.next();

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryTypeWizardPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryTypeWizardPage.java?view=diff&rev=518330&r1=518329&r2=518330
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryTypeWizardPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryTypeWizardPage.java
Wed Mar 14 14:25:07 2007
@@ -39,7 +39,6 @@
 import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyEvent;
 import org.apache.directory.ldapstudio.browser.ui.widgets.WidgetModifyListener;
 import org.apache.directory.ldapstudio.browser.ui.widgets.search.EntryWidget;
-
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.WizardPage;
@@ -52,67 +51,92 @@
 import org.eclipse.swt.widgets.Composite;
 
 
+/**
+ * The NewEntryTypeWizardPage is used to choose the entry creation method.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class NewEntryTypeWizardPage extends WizardPage implements WidgetModifyListener, SelectionListener
 {
 
+    /** The Constant PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY. */
     public static final String PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY = NewEntryTypeWizardPage.class
         .getName()
         + ".preferredEntryCreationMethod";
 
+    /** The wizard. */
     private NewEntryWizard wizard;
 
+    /** The schema button. */
     private Button schemaButton;
 
+    /** The template button. */
     private Button templateButton;
 
+    /** The entry widget to select the template entry. */
     private EntryWidget entryWidget;
 
 
+    /**
+     * Creates a new instance of NewEntryTypeWizardPage.
+     * 
+     * @param pageName the page name
+     * @param wizard the wizard
+     */
     public NewEntryTypeWizardPage( String pageName, NewEntryWizard wizard )
     {
         super( pageName );
-        super.setTitle( "Entry Creation Method" );
-        super.setDescription( "Please select the entry creation method." );
-        super
-            .setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD
) );
-        super.setPageComplete( false );
+        setTitle( "Entry Creation Method" );
+        setDescription( "Please select the entry creation method." );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_WIZARD
) );
+        setPageComplete( false );
 
         this.wizard = wizard;
     }
 
 
+    /**
+     * Validates the input fields.
+     */
     private void validate()
     {
         if ( schemaButton.getSelection() )
         {
-            super.setPageComplete( true );
+            setPageComplete( true );
         }
         else if ( templateButton.getSelection() )
         {
-            super.setPageComplete( entryWidget.getConnection() != null && entryWidget.getDn()
!= null );
+            setPageComplete( entryWidget.getConnection() != null && entryWidget.getDn()
!= null );
         }
         else
         {
-            super.setPageComplete( false );
+            setPageComplete( false );
         }
     }
 
-
-    public void setVisible( boolean visible )
-    {
-        super.setVisible( visible );
-    }
-
-
+    
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation just checks if this page is complete. IIt 
+     * doesn't call {@link #getNextPage()} to avoid unneeded 
+     * creations of new prototype entries.
+     */
     public boolean canFlipToNextPage()
     {
         return isPageComplete();
     }
+    
 
-
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation creates the prototype entry depending on the 
+     * selected entry creation method before flipping to the next page.
+     */
     public IWizardPage getNextPage()
     {
-
         if ( templateButton.getSelection() )
         {
             final IConnection connection = entryWidget.getConnection();
@@ -171,16 +195,16 @@
                 EventRegistry.suspendEventFireingInCurrentThread();
 
                 LdifContentRecord record = ModelConverter.entryToLdifContentRecord( templateEntries[0]
);
-                DummyEntry newEntry = ModelConverter.ldifContentRecordToEntry( record, connection
);
-                IAttribute[] attributes = newEntry.getAttributes();
+                DummyEntry prototypeEntry = ModelConverter.ldifContentRecordToEntry( record,
connection );
+                IAttribute[] attributes = prototypeEntry.getAttributes();
                 for ( int i = 0; i < attributes.length; i++ )
                 {
                     if ( !SchemaUtils.isModifyable( attributes[i].getAttributeTypeDescription()
) )
                     {
-                        newEntry.deleteAttribute( attributes[i] );
+                        prototypeEntry.deleteAttribute( attributes[i] );
                     }
                 }
-                wizard.setNewEntry( newEntry );
+                wizard.setPrototypeEntry( prototypeEntry );
             }
             catch ( Exception e )
             {
@@ -193,16 +217,18 @@
         }
         else
         {
-            wizard.setNewEntry( new DummyEntry( new DN(), wizard.getSelectedConnection()
) );
+            wizard.setPrototypeEntry( new DummyEntry( new DN(), wizard.getSelectedConnection()
) );
         }
 
         return super.getNextPage();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void createControl( Composite parent )
     {
-
         Composite composite = new Composite( parent, SWT.NONE );
         GridLayout gl = new GridLayout( 1, false );
         composite.setLayout( gl );
@@ -215,8 +241,8 @@
 
         Composite entryComposite = BaseWidgetUtils.createColumnContainer( composite, 3, 1
);
         BaseWidgetUtils.createRadioIndent( entryComposite, 1 );
-        entryWidget = new EntryWidget( this.wizard.getSelectedConnection(),
-            this.wizard.getSelectedEntry() != null ? this.wizard.getSelectedEntry().getDn()
: null );
+        entryWidget = new EntryWidget( wizard.getSelectedConnection(), wizard.getSelectedEntry()
!= null ? wizard
+            .getSelectedEntry().getDn() : null );
         entryWidget.createWidget( entryComposite );
         entryWidget.addWidgetModifyListener( this );
 
@@ -233,17 +259,26 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void widgetModified( WidgetModifyEvent event )
     {
         validate();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void widgetDefaultSelected( SelectionEvent e )
     {
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void widgetSelected( SelectionEvent e )
     {
         entryWidget.setEnabled( templateButton.getSelection() );
@@ -251,10 +286,13 @@
     }
 
 
+    /**
+     * Saves the dialog settings.
+     */
     public void saveDialogSettings()
     {
         BrowserUIPlugin.getDefault().getDialogSettings().put( PREFERRED_ENTRY_CREATION_METHOD_DIALOGSETTING_KEY,
-            this.schemaButton.getSelection() );
+            schemaButton.getSelection() );
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryWizard.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryWizard.java?view=diff&rev=518330&r1=518329&r2=518330
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryWizard.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/wizards/NewEntryWizard.java
Wed Mar 14 14:25:07 2007
@@ -48,24 +48,41 @@
 import org.eclipse.ui.PlatformUI;
 
 
+/**
+ * The NewEntryWizard is used to create a new entry from scratch or by 
+ * using another entry as template.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class NewEntryWizard extends Wizard implements INewWizard
 {
 
+    /** The type page. */
     private NewEntryTypeWizardPage typePage;
 
+    /** The object class page. */
     private NewEntryObjectclassWizardPage ocPage;
 
+    /** The dn page. */
     private NewEntryDnWizardPage dnPage;
 
+    /** The attributes page. */
     private NewEntryAttributesWizardPage attributePage;
 
+    /** The selected entry. */
     private IEntry selectedEntry;
 
+    /** The selected connection. */
     private IConnection selectedConnection;
 
-    private DummyEntry newEntry;
+    /** The prototype entry. */
+    private DummyEntry prototypeEntry;
 
 
+    /**
+     * Creates a new instance of NewEntryWizard.
+     */
     public NewEntryWizard()
     {
         super.setWindowTitle( "New Entry" );
@@ -73,67 +90,79 @@
     }
 
 
+    /**
+     * Gets the id.
+     * 
+     * @return the id
+     */
     public static String getId()
     {
         return NewEntryWizard.class.getName();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void init( IWorkbench workbench, IStructuredSelection selection )
     {
+        // determine the currently selected entry
         Object o = selection.getFirstElement();
         if ( o instanceof IEntry )
         {
-            this.selectedEntry = ( ( IEntry ) o );
-            this.selectedConnection = this.selectedEntry.getConnection();
+            selectedEntry = ( ( IEntry ) o );
+            selectedConnection = selectedEntry.getConnection();
         }
         else if ( o instanceof ISearchResult )
         {
-            this.selectedEntry = ( ( ISearchResult ) o ).getEntry();
-            this.selectedConnection = this.selectedEntry.getConnection();
+            selectedEntry = ( ( ISearchResult ) o ).getEntry();
+            selectedConnection = selectedEntry.getConnection();
         }
         else if ( o instanceof Bookmark )
         {
-            this.selectedEntry = ( ( Bookmark ) o ).getEntry();
-            this.selectedConnection = this.selectedEntry.getConnection();
+            selectedEntry = ( ( Bookmark ) o ).getEntry();
+            selectedConnection = selectedEntry.getConnection();
         }
         else if ( o instanceof IAttribute )
         {
-            this.selectedEntry = ( ( IAttribute ) o ).getEntry();
-            this.selectedConnection = this.selectedEntry.getConnection();
+            selectedEntry = ( ( IAttribute ) o ).getEntry();
+            selectedConnection = selectedEntry.getConnection();
         }
         else if ( o instanceof IValue )
         {
-            this.selectedEntry = ( ( IValue ) o ).getAttribute().getEntry();
-            this.selectedConnection = this.selectedEntry.getConnection();
+            selectedEntry = ( ( IValue ) o ).getAttribute().getEntry();
+            selectedConnection = selectedEntry.getConnection();
         }
         else if ( o instanceof ISearch )
         {
-            this.selectedEntry = null;
-            this.selectedConnection = ( ( ISearch ) o ).getConnection();
+            selectedEntry = null;
+            selectedConnection = ( ( ISearch ) o ).getConnection();
         }
         else if ( o instanceof IConnection )
         {
-            this.selectedEntry = null;
-            this.selectedConnection = ( IConnection ) o;
+            selectedEntry = null;
+            selectedConnection = ( IConnection ) o;
         }
         else
         {
-            this.selectedEntry = null;
-            this.selectedConnection = null;
+            selectedEntry = null;
+            selectedConnection = null;
         }
 
-        if ( this.selectedConnection != null )
+        if ( selectedConnection != null )
         {
-            this.selectedConnection.suspend();
-            this.newEntry = new DummyEntry( new DN(), this.selectedConnection );
+            selectedConnection.suspend();
+            prototypeEntry = new DummyEntry( new DN(), selectedConnection );
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void addPages()
     {
-        if ( this.selectedConnection != null && this.selectedConnection.isOpened()
)
+        if ( selectedConnection != null && selectedConnection.isOpened() )
         {
             typePage = new NewEntryTypeWizardPage( NewEntryTypeWizardPage.class.getName(),
this );
             addPage( typePage );
@@ -161,7 +190,7 @@
     public void createPageControls( Composite pageContainer )
     {
         super.createPageControls( pageContainer );
-        
+
         // set help context ID
         PlatformUI.getWorkbench().getHelpSystem().setHelp( typePage.getControl(),
             BrowserUIPlugin.PLUGIN_ID + "." + "tools_newentry_wizard" );
@@ -173,21 +202,32 @@
             BrowserUIPlugin.PLUGIN_ID + "." + "tools_newentry_wizard" );
     }
 
-
+    /**
+     * Just a dummy page.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     class DummyWizardPage extends WizardPage
     {
 
+        /**
+         * Creates a new instance of DummyWizardPage.
+         */
         protected DummyWizardPage()
         {
             super( "" );
             super.setTitle( "No connection selected or connection is closed" );
-            super.setDescription( "In order to use the entry creation wizard please select
a opened connection." );
+            super.setDescription( "In order to use the entry creation wizard please select
an opened connection." );
             super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
                 BrowserUIConstants.IMG_ENTRY_WIZARD ) );
             super.setPageComplete( true );
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public void createControl( Composite parent )
         {
             Composite composite = new Composite( parent, SWT.NONE );
@@ -200,72 +240,106 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean performCancel()
     {
-        if ( this.selectedConnection != null && this.selectedConnection.isOpened()
)
+        if ( selectedConnection != null && selectedConnection.isOpened() )
         {
             EventRegistry.suspendEventFireingInCurrentThread();
-            this.selectedConnection.reset();
+            selectedConnection.reset();
             EventRegistry.resumeEventFireingInCurrentThread();
-            this.selectedConnection.reset();
+            selectedConnection.reset();
         }
 
         return true;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean performFinish()
     {
-        if ( this.selectedConnection != null && this.selectedConnection.isOpened()
)
+        try
         {
-            this.typePage.saveDialogSettings();
-            this.ocPage.saveDialogSettings();
-            this.dnPage.saveDialogSettings();
-
-            this.getSelectedConnection().reset();
-
-            CreateEntryJob job = new CreateEntryJob( new IEntry[]
-                { this.getNewEntry() } );
-            RunnableContextJobAdapter.execute( job, getContainer() );
-
-            if ( !job.getExternalResult().isOK() )
+            if ( selectedConnection != null && selectedConnection.isOpened() )
             {
-                this.getSelectedConnection().suspend();
-                return false;
+                typePage.saveDialogSettings();
+                ocPage.saveDialogSettings();
+                dnPage.saveDialogSettings();
+
+                getSelectedConnection().reset();
+
+                CreateEntryJob job = new CreateEntryJob( new IEntry[]
+                    { getPrototypeEntry() } );
+                RunnableContextJobAdapter.execute( job, getContainer() );
+
+                if ( !job.getExternalResult().isOK() )
+                {
+                    getSelectedConnection().suspend();
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
             }
             else
             {
                 return true;
             }
         }
-        else
+        catch ( Throwable t )
         {
-            return true;
+            t.printStackTrace();
+            return false;
         }
     }
 
 
+    /**
+     * Gets the selected entry.
+     * 
+     * @return the selected entry
+     */
     public IEntry getSelectedEntry()
     {
         return selectedEntry;
     }
 
 
+    /**
+     * Gets the selected connection.
+     * 
+     * @return the selected connection
+     */
     public IConnection getSelectedConnection()
     {
         return selectedConnection;
     }
 
 
-    public DummyEntry getNewEntry()
+    /**
+     * Gets the prototype entry.
+     * 
+     * @return the prototype entry
+     */
+    public DummyEntry getPrototypeEntry()
     {
-        return newEntry;
+        return prototypeEntry;
     }
 
 
-    public void setNewEntry( DummyEntry newEntry )
+    /**
+     * Sets the prototype entry.
+     * 
+     * @param getPrototypeEntry the prototype entry
+     */
+    public void setPrototypeEntry( DummyEntry getPrototypeEntry )
     {
-        this.newEntry = newEntry;
+        this.prototypeEntry = getPrototypeEntry;
     }
 
 }



Mime
View raw message