directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r506058 [2/3] - in /directory/ldapstudio/trunk: ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/events/ ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/schema/ ldap...
Date Sun, 11 Feb 2007 16:01:39 GMT
Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleDescriptionDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleDescriptionDetailsPage.java?view=diff&rev=506058&r1=506057&r2=506058
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleDescriptionDetailsPage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleDescriptionDetailsPage.java Sun Feb 11 08:01:38 2007
@@ -24,7 +24,6 @@
 import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.LdapSyntaxDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleDescription;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -33,52 +32,77 @@
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.forms.events.ExpansionAdapter;
 import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Hyperlink;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 import org.eclipse.ui.forms.widgets.Section;
 
 
+/**
+ * The MatchingRuleDescriptionDetailsPage displays the details of an
+ * matching rule description.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class MatchingRuleDescriptionDetailsPage extends SchemaDetailsPage
 {
 
+    /** The main section, contains oid, names and desc */
     private Section mainSection;
 
-    private Section flagSection;
-
-    private Section syntaxSection;
-
-    private Section usedFromSection;
-
+    /** The numeric oid field */
     private Text numericOidText;
 
-    private Text nameText;
+    /** The names field */
+    private Text namesText;
 
+    /** The description field */
     private Text descText;
 
+    /** The flag section, contains obsolete */
+    private Section flagSection;
+
+    /** The obsolete field */
     private Label isObsoleteText;
 
-    private Text syntaxText;
+    /** The syntax section, contains syntax description and a link to the syntax */
+    private Section syntaxSection;
+
+    /** The syntax description field */
+    private Text syntaxDescText;
 
+    /** The link to the syntax */
     private Hyperlink syntaxLink;
 
+    /** The used from section, contains links to attribute types */
+    private Section usedFromSection;
+
+    /** The links to attribute types using the matching rule */
     private Hyperlink[] usedFromLinks;
 
 
-    public MatchingRuleDescriptionDetailsPage( SchemaBrowser schemaBrowser, FormToolkit toolkit )
+    /**
+     * Creates a new instance of MatchingRuleDescriptionDetailsPage.
+     *
+     * @param schemaPage the master schema page
+     * @param toolkit the toolkit used to create controls
+     */
+    public MatchingRuleDescriptionDetailsPage( SchemaPage scheamPage, FormToolkit toolkit )
     {
-        super( schemaBrowser, toolkit );
+        super( scheamPage, toolkit );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void createContents( final ScrolledForm detailForm )
     {
-
         this.detailForm = detailForm;
         detailForm.getBody().setLayout( new GridLayout() );
 
+        // create main section
         mainSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
         mainSection.setText( "Details" );
         mainSection.marginWidth = 0;
@@ -86,6 +110,7 @@
         mainSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
         toolkit.createCompositeSeparator( mainSection );
 
+        // create flag section
         flagSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
         flagSection.setText( "Flags" );
         flagSection.marginWidth = 0;
@@ -93,6 +118,7 @@
         flagSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
         toolkit.createCompositeSeparator( flagSection );
 
+        // create flag content
         Composite flagClient = toolkit.createComposite( flagSection, SWT.WRAP );
         GridLayout flagLayout = new GridLayout();
         flagLayout.numColumns = 1;
@@ -105,6 +131,7 @@
         isObsoleteText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
         isObsoleteText.setEnabled( false );
 
+        // create syntax section
         syntaxSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
         syntaxSection.setText( "Syntax" );
         syntaxSection.marginWidth = 0;
@@ -112,6 +139,7 @@
         syntaxSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
         toolkit.createCompositeSeparator( syntaxSection );
 
+        // create syntax content
         Composite syntaxClient = toolkit.createComposite( syntaxSection, SWT.WRAP );
         GridLayout syntaxLayout = new GridLayout();
         syntaxLayout.numColumns = 2;
@@ -123,19 +151,14 @@
         toolkit.createLabel( syntaxClient, "Syntax OID:", SWT.NONE );
         syntaxLink = toolkit.createHyperlink( syntaxClient, "", SWT.WRAP );
         syntaxLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
-        syntaxLink.addHyperlinkListener( new HyperlinkAdapter()
-        {
-            public void linkActivated( HyperlinkEvent e )
-            {
-                SchemaBrowser.select( e.getHref() );
-            }
-        } );
+        syntaxLink.addHyperlinkListener( this );
 
         toolkit.createLabel( syntaxClient, "Syntax Description:", SWT.NONE );
-        syntaxText = toolkit.createText( syntaxClient, "", SWT.NONE );
-        syntaxText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
-        syntaxText.setEditable( false );
+        syntaxDescText = toolkit.createText( syntaxClient, "", SWT.NONE );
+        syntaxDescText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+        syntaxDescText.setEditable( false );
 
+        // create used from section
         usedFromSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
         usedFromSection.setText( "Used from" );
         usedFromSection.marginWidth = 0;
@@ -150,16 +173,29 @@
             }
         } );
 
-        super.createRawSection();
+        // create raw section
+        createRawSection();
     }
 
 
-    public void matchingRuleDescriptionSelected( MatchingRuleDescription mrd )
+    /**
+     * {@inheritDoc}
+     */
+    public void setInput( Object input )
     {
-        this.createMainContent( mrd );
+        MatchingRuleDescription mrd = null;
+        if ( input instanceof MatchingRuleDescription )
+        {
+            mrd = ( MatchingRuleDescription ) input;
+        }
+
+        // create main content
+        createMainContent( mrd );
 
+        // set flag
         isObsoleteText.setEnabled( mrd != null && mrd.isObsolete() );
 
+        // set syntax content
         String lsdOid = null;
         LdapSyntaxDescription lsd = null;
         if ( mrd != null )
@@ -174,43 +210,39 @@
         syntaxLink.setHref( lsd );
         syntaxLink.setUnderlined( lsd != null );
         syntaxLink.setEnabled( lsd != null );
-        syntaxText.setText( getNonNullString( lsd != null ? lsd.getDesc() : null ) );
+        syntaxDescText.setText( getNonNullString( lsd != null ? lsd.getDesc() : null ) );
         syntaxSection.layout();
 
-        this.createUsedFromContents( mrd );
+        // create contents of dynamic sections
+        createUsedFromContents( mrd );
+        createRawContents( mrd );
 
-        super.createRawContents( mrd );
-
-        this.usedFromSection.redraw();
-        this.usedFromSection.update();
-        this.usedFromSection.layout();
-        this.detailForm.reflow( true );
+        detailForm.reflow( true );
     }
 
 
+    /**
+     * Creates the content of the main section. It is newly created
+     * on every input change to ensure a proper layout of 
+     * multilined descriptions. 
+     *
+     * @param mrd the matching rule description
+     */
     private void createMainContent( MatchingRuleDescription mrd )
     {
-
-        int labelWidth = 100;
-
+        // dispose old content
         if ( mainSection.getClient() != null )
         {
-            if ( mainSection.getClient() instanceof Composite )
-            {
-                Composite client = ( Composite ) mainSection.getClient();
-                if ( client.getChildren() != null && client.getChildren().length > 0 )
-                {
-                    labelWidth = client.getChildren()[0].getSize().x;
-                }
-            }
             mainSection.getClient().dispose();
         }
 
+        // create new client
         Composite mainClient = toolkit.createComposite( mainSection, SWT.WRAP );
         GridLayout mainLayout = new GridLayout( 2, false );
         mainClient.setLayout( mainLayout );
         mainSection.setClient( mainClient );
 
+        // create new content
         if ( mrd != null )
         {
             toolkit.createLabel( mainClient, "Numeric OID:", SWT.NONE );
@@ -219,14 +251,14 @@
             numericOidText.setEditable( false );
 
             toolkit.createLabel( mainClient, "Matching rule names:", SWT.NONE );
-            nameText = toolkit.createText( mainClient, getNonNullString( mrd.toString() ), SWT.NONE );
-            nameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
-            nameText.setEditable( false );
+            namesText = toolkit.createText( mainClient, getNonNullString( mrd.toString() ), SWT.NONE );
+            namesText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+            namesText.setEditable( false );
 
             toolkit.createLabel( mainClient, "Descripton:", SWT.NONE );
             descText = toolkit.createText( mainClient, getNonNullString( mrd.getDesc() ), SWT.WRAP | SWT.MULTI );
             GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-            gd.widthHint = detailForm.getForm().getSize().x - labelWidth - 60;
+            gd.widthHint = detailForm.getForm().getSize().x - 100 - 60;
             descText.setLayoutData( gd );
             descText.setEditable( false );
         }
@@ -235,18 +267,27 @@
     }
 
 
