You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 18:01:46 UTC

svn commit: r592087 [11/16] - in /directory/sandbox/felixk/studio-ldapbrowser-ui: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/studio/ src...

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserView.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserView.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserView.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserView.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,335 @@
+/*
+ *  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.studio.ldapbrowser.ui.views.browser;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserConfiguration;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserWidget;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.IShowInTarget;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * This class implements the browser view. It displays the DIT, the searches and the bookmarks.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserView extends ViewPart
+{
+
+    /** The configuration */
+    private BrowserConfiguration configuration;
+
+    /** The listeners */
+    private BrowserViewUniversalListener universalListener;
+
+    /** The actions */
+    private BrowserViewActionGroup actionGroup;
+
+    /** The browser's main widget */
+    private BrowserWidget mainWidget;
+
+
+    // private DragAction dragAction;
+    // private DropAction dropAction;
+
+    /**
+     * Returns the browser view ID.
+     * 
+     * @return the browser view ID.
+     */
+    public static String getId()
+    {
+        return BrowserView.class.getName();
+    }
+
+
+    /**
+     * Creates a new instance of BrowserView.
+     */
+    public BrowserView()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation sets focus to the viewer's control.
+     */
+    public void setFocus()
+    {
+        mainWidget.getViewer().getControl().setFocus();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        if ( configuration != null )
+        {
+            actionGroup.dispose();
+            actionGroup = null;
+            universalListener.dispose();
+            universalListener = null;
+            configuration.dispose();
+            configuration = null;
+            mainWidget.dispose();
+            mainWidget = null;
+            getSite().setSelectionProvider( null );
+        }
+
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createPartControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        GridLayout layout = new GridLayout();
+        layout.marginWidth = 0;
+        layout.marginHeight = 0;
+        composite.setLayout( layout );
+
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( composite,
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_browser_view" );
+
+        // create configuration
+        configuration = new BrowserConfiguration();
+
+        // create main widget
+        mainWidget = new BrowserWidget( configuration, getViewSite().getActionBars() );
+        mainWidget.createWidget( composite );
+        mainWidget.setInput( getSite() );
+
+        // create actions and context menu (and register global actions)
+        actionGroup = new BrowserViewActionGroup( this );
+        actionGroup.fillToolBar( mainWidget.getToolBarManager() );
+        actionGroup.fillMenu( mainWidget.getMenuManager() );
+        actionGroup.enableGlobalActionHandlers( getViewSite().getActionBars() );
+        actionGroup.fillContextMenu( mainWidget.getContextMenuManager() );
+
+        // create the listener
+        getSite().setSelectionProvider( mainWidget.getViewer() );
+        universalListener = new BrowserViewUniversalListener( this );
+
+        // DND support
+        // int ops = DND.DROP_COPY | DND.DROP_MOVE;
+        // viewer.addDragSupport(ops, new Transfer[]{TextTransfer.getInstance(),
+        // BrowserTransfer.getInstance()}, this.dragAction);
+        // viewer.addDropSupport(ops, new
+        // Transfer[]{BrowserTransfer.getInstance()}, this.dropAction);
+    }
+
+
+    /**
+     * Selects the given object in the tree. The object
+     * must be an IEntry, ISearch, ISearchResult or IBookmark.
+     * 
+     * @param obj the object to select
+     */
+    public void select( Object obj )
+    {
+        Object objectToSelect = null;
+
+        if ( obj instanceof ISearch )
+        {
+            ISearch search = ( ISearch ) obj;
+
+            universalListener.setInput( search.getBrowserConnection() );
+
+            mainWidget.getViewer().expandToLevel( search, 0 );
+
+            objectToSelect = search;
+        }
+        if ( obj instanceof ISearchResult )
+        {
+            ISearchResult searchResult = ( ISearchResult ) obj;
+            ISearch search = searchResult.getSearch();
+
+            universalListener.setInput( search.getBrowserConnection() );
+
+            mainWidget.getViewer().expandToLevel( search, 1 );
+
+            objectToSelect = searchResult;
+        }
+        if ( obj instanceof IBookmark )
+        {
+            IBookmark bookmark = ( IBookmark ) obj;
+
+            universalListener.setInput( bookmark.getBrowserConnection() );
+
+            mainWidget.getViewer().expandToLevel( bookmark, 0 );
+
+            objectToSelect = bookmark;
+        }
+        if ( obj instanceof IEntry )
+        {
+            IEntry entry = ( IEntry ) obj;
+
+            universalListener.setInput( entry.getBrowserConnection() );
+
+            List<IEntry> entryList = new ArrayList<IEntry>();
+            IEntry tempEntry = entry;
+            while ( tempEntry.getParententry() != null )
+            {
+                IEntry parentEntry = tempEntry.getParententry();
+                entryList.add( 0, parentEntry );
+                tempEntry = parentEntry;
+            }
+
+            for ( IEntry parentEntry : entryList )
+            {
+                if ( !parentEntry.isChildrenInitialized() )
+                {
+                    parentEntry.setChildrenInitialized( true );
+                    parentEntry.setHasMoreChildren( true );
+                }
+                
+                // force refresh of each parent, beginning from the root
+                // if the entry to select was lazy initialized then the 
+                // JFace model has no knowledge about it so we must
+                // refresh the JFace model from the browser model
+                mainWidget.getViewer().refresh( parentEntry, true );
+            }
+
+            objectToSelect = entry;
+        }
+
+        if ( objectToSelect != null )
+        {
+            mainWidget.getViewer().reveal( objectToSelect );
+            mainWidget.getViewer().refresh( objectToSelect, true );
+            mainWidget.getViewer().setSelection( new StructuredSelection( objectToSelect ), true );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object getAdapter( Class required )
+    {
+        if ( IShowInTarget.class.equals( required ) )
+        {
+            return new IShowInTarget()
+            {
+                public boolean show( ShowInContext context )
+                {
+                    StructuredSelection selection = ( StructuredSelection ) context.getSelection();
+                    Object obj = selection.getFirstElement();
+                    if ( obj instanceof IValue )
+                    {
+                        IValue value = ( IValue ) obj;
+                        IEntry entry = value.getAttribute().getEntry();
+                        select( entry );
+                    }
+                    else if ( obj instanceof IAttribute )
+                    {
+                        IAttribute attribute = ( IAttribute ) obj;
+                        IEntry entry = attribute.getEntry();
+                        select( entry );
+
+                    }
+                    else if ( obj instanceof ISearchResult )
+                    {
+                        ISearchResult sr = ( ISearchResult ) obj;
+                        ISearch search = sr.getSearch();
+                        select( search );
+                    }
+                    return true;
+                }
+            };
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Gets the action group.
+     *
+     * @return the action group
+     */
+    public BrowserViewActionGroup getActionGroup()
+    {
+        return actionGroup;
+    }
+
+
+    /**
+     * Gets the configuration.
+     *
+     * @return the configuration
+     */
+    public BrowserConfiguration getConfiguration()
+    {
+        return configuration;
+    }
+
+
+    /**
+     * Gets the main widget.
+     * 
+     * @return the main widget
+     */
+    public BrowserWidget getMainWidget()
+    {
+        return mainWidget;
+    }
+
+
+    /**
+     * Gets the universal listener.
+     * 
+     * @return the universal listener
+     */
+    public BrowserViewUniversalListener getUniversalListener()
+    {
+        return universalListener;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserView.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,427 @@
+/*
+ *  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.studio.ldapbrowser.ui.views.browser;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.DeleteAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.PasteAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.RenameAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.proxy.BrowserActionProxy;
+import org.apache.directory.studio.ldapbrowser.common.actions.proxy.BrowserViewActionProxy;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserActionGroup;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopyDnAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopyEntryAsCsvAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopyEntryAsLdifAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopyUrlAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.ImportExportAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.LocateEntryInDitAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.MoveAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.NewBatchOperationAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.NewBookmarkAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.NewEntryAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.NewSearchAction;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.commands.ActionHandler;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.commands.ICommandService;
+
+
+/**
+ * This class manages all the actions of the browser view.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserViewActionGroup extends BrowserActionGroup
+{
+
+    /** The action to show/hide the DIT. */
+    private ShowDITAction showDITAction;
+
+    /** The action to show/hide searches. */
+    private ShowSearchesAction showSearchesAction;
+
+    /** The action to show/hide bookmarks. */
+    private ShowBookmarksAction showBookmarksAction;
+
+    /** The action to show/hide metadata. */
+    private ShowDirectoryMetadataEntriesAction showDirectoryMetadataEntriesAction;
+
+    /** The action to open the browser's preference page. */
+    private OpenBrowserPreferencePageAction openBrowserPreferencePageAction;
+
+    /** The action to link the current editor with the browser view. */
+    private LinkWithEditorAction linkWithEditorAction;
+
+    /** The Constant locateEntryInDitAction. */
+    private static final String locateEntryInDitAction = "locateEntryInDitAction";
+
+    /** The Constant newEntryAction. */
+    private static final String newEntryAction = "newEntryAction";
+
+    /** The Constant newSearchAction. */
+    private static final String newSearchAction = "newSearchAction";
+
+    /** The Constant newBookmarkAction. */
+    private static final String newBookmarkAction = "newBookmarkAction";
+
+    /** The Constant newBatchOperationAction. */
+    private static final String newBatchOperationAction = "newBatchOperationAction";
+
+    /** The Constant copyAction. */
+    private static final String copyAction = "copyAction";
+
+    /** The Constant pasteAction. */
+    private static final String pasteAction = "pasteAction";
+
+    /** The Constant deleteAction. */
+    private static final String deleteAction = "deleteAction";
+
+    /** The Constant moveAction. */
+    private static final String moveAction = "moveAction";
+
+    /** The Constant renameAction. */
+    private static final String renameAction = "renameAction";
+
+    /** The Constant copyDnAction. */
+    private static final String copyDnAction = "copyDnAction";
+
+    /** The Constant copyUrlAction. */
+    private static final String copyUrlAction = "copyUrlAction";
+
+    /** The Constant copyEntryAsLdifDnOnlyAction. */
+    private static final String copyEntryAsLdifDnOnlyAction = "copyEntryAsLdifDnOnlyAction";
+
+    /** The Constant copyEntryAsLdifReturningAttributesOnlyAction. */
+    private static final String copyEntryAsLdifReturningAttributesOnlyAction = "copyEntryAsLdifReturningAttributesOnlyAction";
+
+    /** The Constant copyEntryAsLdifAction. */
+    private static final String copyEntryAsLdifAction = "copyEntryAsLdifAction";
+
+    /** The Constant copyEntryAsLdifOperationalAction. */
+    private static final String copyEntryAsLdifOperationalAction = "copyEntryAsLdifOperationalAction";
+
+    /** The Constant copyEntryAsCsvDnOnlyAction. */
+    private static final String copyEntryAsCsvDnOnlyAction = "copyEntryAsCsvDnOnlyAction";
+
+    /** The Constant copyEntryAsCsvReturningAttributesOnlyAction. */
+    private static final String copyEntryAsCsvReturningAttributesOnlyAction = "copyEntryAsCsvReturningAttributesOnlyAction";
+
+    /** The Constant copyEntryAsCsvAction. */
+    private static final String copyEntryAsCsvAction = "copyEntryAsCsvAction";
+
+    /** The Constant copyEntryAsCsvOperationalAction. */
+    private static final String copyEntryAsCsvOperationalAction = "copyEntryAsCsvOperationalAction";
+
+    /** The Constant importDsmlAction. */
+    private static final String importDsmlAction = "importDsmlAction";
+
+    /** The Constant importLdifAction. */
+    private static final String importLdifAction = "importLdifAction";
+
+    /** The Constant exportLdifAction. */
+    private static final String exportLdifAction = "exportLdifAction";
+
+    /** The Constant exportDsmlAction. */
+    private static final String exportDsmlAction = "exportDsmlAction";
+
+    /** The Constant exportCsvAction. */
+    private static final String exportCsvAction = "exportCsvAction";
+
+    /** The Constant exportExcelAction. */
+    private static final String exportExcelAction = "exportExcelAction";
+
+
+    /**
+     * Creates a new instance of BrowserViewActionGroup and 
+     * creates all the actions.
+     * 
+     * @param view the browser view
+     */
+    public BrowserViewActionGroup( BrowserView view )
+    {
+        super( view.getMainWidget(), view.getConfiguration() );
+        TreeViewer viewer = view.getMainWidget().getViewer();
+
+        linkWithEditorAction = new LinkWithEditorAction( view );
+        showDITAction = new ShowDITAction();
+        showSearchesAction = new ShowSearchesAction();
+        showBookmarksAction = new ShowBookmarksAction();
+        showDirectoryMetadataEntriesAction = new ShowDirectoryMetadataEntriesAction();
+        openBrowserPreferencePageAction = new OpenBrowserPreferencePageAction();
+
+        browserActionMap.put( newEntryAction, new BrowserViewActionProxy( viewer, this, new NewEntryAction( view
+            .getSite().getWorkbenchWindow() ) ) );
+        browserActionMap.put( newSearchAction, new BrowserViewActionProxy( viewer, this, new NewSearchAction() ) );
+        browserActionMap.put( newBookmarkAction, new BrowserViewActionProxy( viewer, this, new NewBookmarkAction() ) );
+        browserActionMap.put( newBatchOperationAction, new BrowserViewActionProxy( viewer, this,
+            new NewBatchOperationAction() ) );
+
+        browserActionMap.put( locateEntryInDitAction, new BrowserViewActionProxy( viewer, this,
+            new LocateEntryInDitAction() ) );
+
+        browserActionMap.put( pasteAction, new BrowserViewActionProxy( viewer, this, new PasteAction() ) );
+        browserActionMap.put( copyAction, new BrowserViewActionProxy( viewer, this, new CopyAction(
+            ( BrowserActionProxy ) browserActionMap.get( pasteAction ) ) ) );
+        browserActionMap.put( deleteAction, new BrowserViewActionProxy( viewer, this, new DeleteAction() ) );
+        browserActionMap.put( moveAction, new BrowserViewActionProxy( viewer, this, new MoveAction() ) );
+        browserActionMap.put( renameAction, new BrowserViewActionProxy( viewer, this, new RenameAction() ) );
+
+        browserActionMap.put( copyDnAction, new BrowserViewActionProxy( viewer, this, new CopyDnAction() ) );
+        browserActionMap.put( copyUrlAction, new BrowserViewActionProxy( viewer, this, new CopyUrlAction() ) );
+
+        browserActionMap.put( copyEntryAsLdifAction, new BrowserViewActionProxy( viewer, this,
+            new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_NORMAL ) ) );
+        browserActionMap.put( copyEntryAsLdifDnOnlyAction, new BrowserViewActionProxy( viewer, this,
+            new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_DN_ONLY ) ) );
+        browserActionMap.put( copyEntryAsLdifReturningAttributesOnlyAction, new BrowserViewActionProxy( viewer, this,
+            new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_RETURNING_ATTRIBUTES_ONLY ) ) );
+        browserActionMap.put( copyEntryAsLdifOperationalAction, new BrowserViewActionProxy( viewer, this,
+            new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) ) );
+        browserActionMap.put( copyEntryAsCsvAction, new BrowserViewActionProxy( viewer, this, new CopyEntryAsCsvAction(
+            CopyEntryAsLdifAction.MODE_NORMAL ) ) );
+        browserActionMap.put( copyEntryAsCsvDnOnlyAction, new BrowserViewActionProxy( viewer, this,
+            new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_DN_ONLY ) ) );
+        browserActionMap.put( copyEntryAsCsvReturningAttributesOnlyAction, new BrowserViewActionProxy( viewer, this,
+            new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_RETURNING_ATTRIBUTES_ONLY ) ) );
+        browserActionMap.put( copyEntryAsCsvOperationalAction, new BrowserViewActionProxy( viewer, this,
+            new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) ) );
+
+        browserActionMap.put( importDsmlAction, new BrowserViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_IMPORT_DSML ) ) );
+        browserActionMap.put( exportDsmlAction, new BrowserViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_EXPORT_DSML ) ) );
+        browserActionMap.put( importLdifAction, new BrowserViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_IMPORT_LDIF ) ) );
+        browserActionMap.put( exportLdifAction, new BrowserViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_EXPORT_LDIF ) ) );
+        browserActionMap.put( exportCsvAction, new BrowserViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_EXPORT_CSV ) ) );
+        browserActionMap.put( exportExcelAction, new BrowserViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_EXPORT_EXCEL ) ) );
+
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        if ( openBrowserPreferencePageAction != null )
+        {
+            linkWithEditorAction.dispose();
+            linkWithEditorAction = null;
+
+            showDITAction = null;
+            showSearchesAction = null;
+            showBookmarksAction = null;
+            showDirectoryMetadataEntriesAction = null;
+            openBrowserPreferencePageAction = null;
+        }
+
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void fillToolBar( IToolBarManager toolBarManager )
+    {
+
+        toolBarManager.add( ( IAction ) browserActionMap.get( upAction ) );
+        toolBarManager.add( new Separator() );
+        toolBarManager.add( ( IAction ) browserActionMap.get( refreshAction ) );
+        toolBarManager.add( new Separator() );
+        toolBarManager.add( collapseAllAction );
+        toolBarManager.add( linkWithEditorAction );
+        toolBarManager.update( true );
+
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void fillMenu( IMenuManager menuManager )
+    {
+
+        menuManager.add( openSortDialogAction );
+        menuManager.add( new Separator() );
+        menuManager.add( showDITAction );
+        menuManager.add( showSearchesAction );
+        menuManager.add( showBookmarksAction );
+        menuManager.add( showDirectoryMetadataEntriesAction );
+        menuManager.add( new Separator() );
+        menuManager.add( openBrowserPreferencePageAction );
+        menuManager.update( true );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void menuAboutToShow( IMenuManager menuManager )
+    {
+        // new
+        menuManager.add( ( IAction ) browserActionMap.get( newEntryAction ) );
+        menuManager.add( ( IAction ) browserActionMap.get( newSearchAction ) );
+        menuManager.add( ( IAction ) browserActionMap.get( newBookmarkAction ) );
+        menuManager.add( ( IAction ) browserActionMap.get( newBatchOperationAction ) );
+        menuManager.add( new Separator() );
+
+        // navigation
+        BrowserViewActionProxy leid = ( BrowserViewActionProxy ) browserActionMap.get( locateEntryInDitAction );
+        leid.setImageDescriptor( leid.getAction().getImageDescriptor() );
+        menuManager.add( leid );
+        menuManager.add( ( IAction ) browserActionMap.get( upAction ) );
+        menuManager.add( new Separator() );
+
+        // copy/paste/...
+        menuManager.add( ( IAction ) browserActionMap.get( copyAction ) );
+        menuManager.add( ( IAction ) browserActionMap.get( pasteAction ) );
+        menuManager.add( ( IAction ) browserActionMap.get( deleteAction ) );
+        menuManager.add( ( IAction ) browserActionMap.get( moveAction ) );
+        menuManager.add( ( IAction ) browserActionMap.get( renameAction ) );
+        MenuManager advancedMenuManager = new MenuManager( "Advanced" );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyDnAction ) );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyUrlAction ) );
+        advancedMenuManager.add( new Separator() );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyEntryAsLdifDnOnlyAction ) );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyEntryAsLdifReturningAttributesOnlyAction ) );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyEntryAsLdifAction ) );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyEntryAsLdifOperationalAction ) );
+        advancedMenuManager.add( new Separator() );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyEntryAsCsvDnOnlyAction ) );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyEntryAsCsvReturningAttributesOnlyAction ) );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyEntryAsCsvAction ) );
+        advancedMenuManager.add( ( IAction ) browserActionMap.get( copyEntryAsCsvOperationalAction ) );
+        advancedMenuManager.add( new Separator() );
+        menuManager.add( advancedMenuManager );
+        menuManager.add( new Separator() );
+
+        // filter, batch
+        menuManager.add( ( IAction ) browserActionMap.get( filterChildrenAction ) );
+        if ( ( ( IAction ) browserActionMap.get( unfilterChildrenAction ) ).isEnabled() )
+        {
+            menuManager.add( ( IAction ) browserActionMap.get( unfilterChildrenAction ) );
+        }
+        menuManager.add( new Separator() );
+
+        // import/export
+        MenuManager importMenuManager = new MenuManager( "Import" );
+        importMenuManager.add( ( IAction ) browserActionMap.get( importLdifAction ) );
+        importMenuManager.add( ( IAction ) browserActionMap.get( importDsmlAction ) );
+        importMenuManager.add( new Separator() );
+        menuManager.add( importMenuManager );
+
+        MenuManager exportMenuManager = new MenuManager( "Export" );
+        exportMenuManager.add( ( IAction ) browserActionMap.get( exportLdifAction ) );
+        exportMenuManager.add( ( IAction ) browserActionMap.get( exportDsmlAction ) );
+        exportMenuManager.add( new Separator() );
+        exportMenuManager.add( ( IAction ) browserActionMap.get( exportCsvAction ) );
+        exportMenuManager.add( ( IAction ) browserActionMap.get( exportExcelAction ) );
+        menuManager.add( exportMenuManager );
+        menuManager.add( new Separator() );
+
+        // refresh
+        menuManager.add( ( IAction ) browserActionMap.get( refreshAction ) );
+        menuManager.add( new Separator() );
+
+        // additions
+        menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
+
+        // properties
+        menuManager.add( ( IAction ) browserActionMap.get( propertyDialogAction ) );
+
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void activateGlobalActionHandlers()
+    {
+
+        if ( actionBars != null )
+        {
+            actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), ( IAction ) browserActionMap
+                .get( copyAction ) );
+            actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), ( IAction ) browserActionMap
+                .get( pasteAction ) );
+            actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), ( IAction ) browserActionMap
+                .get( deleteAction ) );
+            actionBars.setGlobalActionHandler( ActionFactory.MOVE.getId(), ( IAction ) browserActionMap
+                .get( moveAction ) );
+            actionBars.setGlobalActionHandler( ActionFactory.RENAME.getId(), ( IAction ) browserActionMap
+                .get( renameAction ) );
+        }
+
+        super.activateGlobalActionHandlers();
+
+        ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+            ICommandService.class );
+        if ( commandService != null )
+        {
+            IAction leid = ( IAction ) browserActionMap.get( locateEntryInDitAction );
+            commandService.getCommand( leid.getActionDefinitionId() ).setHandler( new ActionHandler( leid ) );
+        }
+
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void deactivateGlobalActionHandlers()
+    {
+
+        if ( actionBars != null )
+        {
+            actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), null );
+            actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), null );
+            actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), null );
+            actionBars.setGlobalActionHandler( ActionFactory.RENAME.getId(), null );
+            actionBars.setGlobalActionHandler( ActionFactory.MOVE.getId(), null );
+        }
+
+        super.deactivateGlobalActionHandlers();
+
+        ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+            ICommandService.class );
+        if ( commandService != null )
+        {
+            IAction leid = ( IAction ) browserActionMap.get( locateEntryInDitAction );
+            commandService.getCommand( leid.getActionDefinitionId() ).setHandler( null );
+        }
+
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,92 @@
+/*
+ *  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.studio.ldapbrowser.ui.views.browser;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+
+
+/**
+ * This class implements the label decorator for the browser view. It adds
+ * an overlay image to the main image to mark search results, filtered
+ * entries and inconsistent entries.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserViewLabelDecorator extends LabelProvider implements ILightweightLabelDecorator
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public void decorate( Object element, IDecoration decoration )
+    {
+        IEntry entry = null;
+
+        if ( element instanceof ISearchResult )
+        {
+            ISearchResult searchResult = ( ISearchResult ) element;
+            entry = searchResult.getEntry();
+            decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
+                BrowserUIConstants.IMG_OVR_SEARCHRESULT ), IDecoration.BOTTOM_RIGHT );
+        }
+        else if ( element instanceof IEntry )
+        {
+            entry = ( IEntry ) element;
+            if ( entry.getChildrenFilter() != null )
+            {
+                decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
+                    BrowserUIConstants.IMG_OVR_FILTERED ), IDecoration.BOTTOM_RIGHT );
+            }
+        }
+        else
+        {
+            decoration.addOverlay( null, IDecoration.BOTTOM_RIGHT );
+        }
+
+        if ( entry != null )
+        {
+            if ( !entry.isConsistent() )
+            {
+                decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
+                    BrowserUIConstants.IMG_OVR_ERROR ), IDecoration.BOTTOM_LEFT );
+            }
+            else if ( !entry.isDirectoryEntry() )
+            {
+                decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
+                    BrowserUIConstants.IMG_OVR_WARNING ), IDecoration.BOTTOM_LEFT );
+            }
+            else
+            {
+                decoration.addOverlay( null, IDecoration.BOTTOM_LEFT );
+            }
+        }
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,521 @@
+/*
+ *  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.studio.ldapbrowser.ui.views.browser;
+
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
+import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserUniversalListener;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.BookmarkUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.BookmarkUpdateListener;
+import org.apache.directory.studio.ldapbrowser.core.events.BulkModificationEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryAddedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryMovedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryRenamedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateListener;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditor;
+import org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditorInput;
+import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditor;
+import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditorInput;
+import org.apache.directory.studio.ldapbrowser.ui.views.connection.ConnectionView;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.INullSelectionListener;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+
+
+/**
+ * The BrowserViewUniversalListener manages all events for the browser view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserViewUniversalListener extends BrowserUniversalListener implements SearchUpdateListener,
+    BookmarkUpdateListener
+{
+
+    /** This map contains all expanded elements for a particular connection */
+    private Map<IBrowserConnection, Object[]> connectionToExpandedElementsMap;
+
+    /** This map contains all selected elements for a particular connection */
+    private Map<IBrowserConnection, ISelection> connectionToSelectedElementMap;
+
+    /** The browser view */
+    private BrowserView view;
+
+    /** Token used to activate and deactivate shortcuts in the view */
+    private IContextActivation contextActivation;
+
+    /** Listener that listens for selections of connections */
+    private INullSelectionListener connectionSelectionListener = new INullSelectionListener()
+    {
+        /**
+         * {@inheritDoc}
+         *
+         * This implementation sets the input when another connection was selected.
+         */
+        public void selectionChanged( IWorkbenchPart part, ISelection selection )
+        {
+            if ( view != null && part != null )
+            {
+                if ( view.getSite().getWorkbenchWindow() == part.getSite().getWorkbenchWindow() )
+                {
+                    Connection[] connections = BrowserSelectionUtils.getConnections( selection );
+                    if ( connections.length == 1 )
+                    {
+                        IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnection(
+                            connections[0] );
+                        setInput( connection );
+                    }
+                    else
+                    {
+                        setInput( null );
+                    }
+                }
+            }
+        }
+    };
+
+    /** The part listener used to activate and deactivate the shortcuts */
+    private IPartListener2 partListener = new IPartListener2()
+    {
+        /**
+         * {@inheritDoc}
+         *
+         * This implementation deactivates the shortcuts when the part is deactivated.
+         */
+        public void partDeactivated( IWorkbenchPartReference partRef )
+        {
+            if ( partRef.getPart( false ) == view && contextActivation != null )
+            {
+
+                view.getActionGroup().deactivateGlobalActionHandlers();
+
+                IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+                    IContextService.class );
+                contextService.deactivateContext( contextActivation );
+                contextActivation = null;
+            }
+        }
+
+
+        /**
+         * {@inheritDoc}
+         *
+         * This implementation activates the shortcuts when the part is activated.
+         */
+        public void partActivated( IWorkbenchPartReference partRef )
+        {
+            if ( partRef.getPart( false ) == view )
+            {
+
+                IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+                    IContextService.class );
+                contextActivation = contextService
+                    .activateContext( BrowserCommonConstants.CONTEXT_WINDOWS );
+                // org.eclipse.ui.contexts.dialogAndWindow
+                // org.eclipse.ui.contexts.window
+                // org.eclipse.ui.text_editor_context
+
+                view.getActionGroup().activateGlobalActionHandlers();
+            }
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partBroughtToTop( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partClosed( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partOpened( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partHidden( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partVisible( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partInputChanged( IWorkbenchPartReference partRef )
+        {
+        }
+    };
+
+    /** This listener is used to ensure that the entry editor and search result editor are opened
+     when an object in the browser view is selected */
+    private ISelectionChangedListener viewerSelectionListener = new ISelectionChangedListener()
+    {
+        /**
+         * {@inheritDoc}
+         */
+        public void selectionChanged( SelectionChangedEvent event )
+        {
+            ensureEditorsVisible( event.getSelection() );
+        }
+    };
+
+
+    /**
+     * Creates a new instance of BrowserViewUniversalListener.
+     *
+     * @param view the browser view
+     */
+    public BrowserViewUniversalListener( BrowserView view )
+    {
+        super( view.getMainWidget().getViewer() );
+        this.view = view;
+
+        // create maps
+        connectionToExpandedElementsMap = new HashMap<IBrowserConnection, Object[]>();
+        connectionToSelectedElementMap = new HashMap<IBrowserConnection, ISelection>();
+
+        // register listeners
+        EventRegistry.addSearchUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() );
+        EventRegistry.addBookmarkUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() );
+        EventRegistry.addEntryUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() );
+        ConnectionEventRegistry.addConnectionUpdateListener( this, ConnectionUIPlugin.getDefault().getEventRunner() );
+
+        view.getSite().getPage().addPartListener( partListener );
+        view.getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener( ConnectionView.getId(),
+            connectionSelectionListener );
+
+        viewer.addSelectionChangedListener( viewerSelectionListener );
+    }
+
+
+    /**
+     * Ensures that the entry editor or the search result editor are
+     * opended and ready to show the given selection.
+     *
+     * @param selection the browser's selection.
+     */
+    private void ensureEditorsVisible( ISelection selection )
+    {
+        if ( view != null )
+        {
+            IEntry[] entries = BrowserSelectionUtils.getEntries( selection );
+            ISearchResult[] searchResults = BrowserSelectionUtils.getSearchResults( selection );
+            IBookmark[] bookmarks = BrowserSelectionUtils.getBookmarks( selection );
+            ISearch[] searches = BrowserSelectionUtils.getSearches( selection );
+
+            if ( entries.length + searchResults.length + bookmarks.length + searches.length == 1 )
+            {
+                if ( entries.length == 1 )
+                {
+                    try
+                    {
+                        EntryEditorInput input = new EntryEditorInput( entries[0] );
+                        view.getSite().getPage().openEditor( input, EntryEditor.getId(), false );
+                    }
+                    catch ( PartInitException e )
+                    {
+                    }
+                }
+                else if ( searchResults.length == 1 )
+                {
+                    try
+                    {
+                        EntryEditorInput input = new EntryEditorInput( searchResults[0] );
+                        view.getSite().getPage().openEditor( input, EntryEditor.getId(), false );
+                    }
+                    catch ( PartInitException e )
+                    {
+                    }
+                }
+                else if ( bookmarks.length == 1 )
+                {
+                    try
+                    {
+                        EntryEditorInput input = new EntryEditorInput( bookmarks[0] );
+                        view.getSite().getPage().openEditor( input, EntryEditor.getId(), false );
+                    }
+                    catch ( PartInitException e )
+                    {
+                    }
+                }
+                else if ( searches.length == 1 )
+                {
+                    try
+                    {
+                        SearchResultEditorInput input = new SearchResultEditorInput( searches[0] );
+                        view.getSite().getPage().openEditor( input, SearchResultEditor.getId(), false );
+                    }
+                    catch ( PartInitException e )
+                    {
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        if ( view != null )
+        {
+            EventRegistry.removeSearchUpdateListener( this );
+            EventRegistry.removeBookmarkUpdateListener( this );
+            EventRegistry.removeEntryUpdateListener( this );
+            ConnectionEventRegistry.removeConnectionUpdateListener( this );
+
+            view.getSite().getPage().removePartListener( partListener );
+            view.getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(
+                ConnectionView.getId(), connectionSelectionListener );
+
+            view = null;
+            connectionToExpandedElementsMap.clear();
+            connectionToExpandedElementsMap = null;
+            connectionToSelectedElementMap.clear();
+            connectionToSelectedElementMap = null;
+        }
+
+        super.dispose();
+    }
+
+
+    /**
+     * Sets the input to the viewer and saves/restores the expanded and selected elements.
+     *
+     * @param connection the connection input
+     */
+    void setInput( IBrowserConnection connection )
+    {
+        // only if another connection is selected
+        if ( connection != viewer.getInput() )
+        {
+
+            IBrowserConnection currentConnection = viewer.getInput() instanceof IBrowserConnection ? ( IBrowserConnection ) viewer
+                .getInput() : null;
+
+            // save expanded elements and selection
+            if ( currentConnection != null )
+            {
+                connectionToExpandedElementsMap.put( currentConnection, viewer.getExpandedElements() );
+                if ( !viewer.getSelection().isEmpty() )
+                {
+                    connectionToSelectedElementMap.put( currentConnection, viewer.getSelection() );
+                }
+            }
+
+            // change input
+            viewer.setInput( connection );
+            view.getActionGroup().setInput( connection );
+
+            // restore expanded elements and selection
+            if ( view != null && connection != null )
+            {
+                if ( connectionToExpandedElementsMap.containsKey( connection ) )
+                {
+                    viewer.setExpandedElements( ( Object[] ) connectionToExpandedElementsMap.get( connection ) );
+                }
+                if ( connectionToSelectedElementMap.containsKey( connection )
+                    && this.view.getSite().getPage().isPartVisible( view ) )
+                {
+                    viewer.setSelection( ( ISelection ) connectionToSelectedElementMap.get( connection ), true );
+                }
+            }
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionOpened(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionOpened( Connection connection )
+    {
+        IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnection(
+            connection );
+
+        // expand viewer
+        viewer.refresh( browserConnection );
+        viewer.expandToLevel( 2 );
+
+        // expand root DSE to show base entries
+        IRootDSE rootDSE = browserConnection.getRootDSE();
+        viewer.expandToLevel( rootDSE, 1 );
+
+        // expand base entries, if requested
+        if ( view.getConfiguration().getPreferences().isExpandBaseEntries() )
+        {
+            viewer.expandToLevel( rootDSE, 2 );
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionClosed(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionClosed( Connection connection )
+    {
+        IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnection(
+            connection );
+        
+        viewer.collapseAll();
+        connectionToExpandedElementsMap.remove( browserConnection );
+        connectionToSelectedElementMap.remove( browserConnection );
+        viewer.refresh( browserConnection );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     *
+     * This viewer selects the updated search.
+     */
+    public void searchUpdated( SearchUpdateEvent searchUpdateEvent )
+    {
+        ISearch search = searchUpdateEvent.getSearch();
+        viewer.refresh();
+
+        if ( Arrays.asList( search.getBrowserConnection().getSearchManager().getSearches() ).contains( search ) )
+        {
+            viewer.setSelection( new StructuredSelection( search ), true );
+        }
+        else
+        {
+            Object searchCategory = ( ( ITreeContentProvider ) viewer.getContentProvider() ).getParent( search );
+            viewer.setSelection( new StructuredSelection( searchCategory ), true );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent )
+    {
+        viewer.refresh();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     *
+     * This implementation refreshes the tree and
+     * selects an entry depending on the event type.
+     */
+    public void entryUpdated( EntryModificationEvent event )
+    {
+        // Don't handle attribute initalization, could cause double
+        // retrieval of children.
+        //
+        // When double-clicking an entry two Jobs/Threads are started:
+        // - InitializeAttributesJob and
+        // - InitializeChildrenJob
+        // If the InitializeAttributesJob is finished first the
+        // AttributesInitializedEvent is fired. If this causes
+        // a refresh of the tree before the children are initialized
+        // another InitializeChildrenJob is executed.
+        if ( event instanceof AttributesInitializedEvent )
+        {
+            return;
+        }
+
+        if ( event instanceof EntryAddedEvent )
+        {
+            viewer.refresh( event.getModifiedEntry(), true );
+            viewer.refresh( event.getModifiedEntry().getParententry(), true );
+            viewer.setSelection( new StructuredSelection( event.getModifiedEntry() ), true );
+        }
+        else if ( event instanceof EntryRenamedEvent )
+        {
+            EntryRenamedEvent ere = ( EntryRenamedEvent ) event;
+            viewer.refresh( ere.getNewEntry().getParententry(), true );
+            viewer.refresh( ere.getNewEntry(), true );
+            viewer.setSelection( new StructuredSelection( ere.getNewEntry() ), true );
+        }
+        else if ( event instanceof EntryMovedEvent )
+        {
+            EntryMovedEvent eme = ( EntryMovedEvent ) event;
+            viewer.refresh( eme.getOldEntry().getParententry(), true );
+            viewer.refresh( eme.getNewEntry().getParententry(), true );
+            viewer.refresh( eme.getNewEntry(), true );
+            viewer.setSelection( new StructuredSelection( eme.getNewEntry() ), true );
+        }
+        else if ( event instanceof BulkModificationEvent )
+        {
+            viewer.refresh();
+        }
+
+        viewer.refresh( event.getModifiedEntry(), true );
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DragListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DragListener.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DragListener.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DragListener.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,159 @@
+/*
+ *  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.studio.ldapbrowser.ui.views.browser;
+
+import org.eclipse.swt.dnd.DragSourceListener;
+
+
+/**
+ * This class implements the {@link DragSourceListener} for the browser view.
+ * 
+ * TODO: The code isn't working yet, just a test implementation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DragListener /* implements DragSourceListener */
+{
+
+    // private Clipboard systemClipboard;
+    // private InternalClipboard internalClipboard;
+    //    
+    // public DragListener(Shell shell, Clipboard systemClipboard,
+    // InternalClipboard internalClipboard) {
+    // super(shell, "Drag", null, null);
+    // this.systemClipboard = systemClipboard;
+    // this.internalClipboard = internalClipboard;
+    // }
+    // public void dispose() {
+    // this.systemClipboard = null;
+    // this.internalClipboard = null;
+    // super.dispose();
+    // }
+    // protected void updateEnabledState() {
+    // }
+    //    
+    // public void dragStart(DragSourceEvent event) {
+    // //System.out.println("dragStart: " + event);
+    //
+    // if(this.selectedEntries.length > 0 && this.selectedSearches.length ==
+    // 0 && this.selectedSearchResults.length == 0) {
+    // /*
+    // IEntry parent = this.selectedEntries[0].getParententry();
+    // for(int i=1; i<this.selectedEntries.length; i++) {
+    // if(this.selectedEntries[i].getParententry() != parent) {
+    // event.doit = false;
+    // return;
+    // }
+    // }
+    // */
+    // this.internalClipboard.newTransfer(InternalClipboard.TYPE_UNKNOWN,
+    // this.selectedEntries);
+    // event.doit = true;
+    // }
+    // else if(this.selectedSearchResults.length > 0 &&
+    // this.selectedEntries.length == 0 && this.selectedSearches.length ==
+    // 0) {
+    // /*
+    // IEntry parent =
+    // this.selectedSearchResults[0].getEntry().getParententry();
+    // for(int i=1; i<this.selectedSearchResults.length; i++) {
+    // if(this.selectedSearchResults[i].getEntry().getParententry() !=
+    // parent) {
+    // event.doit = false;
+    // return;
+    // }
+    // }
+    // */
+    // this.internalClipboard.newTransfer(InternalClipboard.TYPE_UNKNOWN,
+    // this.selectedSearchResults);
+    // event.doit = true;
+    // }
+    // else if(this.selectedSearches.length > 0 &&
+    // this.selectedEntries.length == 0 && this.selectedSearchResults.length
+    // == 0) {
+    // this.internalClipboard.newTransfer(InternalClipboard.TYPE_UNKNOWN,
+    // this.selectedSearches);
+    // event.doit = true;
+    // }
+    // else {
+    // event.doit = false;
+    // }
+    // }
+    //
+    // public void dragSetData(DragSourceEvent event) {
+    // //System.out.println("dragSetDataA: " + event);
+    // //System.out.println("dragSetDataT: " + event.dataType);
+    // //System.out.println("dragSetDataS: " +
+    // BrowserTransfer.getInstance().isSupportedType(event.dataType));
+    // //System.out.println("dragSetDataE: " +
+    // TextTransfer.getInstance().isSupportedType(event.dataType));
+    //        
+    // if (BrowserTransfer.getInstance().isSupportedType(event.dataType)) {
+    // event.data = this.internalClipboard.getClass().getName();
+    // }
+    // else if (TextTransfer.getInstance().isSupportedType(event.dataType))
+    // {
+    // String text = "";
+    // Object objectToTransfer =
+    // this.internalClipboard.getObjectToTransfer();
+    // if(objectToTransfer instanceof IEntry[]) {
+    // IEntry[] entries = (IEntry[])objectToTransfer;
+    // if(entries.length > 0) {
+    // text = entries[0].getDn().toString();
+    // for(int i=1; i<entries.length; i++) {
+    // text += "\n"+entries[i].getDn().toString();
+    // }
+    // }
+    // }
+    // else if(objectToTransfer instanceof ISearchResult[]) {
+    // ISearchResult[] searchresults = (ISearchResult[])objectToTransfer;
+    // if(searchresults.length > 0) {
+    // text = searchresults[0].getDn().toString();
+    // for(int i=1; i<searchresults.length; i++) {
+    // text += "\n"+searchresults[i].getDn().toString();
+    // }
+    // }
+    // }
+    // else if(objectToTransfer instanceof ISearch[]) {
+    // ISearch[] searches = (ISearch[])objectToTransfer;
+    // if(searches.length > 0) {
+    // text = searches[0].getName();
+    // for(int i=1; i<searches.length; i++) {
+    // text += "\n"+searches[i].getName();
+    // }
+    // }
+    // }
+    // event.data = text;
+    // }
+    // else {
+    // event.data = null;
+    // }
+    //        
+    // //System.out.println("dragSetData2: " + event);
+    // }
+    //
+    // public void dragFinished(org.eclipse.swt.dnd.DragSourceEvent event) {
+    // //System.out.println("dragFinished: " + event);
+    // this.internalClipboard.clear();
+    // }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DragListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DropListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DropListener.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DropListener.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DropListener.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,276 @@
+/*
+ *  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.studio.ldapbrowser.ui.views.browser;
+
+import org.eclipse.swt.dnd.DropTargetListener;
+
+
+/**
+ * This class implements the {@link DropTargetListener} for the browser view.
+ * 
+ * TODO: The code isn't working yet, just a test implementation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DropListener /* implements DropTargetListener, ModelModifier */
+{/*
+ * 
+ * private Shell shell; private Clipboard systemClipboard; private
+ * InternalClipboard internalClipboard;
+ * 
+ * 
+ * public DropListener(Shell shell, Clipboard systemClipboard,
+ * InternalClipboard internalClipboard) { this.shell = shell;
+ * this.systemClipboard = systemClipboard; this.internalClipboard =
+ * internalClipboard;
+ *  } public void dispose() { this.shell = null; this.systemClipboard =
+ * null; this.internalClipboard = null;
+ *  }
+ * 
+ * private int dragOperation = DND.DROP_NONE;
+ * 
+ * public void dragEnter(DropTargetEvent event) {
+ * //System.out.println("dragEnter: " + event.detail); dragOperation =
+ * event.detail; event.currentDataType =
+ * BrowserTransfer.getInstance().getSupportedTypes()[0];
+ * this.check(event); }
+ * 
+ * public void dragLeave(DropTargetEvent event) {
+ * //System.out.println("dragLeave: " + event.detail); dragOperation =
+ * DND.DROP_NONE; }
+ * 
+ * public void dragOperationChanged(DropTargetEvent event) {
+ * //System.out.println("dragOperationChanged: " + event.detail);
+ * dragOperation = event.detail; this.check(event); }
+ * 
+ * public void dragOver(DropTargetEvent event) {
+ * //System.out.println("dragOver: " + event.item.getData());
+ * 
+ * this.check(event);
+ * 
+ * //System.out.println("dragOver: " + event.detail);
+ * 
+ * //System.out.println();
+ * //System.out.println(event.item.getClass().getName());
+ * //System.out.println(event.item.getData().getClass().getName());
+ * //System.out.println(event.currentDataType.type); }
+ * 
+ * private void check(DropTargetEvent event) { if(event.item != null &&
+ * event.item.getData() != null) { if
+ * (BrowserTransfer.getInstance().isSupportedType(event.currentDataType)) {
+ * if(event.item.getData() instanceof ISearch &&
+ * this.internalClipboard.getObjectToTransfer() instanceof ISearch[]) {
+ * event.detail = dragOperation; return; } else if(event.item.getData()
+ * instanceof BrowserCategory &&
+ * ((BrowserCategory)event.item.getData()).getType() ==
+ * BrowserCategory.TYPE_SEARCHES &&
+ * this.internalClipboard.getObjectToTransfer() instanceof ISearch[]) {
+ * event.detail = dragOperation; return; } else if(event.item.getData()
+ * instanceof IEntry && this.internalClipboard.getObjectToTransfer()
+ * instanceof IEntry[]) { event.detail = dragOperation;
+ * 
+ * IEntry[] entries =
+ * (IEntry[])this.internalClipboard.getObjectToTransfer(); for(int i=0;
+ * i<entries.length; i++) { if(entries[i].hasChildren()) { event.detail =
+ * DND.DROP_COPY; return; } }
+ * 
+ * return; } else if(event.item.getData() instanceof IEntry &&
+ * this.internalClipboard.getObjectToTransfer() instanceof
+ * ISearchResult[]) { event.detail = dragOperation;
+ * 
+ * ISearchResult[] srs =
+ * (ISearchResult[])this.internalClipboard.getObjectToTransfer();
+ * for(int i=0; i<srs.length; i++) {
+ * if(!srs[i].getEntry().hasChildren()) { event.detail = DND.DROP_COPY;
+ * return; } }
+ * 
+ * return; } else { event.detail = DND.DROP_NONE; } } else {
+ * event.detail = DND.DROP_NONE; } } else { event.detail =
+ * DND.DROP_NONE; } }
+ * 
+ * public void drop(DropTargetEvent event) {
+ * 
+ * //System.out.println("drop: " + event);
+ * 
+ * try {
+ * 
+ * if
+ * (BrowserTransfer.getInstance().isSupportedType(event.currentDataType) &&
+ * event.data instanceof String &&
+ * this.internalClipboard.getClass().getName().equals(event.data)) {
+ * 
+ * if(event.detail == DND.DROP_MOVE) {
+ * this.internalClipboard.setOperationType(InternalClipboard.TYPE_MOVE_OPERATION); }
+ * else if(event.detail == DND.DROP_COPY) {
+ * this.internalClipboard.setOperationType(InternalClipboard.TYPE_DUPLICATE_OPERATION); }
+ * else {
+ * this.internalClipboard.setOperationType(InternalClipboard.TYPE_UNKNOWN); }
+ * 
+ * 
+ * ISearch[] selectedSearches = new ISearch[0]; IEntry[] selectedEntries =
+ * new IEntry[0]; ISearchResult[] selectedSearchResults = new
+ * ISearchResult[0]; BrowserCategory[] selectedBrowserViewCategories =
+ * new BrowserCategory[0];
+ * 
+ * if (event.item != null && event.item.getData() instanceof ISearch) {
+ * selectedSearches = new ISearch[]{(ISearch) event.item.getData()}; }
+ * else if (event.item != null && event.item.getData() instanceof
+ * IEntry) { selectedEntries = new IEntry[]{(IEntry)
+ * event.item.getData()}; } else if (event.item != null &&
+ * event.item.getData() instanceof ISearchResult) {
+ * selectedSearchResults = new ISearchResult[]{(ISearchResult)
+ * event.item.getData()}; } else if (event.item != null &&
+ * event.item.getData() instanceof BrowserCategory) {
+ * selectedBrowserViewCategories = new
+ * BrowserCategory[]{(BrowserCategory) event.item.getData()}; }
+ * 
+ * this.runPaste(this.internalClipboard, selectedSearches,
+ * selectedEntries, selectedSearchResults,
+ * selectedBrowserViewCategories);
+ * 
+ * 
+ *  // // get search to handle and its search manager // ISearch[]
+ * searches = (ISearch[]) event.data; // for(int i=0; i<searches.length;
+ * i++) { // ISearch search = searches[i]; // IConnection connection =
+ * search.getConnection(); // SearchManager dragSearchManager =
+ * connection.getSearchManager(); // // // get position // //int
+ * position = dragSearchManager.indexOf(search); // // // get drop
+ * search manager and drop position, // // default is last and the drop
+ * search // int dropPosition = -1; // SearchManager dropSearchManager =
+ * null; // if (event.item != null && event.item.getData() instanceof
+ * ISearch) { // ISearch dropSearch = (ISearch) event.item.getData(); //
+ * dropSearchManager = dropSearch.getConnection().getSearchManager(); //
+ * dropPosition = dropSearchManager.indexOf(dropSearch); // } else { //
+ * dropSearchManager = this.selectedConnection.getSearchManager(); //
+ * dropPosition = dropSearchManager.getSearchCount(); // } // if
+ * (dropPosition == -1) { // dropSearchManager = dragSearchManager; //
+ * dropPosition = dragSearchManager.getSearchCount(); // } // // // if
+ * MOVE operation, first remove from old position // if (event.detail ==
+ * DND.DROP_MOVE && dragSearchManager == dropSearchManager) { //
+ * dragSearchManager.removeSearch(search); //
+ * if(dropPosition>dragSearchManager.getSearchCount()) { //
+ * dropPosition--; // } // dropSearchManager.addSearch(dropPosition,
+ * search); // event.detail = DND.DROP_NONE; // // } else if
+ * (event.detail == DND.DROP_COPY || // (event.detail == DND.DROP_MOVE &&
+ * dragSearchManager != dropSearchManager)) { // ISearch newSearch =
+ * (ISearch) search.clone(); //
+ * newSearch.setConnection(dropSearchManager.getConnection()); //
+ * dropSearchManager.addSearch(dropPosition, newSearch); // // } // else { //
+ * event.detail = DND.DROP_NONE; // } // } } } catch (Exception e) {
+ * event.detail = DND.DROP_NONE; e.printStackTrace(); }
+ *  }
+ * 
+ * public void dropAccept(DropTargetEvent event) {
+ * //System.out.println("dropAccept: " + event.detail + event.feedback);
+ * event.currentDataType =
+ * BrowserTransfer.getInstance().getSupportedTypes()[0]; check(event); }
+ * 
+ * 
+ * 
+ * 
+ * public void runPaste(InternalClipboard internalClipboard, ISearch[]
+ * selectedSearches, IEntry[] selectedEntries, ISearchResult[]
+ * selectedSearchResults, BrowserCategory[]
+ * selectedBrowserViewCategories) { Object objectToTransfer =
+ * internalClipboard.getObjectToTransfer();
+ * 
+ * if (objectToTransfer != null && objectToTransfer instanceof ISearch[] &&
+ * selectedSearches.length > 0 && selectedEntries.length == 0 &&
+ * selectedSearchResults.length == 0) { ISearch[] searchesToTransfer =
+ * (ISearch[]) objectToTransfer; if (searchesToTransfer != null &&
+ * searchesToTransfer.length > 0) { ISearch pasteSearch =
+ * selectedSearches[selectedSearches.length-1]; IConnection connection =
+ * pasteSearch.getConnection(); SearchManager searchManager =
+ * connection.getSearchManager();
+ * 
+ * int index = searchManager.indexOf(pasteSearch);
+ * 
+ * for(int i=0; i<searchesToTransfer.length; i++) { ISearch newSearch =
+ * (ISearch) searchesToTransfer[i].clone();
+ * newSearch.setConnection(connection);
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_DUPLICATE_OPERATION) {
+ * searchManager.addSearch(index+1+i, newSearch); } else
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) {
+ * searchesToTransfer[i].getConnection().getSearchManager().removeSearch(searchesToTransfer[i].getName());
+ * searchManager.addSearch(index+i, newSearch);
+ * if(searchManager.indexOf(pasteSearch) < index) { index =
+ * searchManager.indexOf(pasteSearch); } } } } } else if
+ * (objectToTransfer != null && objectToTransfer instanceof ISearch[] &&
+ * selectedBrowserViewCategories.length == 1 &&
+ * selectedBrowserViewCategories[0].getType()==BrowserCategory.TYPE_SEARCHES) {
+ * ISearch[] searchesToTransfer = (ISearch[]) objectToTransfer; if
+ * (searchesToTransfer != null && searchesToTransfer.length > 0) {
+ * IConnection connection =
+ * selectedBrowserViewCategories[0].getParent(); SearchManager
+ * searchManager = connection.getSearchManager(); for(int i=0; i<searchesToTransfer.length;
+ * i++) { ISearch newSearch = (ISearch) searchesToTransfer[i].clone();
+ * newSearch.setConnection(connection);
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_DUPLICATE_OPERATION) {
+ * searchManager.addSearch(searchManager.getSearchCount(), newSearch); }
+ * else if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) {
+ * searchesToTransfer[i].getConnection().getSearchManager().removeSearch(searchesToTransfer[i].getName());
+ * searchManager.addSearch(searchManager.getSearchCount(), newSearch); } } } }
+ * else if (objectToTransfer != null && objectToTransfer instanceof
+ * IEntry[] && selectedEntries.length == 1 && selectedSearches.length ==
+ * 0 && selectedSearchResults.length == 0) { IEntry[] entries =
+ * (IEntry[]) objectToTransfer; if (entries != null && entries.length >
+ * 0) { if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_DUPLICATE_OPERATION) new
+ * CopyEntriesJob(selectedEntries[0], entries).execute(); else
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) this.move(selectedEntries[0],
+ * entries); } } else if (objectToTransfer != null && objectToTransfer
+ * instanceof ISearchResult[] && selectedEntries.length == 1 &&
+ * selectedSearches.length == 0 && selectedSearchResults.length == 0) {
+ * ISearchResult[] searchResults = (ISearchResult[]) objectToTransfer;
+ * IEntry[] entries = new IEntry[searchResults.length]; for(int i=0; i<searchResults.length;
+ * i++) { entries[i] = searchResults[i].getEntry(); } if (entries !=
+ * null && entries.length > 0) { if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_DUPLICATE_OPERATION) new
+ * CopyEntriesJob(selectedEntries[0], entries).execute(); else
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) this.move(selectedEntries[0],
+ * entries); } }
+ * 
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) { internalClipboard.clear(); } }
+ * 
+ * private void move (final IEntry newParent, final IEntry[]
+ * entriesToMove) {
+ * 
+ * for(int i=0; i<entriesToMove.length; i++) { try {
+ * entriesToMove[i].moveTo(newParent, this); }
+ * catch(ModelModificationException mme) {
+ * BrowserUIPlugin.getDefault().getExceptionHandler().handleException(mme.getMessage(),
+ * mme); } catch(Exception e) {
+ * BrowserUIPlugin.getDefault().getExceptionHandler().handleException(e.getMessage(),
+ * e); } }
+ * 
+ * //EventRegistry.fireEntryUpdated(new
+ * ChildrenInitializedEvent(newParent, newParent.getConnection()),
+ * this); }
+ */
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DropListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/LinkWithEditorAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/LinkWithEditorAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/LinkWithEditorAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/LinkWithEditorAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,229 @@
+/*
+ *  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.studio.ldapbrowser.ui.views.browser;
+
+
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditor;
+import org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditorInput;
+import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditor;
+import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditorInput;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+
+
+/**
+ * This class implements the Link With Editor Action for the Browser View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LinkWithEditorAction extends Action
+{
+    /** The browser view */
+    private BrowserView browserView;
+
+    /** The listener listening on changes on editors */
+    private IPartListener2 editorListener = new IPartListener2()
+    {
+        /**
+         * {@inheritDoc}
+         */
+        public void partBroughtToTop( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partActivated( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partClosed( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partDeactivated( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partHidden( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partInputChanged( IWorkbenchPartReference partRef )
+        {
+            linkViewWithEditor( partRef.getPart( false ) );
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partOpened( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partVisible( IWorkbenchPartReference partRef )
+        {
+        }
+    };
+
+
+    /**
+     * Creates a new instance of LinkWithEditorAction.
+     *
+     * @param browserView
+     *      the associated view
+     */
+    public LinkWithEditorAction( BrowserView browserView )
+    {
+        super( "Link with editor", AS_CHECK_BOX );
+        setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LINK_WITH_EDITOR ) );
+        setEnabled( true );
+        setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+            BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR ) );
+        this.browserView = browserView;
+
+        // Enable the listeners
+        if ( isChecked() )
+        {
+            browserView.getSite().getWorkbenchWindow().getPartService().addPartListener( editorListener );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        setChecked( isChecked() );
+        BrowserUIPlugin.getDefault().getPreferenceStore().setValue(
+            BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR, isChecked() );
+
+        if ( isChecked() )
+        {
+            // Enable the listener
+            browserView.getSite().getWorkbenchWindow().getPartService().addPartListener( editorListener );
+
+            // link
+            IEditorPart activeEditor = browserView.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
+            linkViewWithEditor( activeEditor );
+        }
+        else
+        {
+            // Disable the listener
+            browserView.getSite().getWorkbenchWindow().getPartService().removePartListener( editorListener );
+        }
+    }
+
+
+    /**
+     * Links the view with the right editor
+     *
+     * @param partRef the part
+     */
+    private void linkViewWithEditor( IWorkbenchPart part )
+    {
+        if ( part != null && browserView != null
+            && part.getSite().getWorkbenchWindow() == browserView.getSite().getWorkbenchWindow() )
+        {
+            Object objectToSelect = null;
+
+            if ( part instanceof EntryEditor )
+            {
+                EntryEditor editor = ( EntryEditor ) part;
+                IEditorInput input = editor.getEditorInput();
+                if ( input != null && input instanceof EntryEditorInput )
+                {
+                    EntryEditorInput eei = ( EntryEditorInput ) input;
+                    objectToSelect = eei.getInput();
+                }
+            }
+            else if ( part instanceof SearchResultEditor )
+            {
+                SearchResultEditor editor = ( SearchResultEditor ) part;
+                IEditorInput input = editor.getEditorInput();
+                if ( input != null && input instanceof SearchResultEditorInput )
+                {
+                    SearchResultEditorInput srei = ( SearchResultEditorInput ) input;
+                    objectToSelect = srei.getSearch();
+                }
+            }
+
+            if ( objectToSelect != null )
+            {
+                // do not select if already selected!
+                // necessary to avoid infinite loops!
+                IStructuredSelection selection = ( IStructuredSelection ) browserView.getMainWidget().getViewer()
+                    .getSelection();
+                if ( selection.size() != 1 || !selection.getFirstElement().equals( objectToSelect ) )
+                {
+                    browserView.select( objectToSelect );
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Disposes this action.
+     */
+    public void dispose()
+    {
+        if ( editorListener != null )
+        {
+            browserView.getSite().getWorkbenchWindow().getPartService().removePartListener( editorListener );
+            editorListener = null;
+        }
+
+        browserView = null;
+    }
+
+}

Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/LinkWithEditorAction.java
------------------------------------------------------------------------------
    svn:eol-style = native