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 [2/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/BrowserUIPreferencesInitializer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPreferencesInitializer.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPreferencesInitializer.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/BrowserUIPreferencesInitializer.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,53 @@
+/*
+ *  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;
+
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+
+/**
+ * This class is used to set default preference values.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserUIPreferencesInitializer extends AbstractPreferenceInitializer
+{
+    /**
+     * {@inheritDoc}
+     */
+    public void initializeDefaultPreferences()
+    {
+
+        IPreferenceStore store = BrowserUIPlugin.getDefault().getPreferenceStore();
+
+        // Browser
+        store.setDefault( BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR, true );
+
+        // Search Result Editor
+        store.setDefault( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN, true );
+        store.setDefault( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS, true );
+
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyAttributeDescriptionAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyAttributeDescriptionAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyAttributeDescriptionAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyAttributeDescriptionAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,149 @@
+/*
+ *  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.actions;
+
+
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+
+
+/**
+ * This class implements the Copy Attribute Description Action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CopyAttributeDescriptionAction extends BrowserAction
+{
+
+    /**
+     * Creates a new instance of CopyAttributeDescriptionAction.
+     */
+    public CopyAttributeDescriptionAction()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        StringBuffer text = new StringBuffer();
+        for ( Iterator iterator = getAttributeNameSet().iterator(); iterator.hasNext(); )
+        {
+            text.append( iterator.next() );
+            if ( iterator.hasNext() )
+                text.append( BrowserCoreConstants.LINE_SEPARATOR );
+        }
+
+        if ( text.length() > 0 )
+        {
+            CopyAction.copyToClipboard( new Object[]
+                { text.toString() }, new Transfer[]
+                { TextTransfer.getInstance() } );
+        }
+    }
+
+
+    /**
+     * Gets a Set containing all the Attribute Names.
+     *
+     * @return
+     *      a Set containing all the Attribute Names
+     */
+    private Set getAttributeNameSet()
+    {
+        Set<String> attributeNameSet = new LinkedHashSet<String>();
+        for ( int i = 0; i < getSelectedAttributeHierarchies().length; i++ )
+        {
+            for ( Iterator it = getSelectedAttributeHierarchies()[i].iterator(); it.hasNext(); )
+            {
+                IAttribute att = ( IAttribute ) it.next();
+                attributeNameSet.add( att.getDescription() );
+            }
+        }
+        for ( int i = 0; i < getSelectedAttributes().length; i++ )
+        {
+            attributeNameSet.add( getSelectedAttributes()[i].getDescription() );
+        }
+        for ( int i = 0; i < getSelectedValues().length; i++ )
+        {
+            attributeNameSet.add( getSelectedValues()[i].getAttribute().getDescription() );
+        }
+        return attributeNameSet;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        if ( getAttributeNameSet().size() > 1 )
+        {
+            return "Copy Attribute Descriptions";
+        }
+        else
+        {
+            return "Copy Attribute Description";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_ATT );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getAttributeNameSet().size() > 0;
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyDnAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyDnAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyDnAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyDnAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,125 @@
+/*
+ *  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.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+
+
+/**
+ * This class implements the Copy Drag'n'Drop Action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CopyDnAction extends BrowserAction
+{
+
+    /**
+     * Creates a new instance of CopyDnAction.
+     */
+    public CopyDnAction()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        String dn = null;
+        if ( getSelectedEntries().length > 0 )
+        {
+            dn = getSelectedEntries()[0].getDn().getUpName();
+        }
+        else if ( getSelectedAttributes().length > 0 )
+        {
+            dn = getSelectedAttributes()[0].getEntry().getDn().getUpName();
+        }
+        else if ( getSelectedAttributeHierarchies().length > 0 )
+        {
+            dn = getSelectedAttributeHierarchies()[0].getAttribute().getEntry().getDn().getUpName();
+        }
+        else if ( getSelectedValues().length > 0 )
+        {
+            dn = getSelectedValues()[0].getAttribute().getEntry().getDn().getUpName();
+        }
+        else if ( getSelectedSearchResults().length > 0 )
+        {
+            dn = getSelectedSearchResults()[0].getDn().getUpName();
+        }
+        else if ( getSelectedBookmarks().length > 0 )
+        {
+            dn = getSelectedBookmarks()[0].getDn().getUpName();
+        }
+
+        if ( dn != null )
+        {
+            CopyAction.copyToClipboard( new Object[]
+                { dn }, new Transfer[]
+                { TextTransfer.getInstance() } );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Copy DN";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_DN );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 1
+            || getSelectedAttributes().length + getSelectedValues().length > 0;
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,279 @@
+/*
+ *  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.actions;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.common.jobs.RunnableContextJobAdapter;
+import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesJob;
+import org.apache.directory.studio.ldapbrowser.core.jobs.ReadEntryJob;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * This abstract class must be extended by each Action that <em>"Copies an Entry as..."</em>.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class CopyEntryAsAction extends BrowserAction
+{
+    /**
+     * Returns DN only Mode.
+     */
+    public static final int MODE_DN_ONLY = 1;
+
+    /**
+     * Returns Attributes only Mode.
+     */
+    public static final int MODE_RETURNING_ATTRIBUTES_ONLY = 2;
+
+    /**
+     * Normal Mode
+     */
+    public static final int MODE_NORMAL = 3;
+
+    /**
+     * Includes Operational Attributes Mode.
+     */
+    public static final int MODE_INCLUDE_OPERATIONAL_ATTRIBUTES = 4;
+
+    protected int mode;
+
+    protected String type;
+
+    protected String appendix;
+
+
+    /**
+     * Creates a new instance of CopyEntryAsAction.
+     *
+     * @param type
+     *      the type of the target
+     * @param mode
+     *      the copy Mode
+     */
+    public CopyEntryAsAction( String type, int mode )
+    {
+        super();
+        this.type = type;
+        this.mode = mode;
+        if ( this.mode == MODE_DN_ONLY )
+        {
+            this.appendix = " (DN only)";
+        }
+        else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY )
+        {
+            this.appendix = " (returning attributes only)";
+        }
+        else if ( this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES )
+        {
+            this.appendix = " (include operational attributes)";
+        }
+        else if ( this.mode == MODE_NORMAL )
+        {
+            this.appendix = " (all user attributes)";
+        }
+        else
+        {
+            appendix = "";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        if ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length > 0
+            && getSelectedSearches().length == 0 )
+        {
+            String text = ( getSelectedEntries().length + getSelectedSearchResults().length
+                + getSelectedBookmarks().length > 1 ? "Copy Entries as " + type : "Copy Entry as " + type )
+                + appendix;
+            return text;
+        }
+        else if ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 0
+            && getSelectedSearches().length == 1 && getSelectedSearches()[0].getSearchResults() != null
+            && getSelectedSearches()[0].getSearchResults().length > 0 )
+        {
+            String text = ( getSelectedSearches()[0].getSearchResults().length > 1 ? "Copy Search Results as " + type
+                : "Copy Search Result as " + type )
+                + appendix;
+            return text;
+        }
+
+        return "Copy Entry as " + type + appendix;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        // entries to copy
+        List<IEntry> entryList = new ArrayList<IEntry>();
+        for ( int i = 0; i < getSelectedEntries().length; i++ )
+        {
+            entryList.add( getSelectedEntries()[i] );
+        }
+        for ( int i = 0; i < getSelectedSearchResults().length; i++ )
+        {
+            entryList.add( getSelectedSearchResults()[i].getEntry() );
+        }
+        for ( int i = 0; i < getSelectedBookmarks().length; i++ )
+        {
+            IEntry entry = getSelectedBookmarks()[0].getBrowserConnection().getEntryFromCache(
+                getSelectedBookmarks()[0].getDn() );
+            if ( entry == null )
+            {
+                ReadEntryJob job = new ReadEntryJob( getSelectedBookmarks()[0].getBrowserConnection(),
+                    getSelectedBookmarks()[0].getDn() );
+                RunnableContextJobAdapter.execute( job );
+                entry = job.getReadEntry();
+            }
+            entryList.add( entry );
+        }
+        if ( getSelectedSearches().length == 1 )
+        {
+            ISearchResult[] results = getSelectedSearches()[0].getSearchResults();
+            for ( int k = 0; k < results.length; k++ )
+            {
+                entryList.add( results[k].getEntry() );
+            }
+        }
+        IEntry[] entries = ( IEntry[] ) entryList.toArray( new IEntry[entryList.size()] );
+
+        // check uninitialized entries
+        List<IEntry> uninitializedEntryList = new ArrayList<IEntry>();
+        for ( int i = 0; entries != null && i < entries.length; i++ )
+        {
+            if ( !entries[i].isAttributesInitialized() )
+            {
+                uninitializedEntryList.add( entries[i] );
+            }
+        }
+        if ( uninitializedEntryList.size() > 0
+            && ( this.mode == MODE_NORMAL || this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) )
+        {
+            IEntry[] uninitializedEntries = ( IEntry[] ) uninitializedEntryList
+                .toArray( new IEntry[uninitializedEntryList.size()] );
+
+            InitializeAttributesJob job = new InitializeAttributesJob( uninitializedEntries, false );
+            RunnableContextJobAdapter.execute( job );
+
+            // SyncInitializeEntryJob job = new
+            // SyncInitializeEntryJob(uninitializedEntries,
+            // InitializeEntryJob.INIT_ATTRIBUTES_MODE, null);
+            // job.execute();
+        }
+
+        // serialize
+        StringBuffer text = new StringBuffer();
+        serialializeEntries( entries, text );
+        copyToClipboard( text.toString() );
+    }
+
+
+    /**
+     * Serializes Entries.
+     *
+     * @param entries
+     *      the Entries to serialize
+     * @param text
+     *      the StringBuffer to serialize to
+     */
+    protected abstract void serialializeEntries( IEntry[] entries, StringBuffer text );
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        boolean showOperational = BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
+            BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES );
+
+        if ( getSelectedSearchResults().length > 0
+            && getSelectedEntries().length + getSelectedBookmarks().length + getSelectedSearches().length == 0 )
+        {
+            return ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY || this.mode == MODE_NORMAL
+                || this.mode == MODE_DN_ONLY || ( this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES && showOperational ) );
+        }
+        if ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length > 0
+            && getSelectedSearches().length == 0 )
+        {
+            return ( this.mode == MODE_NORMAL || this.mode == MODE_DN_ONLY || ( this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES && showOperational ) );
+        }
+        if ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 0
+            && getSelectedSearches().length == 1 && getSelectedSearches()[0].getSearchResults() != null
+            && getSelectedSearches()[0].getSearchResults().length > 0 )
+        {
+            return ( this.mode != MODE_INCLUDE_OPERATIONAL_ATTRIBUTES || ( this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES && showOperational ) );
+        }
+        return false;
+    }
+
+
+    /**
+     * Copies text to Clipboard
+     *
+     * @param text
+     *      the Text to copy
+     */
+    protected void copyToClipboard( String text )
+    {
+        Clipboard clipboard = null;
+        try
+        {
+            clipboard = new Clipboard( Display.getCurrent() );
+            clipboard.setContents( new Object[]
+                { text }, new Transfer[]
+                { TextTransfer.getInstance() } );
+        }
+        finally
+        {
+            if ( clipboard != null )
+                clipboard.dispose();
+        }
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsCsvAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsCsvAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsCsvAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsCsvAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,354 @@
+/*
+ *  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.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+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.core.utils.AttributeComparator;
+import org.apache.directory.studio.ldapbrowser.core.utils.LdifUtils;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * This Action copies entry(ies) as CSV.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CopyEntryAsCsvAction extends CopyEntryAsAction
+{
+    /**
+     * Table Mode.
+     */
+    public static final int MODE_TABLE = 5;
+
+
+    /**
+     * Creates a new instance of CopyEntryAsCsvAction.
+     *
+     * @param mode
+     *      the copy Mode
+     */
+    public CopyEntryAsCsvAction( int mode )
+    {
+        super( "CSV", mode );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        if ( this.mode == MODE_DN_ONLY )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV );
+        }
+        else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV_SEARCHRESULT );
+        }
+        else if ( this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV_OPERATIONAL );
+        }
+        else if ( this.mode == MODE_NORMAL )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV_USER );
+        }
+        else if ( this.mode == MODE_TABLE )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_TABLE );
+        }
+        else
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        if ( this.mode == MODE_TABLE )
+        {
+            return "Copy Table";
+        }
+
+        return super.getText();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        if ( this.mode == MODE_TABLE )
+        {
+            return getInput() != null && getInput() instanceof ISearch
+                && ( ( ISearch ) getInput() ).getSearchResults() != null
+                && ( ( ISearch ) getInput() ).getSearchResults().length > 0;
+        }
+
+        return super.isEnabled();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+
+        if ( this.mode == MODE_TABLE )
+        {
+            if ( getInput() != null && getInput() instanceof ISearch
+                && ( ( ISearch ) getInput() ).getSearchResults() != null
+                && ( ( ISearch ) getInput() ).getSearchResults().length > 0 )
+            {
+                List<IEntry> entryList = new ArrayList<IEntry>();
+                ISearchResult[] results = ( ( ISearch ) getInput() ).getSearchResults();
+                for ( int k = 0; k < results.length; k++ )
+                {
+                    entryList.add( results[k].getEntry() );
+                }
+                IEntry[] entries = ( IEntry[] ) entryList.toArray( new IEntry[entryList.size()] );
+
+                StringBuffer text = new StringBuffer();
+                serialializeEntries( entries, text );
+                copyToClipboard( text.toString() );
+            }
+        }
+        else
+        {
+            super.run();
+        }
+
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void serialializeEntries( IEntry[] entries, StringBuffer text )
+    {
+
+        String attributeDelimiter = BrowserCommonActivator.getDefault().getPreferenceStore().getString(
+            BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_ATTRIBUTEDELIMITER );
+        String valueDelimiter = BrowserCommonActivator.getDefault().getPreferenceStore().getString(
+            BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_VALUEDELIMITER );
+        String quoteCharacter = BrowserCommonActivator.getDefault().getPreferenceStore().getString(
+            BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_QUOTECHARACTER );
+        String lineSeparator = BrowserCommonActivator.getDefault().getPreferenceStore().getString(
+            BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_LINESEPARATOR );
+        int binaryEncoding = BrowserCommonActivator.getDefault().getPreferenceStore().getInt(
+            BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_BINARYENCODING );
+
+        String[] returningAttributes = null;
+        if ( this.mode == MODE_DN_ONLY )
+        {
+            returningAttributes = new String[0];
+        }
+        else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY && getSelectedSearchResults().length > 0
+            && getSelectedEntries().length + getSelectedBookmarks().length + getSelectedSearches().length == 0 )
+        {
+            returningAttributes = getSelectedSearchResults()[0].getSearch().getReturningAttributes();
+        }
+        else if ( ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY || this.mode == MODE_TABLE )
+            && getSelectedSearches().length == 1 )
+        {
+            returningAttributes = getSelectedSearches()[0].getReturningAttributes();
+        }
+        else if ( ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY || this.mode == MODE_TABLE )
+            && ( getInput() instanceof ISearch ) )
+        {
+            returningAttributes = ( ( ISearch ) ( getInput() ) ).getReturningAttributes();
+        }
+        else
+        {
+            Map<String, IAttribute> attributeMap = new HashMap<String, IAttribute>();
+            for ( int e = 0; entries != null && e < entries.length; e++ )
+            {
+                IAttribute[] attributes = entries[e].getAttributes();
+                for ( int a = 0; attributes != null && a < attributes.length; a++ )
+                {
+
+                    if ( attributes[a].isOperationalAttribute() && this.mode != MODE_INCLUDE_OPERATIONAL_ATTRIBUTES )
+                        continue;
+
+                    if ( !attributeMap.containsKey( attributes[a].getDescription() ) )
+                    {
+                        attributeMap.put( attributes[a].getDescription(), attributes[a] );
+                    }
+                }
+            }
+            IAttribute[] attributes = ( IAttribute[] ) attributeMap.values().toArray(
+                new IAttribute[attributeMap.size()] );
+
+            if ( attributes.length > 0 )
+            {
+                AttributeComparator comparator = new AttributeComparator( entries[0].getBrowserConnection() );
+                Arrays.sort( attributes, comparator );
+            }
+
+            returningAttributes = new String[attributes.length];
+            for ( int i = 0; i < attributes.length; i++ )
+            {
+                returningAttributes[i] = attributes[i].getDescription();
+            }
+        }
+
+        // header
+        if ( this.mode != MODE_TABLE
+            || BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+                BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) )
+        {
+            text.append( quoteCharacter );
+            text.append( "DN" );
+            text.append( quoteCharacter );
+            text.append( attributeDelimiter );
+        }
+        for ( int a = 0; returningAttributes != null && a < returningAttributes.length; a++ )
+        {
+            text.append( quoteCharacter );
+            text.append( returningAttributes[a] );
+            text.append( quoteCharacter );
+            if ( a + 1 < returningAttributes.length )
+            {
+                text.append( attributeDelimiter );
+            }
+        }
+        text.append( lineSeparator );
+
+        for ( int e = 0; entries != null && e < entries.length; e++ )
+        {
+
+            if ( this.mode != MODE_TABLE
+                || BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+                    BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) )
+            {
+                text.append( quoteCharacter );
+                text.append( entries[e].getDn().getUpName() );
+                text.append( quoteCharacter );
+                text.append( attributeDelimiter );
+
+            }
+            for ( int a = 0; returningAttributes != null && a < returningAttributes.length; a++ )
+            {
+
+                AttributeComparator comparator = new AttributeComparator( entries[e] );
+                AttributeHierarchy ah = entries[e].getAttributeWithSubtypes( returningAttributes[a] );
+                if ( ah != null )
+                {
+
+                    StringBuffer valueSB = new StringBuffer();
+
+                    for ( Iterator it = ah.iterator(); it.hasNext(); )
+                    {
+                        IAttribute attribute = ( IAttribute ) it.next();
+                        if ( attribute != null )
+                        {
+
+                            IValue[] values = attribute.getValues();
+                            Arrays.sort( values, comparator );
+
+                            for ( int v = 0; v < values.length; v++ )
+                            {
+                                String val = LdifUtils.getStringValue( values[v], binaryEncoding );
+                                valueSB.append( val );
+                                if ( v + 1 < values.length )
+                                {
+                                    valueSB.append( valueDelimiter );
+                                }
+                            }
+                        }
+
+                        if ( it.hasNext() )
+                        {
+                            valueSB.append( valueDelimiter );
+                        }
+                    }
+
+                    String value = valueSB.toString().replaceAll( quoteCharacter, quoteCharacter + quoteCharacter );
+                    text.append( quoteCharacter );
+                    text.append( value );
+                    text.append( quoteCharacter );
+
+                }
+
+                // IAttribute attribute =
+                // entries[e].getAttribute(returningAttributes[a]);
+                // if (attribute != null) {
+                //
+                // IValue[] values = attribute.getValues();
+                // Arrays.sort(values, comparator);
+                //
+                // StringBuffer valueSB = new StringBuffer();
+                // for (int v = 0; v < values.length; v++) {
+                // String val = LdifUtils.getStringValue(values[v],
+                // binaryEncoding);
+                // valueSB.append(val);
+                // if (v + 1 < values.length) {
+                // valueSB.append(valueDelimiter);
+                // ;
+                // }
+                // }
+                //
+                // String value = valueSB.toString().replaceAll(quoteCharacter,
+                // quoteCharacter + quoteCharacter);
+                // text.append(quoteCharacter);
+                // text.append(value);
+                // text.append(quoteCharacter);
+                //
+                // }
+
+                if ( a + 1 < returningAttributes.length )
+                {
+                    text.append( attributeDelimiter );
+                }
+            }
+
+            if ( e < entries.length )
+            {
+                text.append( lineSeparator );
+            }
+        }
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsLdifAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsLdifAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsLdifAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsLdifAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,183 @@
+/*
+ *  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.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.utils.AttributeComparator;
+import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * This Action copies entry(ies) as LDIF.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CopyEntryAsLdifAction extends CopyEntryAsAction
+{
+
+    /**
+     * Creates a new instance of CopyEntryAsLdifAction.
+     *
+     * @param mode
+     *      the copy Mode
+     */
+    public CopyEntryAsLdifAction( int mode )
+    {
+        super( "LDIF", mode );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        if ( this.mode == MODE_DN_ONLY )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF );
+        }
+        else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF_SEARCHRESULT );
+        }
+        else if ( this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF_OPERATIONAL );
+        }
+        else
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF_USER );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void serialializeEntries( IEntry[] entries, StringBuffer text )
+    {
+
+        String lineSeparator = BrowserCorePlugin.getDefault().getPluginPreferences().getString(
+            BrowserCoreConstants.PREFERENCE_LDIF_LINE_SEPARATOR );
+
+        Set returningAttributesSet = null;
+        if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY && getSelectedSearchResults().length > 0
+            && getSelectedEntries().length + getSelectedBookmarks().length + getSelectedSearches().length == 0 )
+        {
+            returningAttributesSet = new HashSet( Arrays.asList( getSelectedSearchResults()[0].getSearch()
+                .getReturningAttributes() ) );
+        }
+        else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY && getSelectedSearches().length == 1 )
+        {
+            returningAttributesSet = new HashSet( Arrays.asList( getSelectedSearches()[0].getReturningAttributes() ) );
+        }
+
+        for ( int e = 0; entries != null && e < entries.length; e++ )
+        {
+
+            serializeDn( entries[e].getDn(), text );
+
+            if ( this.mode != MODE_DN_ONLY )
+            {
+
+                List valueList = new ArrayList();
+                IAttribute[] attributes = entries[e].getAttributes();
+                if ( attributes != null )
+                {
+                    for ( int i = 0; i < attributes.length; i++ )
+                    {
+
+                        if ( returningAttributesSet != null
+                            && !returningAttributesSet.contains( attributes[i].getType() ) )
+                            continue;
+
+                        if ( attributes[i].isOperationalAttribute() && this.mode != MODE_INCLUDE_OPERATIONAL_ATTRIBUTES )
+                            continue;
+
+                        IValue[] values = attributes[i].getValues();
+                        for ( int k = 0; k < values.length; k++ )
+                        {
+                            valueList.add( values[k] );
+                        }
+                    }
+                }
+                IValue[] values = ( IValue[] ) valueList.toArray( new IValue[valueList.size()] );
+
+                AttributeComparator comparator = new AttributeComparator( entries[e] );
+                Arrays.sort( values, comparator );
+
+                for ( int i = 0; i < values.length; i++ )
+                {
+                    serializeValue( values[i], text );
+                }
+            }
+            if ( e < entries.length )
+            {
+                text.append( lineSeparator );
+            }
+        }
+    }
+
+
+    /**
+     * Serializes a Value.
+     *
+     * @param value
+     *      the Value to serialize
+     * @param text
+     *      the StringBuffer to serialize to
+     */
+    protected void serializeValue( IValue value, StringBuffer text )
+    {
+        text.append( ModelConverter.valueToLdifAttrValLine( value ).toFormattedString() );
+    }
+
+
+    /**
+     * Serialize a DN.
+     *
+     * @param dn
+     *      the DN to serialize
+     * @param text
+     *      the StringBuffer to serialize to
+     */
+    protected void serializeDn( LdapDN dn, StringBuffer text )
+    {
+        text.append( ModelConverter.dnToLdifDnLine( dn ).toFormattedString() );
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopySearchFilterAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopySearchFilterAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopySearchFilterAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopySearchFilterAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,265 @@
+/*
+ *  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.actions;
+
+
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.utils.LdapFilterUtils;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+
+
+/**
+ * This Action copies the Search Filter
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CopySearchFilterAction extends BrowserAction
+{
+
+    /**
+     * Equals Mode.
+     */
+    public static final int MODE_EQUALS = 0;
+
+    /**
+     * Not Mode.
+     */
+    public static final int MODE_NOT = 1;
+
+    /**
+     * And Mode.
+     */
+    public static final int MODE_AND = 2;
+
+    /**
+     * Or Mode.
+     */
+    public static final int MODE_OR = 3;
+
+    private int mode;
+
+
+    /**
+     * Creates a new instance of CopySearchFilterAction.
+     *
+     * @param mode
+     *      the copy Mode
+     */
+    public CopySearchFilterAction( int mode )
+    {
+        this.mode = mode;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        if ( mode == MODE_EQUALS )
+        {
+            return "Copy Search Filter";
+        }
+        else if ( mode == MODE_NOT )
+        {
+            return "Copy NOT Search Filter";
+        }
+        else if ( mode == MODE_AND )
+        {
+            return "Copy AND Search Filter";
+        }
+        else if ( mode == MODE_OR )
+        {
+            return "Copy OR Search Filter";
+        }
+        else
+        {
+            return "Copy Search Filter";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        if ( mode == MODE_EQUALS )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_EQUALS );
+        }
+        else if ( mode == MODE_NOT )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_NOT );
+        }
+        else if ( mode == MODE_AND )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_AND );
+        }
+        else if ( mode == MODE_OR )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_OR );
+        }
+        else
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_FILTER_EQUALS );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        if ( mode == MODE_EQUALS || mode == MODE_NOT )
+        {
+            return getSelectedAttributeHierarchies().length + getSelectedAttributes().length
+                + getSelectedValues().length == 1
+                && ( getSelectedValues().length == 1
+                    || ( getSelectedAttributes().length == 1 && getSelectedAttributes()[0].getValueSize() == 1 ) || ( getSelectedAttributeHierarchies().length == 1
+                    && getSelectedAttributeHierarchies()[0].size() == 1 && getSelectedAttributeHierarchies()[0]
+                    .getAttribute().getValueSize() == 1 ) );
+        }
+        else if ( mode == MODE_AND || mode == MODE_OR )
+        {
+            return getSelectedAttributeHierarchies().length + getSelectedAttributes().length
+                + getSelectedValues().length > 0;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+
+        String filter = null;
+
+        if ( mode == MODE_EQUALS )
+        {
+            filter = getFilter( null );
+        }
+        else if ( mode == MODE_NOT )
+        {
+            filter = getFilter( "!" );
+        }
+        else if ( mode == MODE_AND )
+        {
+            filter = getFilter( "&" );
+        }
+        else if ( mode == MODE_OR )
+        {
+            filter = getFilter( "|" );
+        }
+
+        if ( filter != null && filter.length() > 0 )
+        {
+            CopyAction.copyToClipboard( new Object[]
+                { filter }, new Transfer[]
+                { TextTransfer.getInstance() } );
+        }
+
+    }
+
+
+    /**
+     * Gets the filter
+     *
+     * @param filterType
+     *      the filter type
+     * @return
+     *      the filter
+     */
+    private String getFilter( String filterType )
+    {
+        Set filterSet = new LinkedHashSet();
+        for ( int i = 0; i < getSelectedAttributeHierarchies().length; i++ )
+        {
+            for ( Iterator it = getSelectedAttributeHierarchies()[i].iterator(); it.hasNext(); )
+            {
+                IAttribute att = ( IAttribute ) it.next();
+                IValue[] values = att.getValues();
+                for ( int v = 0; v < values.length; v++ )
+                {
+                    filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
+                }
+            }
+        }
+        for ( int a = 0; a < getSelectedAttributes().length; a++ )
+        {
+            IValue[] values = getSelectedAttributes()[a].getValues();
+            for ( int v = 0; v < values.length; v++ )
+            {
+                filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
+            }
+        }
+        for ( int v = 0; v < getSelectedValues().length; v++ )
+        {
+            filterSet.add( LdapFilterUtils.getFilter( getSelectedValues()[v] ) );
+        }
+
+        StringBuffer filter = new StringBuffer();
+        if ( filterType != null )
+        {
+            filter.append( "(" );
+            filter.append( filterType );
+            for ( Iterator filterIterator = filterSet.iterator(); filterIterator.hasNext(); )
+            {
+                filter.append( filterIterator.next() );
+            }
+            filter.append( ")" );
+        }
+        else if ( filterSet.size() == 1 )
+        {
+            filter.append( filterSet.toArray()[0] );
+        }
+
+        return filter.toString();
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyUrlAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyUrlAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyUrlAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyUrlAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,132 @@
+/*
+ *  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.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction;
+import org.apache.directory.studio.ldapbrowser.core.model.URL;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+
+
+/**
+ * This Action copies the URL of the selected Entry to the Clipboard.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CopyUrlAction extends BrowserAction
+{
+
+    /**
+     * Creates a new instance of CopyUrlAction.
+     */
+    public CopyUrlAction()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        URL url = null;
+        if ( getSelectedSearches().length > 0 )
+        {
+            url = getSelectedSearches()[0].getUrl();
+        }
+        else if ( getSelectedEntries().length > 0 )
+        {
+            url = getSelectedEntries()[0].getUrl();
+        }
+        else if ( getSelectedAttributes().length > 0 )
+        {
+            url = getSelectedAttributes()[0].getEntry().getUrl();
+        }
+        else if ( getSelectedAttributeHierarchies().length > 0 )
+        {
+            url = getSelectedAttributeHierarchies()[0].getAttribute().getEntry().getUrl();
+        }
+        else if ( getSelectedValues().length > 0 )
+        {
+            url = getSelectedValues()[0].getAttribute().getEntry().getUrl();
+        }
+        else if ( getSelectedSearchResults().length > 0 )
+        {
+            url = getSelectedSearchResults()[0].getEntry().getUrl();
+        }
+        else if ( getSelectedBookmarks().length > 0 )
+        {
+            url = getSelectedBookmarks()[0].getEntry().getUrl();
+        }
+
+        if ( url != null )
+        {
+            CopyAction.copyToClipboard( new Object[]
+                { url.toString() }, new Transfer[]
+                { TextTransfer.getInstance() } );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Copy URL";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_URL );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getSelectedSearches().length + getSelectedEntries().length + getSelectedSearchResults().length
+            + getSelectedBookmarks().length == 1
+            || getSelectedAttributes().length + getSelectedValues().length > 0;
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyValueAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyValueAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyValueAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyValueAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,256 @@
+/*
+ *  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.actions;
+
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.utils.LdifUtils;
+import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+
+
+/**
+ * This Action copies the value of the selecte Entry to the Clipboard.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CopyValueAction extends BrowserAction
+{
+    /**
+     * UTF8 Mode.
+     */
+    public static final int MODE_UTF8 = 1;
+
+    /**
+     * Base64 Mode.
+     */
+    public static final int MODE_BASE64 = 2;
+
+    /**
+     * Hexadecimal Mode. 
+     */
+    public static final int MODE_HEX = 3;
+
+    /**
+     * LDIF Mode.
+     */
+    public static final int MODE_LDIF = 4;
+
+    private int mode;
+
+
+    /**
+     * Creates a new instance of CopyValueAction.
+     *
+     * @param mode
+     *      the copy Mode
+     */
+    public CopyValueAction( int mode )
+    {
+        this.mode = mode;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        if ( mode == MODE_UTF8 )
+        {
+            return getValueSet().size() > 1 ? "Copy Values (UTF-8)" : "Copy Value (UTF-8)";
+        }
+        else if ( mode == MODE_BASE64 )
+        {
+            return getValueSet().size() > 1 ? "Copy Values (BASE-64)" : "Copy Value (BASE-64)";
+        }
+        else if ( mode == MODE_HEX )
+        {
+            return getValueSet().size() > 1 ? "Copy Values (HEX)" : "Copy Value (HEX)";
+        }
+        else if ( mode == MODE_LDIF )
+        {
+            return getValueSet().size() > 1 ? "Copy Name-Value-Pairs as LDIF" : "Copy Name-Value-Pair as LDIF";
+        }
+        else
+        {
+            return "Copy Value";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        if ( mode == MODE_UTF8 )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_UTF8 );
+        }
+        else if ( mode == MODE_BASE64 )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_BASE64 );
+        }
+        else if ( mode == MODE_HEX )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_HEX );
+        }
+        else if ( mode == MODE_LDIF )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getValueSet().size() > 0 || getSelectedSearchResults().length > 0;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+
+        StringBuffer text = new StringBuffer();
+        Set valueSet = getValueSet();
+        if ( !valueSet.isEmpty() )
+        {
+            for ( Iterator iterator = valueSet.iterator(); iterator.hasNext(); )
+            {
+                IValue value = ( IValue ) iterator.next();
+
+                if ( mode == MODE_UTF8 )
+                {
+                    text.append( LdifUtils.utf8decode( value.getBinaryValue() ) );
+                    if ( iterator.hasNext() )
+                        text.append( BrowserCoreConstants.LINE_SEPARATOR );
+                }
+                else if ( mode == MODE_BASE64 )
+                {
+                    text.append( LdifUtils.base64encode( value.getBinaryValue() ) );
+                    if ( iterator.hasNext() )
+                        text.append( BrowserCoreConstants.LINE_SEPARATOR );
+                }
+                else if ( mode == MODE_HEX )
+                {
+                    text.append( LdifUtils.hexEncode( value.getBinaryValue() ) );
+                    if ( iterator.hasNext() )
+                        text.append( BrowserCoreConstants.LINE_SEPARATOR );
+                }
+                else if ( mode == MODE_LDIF )
+                {
+                    text.append( ModelConverter.valueToLdifAttrValLine( value ).toFormattedString() );
+                }
+
+            }
+        }
+        else if ( getSelectedSearchResults().length > 0 )
+        {
+            LdapDN dn = getSelectedSearchResults()[0].getDn();
+
+            if ( mode == MODE_UTF8 )
+            {
+                text.append( dn.getUpName() );
+            }
+            else if ( mode == MODE_BASE64 )
+            {
+                text.append( LdifUtils.base64encode( LdifUtils.utf8encode( dn.getUpName() ) ) );
+            }
+            else if ( mode == MODE_HEX )
+            {
+                text.append( LdifUtils.hexEncode( LdifUtils.utf8encode( dn.getUpName() ) ) );
+            }
+            else if ( mode == MODE_LDIF )
+            {
+                text.append( ModelConverter.dnToLdifDnLine( dn ).toFormattedString() );
+            }
+        }
+
+        if ( text.length() > 0 )
+        {
+            CopyAction.copyToClipboard( new Object[]
+                { text.toString() }, new Transfer[]
+                { TextTransfer.getInstance() } );
+        }
+    }
+
+
+    /**
+     * Gets a Set containing all the Values
+     *
+     * @return
+     *      a Set containing all the Values
+     */
+    protected Set getValueSet()
+    {
+        Set valueSet = new LinkedHashSet();
+        for ( int i = 0; i < getSelectedAttributeHierarchies().length; i++ )
+        {
+            for ( Iterator it = getSelectedAttributeHierarchies()[i].iterator(); it.hasNext(); )
+            {
+                IAttribute att = ( IAttribute ) it.next();
+                valueSet.addAll( Arrays.asList( att.getValues() ) );
+            }
+        }
+        for ( int i = 0; i < getSelectedAttributes().length; i++ )
+        {
+            valueSet.addAll( Arrays.asList( getSelectedAttributes()[i].getValues() ) );
+        }
+        valueSet.addAll( Arrays.asList( getSelectedValues() ) );
+        return valueSet;
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ExpandAllAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ExpandAllAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ExpandAllAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ExpandAllAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,73 @@
+/*
+ *  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.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.TreeViewer;
+
+
+/**
+ * This action expands all nodes of the viewer's tree, starting with the root.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExpandAllAction extends Action
+{
+    protected TreeViewer viewer;
+
+
+    /**
+     * Creates a new instance of ExpandAllAction.
+     *
+     * @param viewer
+     *      the attached Viewer
+     */
+    public ExpandAllAction( TreeViewer viewer )
+    {
+        super( "Expand All", BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPANDALL ) );
+        super.setToolTipText( getText() );
+        super.setEnabled( true );
+
+        this.viewer = viewer;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        this.viewer.expandAll();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        this.viewer = null;
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ImportExportAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ImportExportAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ImportExportAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ImportExportAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,341 @@
+/*
+ *  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.actions;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+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.ISearch;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportCsvWizard;
+import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportDsmlWizard;
+import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportExcelWizard;
+import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportLdifWizard;
+import org.apache.directory.studio.ldapbrowser.ui.wizards.ImportDsmlWizard;
+import org.apache.directory.studio.ldapbrowser.ui.wizards.ImportLdifWizard;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+
+
+/**
+ * This class implements Import/Export Actions for LDIF, CSV, EXCEL and DSML.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImportExportAction extends BrowserAction
+{
+    /**
+     * LDIF Import Type
+     */
+    public static final int TYPE_IMPORT_LDIF = 0;
+
+    /**
+     * LDIF Export Type
+     */
+    public static final int TYPE_EXPORT_LDIF = 1;
+
+    /**
+     * CSV Export Type
+     */
+    public static final int TYPE_EXPORT_CSV = 2;
+
+    /**
+     * EXCEL Export Type
+     */
+    public static final int TYPE_EXPORT_EXCEL = 3;
+
+    /**
+     * DSML Import Type
+     */
+    public static final int TYPE_IMPORT_DSML = 4;
+
+    /**
+     * DSML Export Type
+     */
+    public static final int TYPE_EXPORT_DSML = 5;
+
+    private int type;
+
+
+    /**
+     * Creates a new instance of ImportExportAction.
+     *
+     * @param type
+     *      the type of Import/Export
+     */
+    public ImportExportAction( int type )
+    {
+        super();
+        this.type = type;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        if ( this.type == TYPE_IMPORT_LDIF )
+        {
+            return "LDIF Import...";
+        }
+        else if ( this.type == TYPE_EXPORT_LDIF )
+        {
+            return "LDIF Export...";
+        }
+        else if ( this.type == TYPE_EXPORT_CSV )
+        {
+            return "CSV Export...";
+        }
+        else if ( this.type == TYPE_EXPORT_EXCEL )
+        {
+            return "Excel Export...";
+        }
+        else if ( this.type == TYPE_IMPORT_DSML )
+        {
+            return "DSML Import...";
+        }
+        else if ( this.type == TYPE_EXPORT_DSML )
+        {
+            return "DSML Export...";
+        }
+        else
+        {
+            return "Export...";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        if ( this.type == TYPE_IMPORT_LDIF )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_IMPORT_LDIF );
+        }
+        else if ( this.type == TYPE_EXPORT_LDIF )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_LDIF );
+        }
+        else if ( this.type == TYPE_EXPORT_CSV )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_CSV );
+        }
+        else if ( this.type == TYPE_EXPORT_EXCEL )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_XLS );
+        }
+        else if ( this.type == TYPE_IMPORT_DSML )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_IMPORT_DSML );
+        }
+        else if ( this.type == TYPE_EXPORT_DSML )
+        {
+            return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_DSML );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getEntry() != null || getConnection() != null || getSearch() != null || getConnectionInput() != null;
+
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        IWizard wizard = null;
+
+        if ( this.type == TYPE_IMPORT_LDIF )
+        {
+            if ( getEntry() != null )
+            {
+                wizard = new ImportLdifWizard( getEntry().getBrowserConnection() );
+            }
+            else if ( getSearch() != null )
+            {
+                wizard = new ImportLdifWizard( getSearch().getBrowserConnection() );
+            }
+            else if ( getConnectionInput() != null )
+            {
+                wizard = new ImportLdifWizard( getConnectionInput() );
+            }
+            else if ( getConnection() != null )
+            {
+                wizard = new ImportLdifWizard( getConnection() );
+            }
+        }
+        else if ( this.type == TYPE_IMPORT_DSML )
+        {
+            if ( getEntry() != null )
+            {
+                wizard = new ImportDsmlWizard( getEntry().getBrowserConnection() );
+            }
+            else if ( getSearch() != null )
+            {
+                wizard = new ImportDsmlWizard( getSearch().getBrowserConnection() );
+            }
+            else if ( getConnectionInput() != null )
+            {
+                wizard = new ImportDsmlWizard( getConnectionInput() );
+            }
+            else if ( getConnection() != null )
+            {
+                wizard = new ImportDsmlWizard( getConnection() );
+            }
+        }
+        else if ( this.type == TYPE_EXPORT_LDIF )
+        {
+            wizard = new ExportLdifWizard();
+        }
+        else if ( this.type == TYPE_EXPORT_CSV )
+        {
+            wizard = new ExportCsvWizard();
+        }
+        else if ( this.type == TYPE_EXPORT_EXCEL )
+        {
+            wizard = new ExportExcelWizard();
+        }
+        else if ( this.type == TYPE_EXPORT_DSML )
+        {
+            wizard = new ExportDsmlWizard();
+        }
+
+        if ( wizard != null )
+        {
+            WizardDialog dialog = new WizardDialog( getShell(), wizard );
+            dialog.setBlockOnOpen( true );
+            dialog.create();
+            dialog.open();
+        }
+
+    }
+
+
+    /**
+     * Gets the selected Entry.
+     *
+     * @return
+     *      the selected Entry
+     */
+    protected IEntry getEntry()
+    {
+        IEntry entry = null;
+        if ( getSelectedEntries().length > 0 )
+        {
+            entry = getSelectedEntries()[0];
+        }
+        else if ( getSelectedSearchResults().length > 0 )
+        {
+            entry = getSelectedSearchResults()[0].getEntry();
+        }
+        else if ( getSelectedBookmarks().length > 0 )
+        {
+            entry = getSelectedBookmarks()[0].getEntry();
+        }
+
+        return entry != null ? entry : null;
+    }
+
+
+    /**
+     * Gets the Connection.
+     *
+     * @return
+     *      the Connection
+     */
+    protected IBrowserConnection getConnection()
+    {
+        if ( getSelectedConnections().length > 0
+            && getSelectedConnections()[0].getJNDIConnectionWrapper().isConnected() )
+        {
+            Connection connection = getSelectedConnections()[0];
+            IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnection(
+                connection );
+            return browserConnection;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Gets the Search.
+     *
+     * @return
+     *      the Search
+     */
+    protected ISearch getSearch()
+    {
+        return getSelectedSearches().length > 0 ? getSelectedSearches()[0] : null;
+    }
+
+
+    /**
+     * Gets the Connection Input.
+     *
+     * @return
+     *      the Connection Input
+     */
+    protected IBrowserConnection getConnectionInput()
+    {
+
+        if ( getInput() != null && ( getInput() instanceof IBrowserConnection ) )
+        {
+            return ( IBrowserConnection ) getInput();
+        }
+        else
+        {
+            return null;
+        }
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateDnInDitAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateDnInDitAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateDnInDitAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateDnInDitAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,123 @@
+/*
+ *  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.actions;
+
+
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+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.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * This action is used within the entry editor and search result editor 
+ * to locate and open the entry identified by the DN under the cursor. 
+ * 
+ * Example: Attribute "seeAlso" with value "ou=test" is selected in entry edtor. 
+ * Then this action is enabled and opens entry "ou=test" in DIT. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LocateDnInDitAction extends LocateInDitAction
+{
+    /**
+     * Creates a new instance of LocateDnInDitAction.
+     */
+    public LocateDnInDitAction()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Locate DN in DIT";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_DN_IN_DIT );
+    }
+
+
+    /**
+     * This implementation returns a connection and DN if the selected attribute or value
+     * contains a valid DN.
+     */
+    protected ConnectionAndDn getConnectionAndDn()
+    {
+
+        if ( getSelectedAttributeHierarchies().length == 1
+            && getSelectedAttributeHierarchies()[0].getAttribute().getValueSize() == 1
+            && getSelectedSearchResults().length == 1 )
+        {
+            try
+            {
+                IValue value = getSelectedAttributeHierarchies()[0].getAttribute().getValues()[0];
+                if ( value.isString() && LdapDN.isValid( value.getStringValue() ) )
+                {
+                    return new ConnectionAndDn( value.getAttribute().getEntry().getBrowserConnection(), new LdapDN( value
+                        .getStringValue() ) );
+                }
+            }
+            catch ( InvalidNameException e )
+            {
+                // no valid DN
+            }
+        }
+
+        if ( getSelectedValues().length == 1 && getSelectedAttributes().length == 0 )
+        {
+            try
+            {
+                IValue value = getSelectedValues()[0];
+                if ( value.isString() && LdapDN.isValid( value.getStringValue() ) )
+                {
+                    return new ConnectionAndDn( value.getAttribute().getEntry().getBrowserConnection(), new LdapDN( value
+                        .getStringValue() ) );
+                }
+            }
+            catch ( InvalidNameException e )
+            {
+                // no valid DN
+            }
+        }
+
+        if ( getSelectedSearchResults().length == 1 && getSelectedAttributeHierarchies().length == 0 )
+        {
+            ISearchResult result = getSelectedSearchResults()[0];
+            return new ConnectionAndDn( result.getEntry().getBrowserConnection(), result.getEntry().getDn() );
+        }
+
+        return null;
+    }
+}

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