+    /**
+     * Creates the content of the used from section. 
+     * It is newly created on every input change because the content
+     * of this section is dynamic.
+     *
+     * @param mrd the matching rule description
+     */
     private void createUsedFromContents( MatchingRuleDescription mrd )
     {
-
+        // dispose old content
         if ( usedFromSection.getClient() != null )
         {
             usedFromSection.getClient().dispose();
         }
 
+        // create new client
         Composite usedFromClient = toolkit.createComposite( usedFromSection, SWT.WRAP );
         usedFromClient.setLayout( new GridLayout() );
         usedFromSection.setClient( usedFromClient );
 
+        // create new content
         if ( mrd != null )
         {
             AttributeTypeDescription[] usedFromATDs = mrd.getUsedFromAttributeTypeDescriptions();
@@ -261,13 +302,7 @@
                     usedFromLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
                     usedFromLinks[i].setUnderlined( true );
                     usedFromLinks[i].setEnabled( true );
-                    usedFromLinks[i].addHyperlinkListener( new HyperlinkAdapter()
-                    {
-                        public void linkActivated( HyperlinkEvent e )
-                        {
-                            SchemaBrowser.select( e.getHref() );
-                        }
-                    } );
+                    usedFromLinks[i].addHyperlinkListener( this );
                 }
             }
             else

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleDescriptionPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleDescriptionPage.java?view=diff&rev=506058&r1=506057&r2=506058
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleDescriptionPage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleDescriptionPage.java Sun Feb 11 08:01:38 2007
@@ -24,154 +24,111 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
 
 
-public class MatchingRuleDescriptionPage extends SchemaPage implements ISelectionChangedListener
+/**
+ * The MatchingRuleDescriptionPage displays a list with all
+ * matching rule descriptions and hosts the detail page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MatchingRuleDescriptionPage extends SchemaPage
 {
 
-    private Section section;
-
-    private Text filterText;
-
-    private TableViewer viewer;
-
-
+    /**
+     * Creates a new instance of MatchingRuleDescriptionPage.
+     *
+     * @param schemaBrowser the schema browser
+     */
     public MatchingRuleDescriptionPage( SchemaBrowser schemaBrowser )
     {
         super( schemaBrowser );
     }
 
 
-    protected void refresh()
+    /**
+     * {@inheritDoc}
+     */
+    protected String getTitle()
     {
-        if ( this.schemaBrowser.isShowDefaultSchema() )
-        {
-            this.form.setText( "Matching Rules of default schema" );
-            this.viewer.setInput( Schema.DEFAULT_SCHEMA );
-        }
-        else if ( this.selectedConnection != null )
-        {
-            this.form.setText( "Matching Rules of connection '" + this.selectedConnection.getName() + "'" );
-            this.viewer.setInput( this.selectedConnection.getSchema() );
-        }
-        else
-        {
-            this.form.setText( "Matching Rules" );
-            this.viewer.setInput( null );
-        }
+        return "Matching Rules";
     }
 
 
-    protected void createMaster( Composite parent )
+    /**
+     * {@inheritDoc}
+     */
+    protected String getFilterDescription()
     {
+        return "Please select a matching rule. Enter a filter to restrict the list.";
+    }
 
-        section = toolkit.createSection( parent, Section.DESCRIPTION );
-        section.marginWidth = 10;
-        section.marginHeight = 12;
-        section.setText( "Matching Rules" );
-        section.setDescription( "Please select a matching rule. Enter a filter to restrict the list." );
-        toolkit.createCompositeSeparator( section );
-
-        Composite client = toolkit.createComposite( section, SWT.WRAP );
-        GridLayout layout = new GridLayout( 2, false );
-        layout.marginWidth = 5;
-        layout.marginHeight = 5;
-        client.setLayout( layout );
-        section.setClient( client );
 
-        toolkit.createLabel( client, "Filter:" );
-        this.filterText = toolkit.createText( client, "", SWT.NONE );
-        this.filterText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
-        this.filterText.setData( FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER );
-        this.filterText.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent e )
-            {
-                viewer.refresh();
-            }
-        } );
+    /**
+     * {@inheritDoc}
+     */
+    protected IStructuredContentProvider getContentProvider()
+    {
+        return new MRDContentProvider();
+    }
 
-        Table t = toolkit.createTable( client, SWT.NONE );
-        GridData gd = new GridData( GridData.FILL_BOTH );
-        gd.horizontalSpan = 2;
-        gd.heightHint = 20;
-        gd.widthHint = 100;
-        t.setLayoutData( gd );
-        toolkit.paintBordersFor( client );
 
-        viewer = new TableViewer( t );
-        viewer.setContentProvider( new MRDContentProvider() );
-        viewer.setLabelProvider( new MRDLabelProvider() );
-        viewer.setSorter( new MRDViewerSorter() );
-        viewer.addFilter( new MRDViewerFilter() );
+    /**
+     * {@inheritDoc}
+     */
+    protected ITableLabelProvider getLabelProvider()
+    {
+        return new MRDLabelProvider();
     }
 
 
-    protected void createDetail( Composite body )
+    /**
+     * {@inheritDoc}
+     */
+    protected ViewerSorter getSorter()
     {
-        this.detailsPage = new MatchingRuleDescriptionDetailsPage( this.schemaBrowser, this.toolkit );
-        this.detailsPage.createContents( this.detailForm );
-        this.viewer.addSelectionChangedListener( this );
+        return new MRDViewerSorter();
     }
 
 
-    public void selectionChanged( SelectionChangedEvent event )
+    /**
+     * {@inheritDoc}
+     */
+    protected ViewerFilter getFilter()
     {
-        ISelection selection = event.getSelection();
-        if ( selection.isEmpty() )
-        {
-            EventRegistry.fireMatchingRuleDescriptionSelected( null, this );
-        }
-        else
-        {
-            Object obj = ( ( StructuredSelection ) selection ).getFirstElement();
-            if ( obj instanceof MatchingRuleDescription )
-            {
-                MatchingRuleDescription mrd = ( MatchingRuleDescription ) obj;
-                EventRegistry.fireMatchingRuleDescriptionSelected( mrd, this );
-            }
-        }
+        return new MRDViewerFilter();
     }
 
 
-    public void select( Object obj )
+    /**
+     * {@inheritDoc}
+     */
+    protected SchemaDetailsPage getDetailsPage()
     {
-        this.viewer.setSelection( new StructuredSelection( obj ), true );
-        if ( this.viewer.getSelection().isEmpty() )
-        {
-            this.filterText.setText( "" );
-            this.viewer.setSelection( new StructuredSelection( obj ), true );
-        }
+        return new MatchingRuleDescriptionDetailsPage( this, this.toolkit );
     }
 
-    class MRDContentProvider implements IStructuredContentProvider
+    /**
+     * The content provider used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    private class MRDContentProvider implements IStructuredContentProvider
     {
+        /**
+         * {@inheritDoc}
+         */
         public Object[] getElements( Object inputElement )
         {
             if ( inputElement instanceof Schema )
@@ -179,7 +136,7 @@
                 Schema schema = ( Schema ) inputElement;
                 if ( schema != null && schema.getMrdMapByName() != null )
                 {
-                    Set set = new HashSet( schema.getMrdMapByName().values() );
+                    Set<Object> set = new HashSet<Object>( schema.getMrdMapByName().values() );
                     return set.toArray();
                 }
             }
@@ -187,40 +144,76 @@
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public void dispose()
         {
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
         {
         }
     }
 
