directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1220833 - in /directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors: ./ attributetype/ objectclass/
Date Mon, 19 Dec 2011 16:33:24 GMT
Author: pamarcelot
Date: Mon Dec 19 16:33:23 2011
New Revision: 1220833

URL: http://svn.apache.org/viewvc?rev=1220833&view=rev
Log:
Gathered common methods into dedicated abstract classes.

Added:
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/AbstractSchemaObjectEditorPage.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AbstractAttributeTypeEditorPage.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/AbstractObjectClassEditorPage.java
Modified:
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorSourceCodePage.java

Added: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/AbstractSchemaObjectEditorPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/AbstractSchemaObjectEditorPage.java?rev=1220833&view=auto
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/AbstractSchemaObjectEditorPage.java (added)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/AbstractSchemaObjectEditorPage.java Mon Dec 19 16:33:23 2011
@@ -0,0 +1,117 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.schemaeditor.view.editors;
+
+
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+
+
+/**
+ * This abstract class defines a schema object editor page.
+ */
+public abstract class AbstractSchemaObjectEditorPage<E extends FormEditor> extends FormPage
+{
+    /** The flag to indicate if the page has been initialized */
+    protected boolean initialized = false;
+
+
+    /**
+     * Default constructor
+     * 
+     * @param editor the parent editor
+     * @param id the unique identifier
+     * @param title the page title
+     */
+    public AbstractSchemaObjectEditorPage( E editor, String id, String title )
+    {
+        super( editor, id, title );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public E getEditor()
+    {
+        return ( E ) super.getEditor();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void createFormContent( IManagedForm managedForm )
+    {
+        initialized = true;
+    }
+
+
+    /**
+     * Adds listeners to UI fields
+     */
+    protected void addListeners()
+    {
+    }
+
+
+    /**
+     * Removes listeners from UI fields
+     */
+    protected void removeListeners()
+    {
+    }
+
+
+    /**
+     * Initializes the UI fields from the input.
+     */
+    protected void fillInUiFields()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        removeListeners();
+
+        super.dispose();
+    }
+
+
+    /**
+     * Refreshes the UI.
+     */
+    public void refreshUI()
+    {
+        if ( initialized )
+        {
+            removeListeners();
+            fillInUiFields();
+            addListeners();
+        }
+    }
+}

Added: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AbstractAttributeTypeEditorPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AbstractAttributeTypeEditorPage.java?rev=1220833&view=auto
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AbstractAttributeTypeEditorPage.java (added)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AbstractAttributeTypeEditorPage.java Mon Dec 19 16:33:23 2011
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.schemaeditor.view.editors.attributetype;
+
+
+import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.studio.schemaeditor.view.editors.AbstractSchemaObjectEditorPage;
+
+
+/**
+ * This abstract class defines an attribute type editor page.
+ */
+public abstract class AbstractAttributeTypeEditorPage extends AbstractSchemaObjectEditorPage<AttributeTypeEditor>
+{
+    /** The flag to indicate if the page has been initialized */
+    protected boolean initialized = false;
+
+
+    /**
+     * Default constructor
+     * 
+     * @param editor the parent editor
+     * @param id the unique identifier
+     * @param title the page title
+     */
+    public AbstractAttributeTypeEditorPage( AttributeTypeEditor editor, String id, String title )
+    {
+        super( editor, id, title );
+    }
+
+
+    /**
+     * Gets the original attribute type.
+     *
+     * @return
+     *      the original attribute type
+     */
+    public AttributeType getOriginalAttributeType()
+    {
+        return getEditor().getOriginalAttributeType();
+    }
+
+
+    /**
+     * Gets the modified attribute type.
+     *
+     * @return
+     *      the modified attribute type
+     */
+    public AttributeType getModifiedAttributeType()
+    {
+        return getEditor().getModifiedAttributeType();
+    }
+
+
+    /**
+     * Sets the editor as dirty
+     */
+    protected void setEditorDirty()
+    {
+        getEditor().setDirty( true );
+    }
+}

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java?rev=1220833&r1=1220832&r2=1220833&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java (original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorOverviewPage.java Mon Dec 19 16:33:23 2011
@@ -71,8 +71,6 @@ import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.events.HyperlinkAdapter;
 import org.eclipse.ui.forms.events.HyperlinkEvent;
 import org.eclipse.ui.forms.widgets.FormToolkit;
@@ -84,17 +82,11 @@ import org.eclipse.ui.forms.widgets.Sect
 /**
  * This class is the Overview Page of the Attribute Type Editor
  */
-public class AttributeTypeEditorOverviewPage extends FormPage
+public class AttributeTypeEditorOverviewPage extends AbstractAttributeTypeEditorPage
 {
     /** The page ID*/
     public static final String ID = AttributeTypeEditor.ID + ".overviewPage"; //$NON-NLS-1$
 
-    /** The original attribute type */
-    private AttributeType originalAttributeType;
-
-    /** The modified attribute type */
-    private AttributeType modifiedAttributeType;
-
     /** The original schema */
     private Schema originalSchema;
 
@@ -118,7 +110,7 @@ public class AttributeTypeEditorOverview
 
         public void attributeTypeRemoved( AttributeType at )
         {
-            if ( !at.equals( originalAttributeType ) )
+            if ( !at.equals( getOriginalAttributeType() ) )
             {
                 refreshUI();
             }
@@ -232,6 +224,7 @@ public class AttributeTypeEditorOverview
     {
         public void modifyText( ModifyEvent e )
         {
+            AttributeType modifiedAttributeType = getModifiedAttributeType();
             AliasesStringParser parser = new AliasesStringParser();
             parser.parse( aliasesText.getText() );
             List<Alias> parsedAliases = parser.getAliases();
@@ -254,6 +247,7 @@ public class AttributeTypeEditorOverview
     {
         public void widgetSelected( SelectionEvent e )
         {
+            AttributeType modifiedAttributeType = getModifiedAttributeType();
             EditAttributeTypeAliasesDialog dialog = new EditAttributeTypeAliasesDialog(
                 modifiedAttributeType.getNames() );
             if ( dialog.open() == EditAttributeTypeAliasesDialog.OK )
@@ -284,10 +278,10 @@ public class AttributeTypeEditorOverview
 
             if ( Oid.isOid( oid ) )
             {
-                if ( ( originalAttributeType.getOid().equals( oid ) )
+                if ( ( getOriginalAttributeType().getOid().equals( oid ) )
                     || !( schemaHandler.isOidAlreadyTaken( oid ) ) )
                 {
-                    modifiedAttributeType.setOid( oid );
+                    getModifiedAttributeType().setOid( oid );
                     setEditorDirty();
                 }
                 else
@@ -324,7 +318,7 @@ public class AttributeTypeEditorOverview
             IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
 
             SchemaEditorInput input = new SchemaEditorInput( schemaHandler
-                .getSchema( modifiedAttributeType.getSchemaName() ) );
+                .getSchema( getModifiedAttributeType().getSchemaName() ) );
             String editorId = SchemaEditor.ID;
             try
             {
@@ -343,7 +337,7 @@ public class AttributeTypeEditorOverview
         public void modifyText( ModifyEvent e )
         {
             int caretPosition = descriptionText.getCaretPosition();
-            modifiedAttributeType.setDescription( descriptionText.getText() );
+            getModifiedAttributeType().setDescription( descriptionText.getText() );
             descriptionText.setSelection( caretPosition );
             setEditorDirty();
         }
@@ -378,6 +372,7 @@ public class AttributeTypeEditorOverview
     {
         public void selectionChanged( SelectionChangedEvent event )
         {
+            AttributeType modifiedAttributeType = getModifiedAttributeType();
             Object selectedItem = ( ( StructuredSelection ) supComboViewer.getSelection() ).getFirstElement();
 
             if ( selectedItem instanceof AttributeType )
@@ -415,6 +410,7 @@ public class AttributeTypeEditorOverview
     {
         public void modifyText( ModifyEvent e )
         {
+            AttributeType modifiedAttributeType = getModifiedAttributeType();
             if ( usageCombo.getSelectionIndex() == 0 )
             {
                 modifiedAttributeType.setUsage( UsageEnum.DIRECTORY_OPERATION );
@@ -440,6 +436,7 @@ public class AttributeTypeEditorOverview
     {
         public void selectionChanged( SelectionChangedEvent event )
         {
+            AttributeType modifiedAttributeType = getModifiedAttributeType();
             Object selectedItem = ( ( StructuredSelection ) syntaxComboViewer.getSelection() ).getFirstElement();
 
             if ( selectedItem instanceof LdapSyntax )
@@ -468,6 +465,7 @@ public class AttributeTypeEditorOverview
     {
         public void modifyText( ModifyEvent e )
         {
+            AttributeType modifiedAttributeType = getModifiedAttributeType();
             if ( syntaxLengthText.getText().length() <= 0 )
             {
                 modifiedAttributeType.setSyntaxLength( -1 );
@@ -497,7 +495,7 @@ public class AttributeTypeEditorOverview
     {
         public void widgetSelected( SelectionEvent e )
         {
-            modifiedAttributeType.setObsolete( obsoleteCheckbox.getSelection() );
+            getModifiedAttributeType().setObsolete( obsoleteCheckbox.getSelection() );
             setEditorDirty();
         }
     };
@@ -507,7 +505,7 @@ public class AttributeTypeEditorOverview
     {
         public void widgetSelected( SelectionEvent e )
         {
-            modifiedAttributeType.setSingleValued( singleValueCheckbox.getSelection() );
+            getModifiedAttributeType().setSingleValued( singleValueCheckbox.getSelection() );
             setEditorDirty();
         }
     };
@@ -517,7 +515,7 @@ public class AttributeTypeEditorOverview
     {
         public void widgetSelected( SelectionEvent e )
         {
-            modifiedAttributeType.setCollective( collectiveCheckbox.getSelection() );
+            getModifiedAttributeType().setCollective( collectiveCheckbox.getSelection() );
             setEditorDirty();
         }
     };
@@ -527,7 +525,7 @@ public class AttributeTypeEditorOverview
     {
         public void widgetSelected( SelectionEvent e )
         {
-            modifiedAttributeType.setUserModifiable( !noUserModificationCheckbox.getSelection() );
+            getModifiedAttributeType().setUserModifiable( !noUserModificationCheckbox.getSelection() );
             setEditorDirty();
         }
     };
@@ -537,6 +535,7 @@ public class AttributeTypeEditorOverview
     {
         public void selectionChanged( SelectionChangedEvent event )
         {
+            AttributeType modifiedAttributeType = getModifiedAttributeType();
             Object selectedItem = ( ( StructuredSelection ) equalityComboViewer.getSelection() ).getFirstElement();
 
             if ( selectedItem instanceof MatchingRule )
@@ -565,6 +564,7 @@ public class AttributeTypeEditorOverview
     {
         public void selectionChanged( SelectionChangedEvent event )
         {
+            AttributeType modifiedAttributeType = getModifiedAttributeType();
             Object selectedItem = ( ( StructuredSelection ) orderingComboViewer.getSelection() ).getFirstElement();
 
             if ( selectedItem instanceof MatchingRule )
@@ -593,6 +593,7 @@ public class AttributeTypeEditorOverview
     {
         public void selectionChanged( SelectionChangedEvent event )
         {
+            AttributeType modifiedAttributeType = getModifiedAttributeType();
             Object selectedItem = ( ( StructuredSelection ) substringComboViewer.getSelection() ).getFirstElement();
 
             if ( selectedItem instanceof MatchingRule )
@@ -636,7 +637,7 @@ public class AttributeTypeEditorOverview
      * @param editor
      *      the associated editor
      */
-    public AttributeTypeEditorOverviewPage( FormEditor editor )
+    public AttributeTypeEditorOverviewPage( AttributeTypeEditor editor )
     {
         super( editor, ID, Messages.getString( "AttributeTypeEditorOverviewPage.Overview" ) ); //$NON-NLS-1$
         schemaHandler = Activator.getDefault().getSchemaHandler();
@@ -649,6 +650,8 @@ public class AttributeTypeEditorOverview
      */
     protected void createFormContent( IManagedForm managedForm )
     {
+        super.createFormContent( managedForm );
+
         // Creating the base UI
         ScrolledForm form = managedForm.getForm();
         FormToolkit toolkit = managedForm.getToolkit();
@@ -863,14 +866,14 @@ public class AttributeTypeEditorOverview
 
 
     /**
-     * Fills in the User Interface fields.
+     * {@inheritDoc}
      */
-    private void fillInUiFields()
+    protected void fillInUiFields()
     {
-        // Getting the original and modified attribute types
-        modifiedAttributeType = ( ( AttributeTypeEditor ) getEditor() ).getModifiedAttributeType();
-        originalAttributeType = ( ( AttributeTypeEditor ) getEditor() ).getOriginalAttributeType();
-        originalSchema = schemaHandler.getSchema( originalAttributeType.getSchemaName() );
+        // Getting the modified attribute type
+        AttributeType modifiedAttributeType = getModifiedAttributeType();
+
+        originalSchema = schemaHandler.getSchema( getOriginalAttributeType().getSchemaName() );
 
         // ALIASES Label
         if ( ( modifiedAttributeType.getNames() != null ) && ( modifiedAttributeType.getNames().size() != 0 ) )
@@ -940,9 +943,9 @@ public class AttributeTypeEditorOverview
      */
     private void fillSupCombo()
     {
-        supComboViewer.setInput( new ATESuperiorComboInput( originalAttributeType ) );
+        supComboViewer.setInput( new ATESuperiorComboInput( getOriginalAttributeType() ) );
 
-        String supAtName = modifiedAttributeType.getSuperiorOid();
+        String supAtName = getModifiedAttributeType().getSuperiorOid();
         if ( supAtName == null )
         {
             supComboViewer.setSelection( new StructuredSelection( new NonExistingAttributeType(
@@ -975,21 +978,22 @@ public class AttributeTypeEditorOverview
      */
     private void fillInUsageCombo()
     {
-        if ( modifiedAttributeType.getUsage() == UsageEnum.DIRECTORY_OPERATION )
-        {
-            usageCombo.select( 0 );
-        }
-        else if ( modifiedAttributeType.getUsage() == UsageEnum.DISTRIBUTED_OPERATION )
-        {
-            usageCombo.select( 1 );
-        }
-        else if ( modifiedAttributeType.getUsage() == UsageEnum.DSA_OPERATION )
-        {
-            usageCombo.select( 2 );
-        }
-        else if ( modifiedAttributeType.getUsage() == UsageEnum.USER_APPLICATIONS )
+        UsageEnum usage = getModifiedAttributeType().getUsage();
+
+        switch ( usage )
         {
-            usageCombo.select( 3 );
+            case DIRECTORY_OPERATION:
+                usageCombo.select( 0 );
+                return;
+            case DISTRIBUTED_OPERATION:
+                usageCombo.select( 1 );
+                return;
+            case DSA_OPERATION:
+                usageCombo.select( 2 );
+                return;
+            case USER_APPLICATIONS:
+                usageCombo.select( 3 );
+                return;
         }
     }
 
@@ -1001,7 +1005,7 @@ public class AttributeTypeEditorOverview
     {
         syntaxComboViewer.setInput( new ATESyntaxComboInput() );
 
-        String syntaxOID = modifiedAttributeType.getSyntaxOid();
+        String syntaxOID = getModifiedAttributeType().getSyntaxOid();
         if ( syntaxOID == null )
         {
             syntaxComboViewer.setSelection( new StructuredSelection( new NonExistingSyntax( NonExistingSyntax.NONE ) ),
@@ -1036,7 +1040,7 @@ public class AttributeTypeEditorOverview
     {
         equalityComboViewer.setInput( new ATEMatchingRulesComboInput() );
 
-        String equalityName = modifiedAttributeType.getEqualityOid();
+        String equalityName = getModifiedAttributeType().getEqualityOid();
         if ( equalityName == null )
         {
             equalityComboViewer.setSelection( new StructuredSelection( new NonExistingMatchingRule(
@@ -1071,7 +1075,7 @@ public class AttributeTypeEditorOverview
     {
         orderingComboViewer.setInput( new ATEMatchingRulesComboInput() );
 
-        String orderingName = modifiedAttributeType.getOrderingOid();
+        String orderingName = getModifiedAttributeType().getOrderingOid();
         if ( orderingName == null )
         {
             orderingComboViewer.setSelection( new StructuredSelection( new NonExistingMatchingRule(
@@ -1107,7 +1111,7 @@ public class AttributeTypeEditorOverview
     {
         substringComboViewer.setInput( new ATEMatchingRulesComboInput() );
 
-        String substringName = modifiedAttributeType.getSubstringOid();
+        String substringName = getModifiedAttributeType().getSubstringOid();
         if ( substringName == null )
         {
             substringComboViewer.setSelection( new StructuredSelection( new NonExistingMatchingRule(
@@ -1136,9 +1140,9 @@ public class AttributeTypeEditorOverview
 
 
     /**
-     * Adds listeners to UI fields
+     * {@inheritDoc}
      */
-    private void addListeners()
+    protected void addListeners()
     {
         aliasesText.addModifyListener( aliasesTextModifyListener );
         aliasesButton.addSelectionListener( aliasesButtonListener );
@@ -1165,9 +1169,9 @@ public class AttributeTypeEditorOverview
 
 
     /**
-     * Removes listeners from UI fields
+     * {@inheritDoc}
      */
-    private void removeListeners()
+    protected void removeListeners()
     {
         aliasesText.removeModifyListener( aliasesTextModifyListener );
         aliasesButton.removeSelectionListener( aliasesButtonListener );
@@ -1194,34 +1198,12 @@ public class AttributeTypeEditorOverview
 
 
     /**
-     * Sets the dirty state of the editor to dirty
-     */
-    private void setEditorDirty()
-    {
-        ( ( AttributeTypeEditor ) getEditor() ).setDirty( true );
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public void dispose()
     {
-        removeListeners();
-
         schemaHandler.removeListener( schemaHandlerListener );
 
         super.dispose();
     }
-
-
-    /**
-     * Refreshes the UI.
-     */
-    public void refreshUI()
-    {
-        removeListeners();
-        fillInUiFields();
-        addListeners();
-    }
 }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java?rev=1220833&r1=1220832&r2=1220833&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java (original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorSourceCodePage.java Mon Dec 19 16:33:23 2011
@@ -41,8 +41,6 @@ import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 
@@ -50,17 +48,11 @@ import org.eclipse.ui.forms.widgets.Scro
 /**
  * This class is the Source Code Page of the Attribute Type Editor
  */
-public class AttributeTypeEditorSourceCodePage extends FormPage
+public class AttributeTypeEditorSourceCodePage extends AbstractAttributeTypeEditorPage
 {
     /** The page ID */
     public static final String ID = AttributeTypeEditor.ID + "sourceCodePage"; //$NON-NLS-1$
 
-    /** The flag to indicate if the page has been initialized */
-    private boolean initialized = false;
-
-    /** The modified attribute type */
-    private AttributeType modifiedAttributeType;
-
     /** The Schema Source Viewer */
     private SchemaSourceViewer schemaSourceViewer;
 
@@ -106,7 +98,7 @@ public class AttributeTypeEditorSourceCo
      * @param editor
      *            the associated editor
      */
-    public AttributeTypeEditorSourceCodePage( FormEditor editor )
+    public AttributeTypeEditorSourceCodePage( AttributeTypeEditor editor )
     {
         super( editor, ID, Messages.getString( "AttributeTypeEditorSourceCodePage.SourceCode" ) ); //$NON-NLS-1$
     }
@@ -117,6 +109,8 @@ public class AttributeTypeEditorSourceCo
      */
     protected void createFormContent( IManagedForm managedForm )
     {
+        super.createFormContent( managedForm );
+
         ScrolledForm form = managedForm.getForm();
         FormToolkit toolkit = managedForm.getToolkit();
         GridLayout layout = new GridLayout();
@@ -141,7 +135,7 @@ public class AttributeTypeEditorSourceCo
 
         // Initialization from the "input" attribute type
         fillInUiFields();
-        
+
         // Listeners initialization
         addListeners();
 
@@ -154,33 +148,29 @@ public class AttributeTypeEditorSourceCo
 
 
     /**
-     * Adds listeners to UI fields
+     * {@inheritDoc}
      */
-    private void addListeners()
+    protected void addListeners()
     {
         schemaSourceViewer.getTextWidget().addModifyListener( schemaSourceViewerListener );
     }
 
 
     /**
-     * Adds listeners to UI fields
+     * {@inheritDoc}
      */
-    private void removeListeners()
+    protected void removeListeners()
     {
         schemaSourceViewer.getTextWidget().removeModifyListener( schemaSourceViewerListener );
     }
 
 
     /**
-     * Fills in the User Interface.
+     * {@inheritDoc}
      */
-    private void fillInUiFields()
+    protected void fillInUiFields()
     {
-        // Getting the modified attribute type
-        modifiedAttributeType = ( ( AttributeTypeEditor ) getEditor() ).getModifiedAttributeType();
-
-        // SOURCE CODE Field
-        schemaSourceViewer.getDocument().set( OpenLdapSchemaFileExporter.toSourceCode( modifiedAttributeType ) );
+        schemaSourceViewer.getDocument().set( OpenLdapSchemaFileExporter.toSourceCode( getModifiedAttributeType() ) );
     }
 
 
@@ -202,6 +192,8 @@ public class AttributeTypeEditorSourceCo
      */
     private void updateAttributeType( AttributeType atl )
     {
+        AttributeType modifiedAttributeType = getModifiedAttributeType();
+
         modifiedAttributeType.setCollective( atl.isCollective() );
         modifiedAttributeType.setDescription( atl.getDescription() );
         modifiedAttributeType.setEqualityOid( atl.getEqualityOid() );
@@ -217,29 +209,4 @@ public class AttributeTypeEditorSourceCo
         modifiedAttributeType.setUsage( atl.getUsage() );
         modifiedAttributeType.setUserModifiable( atl.isUserModifiable() );
     }
-
-
-    /**
-     * Refreshes the UI.
-     */
-    public void refreshUI()
-    {
-        if ( initialized )
-        {
-            removeListeners();
-            fillInUiFields();
-            addListeners();
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void dispose()
-    {
-        removeListeners();
-
-        super.dispose();
-    }
 }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java?rev=1220833&r1=1220832&r2=1220833&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java (original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/attributetype/AttributeTypeEditorUsedByPage.java Mon Dec 19 16:33:23 2011
@@ -48,8 +48,6 @@ import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 import org.eclipse.ui.forms.widgets.Section;
@@ -58,20 +56,11 @@ import org.eclipse.ui.forms.widgets.Sect
 /**
  * This class is the Used By Page of the Attribute Type Editor
  */
-public class AttributeTypeEditorUsedByPage extends FormPage
+public class AttributeTypeEditorUsedByPage extends AbstractAttributeTypeEditorPage
 {
     /** The page ID */
     public static final String ID = AttributeTypeEditor.ID + "usedByPage"; //$NON-NLS-1$
 
-    /** The flag to indicate if the page has been initialized */
-    private boolean initialized = false;
-
-    /** The modified attribute type */
-    private AttributeType modifiedAttributeType;
-
-    /** The original attribute type */
-    private AttributeType originalAttributeType;
-
     /** The Schema listener */
     private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerAdapter()
     {
@@ -209,7 +198,7 @@ public class AttributeTypeEditorUsedByPa
      * @param editor
      *      the associated editor
      */
-    public AttributeTypeEditorUsedByPage( FormEditor editor )
+    public AttributeTypeEditorUsedByPage( AttributeTypeEditor editor )
     {
         super( editor, ID, Messages.getString( "AttributeTypeEditorUsedByPage.UsedBy" ) ); //$NON-NLS-1$
         Activator.getDefault().getSchemaHandler().addListener( schemaHandlerListener );
@@ -221,10 +210,6 @@ public class AttributeTypeEditorUsedByPa
      */
     protected void createFormContent( IManagedForm managedForm )
     {
-        // Getting the modified and original attribute types
-        modifiedAttributeType = ( ( AttributeTypeEditor ) getEditor() ).getModifiedAttributeType();
-        originalAttributeType = ( ( AttributeTypeEditor ) getEditor() ).getOriginalAttributeType();
-
         // Creating the base UI
         ScrolledForm form = managedForm.getForm();
         FormToolkit toolkit = managedForm.getToolkit();
@@ -261,6 +246,8 @@ public class AttributeTypeEditorUsedByPa
      */
     private void createAsMandatoryAttributeSection( Composite parent, FormToolkit toolkit )
     {
+        AttributeType modifiedAttributeType = getModifiedAttributeType();
+
         // As Mandatory Attribute Section
         Section mandatoryAttributeSection = toolkit.createSection( parent, Section.DESCRIPTION | Section.EXPANDED
             | Section.TITLE_BAR );
@@ -308,6 +295,8 @@ public class AttributeTypeEditorUsedByPa
      */
     private void createAsOptionalAttributeSection( Composite parent, FormToolkit toolkit )
     {
+        AttributeType modifiedAttributeType = getModifiedAttributeType();
+
         // Matching Rules Section
         Section optionalAttributeSection = toolkit.createSection( parent, Section.DESCRIPTION | Section.EXPANDED
             | Section.TITLE_BAR );
@@ -346,19 +335,21 @@ public class AttributeTypeEditorUsedByPa
 
 
     /**
-     * Fills in the User Interface.
+     * {@inheritDoc}
      */
-    private void fillInUiFields()
+    protected void fillInUiFields()
     {
-        mandatoryAttributeTableViewer.setInput( originalAttributeType );
-        optionalAttibuteTableViewer.setInput( originalAttributeType );
+        AttributeType modifiedAttributeType = getModifiedAttributeType();
+
+        mandatoryAttributeTableViewer.setInput( modifiedAttributeType );
+        optionalAttibuteTableViewer.setInput( modifiedAttributeType );
     }
 
 
     /**
-     * Adds listeners to UI fields
+     * {@inheritDoc}
      */
-    private void addListeners()
+    protected void addListeners()
     {
         mandatoryAttributeTable.addMouseListener( mandatoryAttributeTableListener );
         optionalAttibuteTable.addMouseListener( optionalAttibuteTableListener );
@@ -366,9 +357,9 @@ public class AttributeTypeEditorUsedByPa
 
 
     /**
-     * Removes listeners to UI fields
+     * {@inheritDoc}
      */
-    private void removeListeners()
+    protected void removeListeners()
     {
         mandatoryAttributeTable.removeMouseListener( mandatoryAttributeTableListener );
         optionalAttibuteTable.removeMouseListener( optionalAttibuteTableListener );
@@ -396,24 +387,8 @@ public class AttributeTypeEditorUsedByPa
      */
     public void dispose()
     {
-        removeListeners();
-
         Activator.getDefault().getSchemaHandler().removeListener( schemaHandlerListener );
 
         super.dispose();
     }
-
-
-    /**
-     * Refreshes the UI.
-     */
-    public void refreshUI()
-    {
-        if ( initialized )
-        {
-            removeListeners();
-            fillInUiFields();
-            addListeners();
-        }
-    }
 }

Added: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/AbstractObjectClassEditorPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/AbstractObjectClassEditorPage.java?rev=1220833&view=auto
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/AbstractObjectClassEditorPage.java (added)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/AbstractObjectClassEditorPage.java Mon Dec 19 16:33:23 2011
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.schemaeditor.view.editors.objectclass;
+
+
+import org.apache.directory.shared.ldap.model.schema.ObjectClass;
+import org.apache.directory.studio.schemaeditor.view.editors.AbstractSchemaObjectEditorPage;
+
+
+/**
+ * This abstract class defines an object class editor page.
+ */
+public abstract class AbstractObjectClassEditorPage extends AbstractSchemaObjectEditorPage<ObjectClassEditor>
+{
+    /** The flag to indicate if the page has been initialized */
+    protected boolean initialized = false;
+
+
+    /**
+     * Default constructor
+     * 
+     * @param editor the parent editor
+     * @param id the unique identifier
+     * @param title the page title
+     */
+    public AbstractObjectClassEditorPage( ObjectClassEditor editor, String id, String title )
+    {
+        super( editor, id, title );
+    }
+
+
+    /**
+     * Gets the original object class.
+     *
+     * @return
+     *      the original object class
+     */
+    public ObjectClass getOriginalObjectClass()
+    {
+        return getEditor().getOriginalObjectClass();
+    }
+
+
+    /**
+     * Gets the modified object class.
+     *
+     * @return
+     *      the modified object class
+     */
+    public ObjectClass getModifiedObjectClass()
+    {
+        return getEditor().getModifiedObjectClass();
+    }
+
+
+    /**
+     * Sets the editor as dirty
+     */
+    protected void setEditorDirty()
+    {
+        getEditor().setDirty( true );
+    }
+}

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java?rev=1220833&r1=1220832&r2=1220833&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java (original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorOverviewPage.java Mon Dec 19 16:33:23 2011
@@ -76,8 +76,6 @@ import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.events.HyperlinkAdapter;
 import org.eclipse.ui.forms.events.HyperlinkEvent;
 import org.eclipse.ui.forms.widgets.FormToolkit;
@@ -89,17 +87,11 @@ import org.eclipse.ui.forms.widgets.Sect
 /**
  * This class is the Overview Page of the Object Class Editor
  */
-public class ObjectClassEditorOverviewPage extends FormPage
+public class ObjectClassEditorOverviewPage extends AbstractObjectClassEditorPage
 {
     /** The page ID */
     public static final String ID = ObjectClassEditor.ID + "overviewPage"; //$NON-NLS-1$
 
-    /** The original object class */
-    private ObjectClass originalObjectClass;
-
-    /** The modified object class */
-    private ObjectClass modifiedObjectClass;
-
     /** The original schema */
     private Schema originalSchema;
 
@@ -159,7 +151,7 @@ public class ObjectClassEditorOverviewPa
 
         public void objectClassRemoved( ObjectClass oc )
         {
-            if ( !oc.equals( originalObjectClass ) )
+            if ( !oc.equals( getOriginalObjectClass() ) )
             {
                 refreshUI();
             }
@@ -234,6 +226,7 @@ public class ObjectClassEditorOverviewPa
     {
         public void modifyText( ModifyEvent e )
         {
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
             AliasesStringParser parser = new AliasesStringParser();
             parser.parse( aliasesText.getText() );
             List<Alias> parsedAliases = parser.getAliases();
@@ -256,6 +249,8 @@ public class ObjectClassEditorOverviewPa
     {
         public void widgetSelected( SelectionEvent e )
         {
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
+
             EditObjectClassAliasesDialog dialog = new EditObjectClassAliasesDialog( modifiedObjectClass.getNames() );
             if ( dialog.open() == EditObjectClassAliasesDialog.OK )
             {
@@ -281,11 +276,12 @@ public class ObjectClassEditorOverviewPa
             oidText.setForeground( ViewUtils.COLOR_BLACK );
             oidText.setToolTipText( "" ); //$NON-NLS-1$
 
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
             String oid = oidText.getText();
 
             if ( Oid.isOid( oid ) )
             {
-                if ( ( originalObjectClass.getOid().equals( oid ) )
+                if ( ( getOriginalObjectClass().getOid().equals( oid ) )
                     || !( schemaHandler.isOidAlreadyTaken( oid ) ) )
                 {
                     modifiedObjectClass.setOid( oid );
@@ -324,7 +320,7 @@ public class ObjectClassEditorOverviewPa
         {
             IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
 
-            SchemaEditorInput input = new SchemaEditorInput( schemaHandler.getSchema( modifiedObjectClass
+            SchemaEditorInput input = new SchemaEditorInput( schemaHandler.getSchema( getModifiedObjectClass()
                 .getSchemaName() ) );
             String editorId = SchemaEditor.ID;
             try
@@ -344,7 +340,7 @@ public class ObjectClassEditorOverviewPa
         public void modifyText( ModifyEvent e )
         {
             int caretPosition = descriptionText.getCaretPosition();
-            modifiedObjectClass.setDescription( descriptionText.getText() );
+            getModifiedObjectClass().setDescription( descriptionText.getText() );
             descriptionText.setSelection( caretPosition );
             setEditorDirty();
         }
@@ -355,6 +351,8 @@ public class ObjectClassEditorOverviewPa
     {
         public void modifyText( ModifyEvent e )
         {
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
+
             if ( classTypeCombo.getSelectionIndex() == 0 )
             {
                 modifiedObjectClass.setType( ObjectClassTypeEnum.ABSTRACT );
@@ -376,7 +374,7 @@ public class ObjectClassEditorOverviewPa
     {
         public void widgetSelected( SelectionEvent e )
         {
-            modifiedObjectClass.setObsolete( obsoleteCheckbox.getSelection() );
+            getModifiedObjectClass().setObsolete( obsoleteCheckbox.getSelection() );
             setEditorDirty();
         }
     };
@@ -428,6 +426,8 @@ public class ObjectClassEditorOverviewPa
     {
         public void widgetSelected( SelectionEvent e )
         {
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
+
             AttributeTypeSelectionDialog dialog = new AttributeTypeSelectionDialog();
             List<AttributeType> hiddenATs = new ArrayList<AttributeType>();
             List<String> mustsHidden = modifiedObjectClass.getMustAttributeTypeOids();
@@ -491,6 +491,8 @@ public class ObjectClassEditorOverviewPa
                 return;
             }
 
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
+
             Object selectedElement = selection.getFirstElement();
             if ( selectedElement != null )
             {
@@ -565,6 +567,7 @@ public class ObjectClassEditorOverviewPa
     {
         public void widgetSelected( SelectionEvent e )
         {
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
             AttributeTypeSelectionDialog dialog = new AttributeTypeSelectionDialog();
             List<AttributeType> hiddenATs = new ArrayList<AttributeType>();
             List<String> maysHidden = modifiedObjectClass.getMayAttributeTypeOids();
@@ -628,6 +631,8 @@ public class ObjectClassEditorOverviewPa
                 return;
             }
 
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
+
             Object selectedElement = selection.getFirstElement();
             if ( selectedElement != null )
             {
@@ -702,6 +707,7 @@ public class ObjectClassEditorOverviewPa
     {
         public void widgetSelected( SelectionEvent e )
         {
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
             ObjectClassSelectionDialog dialog = new ObjectClassSelectionDialog();
             List<ObjectClass> hiddenOCs = new ArrayList<ObjectClass>();
             for ( String sup : modifiedObjectClass.getSuperiorOids() )
@@ -712,7 +718,7 @@ public class ObjectClassEditorOverviewPa
                     hiddenOCs.add( oc );
                 }
             }
-            hiddenOCs.add( originalObjectClass );
+            hiddenOCs.add( getOriginalObjectClass() );
             dialog.setHiddenObjectClasses( hiddenOCs.toArray( new ObjectClass[0] ) );
 
             if ( dialog.open() != ObjectClassSelectionDialog.OK )
@@ -759,6 +765,8 @@ public class ObjectClassEditorOverviewPa
                 return;
             }
 
+            ObjectClass modifiedObjectClass = getModifiedObjectClass();
+
             Object selectedElement = selection.getFirstElement();
             if ( selectedElement != null )
             {
@@ -806,11 +814,11 @@ public class ObjectClassEditorOverviewPa
 
 
     /**
-     * Default constructor
-     * @param editor
-     *      the associated editor
+     * Default constructor.
+     * 
+     * @param editor the associated editor
      */
-    public ObjectClassEditorOverviewPage( FormEditor editor )
+    public ObjectClassEditorOverviewPage( ObjectClassEditor editor )
     {
         super( editor, ID, Messages.getString( "ObjectClassEditorOverviewPage.Overview" ) ); //$NON-NLS-1$
         schemaHandler = Activator.getDefault().getSchemaHandler();
@@ -823,6 +831,8 @@ public class ObjectClassEditorOverviewPa
      */
     protected void createFormContent( IManagedForm managedForm )
     {
+        super.createFormContent( managedForm );
+
         // Creating the base UI
         ScrolledForm form = managedForm.getForm();
         FormToolkit toolkit = managedForm.getToolkit();
@@ -841,9 +851,6 @@ public class ObjectClassEditorOverviewPa
         // Optionnal Attributes Section
         createOptionalAttributesSection( bottomComposite, toolkit );
 
-        // Enabling or disabling the fields
-        //        setFieldsEditableState();
-
         // Filling the UI with values from the object class
         fillInUiFields();
 
@@ -1056,14 +1063,13 @@ public class ObjectClassEditorOverviewPa
 
 
     /**
-     * Initializes the UI fields from the input.
+     * {@inheritDoc}
      */
-    private void fillInUiFields()
+    protected void fillInUiFields()
     {
         // Getting the original and modified object classes
-        modifiedObjectClass = ( ( ObjectClassEditor ) getEditor() ).getModifiedObjectClass();
-        originalObjectClass = ( ( ObjectClassEditor ) getEditor() ).getOriginalObjectClass();
-        originalSchema = schemaHandler.getSchema( originalObjectClass.getSchemaName() );
+        ObjectClass modifiedObjectClass = getModifiedObjectClass();
+        originalSchema = schemaHandler.getSchema( getOriginalObjectClass().getSchemaName() );
 
         // ALIASES Label
         if ( ( modifiedObjectClass.getNames() != null ) && ( modifiedObjectClass.getNames().size() != 0 ) )
@@ -1111,9 +1117,9 @@ public class ObjectClassEditorOverviewPa
      */
     private void fillInSuperiorsTable()
     {
-        if ( modifiedObjectClass.getSuperiorOids() != null )
+        if ( getModifiedObjectClass().getSuperiorOids() != null )
         {
-            superiorsTableViewer.setInput( modifiedObjectClass.getSuperiorOids() );
+            superiorsTableViewer.setInput( getModifiedObjectClass().getSuperiorOids() );
         }
     }
 
@@ -1134,17 +1140,19 @@ public class ObjectClassEditorOverviewPa
      */
     private void fillInClassType()
     {
-        if ( modifiedObjectClass.getType() == ObjectClassTypeEnum.ABSTRACT )
-        {
-            classTypeCombo.select( 0 );
-        }
-        else if ( modifiedObjectClass.getType() == ObjectClassTypeEnum.AUXILIARY )
-        {
-            classTypeCombo.select( 1 );
-        }
-        else if ( modifiedObjectClass.getType() == ObjectClassTypeEnum.STRUCTURAL )
+        ObjectClassTypeEnum type = getModifiedObjectClass().getType();
+
+        switch ( type )
         {
-            classTypeCombo.select( 2 );
+            case ABSTRACT:
+                classTypeCombo.select( 0 );
+                return;
+            case AUXILIARY:
+                classTypeCombo.select( 1 );
+                return;
+            case STRUCTURAL:
+                classTypeCombo.select( 2 );
+                return;
         }
     }
 
@@ -1154,9 +1162,9 @@ public class ObjectClassEditorOverviewPa
      */
     private void fillInMandatoryAttributesTable()
     {
-        if ( modifiedObjectClass.getMustAttributeTypeOids() != null )
+        if ( getModifiedObjectClass().getMustAttributeTypeOids() != null )
         {
-            mandatoryAttributesTableViewer.setInput( modifiedObjectClass.getMustAttributeTypeOids() );
+            mandatoryAttributesTableViewer.setInput( getModifiedObjectClass().getMustAttributeTypeOids() );
         }
     }
 
@@ -1166,17 +1174,17 @@ public class ObjectClassEditorOverviewPa
      */
     private void fillInOptionalAttributesTable()
     {
-        if ( modifiedObjectClass.getMayAttributeTypeOids() != null )
+        if ( getModifiedObjectClass().getMayAttributeTypeOids() != null )
         {
-            optionalAttributesTableViewer.setInput( modifiedObjectClass.getMayAttributeTypeOids() );
+            optionalAttributesTableViewer.setInput( getModifiedObjectClass().getMayAttributeTypeOids() );
         }
     }
 
 
     /**
-     * Adds listeners to UI fields
+     * {@inheritDoc}
      */
-    private void addListeners()
+    protected void addListeners()
     {
         aliasesText.addModifyListener( aliasesTextModifyListener );
         aliasesButton.addSelectionListener( aliasesButtonListener );
@@ -1201,9 +1209,9 @@ public class ObjectClassEditorOverviewPa
 
 
     /**
-     * Removes listeners from UI fields
+     * {@inheritDoc}
      */
-    private void removeListeners()
+    protected void removeListeners()
     {
         aliasesText.removeModifyListener( aliasesTextModifyListener );
         aliasesButton.removeSelectionListener( aliasesButtonListener );
@@ -1228,34 +1236,12 @@ public class ObjectClassEditorOverviewPa
 
 
     /**
-     * Sets the editor as dirty
-     */
-    private void setEditorDirty()
-    {
-        ( ( ObjectClassEditor ) getEditor() ).setDirty( true );
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public void dispose()
     {
-        removeListeners();
-
         schemaHandler.removeListener( schemaHandlerListener );
 
         super.dispose();
     }
-
-
-    /**
-     * Refreshes the UI.
-     */
-    public void refreshUI()
-    {
-        removeListeners();
-        fillInUiFields();
-        addListeners();
-    }
 }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorSourceCodePage.java?rev=1220833&r1=1220832&r2=1220833&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorSourceCodePage.java (original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/objectclass/ObjectClassEditorSourceCodePage.java Mon Dec 19 16:33:23 2011
@@ -41,8 +41,6 @@ import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 
@@ -50,17 +48,11 @@ import org.eclipse.ui.forms.widgets.Scro
 /**
  * This class is the Source Code Page of the Object Class Editor
  */
-public class ObjectClassEditorSourceCodePage extends FormPage
+public class ObjectClassEditorSourceCodePage extends AbstractObjectClassEditorPage
 {
     /** The page ID */
     public static final String ID = ObjectClassEditor.ID + "sourceCodePage"; //$NON-NLS-1$
 
-    /** The flag to indicate if the page has been initialized */
-    private boolean initialized = false;
-
-    /** The modified object class */
-    private ObjectClass modifiedObjectClass;
-
     /** The Schema Source Viewer */
     private SchemaSourceViewer schemaSourceViewer;
 
@@ -102,11 +94,11 @@ public class ObjectClassEditorSourceCode
 
 
     /**
-     * Default constructor
-     * @param editor
-     *      the associated editor
+     * Default constructor.
+     * 
+     * @param editor the associated editor
      */
-    public ObjectClassEditorSourceCodePage( FormEditor editor )
+    public ObjectClassEditorSourceCodePage( ObjectClassEditor editor )
     {
         super( editor, ID, Messages.getString( "ObjectClassEditorSourceCodePage.SourceCode" ) ); //$NON-NLS-1$
     }
@@ -117,6 +109,8 @@ public class ObjectClassEditorSourceCode
      */
     protected void createFormContent( IManagedForm managedForm )
     {
+        super.createFormContent( managedForm );
+
         ScrolledForm form = managedForm.getForm();
         FormToolkit toolkit = managedForm.getToolkit();
         GridLayout layout = new GridLayout();
@@ -141,46 +135,40 @@ public class ObjectClassEditorSourceCode
 
         // Initialization from the "input" object class
         fillInUiFields();
-        
+
         // Listeners initialization
         addListeners();
 
         // Help Context for Dynamic Help
         PlatformUI.getWorkbench().getHelpSystem().setHelp( form,
             PluginConstants.PLUGIN_ID + "." + "object_class_editor" ); //$NON-NLS-1$ //$NON-NLS-2$
-
-        initialized = true;
     }
 
 
     /**
-     * Adds listeners to UI fields
+     * {@inheritDoc}
      */
-    private void addListeners()
+    protected void addListeners()
     {
         schemaSourceViewer.getTextWidget().addModifyListener( schemaSourceViewerListener );
     }
 
 
     /**
-     * Adds listeners to UI fields
+     * {@inheritDoc}
      */
-    private void removeListeners()
+    protected void removeListeners()
     {
         schemaSourceViewer.getTextWidget().removeModifyListener( schemaSourceViewerListener );
     }
 
 
     /**
-     * Fills in the User Interface.
+     * {@inheritDoc}
      */
-    private void fillInUiFields()
+    protected void fillInUiFields()
     {
-        // Getting the modified object class
-        modifiedObjectClass = ( ( ObjectClassEditor ) getEditor() ).getModifiedObjectClass();
-
-        // SOURCE CODE Field
-        schemaSourceViewer.getDocument().set( OpenLdapSchemaFileExporter.toSourceCode( modifiedObjectClass ) );
+        schemaSourceViewer.getDocument().set( OpenLdapSchemaFileExporter.toSourceCode( getModifiedObjectClass() ) );
     }
 
 
@@ -201,6 +189,8 @@ public class ObjectClassEditorSourceCode
      */
     private void updateObjectClass( ObjectClass ocl )
     {
+        ObjectClass modifiedObjectClass = getModifiedObjectClass();
+
         modifiedObjectClass.setDescription( ocl.getDescription() );
         modifiedObjectClass.setMayAttributeTypeOids( ocl.getMayAttributeTypeOids() );
         modifiedObjectClass.setMustAttributeTypeOids( ocl.getMustAttributeTypeOids() );
@@ -210,29 +200,4 @@ public class ObjectClassEditorSourceCode
         modifiedObjectClass.setSuperiorOids( ocl.getSuperiorOids() );
         modifiedObjectClass.setType( ocl.getType() );
     }
-
-
-    /**
-     * Refreshes the UI.
-     */
-    public void refreshUI()
-    {
-        if ( initialized )
-        {
-            removeListeners();
-            fillInUiFields();
-            addListeners();
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void dispose()
-    {
-        removeListeners();
-
-        super.dispose();
-    }
 }



Mime
View raw message