You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2010/01/18 17:28:49 UTC

svn commit: r900449 - in /directory/studio/trunk: ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/ ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/

Author: pamarcelot
Date: Mon Jan 18 16:28:49 2010
New Revision: 900449

URL: http://svn.apache.org/viewvc?rev=900449&view=rev
Log:
Fix for:
  o DIRSTUDIO-618 (The icon of the entry in the 'Outline' view for the LDIF Entry Editor should be the same as the one in the 'LDAP Browser' view)
  o DIRSTUDIO-619 (Outline view for the LDIF Entry Editor should display by default the nodes underneath the entry)

Modified:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifEditor.java
    directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifOutlinePage.java

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java?rev=900449&r1=900448&r2=900449&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java (original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java Mon Jan 18 16:28:49 2010
@@ -32,6 +32,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
 import org.apache.directory.studio.ldifeditor.editor.LdifEditor;
+import org.apache.directory.studio.ldifeditor.editor.LdifOutlinePage;
 import org.apache.directory.studio.utils.ActionUtils;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.action.Action;
@@ -46,6 +47,7 @@
 import org.eclipse.ui.IShowEditorInput;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 
 
 /**
@@ -202,6 +204,26 @@
     }
 
 
+    /**
+     * @see org.eclipse.ui.editors.text.TextEditor#getAdapter(java.lang.Class)
+     */
+    public Object getAdapter( Class required )
+    {
+        // Overwriting the outline page
+        if ( IContentOutlinePage.class.equals( required ) )
+        {
+            if ( outlinePage == null || outlinePage.getControl() == null || outlinePage.getControl().isDisposed() )
+            {
+                outlinePage = new LdifOutlinePage( this, true );
+            }
+            return outlinePage;
+        }
+
+        // In all other cases, refering to the super class
+        return super.getAdapter( required );
+    }
+
+
     @Override
     protected void createActions()
     {

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifEditor.java?rev=900449&r1=900448&r2=900449&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifEditor.java (original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifEditor.java Mon Jan 18 16:28:49 2010
@@ -129,7 +129,7 @@
 
     private ProjectionSupport projectionSupport;
 
-    private LdifOutlinePage outlinePage;
+    protected LdifOutlinePage outlinePage;
 
     private ValueEditorManager valueEditorManager;
 

Modified: directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifOutlinePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifOutlinePage.java?rev=900449&r1=900448&r2=900449&view=diff
==============================================================================
--- directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifOutlinePage.java (original)
+++ directory/studio/trunk/ldifeditor/src/main/java/org/apache/directory/studio/ldifeditor/editor/LdifOutlinePage.java Mon Jan 18 16:28:49 2010
@@ -26,6 +26,12 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserLabelProvider;
 import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
 import org.apache.directory.studio.ldifeditor.LdifEditorActivator;
 import org.apache.directory.studio.ldifeditor.LdifEditorConstants;
@@ -38,6 +44,7 @@
 import org.apache.directory.studio.ldifparser.model.container.LdifModSpec;
 import org.apache.directory.studio.ldifparser.model.container.LdifRecord;
 import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifDnLine;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -64,6 +71,9 @@
     /** The editor it is attached to */
     private LdifEditor ldifEditor;
 
+    /** Whether or not the outline page is linked to an entry in the LDAP Browser view*/
+    private boolean isLinkedToLdapBrowser = false;
+
 
     /**
      * Creates a new instance of LdifOutlinePage.
@@ -77,6 +87,19 @@
     }
 
 
+    /**
+     * Creates a new instance of LdifOutlinePage.
+     *
+     * @param ldifEditor
+     *      the editor the Outline page is attached to
+     */
+    public LdifOutlinePage( LdifEditor ldifEditor, boolean isLinkedToLdapBrowser )
+    {
+        this.ldifEditor = ldifEditor;
+        this.isLinkedToLdapBrowser = isLinkedToLdapBrowser;
+    }
+
+
     /* (non-Javadoc)
      * @see org.eclipse.ui.views.contentoutline.ContentOutlinePage#createControl(org.eclipse.swt.widgets.Composite)
      */
@@ -85,9 +108,13 @@
         super.createControl( parent );
 
         final TreeViewer treeViewer = getTreeViewer();
-        treeViewer.setLabelProvider( new LdifLabelProvider() );
+        treeViewer.setLabelProvider( new LdifLabelProvider( ldifEditor, isLinkedToLdapBrowser ) );
         treeViewer.setContentProvider( new LdifContentProvider() );
-        // treeViewer.setAutoExpandLevel(1);
+
+        if ( isLinkedToLdapBrowser )
+        {
+            treeViewer.setAutoExpandLevel( 2 );
+        }
 
         treeViewer.addSelectionChangedListener( new ISelectionChangedListener()
         {
@@ -189,6 +216,11 @@
 
             treeViewer.refresh();
 
+            if ( isLinkedToLdapBrowser )
+            {
+                treeViewer.setAutoExpandLevel( 2 );
+            }
+
             // treeViewer.setSelection(selection);
             // treeViewer.setExpandedElements(expandedElements);
         }
@@ -346,6 +378,21 @@
      */
     private static class LdifLabelProvider extends LabelProvider
     {
+        /** The editor it is attached to */
+        private LdifEditor ldifEditor;
+
+        /** Whether or not the outline page is linked to an entry in the LDAP Browser view*/
+        private boolean isLinkedToLdapBrowser = false;
+
+
+        public LdifLabelProvider( LdifEditor ldifEditor, boolean isLinkedToLdapBrowser )
+        {
+            super();
+            this.ldifEditor = ldifEditor;
+            this.isLinkedToLdapBrowser = isLinkedToLdapBrowser;
+        }
+
+
         /* (non-Javadoc)
          * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
          */
@@ -394,6 +441,35 @@
             // Record
             if ( element instanceof LdifContentRecord )
             {
+                if ( isLinkedToLdapBrowser )
+                {
+                    LdifContentRecord record = ( LdifContentRecord ) element;
+
+                    LdifDnLine dnLine = record.getDnLine();
+                    if ( dnLine != null )
+                    {
+                        String dn = dnLine.getRawDn();
+                        if ( dn != null && "".equals( dn ) ) //$NON-NLS-1$
+                        {
+                            // Root DSE
+                            return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_ENTRY_ROOT );
+                        }
+                        else
+                        {
+                            // Any other case
+                            try
+                            {
+                                return BrowserLabelProvider.getImageByObjectClass( ldifEditor.getConnection()
+                                    .getEntryFromCache( new LdapDN( dn ) ) );
+                            }
+                            catch ( InvalidNameException e )
+                            {
+                                // Will never occur
+                            }
+                        }
+                    }
+                }
+
                 return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_ENTRY );
             }
             else if ( element instanceof LdifChangeAddRecord )