directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r561852 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor: controller/ controller/actions/ view/ view/views/
Date Wed, 01 Aug 2007 16:10:44 GMT
Author: pamarcelot
Date: Wed Aug  1 09:10:40 2007
New Revision: 561852

URL: http://svn.apache.org/viewvc?view=rev&rev=561852
Log:
Fixed the state of the Hierarchy View when opened while a project is already opened.
Update the OpenTypeHierarchyAction to open the HierarchyView if it's not already opened.
Fixed the state of the SchemaView when opened for the first time.
Added a link to open the Hierarchy View in the Perspective.

Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/HierarchyViewController.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenTypeHierarchyAction.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/Perspective.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyView.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/HierarchyViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/HierarchyViewController.java?view=diff&rev=561852&r1=561851&r2=561852
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/HierarchyViewController.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/HierarchyViewController.java
Wed Aug  1 09:10:40 2007
@@ -67,6 +67,84 @@
     /** The authorized Preferences keys*/
     List<String> authorizedPrefs;
 
+    /** The ProjectsHandlerListener */
+    private ProjectsHandlerListener projectsHandlerListener = new ProjectsHandlerAdapter()
+    {
+        public void openProjectChanged( Project oldProject, Project newProject )
+        {
+            if ( newProject != null )
+            {
+                view.getViewer().getTree().setEnabled( true );
+                showSupertypeHierarchy.setEnabled( true );
+                showSubtypeHierarchy.setEnabled( true );
+                linkWithEditor.setEnabled( true );
+                openPreferencePage.setEnabled( true );
+            }
+            else
+            {
+                view.setInput( null );
+                view.getViewer().getTree().setEnabled( false );
+                showSupertypeHierarchy.setEnabled( false );
+                showSubtypeHierarchy.setEnabled( false );
+                linkWithEditor.setEnabled( false );
+                openPreferencePage.setEnabled( false );
+            }
+        }
+    };
+
+    /** The IDoubleClickListener */
+    private IDoubleClickListener doubleClickListener = new IDoubleClickListener()
+    {
+        public void doubleClick( DoubleClickEvent event )
+        {
+            // What we get from the treeViewer is a StructuredSelection
+            StructuredSelection selection = ( StructuredSelection ) event.getSelection();
+
+            // Here's the real object (an AttributeTypeWrapper, ObjectClassWrapper or IntermediateNode)
+            Object objectSelection = selection.getFirstElement();
+            IEditorInput input = null;
+            String editorId = null;
+
+            // Selecting the right editor and input
+            if ( objectSelection instanceof AttributeTypeWrapper )
+            {
+                input = new AttributeTypeEditorInput( ( ( AttributeTypeWrapper ) objectSelection
).getAttributeType() );
+                editorId = AttributeTypeEditor.ID;
+            }
+            else if ( objectSelection instanceof ObjectClassWrapper )
+            {
+                input = new ObjectClassEditorInput( ( ( ObjectClassWrapper ) objectSelection
).getObjectClass() );
+                editorId = ObjectClassEditor.ID;
+            }
+
+            // Let's open the editor
+            if ( input != null )
+            {
+                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                try
+                {
+                    page.openEditor( input, editorId );
+                }
+                catch ( PartInitException e )
+                {
+                    // TODO ADD A LOGGER
+                }
+            }
+        }
+    };
+
+    /** The IPropertyChangeListener */
+    private IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener()
+    {
+        public void propertyChange( PropertyChangeEvent event )
+        {
+            if ( authorizedPrefs.contains( event.getProperty() ) )
+            {
+                view.refresh();
+            }
+        }
+    };
+
     // The Actions
     private Action showSupertypeHierarchy;
     private Action showSubtypeHierarchy;
@@ -91,6 +169,7 @@
         initProjectsHandlerListener();
         initDoubleClickListener();
         initPreferencesListener();
+        initState();
     }
 
 
