directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r526693 [4/17] - in /directory/ldapstudio/trunk/ldapstudio-browser-common: ./ META-INF/ resources/ resources/icons/ resources/templates/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/dir...
Date Mon, 09 Apr 2007 09:49:57 GMT
Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/RefreshAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/RefreshAction.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/RefreshAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/RefreshAction.java Mon Apr  9 02:49:48 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.ldapstudio.browser.common.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
+import org.apache.directory.ldapstudio.browser.core.jobs.InitializeAttributesJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.InitializeChildrenJob;
+import org.apache.directory.ldapstudio.browser.core.jobs.SearchJob;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.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;
+        }
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/RenameAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/RenameAction.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/RenameAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/RenameAction.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,370 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.actions;
+
+
+import org.apache.directory.ldapstudio.browser.common.dialogs.RenameEntryDialog;
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.internal.model.RootDSE;
+import org.apache.directory.ldapstudio.browser.core.jobs.RenameEntryJob;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.RDN;
+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()
+    {
+
+        IConnection[] connections = getConnections();
+        IEntry[] entries = getEntries();
+        ISearch[] searches = getSearches();
+        IBookmark[] bookmarks = getBookmarks();
+
+        if ( connections.length == 1 && entries.length == 0 && searches.length == 0 && bookmarks.length == 0 )
+        {
+            return "Rename Connection...";
+        }
+        else if ( entries.length == 1 && connections.length == 0 && searches.length == 0 && bookmarks.length == 0 )
+        {
+            return "Rename Entry...";
+        }
+        else if ( searches.length == 1 && connections.length == 0 && entries.length == 0 && bookmarks.length == 0 )
+        {
+            return "Rename Search...";
+        }
+        else if ( bookmarks.length == 1 && connections.length == 0 && 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()
+    {
+        IConnection[] connections = getConnections();
+        IEntry[] entries = getEntries();
+        ISearch[] searches = getSearches();
+        IBookmark[] bookmarks = getBookmarks();
+
+        if ( connections.length == 1 && entries.length == 0 && searches.length == 0 && bookmarks.length == 0 )
+        {
+            renameConnection( connections[0] );
+        }
+        else if ( entries.length == 1 && connections.length == 0 && searches.length == 0 && bookmarks.length == 0 )
+        {
+            renameEntry( entries[0] );
+        }
+        else if ( searches.length == 1 && connections.length == 0 && entries.length == 0 && bookmarks.length == 0 )
+        {
+            renameSearch( searches[0] );
+        }
+        else if ( bookmarks.length == 1 && connections.length == 0 && entries.length == 0 && searches.length == 0 )
+        {
+            renameBookmark( bookmarks[0] );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        try
+        {
+            IConnection[] connections = getConnections();
+            IEntry[] entries = getEntries();
+            ISearch[] searches = getSearches();
+            IBookmark[] bookmarks = getBookmarks();
+
+            return connections.length + entries.length + searches.length + bookmarks.length == 1;
+
+        }
+        catch ( Exception e )
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Gets the Connections
+     * 
+     * @return
+     *      the Connections
+     */
+    protected IConnection[] getConnections()
+    {
+        if ( getSelectedConnections().length == 1 )
+        {
+            return getSelectedConnections();
+        }
+        else
+        {
+            return new IConnection[0];
+        }
+    }
+
+
+    /**
+     * Renames a Connection.
+     *
+     * @param connection
+     *      the Connection to rename
+     */
+    protected void renameConnection( final IConnection connection )
+    {
+        IInputValidator validator = new IInputValidator()
+        {
+            public String isValid( String newName )
+            {
+                if ( connection.getName().equals( newName ) )
+                    return null;
+                else if ( BrowserCorePlugin.getDefault().getConnectionManager().getConnection( newName ) != null )
+                    return "A connection with this name already exists.";
+                else
+                    return null;
+            }
+        };
+
+        InputDialog dialog = new InputDialog( getShell(), "Rename Connection", "New name:", connection.getName(),
+            validator );
+
+        dialog.open();
+        String newName = dialog.getValue();
+        if ( newName != null )
+        {
+            connection.setName( newName );
+        }
+    }
+
+
+    /**
+     * 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.getConnection().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.getConnection().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 );
+        }
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/SelectAllAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/SelectAllAction.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/SelectAllAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/SelectAllAction.java Mon Apr  9 02:49:48 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.ldapstudio.browser.common.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.ConnectionManager;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.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 );
+        }
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/SelectionUtils.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/SelectionUtils.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/SelectionUtils.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/SelectionUtils.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,452 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.actions;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserCategory;
+import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserEntryPage;
+import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserSearchResultPage;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Search;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.ldapstudio.browser.core.utils.LdapFilterUtils;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+
+/**
+ * The SelectionUtils are used to extract specific beans from the current
+ * selection (org.eclipse.jface.viewers.ISelection).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class SelectionUtils
+{
+
+    /**
+     * This method creates a prototype search from the given selection.
+     * 
+     * Dependend on the selected element it determines the best connection,
+     * search base and filter:
+     * <ul>
+     *   <li>ISearch: all parameters are copied to the prototype search (clone)
+     *   <li>IEntry or ISearchResult or IBookmark: DN is used as search base
+     *   <li>IAttribute or IValue: the entry's DN is used as search base, 
+     *       the filter is built using the name-value-pairs (query by example). 
+     * </ul>
+     * 
+     * 
+     * @param selection the current selection
+     * @return a prototype search
+     */
+    public static ISearch getExampleSearch( ISelection selection )
+    {
+
+        ISearch exampleSearch = new Search();
+        String oldName = exampleSearch.getSearchParameter().getName();
+        exampleSearch.getSearchParameter().setName( null );
+        exampleSearch.setScope( ISearch.SCOPE_SUBTREE );
+
+        if ( selection != null && !selection.isEmpty() && selection instanceof StructuredSelection )
+        {
+
+            Object[] objects = ( ( IStructuredSelection ) selection ).toArray();
+            Comparator<Object> comparator = new Comparator<Object>()
+            {
+                public int compare( Object o1, Object o2 )
+                {
+                    if ( ( o1 instanceof IValue ) && !( o2 instanceof IValue ) )
+                    {
+                        return -1;
+                    }
+                    else if ( !( o1 instanceof IValue ) && ( o2 instanceof IValue ) )
+                    {
+                        return 1;
+                    }
+                    else if ( ( o1 instanceof IAttribute ) && !( o2 instanceof IAttribute ) )
+                    {
+                        return -1;
+                    }
+                    else if ( !( o1 instanceof IAttribute ) && ( o2 instanceof IAttribute ) )
+                    {
+                        return 1;
+                    }
+                    else if ( ( o1 instanceof AttributeHierarchy ) && !( o2 instanceof AttributeHierarchy ) )
+                    {
+                        return -1;
+                    }
+                    else if ( !( o1 instanceof AttributeHierarchy ) && ( o2 instanceof AttributeHierarchy ) )
+                    {
+                        return 1;
+                    }
+                    return 0;
+                }
+            };
+            Arrays.sort( objects, comparator );
+            Object obj = objects[0];
+
+            if ( obj instanceof ISearch )
+            {
+                ISearch search = ( ISearch ) obj;
+                exampleSearch = ( ISearch ) search.clone();
+                exampleSearch.setName( null );
+            }
+            else if ( obj instanceof IEntry )
+            {
+                IEntry entry = ( IEntry ) obj;
+                exampleSearch.setConnection( entry.getConnection() );
+                exampleSearch.setSearchBase( entry.getDn() );
+            }
+            else if ( obj instanceof ISearchResult )
+            {
+                ISearchResult searchResult = ( ISearchResult ) obj;
+                exampleSearch.setConnection( searchResult.getEntry().getConnection() );
+                exampleSearch.setSearchBase( searchResult.getEntry().getDn() );
+            }
+            else if ( obj instanceof IBookmark )
+            {
+                IBookmark bookmark = ( IBookmark ) obj;
+                exampleSearch.setConnection( bookmark.getConnection() );
+                exampleSearch.setSearchBase( bookmark.getDn() );
+            }
+
+            else if ( obj instanceof AttributeHierarchy || obj instanceof IAttribute || obj instanceof IValue )
+            {
+
+                IEntry entry = null;
+                Set<String> filterSet = new LinkedHashSet<String>();
+                for ( int i = 0; i < objects.length; i++ )
+                {
+                    Object object = objects[i];
+                    if ( object instanceof AttributeHierarchy )
+                    {
+                        AttributeHierarchy ah = ( AttributeHierarchy ) object;
+                        for ( Iterator it = ah.iterator(); it.hasNext(); )
+                        {
+                            IAttribute attribute = ( IAttribute ) it.next();
+                            entry = attribute.getEntry();
+                            IValue[] values = attribute.getValues();
+                            for ( int v = 0; v < values.length; v++ )
+                            {
+                                filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
+                            }
+                        }
+                    }
+                    else if ( object instanceof IAttribute )
+                    {
+                        IAttribute attribute = ( IAttribute ) object;
+                        entry = attribute.getEntry();
+                        IValue[] values = attribute.getValues();
+                        for ( int v = 0; v < values.length; v++ )
+                        {
+                            filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
+                        }
+                    }
+                    else if ( object instanceof IValue )
+                    {
+                        IValue value = ( IValue ) object;
+                        entry = value.getAttribute().getEntry();
+                        filterSet.add( LdapFilterUtils.getFilter( value ) );
+                    }
+                }
+
+                exampleSearch.setConnection( entry.getConnection() );
+                exampleSearch.setSearchBase( entry.getDn() );
+                StringBuffer filter = new StringBuffer();
+                if ( filterSet.size() > 1 )
+                {
+                    filter.append( "(&" );
+                    for ( Iterator<String> filterIterator = filterSet.iterator(); filterIterator.hasNext(); )
+                    {
+                        filter.append( filterIterator.next() );
+                    }
+                    filter.append( ")" );
+                }
+                else if ( filterSet.size() == 1 )
+                {
+                    filter.append( filterSet.toArray()[0] );
+                }
+                else
+                {
+                    filter.append( ISearch.FILTER_TRUE );
+                }
+                exampleSearch.setFilter( filter.toString() );
+            }
+
+            else if ( obj instanceof IConnection )
+            {
+                IConnection connection = ( IConnection ) obj;
+                exampleSearch.setConnection( connection );
+                if ( connection.getRootDSE().getChildrenCount() > 0 )
+                {
+                    exampleSearch.setSearchBase( connection.getRootDSE().getChildren()[0].getDn() );
+                }
+                else
+                {
+                    exampleSearch.setSearchBase( connection.getRootDSE().getDn() );
+                }
+            }
+            else if ( obj instanceof BrowserCategory )
+            {
+                BrowserCategory cat = ( BrowserCategory ) obj;
+                exampleSearch.setConnection( cat.getParent() );
+                if ( cat.getParent().getRootDSE().getChildrenCount() > 0 )
+                {
+                    exampleSearch.setSearchBase( cat.getParent().getRootDSE().getChildren()[0].getDn() );
+                }
+                else
+                {
+                    exampleSearch.setSearchBase( cat.getParent().getRootDSE().getDn() );
+                }
+            }
+
+        }
+
+        exampleSearch.getSearchParameter().setName( oldName );
+        return exampleSearch;
+    }
+
+
+    /**
+     * Gets the BrowserCategory beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with BrowserCategory beans, may be empty.
+     */
+    public static BrowserCategory[] getBrowserViewCategories( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, BrowserCategory.class );
+        return list.toArray( new BrowserCategory[list.size()] );
+    }
+
+
+    /**
+     * Gets the IValue beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with IValue beans, may be empty.
+     */
+    public static IValue[] getValues( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, IValue.class );
+        return list.toArray( new IValue[list.size()] );
+    }
+
+
+    /**
+     * Gets the IAttribute beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with IAttribute beans, may be empty.
+     */
+    public static IAttribute[] getAttributes( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, IAttribute.class );
+        return list.toArray( new IAttribute[list.size()] );
+    }
+
+
+    /**
+     * Gets the AttributeHierarchy beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with AttributeHierarchy beans, may be empty.
+     */
+    public static AttributeHierarchy[] getAttributeHierarchie( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, AttributeHierarchy.class );
+        return list.toArray( new AttributeHierarchy[list.size()] );
+    }
+
+
+    /**
+     * Gets the Strings contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with Strings, may be empty.
+     */
+    public static String[] getProperties( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, String.class );
+        return list.toArray( new String[list.size()] );
+    }
+
+
+    /**
+     * Gets the AttributeTypeDescription beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with AttributeTypeDescription beans, may be empty.
+     */
+    public static AttributeTypeDescription[] getAttributeTypeDescription( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, AttributeTypeDescription.class );
+        return list.toArray( new AttributeTypeDescription[list.size()] );
+    }
+
+
+    /**
+     * Gets the IEntry beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with IEntry beans, may be empty.
+     */
+    public static IEntry[] getEntries( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, IEntry.class );
+        return list.toArray( new IEntry[list.size()] );
+    }
+
+
+    /**
+     * Gets the IBookmark beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with IBookmark beans, may be empty.
+     */
+    public static IBookmark[] getBookmarks( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, IBookmark.class );
+        return list.toArray( new IBookmark[list.size()] );
+    }
+
+
+    /**
+     * Gets the ISearchResult beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with ISearchResult beans, may be empty.
+     */
+    public static ISearchResult[] getSearchResults( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, ISearchResult.class );
+        return list.toArray( new ISearchResult[list.size()] );
+    }
+
+
+    /**
+     * Gets all beans of the requested type contained in the given selection.
+     *
+     * @param selection the selection
+     * @param type the requested type
+     * @return a list containg beans of the requesten type
+     */
+    private static List<Object> getTypes( ISelection selection, Class type )
+    {
+        List<Object> list = new ArrayList<Object>();
+        if ( selection instanceof IStructuredSelection )
+        {
+            IStructuredSelection structuredSelection = ( IStructuredSelection ) selection;
+            Iterator it = structuredSelection.iterator();
+            while ( it.hasNext() )
+            {
+                Object o = it.next();
+                if ( type.isInstance( o ) )
+                {
+                    list.add( o );
+                }
+            }
+        }
+        return list;
+    }
+
+
+    /**
+     * Gets the ISearch beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with ISearch beans, may be empty.
+     */
+    public static ISearch[] getSearches( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, ISearch.class );
+        return list.toArray( new ISearch[list.size()] );
+    }
+
+
+    /**
+     * Gets the IConnection beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with IConnection beans, may be empty.
+     */
+    public static IConnection[] getConnections( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, IConnection.class );
+        return list.toArray( new IConnection[list.size()] );
+    }
+
+
+    /**
+     * Gets the BrowserEntryPage beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with BrowserEntryPage beans, may be empty.
+     */
+    public static BrowserEntryPage[] getBrowserEntryPages( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, BrowserEntryPage.class );
+        return list.toArray( new BrowserEntryPage[list.size()] );
+    }
+
+
+    /**
+     * Gets the BrowserSearchResultPage beans contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with BrowserSearchResultPage beans, may be empty.
+     */
+    public static BrowserSearchResultPage[] getBrowserSearchResultPages( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, BrowserSearchResultPage.class );
+        return list.toArray( new BrowserSearchResultPage[list.size()] );
+    }
+
+    
+    /**
+     * Gets the objects contained in the given selection.
+     *
+     * @param selection the selection
+     * @return an array with object, may be empty.
+     */
+    public static Object[] getObjects( ISelection selection )
+    {
+        List<Object> list = getTypes( selection, Object.class );
+        return list.toArray( new Object[list.size()] );
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/ShowRawValuesAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/ShowRawValuesAction.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/ShowRawValuesAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/ShowRawValuesAction.java Mon Apr  9 02:49:48 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.ldapstudio.browser.common.actions;
+
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.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();
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/UnfilterChildrenAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/UnfilterChildrenAction.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/UnfilterChildrenAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/UnfilterChildrenAction.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,97 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.actions;
+
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
+import org.apache.directory.ldapstudio.browser.core.jobs.InitializeChildrenJob;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * This action removes the children filter from the currently selected entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class UnfilterChildrenAction extends BrowserAction
+{
+    /**
+     * Creates a new instance of UnfilterChildrenAction.
+     */
+    public UnfilterChildrenAction()
+    {
+        super();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        if ( getSelectedEntries().length == 1 )
+        {
+            getSelectedEntries()[0].setChildrenFilter( null );
+            new InitializeChildrenJob( new IEntry[]
+                { getSelectedEntries()[0] } ).execute();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Remove Children Filter";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_UNFILTER_DIT );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getSelectedSearches().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 0
+            && getSelectedEntries().length == 1 && getSelectedEntries()[0].getChildrenFilter() != null;
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/UpAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/UpAction.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/UpAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/UpAction.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,153 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.actions;
+
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
+import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserEntryPage;
+import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserSearchResultPage;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+
+
+/**
+ * This class implements the Up Action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class UpAction extends BrowserAction
+{
+    protected TreeViewer viewer;
+
+
+    /**
+     * Creates a new instance of UpAction.
+     *
+     * @param viewer
+     *      the attached TreeViewer
+     */
+    public UpAction( TreeViewer viewer )
+    {
+        super();
+        this.viewer = viewer;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Up";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_PARENT );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return "org.apache.directory.ldapstudio.browser.action.openSearchResult";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        IEntry[] entries = getSelectedEntries();
+        ISearch[] searches = getSelectedSearches();
+        ISearchResult[] searchResults = getSelectedSearchResults();
+        IBookmark[] bookmarks = getSelectedBookmarks();
+        BrowserEntryPage[] browserEntryPages = getSelectedBrowserEntryPages();
+        BrowserSearchResultPage[] browserSearchResultPages = getSelectedBrowserSearchResultPages();
+
+        Object selection = null;
+
+        if ( entries.length > 0 )
+        {
+            selection = entries[0];
+        }
+        else if ( searches.length > 0 )
+        {
+            selection = searches[0];
+        }
+        else if ( searchResults.length > 0 )
+        {
+            selection = searchResults[0];
+        }
+        else if ( bookmarks.length > 0 )
+        {
+            selection = bookmarks[0];
+        }
+        else if ( browserEntryPages.length > 0 )
+        {
+            selection = browserEntryPages[0];
+        }
+        else if ( browserSearchResultPages.length > 0 )
+        {
+            selection = browserSearchResultPages[0];
+        }
+
+        if ( selection != null )
+        {
+            ITreeContentProvider contentProvider = ( ITreeContentProvider ) viewer.getContentProvider();
+            Object newSelection = contentProvider.getParent( selection );
+            viewer.reveal( newSelection );
+            viewer.setSelection( new StructuredSelection( newSelection ), true );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        IEntry[] entries = getSelectedEntries();
+        ISearch[] searches = getSelectedSearches();
+        ISearchResult[] searchResults = getSelectedSearchResults();
+        IBookmark[] bookmarks = getSelectedBookmarks();
+        BrowserEntryPage[] browserEntryPages = getSelectedBrowserEntryPages();
+        BrowserSearchResultPage[] browserSearchResultPages = getSelectedBrowserSearchResultPages();
+
+        return entries.length > 0 || searches.length > 0 || searchResults.length > 0 || bookmarks.length > 0
+            || browserEntryPages.length > 0 || browserSearchResultPages.length > 0;
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/ValueEditorPreferencesAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/ValueEditorPreferencesAction.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/ValueEditorPreferencesAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/ValueEditorPreferencesAction.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,60 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.actions;
+
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+/**
+ * This Action opens the Value Editors Preference Page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ValueEditorPreferencesAction extends Action
+{
+    /**
+     * Creates a new instance of ValueEditorPreferencesAction.
+     */
+    public ValueEditorPreferencesAction()
+    {
+        super.setText( "Preferences..." );
+        super.setToolTipText( "Preferences..." );
+        super.setEnabled( true );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        Shell shell = Display.getCurrent().getActiveShell();
+        String pageId = BrowserCommonConstants.PREFERENCEPAGEID_VALUEEDITORS;
+        PreferencesUtil.createPreferenceDialogOn( shell, pageId, new String[]
+            { pageId }, null ).open();
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/BrowserActionProxy.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/BrowserActionProxy.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/BrowserActionProxy.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/BrowserActionProxy.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,204 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.common.actions.BrowserAction;
+import org.apache.directory.ldapstudio.browser.common.actions.SelectionUtils;
+import org.apache.directory.ldapstudio.browser.core.events.BookmarkUpdateEvent;
+import org.apache.directory.ldapstudio.browser.core.events.BookmarkUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.ConnectionUpdateEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ConnectionUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateEvent;
+import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateListener;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+
+public abstract class BrowserActionProxy extends Action implements ISelectionChangedListener, EntryUpdateListener,
+    SearchUpdateListener, BookmarkUpdateListener, ConnectionUpdateListener
+{
+
+    protected BrowserAction action;
+
+    protected ISelectionProvider selectionProvider;
+
+
+    protected BrowserActionProxy( ISelectionProvider selectionProvider, BrowserAction action, int style )
+    {
+        super( action.getText(), style );
+        this.selectionProvider = selectionProvider;
+        this.action = action;
+
+        super.setImageDescriptor( action.getImageDescriptor() );
+        super.setActionDefinitionId( action.getCommandId() );
+
+        this.selectionProvider.addSelectionChangedListener( this );
+        // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener(this);
+
+        EventRegistry.addConnectionUpdateListener( this );
+        EventRegistry.addEntryUpdateListener( this );
+        EventRegistry.addSearchUpdateListener( this );
+        EventRegistry.addBookmarkUpdateListener( this );
+
+        this.updateAction();
+
+    }
+
+
+    protected BrowserActionProxy( ISelectionProvider selectionProvider, BrowserAction action )
+    {
+        this( selectionProvider, action, Action.AS_PUSH_BUTTON );
+    }
+
+
+    public void dispose()
+    {
+        EventRegistry.removeConnectionUpdateListener( this );
+        EventRegistry.removeEntryUpdateListener( this );
+        EventRegistry.removeSearchUpdateListener( this );
+        EventRegistry.removeBookmarkUpdateListener( this );
+        this.selectionProvider.removeSelectionChangedListener( this );
+        // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removeSelectionListener(this);
+
+        this.action.dispose();
+        this.action = null;
+    }
+
+
+    public boolean isDisposed()
+    {
+        return this.action == null;
+    }
+
+
+    public final void entryUpdated( EntryModificationEvent entryModificationEvent )
+    {
+        if ( !this.isDisposed() )
+        {
+            this.action.entryUpdated( entryModificationEvent );
+            this.updateAction();
+        }
+    }
+
+
+    public void searchUpdated( SearchUpdateEvent searchUpdateEvent )
+    {
+        if ( !this.isDisposed() )
+        {
+            this.action.searchUpdated( searchUpdateEvent );
+            this.updateAction();
+        }
+    }
+
+
+    public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent )
+    {
+        if ( !this.isDisposed() )
+        {
+            this.action.bookmarkUpdated( bookmarkUpdateEvent );
+            this.updateAction();
+        }
+    }
+
+
+    public final void connectionUpdated( ConnectionUpdateEvent connectionUpdateEvent )
+    {
+        if ( !this.isDisposed() )
+        {
+            this.action.connectionUpdated( connectionUpdateEvent );
+            this.updateAction();
+        }
+    }
+
+
+    public void inputChanged( Object input )
+    {
+        if ( !this.isDisposed() )
+        {
+            this.action.setInput( input );
+            this.selectionChanged( new SelectionChangedEvent( this.selectionProvider, new StructuredSelection() ) );
+            // this.updateAction();
+        }
+    }
+
+
+    public void selectionChanged( SelectionChangedEvent event )
+    {
+        if ( !this.isDisposed() )
+        {
+            ISelection selection = event.getSelection();
+
+            this.action.setSelectedConnections( SelectionUtils.getConnections( selection ) );
+
+            this.action.setSelectedBrowserViewCategories( SelectionUtils.getBrowserViewCategories( selection ) );
+            this.action.setSelectedEntries( SelectionUtils.getEntries( selection ) );
+            this.action.setSelectedBrowserEntryPages( SelectionUtils.getBrowserEntryPages( selection ) );
+            this.action.setSelectedSearchResults( SelectionUtils.getSearchResults( selection ) );
+            this.action.setSelectedBrowserSearchResultPages( SelectionUtils.getBrowserSearchResultPages( selection ) );
+            this.action.setSelectedBookmarks( SelectionUtils.getBookmarks( selection ) );
+
+            this.action.setSelectedSearches( SelectionUtils.getSearches( selection ) );
+
+            this.action.setSelectedAttributes( SelectionUtils.getAttributes( selection ) );
+            this.action.setSelectedAttributeHierarchies( SelectionUtils.getAttributeHierarchie( selection ) );
+            this.action.setSelectedValues( SelectionUtils.getValues( selection ) );
+            this.updateAction();
+        }
+    }
+
+
+    public void updateAction()
+    {
+        if ( !this.isDisposed() )
+        {
+            this.setText( this.action.getText() );
+            this.setToolTipText( this.action.getText() );
+            this.setEnabled( this.action.isEnabled() );
+            this.setImageDescriptor( this.action.getImageDescriptor() );
+        }
+    }
+
+
+    public void run()
+    {
+        if ( !this.isDisposed() )
+        {
+            this.action.run();
+        }
+    }
+
+
+    public BrowserAction getAction()
+    {
+        return action;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/BrowserViewActionProxy.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/BrowserViewActionProxy.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/BrowserViewActionProxy.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/BrowserViewActionProxy.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.common.actions.BrowserAction;
+import org.eclipse.jface.viewers.Viewer;
+
+
+public class BrowserViewActionProxy extends BrowserActionProxy
+{
+
+    public BrowserViewActionProxy( Viewer viewer, BrowserAction action, int style )
+    {
+        super( viewer, action, style );
+    }
+
+
+    public BrowserViewActionProxy( Viewer viewer, BrowserAction action )
+    {
+        super( viewer, action );
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/ConnectionViewActionProxy.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/ConnectionViewActionProxy.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/ConnectionViewActionProxy.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/ConnectionViewActionProxy.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.common.actions.BrowserAction;
+import org.eclipse.jface.viewers.Viewer;
+
+
+public class ConnectionViewActionProxy extends BrowserActionProxy
+{
+
+    public ConnectionViewActionProxy( Viewer viewer, BrowserAction action, int style )
+    {
+        super( viewer, action, style );
+    }
+
+
+    public ConnectionViewActionProxy( Viewer viewer, BrowserAction action )
+    {
+        super( viewer, action );
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/EntryEditorActionProxy.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/EntryEditorActionProxy.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/EntryEditorActionProxy.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/actions/proxy/EntryEditorActionProxy.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.actions.proxy;
+
+
+import org.apache.directory.ldapstudio.browser.common.actions.BrowserAction;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.Viewer;
+
+
+public class EntryEditorActionProxy extends BrowserActionProxy implements ISelectionChangedListener
+{
+
+    public EntryEditorActionProxy( Viewer viewer, BrowserAction action, int style )
+    {
+        super( viewer, action, style );
+    }
+
+
+    public EntryEditorActionProxy( Viewer viewer, BrowserAction action )
+    {
+        super( viewer, action );
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/CredentialsDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/CredentialsDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/CredentialsDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/CredentialsDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.dialogs;
+
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class CredentialsDialog extends InputDialog
+{
+
+    public CredentialsDialog( Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
+        IInputValidator validator )
+    {
+        super( parentShell, dialogTitle, dialogMessage, initialValue, validator );
+    }
+
+
+    protected void setShellStyle( int newShellStyle )
+    {
+        super.setShellStyle( newShellStyle );
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        super.getText().setEchoChar( '*' );
+        return composite;
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/FilterDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/FilterDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/FilterDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/FilterDialog.java Mon Apr  9 02:49:48 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.ldapstudio.browser.common.dialogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
+import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants;
+import org.apache.directory.ldapstudio.browser.common.filtereditor.FilterSourceViewerConfiguration;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.filter.parser.LdapFilterParser;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.VerticalRuler;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class FilterDialog extends Dialog
+{
+
+    public static final String DIALOG_TITLE = "Filter Editor";
+
+    private String title;
+
+    private IConnection connection;
+
+    private SourceViewer sourceViewer;
+
+    private FilterSourceViewerConfiguration configuration;
+
+    private LdapFilterParser parser;
+
+    private String filter;
+
+
+    public FilterDialog( Shell parentShell, String title, String filter, IConnection connection )
+    {
+        super( parentShell );
+        this.title = title;
+        this.filter = filter;
+        this.connection = connection;
+        this.parser = new LdapFilterParser();
+        setShellStyle( SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE );
+    }
+
+
+    public String getFilter()
+    {
+        return this.filter;
+    }
+
+
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( this.title != null ? this.title : DIALOG_TITLE );
+        //newShell.setImage( Activator.getDefault().getImage( BrowserWidgetsConstants.IMG_FILTER_EQUALS ) );
+    }
+
+
+    protected void buttonPressed( int buttonId )
+    {
+        if ( buttonId == IDialogConstants.OK_ID )
+        {
+            // this.filter = sourceViewer.getDocument().get();
+            this.parser.parse( sourceViewer.getDocument().get() );
+            this.filter = this.parser.getModel().toString();
+        }
+        else if ( buttonId == 987654321 )
+        {
+            IRegion region = new Region( 0, sourceViewer.getDocument().getLength() );
+            configuration.getContentFormatter( sourceViewer ).format( sourceViewer.getDocument(), region );
+        }
+
+        // call super implementation
+        super.buttonPressed( buttonId );
+    }
+
+
+    protected Control createButtonBar( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createButtonBar( parent );
+        super.createButton( composite, 987654321, "Format", false );
+        return composite;
+    }
+
+
+    protected Control createDialogArea( Composite parent )
+    {
+        // Composite composite = parent;
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        composite.setLayoutData( gd );
+
+        // create and configure source viewer
+        sourceViewer = new SourceViewer( composite, new VerticalRuler( 0 ), SWT.H_SCROLL | SWT.V_SCROLL );
+        sourceViewer.getControl().setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        configuration = new FilterSourceViewerConfiguration( this.sourceViewer, this.parser, this.connection );
+        sourceViewer.configure( configuration );
+
+        // set document
+        IDocument document = new Document( this.filter );
+        sourceViewer.setDocument( document );
+
+        // preformat
+        IRegion region = new Region( 0, sourceViewer.getDocument().getLength() );
+        configuration.getContentFormatter( sourceViewer ).format( sourceViewer.getDocument(), region );
+
+        sourceViewer.getTextWidget().setFocus();
+
+        return composite;
+    }
+
+
+    protected boolean canHandleShellCloseEvent()
+    {
+        // proposal popup is opened, don't close dialog!
+        return super.canHandleShellCloseEvent();
+    }
+
+}

Added: directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/FilterWidgetDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/FilterWidgetDialog.java?view=auto&rev=526693
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/FilterWidgetDialog.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-common/src/main/java/org/apache/directory/ldapstudio/browser/common/dialogs/FilterWidgetDialog.java Mon Apr  9 02:49:48 2007
@@ -0,0 +1,138 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.common.dialogs;
+
+
+import org.apache.directory.ldapstudio.browser.common.widgets.search.FilterWidget;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * This dialog is used to enter a LDAP filter.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class FilterWidgetDialog extends Dialog
+{
+
+    /** The title */
+    private String title;
+
+    /** The connection, used for attribute completion. */
+    private IConnection connection;
+
+    /** The filter widget. */
+    private FilterWidget filterWidget;
+
+    /** The filter. */
+    private String filter;
+
+
+    /**
+     * Creates a new instance of FilterWidgetDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param title the dialog's title
+     * @param filter the inital filter
+     * @param connection the connection, used for attribute completion
+     */
+    public FilterWidgetDialog( Shell parentShell, String title, String filter, IConnection connection )
+    {
+        super( parentShell );
+        this.title = title;
+        this.filter = filter;
+        this.connection = connection;
+        setShellStyle( SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE );
+    }
+
+
+    /**
+     * Gets the filter.
+     * 
+     * @return the filter
+     */
+    public String getFilter()
+    {
+        return filter;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( title );
+        //newShell.setImage( Activator.getDefault().getImage( BrowserWidgetsConstants.IMG_FILTEREDITOR ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void buttonPressed( int buttonId )
+    {
+        if ( buttonId == IDialogConstants.OK_ID )
+        {
+            filter = filterWidget.getFilter();
+            filterWidget.saveDialogSettings();
+        }
+
+        // call super implementation
+        super.buttonPressed( buttonId );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        composite.setLayoutData( gd );
+
+        Composite inner = new Composite( composite, SWT.NONE );
+        GridLayout gridLayout = new GridLayout( 2, false );
+        inner.setLayout( gridLayout );
+        gd = new GridData( GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL );
+        gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+        inner.setLayoutData( gd );
+
+        filterWidget = new FilterWidget( connection, filter != null ? filter : "" );
+        filterWidget.createWidget( inner );
+        filterWidget.setFocus();
+
+        return composite;
+    }
+
+}



Mime
View raw message