-    class MRDLabelProvider extends LabelProvider implements ITableLabelProvider
-    {
+    /**
+     * The label provider used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    private class MRDLabelProvider extends LabelProvider implements ITableLabelProvider
+    {
+        /**
+         * {@inheritDoc}
+         */
         public String getColumnText( Object obj, int index )
         {
             return obj.toString();
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public Image getColumnImage( Object obj, int index )
         {
             return null;
         }
     }
 
-    class MRDViewerSorter extends ViewerSorter
-    {
+    /**
+     * The sorter used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    private class MRDViewerSorter extends ViewerSorter
+    {
+        /**
+         * {@inheritDoc}
+         */
         public int compare( Viewer viewer, Object e1, Object e2 )
         {
             return e1.toString().compareTo( e2.toString() );
         }
     }
 
-    class MRDViewerFilter extends ViewerFilter
-    {
+    /**
+     * The filter used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    private class MRDViewerFilter extends ViewerFilter
+    {
+        /**
+         * {@inheritDoc}
+         */
         public boolean select( Viewer viewer, Object parentElement, Object element )
         {
             if ( element instanceof MatchingRuleDescription )

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleUseDescriptionDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleUseDescriptionDetailsPage.java?view=diff&rev=506058&r1=506057&r2=506058
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleUseDescriptionDetailsPage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleUseDescriptionDetailsPage.java Sun Feb 11 08:01:38 2007
@@ -24,7 +24,6 @@
 import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleUseDescription;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -33,8 +32,6 @@
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.forms.events.ExpansionAdapter;
 import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Hyperlink;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
@@ -44,35 +41,53 @@
 public class MatchingRuleUseDescriptionDetailsPage extends SchemaDetailsPage
 {
 
+    /** The main section, contains oid, names and desc */
     private Section mainSection;
 
-    private Section flagSection;
-
-    private Section appliesSection;
-
+    /** The numeric oid field */
     private Text numericOidText;
-
+    
+    /** The name link */
     private Hyperlink nameLink;
-
+    
+    /** The description field */
     private Text descText;
 
+    /** The flag section, contains obsolete */
+    private Section flagSection;
+
+    /** The obsolete field */
     private Label isObsoleteText;
 
+    /** The applies section, contains links */
+    private Section appliesSection;
+
+    /** The links to attribute types the matching rule is applicaple to */
     private Hyperlink[] appliesLinks;
 
 
-    public MatchingRuleUseDescriptionDetailsPage( SchemaBrowser schemaBrowser, FormToolkit toolkit )
+    /**
+     * Creates a new instance of MatchingRuleUseDescriptionDetailsPage.
+     *
+     * @param schemaPage the master schema page
+     * @param toolkit the toolkit used to create controls
+     */
+    public MatchingRuleUseDescriptionDetailsPage( SchemaPage schemaPage, FormToolkit toolkit )
     {
-        super( schemaBrowser, toolkit );
+        super( schemaPage, toolkit );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void createContents( final ScrolledForm detailForm )
     {
 
         this.detailForm = detailForm;
         detailForm.getBody().setLayout( new GridLayout() );
 
+        // create main section
         mainSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
         mainSection.setText( "Details" );
         mainSection.marginWidth = 0;
@@ -80,6 +95,7 @@
         mainSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
         toolkit.createCompositeSeparator( mainSection );
 
+        // create flag section
         flagSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
         flagSection.setText( "Flags" );
         flagSection.marginWidth = 0;
@@ -87,6 +103,7 @@
         flagSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
         toolkit.createCompositeSeparator( flagSection );
 
+        // create flag content
         Composite flagClient = toolkit.createComposite( flagSection, SWT.WRAP );
         GridLayout flagLayout = new GridLayout();
         flagLayout.numColumns = 1;
@@ -99,6 +116,7 @@
         isObsoleteText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
         isObsoleteText.setEnabled( false );
 
+        // create applies section
         appliesSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
         appliesSection.setText( "Applies" );
         appliesSection.marginWidth = 0;
@@ -113,14 +131,29 @@
             }
         } );
 
+        // create raw section
         super.createRawSection();
     }
 
 
-    public void matchingRuleUseDescriptionSelected( MatchingRuleUseDescription mrud )
+    /**
+     * {@inheritDoc}
+     */
+    public void setInput( Object input )
     {
+        MatchingRuleUseDescription mrud = null;
+        if ( input instanceof MatchingRuleUseDescription )
+        {
+            mrud = ( MatchingRuleUseDescription ) input;
+        }
+
+        // create main content
         this.createMainContent( mrud );
+        
+        // set flag
         isObsoleteText.setEnabled( mrud != null && mrud.isObsolete() );
+        
+        // create contents of dynamic sections
         this.createAppliesContents( mrud );
         super.createRawContents( mrud );
 
@@ -128,29 +161,28 @@
     }
 
 
+    /**
+     * Creates the content of the main section. It is newly created
+     * on every input change to ensure a proper layout of 
+     * multilined descriptions. 
+     *
+     * @param mrud the matching rule use description
+     */
     private void createMainContent( MatchingRuleUseDescription mrud )
     {
-
-        int labelWidth = 100;
-
+        // dispose old content
         if ( mainSection.getClient() != null )
         {
-            if ( mainSection.getClient() instanceof Composite )
-            {
-                Composite client = ( Composite ) mainSection.getClient();
-                if ( client.getChildren() != null && client.getChildren().length > 0 )
-                {
-                    labelWidth = client.getChildren()[0].getSize().x;
-                }
-            }
             mainSection.getClient().dispose();
         }
 
+        // create new client
         Composite mainClient = toolkit.createComposite( mainSection, SWT.WRAP );
         GridLayout mainLayout = new GridLayout( 2, false );
         mainClient.setLayout( mainLayout );
         mainSection.setClient( mainClient );
 
+        // create new content
         if ( mrud != null )
         {
             toolkit.createLabel( mainClient, "Numeric OID:", SWT.NONE );
@@ -161,13 +193,7 @@
             toolkit.createLabel( mainClient, "Matching rule names:", SWT.NONE );
             nameLink = toolkit.createHyperlink( mainClient, "", SWT.WRAP );
             nameLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
-            nameLink.addHyperlinkListener( new HyperlinkAdapter()
-            {
-                public void linkActivated( HyperlinkEvent e )
-                {
-                    SchemaBrowser.select( e.getHref() );
-                }
-            } );
+            nameLink.addHyperlinkListener( this );
 
             MatchingRuleDescription mrd = mrud.getSchema().hasMatchingRuleDescription( mrud.getNumericOID() ) ? mrud
                 .getSchema().getMatchingRuleDescription( mrud.getNumericOID() ) : null;
@@ -179,7 +205,7 @@
             toolkit.createLabel( mainClient, "Descripton:", SWT.NONE );
             descText = toolkit.createText( mainClient, getNonNullString( mrud.getDesc() ), SWT.WRAP | SWT.MULTI );
             GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-            gd.widthHint = detailForm.getForm().getSize().x - labelWidth - 60;
+            gd.widthHint = detailForm.getForm().getSize().x - 100 - 60;
             descText.setLayoutData( gd );
             descText.setEditable( false );
         }
@@ -188,17 +214,27 @@
     }
 
 
+    /**
+     * Creates the content of the applies section. 
+     * It is newly created on every input change because the content
+     * of this section is dynamic.
+     *
+     * @param mrud the matching rule use description
+     */
     private void createAppliesContents( MatchingRuleUseDescription mrud )
     {
+        // dispose old content
         if ( appliesSection.getClient() != null )
         {
             appliesSection.getClient().dispose();
         }
 
+        // create new client
         Composite appliesClient = toolkit.createComposite( appliesSection, SWT.WRAP );
         appliesClient.setLayout( new GridLayout() );
         appliesSection.setClient( appliesClient );
 
+        // create content
         if ( mrud != null )
         {
             String[] names = mrud.getAppliesAttributeTypeDescriptionOIDs();
@@ -216,13 +252,7 @@
                         appliesLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
                         appliesLinks[i].setUnderlined( true );
                         appliesLinks[i].setEnabled( true );
-                        appliesLinks[i].addHyperlinkListener( new HyperlinkAdapter()
-                        {
-                            public void linkActivated( HyperlinkEvent e )
-                            {
-                                SchemaBrowser.select( e.getHref() );
-                            }
-                        } );
+                        appliesLinks[i].addHyperlinkListener( this );
                     }
                     else
                     {

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleUseDescriptionPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleUseDescriptionPage.java?view=diff&rev=506058&r1=506057&r2=506058
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleUseDescriptionPage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/MatchingRuleUseDescriptionPage.java Sun Feb 11 08:01:38 2007
@@ -24,154 +24,112 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleUseDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
 
 
-public class MatchingRuleUseDescriptionPage extends SchemaPage implements ISelectionChangedListener
+/**
+ * The MatchingRuleUseDescriptionPage displays a list with all
+ * matching rule use descriptions and hosts the detail page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MatchingRuleUseDescriptionPage extends SchemaPage
 {
 
-    private Section section;
-
-    private Text filterText;
-
-    private TableViewer viewer;
-
-
+    /**
+     * 
+     * Creates a new instance of MatchingRuleUseDescriptionPage.
+     *
+     * @param schemaBrowser the schema browser
+     */
     public MatchingRuleUseDescriptionPage( SchemaBrowser schemaBrowser )
     {
         super( schemaBrowser );
     }
 
 
-    protected void refresh()
+    /**
+     * {@inheritDoc}
+     */
+    protected String getTitle()
     {
-        if ( this.schemaBrowser.isShowDefaultSchema() )
-        {
-            this.form.setText( "Matching Rule Use of default schema" );
-            this.viewer.setInput( Schema.DEFAULT_SCHEMA );
-        }
-        else if ( this.selectedConnection != null )
-        {
-            this.form.setText( "Matching Rule Use of connection '" + this.selectedConnection.getName() + "'" );
-            this.viewer.setInput( this.selectedConnection.getSchema() );
-        }
-        else
-        {
-            this.form.setText( "Matching Rule Use" );
-            this.viewer.setInput( null );
-        }
+        return "Matching Rule Use";
     }
 
 
-    protected void createMaster( Composite parent )
+    /**
+     * {@inheritDoc}
+     */
+    protected String getFilterDescription()
     {
+        return "Please select a matching rule. Enter a filter to restrict the list.";
+    }
 
-        section = toolkit.createSection( parent, Section.DESCRIPTION );
-        section.marginWidth = 10;
-        section.marginHeight = 12;
-        section.setText( "Matching Rule Use" );
-        section.setDescription( "Please select a matching rule. Enter a filter to restrict the list." );
-        toolkit.createCompositeSeparator( section );
-
-        Composite client = toolkit.createComposite( section, SWT.WRAP );
-        GridLayout layout = new GridLayout( 2, false );
-        layout.marginWidth = 5;
-        layout.marginHeight = 5;
-        client.setLayout( layout );
-        section.setClient( client );
 
-        toolkit.createLabel( client, "Filter:" );
-        this.filterText = toolkit.createText( client, "", SWT.NONE );
-        this.filterText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
-        this.filterText.setData( FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER );
-        this.filterText.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent e )
-            {
-                viewer.refresh();
-            }
-        } );
+    /**
+     * {@inheritDoc}
+     */
+    protected IStructuredContentProvider getContentProvider()
+    {
+        return new MRUDContentProvider();
+    }
 
-        Table t = toolkit.createTable( client, SWT.NONE );
-        GridData gd = new GridData( GridData.FILL_BOTH );
-        gd.horizontalSpan = 2;
-        gd.heightHint = 20;
-        gd.widthHint = 100;
-        t.setLayoutData( gd );
-        toolkit.paintBordersFor( client );
 
-        viewer = new TableViewer( t );
-        viewer.setContentProvider( new MRUDContentProvider() );
-        viewer.setLabelProvider( new MRUDLabelProvider() );
-        viewer.setSorter( new MRUDViewerSorter() );
-        viewer.addFilter( new MRUDViewerFilter() );
+    /**
+     * {@inheritDoc}
+     */
+    protected ITableLabelProvider getLabelProvider()
+    {
+        return new MRUDLabelProvider();
     }
 
 
-    protected void createDetail( Composite body )
+    /**
+     * {@inheritDoc}
+     */
+    protected ViewerSorter getSorter()
     {
-        this.detailsPage = new MatchingRuleUseDescriptionDetailsPage( this.schemaBrowser, this.toolkit );
-        this.detailsPage.createContents( this.detailForm );
-        this.viewer.addSelectionChangedListener( this );
+        return new MRUDViewerSorter();
     }
 
 
-    public void selectionChanged( SelectionChangedEvent event )
+    /**
+     * {@inheritDoc}
+     */
+    protected ViewerFilter getFilter()
     {
-        ISelection selection = event.getSelection();
-        if ( selection.isEmpty() )
-        {
-            EventRegistry.fireMatchingRuleUseDescriptionSelected( null, this );
-        }
-        else
-        {
-            Object obj = ( ( StructuredSelection ) selection ).getFirstElement();
-            if ( obj instanceof MatchingRuleUseDescription )
-            {
-                MatchingRuleUseDescription mrud = ( MatchingRuleUseDescription ) obj;
-                EventRegistry.fireMatchingRuleUseDescriptionSelected( mrud, this );
-            }
-        }
+        return new MRUDViewerFilter();
     }
 
 
-    public void select( Object obj )
+    /**
+     * {@inheritDoc}
+     */
+    protected SchemaDetailsPage getDetailsPage()
     {
-        this.viewer.setSelection( new StructuredSelection( obj ), true );
-        if ( this.viewer.getSelection().isEmpty() )
-        {
-            this.filterText.setText( "" );
-            this.viewer.setSelection( new StructuredSelection( obj ), true );
-        }
+        return new MatchingRuleUseDescriptionDetailsPage( this, this.toolkit );
     }
 
+    /**
+     * The content provider used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     class MRUDContentProvider implements IStructuredContentProvider
     {
+        /**
+         * {@inheritDoc}
+         */
         public Object[] getElements( Object inputElement )
         {
             if ( inputElement instanceof Schema )
@@ -179,7 +137,7 @@
                 Schema schema = ( Schema ) inputElement;
                 if ( schema != null && schema.getMrudMapByName() != null )
                 {
-                    Set set = new HashSet( schema.getMrudMapByName().values() );
+                    Set<Object> set = new HashSet<Object>( schema.getMrudMapByName().values() );
                     return set.toArray();
                 }
             }
@@ -187,40 +145,76 @@
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public void dispose()
         {
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
         {
         }
     }
 
+    /**
+     * The label provider used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     class MRUDLabelProvider extends LabelProvider implements ITableLabelProvider
     {
+        /**
+         * {@inheritDoc}
+         */
         public String getColumnText( Object obj, int index )
         {
             return obj.toString();
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public Image getColumnImage( Object obj, int index )
         {
             return null;
         }
     }
 
+    /**
+     * The sorter used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     class MRUDViewerSorter extends ViewerSorter
     {
+        /**
+         * {@inheritDoc}
+         */
         public int compare( Viewer viewer, Object e1, Object e2 )
         {
             return e1.toString().compareTo( e2.toString() );
         }
     }
 
