directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592087 [12/16] - in /directory/sandbox/felixk/studio-ldapbrowser-ui: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/studio/ src...
Date Mon, 05 Nov 2007 17:01:46 GMT
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/OpenBrowserPreferencePageAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/OpenBrowserPreferencePageAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/OpenBrowserPreferencePageAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/OpenBrowserPreferencePageAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,63 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.browser;
+
+
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+/**
+ * The OpenBrowserPreferencePageAction is used to open the 
+ * preference dialog with the browser's preference page.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OpenBrowserPreferencePageAction extends Action
+{
+
+    /**
+     * Creates a new instance of OpenBrowserPreferencePageAction.
+     */
+    public OpenBrowserPreferencePageAction()
+    {
+        super.setText( "Preferences..." );
+        setToolTipText( "Preferences..." );
+        setEnabled( true );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        Shell shell = Display.getCurrent().getActiveShell();
+        String pageId = BrowserUIConstants.PREFERENCEPAGEID_BROWSER;
+        PreferencesUtil.createPreferenceDialogOn( shell, pageId, new String[]
+            { pageId }, null ).open();
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowBookmarksAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowBookmarksAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowBookmarksAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowBookmarksAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.browser;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+
+/**
+ * The ShowBookmarksAction is used to select wheater the bookmark category
+ * should be visible in the browser view or not.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowBookmarksAction extends Action
+{
+
+    /**
+     * Creates a new instance of ShowBookmarksAction.
+     */
+    public ShowBookmarksAction()
+    {
+        super( "Show Bookmarks", IAction.AS_CHECK_BOX );
+        setEnabled( true );
+        setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
+            BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_BOOKMARKS ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        BrowserCommonActivator.getDefault().getPreferenceStore().setValue(
+            BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_BOOKMARKS, isChecked() );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDITAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDITAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDITAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDITAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.browser;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+
+/**
+ * The ShowDITAction is used to select wheater the DIT category
+ * should be visible in the browser view or not.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowDITAction extends Action
+{
+
+    /**
+     * Creates a new instance of ShowDITAction.
+     */
+    public ShowDITAction()
+    {
+        super( "Show DIT", IAction.AS_CHECK_BOX );
+        setEnabled( true );
+        setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
+            BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIT ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        BrowserCommonActivator.getDefault().getPreferenceStore().setValue(
+            BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIT, isChecked() );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.browser;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+
+/**
+ * The ShowDirectoryMetadataEntriesAction is used to select wheater metadata entries
+ * should be visible in the browser view or not.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowDirectoryMetadataEntriesAction extends Action
+{
+
+    /**
+     * Creates a new instance of ShowDirectoryMetadataEntriesAction.
+     */
+    public ShowDirectoryMetadataEntriesAction()
+    {
+        super( "Show Directory Metadata", IAction.AS_CHECK_BOX );
+        setEnabled( true );
+        setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
+            BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIRECTORY_META_ENTRIES ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        BrowserCommonActivator.getDefault().getPreferenceStore().setValue(
+            BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIRECTORY_META_ENTRIES, isChecked() );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowSearchesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowSearchesAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowSearchesAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowSearchesAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,61 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.browser;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+
+/**
+ * The ShowSearchesAction is used to select wheater the search category
+ * should be visible in the browser view or not.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowSearchesAction extends Action
+{
+
+    /**
+     * Creates a new instance of ShowSearchesAction.
+     */
+    public ShowSearchesAction()
+    {
+        super( "Show Searches", IAction.AS_CHECK_BOX );
+        setEnabled( true );
+        setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
+            BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_SEARCHES ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        BrowserCommonActivator.getDefault().getPreferenceStore().setValue(
+            BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_SEARCHES, isChecked() );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionView.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionView.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionView.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionView.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,220 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.connection;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionConfiguration;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionWidget;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * This class implements the connection view. It displays all connections.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectionView extends ViewPart
+{
+
+    /** The configuration. */
+    private ConnectionConfiguration configuration;
+
+    /** The actions */
+    private ConnectionViewActionGroup actionGroup;
+
+    /** The main widget */
+    private ConnectionWidget mainWidget;
+
+    /** The listeners */
+    private ConnectionViewUniversalListener universalListener;
+
+
+    /**
+     * Returns the connection view ID.
+     * 
+     * @return the connection view ID.
+     */
+    public static String getId()
+    {
+        return ConnectionView.class.getName();
+    }
+
+
+    /**
+     * Creates a new instance of ConnectionView.
+     */
+    public ConnectionView()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation sets focus to the viewer's control.
+     */
+    public void setFocus()
+    {
+        mainWidget.getViewer().getControl().setFocus();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        if ( configuration != null )
+        {
+            actionGroup.dispose();
+            actionGroup = null;
+            configuration.dispose();
+            configuration = null;
+            universalListener.dispose();
+            universalListener = null;
+            mainWidget.dispose();
+            mainWidget = null;
+            getSite().setSelectionProvider( null );
+        }
+
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createPartControl( Composite parent )
+    {
+
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        GridLayout layout = new GridLayout();
+        layout.marginWidth = 0;
+        layout.marginHeight = 0;
+        composite.setLayout( layout );
+
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( composite,
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_connections_view" );
+
+        // create configuration
+        configuration = new ConnectionConfiguration();
+
+        // create main widget
+        mainWidget = new ConnectionWidget( configuration, getViewSite().getActionBars() );
+        mainWidget.createWidget( composite );
+        mainWidget.setInput( ConnectionCorePlugin.getDefault().getConnectionFolderManager() );
+
+        // create actions and context menu (and register global actions)
+        actionGroup = new ConnectionViewActionGroup( this );
+        actionGroup.fillToolBar( mainWidget.getToolBarManager() );
+        actionGroup.fillMenu( mainWidget.getMenuManager() );
+        actionGroup.enableGlobalActionHandlers( getViewSite().getActionBars() );
+        actionGroup.fillContextMenu( configuration.getContextMenuManager( mainWidget.getViewer() ) );
+        
+        // create the listener
+        getSite().setSelectionProvider( mainWidget.getViewer() );
+        universalListener = new ConnectionViewUniversalListener( this );
+        
+        // default selection
+//        Connection[] connections = ConnectionCorePlugin.getDefault().getConnectionManager().getConnections();
+//        if ( connections.length > 0 )
+//        {
+//            ISelection selection = new StructuredSelection( connections[0] );
+//            mainWidget.getViewer().setSelection( selection );
+//            //this.universalListener.selectionChanged( this, selection );
+//        }
+    }
+
+
+    /**
+     * Selects the given object in the tree. The object
+     * must be an IConnection.
+     * 
+     * @param obj the object to select
+     */
+    public void select( Object obj )
+    {
+        if ( obj instanceof Connection )
+        {
+            Connection connection = ( Connection ) obj;
+
+            mainWidget.getViewer().reveal( connection );
+            mainWidget.getViewer().refresh( connection, true );
+            mainWidget.getViewer().setSelection( new StructuredSelection( connection ), true );
+        }
+    }
+
+
+    /**
+     * Gets the action group.
+     * 
+     * @return the action group
+     */
+    public ConnectionViewActionGroup getActionGroup()
+    {
+        return actionGroup;
+    }
+
+
+    /**
+     * Gets the configuration.
+     * 
+     * @return the configuration
+     */
+    public ConnectionConfiguration getConfiguration()
+    {
+        return configuration;
+    }
+
+
+    /**
+     * Gets the main widget.
+     * 
+     * @return the main widget
+     */
+    public ConnectionWidget getMainWidget()
+    {
+        return mainWidget;
+    }
+
+
+    /**
+     * Gets the universal listener.
+     * 
+     * @return the universal listener
+     */
+    public ConnectionViewUniversalListener getUniversalListener()
+    {
+        return universalListener;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewActionGroup.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewActionGroup.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewActionGroup.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,173 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.connection;
+
+
+import org.apache.directory.studio.connection.ui.actions.ConnectionViewActionProxy;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionActionGroup;
+import org.apache.directory.studio.ldapbrowser.ui.actions.ImportExportAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.OpenSchemaBrowserAction;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IWorkbenchActionConstants;
+
+
+/**
+ * This class manages all the actions of the connection view.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectionViewActionGroup extends ConnectionActionGroup
+{
+
+    /** The connection view */
+    private ConnectionView view;
+
+    /** The link with editor action. */
+    private LinkWithEditorAction linkWithEditorAction;
+
+    /** The Constant importDsmlAction. */
+    private static final String importDsmlAction = "importDsmlAction";
+
+    /** The Constant exportDsmlAction. */
+    private static final String exportDsmlAction = "exportDsmlAction";
+
+    /** The Constant importLdifAction. */
+    private static final String importLdifAction = "importLdifAction";
+
+    /** The Constant exportLdifAction. */
+    private static final String exportLdifAction = "exportLdifAction";
+
+    /** The Constant exportCsvAction. */
+    private static final String exportCsvAction = "exportCsvAction";
+
+    /** The Constant exportExcelAction. */
+    private static final String exportExcelAction = "exportExcelAction";
+
+    /** The Constant openSchemaBrowserAction. */
+    private static final String openSchemaBrowserAction = "openSchemaBrowserAction";
+
+
+    /**
+     * Creates a new instance of ConnectionViewActionGroup and creates
+     * all actions.
+     *
+     * @param view the connection view
+     */
+    public ConnectionViewActionGroup( ConnectionView view )
+    {
+        super( view.getMainWidget(), view.getConfiguration() );
+        this.view = view;
+        TreeViewer viewer = view.getMainWidget().getViewer();
+
+        linkWithEditorAction = new LinkWithEditorAction( view );
+        connectionActionMap.put( importDsmlAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_IMPORT_DSML ) ) );
+        connectionActionMap.put( exportDsmlAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_EXPORT_DSML ) ) );
+        connectionActionMap.put( importLdifAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_IMPORT_LDIF ) ) );
+        connectionActionMap.put( exportLdifAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_EXPORT_LDIF ) ) );
+        connectionActionMap.put( exportCsvAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction(
+            ImportExportAction.TYPE_EXPORT_CSV ) ) );
+        connectionActionMap.put( exportExcelAction, new ConnectionViewActionProxy( viewer, this,
+            new ImportExportAction( ImportExportAction.TYPE_EXPORT_EXCEL ) ) );
+
+        connectionActionMap.put( openSchemaBrowserAction, new ConnectionViewActionProxy( viewer, this,
+            new OpenSchemaBrowserAction() ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        if ( view != null )
+        {
+            linkWithEditorAction.dispose();
+            linkWithEditorAction = null;
+            view = null;
+        }
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void menuAboutToShow( IMenuManager menuManager )
+    {
+
+        // add
+        menuManager.add( ( IAction ) connectionActionMap.get( newConnectionAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( newConnectionFolderAction ) );
+        menuManager.add( new Separator() );
+
+        // open/close
+        if ( ( ( IAction ) connectionActionMap.get( closeConnectionAction ) ).isEnabled() )
+        {
+            menuManager.add( ( IAction ) connectionActionMap.get( closeConnectionAction ) );
+        }
+        else if ( ( ( IAction ) connectionActionMap.get( openConnectionAction ) ).isEnabled() )
+        {
+            menuManager.add( ( IAction ) connectionActionMap.get( openConnectionAction ) );
+        }
+        menuManager.add( new Separator() );
+
+        menuManager.add( ( IAction ) connectionActionMap.get( openSchemaBrowserAction ) );
+        menuManager.add( new Separator() );
+
+        // copy/paste/...
+        menuManager.add( ( IAction ) connectionActionMap.get( copyConnectionAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( pasteConnectionAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( deleteConnectionAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( renameConnectionAction ) );
+        menuManager.add( new Separator() );
+
+        // import/export
+        MenuManager importMenuManager = new MenuManager( "Import" );
+        importMenuManager.add( ( IAction ) connectionActionMap.get( importLdifAction ) );
+        importMenuManager.add( ( IAction ) connectionActionMap.get( importDsmlAction ) );
+        importMenuManager.add( new Separator() );
+        menuManager.add( importMenuManager );
+        MenuManager exportMenuManager = new MenuManager( "Export" );
+        exportMenuManager.add( ( IAction ) connectionActionMap.get( exportLdifAction ) );
+        exportMenuManager.add( ( IAction ) connectionActionMap.get( exportDsmlAction ) );
+        exportMenuManager.add( new Separator() );
+        exportMenuManager.add( ( IAction ) connectionActionMap.get( exportCsvAction ) );
+        exportMenuManager.add( ( IAction ) connectionActionMap.get( exportExcelAction ) );
+        menuManager.add( exportMenuManager );
+        menuManager.add( new Separator() );
+
+        // additions
+        menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
+
+        // properties
+        menuManager.add( ( IAction ) connectionActionMap.get( propertyDialogAction ) );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,160 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.connection;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.jobs.OpenConnectionsJob;
+import org.apache.directory.studio.connection.ui.actions.SelectionUtils;
+import org.apache.directory.studio.connection.ui.widgets.ConnectionUniversalListener;
+import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView;
+import org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs.ModificationLogsView;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * The ConnectionViewUniversalListener manages all events for the connection view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectionViewUniversalListener extends ConnectionUniversalListener
+{
+
+    /** The connection view */
+    protected ConnectionView view;
+
+    /** This listener is used to ensure that the browser view is opened
+     when an object in the connection view is selected */
+    private ISelectionChangedListener viewerSelectionListener = new ISelectionChangedListener()
+    {
+        public void selectionChanged( SelectionChangedEvent event )
+        {
+            Connection[] connections = SelectionUtils.getConnections( event.getSelection() );
+            if ( connections.length == 1 )
+            {
+                ensureViewVisible();
+            }
+        }
+    };
+
+    /** This listener opens/closes a connection when double clicking a connection */
+    private IDoubleClickListener viewerDoubleClickListener = new IDoubleClickListener()
+    {
+        public void doubleClick( DoubleClickEvent event )
+        {
+            Connection[] connections = SelectionUtils.getConnections( event.getSelection() );
+            if ( connections.length == 1 )
+            {
+                toggleConnection( connections[0] );
+            }
+        }
+    };
+
+
+    /**
+     * Creates a new instance of ConnectionViewUniversalListener.
+     *
+     * @param view the connection view
+     */
+    public ConnectionViewUniversalListener( ConnectionView view )
+    {
+        super( view.getMainWidget().getViewer() );
+        this.view = view;
+
+        // listeners
+        viewer.addSelectionChangedListener( viewerSelectionListener );
+        viewer.addDoubleClickListener( viewerDoubleClickListener );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        this.view = null;
+        super.dispose();
+    }
+
+
+    /**
+     * Ensures that the browser view and modification log views are opended 
+     * and ready to show the given selection.
+     *
+     * @param selection the view's selection.
+     */
+    private void ensureViewVisible()
+    {
+        if ( view != null )
+        {
+            try
+            {
+                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( BrowserView.getId(),
+                    null, IWorkbenchPage.VIEW_VISIBLE );
+            }
+            catch ( PartInitException e )
+            {
+            }
+            catch ( NullPointerException e )
+            {
+            }
+            
+            try
+            {
+                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( ModificationLogsView.getId(),
+                    null, IWorkbenchPage.VIEW_VISIBLE );
+            }
+            catch ( PartInitException e )
+            {
+            }
+            catch ( NullPointerException e )
+            {
+            }
+        }
+    }
+
+
+    /**
+     * Opens a closed connections or closes an opened connection. 
+     *
+     * @param connection the connection
+     */
+    private void toggleConnection( Connection connection )
+    {
+        if ( connection.getJNDIConnectionWrapper().isConnected() )
+        {
+            connection.getJNDIConnectionWrapper().disconnect();
+        }
+        else
+        {
+            OpenConnectionsJob ocj = new OpenConnectionsJob( connection );
+            ocj.execute();
+        }
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/LinkWithEditorAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/LinkWithEditorAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/LinkWithEditorAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/LinkWithEditorAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,264 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.ldapbrowser.ui.views.connection;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditor;
+import org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditorInput;
+import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditor;
+import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditorInput;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+
+
+/**
+ * This class implements the Link With Editor Action for the Connection View.
+ * 
+ * This action is not visible to the user, but it listens to to the link 
+ * with editor property of the browser view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LinkWithEditorAction extends Action
+{
+    /** The connection view */
+    private ConnectionView connectionView;
+
+    /** The listener listening on changes on editors */
+    private IPartListener2 editorListener = new IPartListener2()
+    {
+        /**
+         * {@inheritDoc}
+         */
+        public void partBroughtToTop( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partActivated( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partClosed( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partDeactivated( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partHidden( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partInputChanged( IWorkbenchPartReference partRef )
+        {
+            linkViewWithEditor( partRef.getPart( false ) );
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partOpened( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partVisible( IWorkbenchPartReference partRef )
+        {
+        }
+    };
+
+    /** The listener listening on changes of the link with editor action of the browser view */
+    private IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener()
+    {
+
+        /**
+         * {@inheritDoc}
+         */
+        public void propertyChange( PropertyChangeEvent event )
+        {
+            if ( BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR.equals( event.getProperty() ) )
+            {
+                run();
+            }
+        }
+    };
+
+
+    /**
+     * Creates a new instance of LinkWithEditorAction.
+     *
+     * @param connectionView
+     *      the associated view
+     */
+    public LinkWithEditorAction( ConnectionView connectionView )
+    {
+        super( "Link with editor", AS_CHECK_BOX );
+
+        super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+            BrowserUIConstants.IMG_LINK_WITH_EDITOR ) );
+        super.setEnabled( true );
+        this.connectionView = connectionView;
+
+        super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+            BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR ) );
+
+        // enable the listeners
+        BrowserUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( propertyChangeListener );
+        if ( isChecked() )
+        {
+            connectionView.getSite().getWorkbenchWindow().getPartService().addPartListener( editorListener );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+            BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR ) );
+
+        if ( isChecked() )
+        {
+            // enable the listeners
+            connectionView.getSite().getWorkbenchWindow().getPartService().addPartListener( editorListener );
+
+            // link
+            IEditorPart activeEditor = connectionView.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
+            linkViewWithEditor( activeEditor );
+        }
+        else
+        {
+            // dsable the listeners
+            connectionView.getSite().getWorkbenchWindow().getPartService().removePartListener( editorListener );
+        }
+    }
+
+
+    /**
+     * Links the view with the right editor
+     *
+     * @param partRef the part
+     */
+    private void linkViewWithEditor( IWorkbenchPart part )
+    {
+        if ( part != null && connectionView != null
+            && part.getSite().getWorkbenchWindow() == connectionView.getSite().getWorkbenchWindow() )
+        {
+            Object objectToSelect = null;
+
+            if ( part instanceof EntryEditor )
+            {
+                EntryEditor editor = ( EntryEditor ) part;
+                IEditorInput input = editor.getEditorInput();
+                if ( input != null && input instanceof EntryEditorInput )
+                {
+                    EntryEditorInput eei = ( EntryEditorInput ) input;
+                    IEntry entry = eei.getResolvedEntry();
+                    if ( entry != null )
+                    {
+                        objectToSelect = entry.getBrowserConnection().getConnection();
+                    }
+                }
+            }
+            else if ( part instanceof SearchResultEditor )
+            {
+                SearchResultEditor editor = ( SearchResultEditor ) part;
+                IEditorInput input = editor.getEditorInput();
+                if ( input != null && input instanceof SearchResultEditorInput )
+                {
+                    SearchResultEditorInput srei = ( SearchResultEditorInput ) input;
+                    ISearch search = srei.getSearch();
+                    if ( search != null )
+                    {
+                        objectToSelect = search.getBrowserConnection().getConnection();
+                    }
+                }
+            }
+
+            if ( objectToSelect != null )
+            {
+                // do not select if already selected!
+                // necessary to avoid infinite loops!
+                IStructuredSelection selection = ( IStructuredSelection ) connectionView.getMainWidget().getViewer()
+                    .getSelection();
+                if ( selection.size() != 1 || !selection.getFirstElement().equals( objectToSelect ) )
+                {
+                    connectionView.select( objectToSelect );
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Disposes this action.
+     */
+    public void dispose()
+    {
+        if ( editorListener != null )
+        {
+            connectionView.getSite().getWorkbenchWindow().getPartService().removePartListener( editorListener );
+            BrowserUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( propertyChangeListener );
+            editorListener = null;
+        }
+
+        connectionView = null;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ClearAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ClearAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ClearAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ClearAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,106 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+public class ClearAction extends BrowserAction
+{
+
+    /** The modification logs view. */
+    private ModificationLogsView view;
+
+
+    /**
+     * Creates a new instance of ClearAction.
+     * 
+     * @param view
+     *            the modification logs view
+     */
+    public ClearAction( ModificationLogsView view )
+    {
+        this.view = view;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_CLEAR );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Clear";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getInput() != null && ( getInput() instanceof ModificationLogsViewInput );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        if ( MessageDialog.openConfirm( this.getShell(), "Delete", "Delete all log files?" ) )
+        {
+            view.getUniversalListener().clearInput();
+        }
+
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsView.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsView.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsView.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsView.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,164 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
+
+
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.apache.directory.studio.ldifeditor.widgets.LdifEditorWidget;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * The ModificationLogsView displays all modifications applied 
+ * to a connection using LDIF change format.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModificationLogsView extends ViewPart
+{
+
+    /** The action group. */
+    private ModificationLogsViewActionGroup actionGroup;
+
+    /** The main widget. */
+    private LdifEditorWidget mainWidget;
+
+    /** The universal listener. */
+    private ModificationLogsViewUniversalListener universalListener;
+
+
+    /**
+     * Gets the id.
+     * 
+     * @return the id
+     */
+    public static String getId()
+    {
+        return ModificationLogsView.class.getName();
+    }
+
+
+    /**
+     * Creates a new instance of ModificationLogsView.
+     */
+    public ModificationLogsView()
+    {
+        super();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setFocus()
+    {
+        mainWidget.getSourceViewer().getTextWidget().setFocus();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        if ( mainWidget != null )
+        {
+            actionGroup.dispose();
+            actionGroup = null;
+            universalListener.dispose();
+            universalListener = null;
+            mainWidget.dispose();
+            mainWidget = null;
+        }
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void createPartControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        GridLayout layout = new GridLayout();
+        layout.marginWidth = 0;
+        layout.marginHeight = 0;
+        composite.setLayout( layout );
+
+        // create main widget
+        mainWidget = new LdifEditorWidget( null, "", false );
+        mainWidget.createWidget( composite );
+        mainWidget.getSourceViewer().setEditable( false );
+
+        // create actions and context menu (and register global actions)
+        actionGroup = new ModificationLogsViewActionGroup( this );
+        actionGroup.fillActionBars( getViewSite().getActionBars() );
+        // this.actionGroup.fillContextMenu(this.configuration.getContextMenuManager(this.mainWidget.getViewer()));
+        
+        // create the listener
+        universalListener = new ModificationLogsViewUniversalListener( this );
+        
+        // set help context
+        PlatformUI.getWorkbench().getHelpSystem().setHelp( mainWidget.getSourceViewer().getTextWidget(),
+            BrowserUIPlugin.PLUGIN_ID + "." + "tools_modification_logs_view" );
+    }
+
+
+    /**
+     * Gets the main widget.
+     * 
+     * @return the main widget
+     */
+    public LdifEditorWidget getMainWidget()
+    {
+        return mainWidget;
+    }
+
+
+    /**
+     * Gets the universal listener.
+     * 
+     * @return the universal listener
+     */
+    public ModificationLogsViewUniversalListener getUniversalListener()
+    {
+        return universalListener;
+    }
+
+
+    /**
+     * Gets the action group.
+     * 
+     * @return the action group
+     */
+    public ModificationLogsViewActionGroup getActionGroup()
+    {
+        return actionGroup;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,166 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager;
+import org.apache.directory.studio.ldapbrowser.ui.actions.proxy.ModificationLogsViewActionProxy;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.ui.IActionBars;
+
+
+/**
+ * The ModificationLogsViewActionGroup manages all the actions of the modification logs view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModificationLogsViewActionGroup implements ActionHandlerManager, IMenuListener
+{
+
+    /** The view. */
+    private ModificationLogsView view;
+
+    /** The Constant olderAction. */
+    private static final String olderAction = "olderAction";
+
+    /** The Constant newerAction. */
+    private static final String newerAction = "newerAction";
+
+    /** The Constant refreshAction. */
+    private static final String refreshAction = "refreshAction";
+
+    /** The Constant refreshAction. */
+    private static final String clearAction = "clearAction";
+
+    /** The modification logs view action map. */
+    private Map<String, ModificationLogsViewActionProxy> modificationLogsViewActionMap;
+
+
+    /**
+     * Creates a new instance of ModificationLogsViewActionGroup.
+     *
+     * @param view the modification logs view
+     */
+    public ModificationLogsViewActionGroup( ModificationLogsView view )
+    {
+        this.view = view;
+        SourceViewer viewer = this.view.getMainWidget().getSourceViewer();
+
+        modificationLogsViewActionMap = new HashMap<String, ModificationLogsViewActionProxy>();
+        modificationLogsViewActionMap.put( olderAction, new ModificationLogsViewActionProxy( viewer, this,
+            new OlderAction( view ) ) );
+        modificationLogsViewActionMap.put( newerAction, new ModificationLogsViewActionProxy( viewer, this,
+            new NewerAction( view ) ) );
+        modificationLogsViewActionMap.put( refreshAction, new ModificationLogsViewActionProxy( viewer, this,
+            new RefreshAction( view ) ) );
+        modificationLogsViewActionMap.put( clearAction, new ModificationLogsViewActionProxy( viewer, this,
+            new ClearAction( view ) ) );
+    }
+
+
+    /**
+     * Disposes thes action group.
+     */
+    public void dispose()
+    {
+        if ( view != null )
+        {
+            for ( Iterator it = modificationLogsViewActionMap.keySet().iterator(); it.hasNext(); )
+            {
+                String key = ( String ) it.next();
+                ModificationLogsViewActionProxy action = ( ModificationLogsViewActionProxy ) modificationLogsViewActionMap
+                    .get( key );
+                action.dispose();
+                action = null;
+                it.remove();
+            }
+            modificationLogsViewActionMap.clear();
+            modificationLogsViewActionMap = null;
+
+            view = null;
+        }
+    }
+
+
+    /**
+     * Fill the action bars.
+     * 
+     * @param actionBars the action bars
+     */
+    public void fillActionBars( IActionBars actionBars )
+    {
+        // Tool Bar
+        actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get( clearAction ) );
+        actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get( refreshAction ) );
+        actionBars.getToolBarManager().add( new Separator() );
+        actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get( olderAction ) );
+        actionBars.getToolBarManager().add( ( IAction ) modificationLogsViewActionMap.get( newerAction ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void menuAboutToShow( IMenuManager menuManager )
+    {
+    }
+
+
+    /**
+     * Propagates the input to all actions.
+     * 
+     * @param input the input
+     */
+    public void setInput( ModificationLogsViewInput input )
+    {
+        for ( Iterator it = modificationLogsViewActionMap.values().iterator(); it.hasNext(); )
+        {
+            ModificationLogsViewActionProxy action = ( ModificationLogsViewActionProxy ) it.next();
+            action.inputChanged( input );
+        }
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager#activateGlobalActionHandlers()
+     */
+    public void activateGlobalActionHandlers()
+    {
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager#deactivateGlobalActionHandlers()
+     */
+    public void deactivateGlobalActionHandlers()
+    {
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewInput.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewInput.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewInput.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+
+
+/**
+ * A ModificationLogsViewInput represents the input of the modification logs view.
+ * It consists of a connection and the index of the displayed log file.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModificationLogsViewInput
+{
+
+    /** The connection. */
+    private IBrowserConnection connection;
+
+    /** The index of the displayed log file */
+    private int index;
+
+
+    /**
+     * Creates a new instance of ModificationLogsViewInput.
+     * 
+     * @param connection the connection
+     * @param index the index of the displayed log file
+     */
+    public ModificationLogsViewInput( IBrowserConnection connection, int index )
+    {
+        this.connection = connection;
+        this.index = index;
+    }
+
+
+    /**
+     * Gets the connection.
+     * 
+     * @return the connection
+     */
+    public IBrowserConnection getConnection()
+    {
+        return connection;
+    }
+
+
+    /**
+     * Gets the index of the displayed log file.
+     * 
+     * @return the index
+     */
+    public int getIndex()
+    {
+        return index;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,245 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
+
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.ChildrenInitializedEvent;
+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.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContainer;
+import org.apache.directory.studio.ldapbrowser.ui.views.connection.ConnectionView;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.INullSelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+/**
+ * The ModificationLogsViewUniversalListener manages all events for the modification logs view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModificationLogsViewUniversalListener implements EntryUpdateListener
+{
+
+    /** The modification log view. */
+    private ModificationLogsView view;
+
+    /** The current input */
+    private ModificationLogsViewInput input;
+
+    /** Listener that listens for selections of connections */
+    private INullSelectionListener connectionSelectionListener = new INullSelectionListener()
+    {
+        /**
+         * {@inheritDoc}
+         *
+         * This implementation sets the input when another connection was selected.
+         */
+        public void selectionChanged( IWorkbenchPart part, ISelection selection )
+        {
+            if ( view != null && part != null )
+            {
+                if ( view.getSite().getWorkbenchWindow() == part.getSite().getWorkbenchWindow() )
+                {
+                    Connection[] connections = BrowserSelectionUtils.getConnections( selection );
+                    if ( connections.length == 1 )
+                    {
+                        IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnectionById( connections[0].getId() );
+                        ModificationLogsViewInput input = new ModificationLogsViewInput( connection, 0 );
+                        setInput( input );
+                        scrollToNewest();
+                    }
+                }
+            }
+        }
+    };
+
+
+    /**
+     * Creates a new instance of ModificationLogsViewUniversalListener.
+     *
+     * @param view the modification logs view
+     */
+    public ModificationLogsViewUniversalListener( ModificationLogsView view )
+    {
+        this.view = view;
+        this.input = null;
+
+        EventRegistry.addEntryUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() );
+        view.getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener( ConnectionView.getId(),
+            connectionSelectionListener );
+    }
+
+
+    /**
+     * Disposed this listener
+     */
+    public void dispose()
+    {
+        if ( view != null )
+        {
+            view.getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(
+                ConnectionView.getId(), connectionSelectionListener );
+
+            EventRegistry.removeEntryUpdateListener( this );
+            view = null;
+        }
+    }
+
+
+    /**
+     * Refreshes the input.
+     */
+    void refreshInput()
+    {
+        ModificationLogsViewInput newInput = input;
+        input = null;
+        setInput( newInput );
+    }
+
+
+    /**
+     * Sets the input.
+     *
+     * @param input the input
+     */
+    void setInput( ModificationLogsViewInput input )
+    {
+        // only if another connection is selected
+        if ( this.input != input )
+        {
+            this.input = input;
+
+            // load file %u %g
+            StringBuffer sb = new StringBuffer();
+            File[] files = input.getConnection().getModificationLogger().getFiles();
+            int i = input.getIndex();
+            if ( 0 <= i && i < files.length && files[i] != null && files[i].exists() && files[i].canRead() )
+            {
+                try
+                {
+                    FileReader fr = new FileReader( files[i] );
+                    char[] cbuf = new char[4096];
+                    for ( int length = fr.read( cbuf ); length > 0; length = fr.read( cbuf ) )
+                    {
+                        sb.append( cbuf, 0, length );
+                    }
+                }
+                catch ( Exception e )
+                {
+                    sb.append( e.getMessage() );
+                }
+            }
+
+            // change input
+            view.getMainWidget().getSourceViewer().getDocument().set( sb.toString() );
+            view.getActionGroup().setInput( input );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     *
+     * This implementation refreshes the input.
+     */
+    public void entryUpdated( EntryModificationEvent event )
+    {
+        if ( !( event instanceof AttributesInitializedEvent ) && !( event instanceof ChildrenInitializedEvent ) )
+        {
+            refreshInput();
+            scrollToNewest();
+        }
+    }
+
+
+    /**
+     * Scroll to oldest log entry.
+     */
+    public void scrollToOldest()
+    {
+        view.getMainWidget().getSourceViewer().setTopIndex( 0 );
+    }
+
+
+    /**
+     * Scroll to newest log entry.
+     */
+    public void scrollToNewest()
+    {
+        try
+        {
+            LdifContainer record = view.getMainWidget().getLdifModel().getLastContainer();
+            int offset = record.getOffset();
+            int line = view.getMainWidget().getSourceViewer().getDocument().getLineOfOffset( offset );
+            if ( line > 3 )
+                line -= 3;
+            view.getMainWidget().getSourceViewer().setTopIndex( line );
+        }
+        catch ( Exception e )
+        {
+        }
+
+    }
+    
+	/**
+     * Clears the input and deletes the logfiles for it
+     * 
+     */
+    public void clearInput()
+    {
+        StringBuffer sb = new StringBuffer( "" );
+        FileWriter fw = null;
+        File[] files = input.getConnection().getModificationLogger().getFiles();
+        input.getConnection().getModificationLogger().dispose();
+        for ( int i = 0; i < files.length; i++ )
+        {
+            try
+            {
+                if ( files[i] != null && files[i].exists() && !files[i].delete() )
+                {
+                    fw = new FileWriter( files[i] );
+                    fw.write( "" );
+                }
+
+            }
+            catch ( Exception e )
+            {
+                sb.append( e.getMessage() );
+            }
+        }
+        view.getMainWidget().getSourceViewer().setTopIndex( 0 );
+        view.getMainWidget().getSourceViewer().getDocument().set( sb.toString() );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/NewerAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/NewerAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/NewerAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/NewerAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,114 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * Action to switch to a newer logfile.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NewerAction extends BrowserAction
+{
+    
+    /** The modification logs view. */
+    private ModificationLogsView view;
+
+
+    /**
+     * Creates a new instance of NewerAction.
+     *
+     * @param view the modification logs view
+     */
+    public NewerAction( ModificationLogsView view )
+    {
+        this.view = view;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        ModificationLogsViewInput oldInput = ( ModificationLogsViewInput ) getInput();
+        ModificationLogsViewInput newInput = new ModificationLogsViewInput( oldInput.getConnection(), oldInput.getIndex() - 1 );
+        view.getUniversalListener().setInput( newInput );
+        view.getUniversalListener().scrollToOldest();
+
+        // go to top
+        view.getMainWidget().getSourceViewer().setTopIndex( 0 );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Newer";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_NEXT );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getInput() != null && ( getInput() instanceof ModificationLogsViewInput )
+            && ( ( ModificationLogsViewInput ) getInput() ).getIndex() > 0;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,124 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
+
+
+import java.io.File;
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * Action to switch to an older logfile.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OlderAction extends BrowserAction
+{
+
+    /** The modification logs view. */
+    private ModificationLogsView view;
+
+
+    /**
+     * Creates a new instance of OlderAction.
+     *
+     * @param view the modification logs view
+     */
+    public OlderAction( ModificationLogsView view )
+    {
+        this.view = view;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        ModificationLogsViewInput oldInput = ( ModificationLogsViewInput ) getInput();
+        ModificationLogsViewInput newInput = new ModificationLogsViewInput( oldInput.getConnection(), oldInput
+            .getIndex() + 1 );
+        view.getUniversalListener().setInput( newInput );
+        view.getUniversalListener().scrollToNewest();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Older";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_PREVIOUS );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        if ( getInput() != null && ( getInput() instanceof ModificationLogsViewInput ) )
+        {
+            ModificationLogsViewInput input = ( ModificationLogsViewInput ) getInput();
+            File[] files = input.getConnection().getModificationLogger().getFiles();
+            int i = input.getIndex() + 1;
+            if ( 0 <= i && i < files.length && files[i] != null && files[i].exists() && files[i].canRead() )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/RefreshAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/RefreshAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/RefreshAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/RefreshAction.java Mon Nov  5 09:01:21 2007
@@ -0,0 +1,110 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+/**
+ * Action to refresh the view from logfile.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RefreshAction extends BrowserAction
+{
+
+    /** The modification logs view. */
+    private ModificationLogsView view;
+
+
+    /**
+     * Creates a new instance of RefreshAction.
+     *
+     * @param view the modification logs view
+     */
+    public RefreshAction( ModificationLogsView view )
+    {
+        this.view = view;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        super.dispose();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        // int topIndex = view.getMainWidget().getSourceViewer().getTopIndex();
+        view.getUniversalListener().refreshInput();
+        view.getUniversalListener().scrollToNewest();
+        // view.getMainWidget().getSourceViewer().setTopIndex(topIndex);
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getText()
+    {
+        return "Refresh";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_REFRESH );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getCommandId()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEnabled()
+    {
+        return getInput() != null && ( getInput() instanceof ModificationLogsViewInput );
+    }
+
+}

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



Mime
View raw message