directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1213770 [2/2] - in /directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor: controller/ controller/actions/ model/schemachecker/ view/dialogs/ view/editors/ view/editors/attributetype/ view/edito...
Date Tue, 13 Dec 2011 16:29:44 GMT
Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorOverviewPage.java?rev=1213770&r1=1213769&r2=1213770&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorOverviewPage.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorOverviewPage.java
Tue Dec 13 16:29:43 2011
@@ -22,13 +22,14 @@ package org.apache.directory.studio.sche
 
 
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.model.schema.MatchingRule;
 import org.apache.directory.shared.ldap.model.schema.ObjectClass;
 import org.apache.directory.studio.schemaeditor.Activator;
 import org.apache.directory.studio.schemaeditor.PluginConstants;
 import org.apache.directory.studio.schemaeditor.PluginUtils;
-import org.apache.directory.studio.schemaeditor.controller.SchemaAdapter;
-import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
-import org.apache.directory.studio.schemaeditor.controller.SchemaListener;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerAdapter;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 import org.apache.directory.studio.schemaeditor.view.ViewUtils;
 import org.apache.directory.studio.schemaeditor.view.editors.attributetype.AttributeTypeEditor;
@@ -64,70 +65,108 @@ public class SchemaEditorOverviewPage ex
     /** The page ID */
     public static final String ID = SchemaEditor.ID + "overviewPage"; //$NON-NLS-1$
 
-    /** The SchemaHandler */
-    private SchemaHandler schemaHandler;
-
     /** The associated schema */
-    private Schema schema;
+    private Schema originalSchema;
 
-    private SchemaListener schemaListener = new SchemaAdapter()
+    private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerAdapter()
     {
-        /**
-         * {@inheritDoc}
-         */
         public void attributeTypeAdded( AttributeType at )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
-        /**
-         * {@inheritDoc}
-         */
         public void attributeTypeModified( AttributeType at )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
-        /**
-         * {@inheritDoc}
-         */
         public void attributeTypeRemoved( AttributeType at )
         {
-            fillInUiFields();
+            refreshUI();
+        }
+
+
+        public void matchingRuleAdded( MatchingRule mr )
+        {
+            refreshUI();
+        }
+
+
+        public void matchingRuleModified( MatchingRule mr )
+        {
+            refreshUI();
+        }
+
+
+        public void matchingRuleRemoved( MatchingRule mr )
+        {
+            refreshUI();
         }
 
 
-        /**
-         * {@inheritDoc}
-         */
         public void objectClassAdded( ObjectClass oc )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
-        /**
-         * {@inheritDoc}
-         */
         public void objectClassModified( ObjectClass oc )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
-        /**
-         * {@inheritDoc}
-         */
         public void objectClassRemoved( ObjectClass oc )
         {
-            fillInUiFields();
+            refreshUI();
+        }
+
+
+        public void schemaAdded( Schema schema )
+        {
+            refreshUI();
+        }
+
+
+        public void schemaRemoved( Schema schema )
+        {
+            if ( !schema.equals( originalSchema ) )
+            {
+                refreshUI();
+            }
+        }
+
+
+        public void schemaRenamed( Schema schema )
+        {
+            refreshUI();
+        }
+
+
+        public void syntaxAdded( LdapSyntax syntax )
+        {
+            refreshUI();
+        }
+
+
+        public void syntaxModified( LdapSyntax syntax )
+        {
+            refreshUI();
+        }
+
+
+        public void syntaxRemoved( LdapSyntax syntax )
+        {
+            refreshUI();
         }
     };
 
     // UI Fields
+    private Section attributeTypesSection;
     private TableViewer attributeTypesTableViewer;
+    private Section objectClassesSection;
     private TableViewer objectClassesTableViewer;
 
     // Listeners
@@ -153,8 +192,9 @@ public class SchemaEditorOverviewPage ex
                 catch ( PartInitException exception )
                 {
                     PluginUtils.logError( Messages.getString( "SchemaEditorOverviewPage.ErrorOpenEditor"
), exception ); //$NON-NLS-1$
-                    ViewUtils.displayErrorMessageDialog( Messages.getString( "SchemaEditorOverviewPage.Error"
), Messages //$NON-NLS-1$
-                        .getString( "SchemaEditorOverviewPage.ErrorOpenEditor" ) ); //$NON-NLS-1$
+                    ViewUtils.displayErrorMessageDialog(
+                        Messages.getString( "SchemaEditorOverviewPage.Error" ), Messages
//$NON-NLS-1$
+                            .getString( "SchemaEditorOverviewPage.ErrorOpenEditor" ) ); //$NON-NLS-1$
                 }
             }
         }
