directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r558811 - /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ProblemsViewController.java
Date Mon, 23 Jul 2007 17:42:10 GMT
Author: pamarcelot
Date: Mon Jul 23 10:42:09 2007
New Revision: 558811

URL: http://svn.apache.org/viewvc?view=rev&rev=558811
Log:
Added ProjectHandlerListener to the ProblemsViewController.

Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ProblemsViewController.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ProblemsViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ProblemsViewController.java?view=diff&rev=558811&r1=558810&r2=558811
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ProblemsViewController.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/ProblemsViewController.java
Mon Jul 23 10:42:09 2007
@@ -24,6 +24,7 @@
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
 import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
 import org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.SchemaChecker;
 import org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.SchemaCheckerListener;
 import org.apache.directory.studio.apacheds.schemaeditor.view.editors.attributetype.AttributeTypeEditor;
@@ -56,6 +57,21 @@
     /** The associated view */
     private ProblemsView view;
 
+    /** The SchemaCheckerListener */
+    private SchemaCheckerListener schemaCheckerListener = new SchemaCheckerListener()
+    {
+        public void schemaCheckerUpdated()
+        {
+            Display.getDefault().asyncExec( new Runnable()
+            {
+                public void run()
+                {
+                    view.reloadViewer();
+                }
+            } );
+        }
+    };
+
 
     // The Actions
 
@@ -71,6 +87,7 @@
 
         initActions();
         initToolbar();
+        initProjectsHandlerListener();
         initDoubleClickListener();
         initSchemaCheckerListener();
     }
@@ -90,6 +107,66 @@
     private void initToolbar()
     {
         //        IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
+    }
+
+
+    /**
+     * Initializes the ProjectsHandlerListener.
+     */
+    private void initProjectsHandlerListener()
+    {
+        Activator.getDefault().getProjectsHandler().addListener( new ProjectsHandlerAdapter()
+        {
+            public void openProjectChanged( Project oldProject, Project newProject )
+            {
+                if ( oldProject != null )
+                {
+                    removeSchemaCheckerListener( oldProject );
+                }
+
+                if ( newProject != null )
+                {
+                    addSchemaCheckerListener( newProject );
+                    view.reloadViewer();
+                }
+                else
+                {
+                    view.getViewer().setInput( null );
+                }
+            }
+        } );
+    }
+
+
+    /**
+     * Adds the SchemaCheckerListener.
+     *
+     * @param project
+     *      the project
+     */
+    private void addSchemaCheckerListener( Project project )
+    {
+        SchemaChecker schemaChecker = project.getSchemaChecker();
+        if ( schemaChecker != null )
+        {
+            schemaChecker.addListener( schemaCheckerListener );
+        }
+    }
+
+
+    /**
+     * Removes the SchemaCheckerListener.
+     *
+     * @param project
+     *      the project
+     */
+    private void removeSchemaCheckerListener( Project project )
+    {
+        SchemaChecker schemaChecker = project.getSchemaChecker();
+        if ( schemaChecker != null )
+        {
+            schemaChecker.removeListener( schemaCheckerListener );
+        }
     }
 
 



Mime
View raw message