+    /**
+     * The filter used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     class MRUDViewerFilter extends ViewerFilter
     {
+        /**
+         * {@inheritDoc}
+         */
         public boolean select( Viewer viewer, Object parentElement, Object element )
         {
             if ( element instanceof MatchingRuleUseDescription )

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ObjectClassDescriptionDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ObjectClassDescriptionDetailsPage.java?view=diff&rev=506058&r1=506057&r2=506058
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ObjectClassDescriptionDetailsPage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ObjectClassDescriptionDetailsPage.java Sun Feb 11 08:01:38 2007
@@ -23,7 +23,6 @@
 
 import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -31,56 +30,83 @@
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.forms.events.ExpansionAdapter;
 import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.Hyperlink;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 import org.eclipse.ui.forms.widgets.Section;
 
 
+/**
+ * The ObjectClassDescriptionDetailsPage displays the details of an
+ * object class description.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class ObjectClassDescriptionDetailsPage extends SchemaDetailsPage
 {
 
+    /** The main section, contains oid, names, desc and kind */
     private Section mainSection;
 
+    /** The numeric oid field */
     private Text numericOidText;
 
-    private Text nameText;
+    /** The names field */
+    private Text namesText;
 
+    /** The description field */
     private Text descText;
 
+    /** The kind field */
     private Text kindText;
 
+    /** The section with links to superior object classes */
     private Section superclassesSection;
 
+    /** The links to superior object classes */
     private Hyperlink[] superLinks;
 
+    /** The section with links to derived object classes */
     private Section subclassesSection;
 
+    /** The links to derived object classes */
     private Hyperlink[] subLinks;
 
+    /** The section with links to must attribute types */
     private Section mustSection;
 
+    /** The links to must attribute types */
     private Hyperlink[] mustLinks;
 
+    /** The section with links to may attribute types */
     private Section maySection;
 
+    /** The links to may attribute types */
     private Hyperlink[] mayLinks;
 
 
-    public ObjectClassDescriptionDetailsPage( SchemaBrowser schemaBrowser, FormToolkit toolkit )
+    /**
+     * Creates a new instance of ObjectClassDescriptionDetailsPage.
+     *
+     * @param schemaPage the master schema page
+     * @param toolkit the toolkit used to create controls
+     */
+    public ObjectClassDescriptionDetailsPage( SchemaPage schemaPage, FormToolkit toolkit )
     {
-        super( schemaBrowser, toolkit );
+        super( schemaPage, toolkit );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void createContents( final ScrolledForm detailForm )
     {
-
         this.detailForm = detailForm;
         detailForm.getBody().setLayout( new GridLayout() );
 
+        // create main section
         mainSection = toolkit.createSection( detailForm.getBody(), SWT.NONE );
         mainSection.setText( "Details" );
         mainSection.marginWidth = 0;
@@ -88,6 +114,7 @@
         mainSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
         toolkit.createCompositeSeparator( mainSection );
 
+        // create must section
         mustSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
         mustSection.setText( "MUST Attributes" );
         mustSection.marginWidth = 0;
@@ -102,6 +129,7 @@
             }
         } );
 
