directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592079 [4/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/UnfilterChildrenAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/UnfilterChildrenAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/UnfilterChildrenAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/UnfilterChildrenAction.java Mon Nov  5 08:48:35 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.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.jobs.InitializeChildrenJob;
+import org.apache.directory.studio.ldapbrowser.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;
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/UpAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/UpAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/UpAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/UpAction.java Mon Nov  5 08:48:35 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.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.widgets.browser.BrowserEntryPage;
+import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserSearchResultPage;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.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.studio.ldapbrowser.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;
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ValueEditorPreferencesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ValueEditorPreferencesAction.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ValueEditorPreferencesAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ValueEditorPreferencesAction.java Mon Nov  5 08:48:35 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.studio.ldapbrowser.common.actions;
+
+
+import org.apache.directory.studio.ldapbrowser.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();
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/ActionHandlerManager.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/ActionHandlerManager.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/ActionHandlerManager.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/ActionHandlerManager.java Mon Nov  5 08:48:35 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.studio.ldapbrowser.common.actions.proxy;
+
+/**
+ * A ActionHandlerManager activates and deactives the action handlers.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ActionHandlerManager
+{
+
+    /**
+     * Deactivates global action handlers.
+     */
+    public void deactivateGlobalActionHandlers();
+
+    
+    /**
+     * Activates global action handlers.
+     */
+    public void activateGlobalActionHandlers();
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/BrowserActionProxy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/BrowserActionProxy.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/BrowserActionProxy.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/BrowserActionProxy.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,269 @@
+/*
+ *  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.proxy;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionFolder;
+import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
+import org.apache.directory.studio.connection.core.event.ConnectionUpdateListener;
+import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
+import org.apache.directory.studio.ldapbrowser.core.events.BookmarkUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.BookmarkUpdateListener;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryUpdateListener;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateListener;
+import org.eclipse.jface.action.Action;
+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
+{
+
+    /** The action handler manager, used to deactivate and activate the action handlers and key bindings. */
+    private ActionHandlerManager actionHandlerManager;
+
+    protected BrowserAction action;
+
+    protected ISelectionProvider selectionProvider;
+
+
+    protected BrowserActionProxy( ISelectionProvider selectionProvider, ActionHandlerManager actionHandlerManager,
+        BrowserAction action, int style )
+    {
+        super( action.getText(), style );
+        this.selectionProvider = selectionProvider;
+        this.actionHandlerManager = actionHandlerManager;
+        this.action = action;
+
+        super.setImageDescriptor( action.getImageDescriptor() );
+        super.setActionDefinitionId( action.getCommandId() );
+
+        selectionProvider.addSelectionChangedListener( this );
+        // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener(this);
+
+        ConnectionEventRegistry.addConnectionUpdateListener( this, ConnectionUIPlugin.getDefault().getEventRunner() );
+        EventRegistry.addEntryUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() );
+        EventRegistry.addSearchUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() );
+        EventRegistry.addBookmarkUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() );
+
+        updateAction();
+    }
+
+
+    protected BrowserActionProxy( ISelectionProvider selectionProvider, ActionHandlerManager actionHandlerManager,
+        BrowserAction action )
+    {
+        this( selectionProvider, actionHandlerManager, action, Action.AS_PUSH_BUTTON );
+    }
+
+
+    public void dispose()
+    {
+        ConnectionEventRegistry.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.updateAction();
+        }
+    }
+
+
+    public void searchUpdated( SearchUpdateEvent searchUpdateEvent )
+    {
+        if ( !this.isDisposed() )
+        {
+            this.updateAction();
+        }
+    }
+
+
+    public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent )
+    {
+        if ( !this.isDisposed() )
+        {
+            this.updateAction();
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionUpdated(org.apache.directory.studio.connection.core.Connection)
+     */
+    public final void connectionUpdated( Connection connection )
+    {
+        if ( !isDisposed() )
+        {
+            updateAction();
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionAdded(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionAdded( Connection connection )
+    {
+        connectionUpdated( connection );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionRemoved(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionRemoved( Connection connection )
+    {
+        connectionUpdated( connection );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionOpened(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionOpened( Connection connection )
+    {
+        connectionUpdated( connection );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionClosed(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionClosed( Connection connection )
+    {
+        connectionUpdated( connection );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionFolderModified(org.apache.directory.studio.connection.core.ConnectionFolder)
+     */
+    public void connectionFolderModified( ConnectionFolder connectionFolder )
+    {
+        connectionUpdated( null );
+    }
+
+
+    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.setSelectedBrowserViewCategories( BrowserSelectionUtils.getBrowserViewCategories( selection ) );
+            this.action.setSelectedEntries( BrowserSelectionUtils.getEntries( selection ) );
+            this.action.setSelectedBrowserEntryPages( BrowserSelectionUtils.getBrowserEntryPages( selection ) );
+            this.action.setSelectedSearchResults( BrowserSelectionUtils.getSearchResults( selection ) );
+            this.action.setSelectedBrowserSearchResultPages( BrowserSelectionUtils
+                .getBrowserSearchResultPages( selection ) );
+            this.action.setSelectedBookmarks( BrowserSelectionUtils.getBookmarks( selection ) );
+
+            this.action.setSelectedSearches( BrowserSelectionUtils.getSearches( selection ) );
+
+            this.action.setSelectedAttributes( BrowserSelectionUtils.getAttributes( selection ) );
+            this.action.setSelectedAttributeHierarchies( BrowserSelectionUtils.getAttributeHierarchie( selection ) );
+            this.action.setSelectedValues( BrowserSelectionUtils.getValues( selection ) );
+
+            this.action.setSelectedProperties( BrowserSelectionUtils.getProperties( 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 ( !isDisposed() )
+        {
+            // deactivate global actions
+            if ( actionHandlerManager != null )
+            {
+                actionHandlerManager.deactivateGlobalActionHandlers();
+            }
+
+            action.run();
+
+            // activate global actions
+            if ( actionHandlerManager != null )
+            {
+                actionHandlerManager.activateGlobalActionHandlers();
+            }
+        }
+    }
+
+
+    public BrowserAction getAction()
+    {
+        return action;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/BrowserViewActionProxy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/BrowserViewActionProxy.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/BrowserViewActionProxy.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/BrowserViewActionProxy.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,50 @@
+/*
+ *  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.proxy;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * The BrowserViewActionProxy is a proxy for a real action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserViewActionProxy extends BrowserActionProxy
+{
+
+    /**
+     * Creates a new instance of BrowserViewActionProxy.
+     * 
+     * @param viewer the viewer
+     * @param actionHandlerManager the action handler manager, 
+     *        used to deactivate and activate the action handlers and key bindings
+     * @param action the real action
+     */
+    public BrowserViewActionProxy( Viewer viewer, ActionHandlerManager actionHandlerManager, BrowserAction action )
+    {
+        super( viewer, actionHandlerManager, action );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/EntryEditorActionProxy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/EntryEditorActionProxy.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/EntryEditorActionProxy.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/proxy/EntryEditorActionProxy.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,51 @@
+/*
+ *  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.proxy;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * The EntryEditorActionProxy is a proxy for a real action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorActionProxy extends BrowserActionProxy implements ISelectionChangedListener
+{
+
+    /**
+     * Creates a new instance of EntryEditorActionProxy.
+     * 
+     * @param viewer the viewer
+     * @param actionHandlerManager the action handler manager, 
+     *        used to deactivate and activate the action handlers and key bindings
+     * @param action the real action
+     */
+    public EntryEditorActionProxy( Viewer viewer, ActionHandlerManager actionHandlerManager, BrowserAction action )
+    {
+        super( viewer, actionHandlerManager, action );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/FilterDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/FilterDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/FilterDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/FilterDialog.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,184 @@
+/*
+ *  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.dialogs;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.filtereditor.FilterSourceViewerConfiguration;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.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;
+
+
+/**
+ * Dialog to edit a filter in a text source viewer with syntax highlighting
+ * and content assistent. It also provides a button to format the filter.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class FilterDialog extends Dialog
+{
+
+    /** The default dialog title. */
+    private static final String DIALOG_TITLE = "Filter Editor";
+
+    /** The button ID for the format button. */
+    private static final int FORMAT_BUTTON_ID = 987654321;
+
+    /** The dialog title. */
+    private String title;
+
+    /** The browser connection. */
+    private IBrowserConnection browserConnection;
+
+    /** The source viewer. */
+    private SourceViewer sourceViewer;
+
+    /** The filter source viewer configuration. */
+    private FilterSourceViewerConfiguration configuration;
+
+    /** The filter parser. */
+    private LdapFilterParser parser;
+
+    /** The filter. */
+    private String filter;
+
+
+    /**
+     * Creates a new instance of FilterDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param title the title
+     * @param filter the initial filter
+     * @param brwoserConnection the browser connection
+     */
+    public FilterDialog( Shell parentShell, String title, String filter, IBrowserConnection brwoserConnection )
+    {
+        super( parentShell );
+        this.title = title;
+        this.filter = filter;
+        this.browserConnection = brwoserConnection;
+        this.parser = new LdapFilterParser();
+        setShellStyle( SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE );
+    }
+
+
+    /**
+     * Gets the filter.
+     * 
+     * @return the filter
+     */
+    public String getFilter()
+    {
+        return filter;
+    }
+
+
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell newShell )
+    {
+        super.configureShell( newShell );
+        newShell.setText( title != null ? title : DIALOG_TITLE );
+        newShell.setImage( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_FILTER_EDITOR ) );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+     */
+    protected void buttonPressed( int buttonId )
+    {
+        if ( buttonId == IDialogConstants.OK_ID )
+        {
+            parser.parse( sourceViewer.getDocument().get() );
+            filter = parser.getModel().toString();
+        }
+        else if ( buttonId == FORMAT_BUTTON_ID )
+        {
+            IRegion region = new Region( 0, sourceViewer.getDocument().getLength() );
+            configuration.getContentFormatter( sourceViewer ).format( sourceViewer.getDocument(), region );
+        }
+
+        // call super implementation
+        super.buttonPressed( buttonId );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createButtonBar( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createButtonBar( parent );
+        super.createButton( composite, FORMAT_BUTTON_ID, "Format", false );
+        return composite;
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.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( parser, browserConnection );
+        sourceViewer.configure( configuration );
+
+        // set document
+        IDocument document = new Document( filter );
+        sourceViewer.setDocument( document );
+
+        // preformat
+        IRegion region = new Region( 0, sourceViewer.getDocument().getLength() );
+        configuration.getContentFormatter( sourceViewer ).format( sourceViewer.getDocument(), region );
+
+        // set focus to the source viewer
+        sourceViewer.getTextWidget().setFocus();
+
+        return composite;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/FilterWidgetDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/FilterWidgetDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/FilterWidgetDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/FilterWidgetDialog.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,171 @@
+/*
+ *  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.dialogs;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.search.FilterWidget;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+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.Label;
+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 IBrowserConnection connection;
+
+    /** The filter widget. */
+    private FilterWidget filterWidget;
+
+    /** The filter. */
+    private String filter;
+
+    /** The error message label. */
+    private Label errorMessageLabel;
+
+
+    /**
+     * 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, IBrowserConnection 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( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_FILTER_EDITOR ) );
+    }
+
+
+    /**
+     * {@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();
+        filterWidget.addWidgetModifyListener( new WidgetModifyListener()
+        {
+            public void widgetModified( WidgetModifyEvent event )
+            {
+                validate();
+            }
+        } );
+
+        errorMessageLabel = BaseWidgetUtils.createLabel( inner, "Please enter a valid filter.", 2 );
+
+        validate();
+
+        return composite;
+    }
+
+
+    /**
+     * Validates the filter.
+     */
+    protected void validate()
+    {
+        if ( getButton( IDialogConstants.OK_ID ) != null )
+        {
+            getButton( IDialogConstants.OK_ID ).setEnabled( filterWidget.getFilter() != null );
+        }
+        errorMessageLabel.setText( filterWidget.getFilter() == null ? "Please enter a valid filter." : "" );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/HexDialog.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,321 @@
+/*
+ *  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.dialogs;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+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.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * Dialog to display binary data in hex format. It could be 
+ * used to load and save binary data from and to disk.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HexDialog extends Dialog
+{
+
+    /** The default title. */
+    private static final String DIALOG_TITLE = "Hex Editor";
+
+    /** The button ID for the load button. */
+    private static final int LOAD_BUTTON_ID = 9998;
+
+    /** The button ID for the save button. */
+    private static final int SAVE_BUTTON_ID = 9999;
+
+    /** The current data. */
+    private byte[] currentData;
+
+    /** The return data. */
+    private byte[] returnData;
+
+    /** The text field with the binary data. */
+    private Text hexText;
+
+
+    /**
+     * Creates a new instance of HexDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param initialData the initial data
+     */
+    public HexDialog( Shell parentShell, byte[] initialData )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.currentData = initialData;
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+     */
+    protected void buttonPressed( int buttonId )
+    {
+        if ( buttonId == IDialogConstants.OK_ID )
+        {
+            returnData = currentData;
+        }
+        else if ( buttonId == SAVE_BUTTON_ID )
+        {
+            FileDialog fileDialog = new FileDialog( getShell(), SWT.SAVE );
+            fileDialog.setText( "Save Data" );
+            // fileDialog.setFilterExtensions(new String[]{"*.jpg"});
+            String returnedFileName = fileDialog.open();
+            if ( returnedFileName != null )
+            {
+                try
+                {
+                    File file = new File( returnedFileName );
+                    FileOutputStream out = new FileOutputStream( file );
+                    out.write( currentData );
+                    out.flush();
+                    out.close();
+                }
+                catch ( FileNotFoundException e )
+                {
+                    BrowserCommonActivator.getDefault().getExceptionHandler().handleException(
+                        new Status( IStatus.ERROR, BrowserCommonActivator.PLUGIN_ID, IStatus.ERROR,
+                            "Can't write to file", e ) );
+                }
+                catch ( IOException e )
+                {
+                    BrowserCommonActivator.getDefault().getExceptionHandler().handleException(
+                        new Status( IStatus.ERROR, BrowserCommonActivator.PLUGIN_ID, IStatus.ERROR,
+                            "Can't write to file", e ) );
+                }
+            }
+        }
+        else if ( buttonId == LOAD_BUTTON_ID )
+        {
+            FileDialog fileDialog = new FileDialog( getShell(), SWT.OPEN );
+            fileDialog.setText( "Load Data" );
+            String returnedFileName = fileDialog.open();
+            if ( returnedFileName != null )
+            {
+                try
+                {
+                    File file = new File( returnedFileName );
+                    FileInputStream in = new FileInputStream( file );
+                    ByteArrayOutputStream out = new ByteArrayOutputStream( ( int ) file.length() );
+                    byte[] buf = new byte[4096];
+                    int len;
+                    while ( ( len = in.read( buf ) ) > 0 )
+                    {
+                        out.write( buf, 0, len );
+                    }
+                    currentData = out.toByteArray();
+                    hexText.setText( toFormattedHex( currentData ) );
+                    out.close();
+                    in.close();
+                }
+                catch ( FileNotFoundException e )
+                {
+                    BrowserCommonActivator.getDefault().getExceptionHandler().handleException(
+                        new Status( IStatus.ERROR, BrowserCommonActivator.PLUGIN_ID, IStatus.ERROR, "Can't read file",
+                            e ) );
+                }
+                catch ( IOException e )
+                {
+                    BrowserCommonActivator.getDefault().getExceptionHandler().handleException(
+                        new Status( IStatus.ERROR, BrowserCommonActivator.PLUGIN_ID, IStatus.ERROR, "Can't read file",
+                            e ) );
+                }
+            }
+        }
+        else
+        {
+            returnData = null;
+        }
+
+        super.buttonPressed( buttonId );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+        shell.setImage( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_HEXEDITOR ) );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, LOAD_BUTTON_ID, "Load Data...", false );
+        createButton( parent, SAVE_BUTTON_ID, "Save Data...", false );
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        // create composite
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+
+        hexText = new Text( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY );
+        hexText.setFont( JFaceResources.getFont( JFaceResources.TEXT_FONT ) );
+
+        hexText.setText( toFormattedHex( currentData ) );
+        // GridData gd = new GridData(GridData.GRAB_HORIZONTAL |
+        // GridData.HORIZONTAL_ALIGN_FILL);
+        GridData gd = new GridData( GridData.FILL_BOTH );
+        gd.widthHint = convertHorizontalDLUsToPixels( ( int ) ( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH * 1.6 ) );
+        gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+        hexText.setLayoutData( gd );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    /**
+     * Formats the binary data in two colums. One containing the hex
+     * presentation and one containting the ASCII presentation of each byte.
+     * 
+     * 91 a1 08 23 42 b1 c1 15  52 d1 f0 24 33 62 72 82     ...#B... R..$3br.
+     * 09 0a 16 17 18 19 1a 25  26 27 28 29 2a 34 35 36     .......% &'()*456 
+     * 
+     * @param data the data
+     * 
+     * @return the formatted string
+     */
+    private String toFormattedHex( byte[] data )
+    {
+        StringBuffer sb = new StringBuffer();
+        for ( int i = 0; i < data.length; i++ )
+        {
+            // get byte
+            int b = ( int ) data[i];
+            if ( b < 0 )
+            {
+                b = 256 + b;
+            }
+
+            // format to hex, optionally prepend a 0
+            String s = Integer.toHexString( b );
+            if ( s.length() == 1 )
+            {
+                s = "0" + s;
+            }
+
+            // space between hex numbers
+            sb.append( s ).append( " " );
+
+            // extra space after 8 hex numbers
+            if ( ( i + 1 ) % 8 == 0 )
+            {
+                sb.append( " " );
+            }
+
+            // if end of data is reached then fill with spaces
+            if ( i == data.length - 1 )
+            {
+                while ( ( i + 1 ) % 16 != 0 )
+                {
+                    sb.append( "   " );
+                    if ( ( i + 1 ) % 8 == 0 )
+                    {
+                        sb.append( " " );
+                    }
+                    i++;
+                }
+                sb.append( " " );
+            }
+
+            // print ASCII characters after 16 hex numbers 
+            if ( ( i + 1 ) % 16 == 0 )
+            {
+                sb.append( "   " );
+                for ( int x = i - 16 + 1; x <= i && x < data.length; x++ )
+                {
+                    // print ASCII charachter if printable
+                    // otherwise print a dot
+                    if ( data[x] > 32 && data[x] < 127 )
+                    {
+                        sb.append( ( char ) data[x] );
+                    }
+                    else
+                    {
+                        sb.append( '.' );
+                    }
+
+                    // space after 8 characters 
+                    if ( ( x + 1 ) % 8 == 0 )
+                    {
+                        sb.append( " " );
+                    }
+                }
+            }
+
+            // start new line after 16 hex numbers
+            if ( ( i + 1 ) % 16 == 0 )
+            {
+                sb.append( "\r\n" );
+            }
+        }
+        return sb.toString();
+    }
+
+
+    /**
+     * Gets the data.
+     * 
+     * @return the data
+     */
+    public byte[] getData()
+    {
+        return returnData;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MoveEntriesDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MoveEntriesDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MoveEntriesDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MoveEntriesDialog.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,193 @@
+/*
+ *  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.dialogs;
+
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.DnBuilderWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.utils.DnUtils;
+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.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Dialog to select and enter the new parent of some entries. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MoveEntriesDialog extends Dialog implements WidgetModifyListener
+{
+
+    /** The dialog title. */
+    private static final String DIALOG_TITLE = "Move Entries";
+
+    /** The entries to move. */
+    private IEntry[] entries;
+
+    /** The dn builder widget. */
+    private DnBuilderWidget dnBuilderWidget;
+
+    /** The simulate move button. */
+    private Button simulateMoveButton;
+
+    /** The ok button. */
+    private Button okButton;
+
+    /** The parent DN. */
+    private LdapDN parentDn;
+
+    /** The simulate move flag. */
+    private boolean simulateMove;
+
+
+    /**
+     * Creates a new instance of MoveEntriesDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param entries the entries
+     */
+    public MoveEntriesDialog( Shell parentShell, IEntry[] entries )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.entries = entries;
+        this.parentDn = null;
+    }
+
+
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#close()
+     */
+    public boolean close()
+    {
+        dnBuilderWidget.removeWidgetModifyListener( this );
+        dnBuilderWidget.dispose();
+        return super.close();
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+     */
+    protected void okPressed()
+    {
+        parentDn = dnBuilderWidget.getParentDn();
+        simulateMove = simulateMoveButton.getSelection();
+
+        dnBuilderWidget.saveDialogSettings();
+
+        super.okPressed();
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        okButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    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 ) * 3 / 2;
+        composite.setLayoutData( gd );
+
+        BaseWidgetUtils.createLabel( composite,
+            "Please enter/select the parent DN where the selected entries should be moved to.", 1 );
+
+        dnBuilderWidget = new DnBuilderWidget( false, true );
+        dnBuilderWidget.addWidgetModifyListener( this );
+        dnBuilderWidget.createContents( composite );
+        dnBuilderWidget.setInput( entries[0].getBrowserConnection(), null, null, DnUtils.getParent( entries[0].getDn() ) );
+
+        simulateMoveButton = BaseWidgetUtils.createCheckbox( composite,
+            "Simulate subtree moving by searching/adding/deleting recursively", 1 );
+        simulateMoveButton.setSelection( false );
+        simulateMoveButton.setEnabled( false );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener#widgetModified(org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent)
+     */
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        if ( okButton != null )
+        {
+            okButton.setEnabled( dnBuilderWidget.getParentDn() != null );
+        }
+    }
+
+
+    /**
+     * Gets the parent dn.
+     * 
+     * @return the parent dn
+     */
+    public LdapDN getParentDn()
+    {
+        return parentDn;
+    }
+
+
+    /**
+     * Gets the simulate move flag.
+     * 
+     * @return the simulate move flag
+     */
+    public boolean isSimulateMove()
+    {
+        return simulateMove;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MultivaluedDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MultivaluedDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MultivaluedDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/MultivaluedDialog.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,368 @@
+/*
+ *  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.dialogs;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetActionGroup;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetConfiguration;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetUniversalListener;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.OpenDefaultEditorAction;
+import org.apache.directory.studio.ldapbrowser.core.events.AttributeDeletedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EmptyValueAddedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EmptyValueDeletedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
+import org.apache.directory.studio.ldapbrowser.core.events.ValueAddedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.ValueDeletedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.ValueModifiedEvent;
+import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+
+
+/**
+ * Dialog to view and edit multi-valued attributes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MultivaluedDialog extends Dialog
+{
+
+    /** The dialog title. */
+    private static final String DIALOG_TITLE = "Multivalued Editor";
+
+    /** The attribute hierarchie to edit. */
+    private AttributeHierarchy attributeHierarchie;
+
+    /** The entry editor widget configuration. */
+    private EntryEditorWidgetConfiguration configuration;
+
+    /** The entry edtior widget action group. */
+    private EntryEditorWidgetActionGroup actionGroup;
+
+    /** The entry editor widget. */
+    private EntryEditorWidget mainWidget;
+
+    /** The universal listener. */
+    private MultiValuedEntryEditorUniversalListener universalListener;
+
+    /** Token used to activate and deactivate shortcuts in the editor */
+    private IContextActivation contextActivation;
+
+
+    /**
+     * Creates a new instance of MultivaluedDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param attributeHierarchie the attribute hierarchie
+     */
+    public MultivaluedDialog( Shell parentShell, AttributeHierarchy attributeHierarchie )
+    {
+        super( parentShell );
+        setShellStyle( getShellStyle() | SWT.RESIZE );
+        this.attributeHierarchie = attributeHierarchie;
+    }
+
+
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+        shell.setImage( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_MULTIVALUEDEDITOR ) );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        createButton( parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false );
+        getShell().update();
+        getShell().layout( true, true );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+     */
+    protected void buttonPressed( int buttonId )
+    {
+        if ( IDialogConstants.CLOSE_ID == buttonId )
+        {
+            close();
+        }
+        else
+        {
+            super.buttonPressed( buttonId );
+        }
+    }
+
+
+    /**
+     * @see org.eclipse.jface.window.Window#open()
+     */
+    public int open()
+    {
+        if ( attributeHierarchie.getAttribute().getValueSize() == 0 )
+        {
+            attributeHierarchie.getAttribute().addEmptyValue();
+        }
+
+        return super.open();
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#close()
+     */
+    public boolean close()
+    {
+        boolean returnValue = super.close();
+        if ( returnValue )
+        {
+            dispose();
+
+            // cleanup attribute hierarchy after editing
+            for ( Iterator<IAttribute> it = attributeHierarchie.iterator(); it.hasNext(); )
+            {
+                IAttribute attribute = it.next();
+                if ( attribute != null )
+                {
+                    // remove empty values
+                    IValue[] values = attribute.getValues();
+                    for ( int i = 0; i < values.length; i++ )
+                    {
+                        if ( values[i].isEmpty() )
+                        {
+                            attribute.deleteEmptyValue();
+                        }
+                    }
+
+                    // delete attribute from entry if all values were deleted
+                    if ( attribute.getValueSize() == 0 )
+                    {
+                        attribute.getEntry().deleteAttribute( attribute );
+                    }
+                }
+            }
+        }
+        return returnValue;
+    }
+
+
+    /**
+     * Disposes all widgets.
+     */
+    public void dispose()
+    {
+        if ( configuration != null )
+        {
+            universalListener.dispose();
+            universalListener = null;
+            mainWidget.dispose();
+            mainWidget = null;
+            actionGroup.deactivateGlobalActionHandlers();
+            actionGroup.dispose();
+            actionGroup = null;
+            configuration.dispose();
+            configuration = null;
+
+            if ( contextActivation != null )
+            {
+                IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+                    IContextService.class );
+                contextService.deactivateContext( contextActivation );
+                contextActivation = null;
+            }
+        }
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite composite = ( Composite ) super.createDialogArea( parent );
+
+        // create configuration
+        configuration = new EntryEditorWidgetConfiguration();
+
+        // create main widget
+        mainWidget = new EntryEditorWidget( configuration );
+        mainWidget.createWidget( composite );
+        mainWidget.getViewer().setInput( attributeHierarchie );
+        mainWidget.getViewer().getTree().setFocus();
+
+        // create actions
+        actionGroup = new EntryEditorWidgetActionGroup( mainWidget, configuration );
+        actionGroup.fillToolBar( mainWidget.getToolBarManager() );
+        actionGroup.fillMenu( mainWidget.getMenuManager() );
+        actionGroup.fillContextMenu( mainWidget.getContextMenuManager() );
+        IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+            IContextService.class );
+        contextActivation = contextService.activateContext( BrowserCommonConstants.CONTEXT_DIALOGS );
+        actionGroup.activateGlobalActionHandlers();
+
+        // create the listener
+        universalListener = new MultiValuedEntryEditorUniversalListener( mainWidget.getViewer(), actionGroup
+            .getOpenDefaultEditorAction() );
+
+        // start edit mode if an empty value exists
+        for ( Iterator<IAttribute> it = attributeHierarchie.iterator(); it.hasNext(); )
+        {
+            IAttribute attribute = it.next();
+            IValue[] values = attribute.getValues();
+            for ( int i = 0; i < values.length; i++ )
+            {
+                IValue value = values[i];
+                if ( value.isEmpty() )
+                {
+                    mainWidget.getViewer().setSelection( new StructuredSelection( value ), true );
+                    if ( actionGroup.getOpenDefaultEditorAction().isEnabled() )
+                    {
+                        actionGroup.getOpenDefaultEditorAction().run();
+                        break;
+                    }
+                }
+            }
+        }
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+    /**
+     * A special listener for the {@link MultivaluedDialog}.
+     */
+    class MultiValuedEntryEditorUniversalListener extends EntryEditorWidgetUniversalListener
+    {
+
+        /**
+         * Creates a new instance of MultiValuedEntryEditorUniversalListener.
+         * 
+         * @param startEditAction the start edit action
+         * @param treeViewer the tree viewer
+         */
+        public MultiValuedEntryEditorUniversalListener( TreeViewer treeViewer, OpenDefaultEditorAction startEditAction )
+        {
+            super( treeViewer, startEditAction );
+        }
+
+
+        /**
+         * @see org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetUniversalListener#entryUpdated(org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent)
+         */
+        public void entryUpdated( EntryModificationEvent event )
+        {
+            if ( viewer == null || viewer.getTree() == null || viewer.getTree().isDisposed() )
+            {
+                return;
+            }
+
+            if ( viewer.isCellEditorActive() )
+            {
+                viewer.cancelEditing();
+            }
+
+            // set new input because attributes are newly created after a
+            // modification
+            IEntry entry = attributeHierarchie.getEntry();
+            String attributeDescription = attributeHierarchie.getAttributeDescription();
+            attributeHierarchie = entry.getAttributeWithSubtypes( attributeDescription );
+            if ( attributeHierarchie == null )
+            {
+                EventRegistry.suspendEventFireingInCurrentThread();
+                IAttribute attribute = new Attribute( entry, attributeDescription );
+                entry.addAttribute( attribute );
+                attribute.addEmptyValue();
+                EventRegistry.resumeEventFireingInCurrentThread();
+                attributeHierarchie = entry.getAttributeWithSubtypes( attributeDescription );
+            }
+            viewer.setInput( attributeHierarchie );
+            viewer.refresh();
+
+            // select added/modified value
+            if ( event instanceof ValueAddedEvent )
+            {
+                ValueAddedEvent vaEvent = ( ValueAddedEvent ) event;
+                viewer.setSelection( new StructuredSelection( vaEvent.getAddedValue() ), true );
+                viewer.refresh();
+            }
+            else if ( event instanceof ValueModifiedEvent )
+            {
+                ValueModifiedEvent vmEvent = ( ValueModifiedEvent ) event;
+                viewer.setSelection( new StructuredSelection( vmEvent.getNewValue() ), true );
+            }
+            else if ( event instanceof ValueDeletedEvent )
+            {
+                ValueDeletedEvent vdEvent = ( ValueDeletedEvent ) event;
+                if ( vdEvent.getDeletedValue().getAttribute().getValueSize() > 0 )
+                {
+                    viewer.setSelection( new StructuredSelection(
+                        vdEvent.getDeletedValue().getAttribute().getValues()[0] ), true );
+                }
+            }
+            else if ( event instanceof EmptyValueAddedEvent )
+            {
+                viewer.refresh();
+                EmptyValueAddedEvent evaEvent = ( EmptyValueAddedEvent ) event;
+                viewer.setSelection( new StructuredSelection( evaEvent.getAddedValue() ), true );
+                if ( startEditAction.isEnabled() )
+                    startEditAction.run();
+            }
+            else if ( event instanceof EmptyValueDeletedEvent )
+            {
+                EmptyValueDeletedEvent evdEvent = ( EmptyValueDeletedEvent ) event;
+                if ( viewer.getSelection().isEmpty() && evdEvent.getDeletedValue().getAttribute().getValueSize() > 0 )
+                    viewer.setSelection( new StructuredSelection(
+                        evdEvent.getDeletedValue().getAttribute().getValues()[0] ), true );
+            }
+            else if ( event instanceof AttributeDeletedEvent )
+            {
+            }
+        }
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java?rev=592079&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java Mon Nov  5 08:48:35 2007
@@ -0,0 +1,225 @@
+/*
+ *  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.dialogs;
+
+
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.DnBuilderWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+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.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * A dialog to enter the new RDN of an entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RenameEntryDialog extends Dialog implements WidgetModifyListener
+{
+
+    /** The "Delete old RDN" dialog setting . */
+    private static final String DELETE_OLD_RDN_DIALOGSETTING_KEY = RenameEntryDialog.class.getName() + ".deleteOldRdn";
+
+    /** The dialog title. */
+    private static final String DIALOG_TITLE = "Rename Entry";
+
+    /** The entry to rename. */
+    private IEntry entry;
+
+    /** The dn builder widget. */
+    private DnBuilderWidget dnBuilderWidget;
+
+    /** The delete old rdn button. */
+    private Button deleteOldRdnButton;
+
+    /** The simulate rename button. */
+    private Button simulateRenameButton;
+
+    /** The ok button. */
+    private Button okButton;
+
+    /** The new rdn. */
+    private Rdn rdn;
+
+    /** The delete old rdn flag. */
+    private boolean deleteOldRdn;
+
+    /** The simulate rename flag. */
+    private boolean simulateRename;
+
+
+    /**
+     * Creates a new instance of RenameEntryDialog.
+     * 
+     * @param parentShell the parent shell
+     * @param entry the entry
+     */
+    public RenameEntryDialog( Shell parentShell, IEntry entry )
+    {
+        super( parentShell );
+        super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+        this.entry = entry;
+        this.rdn = null;
+
+        if ( BrowserCommonActivator.getDefault().getDialogSettings().get( DELETE_OLD_RDN_DIALOGSETTING_KEY ) == null )
+        {
+            BrowserCommonActivator.getDefault().getDialogSettings().put( DELETE_OLD_RDN_DIALOGSETTING_KEY, true );
+        }
+        this.deleteOldRdn = BrowserCommonActivator.getDefault().getDialogSettings().getBoolean(
+            DELETE_OLD_RDN_DIALOGSETTING_KEY );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        shell.setText( DIALOG_TITLE );
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#close()
+     */
+    public boolean close()
+    {
+        dnBuilderWidget.removeWidgetModifyListener( this );
+        dnBuilderWidget.dispose();
+        return super.close();
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+     */
+    protected void okPressed()
+    {
+        rdn = dnBuilderWidget.getRdn();
+        deleteOldRdn = deleteOldRdnButton.getSelection();
+        simulateRename = simulateRenameButton.getSelection();
+
+        BrowserCommonActivator.getDefault().getDialogSettings().put( DELETE_OLD_RDN_DIALOGSETTING_KEY, deleteOldRdn );
+        dnBuilderWidget.saveDialogSettings();
+
+        super.okPressed();
+    }
+
+
+    /**
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
+    {
+        okButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true );
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+    }
+
+
+    /**     
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    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 ) * 3 / 2;
+        composite.setLayoutData( gd );
+
+        BaseWidgetUtils.createLabel( composite, "Please enter the new RDN of the selected entry.", 1 );
+
+        dnBuilderWidget = new DnBuilderWidget( true, false );
+        dnBuilderWidget.addWidgetModifyListener( this );
+        dnBuilderWidget.createContents( composite );
+        dnBuilderWidget.setInput( entry.getBrowserConnection(), entry.getSubschema().getAllAttributeNames(), entry
+            .getRdn(), null );
+
+        deleteOldRdnButton = BaseWidgetUtils.createCheckbox( composite, "Delete old RDN", 1 );
+        deleteOldRdnButton.setSelection( deleteOldRdn );
+
+        simulateRenameButton = BaseWidgetUtils.createCheckbox( composite,
+            "Simulate subtree renaming by searching/adding/deleting recursively", 1 );
+        simulateRenameButton.setSelection( false );
+        simulateRenameButton.setEnabled( false );
+
+        applyDialogFont( composite );
+        return composite;
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener#widgetModified(org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent)
+     */
+    public void widgetModified( WidgetModifyEvent event )
+    {
+        if ( okButton != null )
+        {
+            okButton.setEnabled( dnBuilderWidget.getRdn() != null );
+        }
+    }
+
+
+    /**
+     * Gets the rdn.
+     * 
+     * @return the rdn
+     */
+    public Rdn getRdn()
+    {
+        return rdn;
+    }
+
+
+    /**
+     * Checks if the old RDN should be deleted.
+     * 
+     * @return true if the old RDN should be deleted.
+     */
+    public boolean isDeleteOldRdn()
+    {
+        return deleteOldRdn;
+    }
+
+
+    /**
+     * Checks if the renaming should be simulated by searching/adding/deleting.
+     * 
+     * @return true, if renaming shoudl be simulated
+     */
+    public boolean isSimulateRename()
+    {
+        return simulateRename;
+    }
+
+}



Mime
View raw message