directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r505252 [2/2] - /directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/
Date Fri, 09 Feb 2007 11:26:31 GMT
Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java?view=diff&rev=505252&r1=505251&r2=505252
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorSourceCodePage.java
Fri Feb  9 03:26:30 2007
@@ -25,10 +25,7 @@
 import java.text.ParseException;
 import java.util.List;
 
-import org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent;
 import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
-import org.apache.directory.ldapstudio.schemas.model.SchemaElement;
-import org.apache.directory.ldapstudio.schemas.model.SchemaElementListener;
 import org.apache.directory.ldapstudio.schemas.model.Schema.SchemaType;
 import org.apache.directory.ldapstudio.schemas.view.viewers.SchemaSourceViewer;
 import org.apache.directory.server.core.tools.schema.ObjectClassLiteral;
@@ -52,10 +49,10 @@
 /**
  * This class is the Source Code Page of the Object Class Editor
  */
-public class ObjectClassFormEditorSourceCodePage extends FormPage implements SchemaElementListener
+public class ObjectClassFormEditorSourceCodePage extends FormPage
 {
     /** The page ID */
-    public static final String ID = "org.apache.directory.ldapstudio.schemas.view.editors.ObjectClassEditorSourceCodePage";
+    public static final String ID = ObjectClassFormEditor.ID + "sourceCodePage";
 
     /** The page title*/
     public static final String TITLE = Messages.getString( "ObjectClassFormEditor.Source_Code"
);
@@ -69,6 +66,39 @@
     /** The flag to indicate if the user can leave the Source Code page */
     private boolean canLeaveThePage = true;
 
+    /** The listener of the Schema Source Viewer Widget */
+    private ModifyListener schemaSourceViewerListener = new ModifyListener()
+    {
+        public void modifyText( ModifyEvent e )
+        {
+            canLeaveThePage = true;
+            try
+            {
+                ( ( ObjectClassFormEditor ) getEditor() ).setDirty( true );
+                OpenLdapSchemaParser parser = new OpenLdapSchemaParser();
+                parser.parse( schemaSourceViewer.getTextWidget().getText() );
+
+                List objectclasses = parser.getObjectClassTypes();
+                if ( objectclasses.size() != 1 )
+                {
+                    // TODO Throw an exception and return
+                }
+                else
+                {
+                    updateObjectClass( ( ObjectClassLiteral ) objectclasses.get( 0 ) );
+                }
+            }
+            catch ( IOException e1 )
+            {
+                canLeaveThePage = false;
+            }
+            catch ( ParseException exception )
+            {
+                canLeaveThePage = false;
+            }
+        }
+    };
+
 
     /**
      * Default constructor
@@ -95,7 +125,6 @@
         toolkit.paintBordersFor( form.getBody() );
 
         modifiedObjectClass = ( ( ObjectClassFormEditor ) getEditor() ).getModifiedObjectClass();
-        modifiedObjectClass.addListener( this );
 
         // SOURCE CODE Field
         schemaSourceViewer = new SchemaSourceViewer( form.getBody(), null, null, false, SWT.BORDER
| SWT.H_SCROLL
@@ -107,39 +136,6 @@
         {
             schemaSourceViewer.setEditable( false );
         }
-        schemaSourceViewer.getTextWidget().addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent e )
-            {
-                canLeaveThePage = true;
-                try
-                {
-                    ( ( ObjectClassFormEditor ) getEditor() ).setDirty( true );
-                    OpenLdapSchemaParser parser = new OpenLdapSchemaParser();
-                    parser.parse( schemaSourceViewer.getTextWidget().getText() );
-
-                    List objectclasses = parser.getObjectClassTypes();
-                    if ( objectclasses.size() != 1 )
-                    {
-                        // Throw an exception and return
-                    }
-                    else
-                    {
-                        updateObjectClass( ( ObjectClassLiteral ) objectclasses.get( 0 )
);
-                    }
-                }
-                catch ( IOException e1 )
-                {
-                    canLeaveThePage = false;
-                }
-                catch ( ParseException exception )
-                {
-                    canLeaveThePage = false;
-                    System.err.println( exception.getMessage() );
-                }
-            }
-        } );
-        //toolkit.createLabel( form.getBody(), "" );
 
         // set text font
         Font font = JFaceResources.getFont( JFaceResources.TEXT_FONT );
@@ -147,10 +143,11 @@
 
         IDocument document = new Document();
         schemaSourceViewer.setDocument( document );
-        schemaSourceViewer.getAnnotationModel().connect( document );
 
         // Initialization from the "input" object class
         fillInUiFields();
+
+        schemaSourceViewer.getTextWidget().addModifyListener( schemaSourceViewerListener
);
     }
 
 
@@ -173,17 +170,6 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.ldapstudio.schemas.model.SchemaElementListener#schemaElementChanged(org.apache.directory.ldapstudio.schemas.model.SchemaElement,
org.apache.directory.ldapstudio.schemas.model.LDAPModelEvent)
-     */
-    public void schemaElementChanged( SchemaElement originatingSchemaElement, LDAPModelEvent
e )
-    {
-        modifiedObjectClass.removeListener( this );
-        fillInUiFields();
-        modifiedObjectClass.addListener( this );
-    }
-
-
     /**
      * Updates the Modified Object Class from the given Object Class Literal.
      *
@@ -192,7 +178,6 @@
      */
     private void updateObjectClass( ObjectClassLiteral ocl )
     {
-        modifiedObjectClass.removeListener( this );
         modifiedObjectClass.setClassType( ocl.getClassType() );
         modifiedObjectClass.setDescription( ocl.getDescription() );
         modifiedObjectClass.setMay( ocl.getMay() );
@@ -201,6 +186,14 @@
         modifiedObjectClass.setObsolete( ocl.isObsolete() );
         modifiedObjectClass.setOid( ocl.getOid() );
         modifiedObjectClass.setSuperiors( ocl.getSuperiors() );
-        modifiedObjectClass.addListener( this );
+    }
+
+
+    /**
+     * Refreshes the UI.
+     */
+    public void refreshUI()
+    {
+        fillInUiFields();
     }
 }



Mime
View raw message