+        // create may section
         maySection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
         maySection.setText( "MAY Attributes" );
         maySection.marginWidth = 0;
@@ -116,6 +144,7 @@
             }
         } );
 
+        // create superior section
         superclassesSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
         superclassesSection.setText( "Superclasses" );
         superclassesSection.marginWidth = 0;
@@ -130,6 +159,7 @@
             }
         } );
 
+        // create subclasses section
         subclassesSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
         subclassesSection.setText( "Subclasses" );
         subclassesSection.marginWidth = 0;
@@ -144,51 +174,58 @@
             }
         } );
 
-        super.createRawSection();
-
+        // create raw section
+        createRawSection();
     }
 
 
-    public void objectClassDescriptionSelected( ObjectClassDescription ocd )
+    /**
+     * {@inheritDoc}
+     */
+    public void setInput( Object input )
     {
+        ObjectClassDescription ocd = null;
+        if ( input instanceof ObjectClassDescription )
+        {
+            ocd = ( ObjectClassDescription ) input;
+        }
+
+        // create main content
         this.createMainContent( ocd );
 
+        // create contents of dynamic sections
         this.createSuperclassContents( ocd );
         this.createSubclassContents( ocd );
-
         this.createMustContents( ocd );
         this.createMayContents( ocd );
-
         super.createRawContents( ocd );
 
         this.detailForm.reflow( true );
-        this.detailForm.redraw();
     }
 
 
+    /**
+     * Creates the content of the main section. It is newly created
+     * on every input change to ensure a proper layout of 
+     * multilined descriptions. 
+     *
+     * @param ocd the object class description
+     */
     private void createMainContent( ObjectClassDescription ocd )
     {
-
-        // int labelWidth = 100;
-
+        // dispose old content
         if ( mainSection.getClient() != null )
         {
-            if ( mainSection.getClient() instanceof Composite )
-            {
-                Composite client = ( Composite ) mainSection.getClient();
-                if ( client.getChildren() != null && client.getChildren().length > 0 )
-                {
-                    // labelWidth = client.getChildren()[0].getSize().x;
-                }
-            }
             mainSection.getClient().dispose();
         }
 
+        // create new client
         Composite mainClient = toolkit.createComposite( mainSection, SWT.WRAP );
         GridLayout mainLayout = new GridLayout( 2, false );
         mainClient.setLayout( mainLayout );
         mainSection.setClient( mainClient );
 
+        // create new content
         if ( ocd != null )
         {
             toolkit.createLabel( mainClient, "Numeric OID:", SWT.NONE );
@@ -197,9 +234,9 @@
             numericOidText.setEditable( false );
 
             toolkit.createLabel( mainClient, "Objectclass names:", SWT.NONE );
-            nameText = toolkit.createText( mainClient, getNonNullString( ocd.toString() ), SWT.NONE );
-            nameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
-            nameText.setEditable( false );
+            namesText = toolkit.createText( mainClient, getNonNullString( ocd.toString() ), SWT.NONE );
+            namesText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+            namesText.setEditable( false );
 
             toolkit.createLabel( mainClient, "Descripton:", SWT.NONE );
             descText = toolkit.createText( mainClient, getNonNullString( ocd.getDesc() ), SWT.WRAP | SWT.MULTI );
@@ -210,35 +247,52 @@
 
             String kind = "";
             if ( ocd.isStructural() )
+            {
                 kind = "structural";
+            }
             else if ( ocd.isAbstract() )
+            {
                 kind = "abstract";
+            }
             else if ( ocd.isAuxiliary() )
+            {
                 kind = "auxiliary";
+            }
             if ( ocd.isObsolete() )
+            {
                 kind += " (obsolete)";
+            }
             toolkit.createLabel( mainClient, "Objectclass kind:", SWT.NONE );
             kindText = toolkit.createText( mainClient, getNonNullString( kind ), SWT.NONE );
             kindText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
             kindText.setEditable( false );
-
         }
 
         mainSection.layout();
     }
 
 
+    /**
+     * Creates the content of the must section. 
+     * It is newly created on every input change because the content
+     * of this section is dynamic.
+     *
+     * @param ocd the object class description
+     */
     private void createMustContents( ObjectClassDescription ocd )
     {
+        // dispose old content
         if ( mustSection.getClient() != null )
         {
             mustSection.getClient().dispose();
         }
 
+        // create new client
         Composite mustClient = toolkit.createComposite( mustSection, SWT.WRAP );
         mustClient.setLayout( new GridLayout() );
         mustSection.setClient( mustClient );
 
+        // create new content
         if ( ocd != null )
         {
             String[] names = ocd.getMustAttributeTypeDescriptionNamesTransitive();
@@ -256,13 +310,7 @@
                         mustLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
                         mustLinks[i].setUnderlined( true );
                         mustLinks[i].setEnabled( true );
-                        mustLinks[i].addHyperlinkListener( new HyperlinkAdapter()
-                        {
-                            public void linkActivated( HyperlinkEvent e )
-                            {
-                                SchemaBrowser.select( e.getHref() );
-                            }
-                        } );
+                        mustLinks[i].addHyperlinkListener( this );
                     }
                     else
                     {
@@ -291,17 +339,27 @@
     }
 
 
+    /**
+     * Creates the content of the may section. 
+     * It is newly created on every input change because the content
+     * of this section is dynamic.
+     *
+     * @param ocd the object class description
+     */
     private void createMayContents( ObjectClassDescription ocd )
     {
+        // dispose old content
         if ( maySection.getClient() != null )
         {
             maySection.getClient().dispose();
         }
 
+        // create new client
         Composite mayClient = toolkit.createComposite( maySection, SWT.WRAP );
         mayClient.setLayout( new GridLayout() );
         maySection.setClient( mayClient );
 
+        // create new content
         if ( ocd != null )
         {
             String[] names = ocd.getMayAttributeTypeDescriptionNamesTransitive();
@@ -319,14 +377,7 @@
                         mayLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
                         mayLinks[i].setUnderlined( true );
                         mayLinks[i].setEnabled( true );
-                        mayLinks[i].addHyperlinkListener( new HyperlinkAdapter()
-                        {
-                            public void linkActivated( HyperlinkEvent e )
-                            {
-                                SchemaBrowser.select( e.getHref() );
-
-                            }
-                        } );
+                        mayLinks[i].addHyperlinkListener( this );
                     }
                     else
                     {
@@ -354,18 +405,27 @@
     }
 
 
+    /**
+     * Creates the content of the must section. 
+     * It is newly created on every input change because the content
+     * of this section is dynamic.
+     *
+     * @param ocd the object class description
+     */
     private void createSubclassContents( ObjectClassDescription ocd )
     {
-
+        // dispose old content
         if ( subclassesSection.getClient() != null )
         {
             subclassesSection.getClient().dispose();
         }
 
+        // create new client
         Composite subClient = toolkit.createComposite( subclassesSection, SWT.WRAP );
         subClient.setLayout( new GridLayout() );
         subclassesSection.setClient( subClient );
 
+        // create new content
         if ( ocd != null )
         {
             ObjectClassDescription[] subOCDs = ocd.getSubObjectClassDescriptions();
@@ -380,13 +440,7 @@
                     subLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
                     subLinks[i].setUnderlined( true );
                     subLinks[i].setEnabled( true );
-                    subLinks[i].addHyperlinkListener( new HyperlinkAdapter()
-                    {
-                        public void linkActivated( HyperlinkEvent e )
-                        {
-                            SchemaBrowser.select( e.getHref() );
-                        }
-                    } );
+                    subLinks[i].addHyperlinkListener( this );
                 }
             }
             else
@@ -404,25 +458,32 @@
         }
 
         subclassesSection.layout();
-
     }
 
 
