directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592079 [3/17] - in /directory/sandbox/felixk/studio-ldapbrowser-common: ./ 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/ ...
Date Mon, 05 Nov 2007 16:48:54 GMT
Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,674 @@
+/*
+ *  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.common.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.jobs.DeleteAttributesValueJob;
+import org.apache.directory.studio.ldapbrowser.core.jobs.DeleteEntriesJob;
+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.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.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.ObjectClassDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
+
+
+/**
+ * This Action implements the Delete Action. It deletes Connections, Entries, Searches, Bookmarks, Attributes or Values.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DeleteAction extends BrowserAction
+{
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        try
+        {
+            IEntry[] entries = getEntries();
+            ISearch[] searches = getSearches();
+            IBookmark[] bookmarks = getBookmarks();
+            IAttribute[] attributes = getAttributes();
+            IValue[] values = getValues();
+
+            if ( entries.length > 0 && searches.length == 0 && bookmarks.length == 0
+                && attributes.length == 0 && values.length == 0 )
+            {
+                return entries.length > 1 ? "Delete Entries" : "Delete Entry";
+            }
+            if ( searches.length > 0 && entries.length == 0 && bookmarks.length == 0
+                && attributes.length == 0 && values.length == 0 )
+            {
+                return searches.length > 1 ? "Delete Searches" : "Delete Search";
+            }
+            if ( bookmarks.length > 0 && entries.length == 0 && searches.length == 0
+                && attributes.length == 0 && values.length == 0 )
+            {
+                return bookmarks.length > 1 ? "Delete Bookmarks" : "Delete Bookmark";
+            }
+            if ( attributes.length > 0 && entries.length == 0 && searches.length == 0
+                && bookmarks.length == 0 && values.length == 0 )
+            {
+                return attributes.length > 1 ? "Delete Attributes" : "Delete Attribute";
+            }
+            if ( values.length > 0 && entries.length == 0 && searches.length == 0
+                && bookmarks.length == 0 && attributes.length == 0 )
+            {
+                return values.length > 1 ? "Delete Values" : "Delete Value";
+            }
+        }
+        catch ( Exception e )
+        {
+        }
+
+        return "Delete";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_DELETE );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return IWorkbenchActionDefinitionIds.DELETE;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        try
+        {
+            IEntry[] entries = getEntries();
+            ISearch[] searches = getSearches();
+            IBookmark[] bookmarks = getBookmarks();
+            IAttribute[] attributes = getAttributes();
+            IValue[] values = getValues();
+
+            StringBuffer message = new StringBuffer();
+
+            if ( entries.length > 0 )
+            {
+                if ( entries.length <= 5 )
+                {
+                    message
+                        .append( entries.length == 1 ? "Are your sure to delete the following entry, including all children?"
+                            : "Are your sure to delete the following entries, including all children?" );
+                    for ( int i = 0; i < entries.length; i++ )
+                    {
+                        message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                        message.append( "  - " );
+                        message.append( entries[i].getDn().getUpName() );
+                    }
+                }
+                else
+                {
+                    message.append( "Are your sure to delete the selected entries, including all children?" );
+                }
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+            }
+
+            if ( searches.length > 0 )
+            {
+                if ( searches.length <= 5 )
+                {
+                    message.append( searches.length == 1 ? "Are your sure to delete the following search?"
+                        : "Are your sure to delete the following searches?" );
+                    for ( int i = 0; i < searches.length; i++ )
+                    {
+                        message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                        message.append( "  - " );
+                        message.append( searches[i].getName() );
+                    }
+                }
+                else
+                {
+                    message.append( "Are your sure to delete the selected searches?" );
+                }
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+            }
+
+            if ( bookmarks.length > 0 )
+            {
+                if ( bookmarks.length <= 5 )
+                {
+                    message.append( bookmarks.length == 1 ? "Are your sure to delete the following bookmark?"
+                        : "Are your sure to delete the following bookmarks?" );
+                    for ( int i = 0; i < bookmarks.length; i++ )
+                    {
+                        message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                        message.append( "  - " );
+                        message.append( bookmarks[i].getName() );
+                    }
+                }
+                else
+                {
+                    message.append( "Are your sure to delete the selected bookmarks?" );
+                }
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+            }
+
+            if ( attributes.length > 0 )
+            {
+                if ( attributes.length <= 5 )
+                {
+                    message.append( attributes.length == 1 ? "Are your sure to delete the following attribute?"
+                        : "Are your sure to delete the following attribute?" );
+                    for ( int i = 0; i < attributes.length; i++ )
+                    {
+                        message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                        message.append( "  - " );
+                        message.append( attributes[i].getDescription() );
+                    }
+                }
+                else
+                {
+                    message.append( "Are your sure to delete the selected attributes?" );
+                }
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                message.append( BrowserCoreConstants.LINE_SEPARATOR );
+            }
+
+            if ( values.length > 0 )
+            {
+                boolean emptyValuesOnly = true;
+                for ( int i = 0; i < values.length; i++ )
+                {
+                    if ( !values[i].isEmpty() )
+                    {
+                        emptyValuesOnly = false;
+                    }
+                }
+                if ( !emptyValuesOnly )
+                {
+                    if ( values.length <= 5 )
+                    {
+                        message.append( values.length == 1 ? "Are your sure to delete the following value?"
+                            : "Are your sure to delete the following values?" );
+                        for ( int i = 0; i < values.length; i++ )
+                        {
+                            message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                            message.append( "  - " );
+                            message.append( values[i].toString() );
+                        }
+                    }
+                    else
+                    {
+                        message.append( "Are your sure to delete the selected values?" );
+                    }
+                    message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                    message.append( BrowserCoreConstants.LINE_SEPARATOR );
+                }
+            }
+
+            if ( message.length() == 0 || MessageDialog.openConfirm( getShell(), getText(), message.toString() ) )
+            {
+                if ( entries.length > 0 )
+                {
+                    deleteEntries( entries );
+                }
+                if ( searches.length > 0 )
+                {
+                    deleteSearches( searches );
+                }
+                if ( bookmarks.length > 0 )
+                {
+                    deleteBookmarks( bookmarks );
+                }
+                if ( attributes.length + values.length > 0 )
+                {
+
+                    List attributeList = new ArrayList( Arrays.asList( attributes ) );
+                    List valueList = new ArrayList( Arrays.asList( values ) );
+
+                    // filter empty attributes and values
+                    for ( Iterator it = attributeList.iterator(); it.hasNext(); )
+                    {
+                        IAttribute att = ( IAttribute ) it.next();
+                        IValue[] vals = att.getValues();
+                        for ( int i = 0; i < vals.length; i++ )
+                        {
+                            if ( vals[i].isEmpty() )
+                            {
+                                att.deleteEmptyValue();
+                            }
+                        }
+                        if ( att.getValueSize() == 0 )
+                        {
+                            att.getEntry().deleteAttribute( att );
+                            it.remove();
+                        }
+                    }
+                    for ( Iterator it = valueList.iterator(); it.hasNext(); )
+                    {
+                        IValue value = ( IValue ) it.next();
+                        if ( value.isEmpty() )
+                        {
+                            value.getAttribute().deleteEmptyValue();
+                            it.remove();
+                        }
+                    }
+
+                    if ( !attributeList.isEmpty() || !valueList.isEmpty() )
+                    {
+                        deleteAttributesAndValues( ( IAttribute[] ) attributeList.toArray( new IAttribute[attributeList
+                            .size()] ), ( IValue[] ) valueList.toArray( new IValue[valueList.size()] ) );
+                    }
+                }
+            }
+        }
+        catch ( Exception e )
+        {
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        try
+        {
+            IEntry[] entries = getEntries();
+            ISearch[] searches = getSearches();
+            IBookmark[] bookmarks = getBookmarks();
+            IAttribute[] attributes = getAttributes();
+            IValue[] values = getValues();
+
+            return entries.length + searches.length + bookmarks.length + attributes.length
+                + values.length > 0;
+
+        }
+        catch ( Exception e )
+        {
+            // e.printStackTrace();
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the Entries.
+     *
+     * @return
+     *      the Entries
+     * @throws Exception
+     *      when an Entry has parent Entries
+     */
+    protected IEntry[] getEntries() throws Exception
+    {
+        LinkedHashSet entriesSet = new LinkedHashSet();
+        for ( int i = 0; i < getSelectedEntries().length; i++ )
+        {
+            if ( !getSelectedEntries()[i].hasParententry() )
+            {
+                throw new Exception();
+            }
+            entriesSet.add( getSelectedEntries()[i] );
+        }
+        for ( int i = 0; i < this.getSelectedSearchResults().length; i++ )
+        {
+            if ( !getSelectedSearchResults()[i].getEntry().hasParententry() )
+            {
+                throw new Exception();
+            }
+            entriesSet.add( this.getSelectedSearchResults()[i].getEntry() );
+        }
+
+        IEntry[] allEntries = ( IEntry[] ) entriesSet.toArray( new IEntry[entriesSet.size()] );
+        for ( int i = 0; i < allEntries.length; i++ )
+        {
+            IEntry entry = allEntries[i];
+            if ( entriesSet.contains( entry.getParententry() ) )
+            {
+                entriesSet.remove( entry );
+            }
+        }
+
+        return ( IEntry[] ) entriesSet.toArray( new IEntry[entriesSet.size()] );
+    }
+
+
+    /**
+     * Deletes Entries
+     *
+     * @param entries
+     *      the Entries to delete
+     */
+    protected void deleteEntries( IEntry[] entries )
+    {
+        new DeleteEntriesJob( entries ).execute();
+    }
+
+
+    /**
+     * Gets the Searches
+     *
+     * @return
+     *      the Searches
+     * @throws Exception
+     */
+    protected ISearch[] getSearches() throws Exception
+    {
+        return getSelectedSearches();
+    }
+
+
+    /**
+     * Delete Searches
+     *
+     * @param searches
+     *      the Searches to delete
+     */
+    protected void deleteSearches( ISearch[] searches )
+    {
+        for ( int i = 0; i < searches.length; i++ )
+        {
+            ISearch search = searches[i];
+            search.getBrowserConnection().getSearchManager().removeSearch( search );
+        }
+    }
+
+
+    /**
+     * Get the Bookmarks
+     *
+     * @return
+     * @throws Exception
+     */
+    protected IBookmark[] getBookmarks() throws Exception
+    {
+        return getSelectedBookmarks();
+    }
+
+
+    /**
+     * Delete Bookmarks
+     *
+     * @param bookmarks
+     *      the Bookmarks to delete
+     */
+    protected void deleteBookmarks( IBookmark[] bookmarks )
+    {
+        for ( int i = 0; i < bookmarks.length; i++ )
+        {
+            IBookmark bookmark = bookmarks[i];
+            bookmark.getBrowserConnection().getBookmarkManager().removeBookmark( bookmark );
+        }
+    }
+
+
+    /**
+     * Gets the Attributes
+     *
+     * @return
+     *      the Attributes
+     * @throws Exception
+     */
+    protected IAttribute[] getAttributes() throws Exception
+    {
+
+        for ( int i = 0; i < getSelectedAttributes().length; i++ )
+        {
+            // check if a non-modifyable, must or objectClass attribute is
+            // selected
+            IAttribute att = getSelectedAttributes()[i];
+            if ( !SchemaUtils.isModifyable( att.getAttributeTypeDescription() ) || att.isMustAttribute()
+                || att.isObjectClassAttribute() )
+            {
+                throw new Exception();
+            }
+        }
+
+        for ( int i = 0; i < getSelectedAttributeHierarchies().length; i++ )
+        {
+            // check if a non-modifyable, must or objectClass attribute is
+            // selected
+            AttributeHierarchy ah = getSelectedAttributeHierarchies()[i];
+            for ( Iterator it = ah.iterator(); it.hasNext(); )
+            {
+                IAttribute attribute = ( IAttribute ) it.next();
+                if ( !SchemaUtils.isModifyable( attribute.getAttributeTypeDescription() )
+                    || attribute.isMustAttribute() || attribute.isObjectClassAttribute() )
+                {
+                    throw new Exception();
+                }
+            }
+        }
+
+        List attributeList = new ArrayList();
+
+        // add selected attributes
+        for ( int i = 0; i < getSelectedAttributes().length; i++ )
+        {
+            IAttribute attribute = getSelectedAttributes()[i];
+            if ( attribute != null && attribute.getValueSize() > 0 )
+            {
+                attributeList.add( attribute );
+            }
+        }
+
+        // add selected hierarchies
+        for ( int i = 0; i < getSelectedAttributeHierarchies().length; i++ )
+        {
+            // check if a operational, must or objectClass attribute is
+            // selected
+            AttributeHierarchy ah = getSelectedAttributeHierarchies()[i];
+            for ( Iterator it = ah.iterator(); it.hasNext(); )
+            {
+                IAttribute attribute = ( IAttribute ) it.next();
+                if ( attribute != null && attribute.getValueSize() > 0 )
+                {
+                    attributeList.add( attribute );
+                }
+            }
+        }
+
+        // check if ALL values of an attribute are selected -> delete whole
+        // attribute
+        Map attributeNameToSelectedValuesCountMap = new HashMap();
+        for ( int i = 0; i < getSelectedValues().length; i++ )
+        {
+            if ( !attributeNameToSelectedValuesCountMap.containsKey( getSelectedValues()[i].getAttribute()
+                .getDescription() ) )
+            {
+                attributeNameToSelectedValuesCountMap.put( getSelectedValues()[i].getAttribute().getDescription(),
+                    new Integer( 0 ) );
+            }
+            int count = ( ( Integer ) attributeNameToSelectedValuesCountMap.get( getSelectedValues()[i].getAttribute()
+                .getDescription() ) ).intValue() + 1;
+            attributeNameToSelectedValuesCountMap.put( getSelectedValues()[i].getAttribute().getDescription(),
+                new Integer( count ) );
+            if ( count >= getSelectedValues()[i].getAttribute().getValueSize() )
+            {
+                IAttribute attribute = getSelectedValues()[i].getAttribute();
+                if ( attribute != null && !attributeList.contains( attribute ) )
+                {
+                    attributeList.add( attribute );
+                }
+            }
+        }
+
+        return ( IAttribute[] ) attributeList.toArray( new IAttribute[attributeList.size()] );
+    }
+
+
+    /**
+     * Gets the Values
+     *
+     * @return
+     *      the Values
+     * @throws Exception
+     */
+    protected IValue[] getValues() throws Exception
+    {
+
+        Map attributeNameToSelectedValuesCountMap = new HashMap();
+        Set selectedObjectClasses = new HashSet();
+        for ( int i = 0; i < getSelectedValues().length; i++ )
+        {
+            // check if a value of an operational attribute is selected
+            if ( !SchemaUtils.isModifyable( getSelectedValues()[i].getAttribute().getAttributeTypeDescription() ) )
+            {
+                throw new Exception();
+            }
+
+            // check if (part of) RDN is selected
+            Iterator<AttributeTypeAndValue> atavIterator = this.getSelectedValues()[i].getAttribute().getEntry().getRdn().iterator();
+            while(atavIterator.hasNext())
+            {
+                AttributeTypeAndValue atav = atavIterator.next();
+                if ( getSelectedValues()[i].getAttribute().getDescription().equals( atav.getUpType() )
+                    && getSelectedValues()[i].getStringValue().equals( atav.getUpValue() ) )
+                {
+                    throw new Exception();
+                }
+            }
+
+            // check if a required objectClass is selected
+            if ( getSelectedValues()[i].getAttribute().isObjectClassAttribute() )
+            {
+                selectedObjectClasses.add( getSelectedValues()[i].getStringValue() );
+            }
+
+            // check if ALL values of objectClass or a MUST attribute are
+            // selected
+            if ( !attributeNameToSelectedValuesCountMap.containsKey( getSelectedValues()[i].getAttribute()
+                .getDescription() ) )
+            {
+                attributeNameToSelectedValuesCountMap.put( getSelectedValues()[i].getAttribute().getDescription(),
+                    new Integer( 0 ) );
+            }
+            int count = ( ( Integer ) attributeNameToSelectedValuesCountMap.get( getSelectedValues()[i].getAttribute()
+                .getDescription() ) ).intValue() + 1;
+            attributeNameToSelectedValuesCountMap.put( getSelectedValues()[i].getAttribute().getDescription(),
+                new Integer( count ) );
+            if ( ( getSelectedValues()[i].getAttribute().isObjectClassAttribute() || getSelectedValues()[i]
+                .getAttribute().isMustAttribute() /*
+             * || this.selectedEntry ==
+             * null
+             */)
+                && count >= getSelectedValues()[i].getAttribute().getValueSize() )
+            {
+                throw new Exception();
+            }
+        }
+        // check if a required objectClass is selected
+        if ( getSelectedValues().length > 0 && !selectedObjectClasses.isEmpty() )
+        {
+            IEntry entry = getSelectedValues()[0].getAttribute().getEntry();
+            // get remaining attributes
+            String[] ocValues = entry.getSubschema().getObjectClassNames();
+            Set remainingObjectClassesSet = new HashSet( Arrays.asList( ocValues ) );
+            remainingObjectClassesSet.removeAll( selectedObjectClasses );
+            Set remainingAttributeSet = new HashSet();
+            for ( Iterator it = remainingObjectClassesSet.iterator(); it.hasNext(); )
+            {
+                String oc = ( String ) it.next();
+                ObjectClassDescription ocd = entry.getBrowserConnection().getSchema().getObjectClassDescription( oc );
+                if ( ocd != null )
+                {
+                    remainingAttributeSet
+                        .addAll( Arrays.asList( ocd.getMustAttributeTypeDescriptionNamesTransitive() ) );
+                    remainingAttributeSet.addAll( Arrays.asList( ocd.getMayAttributeTypeDescriptionNamesTransitive() ) );
+                }
+            }
+            // check against attributes
+            IAttribute[] attributes = entry.getAttributes();
+            for ( int i = 0; i < attributes.length; i++ )
+            {
+                IAttribute attribute = attributes[i];
+                if ( attribute.isMayAttribute() || attribute.isMustAttribute() )
+                {
+                    if ( !remainingAttributeSet.contains( attribute.getType() ) )
+                    {
+                        throw new Exception();
+                    }
+                }
+            }
+        }
+
+        List valueList = new ArrayList();
+
+        // add selected values
+        Set attributeSet = new HashSet( Arrays.asList( getAttributes() ) );
+        for ( int i = 0; i < getSelectedValues().length; i++ )
+        {
+            if ( !attributeSet.contains( getSelectedValues()[i].getAttribute() ) )
+            {
+                valueList.add( getSelectedValues()[i] );
+            }
+        }
+
+        return ( IValue[] ) valueList.toArray( new IValue[valueList.size()] );
+    }
+
+
+    /**
+     * Deletes Attributes and Values
+     *
+     * @param attributes
+     *      the Attributes to delete
+     * @param values
+     *      the Values to delete
+     */
+    protected void deleteAttributesAndValues( IAttribute[] attributes, IValue[] values )
+    {
+        new DeleteAttributesValueJob( attributes, values ).execute();
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAllValuesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAllValuesAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAllValuesAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAllValuesAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,136 @@
+/*
+ *  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.common.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+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.model.schema.SchemaUtils;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * This Action deletes all the values of an Attribute (a whole Attribute).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DeleteAllValuesAction extends DeleteAction
+{
+    /**
+     * Creates a new instance of DeleteAllValuesAction.
+     */
+    public DeleteAllValuesAction()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        super.run();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        if ( getSelectedValues().length == 1 )
+        {
+            return "Delete Attribute '" + getSelectedValues()[0].getAttribute().getDescription() + "'";
+        }
+        else
+        {
+            return "Delete Attribute";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_DELETE_ALL );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return super.isEnabled();
+        // return getSelectedAttributes().length == 0 &&
+        // getSelectedValues().length == 1 &&
+        // getSelectedValues()[0].getAttribute().getValueSize() > 1 &&
+        // !getSelectedValues()[0].getAttribute().isMustAttribute() &&
+        // !getSelectedValues()[0].getAttribute().isObjectClassAttribute() &&
+        // !getSelectedValues()[0].getAttribute().isOperationalAttribute();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected IAttribute[] getAttributes() throws Exception
+    {
+        if ( getSelectedAttributes().length == 0 && getSelectedValues().length == 1
+            && getSelectedValues()[0].getAttribute().getValueSize() > 1
+            && !getSelectedValues()[0].getAttribute().isMustAttribute()
+            && !getSelectedValues()[0].getAttribute().isObjectClassAttribute()
+            && SchemaUtils.isModifyable( getSelectedValues()[0].getAttribute().getAttributeTypeDescription() ) )
+        {
+
+            return new IAttribute[]
+                { getSelectedValues()[0].getAttribute() };
+
+        }
+        else
+        {
+            return new IAttribute[0];
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected IValue[] getValues() throws Exception
+    {
+        return new IValue[0];
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/FilterChildrenAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/FilterChildrenAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/FilterChildrenAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/FilterChildrenAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,119 @@
+/*
+ *  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.common.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.dialogs.FilterWidgetDialog;
+import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeChildrenJob;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * This action opens the Filter Children Dialog and sets the children filter to the
+ * currently selected entry. It is useful when browsing the DIT and entries with 
+ * many child nodes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class FilterChildrenAction extends BrowserAction
+{
+
+    /**
+     * Creates a new instance of FilterChildrenAction.
+     */
+    public FilterChildrenAction()
+    {
+        super();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        if ( getSelectedEntries().length == 1 )
+        {
+            FilterWidgetDialog dialog = new FilterWidgetDialog( getShell(), "Filter Children", getSelectedEntries()[0]
+                .getChildrenFilter(), getSelectedEntries()[0].getBrowserConnection() );
+            if ( dialog.open() == Dialog.OK )
+            {
+                String newFilter = dialog.getFilter();
+
+                if ( newFilter == null || "".equals( newFilter.trim() ) )
+                {
+                    getSelectedEntries()[0].setChildrenFilter( null );
+                }
+                else
+                {
+                    getSelectedEntries()[0].setChildrenFilter( newFilter.trim() );
+                }
+                new InitializeChildrenJob( new IEntry[]
+                    { getSelectedEntries()[0] } ).execute();
+
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Filter Children...";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_FILTER_DIT );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getSelectedSearches().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 0
+            && getSelectedEntries().length == 1
+            && ( getSelectedEntries()[0].hasChildren() || getSelectedEntries()[0].getChildrenFilter() != null );
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewAttributeAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewAttributeAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewAttributeAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewAttributeAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,150 @@
+/*
+ *  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.common.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.wizards.AttributeWizard;
+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.impl.Attribute;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardDialog;
+
+
+/**
+ * This Action creates a new Attribute
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewAttributeAction extends BrowserAction
+{
+    /**
+     * Creates a new instance of NewAttributeAction.
+     */
+    public NewAttributeAction()
+    {
+        super();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+
+        IEntry entry = null;
+        if ( getInput() != null && getInput() instanceof IEntry )
+        {
+            entry = ( IEntry ) getInput();
+        }
+        else if ( getSelectedEntries().length > 0 )
+        {
+            entry = getSelectedEntries()[0];
+        }
+        else if ( getSelectedAttributes().length > 0 )
+        {
+            entry = getSelectedAttributes()[0].getEntry();
+        }
+        else if ( getSelectedValues().length > 0 )
+        {
+            entry = getSelectedValues()[0].getAttribute().getEntry();
+        }
+
+        if ( entry != null )
+        {
+            AttributeWizard wizard = new AttributeWizard( "New Attribute", true, true, null, entry );
+            WizardDialog dialog = new WizardDialog( getShell(), wizard );
+            dialog.setBlockOnOpen( true );
+            dialog.create();
+            if ( dialog.open() == WizardDialog.OK )
+            {
+                String newAttributeDescription = wizard.getAttributeDescription();
+                if ( newAttributeDescription != null && !"".equals( newAttributeDescription ) )
+                {
+                    IAttribute att = entry.getAttribute( newAttributeDescription );
+                    if ( att == null )
+                    {
+                        att = new Attribute( entry, newAttributeDescription );
+                        entry.addAttribute( att ) ;
+                    }
+
+                    att.addEmptyValue();
+                }
+            }
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "New Attribute...";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_ATTRIBUTE_ADD );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return "org.apache.directory.studio.ldapbrowser.action.addAttribute";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+
+        if ( ( getSelectedSearchResults().length == 1 && getSelectedAttributes().length > 0 ) )
+        {
+            return false;
+        }
+
+        return ( ( getInput() != null && getInput() instanceof IEntry ) || getSelectedEntries().length == 1
+            || getSelectedAttributes().length > 0 || getSelectedValues().length > 0 );
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewValueAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewValueAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewValueAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/NewValueAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,136 @@
+/*
+ *  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.common.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * This Action adds a new Value to an Attribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewValueAction extends BrowserAction
+{
+    /**
+     * Creates a new instance of NewValueAction.
+     */
+    public NewValueAction()
+    {
+        super();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        if ( getSelectedValues().length == 1 )
+        {
+            getSelectedValues()[0].getAttribute().addEmptyValue();
+        }
+        else if ( getSelectedAttributes().length == 1 )
+        {
+            getSelectedAttributes()[0].addEmptyValue();
+        }
+        else if ( getSelectedAttributeHierarchies().length == 1 )
+        {
+            getSelectedAttributeHierarchies()[0].getAttribute().addEmptyValue();
+        }
+
+        if ( getSelectedSearchResults().length > 0 )
+        {
+
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "New Value";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_VALUE_ADD );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return "org.apache.directory.studio.ldapbrowser.action.addValue";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        // System.out.println(getSelectedAttributeArrays());
+        // System.out.print("==> ");
+        // IAttribute[][] attArr = getSelectedAttributeArrays();
+        // for (int i = 0; i < attArr.length; i++) {
+        // for (int j = 0; j < attArr[i].length; j++) {
+        // IAttribute att = attArr[i][j];
+        // System.out.print(att + "|");
+        // }
+        // }
+        // System.out.println();
+
+        return ( getSelectedSearchResults().length == 0 && getSelectedAttributes().length == 0
+            && getSelectedValues().length == 1 && SchemaUtils.isModifyable( getSelectedValues()[0].getAttribute()
+            .getAttributeTypeDescription() ) )
+
+            || ( getSelectedSearchResults().length == 0 && getSelectedValues().length == 0
+                && getSelectedAttributes().length == 1 && SchemaUtils.isModifyable( getSelectedAttributes()[0]
+                .getAttributeTypeDescription() ) )
+
+            || ( getSelectedSearchResults().length == 1 && getSelectedValues().length == 0
+                && getSelectedAttributes().length == 0 && getSelectedAttributeHierarchies().length == 1 && SchemaUtils
+                .isModifyable( getSelectedAttributeHierarchies()[0].getAttribute().getAttributeTypeDescription() ) );
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PasteAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,300 @@
+/*
+ *  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.common.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.dialogs.ScopeDialog;
+import org.apache.directory.studio.ldapbrowser.common.dnd.EntryTransfer;
+import org.apache.directory.studio.ldapbrowser.common.dnd.ValuesTransfer;
+import org.apache.directory.studio.ldapbrowser.core.jobs.CopyEntriesJob;
+import org.apache.directory.studio.ldapbrowser.core.jobs.CreateValuesJob;
+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.model.ISearch.SearchScope;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
+
+
+/**
+ * This class implements the Paste Action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PasteAction extends BrowserAction
+{
+    /**
+     * Creates a new instance of PasteAction.
+     */
+    public PasteAction()
+    {
+        super();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        // entry
+        IEntry[] entries = getEntriesToPaste();
+        if ( entries != null )
+        {
+            return entries.length > 1 ? "Paste Entries" : "Paste Entry";
+        }
+
+        // value
+        IValue[] values = getValuesToPaste();
+        if ( values != null )
+        {
+            return values.length > 1 ? "Paste Values" : "Paste Value";
+        }
+
+        return "Paste";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( ISharedImages.IMG_TOOL_PASTE );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return IWorkbenchActionDefinitionIds.PASTE;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        // entry
+        if ( getEntriesToPaste() != null )
+        {
+            return true;
+        }
+
+        // value
+        else if ( getValuesToPaste() != null )
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        // entry
+        IEntry[] entries = getEntriesToPaste();
+        if ( entries != null )
+        {
+            this.pasteEntries( getSelectedEntries()[0], entries );
+            return;
+        }
+
+        // value
+        IValue[] values = getValuesToPaste();
+        if ( values != null )
+        {
+            this.pasteValues( values );
+            return;
+        }
+
+    }
+
+
+    /**
+     * Pastes the given entries
+     *
+     * @param parent
+     *      the parent Entry
+     * @param entriesToPaste
+     *      the Entries to paste
+     */
+    private void pasteEntries( final IEntry parent, final IEntry[] entriesToPaste )
+    {
+        SearchScope scope = SearchScope.OBJECT;
+        boolean askForScope = false;
+        for ( int i = 0; i < entriesToPaste.length; i++ )
+        {
+            if ( entriesToPaste[i].hasChildren() )
+            {
+                askForScope = true;
+                break;
+            }
+        }
+        if ( askForScope )
+        {
+            ScopeDialog scopeDialog = new ScopeDialog( Display.getDefault().getActiveShell(), "Select Copy Depth",
+                entriesToPaste.length > 1 );
+            scopeDialog.open();
+            scope = scopeDialog.getScope();
+        }
+
+        new CopyEntriesJob( parent, entriesToPaste, scope ).execute();
+    }
+
+
+    /**
+     * Paste Values
+     *
+     * @param values
+     *      the Values to paste
+     */
+    private void pasteValues( IValue[] values )
+    {
+        IEntry entry = null;
+        if ( getSelectedAttributes().length > 0 )
+        {
+            entry = getSelectedAttributes()[0].getEntry();
+        }
+        else if ( getSelectedValues().length > 0 )
+        {
+            entry = getSelectedValues()[0].getAttribute().getEntry();
+        }
+        else if ( getSelectedEntries().length == 1 )
+        {
+            entry = getSelectedEntries()[0];
+        }
+        else if ( getSelectedSearchResults().length == 1 )
+        {
+            entry = getSelectedSearchResults()[0].getEntry();
+        }
+        else if ( getSelectedBookmarks().length == 1 )
+        {
+            entry = getSelectedBookmarks()[0].getEntry();
+        }
+
+        if ( entry != null )
+        {
+//            String[] attributeNames = new String[values.length];
+//            Object[] rawValues = new Object[values.length];
+//            for ( int v = 0; v < values.length; v++ )
+//            {
+//                attributeNames[v] = values[v].getAttribute().getDescription();
+//                rawValues[v] = values[v].getRawValue();
+//            }
+//            new CreateValuesJob( entry, attributeNames, rawValues ).execute();
+            new CreateValuesJob( entry, values ).execute();
+        }
+    }
+
+
+    /**
+     * Conditions: - an entry is selected - there are entries in clipboard
+     * 
+     * @return
+     */
+    private IEntry[] getEntriesToPaste()
+    {
+        if ( getSelectedBookmarks().length + getSelectedSearchResults().length + getSelectedSearches().length
+            + getSelectedConnections().length + getSelectedAttributes().length + getSelectedValues().length == 0
+            && getSelectedEntries().length == 1 )
+        {
+
+            Object content = this.getFromClipboard( EntryTransfer.getInstance() );
+            if ( content != null && content instanceof IEntry[] )
+            {
+                IEntry[] entries = ( IEntry[] ) content;
+                return entries;
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Conditions: - an attribute or value is selected - there are values in
+     * clipboard
+     * 
+     * @return
+     */
+    private IValue[] getValuesToPaste()
+    {
+        if ( ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length
+            + getSelectedSearches().length + getSelectedConnections().length == 0 && ( getSelectedAttributes().length
+            + getSelectedValues().length > 0 ) )
+            || ( getSelectedAttributes().length + getSelectedValues().length + getSelectedSearchResults().length
+                + getSelectedBookmarks().length + getSelectedSearches().length + getSelectedConnections().length == 0 && ( getSelectedEntries().length == 1 ) )
+            || ( getSelectedAttributes().length + getSelectedValues().length + getSelectedEntries().length
+                + getSelectedSearchResults().length + getSelectedSearches().length + getSelectedConnections().length == 0 && ( getSelectedBookmarks().length == 1 ) )
+            || ( getSelectedAttributes().length + getSelectedValues().length + getSelectedEntries().length
+                + getSelectedBookmarks().length + getSelectedSearches().length + getSelectedConnections().length == 0 && ( getSelectedSearchResults().length == 1 ) )
+
+        )
+        {
+
+            Object content = this.getFromClipboard( ValuesTransfer.getInstance() );
+            if ( content != null && content instanceof IValue[] )
+            {
+                IValue[] values = ( IValue[] ) content;
+                return values;
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Retrieve the data of the specified type currently available on the system clipboard.
+     *
+     * @param dataType
+     *      the transfer agent for the type of data being requested
+     * @return
+     *      the data obtained from the clipboard or null if no data of this type is available
+     */
+    protected Object getFromClipboard( Transfer dataType )
+    {
+        Clipboard clipboard = null;
+        try
+        {
+            clipboard = new Clipboard( Display.getCurrent() );
+            return clipboard.getContents( dataType );
+        }
+        finally
+        {
+            if ( clipboard != null )
+                clipboard.dispose();
+        }
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PropertiesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PropertiesAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PropertiesAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/PropertiesAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,155 @@
+/*
+ *  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.common.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
+
+
+/**
+ * This Action opens the Property Dialog for a given object.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PropertiesAction extends BrowserAction
+{
+    /**
+     * Creates a new instance of PropertiesAction.
+     */
+    public PropertiesAction()
+    {
+        super();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Properties";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return IWorkbenchActionDefinitionIds.PROPERTIES;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+
+        return getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length
+                + getSelectedSearches().length == 1 || getSelectedAttributes().length + getSelectedValues().length == 1
+            || ( getSelectedAttributeHierarchies().length == 1 && getSelectedAttributeHierarchies()[0].size() == 1 );
+
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+
+        IAdaptable element = null;
+        String pageId = null;
+        String title = null;
+
+        if ( getSelectedValues().length == 1 )
+        {
+            element = ( IAdaptable ) getSelectedValues()[0];
+            pageId = "org.apache.directory.studio.ldapbrowser.ui.dialogs.properties.ValuePropertyPage";
+            title = getSelectedValues()[0].toString();
+        }
+        else if ( getSelectedAttributes().length == 1 )
+        {
+            element = ( IAdaptable ) getSelectedAttributes()[0];
+            pageId = "org.apache.directory.studio.ldapbrowser.ui.dialogs.properties.AttributePropertyPage";
+            title = getSelectedAttributes()[0].toString();
+        }
+        else if ( getSelectedAttributeHierarchies().length == 1 )
+        {
+            IAttribute att = getSelectedAttributeHierarchies()[0].getAttribute();
+            element = att;
+            pageId = "org.apache.directory.studio.ldapbrowser.ui.dialogs.properties.AttributePropertyPage";
+            title = att.toString();
+        }
+        else if ( getSelectedSearches().length == 1 )
+        {
+            element = ( IAdaptable ) getSelectedSearches()[0];
+            pageId = "org.apache.directory.studio.ldapbrowser.ui.dialogs.properties.SearchPropertyPage";
+            title = getSelectedSearches()[0].getName();
+        }
+        else if ( getSelectedBookmarks().length == 1 )
+        {
+            element = ( IAdaptable ) getSelectedBookmarks()[0];
+            pageId = "org.apache.directory.studio.ldapbrowser.ui.dialogs.properties.BookmarkPropertyPage";
+            title = getSelectedBookmarks()[0].getName();
+        }
+        else if ( getSelectedEntries().length == 1 )
+        {
+            element = ( IAdaptable ) getSelectedEntries()[0];
+            pageId = "org.apache.directory.studio.ldapbrowser.ui.dialogs.properties.EntryPropertyPage";
+            title = getSelectedEntries()[0].getDn().getUpName();
+        }
+        else if ( getSelectedSearchResults().length == 1 )
+        {
+            element = ( IAdaptable ) getSelectedSearchResults()[0];
+            pageId = "org.apache.directory.studio.ldapbrowser.ui.dialogs.properties.EntryPropertyPage";
+            title = getSelectedSearchResults()[0].getDn().getUpName();
+        }
+
+        if ( element != null )
+        {
+            PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn( getShell(), element, pageId, null, null );
+            if ( dialog != null )
+                title = Utils.shorten( title, 30 );
+            dialog.getShell().setText( "Properties for '" + title + "'" );
+            dialog.open();
+
+        }
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RefreshAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,241 @@
+/*
+ *  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.common.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+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.core.jobs.InitializeAttributesJob;
+import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeChildrenJob;
+import org.apache.directory.studio.ldapbrowser.core.jobs.SearchJob;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * This Action refreshes the selected item.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RefreshAction extends BrowserAction
+{
+    /**
+     * Creates a new instance of RefreshAction.
+     */
+    public RefreshAction()
+    {
+        super();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        IEntry[] entries = getEntries();
+        ISearch[] searches = getSearches();
+        IEntry entryInput = getEntryInput();
+        ISearch searchInput = getSearchInput();
+
+        if ( entries.length > 0 && searches.length == 0 && entryInput == null && searchInput == null )
+        {
+            return "Reload Attributes and Children";
+        }
+        else if ( searches.length > 0 && entries.length == 0 && entryInput == null && searchInput == null )
+        {
+            boolean searchAgain = true;
+            for ( int i = 0; i < searches.length; i++ )
+            {
+                if ( searches[i].getSearchResults() == null )
+                {
+                    searchAgain = false;
+                    break;
+                }
+            }
+            if ( searchAgain )
+            {
+                return "Search Again";
+            }
+            else
+            {
+                return searches.length == 1 ? "Perform Search" : "Perform Searches";
+            }
+        }
+        else if ( entryInput != null && searches.length == 0 && entries.length == 0 && searchInput == null )
+        {
+            return "Reload Attributes";
+        }
+        else if ( searchInput != null && searches.length == 0 && entryInput == null )
+        {
+            return searchInput.getSearchResults() == null ? "Perform Search" : "Search Again";
+        }
+        else
+        {
+            return "Refresh";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_REFRESH );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return "org.eclipse.ui.file.refresh";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        IEntry[] entries = getEntries();
+        ISearch[] searches = getSearches();
+        IEntry entryInput = getEntryInput();
+        ISearch searchInput = getSearchInput();
+        boolean soa = BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
+            BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES );
+
+        if ( entries.length > 0 )
+        {
+            new InitializeAttributesJob( entries, soa ).execute();
+            new InitializeChildrenJob( entries ).execute();
+        }
+        if ( searches.length > 0 )
+        {
+            new SearchJob( searches ).execute();
+        }
+
+        if ( entryInput != null )
+        {
+            new InitializeAttributesJob( new IEntry[]
+                { entryInput }, soa ).execute();
+        }
+        if ( searchInput != null )
+        {
+            new SearchJob( new ISearch[]
+                { searchInput } ).execute();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        IEntry[] entries = getEntries();
+        ISearch[] searches = getSearches();
+        IEntry entryInput = getEntryInput();
+        ISearch searchInput = getSearchInput();
+
+        return entries.length > 0 || searches.length > 0 || entryInput != null || searchInput != null;
+    }
+
+
+    /**
+     * Gets the Entries
+     *
+     * @return
+     *      the entries
+     */
+    protected IEntry[] getEntries()
+    {
+        List<IEntry> entriesList = new ArrayList<IEntry>();
+        entriesList.addAll( Arrays.asList( getSelectedEntries() ) );
+        for ( int i = 0; i < getSelectedSearchResults().length; i++ )
+        {
+            entriesList.add( getSelectedSearchResults()[i].getEntry() );
+        }
+        for ( int i = 0; i < getSelectedBookmarks().length; i++ )
+        {
+            entriesList.add( getSelectedBookmarks()[i].getEntry() );
+        }
+        return ( IEntry[] ) entriesList.toArray( new IEntry[entriesList.size()] );
+    }
+
+
+    /**
+     * Gets the Searches.
+     *
+     * @return
+     *      the Searches
+     */
+    protected ISearch[] getSearches()
+    {
+        return getSelectedSearches();
+    }
+
+
+    /**
+     * Gets the Entry Input.
+     *
+     * @return
+     *      the Entry Input
+     */
+    private IEntry getEntryInput()
+    {
+        if ( getInput() != null && getInput() instanceof IEntry )
+        {
+            return ( IEntry ) getInput();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Gets the Search Input.
+     *
+     * @return
+     *      the Search Input
+     */
+    private ISearch getSearchInput()
+    {
+        if ( getInput() != null && getInput() instanceof ISearch )
+        {
+            return ( ISearch ) getInput();
+        }
+        else
+        {
+            return null;
+        }
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RenameAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RenameAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RenameAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/RenameAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,305 @@
+/*
+ *  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.common.actions;
+
+
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.studio.ldapbrowser.common.dialogs.RenameEntryDialog;
+import org.apache.directory.studio.ldapbrowser.core.jobs.RenameEntryJob;
+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.impl.RootDSE;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
+
+
+/**
+ * This Action renames Connections, Entries, Searches, or Bookmarks.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RenameAction extends BrowserAction
+{
+    /**
+     * Creates a new instance of RenameAction.
+     *
+     */
+    public RenameAction()
+    {
+        super();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+
+        IEntry[] entries = getEntries();
+        ISearch[] searches = getSearches();
+        IBookmark[] bookmarks = getBookmarks();
+
+        if ( entries.length == 1 && searches.length == 0 && bookmarks.length == 0 )
+        {
+            return "Rename Entry...";
+        }
+        else if ( searches.length == 1 && entries.length == 0 && bookmarks.length == 0 )
+        {
+            return "Rename Search...";
+        }
+        else if ( bookmarks.length == 1 && entries.length == 0 && searches.length == 0 )
+        {
+            return "Rename Bookmark...";
+        }
+        else
+        {
+            return "Rename";
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return IWorkbenchActionDefinitionIds.RENAME;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        IEntry[] entries = getEntries();
+        ISearch[] searches = getSearches();
+        IBookmark[] bookmarks = getBookmarks();
+
+        if ( entries.length == 1 && searches.length == 0 && bookmarks.length == 0 )
+        {
+            renameEntry( entries[0] );
+        }
+        else if ( searches.length == 1 && entries.length == 0 && bookmarks.length == 0 )
+        {
+            renameSearch( searches[0] );
+        }
+        else if ( bookmarks.length == 1 && entries.length == 0 && searches.length == 0 )
+        {
+            renameBookmark( bookmarks[0] );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        try
+        {
+            IEntry[] entries = getEntries();
+            ISearch[] searches = getSearches();
+            IBookmark[] bookmarks = getBookmarks();
+
+            return entries.length + searches.length + bookmarks.length == 1;
+
+        }
+        catch ( Exception e )
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the Entries
+     *
+     * @return
+     *      the Entries
+     */
+    protected IEntry[] getEntries()
+    {
+
+        IEntry entry = null;
+
+        if ( getSelectedEntries().length == 1 )
+        {
+            entry = getSelectedEntries()[0];
+        }
+        else if ( getSelectedSearchResults().length == 1 )
+        {
+            entry = getSelectedSearchResults()[0].getEntry();
+        }
+        else if ( getSelectedValues().length == 1 && getSelectedValues()[0].isRdnPart() )
+        {
+            entry = getSelectedValues()[0].getAttribute().getEntry();
+        }
+
+        if ( entry != null && !( entry instanceof RootDSE ) )
+        {
+            return new IEntry[]
+                { entry };
+        }
+        else
+        {
+            return new IEntry[0];
+        }
+    }
+
+
+    /**
+     * Renames an Entry.
+     *
+     * @param entry
+     *      the Entry to rename
+     */
+    protected void renameEntry( final IEntry entry )
+    {
+        RenameEntryDialog renameDialog = new RenameEntryDialog( getShell(), entry );
+        if ( renameDialog.open() == Dialog.OK )
+        {
+            Rdn newRdn = renameDialog.getRdn();
+            boolean deleteOldRdn = renameDialog.isDeleteOldRdn();
+            if ( newRdn != null && !newRdn.equals( entry.getRdn() ) )
+            {
+                new RenameEntryJob( entry, newRdn, deleteOldRdn ).execute();
+            }
+        }
+    }
+
+
+    /**
+     * Get the Searches.
+     *
+     * @return
+     *      the Searches
+     */
+    protected ISearch[] getSearches()
+    {
+        if ( getSelectedSearches().length == 1 )
+        {
+            return getSelectedSearches();
+        }
+        else
+        {
+            return new ISearch[0];
+        }
+    }
+
+
+    /**
+     * Renames a Search.
+     *
+     * @param search
+     *      the Search to rename
+     */
+    protected void renameSearch( final ISearch search )
+    {
+        IInputValidator validator = new IInputValidator()
+        {
+            public String isValid( String newName )
+            {
+                if ( search.getName().equals( newName ) )
+                    return null;
+                else if ( search.getBrowserConnection().getSearchManager().getSearch( newName ) != null )
+                    return "A connection with this name already exists.";
+                else
+                    return null;
+            }
+        };
+
+        InputDialog dialog = new InputDialog( getShell(), "Rename Search", "New name:", search.getName(), validator );
+
+        dialog.open();
+        String newName = dialog.getValue();
+        if ( newName != null )
+        {
+            search.setName( newName );
+        }
+    }
+
+
+    /**
+     * Get the Bookmarks
+     *
+     * @return
+     *      the Bookmarks
+     */
+    protected IBookmark[] getBookmarks()
+    {
+        if ( getSelectedBookmarks().length == 1 )
+        {
+            return getSelectedBookmarks();
+        }
+        else
+        {
+            return new IBookmark[0];
+        }
+    }
+
+
+    /**
+     * Renames a Bookmark
+     *
+     * @param bookmark
+     *      the Bookmark to rename
+     */
+    protected void renameBookmark( final IBookmark bookmark )
+    {
+        IInputValidator validator = new IInputValidator()
+        {
+            public String isValid( String newName )
+            {
+                if ( bookmark.getName().equals( newName ) )
+                    return null;
+                else if ( bookmark.getBrowserConnection().getBookmarkManager().getBookmark( newName ) != null )
+                    return "A bookmark with this name already exists.";
+                else
+                    return null;
+            }
+        };
+
+        InputDialog dialog = new InputDialog( getShell(), "Rename Bookmark", "New name:", bookmark.getName(), validator );
+
+        dialog.open();
+        String newName = dialog.getValue();
+        if ( newName != null )
+        {
+            bookmark.setName( newName );
+        }
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/SelectAllAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/SelectAllAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/SelectAllAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/SelectAllAction.java Mon Nov  5 08:48:35 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.common.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.studio.connection.core.ConnectionManager;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
+
+
+/**
+ * This class implements the Select All Action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SelectAllAction extends BrowserAction
+{
+    private Viewer viewer;
+
+
+    /**
+     * Creates a new instance of SelectAllAction.
+     *
+     * @param viewer
+     *      the attached viewer
+     */
+    public SelectAllAction( Viewer viewer )
+    {
+        this.viewer = viewer;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Select All";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return IWorkbenchActionDefinitionIds.SELECT_ALL;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        if ( getInput() != null && getInput() instanceof IEntry )
+        {
+            List selectionList = new ArrayList();
+            IAttribute[] attributes = ( ( IEntry ) getInput() ).getAttributes();
+            if ( attributes != null )
+            {
+                selectionList.addAll( Arrays.asList( attributes ) );
+                for ( int i = 0; i < attributes.length; i++ )
+                {
+                    selectionList.addAll( Arrays.asList( attributes[i].getValues() ) );
+                }
+            }
+            StructuredSelection selection = new StructuredSelection( selectionList );
+            this.viewer.setSelection( selection );
+        }
+        else if ( getInput() != null && getInput() instanceof ConnectionManager )
+        {
+            StructuredSelection selection = new StructuredSelection( ( ( ConnectionManager ) getInput() )
+                .getConnections() );
+            this.viewer.setSelection( selection );
+        }
+        else if ( getSelectedConnections().length > 0 && viewer.getInput() instanceof ConnectionManager )
+        {
+            StructuredSelection selection = new StructuredSelection( ( ( ConnectionManager ) viewer.getInput() )
+                .getConnections() );
+            this.viewer.setSelection( selection );
+        }
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ShowRawValuesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ShowRawValuesAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ShowRawValuesAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ShowRawValuesAction.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,77 @@
+/*
+ *  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.common.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.eclipse.jface.action.Action;
+
+
+/**
+ * This Action toggles the Show Raw Values Preference.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowRawValuesAction extends Action
+{
+    /**
+     * Creates a new instance of ShowRawValuesAction.
+     */
+    public ShowRawValuesAction()
+    {
+        super( "Show Raw Values", AS_CHECK_BOX );
+        super.setToolTipText( getText() );
+        super.setEnabled( true );
+
+        super.setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
+            BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        BrowserCommonActivator.getDefault().getPreferenceStore().setValue( BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES,
+            super.isChecked() );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setChecked( boolean checked )
+    {
+        super.setChecked( checked );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isChecked()
+    {
+        return super.isChecked();
+    }
+}

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



Mime
View raw message