@@ -182,14 +222,16 @@ public class SchemaEditorOverviewPage ex
                 catch ( PartInitException exception )
                 {
                     PluginUtils.logError( Messages.getString( "SchemaEditorOverviewPage.ErrorOpenEditor"
), exception ); //$NON-NLS-1$
-                    ViewUtils.displayErrorMessageDialog( Messages.getString( "SchemaEditorOverviewPage.Error"
), Messages //$NON-NLS-1$
-                        .getString( "SchemaEditorOverviewPage.ErrorOpenEditor" ) ); //$NON-NLS-1$
+                    ViewUtils.displayErrorMessageDialog(
+                        Messages.getString( "SchemaEditorOverviewPage.Error" ), Messages
//$NON-NLS-1$
+                            .getString( "SchemaEditorOverviewPage.ErrorOpenEditor" ) ); //$NON-NLS-1$
                 }
             }
         }
     };
 
 
+
     /**
      * Creates a new instance of SchemaFormEditorOverviewPage.
      *
@@ -199,7 +241,7 @@ public class SchemaEditorOverviewPage ex
     public SchemaEditorOverviewPage( FormEditor editor )
     {
         super( editor, ID, Messages.getString( "SchemaEditorOverviewPage.Overview" ) ); //$NON-NLS-1$
-        schemaHandler = Activator.getDefault().getSchemaHandler();
+        Activator.getDefault().getSchemaHandler().addListener( schemaHandlerListener );
     }
 
 
@@ -209,7 +251,7 @@ public class SchemaEditorOverviewPage ex
     protected void createFormContent( IManagedForm managedForm )
     {
         // Getting the associated schema
-        schema = ( ( SchemaEditor ) getEditor() ).getSchema();
+        originalSchema = ( ( SchemaEditor ) getEditor() ).getSchema();
 
         // Creating the base UI
         ScrolledForm form = managedForm.getForm();
@@ -243,11 +285,9 @@ public class SchemaEditorOverviewPage ex
     private void createAttributeTypesSection( Composite parent, FormToolkit toolkit )
     {
         // Attribute Types Section
-        Section attributeTypesSection = toolkit.createSection( parent, Section.DESCRIPTION
| Section.EXPANDED
+        attributeTypesSection = toolkit.createSection( parent, Section.DESCRIPTION | Section.EXPANDED
             | Section.TITLE_BAR );
-        attributeTypesSection.setDescription( NLS.bind(
-            Messages.getString( "SchemaEditorOverviewPage.SchemaAttribute" ), new String[]
//$NON-NLS-1$
-            { schema.getSchemaName() } ) );
+        attributeTypesSection.setDescription( "" ); //$NON-NLS-1$
         attributeTypesSection.setText( Messages.getString( "SchemaEditorOverviewPage.AttributeTypes"
) ); //$NON-NLS-1$
 
         // Creating the layout of the section
@@ -276,11 +316,9 @@ public class SchemaEditorOverviewPage ex
     private void createObjectClassesSection( Composite parent, FormToolkit toolkit )
     {
         // Attribute Types Section
-        Section objectClassesSection = toolkit.createSection( parent, Section.DESCRIPTION
| Section.EXPANDED
+        objectClassesSection = toolkit.createSection( parent, Section.DESCRIPTION | Section.EXPANDED
             | Section.TITLE_BAR );
-        objectClassesSection.setDescription( NLS.bind( Messages
-            .getString( "SchemaEditorOverviewPage.SchemaObjectClasses" ), new String[] //$NON-NLS-1$
-            { schema.getSchemaName() } ) );
+        objectClassesSection.setDescription( "" );//$NON-NLS-1$
         objectClassesSection.setText( Messages.getString( "SchemaEditorOverviewPage.ObjectClasses"
) ); //$NON-NLS-1$
 
         // Creating the layout of the section
@@ -303,8 +341,14 @@ public class SchemaEditorOverviewPage ex
      */
     private void fillInUiFields()
     {
-        attributeTypesTableViewer.setInput( schema.getAttributeTypes() );
-        objectClassesTableViewer.setInput( schema.getObjectClasses() );
+        attributeTypesSection.setDescription( NLS.bind(
+            Messages.getString( "SchemaEditorOverviewPage.SchemaAttribute" ), new String[]
//$NON-NLS-1$
+            { originalSchema.getSchemaName() } ) );
+        objectClassesSection.setDescription( NLS.bind( Messages
+            .getString( "SchemaEditorOverviewPage.SchemaObjectClasses" ), new String[] //$NON-NLS-1$
+            { originalSchema.getSchemaName() } ) );
+        attributeTypesTableViewer.setInput( originalSchema.getAttributeTypes() );
+        objectClassesTableViewer.setInput( originalSchema.getObjectClasses() );
     }
 
 
@@ -313,7 +357,6 @@ public class SchemaEditorOverviewPage ex
      */
     private void addListeners()
     {
-        schemaHandler.addListener( schema, schemaListener );
         attributeTypesTableViewer.addDoubleClickListener( attributeTypesTableViewerListener
);
         objectClassesTableViewer.addDoubleClickListener( objectClassesTableViewerListener
);
     }