+    /**
+     * Creates the content of the must section. 
+     * It is newly created on every input change because the content
+     * of this section is dynamic.
+     *
+     * @param ocd the object class description
+     */
     private void createSuperclassContents( ObjectClassDescription ocd )
     {
-
+        // dispose old content
         if ( superclassesSection.getClient() != null )
         {
             superclassesSection.getClient().dispose();
         }
 
+        // create new client
         Composite superClient = toolkit.createComposite( superclassesSection, SWT.WRAP );
         superClient.setLayout( new GridLayout() );
         superclassesSection.setClient( superClient );
 
+        // craete new content
         if ( ocd != null )
         {
-
             String[] names = ocd.getSuperiorObjectClassDescriptionNames();
             if ( names != null && names.length > 0 )
             {
@@ -443,13 +504,7 @@
                         superLinks[i].setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
                         superLinks[i].setUnderlined( true );
                         superLinks[i].setEnabled( true );
-                        superLinks[i].addHyperlinkListener( new HyperlinkAdapter()
-                        {
-                            public void linkActivated( HyperlinkEvent e )
-                            {
-                                SchemaBrowser.select( e.getHref() );
-                            }
-                        } );
+                        superLinks[i].addHyperlinkListener( this );
                     }
                     else
                     {
@@ -475,7 +530,6 @@
         }
 
         superclassesSection.layout();
-
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ObjectClassDescriptionPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ObjectClassDescriptionPage.java?view=diff&rev=506058&r1=506057&r2=506058
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ObjectClassDescriptionPage.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ObjectClassDescriptionPage.java Sun Feb 11 08:01:38 2007
@@ -21,155 +21,111 @@
 package org.apache.directory.ldapstudio.browser.ui.editors.schemabrowser;
 
 
-import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
 import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.Schema;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
 
 
-public class ObjectClassDescriptionPage extends SchemaPage implements ISelectionChangedListener
+/**
+ * The ObjectClassDescriptionPage displays a list with all
+ * object class descriptions and hosts the detail page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ObjectClassDescriptionPage extends SchemaPage
 {
 
-    private Section section;
-
-    private Text filterText;
-
-    private TableViewer viewer;
-
-
+    /**
+     * Creates a new instance of ObjectClassDescriptionPage.
+     *
+     * @param schemaBrowser the schema browser
+     */
     public ObjectClassDescriptionPage( SchemaBrowser schemaBrowser )
     {
         super( schemaBrowser );
     }
 
 
-    protected void refresh()
+    /**
+     * {@inheritDoc}
+     */
+    protected String getTitle()
     {
-        if ( this.schemaBrowser.isShowDefaultSchema() )
-        {
-            this.form.setText( "Object Classes of default schema" );
-            this.viewer.setInput( Schema.DEFAULT_SCHEMA );
-        }
-        else if ( this.selectedConnection != null )
-        {
-            this.form.setText( "Object Classes of connection '" + this.selectedConnection.getName() + "'" );
-            this.viewer.setInput( this.selectedConnection.getSchema() );
-        }
-        else
-        {
-            this.form.setText( "Object Classes" );
-            this.viewer.setInput( null );
-        }
-        this.viewer.refresh();
+        return "Object Classes";
     }
 
 
-    protected void createMaster( Composite parent )
+    /**
+     * {@inheritDoc}
+     */
+    protected String getFilterDescription()
     {
+        return "Please select an object class. Enter a filter to restrict the list.";
+    }
 
-        section = toolkit.createSection( parent, Section.DESCRIPTION );
-        section.marginWidth = 10;
-        section.marginHeight = 12;
-        section.setText( "Object Classes" );
-        section.setDescription( "Please select an object class. Enter a filter to restrict the list." );
-        toolkit.createCompositeSeparator( section );
-
-        Composite client = toolkit.createComposite( section, SWT.WRAP );
-        GridLayout layout = new GridLayout( 2, false );
-        layout.marginWidth = 5;
-        layout.marginHeight = 5;
-        client.setLayout( layout );
-        section.setClient( client );
 
-        toolkit.createLabel( client, "Filter:" );
-        this.filterText = toolkit.createText( client, "", SWT.NONE );
-        this.filterText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
-        this.filterText.setData( FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER );
-        this.filterText.addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent e )
-            {
-                viewer.refresh();
-            }
-        } );
+    /**
+     * {@inheritDoc}
+     */
+    protected IStructuredContentProvider getContentProvider()
+    {
+        return new OCDContentProvider();
+    }
 
-        Table t = toolkit.createTable( client, SWT.NONE );
-        GridData gd = new GridData( GridData.FILL_BOTH );
-        gd.horizontalSpan = 2;
-        gd.heightHint = 20;
-        gd.widthHint = 100;
-        t.setLayoutData( gd );
-        toolkit.paintBordersFor( client );
 
-        viewer = new TableViewer( t );
-        viewer.setContentProvider( new OCDContentProvider() );
-        viewer.setLabelProvider( new OCDLabelProvider() );
-        viewer.setSorter( new OCDViewerSorter() );
-        viewer.addFilter( new OCDViewerFilter() );
+    /**
+     * {@inheritDoc}
+     */
+    protected ITableLabelProvider getLabelProvider()
+    {
+        return new OCDLabelProvider();
     }
 
 
-    protected void createDetail( Composite body )
+    /**
+     * {@inheritDoc}
+     */
+    protected ViewerSorter getSorter()
     {
-        this.detailsPage = new ObjectClassDescriptionDetailsPage( this.schemaBrowser, this.toolkit );
-        this.detailsPage.createContents( this.detailForm );
-        this.viewer.addSelectionChangedListener( this );
+        return new OCDViewerSorter();
     }
 
 
-    public void selectionChanged( SelectionChangedEvent event )
+    /**
+     * {@inheritDoc}
+     */
+    protected ViewerFilter getFilter()
     {
-        ISelection selection = event.getSelection();
-        if ( selection.isEmpty() )
-        {
-            EventRegistry.fireObjectClassDescriptionSelected( null, this );
-        }
-        else
-        {
-            Object obj = ( ( StructuredSelection ) selection ).getFirstElement();
-            if ( obj instanceof ObjectClassDescription )
-            {
-                ObjectClassDescription ocd = ( ObjectClassDescription ) obj;
-                EventRegistry.fireObjectClassDescriptionSelected( ocd, this );
-            }
-        }
+        return new OCDViewerFilter();
     }
 
 
-    public void select( Object obj )
+    /**
+     * {@inheritDoc}
+     */
+    protected SchemaDetailsPage getDetailsPage()
     {
-        this.viewer.setSelection( new StructuredSelection( obj ), true );
-        if ( this.viewer.getSelection().isEmpty() )
-        {
-            this.filterText.setText( "" );
-            this.viewer.setSelection( new StructuredSelection( obj ), true );
-        }
+        return new ObjectClassDescriptionDetailsPage( this, this.toolkit );
     }
 
+    /**
+     * The content provider used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     class OCDContentProvider implements IStructuredContentProvider
     {
+        /**
+         * {@inheritDoc}
+         */
         public Object[] getElements( Object inputElement )
         {
             if ( inputElement instanceof Schema )
@@ -184,40 +140,76 @@
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public void dispose()
         {
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
         {
         }
     }
 
+    /**
+     * The label provider used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     class OCDLabelProvider extends LabelProvider implements ITableLabelProvider
     {
+        /**
+         * {@inheritDoc}
+         */
         public String getColumnText( Object obj, int index )
         {
             return obj.toString();
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
         public Image getColumnImage( Object obj, int index )
         {
             return null;
         }
     }
 
+    /**
+     * The sorter used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     class OCDViewerSorter extends ViewerSorter
     {
+        /**
+         * {@inheritDoc}
+         */
         public int compare( Viewer viewer, Object e1, Object e2 )
         {
             return e1.toString().compareTo( e2.toString() );
         }
     }
 
