directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r488189 - in /directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser: controller/ controller/actions/ view/views/ view/views/wrappers/
Date Mon, 18 Dec 2006 10:08:43 GMT
Author: pamarcelot
Date: Mon Dec 18 02:08:41 2006
New Revision: 488189

URL: http://svn.apache.org/viewvc?view=rev&rev=488189
Log:
Changing the UI of the Attributes View. The Attribute Viewer now groups multiple values together
and the node needs to be collapsed to see the different values.

Added:
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeValueWrapper.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeWrapper.java
Modified:
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesView.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewContentProvider.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewLabelProvider.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewSorter.java
    directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/DisplayableTreeViewerElement.java

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java?view=diff&rev=488189&r1=488188&r2=488189
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/AttributesViewController.java
Mon Dec 18 02:08:41 2006
@@ -38,6 +38,7 @@
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Tree;
 import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.IWorkbenchPart;
 
@@ -104,7 +105,7 @@
         } );
 
         // Handling the double click modification
-        view.getViewer().getTable().addSelectionListener( new SelectionAdapter()
+        view.getViewer().getTree().addSelectionListener( new SelectionAdapter()
         {
             public void widgetDefaultSelected( SelectionEvent e )
             {
@@ -156,30 +157,30 @@
             public void selectionChanged( IWorkbenchPart part, ISelection selection )
             {
                 Object selectedObject = ( ( TreeSelection ) selection ).getFirstElement();
-                Table table = view.getViewer().getTable();
+                Tree tree = view.getViewer().getTree();
 
                 if ( selectedObject == null )
                 {
                     attributeNewAction.setEnabled( false );
-                    table.setEnabled( false );
+                    tree.setEnabled( false );
                 }
                 else
                 {
                     if ( selectedObject instanceof ConnectionWrapper )
                     {
                         attributeNewAction.setEnabled( false );
-                        table.setEnabled( false );
+                        tree.setEnabled( false );
                     }
                     else if ( selectedObject instanceof EntryWrapper )
                     {
                         attributeNewAction.setEnabled( true );
-                        table.setEnabled( true );
+                        tree.setEnabled( true );
                     }
                 }
             }
         } );
 
-        // Handling selection of the Attributes View to enable/disable the Actions
+        // Handling selection of thencoree Attributes View to enable/disable the Actions
         view.getSite().getPage().addSelectionListener( AttributesView.ID, new ISelectionListener()
         {
             public void selectionChanged( IWorkbenchPart part, ISelection selection )

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java?view=diff&rev=488189&r1=488188&r2=488189
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java
Mon Dec 18 02:08:41 2006
@@ -71,7 +71,7 @@
     {
         super( text );
         this.view = view;
-        this.table = view.getViewer().getTable();
+//        this.table = view.getViewer().getTable();
     }
 
 
@@ -90,52 +90,52 @@
      */
     private void createEditor()
     {
-        // Creating the Table Editor
-        tableEditor = new TableEditor( table );
-        tableEditor.horizontalAlignment = SWT.LEFT;
-        tableEditor.grabHorizontal = true;
-        tableEditor.minimumWidth = 50;
-
-        // Creating the Text Widget that will be used by the user 
-        // to enter the new value
-        textEditor = new Text( view.getViewer().getTable(), SWT.NONE );
-
-        // Adding Traverse Listener used to handle event when the 'return'
-        // or 'escape' key is pressed
-        textEditor.addListener( SWT.Traverse, new Listener()
-        {
-            public void handleEvent( Event event )
-            {
-                // Workaround for bug 20214 due to extra traverse events
-                switch ( event.detail )
-                {
-                    case SWT.TRAVERSE_ESCAPE: // Escape Key
-                        // Do nothing in this case
-                        disposeEditor();
-                        event.doit = true;
-                        event.detail = SWT.TRAVERSE_NONE;
-                        break;
-                    case SWT.TRAVERSE_RETURN: // Return Key
-                        saveChangesAndDisposeEditor();
-                        event.doit = true;
-                        event.detail = SWT.TRAVERSE_NONE;
-                        break;
-                }
-            }
-        } );
-
-        // Adding Focus Listener used to handle event when the user
-        // clicks on the elsewhere
-        textEditor.addFocusListener( new FocusAdapter()
-        {
-            public void focusLost( FocusEvent fe )
-            {
-                if ( !done )
-                {
-                    saveChangesAndDisposeEditor();
-                }
-            }
-        } );
+//        // Creating the Table Editor
+//        tableEditor = new TableEditor( table );
+//        tableEditor.horizontalAlignment = SWT.LEFT;
+//        tableEditor.grabHorizontal = true;
+//        tableEditor.minimumWidth = 50;
+//
+//        // Creating the Text Widget that will be used by the user 
+//        // to enter the new value
+//        textEditor = new Text( view.getViewer().getTable(), SWT.NONE );
+//
+//        // Adding Traverse Listener used to handle event when the 'return'
+//        // or 'escape' key is pressed
+//        textEditor.addListener( SWT.Traverse, new Listener()
+//        {
+//            public void handleEvent( Event event )
+//            {
+//                // Workaround for bug 20214 due to extra traverse events
+//                switch ( event.detail )
+//                {
+//                    case SWT.TRAVERSE_ESCAPE: // Escape Key
+//                        // Do nothing in this case
+//                        disposeEditor();
+//                        event.doit = true;
+//                        event.detail = SWT.TRAVERSE_NONE;
+//                        break;
+//                    case SWT.TRAVERSE_RETURN: // Return Key
+//                        saveChangesAndDisposeEditor();
+//                        event.doit = true;
+//                        event.detail = SWT.TRAVERSE_NONE;
+//                        break;
+//                }
+//            }
+//        } );
+//
+//        // Adding Focus Listener used to handle event when the user
+//        // clicks on the elsewhere
+//        textEditor.addFocusListener( new FocusAdapter()
+//        {
+//            public void focusLost( FocusEvent fe )
+//            {
+//                if ( !done )
+//                {
+//                    saveChangesAndDisposeEditor();
+//                }
+//            }
+//        } );
     }
 
 
@@ -144,7 +144,7 @@
      */
     private void showEditor()
     {
-        tableEditor.setEditor( textEditor, view.getViewer().getTable().getSelection()[0],
COLUMN_TO_EDIT );
+//        tableEditor.setEditor( textEditor, view.getViewer().getTable().getSelection()[0],
COLUMN_TO_EDIT );
         textEditor.setText( getAttributeValue() );
         textEditor.selectAll();
         textEditor.setFocus();
@@ -175,7 +175,7 @@
 
         // Resizing Columns and resetting the focus on the Table
         view.resizeColumsToFit();
-        view.getViewer().getTable().setFocus();
+//        view.getViewer().getTable().setFocus();
     }
 
 
@@ -185,8 +185,9 @@
      */
     private String getAttributeName()
     {
-        TableItem item = view.getSelectedAttributeTableItem();
-        return item.getText( 0 );
+//        TableItem item = view.getSelectedAttributeTableItem();
+//        return item.getText( 0 );
+        return "";
     }
 
 
@@ -196,8 +197,9 @@
      */
     private String getAttributeValue()
     {
-        TableItem item = view.getSelectedAttributeTableItem();
-        return item.getText( 1 );
+//        TableItem item = view.getSelectedAttributeTableItem();
+//        return item.getText( 1 );
+        return "";
     }
 
 
@@ -242,9 +244,9 @@
                     entry.getPartialAttributeList().get( getAttributeName() ).remove( getAttributeValue()
);
                     entry.getPartialAttributeList().get( getAttributeName() ).add( textEditor.getText()
);
                     
-                    TableItem item = view.getSelectedAttributeTableItem();
-                    item.setText( 1, textEditor.getText() );
-                    view.getViewer().refresh( item );
+//                    TableItem item = view.getSelectedAttributeTableItem();
+//                    item.setText( 1, textEditor.getText() );
+//                    view.getViewer().refresh( item );
                 }
                 else
                 {

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesView.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesView.java?view=diff&rev=488189&r1=488188&r2=488189
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesView.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesView.java
Mon Dec 18 02:08:41 2006
@@ -26,16 +26,23 @@
 
 import org.apache.directory.ldapstudio.browser.Activator;
 import org.apache.directory.ldapstudio.browser.controller.AttributesViewController;
+import org.apache.directory.ldapstudio.browser.view.views.wrappers.AttributeWrapper;
+import org.eclipse.core.runtime.Plugin;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.ViewPart;
 
@@ -49,12 +56,12 @@
 {
     /** The Attributes View's ID */
     public static final String ID = Activator.PLUGIN_ID + ".AttributesView";
-    private Table table;
-    private TableViewer viewer;
+    private Tree tree;
+    private TreeViewer viewer;
     private AttributesViewController controller;
     private AttributesViewSorter sorter;
-    private TableColumn attributeColumn;
-    private TableColumn valueColumn;
+    private TreeColumn attributeColumn;
+    private TreeColumn valueColumn;
 
 
     /**
@@ -69,19 +76,19 @@
     @Override
     public void createPartControl( Composite parent )
     {
-        table = new Table( parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
-        table.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true ) );
-        table.setLinesVisible( true );
-        table.setHeaderVisible( true );
-        table.setEnabled( false ); // The table is disabled by default since nothing is selected
in the Browser View
+        tree = new Tree( parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
+        tree.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true ) );
+        tree.setLinesVisible( true );
+        tree.setHeaderVisible( true );
+//        tree.setEnabled( false ); // The table is disabled by default since nothing is
selected in the Browser View
 
-        viewer = new TableViewer( table );
+        viewer = new TreeViewer( tree );
         viewer.setUseHashlookup( true );
 
         // Adding columns headers
-        attributeColumn = new TableColumn( table, SWT.NONE );
+        attributeColumn = new TreeColumn( tree, SWT.NONE );
         attributeColumn.setText( "Attribute" );
-        valueColumn = new TableColumn( table, SWT.NONE );
+        valueColumn = new TreeColumn( tree, SWT.NONE );
         valueColumn.setText( "Value" );
 
         // Initializing ContentProvider and LabelProvider
@@ -94,14 +101,14 @@
 
         // Registering the view to the controller and creating the Actions
         controller.setView( this );
-        controller.createActions();
+//        controller.createActions();
 
         // Registering the Viewer, so other views can be notified when the viewer selection
changes
         getSite().setSelectionProvider( viewer );
 
-        createContextMenu();
+//        createContextMenu();
 
-        createToolbarButtons();
+//        createToolbarButtons();
     }
 
 
@@ -115,10 +122,14 @@
             @SuppressWarnings("unchecked")
             public int compare( Object o1, Object o2 )
             {
-                List<String> list1 = ( List<String> ) o1;
-                List<String> list2 = ( List<String> ) o2;
-
-                return list1.get( 0 ).compareTo( list2.get( 0 ) );
+                if ( o1 instanceof AttributeWrapper )
+                {
+                    AttributeWrapper at1 = ( AttributeWrapper ) o1;
+                    AttributeWrapper at2 = ( AttributeWrapper ) o2;
+                    
+                    return at1.getName().compareTo( at2.getName() );
+                }
+                return 0;
             }
         };
 
@@ -127,14 +138,11 @@
             @SuppressWarnings("unchecked")
             public int compare( Object o1, Object o2 )
             {
-                List<String> list1 = ( List<String> ) o1;
-                List<String> list2 = ( List<String> ) o2;
-
-                return list1.get( 1 ).compareTo( list2.get( 1 ) );
+                return 0;
             }
         };
 
-        sorter = new AttributesViewSorter( viewer, new TableColumn[]
+        sorter = new AttributesViewSorter( viewer, new TreeColumn[]
             { attributeColumn, valueColumn }, new Comparator[]
             { nameComparator, valueComparator } );
 
@@ -179,7 +187,7 @@
     @Override
     public void setFocus()
     {
-        table.setFocus();
+        tree.setFocus();
     }
 
 
@@ -199,11 +207,11 @@
     public void resizeColumsToFit()
     {
         // Resizing the first column
-        table.getColumn( 0 ).pack();
+        tree.getColumn( 0 ).pack();
         // Adding a little space to the first column
-        table.getColumn( 0 ).setWidth( table.getColumn( 0 ).getWidth() + 5 );
+        tree.getColumn( 0 ).setWidth( tree.getColumn( 0 ).getWidth() + 5 );
         // Resizing the second column
-        table.getColumn( 1 ).pack();
+        tree.getColumn( 1 ).pack();
     }
 
 
@@ -211,13 +219,13 @@
      * Gets the currently selected Attribute TableItem 
      * @return the currently selected Attribute TableItem
      */
-    public TableItem getSelectedAttributeTableItem()
+    public TreeItem getSelectedAttributeTableItem()
     {
-        return table.getSelection()[0];
+        return tree.getSelection()[0];
     }
 
 
-    public TableViewer getViewer()
+    public TreeViewer getViewer()
     {
         return viewer;
     }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewContentProvider.java?view=diff&rev=488189&r1=488188&r2=488189
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewContentProvider.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewContentProvider.java
Mon Dec 18 02:08:41 2006
@@ -30,20 +30,25 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 
+import org.apache.directory.ldapstudio.browser.view.views.wrappers.AttributeValueWrapper;
+import org.apache.directory.ldapstudio.browser.view.views.wrappers.AttributeWrapper;
 import org.apache.directory.ldapstudio.browser.view.views.wrappers.EntryWrapper;
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.ui.PlatformUI;
 
+import sun.security.krb5.internal.util.o;
+
 
 /**
  * This class is the Content Provider for the Attributes View
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AttributesViewContentProvider implements IStructuredContentProvider
+public class AttributesViewContentProvider implements IStructuredContentProvider, ITreeContentProvider
 {
 
     /* (non-Javadoc)
@@ -54,7 +59,7 @@
         if ( inputElement instanceof EntryWrapper )
         {
             // Initializing the retun list
-            List<List<String>> returnList = new ArrayList<List<String>>();
+            List<AttributeWrapper> returnList = new ArrayList<AttributeWrapper>();
 
             // Getting the entry and looping on its attributes
             SearchResultEntry entry = ( ( EntryWrapper ) inputElement ).getEntry();
@@ -62,40 +67,8 @@
 
             while ( ne.hasMoreElements() )
             {
-                Attribute attribute = ( Attribute ) ne.nextElement();
-                for ( int i = 0; i < attribute.size(); i++ )
-                {
-                    try
-                    {
-                        // A List is constructed  : {Attribute ID, Attribute Value}
-                        List<String> list = new ArrayList<String>( 2 );
-                        list.add( 0, attribute.getID() );
-                        list.add( 1, ( String ) attribute.get( i ) );
-
-                        returnList.add( list );
-                    }
-                    catch ( NamingException e )
-                    {
-                        // Displaying an error
-                        MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
-                            "Error !", "An error has ocurred.\n" + e.getMessage() );
-                        return null;
-                    }
-                }
+                returnList.add( new AttributeWrapper( ( Attribute ) ne.nextElement(), ( EntryWrapper
) inputElement ) );
             }
-
-            // Sorting the attributes
-            Collections.sort( returnList, new Comparator<List<String>>()
-            {
-                public int compare( List<String> l1, List<String> l2 )
-                {
-                    String s1 = l1.get( 0 );
-                    String s2 = l2.get( 0 );
-
-                    return s1.compareTo( s2 );
-                }
-            } );
-
             return returnList.toArray();
         }
 
@@ -121,6 +94,38 @@
     {
         // Nothing to do here but the method is needed 
         // by IContentProvider Interface
+    }
+
+
+    public Object[] getChildren( Object parentElement )
+    {
+        if ( parentElement instanceof AttributeWrapper )
+        {
+            return ( ( AttributeWrapper ) parentElement ).getChildren();
+            
+        }
+        return null;
+    }
+
+
+    public Object getParent( Object element )
+    {
+        if ( element instanceof AttributeValueWrapper )
+        {
+            return ( ( AttributeValueWrapper ) element ).getParent();
+        }
+        return null;
+    }
+
+
+    public boolean hasChildren( Object element )
+    {
+        if ( element instanceof AttributeWrapper )
+        {
+            return ( ( AttributeWrapper ) element).hasChildren();
+            
+        }
+        return false;
     }
 
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewLabelProvider.java?view=diff&rev=488189&r1=488188&r2=488189
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewLabelProvider.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewLabelProvider.java
Mon Dec 18 02:08:41 2006
@@ -21,11 +21,18 @@
 package org.apache.directory.ldapstudio.browser.view.views;
 
 
-import java.util.List;
-
+import org.apache.directory.ldapstudio.browser.view.views.wrappers.AttributeValueWrapper;
+import org.apache.directory.ldapstudio.browser.view.views.wrappers.AttributeWrapper;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableFontProvider;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.PlatformUI;
 
 
 /**
@@ -33,7 +40,7 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AttributesViewLabelProvider extends LabelProvider implements ITableLabelProvider
+public class AttributesViewLabelProvider extends LabelProvider implements ITableLabelProvider,
ITableFontProvider, ITableColorProvider
 {
 
     /* (non-Javadoc)
@@ -50,13 +57,52 @@
      */
     public String getColumnText( Object element, int columnIndex )
     {
-        if ( element instanceof List )
+        if ( element instanceof AttributeWrapper )
         {
-            List<String> couple = ( List<String> ) element;
-            return couple.get( columnIndex );
+            return ( ( AttributeWrapper ) element ).getColumnText( element, columnIndex );
+        }
+        else if ( element instanceof AttributeValueWrapper )
+        {
+            return ( ( AttributeValueWrapper ) element ).getColumnText( element, columnIndex
);
         }
-
         // Default return (should never be used)
         return "";
+    }
+    
+
+    public Font getFont( Object element, int columnIndex )
+    {
+        if ( ( element instanceof AttributeWrapper ) && ( columnIndex == 1 )  )
+        {   
+            AttributeWrapper attributeWrapper = ( AttributeWrapper ) element;
+            
+            if ( attributeWrapper.getChildren().length > 1 )
+            {
+                return new Font( null, "Geneva", 9, SWT.ITALIC );
+            }
+        }
+        return null;
+    }
+
+
+    public Color getBackground( Object element, int columnIndex )
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+    public Color getForeground( Object element, int columnIndex )
+    {
+        if ( ( element instanceof AttributeWrapper ) && ( columnIndex == 1 )  )
+        {   
+            AttributeWrapper attributeWrapper = ( AttributeWrapper ) element;
+            
+            if ( attributeWrapper.getChildren().length > 1 )
+            {
+                return PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_GRAY);
+            }
+        }
+        return null;
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewSorter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewSorter.java?view=diff&rev=488189&r1=488188&r2=488189
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewSorter.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/AttributesViewSorter.java
Mon Dec 18 02:08:41 2006
@@ -23,12 +23,12 @@
 
 import java.util.Comparator;
 
-import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerSorter;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TreeColumn;
 
 
 /**
@@ -50,7 +50,7 @@
     }
 
     /** The associated viewer */
-    private TableViewer viewer;
+    private TreeViewer viewer;
 
     /** The information on the sortable columns */
     private SortableColumnInfo[] infos;
@@ -66,7 +66,7 @@
      * @param columns the array containing the sortable columns
      * @param comparators the array containing the associated comparators
      */
-    public AttributesViewSorter( TableViewer viewer, TableColumn[] columns, Comparator[]
comparators )
+    public AttributesViewSorter( TreeViewer viewer, TreeColumn[] columns, Comparator[] comparators
)
     {
         this.viewer = viewer;
         infos = new SortableColumnInfo[columns.length];
@@ -108,7 +108,7 @@
      * @param column
      * @param info
      */
-    private void createSelectionListener( TableColumn column, final SortableColumnInfo info
)
+    private void createSelectionListener( TreeColumn column, final SortableColumnInfo info
)
     {
         column.addSelectionListener( new SelectionAdapter()
         {

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeValueWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeValueWrapper.java?view=auto&rev=488189
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeValueWrapper.java
(added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeValueWrapper.java
Mon Dec 18 02:08:41 2006
@@ -0,0 +1,49 @@
+
+package org.apache.directory.ldapstudio.browser.view.views.wrappers;
+
+/**
+ * AttributeValueWrapper used to display an attribute value in the Attributes View
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeValueWrapper
+{
+    private Object value;
+    private AttributeWrapper parent;
+    
+    public AttributeValueWrapper( Object value, AttributeWrapper parent)
+    {
+       this.value = value;
+       this.parent = parent;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
int)
+     */
+    public String getColumnText( Object element, int columnIndex )
+    {
+        if ( columnIndex == 0 )
+        {
+            return ""; // The first column needs an entry String
+        }
+        else if ( columnIndex == 1 )
+        {
+            if ( value instanceof String )
+            {
+                return ( String ) value;
+            }
+        }
+        
+        return "";
+    }
+
+    /**
+     * Gets the parent element
+     * @return the parent element
+     */
+    public AttributeWrapper getParent()
+    {
+        return parent;
+    }    
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeWrapper.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeWrapper.java?view=auto&rev=488189
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeWrapper.java
(added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/AttributeWrapper.java
Mon Dec 18 02:08:41 2006
@@ -0,0 +1,141 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.view.views.wrappers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+
+/**
+ * AttributeWrapper used to display an attribute and the number of its values in the Attributes
View
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeWrapper
+{
+    private Attribute attribute;
+    private EntryWrapper entry;
+    private List<AttributeValueWrapper> children;
+    
+    /**
+     * Creates a new instance of AttributeWrapper.
+     *
+     * @param attribute the attribute to wrap
+     * @param entry the associated EntryWrapper
+     */
+    public AttributeWrapper( Attribute attribute, EntryWrapper entry)
+    {
+        this.attribute = attribute;
+        this.entry = entry;
+    }
+    
+    /**
+     * Gets the children of the object
+     * @return the children of the object
+     */
+    public Object[] getChildren()
+    {
+        if ( children == null )
+        {
+            children = new ArrayList<AttributeValueWrapper>();
+            
+            try
+            {
+                NamingEnumeration ne = attribute.getAll();
+                
+                while ( ne.hasMoreElements() )
+                {
+                    AttributeValueWrapper avw = new AttributeValueWrapper( ne.nextElement(),
this );
+                    children.add( avw );
+                }
+            }
+            catch ( NamingException e )
+            {
+                // TODO Add a log into Eclipse system
+                e.printStackTrace();
+            }
+        }
+        return children.toArray();
+    }
+    
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
int)
+     */
+    public String getColumnText( Object element, int columnIndex )
+    {
+        if ( columnIndex == 0 )
+        {
+            return attribute.getID();
+        }
+        else if ( columnIndex == 1 )
+        {
+            int nb = getChildren().length;
+            if ( nb == 1 )
+            {
+                // If there's only one value we display it                
+                try
+                {
+                    Object value;value = attribute.get();
+                    if ( value instanceof String )
+                    {
+                        return ( String ) value;
+                        
+                    }
+                    return "(Binary value)";
+                    
+                }
+                catch ( NamingException e )
+                {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+            else
+            {
+                return "(" + nb + " attributes)";
+            }
+        }
+        return "";
+    }
+    
+    /**
+     * Gets the HasChildren Flag
+     * @return
+     */
+    public boolean hasChildren()
+    {
+        return ( getChildren().length > 1 );
+    }
+    
+    /**
+     * Gets the name of the attribute
+     * 
+     * @return the name of the attribute
+     */
+    public String getName()
+    {
+        return attribute.getID();
+    }
+}

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/DisplayableTreeViewerElement.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/DisplayableTreeViewerElement.java?view=diff&rev=488189&r1=488188&r2=488189
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/DisplayableTreeViewerElement.java
(original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/view/views/wrappers/DisplayableTreeViewerElement.java
Mon Dec 18 02:08:41 2006
@@ -48,13 +48,6 @@
 
 
     /**
-     * Get the Connection associated
-     * @return the connection
-     */
-    public Connection getConnection();
-
-
-    /**
      * Get parent object in the TreeViewer Hierarchy
      * @return the parent
      */



Mime
View raw message