@@ -161,29 +240,7 @@
      */
     private void initProjectsHandlerListener()
     {
-        Activator.getDefault().getProjectsHandler().addListener( new ProjectsHandlerAdapter()
-        {
-            public void openProjectChanged( Project oldProject, Project newProject )
-            {
-                if ( newProject != null )
-                {
-                    view.getViewer().getTree().setEnabled( true );
-                    showSupertypeHierarchy.setEnabled( true );
-                    showSubtypeHierarchy.setEnabled( true );
-                    linkWithEditor.setEnabled( true );
-                    openPreferencePage.setEnabled( true );
-                }
-                else
-                {
-                    view.setInput( null );
-                    view.getViewer().getTree().setEnabled( false );
-                    showSupertypeHierarchy.setEnabled( false );
-                    showSubtypeHierarchy.setEnabled( false );
-                    linkWithEditor.setEnabled( false );
-                    openPreferencePage.setEnabled( false );
-                }
-            }
-        } );
+        Activator.getDefault().getProjectsHandler().addListener( projectsHandlerListener
);
     }
 
 
@@ -192,46 +249,7 @@
      */
     private void initDoubleClickListener()
     {
-        view.getViewer().addDoubleClickListener( new IDoubleClickListener()
-        {
-            public void doubleClick( DoubleClickEvent event )
-            {
-                // What we get from the treeViewer is a StructuredSelection
-                StructuredSelection selection = ( StructuredSelection ) event.getSelection();
-
-                // Here's the real object (an AttributeTypeWrapper, ObjectClassWrapper or
IntermediateNode)
-                Object objectSelection = selection.getFirstElement();
-                IEditorInput input = null;
-                String editorId = null;
-
-                // Selecting the right editor and input
-                if ( objectSelection instanceof AttributeTypeWrapper )
-                {
-                    input = new AttributeTypeEditorInput( ( ( AttributeTypeWrapper ) objectSelection
)
-                        .getAttributeType() );
-                    editorId = AttributeTypeEditor.ID;
-                }
-                else if ( objectSelection instanceof ObjectClassWrapper )
-                {
-                    input = new ObjectClassEditorInput( ( ( ObjectClassWrapper ) objectSelection
).getObjectClass() );
-                    editorId = ObjectClassEditor.ID;
-                }
-
-                // Let's open the editor
-                if ( input != null )
-                {
-                    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-                    try
-                    {
-                        page.openEditor( input, editorId );
-                    }
-                    catch ( PartInitException e )
-                    {
-                        // TODO ADD A LOGGER
-                    }
-                }
-            }
-        } );
+        view.getViewer().addDoubleClickListener( doubleClickListener );
     }
 
 
@@ -240,18 +258,41 @@
      */
     private void initPreferencesListener()
     {
-        Activator.getDefault().getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener()
+        Activator.getDefault().getPreferenceStore().addPropertyChangeListener( propertyChangeListener
);
+    }
+
+
+    /**
+     * Initializes the state of the View.
+     */
+    private void initState()
+    {
+        if ( Activator.getDefault().getProjectsHandler().getOpenProject() != null )
         {
-            /* (non-Javadoc)
-             * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
-             */
-            public void propertyChange( PropertyChangeEvent event )
-            {
-                if ( authorizedPrefs.contains( event.getProperty() ) )
-                {
-                    view.refresh();
-                }
-            }
-        } );
+            view.getViewer().getTree().setEnabled( true );
+            showSupertypeHierarchy.setEnabled( true );
+            showSubtypeHierarchy.setEnabled( true );
+            linkWithEditor.setEnabled( true );
+            openPreferencePage.setEnabled( true );
+        }
+        else
+        {
+            view.getViewer().getTree().setEnabled( false );
+            showSupertypeHierarchy.setEnabled( false );
+            showSubtypeHierarchy.setEnabled( false );
+            linkWithEditor.setEnabled( false );
+            openPreferencePage.setEnabled( false );
+        }
+    }
+
+
+    /**
+     * This method is called when the view is disposed.
+     */
+    public void dispose()
+    {
+        Activator.getDefault().getProjectsHandler().removeListener( projectsHandlerListener
);
+        view.getViewer().removeDoubleClickListener( doubleClickListener );
+        Activator.getDefault().getPreferenceStore().removePropertyChangeListener( propertyChangeListener
);
     }
 }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java?view=diff&rev=561852&r1=561851&r2=561852
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaViewController.java
Wed Aug  1 09:10:40 2007
@@ -378,6 +378,7 @@
         initDoubleClickListener();
         initAuthorizedPrefs();
         initPreferencesListener();