+    /**
+     * The filter used by the viewer.
+     *
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
     class OCDViewerFilter extends ViewerFilter
     {
+        /**
+         * {@inheritDoc}
+         */
         public boolean select( Viewer viewer, Object parentElement, Object element )
         {
             if ( element instanceof ObjectClassDescription )

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ReloadSchemaAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ReloadSchemaAction.java?view=diff&rev=506058&r1=506057&r2=506058
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ReloadSchemaAction.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/ReloadSchemaAction.java Sun Feb 11 08:01:38 2007
@@ -25,48 +25,68 @@
 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
-
 import org.eclipse.jface.action.Action;
 
 
+/**
+ * This action reloads the schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class ReloadSchemaAction extends Action
 {
 
-    private SchemaBrowser schemaBrowser;
+    /** The schema page */
+    private SchemaPage schemaPage;
 
 
-    public ReloadSchemaAction( SchemaBrowser schemaBrowserView )
+    /**
+     * Creates a new instance of ReloadSchemaAction.
+     *
+     * @param schemaPage the schema page
+     */
+    public ReloadSchemaAction( SchemaPage schemaPage )
     {
         super( "Reload Schema" );
         super.setToolTipText( "Reload Schema" );
         super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_REFRESH ) );
         super.setEnabled( true );
 
-        this.schemaBrowser = schemaBrowserView;
+        this.schemaPage = schemaPage;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void run()
     {
-        final IConnection connection = schemaBrowser.getSelectedConnection();
+        final IConnection connection = schemaPage.getConnection();
         if ( connection != null )
         {
             new ReloadSchemasJob( new IConnection[]
                 { connection } ).execute();
-            this.schemaBrowser.refresh();
+            schemaPage.getSchemaBrowser().refresh();
         }
     }
 
 
+    /**
+     * Disposes this action.
+     */
     public void dispose()
     {
-        this.schemaBrowser = null;
+        schemaPage = null;
     }
 
 
+    /**
+     * Updates the enabled state.
+     */
     public void updateEnabledState()
     {
-        this.setEnabled( schemaBrowser.getSelectedConnection() != null && !schemaBrowser.isShowDefaultSchema() );
+        setEnabled( schemaPage.getConnection() != null && !schemaPage.isShowDefaultSchema() );
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/SchemaBrowser.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/SchemaBrowser.java?view=diff&rev=506058&r1=506057&r2=506058
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/SchemaBrowser.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/editors/schemabrowser/SchemaBrowser.java Sun Feb 11 08:01:38 2007
@@ -27,9 +27,9 @@
 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleUseDescription;
 import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaPart;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
-
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.CTabFolder;
@@ -39,257 +39,316 @@
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.INavigationLocation;
+import org.eclipse.ui.INavigationLocationProvider;
+import org.eclipse.ui.IReusableEditor;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.EditorPart;
 
 
-public class SchemaBrowser extends EditorPart
+/**
+ * The schema browser editor part.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaBrowser extends EditorPart implements INavigationLocationProvider, IReusableEditor
 {
 
+    /** The tab folder with all the schema element tabs */
     private CTabFolder tabFolder;
 
+    /** The object class tab */
     private CTabItem ocdTab;
 
+    /** The object class page */
     private ObjectClassDescriptionPage ocdPage;
 
+    /** The attribute type tab */
     private CTabItem atdTab;
 
+    /** The attribute type page */
     private AttributeTypeDescriptionPage atdPage;
 
+    /** The matching rule tab */
     private CTabItem mrdTab;
 
+    /** The matching rule page */
     private MatchingRuleDescriptionPage mrdPage;
 
+    /** The matching rule use tab */
     private CTabItem mrudTab;
 
+    /** The matching rule use page */
     private MatchingRuleUseDescriptionPage mrudPage;
 
+    /** The syntax tab */
     private CTabItem lsdTab;
 
+    /** The syntax page */
     private LdapSyntaxDescriptionPage lsdPage;
 
-    private HistoryManager historyManager;
-
-    private BackAction backAction;
-
-    private ForwardAction forwardAction;
-
-    private ShowDefaultSchemaAction showDefaultSchemaAction;
-
-    private ReloadSchemaAction reloadSchemaAction;
-
 
+    /**
+     * Gets the ID of the schema browser.
+     *
+     * @return the ID of the schema browser
+     */
     public static String getId()
     {
         return SchemaBrowser.class.getName();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void init( IEditorSite site, IEditorInput input ) throws PartInitException
     {
-        setInput( SchemaBrowserInput.getInstance() );
-        super.setSite( site );
+        setSite( site );
+
+        // mark dummy location, necessary because the first marked
+        // location doesn't appear in history
+        setInput( new SchemaBrowserInput( null, null ) );
+        getSite().getPage().getNavigationHistory().markLocation( this );
+
+        // set real input
+        setInput( input );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
-        this.reloadSchemaAction.dispose();
-        this.showDefaultSchemaAction.dispose();
-        this.ocdPage.dispose();
-        this.atdPage.dispose();
-        this.mrdPage.dispose();
-        this.mrudPage.dispose();
-        this.lsdPage.dispose();
-        this.tabFolder.dispose();
+        ocdPage.dispose();
+        atdPage.dispose();
+        mrdPage.dispose();
+        mrudPage.dispose();
+        lsdPage.dispose();
+        tabFolder.dispose();
         super.dispose();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void createPartControl( Composite parent )
     {
+        tabFolder = new CTabFolder( parent, SWT.BOTTOM );
 
-        this.historyManager = new HistoryManager( this );
-        this.backAction = new BackAction( this.historyManager );
-        this.forwardAction = new ForwardAction( this.historyManager );
-        this.showDefaultSchemaAction = new ShowDefaultSchemaAction( this );
-        this.reloadSchemaAction = new ReloadSchemaAction( this );
-
-        this.tabFolder = new CTabFolder( parent, SWT.BOTTOM );
-
-        this.ocdTab = new CTabItem( this.tabFolder, SWT.NONE );
-        this.ocdTab.setText( "Object Classes" );
-        this.ocdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_OCD ) );
-        this.ocdPage = new ObjectClassDescriptionPage( this );
-        Control ocdPageControl = this.ocdPage.createControl( this.tabFolder );
-        this.ocdTab.setControl( ocdPageControl );
-
-        this.atdTab = new CTabItem( this.tabFolder, SWT.NONE );
-        this.atdTab.setText( "Attribute Types" );
-        this.atdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_ATD ) );
-        this.atdPage = new AttributeTypeDescriptionPage( this );
-        Control atdPageControl = this.atdPage.createControl( this.tabFolder );
-        this.atdTab.setControl( atdPageControl );
-
-        this.mrdTab = new CTabItem( this.tabFolder, SWT.NONE );
-        this.mrdTab.setText( "Matching Rules" );
-        this.mrdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_MRD ) );
-        this.mrdPage = new MatchingRuleDescriptionPage( this );
-        Control mrdPageControl = this.mrdPage.createControl( this.tabFolder );
-        this.mrdTab.setControl( mrdPageControl );
-
-        this.mrudTab = new CTabItem( this.tabFolder, SWT.NONE );
-        this.mrudTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_MRUD ) );
-        this.mrudTab.setText( "Matching Rule Use" );
-        this.mrudPage = new MatchingRuleUseDescriptionPage( this );
-        Control mrudPageControl = this.mrudPage.createControl( this.tabFolder );
-        this.mrudTab.setControl( mrudPageControl );
-
-        this.lsdTab = new CTabItem( this.tabFolder, SWT.NONE );
-        this.lsdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_LSD ) );
-        this.lsdTab.setText( "Syntaxes" );
-        this.lsdPage = new LdapSyntaxDescriptionPage( this );
-        Control lsdPageControl = this.lsdPage.createControl( this.tabFolder );
-        this.lsdTab.setControl( lsdPageControl );
+        ocdTab = new CTabItem( tabFolder, SWT.NONE );
+        ocdTab.setText( "Object Classes" );
+        ocdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_OCD ) );
+        ocdPage = new ObjectClassDescriptionPage( this );
+        Control ocdPageControl = ocdPage.createControl( tabFolder );
+        ocdTab.setControl( ocdPageControl );
+
+        atdTab = new CTabItem( tabFolder, SWT.NONE );
+        atdTab.setText( "Attribute Types" );
+        atdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_ATD ) );
+        atdPage = new AttributeTypeDescriptionPage( this );
+        Control atdPageControl = atdPage.createControl( tabFolder );
+        atdTab.setControl( atdPageControl );
+
+        mrdTab = new CTabItem( tabFolder, SWT.NONE );
+        mrdTab.setText( "Matching Rules" );
+        mrdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_MRD ) );
+        mrdPage = new MatchingRuleDescriptionPage( this );
+        Control mrdPageControl = mrdPage.createControl( tabFolder );
+        mrdTab.setControl( mrdPageControl );
+
+        mrudTab = new CTabItem( tabFolder, SWT.NONE );
+        mrudTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_MRUD ) );
+        mrudTab.setText( "Matching Rule Use" );
+        mrudPage = new MatchingRuleUseDescriptionPage( this );
+        Control mrudPageControl = mrudPage.createControl( tabFolder );
+        mrudTab.setControl( mrudPageControl );
+
+        lsdTab = new CTabItem( tabFolder, SWT.NONE );
+        lsdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_LSD ) );
+        lsdTab.setText( "Syntaxes" );
+        lsdPage = new LdapSyntaxDescriptionPage( this );
+        Control lsdPageControl = lsdPage.createControl( tabFolder );
+        lsdTab.setControl( lsdPageControl );
 