@@ -324,7 +367,6 @@ public class SchemaEditorOverviewPage ex
      */
     private void removeListeners()
     {
-        schemaHandler.removeListener( schema, schemaListener );
         attributeTypesTableViewer.removeDoubleClickListener( attributeTypesTableViewerListener
);
         objectClassesTableViewer.removeDoubleClickListener( objectClassesTableViewerListener
);
     }
@@ -337,6 +379,19 @@ public class SchemaEditorOverviewPage ex
     {
         removeListeners();
 
+        Activator.getDefault().getSchemaHandler().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/schema/SchemaEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java?rev=1213770&r1=1213769&r2=1213770&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java
Tue Dec 13 16:29:43 2011
@@ -27,7 +27,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.schema.ObjectClass;
 import org.apache.directory.studio.schemaeditor.Activator;
 import org.apache.directory.studio.schemaeditor.PluginConstants;
-import org.apache.directory.studio.schemaeditor.controller.SchemaListener;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerAdapter;
+import org.apache.directory.studio.schemaeditor.controller.SchemaHandlerListener;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 import org.apache.directory.studio.schemaeditor.model.io.OpenLdapSchemaFileExporter;
 import org.apache.directory.studio.schemaeditor.view.widget.SchemaSourceViewer;
@@ -56,6 +57,9 @@ public class SchemaEditorSourceCodePage 
     /** The page ID */
     public static final String ID = SchemaEditor.ID + "sourceCode"; //$NON-NLS-1$
 
+    /** The flag to indicate if the page has been initialized */
+    private boolean initialized = false;
+
     /** The associated schema */
     private Schema schema;
 
@@ -63,14 +67,14 @@ public class SchemaEditorSourceCodePage 
     private SchemaSourceViewer schemaSourceViewer;
 
     // Listerner
-    private SchemaListener schemaListener = new SchemaListener()
+    private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerAdapter()
     {
         /**
          * {@inheritDoc}
          */
         public void attributeTypeAdded( AttributeType at )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -79,7 +83,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void attributeTypeModified( AttributeType at )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -88,7 +92,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void attributeTypeRemoved( AttributeType at )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -97,7 +101,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void matchingRuleAdded( MatchingRule mr )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -106,7 +110,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void matchingRuleModified( MatchingRule mr )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -115,7 +119,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void matchingRuleRemoved( MatchingRule mr )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -124,7 +128,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void objectClassAdded( ObjectClass oc )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -133,7 +137,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void objectClassModified( ObjectClass oc )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -142,7 +146,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void objectClassRemoved( ObjectClass oc )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -151,7 +155,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void syntaxAdded( LdapSyntax syntax )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -160,7 +164,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void syntaxModified( LdapSyntax syntax )
         {
-            fillInUiFields();
+            refreshUI();
         }
 
 
@@ -169,7 +173,7 @@ public class SchemaEditorSourceCodePage 
          */
         public void syntaxRemoved( LdapSyntax syntax )
         {
-            fillInUiFields();
+            refreshUI();
         }
     };
 
@@ -183,6 +187,7 @@ public class SchemaEditorSourceCodePage 
     public SchemaEditorSourceCodePage( FormEditor editor )
     {
         super( editor, ID, Messages.getString( "SchemaEditorSourceCodePage.SourceCode" )
); //$NON-NLS-1$
+        Activator.getDefault().getSchemaHandler().addListener( schemaHandlerListener );
     }
 
 
@@ -217,10 +222,10 @@ public class SchemaEditorSourceCodePage 
         // Initializes the UI from the schema
         fillInUiFields();
 
-        addListeners();
-
         // Help Context for Dynamic Help
         PlatformUI.getWorkbench().getHelpSystem().setHelp( form, PluginConstants.PLUGIN_ID
+ "." + "schema_editor" ); //$NON-NLS-1$ //$NON-NLS-2$
+  
+        initialized = true;
     }
 
 
@@ -234,30 +239,24 @@ public class SchemaEditorSourceCodePage 
 
 
     /**
-     * Adds the listeners.
+     * {@inheritDoc}
      */
-    private void addListeners()
+    public void dispose()
     {
-        Activator.getDefault().getSchemaHandler().addListener( schema, schemaListener );
-    }
+        Activator.getDefault().getSchemaHandler().removeListener( schemaHandlerListener );
 
-
-    /**
-     * Removes the listeners.
-     */
-    private void removeListeners()
-    {
-        Activator.getDefault().getSchemaHandler().removeListener( schema, schemaListener
);
+        super.dispose();
     }
 
 
     /**
-     * {@inheritDoc}
+     * Refreshes the UI.
      */
-    public void dispose()
+    public void refreshUI()
     {
-        removeListeners();
-
-        super.dispose();
+        if ( initialized )
+        {
+            fillInUiFields();
+        }
     }
 }



Mime
View raw message