+        initState();
     }
 
 
@@ -810,6 +811,40 @@
         {
             viewer.update( parent, null );
             parent = parent.getParent();
+        }
+    }
+
+
+    /**
+     * Initializes the state of the View.
+     */
+    private void initState()
+    {
+        Project project = Activator.getDefault().getProjectsHandler().getOpenProject();
+        if ( project != null )
+        {
+            viewer.getTree().setEnabled( true );
+            newSchema.setEnabled( true );
+            newAttributeType.setEnabled( true );
+            newObjectClass.setEnabled( true );
+            collapseAll.setEnabled( true );
+            linkWithEditor.setEnabled( true );
+            openSchemaViewSortingDialog.setEnabled( true );
+            openSchemaViewPreference.setEnabled( true );
+
+            addSchemaHandlerListener( project );
+            view.reloadViewer();
+        }
+        else
+        {
+            viewer.getTree().setEnabled( false );
+            newSchema.setEnabled( false );
+            newAttributeType.setEnabled( false );
+            newObjectClass.setEnabled( false );
+            collapseAll.setEnabled( false );
+            linkWithEditor.setEnabled( false );
+            openSchemaViewSortingDialog.setEnabled( false );
+            openSchemaViewPreference.setEnabled( false );
         }
     }
 }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenTypeHierarchyAction.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenTypeHierarchyAction.java?view=diff&rev=561852&r1=561851&r2=561852
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenTypeHierarchyAction.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/actions/OpenTypeHierarchyAction.java
Wed Aug  1 09:10:40 2007
@@ -38,6 +38,7 @@
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 
 
@@ -153,8 +154,24 @@
         HierarchyView view = ( HierarchyView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
             .findView( HierarchyView.ID );
 
-        view.setInput( element );
-        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(
view );
+        if ( view == null )
+        {
+            try
+            {
+                view = ( HierarchyView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(
+                    HierarchyView.ID );
+            }
+            catch ( PartInitException e )
+            {
+                // TODO Add a logger
+            }
+        }
+
+        if ( view != null )
+        {
+            view.setInput( element );
+            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(
view );
+        }
     }
 
 

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/Perspective.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/Perspective.java?view=diff&rev=561852&r1=561851&r2=561852
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/Perspective.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/Perspective.java
Wed Aug  1 09:10:40 2007
@@ -82,6 +82,7 @@
         layout.addShowViewShortcut( SchemaView.ID );
         layout.addShowViewShortcut( ProjectsView.ID );
         layout.addShowViewShortcut( ProblemsView.ID );
+        layout.addShowViewShortcut( HierarchyView.ID );
 
         // Adding New Wizard shortcuts
         layout.addNewWizardShortcut( NewProjectWizard.ID );

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyView.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyView.java?view=diff&rev=561852&r1=561851&r2=561852
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyView.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/HierarchyView.java
Wed Aug  1 09:10:40 2007
@@ -43,8 +43,8 @@
     /** The tree viewer */
     private TreeViewer viewer;
 
-    /** The content provider */
-    private HierarchyViewContentProvider contentProvider;
+    /** The controller */
+    private HierarchyViewController controller;
 
 
     /* (non-Javadoc)
@@ -54,7 +54,7 @@
     {
         initViewer( parent );
 
-        new HierarchyViewController( this );
+        controller = new HierarchyViewController( this );
     }
 
 
@@ -67,8 +67,7 @@
     private void initViewer( Composite parent )
     {
         viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
);
-        contentProvider = new HierarchyViewContentProvider();
-        viewer.setContentProvider( contentProvider );
+        viewer.setContentProvider( new HierarchyViewContentProvider() );
         viewer.setLabelProvider( new DecoratingLabelProvider( new HierarchyViewLabelProvider(),
Activator.getDefault()
             .getWorkbench().getDecoratorManager().getLabelDecorator() ) );
         viewer.getTree().setEnabled( false );
@@ -110,5 +109,16 @@
     {
         viewer.setInput( input );
         viewer.expandAll();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.WorkbenchPart#dispose()
+     */
+    public void dispose()
+    {
+        controller.dispose();
+        
+        super.dispose();
     }
 }



Mime
View raw message