-        this.tabFolder.setSelection( this.ocdTab );
+        // set default selection
+        tabFolder.setSelection( ocdTab );
 
+        // init help context
         PlatformUI.getWorkbench().getHelpSystem().setHelp( parent,
             BrowserUIPlugin.PLUGIN_ID + "." + "tools_schema_browser" );
         PlatformUI.getWorkbench().getHelpSystem().setHelp( tabFolder,
             BrowserUIPlugin.PLUGIN_ID + "." + "tools_schema_browser" );
         PlatformUI.getWorkbench().getHelpSystem().setHelp( ocdPageControl,
             BrowserUIPlugin.PLUGIN_ID + "." + "tools_schema_browser" );
-
     }
 
 
-    public static void select( Object obj )
+    /**
+     * {@inheritDoc}
+     */
+    public void setInput( IEditorInput input )
     {
+        super.setInput( input );
 
-        String targetId = SchemaBrowser.getId();
-        IEditorPart target = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findEditor(
-            SchemaBrowserInput.getInstance() );
-        if ( target == null )
-        {
-            try
-            {
-                target = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(
-                    SchemaBrowserInput.getInstance(), targetId, true );
-            }
-            catch ( PartInitException e )
-            {
-            }
-        }
-        if ( target != null && target instanceof SchemaBrowser )
+        if ( input instanceof SchemaBrowserInput && tabFolder != null )
         {
-            // target.getSite().getPage().activate(target);
-            target.getSite().getPage().bringToTop( target );
+            SchemaBrowserInput sbi = ( SchemaBrowserInput ) input;
 
-            SchemaBrowser schemaBrowser = ( ( SchemaBrowser ) target );
-            if ( obj instanceof ObjectClassDescription )
+            // set connection;
+            IConnection connection = sbi.getConnection();
+            setConnection( connection );
+
+            // set schema element and activate tab
+            SchemaPart schemaElement = sbi.getSchemaElement();
+            if ( schemaElement instanceof ObjectClassDescription )
             {
-                schemaBrowser.ocdPage.select( obj );
-                schemaBrowser.tabFolder.setSelection( schemaBrowser.ocdTab );
+                ocdPage.select( schemaElement );
+                tabFolder.setSelection( ocdTab );
             }
-            else if ( obj instanceof AttributeTypeDescription )
+            else if ( schemaElement instanceof AttributeTypeDescription )
             {
-                schemaBrowser.atdPage.select( obj );
-                schemaBrowser.tabFolder.setSelection( schemaBrowser.atdTab );
+                atdPage.select( schemaElement );
+                tabFolder.setSelection( atdTab );
             }
-            else if ( obj instanceof MatchingRuleDescription )
+            else if ( schemaElement instanceof MatchingRuleDescription )
             {
-                schemaBrowser.mrdPage.select( obj );
-                schemaBrowser.tabFolder.setSelection( schemaBrowser.mrdTab );
+                mrdPage.select( schemaElement );
+                tabFolder.setSelection( mrdTab );
             }
-            else if ( obj instanceof MatchingRuleUseDescription )
+            else if ( schemaElement instanceof MatchingRuleUseDescription )
             {
-                schemaBrowser.mrudPage.select( obj );
-                schemaBrowser.tabFolder.setSelection( schemaBrowser.mrudTab );
+                mrudPage.select( schemaElement );
+                tabFolder.setSelection( mrudTab );
             }
-            else if ( obj instanceof LdapSyntaxDescription )
+            else if ( schemaElement instanceof LdapSyntaxDescription )
             {
-                schemaBrowser.lsdPage.select( obj );
-                schemaBrowser.tabFolder.setSelection( schemaBrowser.lsdTab );
+                lsdPage.select( schemaElement );
+                tabFolder.setSelection( lsdTab );
             }
-        }
-
-    }
-
-
-    public BackAction getBackAction()
-    {
-        return this.backAction;
-    }
-
-
-    public ForwardAction getForwardAction()
-    {
-        return this.forwardAction;
-    }
-
-
-    public ReloadSchemaAction getReloadSchemaAction()
-    {
-        return reloadSchemaAction;
-    }
 
+            if ( connection != null && schemaElement != null )
+            {
+                // enable one instance hack before fireing the input change event 
+                // otherwise the navigation history is cleared.
+                SchemaBrowserInput.enableOneInstanceHack( true );
+                firePropertyChange( IEditorPart.PROP_INPUT );
+
+                // disable one instance hack for marking the location
+                SchemaBrowserInput.enableOneInstanceHack( false );
+                getSite().getPage().getNavigationHistory().markLocation( this );
+            }
 
-    public ShowDefaultSchemaAction getShowDefaultSchemaAction()
-    {
-        return showDefaultSchemaAction;
+            // finally enable the one instance hack 
+            SchemaBrowserInput.enableOneInstanceHack( true );
+        }
     }
 
 
+    /**
+     * Refreshes all pages.
+     */
     public void refresh()
     {
-        this.ocdPage.refresh();
-        this.atdPage.refresh();
-        this.mrdPage.refresh();
-        this.mrudPage.refresh();
-        this.lsdPage.refresh();
-
-        this.reloadSchemaAction.updateEnabledState();
+        ocdPage.refresh();
+        atdPage.refresh();
+        mrdPage.refresh();
+        mrudPage.refresh();
+        lsdPage.refresh();
     }
 
 
-    public boolean isShowDefaultSchema()
+    /**
+     * Sets the show defauls schema flag to all pages.
+     *
+     * @param b the default schema flag
+     */
+    public void setShowDefaultSchema( boolean b )
     {
-        return this.showDefaultSchemaAction.isChecked();
+        ocdPage.setShowDefaultSchema( b );
+        atdPage.setShowDefaultSchema( b );
+        mrdPage.setShowDefaultSchema( b );
+        mrudPage.setShowDefaultSchema( b );
+        lsdPage.setShowDefaultSchema( b );
     }
 
 
-    public IConnection getSelectedConnection()
+    /**
+     * Sets the connection.
+     * 
+     * @param connection the connection
+     */
+    public void setConnection( IConnection connection )
     {
-        return this.ocdPage.getSelectedConnection();
+        ocdPage.setConnection( connection );
+        atdPage.setConnection( connection );
+        mrdPage.setConnection( connection );
+        mrudPage.setConnection( connection );
+        lsdPage.setConnection( connection );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setFocus()
     {
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void doSave( IProgressMonitor monitor )
     {
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void doSaveAs()
     {
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean isDirty()
     {
         return false;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean isSaveAsAllowed()
     {
         return false;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public INavigationLocation createEmptyNavigationLocation()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public INavigationLocation createNavigationLocation()
+    {
+        return new SchemaBrowserNavigationLocation( this );
     }
 
 }



Mime
View raw message