directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r592082 [2/20] - in /directory/sandbox/felixk/studio-ldapbrowser-core: ./ 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/ sr...
Date Mon, 05 Nov 2007 16:52:07 GMT
Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionManager.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionManager.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionManager.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserConnectionManager.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,678 @@
+/*
+ *  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.core;
+
+
+import java.beans.Encoder;
+import java.beans.ExceptionListener;
+import java.beans.Expression;
+import java.beans.PersistenceDelegate;
+import java.beans.XMLDecoder;
+import java.beans.XMLEncoder;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+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.core.io.ConnectionIOException;
+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.BrowserConnectionUpdateEvent;
+import org.apache.directory.studio.ldapbrowser.core.events.BrowserConnectionUpdateListener;
+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.apache.directory.studio.ldapbrowser.core.model.BookmarkParameter;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.AliasDereferencingMethod;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ReferralHandlingMethod;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Bookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.BrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.impl.Search;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+import org.apache.directory.studio.ldapbrowser.core.utils.LdifUtils;
+import org.eclipse.core.runtime.IPath;
+
+
+/**
+ * This class is used to manage {@link IBrowserConnection}s.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserConnectionManager implements ConnectionUpdateListener, BrowserConnectionUpdateListener, SearchUpdateListener, BookmarkUpdateListener
+{
+
+    /** The list of connections. */
+    private Map<String, IBrowserConnection> connectionMap;
+
+
+    /**
+     * Creates a new instance of ConnectionManager.
+     */
+    public BrowserConnectionManager()
+    {
+        this.connectionMap = new HashMap<String, IBrowserConnection>();
+        loadBrowserConnections();
+        ConnectionEventRegistry.addConnectionUpdateListener( this, ConnectionCorePlugin.getDefault().getEventRunner() );
+        EventRegistry.addSearchUpdateListener( this, BrowserCorePlugin.getDefault().getEventRunner() );
+        EventRegistry.addBookmarkUpdateListener( this, BrowserCorePlugin.getDefault().getEventRunner() );
+        EventRegistry.addBrowserConnectionUpdateListener( this, BrowserCorePlugin.getDefault().getEventRunner() );
+    }
+
+
+    /**
+     * Gets the Schema Cache filename for the corresponding browser connection.
+     *
+     * @param browserConnection
+     *      the browser connection
+     * @return
+     *      the Schema Cache filename for the corresponding browser connection
+     */
+    public static final String getSchemaCacheFileName( IBrowserConnection browserConnection )
+    {
+        return BrowserCorePlugin.getDefault().getStateLocation().append(
+            "schema-" + toSaveString( browserConnection.getConnection().getId() ) + ".ldif" ).toOSString(); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+
+    /**
+     * Gets the Modification Log filename for the corresponding browser connection.
+     *
+     * @param browserConnection
+     *      the browser connection
+     * @return
+     *      the Modification Log filename
+     */
+    public static final String getModificationLogFileName( IBrowserConnection browserConnection )
+    {
+        IPath p = BrowserCorePlugin.getDefault().getStateLocation().append( "logs" ); //$NON-NLS-1$
+        File file = p.toFile();
+        if ( !file.exists() )
+        {
+            file.mkdir();
+        }
+        return p
+            .append( "modifications-" + toSaveString( browserConnection.getConnection().getId() ) + "-%u-%g.ldiflog" ).toOSString(); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+
+    /**
+     * Gets the filename of the Connection Store.
+     *
+     * @return
+     *      the filename of the Connection Store
+     */
+    public static final String getBrowserConnectionStoreFileName()
+    {
+        String filename = BrowserCorePlugin.getDefault().getStateLocation().append( "browserconnections.xml" ).toOSString(); //$NON-NLS-1$
+        File file = new File( filename );
+        if ( !file.exists() )
+        {
+            // try to convert old connections.xml:
+            // 1st search it in current workspace with the old ldapstudio plugin ID
+            // 2nd search it in old .ldapstudio workspace with the old ldapstudio plugin ID
+            String[] oldFilenames = new String[2];
+            oldFilenames[0] = filename.replace( "org.apache.directory.studio.ldapbrowser.core",
+                "org.apache.directory.ldapstudio.browser.core" );
+            oldFilenames[1] = oldFilenames[0].replace( ".ApacheDirectoryStudio", ".ldapstudio" );
+            for ( int i = 0; i < oldFilenames.length; i++ )
+            {
+                File oldFile = new File( oldFilenames[i] );
+                if ( oldFile.exists() )
+                {
+                    try
+                    {
+                        String oldContent = FileUtils.readFileToString( oldFile, "UTF-8" );
+                        String newContent = oldContent.replace( "org.apache.directory.ldapstudio.browser.core",
+                            "org.apache.directory.studio.ldapbrowser.core" );
+                        FileUtils.writeStringToFile( file, newContent, "UTF-8" );
+                        break;
+                    }
+                    catch ( IOException e )
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+
+        return filename;
+    }
+
+
+    /**
+     * Converts a String into a Saveable String.
+     *
+     * @param s
+     *      the String to convert
+     * @return
+     *      the converted String
+     */
+    private static String toSaveString( String s )
+    {
+        if ( s == null )
+        {
+            return null;
+        }
+
+        byte[] b = LdifUtils.utf8encode( s );
+        StringBuffer sb = new StringBuffer();
+        for ( int i = 0; i < b.length; i++ )
+        {
+
+            if ( b[i] == '-' || b[i] == '_' || ( '0' <= b[i] && b[i] <= '9' ) || ( 'A' <= b[i] && b[i] <= 'Z' )
+                || ( 'a' <= b[i] && b[i] <= 'z' ) )
+            {
+                sb.append( ( char ) b[i] );
+            }
+            else
+            {
+                int x = ( int ) b[i];
+                if ( x < 0 )
+                    x = 256 + x;
+                String t = Integer.toHexString( x );
+                if ( t.length() == 1 )
+                    t = "0" + t; //$NON-NLS-1$
+                sb.append( t );
+            }
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * Gets a browser connection from its id.
+     *
+     * @param id
+     *      the id of the Connection
+     * @return
+     *      the corresponding IBrowserConnection
+     */
+    public IBrowserConnection getBrowserConnectionById( String id )
+    {
+        return connectionMap.get( id );
+    }
+
+
+    /**
+     * Gets a browser connection from its name.
+     *
+     * @param name
+     *      the name of the Connection
+     * @return
+     *      the corresponding IBrowserConnection
+     */
+    public IBrowserConnection getBrowserConnectionByName( String name )
+    {
+        Connection connection = ConnectionCorePlugin.getDefault().getConnectionManager().getConnectionByName( name );
+        return getBrowserConnection( connection );
+    }
+    
+    
+    /**
+     * Gets a browser connection from its underlying connection.
+     *
+     * @param connection
+     *      the underlying connection
+     * @return
+     *      the corresponding IBrowserConnection
+     */
+    public IBrowserConnection getBrowserConnection( Connection connection )
+    {
+        return connection != null ? getBrowserConnectionById( connection.getId() ) : null;
+    }
+
+
+    /**
+     * Gets an array containing all the Connections.
+     *
+     * @return
+     *      an array containing all the Connections
+     */
+    public IBrowserConnection[] getBrowserConnections()
+    {
+        return ( IBrowserConnection[] ) connectionMap.values().toArray( new IBrowserConnection[0] );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionRemoved(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionRemoved( Connection connection )
+    {
+        // update connection list
+        IBrowserConnection browserConnection = connectionMap.remove( connection.getId() );
+
+        // remove schema file
+        File schemaFile = new File( getSchemaCacheFileName( browserConnection ) );
+        if ( schemaFile.exists() )
+        {
+            schemaFile.delete();
+        }
+
+        // make persistent
+        saveBrowserConnections();
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionAdded(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionAdded( Connection connection )
+    {
+        // update connection list
+        BrowserConnection browserConnection = new BrowserConnection( connection );
+        connectionMap.put( connection.getId(), browserConnection );
+
+        // make persistent
+        saveBrowserConnections();
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionUpdated(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionUpdated( Connection connection )
+    {
+        saveBrowserConnections();
+        saveSchema( getBrowserConnection( connection ) );
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionOpened(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionOpened( Connection connection )
+    {
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionClosed(org.apache.directory.studio.connection.core.Connection)
+     */
+    public void connectionClosed( Connection connection )
+    {
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionFolderModified(org.apache.directory.studio.connection.core.ConnectionFolder)
+     */
+    public void connectionFolderModified( ConnectionFolder connectionFolder )
+    {
+    }
+
+
+    /**
+     * @see org.apache.directory.studio.ldapbrowser.core.events.BrowserConnectionUpdateListener#browserConnectionUpdated(org.apache.directory.studio.ldapbrowser.core.events.BrowserConnectionUpdateEvent)
+     */
+    public void browserConnectionUpdated( BrowserConnectionUpdateEvent browserConnectionUpdateEvent )
+    {
+        if ( browserConnectionUpdateEvent.getDetail() == BrowserConnectionUpdateEvent.Detail.BROWSER_CONNECTION_OPENED
+            || browserConnectionUpdateEvent.getDetail() == BrowserConnectionUpdateEvent.Detail.SCHEMA_UPDATED )
+        {
+            saveSchema( browserConnectionUpdateEvent.getBrowserConnection() );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void searchUpdated( SearchUpdateEvent searchUpdateEvent )
+    {
+        if ( searchUpdateEvent.getDetail() == SearchUpdateEvent.EventDetail.SEARCH_ADDED
+            || searchUpdateEvent.getDetail() == SearchUpdateEvent.EventDetail.SEARCH_REMOVED
+            || searchUpdateEvent.getDetail() == SearchUpdateEvent.EventDetail.SEARCH_RENAMED
+            || searchUpdateEvent.getDetail() == SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED )
+        {
+            saveBrowserConnections();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent )
+    {
+        if ( bookmarkUpdateEvent.getDetail() == BookmarkUpdateEvent.Detail.BOOKMARK_ADDED
+            || bookmarkUpdateEvent.getDetail() == BookmarkUpdateEvent.Detail.BOOKMARK_REMOVED
+            || bookmarkUpdateEvent.getDetail() == BookmarkUpdateEvent.Detail.BOOKMARK_UPDATED )
+        {
+            saveBrowserConnections();
+        }
+    }
+
+
+    /**
+     * Saves the browser Connections
+     */
+    private void saveBrowserConnections()
+    {
+        // To avoid a corrupt file, save object to a temp file first 
+        try
+        {
+            BrowserConnectionIO.save( new FileOutputStream( getBrowserConnectionStoreFileName() + "-temp" ), connectionMap );
+        }
+        catch ( IOException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        // move temp file to good file
+        File file = new File( getBrowserConnectionStoreFileName() );
+        File tempFile = new File( getBrowserConnectionStoreFileName() + "-temp" );
+        if ( file.exists() )
+        {
+            file.delete();
+        }
+
+        try
+        {
+            String content = FileUtils.readFileToString( tempFile, "UTF-8" );
+            FileUtils.writeStringToFile( file, content, "UTF-8" );
+        }
+        catch ( IOException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        
+//        Object[][] object = new Object[connectionMap.size()][3];
+//
+//        Iterator<IBrowserConnection> connectionIterator = connectionMap.values().iterator();
+//        for ( int i = 0; connectionIterator.hasNext(); i++ )
+//        {
+//            IBrowserConnection browserConnection = connectionIterator.next();
+//            
+//            ISearch[] searches = browserConnection.getSearchManager().getSearches();
+//            SearchParameter[] searchParameters = new SearchParameter[searches.length];
+//            for ( int k = 0; k < searches.length; k++ )
+//            {
+//                searchParameters[k] = searches[k].getSearchParameter();
+//            }
+//            
+//            IBookmark[] bookmarks = browserConnection.getBookmarkManager().getBookmarks();
+//            BookmarkParameter[] bookmarkParameters = new BookmarkParameter[bookmarks.length];
+//            for ( int k = 0; k < bookmarks.length; k++ )
+//            {
+//                bookmarkParameters[k] = bookmarks[k].getBookmarkParameter();
+//            }
+//
+//            object[i][0] = browserConnection.getConnection().getId();
+//            object[i][1] = searchParameters;
+//            object[i][2] = bookmarkParameters;
+//        }
+//
+//        save( object, getBrowserConnectionStoreFileName() );
+    }
+
+
+    /**
+     * Saves the Schema of the Connection
+     *
+     * @param connection
+     *      the Connection
+     */
+    private void saveSchema( IBrowserConnection connection )
+    {
+        try
+        {
+            String filename = getSchemaCacheFileName( connection );
+            FileWriter writer = new FileWriter( filename );
+            connection.getSchema().saveToLdif( writer );
+            writer.close();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * Loads the Connections
+     */
+    private void loadBrowserConnections()
+    {
+        Connection[] connections = ConnectionCorePlugin.getDefault().getConnectionManager().getConnections();
+        for ( int i = 0; i < connections.length; i++ )
+        {
+            Connection connection = connections[i];
+            BrowserConnection browserConnection = new BrowserConnection( connection );
+            connectionMap.put( connection.getId(), browserConnection );
+            
+            try
+            {
+                String schemaFilename = getSchemaCacheFileName( browserConnection );
+                FileReader reader = new FileReader( schemaFilename );
+                Schema schema = new Schema();
+                schema.loadFromLdif( reader );
+                browserConnection.setSchema( schema );
+            }
+            catch ( Exception e )
+            {
+            }
+        }
+        
+        // java.beans.XMLDecoder
+        try
+        {
+            String fileName = getBrowserConnectionStoreFileName();
+            File file = new File( fileName );
+            if ( file.exists() )
+            {
+                String oldContent = FileUtils.readFileToString( file, "UTF-8" );
+                if(!oldContent.contains( "java.beans.XMLDecoder" ))
+                {
+                    // new file format
+                    try
+                    {
+                        BrowserConnectionIO.load( new FileInputStream( getBrowserConnectionStoreFileName() ), connectionMap );
+                    }
+                    catch ( Exception e )
+                    {
+                        // If loading failed, try with temp file
+                        try
+                        {
+                            BrowserConnectionIO
+                                .load( new FileInputStream( getBrowserConnectionStoreFileName() + "-temp" ), connectionMap );
+                        }
+                        catch ( FileNotFoundException e1 )
+                        {
+                            // TODO Auto-generated catch block
+                            return;
+                        }
+                        catch ( ConnectionIOException e1 )
+                        {
+                            // TODO Auto-generated catch block
+                            return;
+                        }
+                    }
+                }
+                else 
+                {
+                    // old file format
+                    Object[][] object = ( Object[][] ) this.load( getBrowserConnectionStoreFileName() );
+
+                    if ( object != null )
+                    {
+                        try
+                        {
+                            for ( int i = 0; i < object.length; i++ )
+                            {
+                                String connectionId = ( String ) object[i][0];
+                                IBrowserConnection browserConnection = getBrowserConnectionById( connectionId );
+
+                                if ( browserConnection != null )
+                                {
+                                    if ( object[i].length > 0 )
+                                    {
+                                        SearchParameter[] searchParameters = ( SearchParameter[] ) object[i][1];
+                                        for ( int k = 0; k < searchParameters.length; k++ )
+                                        {
+                                            ISearch search = new Search( browserConnection, searchParameters[k] );
+                                            browserConnection.getSearchManager().addSearch( search );
+                                        }
+                                    }
+
+                                    if ( object[i].length > 1 )
+                                    {
+                                        BookmarkParameter[] bookmarkParameters = ( BookmarkParameter[] ) object[i][2];
+                                        for ( int k = 0; k < bookmarkParameters.length; k++ )
+                                        {
+                                            IBookmark bookmark = new Bookmark( browserConnection, bookmarkParameters[k] );
+                                            browserConnection.getBookmarkManager().addBookmark( bookmark );
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        catch ( ArrayIndexOutOfBoundsException e )
+                        {
+                            // Thrown by decoder.readObject(), signals EOF
+                        }
+                        catch ( Exception e )
+                        {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            }
+        }
+        catch ( Exception e )
+        {
+        }
+        
+        
+    }
+
+
+    /**
+     * Loads an Object from an XML file
+     *
+     * @param filename
+     *      the filename of the XML file
+     * @return
+     *      the deserialized Object
+     */
+    private synchronized Object load( String filename )
+    {
+        try
+        {
+            Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
+            XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( ( new FileInputStream( filename ) ) ) );
+            Object object = decoder.readObject();
+            decoder.close();
+            return object;
+        }
+        catch ( IOException ioe )
+        {
+            return null;
+        }
+        catch ( Exception e )
+        {
+            // if loading failed, try with temp file
+            String tempFilename = filename + "-temp";
+            try
+            {
+                XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( ( new FileInputStream( tempFilename ) ) ) );
+                Object object = decoder.readObject();
+                decoder.close();
+                return object;
+            }
+            catch ( IOException ioe2 )
+            {
+                return null;
+            }
+            catch ( Exception e2 )
+            {
+                return null;
+            }
+        }
+    }
+
+
+    class TypeSafeEnumPersistenceDelegate extends PersistenceDelegate
+    {
+        protected boolean mutatesTo( Object oldInstance, Object newInstance )
+        {
+            return oldInstance == newInstance;
+        }
+
+
+        protected Expression instantiate( Object oldInstance, Encoder out )
+        {
+            Class<?> type = oldInstance.getClass();
+            if ( !Modifier.isPublic( type.getModifiers() ) )
+            {
+                throw new IllegalArgumentException( "Could not instantiate instance of non-public class: "
+                    + oldInstance );
+            }
+
+            for ( Field field : type.getFields() )
+            {
+                int mod = field.getModifiers();
+                if ( Modifier.isPublic( mod ) && Modifier.isStatic( mod ) && Modifier.isFinal( mod )
+                    && ( type == field.getDeclaringClass() ) )
+                {
+                    try
+                    {
+                        if ( oldInstance == field.get( null ) )
+                        {
+                            return new Expression( oldInstance, field, "get", new Object[]
+                                { null } );
+                        }
+                    }
+                    catch ( IllegalAccessException exception )
+                    {
+                        throw new IllegalArgumentException( "Could not get value of the field: " + field, exception );
+                    }
+                }
+            }
+            throw new IllegalArgumentException( "Could not instantiate value: " + oldInstance );
+        }
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCoreConstants.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCoreConstants.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCoreConstants.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCoreConstants.java Mon Nov  5 08:51:43 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.core;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+
+
+/**
+ * This class contains all the constants used by the Browser Core Plugin
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface BrowserCoreConstants
+{
+    public static final String PREFERENCE_BINARY_SYNTAXES = "binarySyntaxes"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_BINARY_ATTRIBUTES = "binaryAttributes"; //$NON-NLS-1$
+
+    public static final String BINARY = "BINARY"; //$NON-NLS-1$
+
+    public static final String LINE_SEPARATOR = System.getProperty( "line.separator" ); //$NON-NLS-1$
+
+    public static final String DEFAULT_ENCODING = new OutputStreamWriter( new ByteArrayOutputStream() ).getEncoding();
+
+    public static final String DATEFORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_CHECK_FOR_CHILDREN = "checkForChildren"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS = "showAliasAndReferralObjects"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_FETCH_SUBENTRIES = "fetchSubentries"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_FORMAT_CSV_ATTRIBUTEDELIMITER = "formatCsvAttributeDelimiter"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_FORMAT_CSV_VALUEDELIMITER = "formatCsvValueDelimiter"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_FORMAT_CSV_QUOTECHARACTER = "formatCsvQuoteCharacter"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_FORMAT_CSV_LINESEPARATOR = "formatCsvLineSeparator"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_FORMAT_CSV_BINARYENCODING = "formatCsvBinaryEncoding"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_FORMAT_CSV_ENCODING = "formatCsvEncoding"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_FORMAT_XLS_VALUEDELIMITER = "formatXlsValueDelimiter"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_FORMAT_XLS_BINARYENCODING = "formatXlsBinaryEncoding"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_LDIF_LINE_WIDTH = "ldifLineWidth"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_LDIF_LINE_SEPARATOR = "ldifLineSeparator"; //$NON-NLS-1$
+
+    public static final String PREFERENCE_LDIF_SPACE_AFTER_COLON = "ldifSpaceAfterColon"; //$NON-NLS-1$
+
+    public static final int BINARYENCODING_IGNORE = 0;
+
+    public static final int BINARYENCODING_BASE64 = 1;
+
+    public static final int BINARYENCODING_HEX = 2;
+
+    public static final int SORT_BY_NONE = 0;
+
+    public static final int SORT_BY_RDN = 1;
+
+    public static final int SORT_BY_RDN_VALUE = 2;
+
+    public static final int SORT_BY_ATTRIBUTE_DESCRIPTION = 3;
+
+    public static final int SORT_BY_VALUE = 4;
+
+    public static final int SORT_ORDER_NONE = 0;
+
+    public static final int SORT_ORDER_ASCENDING = 1;
+
+    public static final int SORT_ORDER_DESCENDING = 2;
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCoreMessages.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCoreMessages.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCoreMessages.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCoreMessages.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,424 @@
+/*
+ *  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.core;
+
+
+import org.eclipse.osgi.util.NLS;
+
+
+/**
+ * This class contains most of the Strings used by the Plugin
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserCoreMessages extends NLS
+{
+    private static final String BUNDLE_NAME = "org.apache.directory.studio.ldapbrowser.core.browsercoremessages"; //$NON-NLS-1$
+
+	
+	/**
+	 * Creates a new instance of BrowserCoreMessages.
+	 */
+	private BrowserCoreMessages()
+    {
+    }
+
+    static
+    {
+        // initialize resource bundle
+        NLS.initializeMessages( BUNDLE_NAME, BrowserCoreMessages.class );
+    }
+
+    public static String copy_n_of_s;
+
+    public static String event__added_att_to_dn;
+
+    public static String event__deleted_att_from_dn;
+
+    public static String event__dn_attributes_initialized;
+
+    public static String event__dn_children_initialized;
+    
+    public static String event__bulk_modification;
+
+    public static String event__empty_value_added_to_att_at_dn;
+
+    public static String event__empty_value_deleted_from_att_at_dn;
+
+    public static String event__added_dn;
+
+    public static String event__deleted_dn;
+
+    public static String event__moved_oldrdn_from_oldparent_to_newparent;
+
+    public static String event__renamed_olddn_to_newdn;
+
+    public static String event__added_val_to_att_at_dn;
+
+    public static String event__deleted_val_from_att_at_dn;
+
+    public static String event__replaced_oldval_by_newval_at_att_at_dn;
+
+    public static String event__renamed_oldval_by_newval_at_dn;
+
+    public static String jobs__copy_entries_source_and_target_are_equal;
+
+    public static String model__empty_connection;
+
+    public static String model__empty_entry;
+
+    public static String model__empty_attribute;
+
+    public static String model__empty_value;
+
+    public static String model__empty_url;
+
+    public static String model__empty_dn;
+
+    public static String model__empty_rdn;
+
+    public static String model__empty_password;
+
+    public static String model__invalid_url;
+
+    public static String model__invalid_protocol;
+
+    public static String model__attribute_does_not_exist;
+
+    public static String model__attribute_already_exists;
+
+    public static String model__attributes_entry_is_not_myself;
+
+    public static String model__url_no_attributes;
+
+    public static String model__url_no_dn;
+
+    public static String model__url_no_extensions;
+
+    public static String model__url_no_filter;
+
+    public static String model__url_no_host;
+
+    public static String model__url_no_port;
+
+    public static String model__url_no_protocol;
+
+    public static String model__url_no_scope;
+
+    public static String model__values_attribute_is_not_myself;
+
+    public static String model__move_between_different_connections_not_supported;
+
+    public static String model__copied_n_entries;
+
+    public static String model__deleted_n_entries;
+
+    public static String model__retrieved_n_entries;
+
+    public static String model__retrieved_1_entry;
+
+    public static String model__no_connection_provider;
+
+    public static String model__connecting;
+
+    public static String model__binding;
+
+    public static String model__loading_rootdse;
+
+    public static String model__error_loading_rootdse;
+
+    public static String model__setting_base_dn;
+
+    public static String model__error_setting_base_dn;
+
+    public static String model__error_setting_metadata;
+
+    public static String model__loading_schema;
+
+    public static String model__no_schema_information;
+
+    public static String model__missing_schema_location;
+
+    public static String model__error_loading_schema;
+
+    public static String model__no_such_entry;
+
+    public static String model__error_logging_modification;
+
+    public static String model__no_hash;
+
+    public static String model__unsupported_hash;
+
+    public static String ldif__imported_n_entries_m_errors;
+
+    public static String ldif__n_errors_see_logfile;
+
+    public static String ldif__imported_into_host_port_on_date;
+
+    public static String ldif__import_into_host_port_failed_on_date;
+
+    public static String ldif__error_msg;
+    
+    public static String dsml__n_errors_see_responsefile;
+
+    public static String model__no_connection;
+
+    public static String model__no_auth_handler;
+
+    public static String model__no_credentials;
+
+    public static String model__no_referral_handler;
+
+    public static String model__no_referral_connection;
+
+    public static String model__invalid_record;
+
+    public static String model__unknown_host;
+
+    public static String jobs__error_occurred;
+
+    public static String jobs__check_bind_name;
+
+    public static String jobs__check_bind_task;
+
+    public static String jobs__check_bind_error;
+
+    public static String jobs__check_network_name;
+
+    public static String jobs__check_network_task;
+
+    public static String jobs__check_network_error;
+
+    public static String jobs__fetch_basedns_name;
+
+    public static String jobs__fetch_basedns_task;
+
+    public static String jobs__fetch_basedns_error;
+
+    public static String jobs__copy_entries_name_1;
+
+    public static String jobs__copy_entries_name_n;
+
+    public static String jobs__copy_entries_task_1;
+
+    public static String jobs__copy_entries_task_n;
+
+    public static String jobs__copy_entries_error_1;
+
+    public static String jobs__copy_entries_error_n;
+
+    public static String jobs__create_entry_name_1;
+
+    public static String jobs__create_entry_name_n;
+
+    public static String jobs__create_entry_task_1;
+
+    public static String jobs__create_entry_task_n;
+
+    public static String jobs__create_entry_error_1;
+
+    public static String jobs__create_entry_error_n;
+
+    public static String jobs__create_values_name_1;
+
+    public static String jobs__create_values_name_n;
+
+    public static String jobs__create_values_task_1;
+
+    public static String jobs__create_values_task_n;
+
+    public static String jobs__create_values_error_1;
+
+    public static String jobs__create_values_error_n;
+
+    public static String jobs__delete_attributes_name_1;
+
+    public static String jobs__delete_attributes_name_n;
+
+    public static String jobs__delete_attributes_task_1;
+
+    public static String jobs__delete_attributes_task_n;
+
+    public static String jobs__delete_attributes_error_1;
+
+    public static String jobs__delete_attributes_error_n;
+
+    public static String jobs__delete_entries_name_1;
+
+    public static String jobs__delete_entries_name_n;
+
+    public static String jobs__delete_entries_task_1;
+
+    public static String jobs__delete_entries_task_n;
+
+    public static String jobs__delete_entries_error_1;
+
+    public static String jobs__delete_entries_error_n;
+
+    public static String jobs__execute_ldif_name;
+
+    public static String jobs__execute_ldif_task;
+
+    public static String jobs__execute_ldif_error;
+
+    public static String jobs__export_cvs_error;
+
+    public static String jobs__export_csv_name;
+
+    public static String jobs__export_csv_task;
+
+    public static String jobs__export_ldif_name;
+
+    public static String jobs__export_ldif_task;
+
+    public static String jobs__export_ldif_error;
+    
+    public static String jobs__export_dsml_name;
+
+    public static String jobs__export_dsml_task;
+
+    public static String jobs__export_dsml_error;
+
+    public static String jobs__export_progress;
+
+    public static String jobs__progressmonitor_check_cancellation;
+
+    public static String jobs__progressmonitor_report_progress;
+
+    public static String jobs__export_xls_name;
+
+    public static String jobs__export_xls_task;
+
+    public static String jobs__export_xls_error;
+
+    public static String jobs__import_ldif_name;
+
+    public static String jobs__import_ldif_task;
+
+    public static String jobs__import_ldif_error;
+    
+    public static String jobs__import_dsml_name;
+
+    public static String jobs__import_dsml_task;
+
+    public static String jobs__import_dsml_error;
+
+    public static String jobs__init_entries_title_attandsub;
+
+    public static String jobs__init_entries_title_subonly;
+
+    public static String jobs__init_entries_title_attonly;
+
+    public static String jobs__init_entries_title;
+
+    public static String jobs__init_entries_task;
+
+    public static String jobs__init_entries_progress_att;
+
+    public static String jobs__init_entries_progress_sub;
+
+    public static String jobs__init_entries_progress_subcount;
+
+    public static String jobs__init_entries_error_1;
+
+    public static String jobs__init_entries_error_n;
+
+    public static String jobs__modify_value_name;
+
+    public static String jobs__modify_value_task;
+
+    public static String jobs__modify_value_error;
+
+    public static String jobs__open_connections_name_1;
+
+    public static String jobs__open_connections_name_n;
+
+    public static String jobs__open_connections_task;
+
+    public static String jobs__open_connections_error_1;
+
+    public static String jobs__open_connections_error_n;
+
+    public static String jobs__read_entry_name;
+
+    public static String jobs__read_entry_task;
+
+    public static String jobs__read_entry_error;
+
+    public static String jobs__reload_schemas_name_1;
+
+    public static String jobs__reload_schemas_name_n;
+
+    public static String jobs__reload_schemas_task;
+
+    public static String jobs__reload_schemas_error_1;
+
+    public static String jobs__reload_schemas_error_n;
+
+    public static String jobs__move_entry_name_1;
+
+    public static String jobs__move_entry_name_n;
+
+    public static String jobs__move_entry_task_1;
+
+    public static String jobs__move_entry_task_n;
+
+    public static String jobs__move_entry_error_1;
+
+    public static String jobs__move_entry_error_n;
+
+    public static String jobs__rename_entry_name;
+
+    public static String jobs__rename_entry_task;
+
+    public static String jobs__rename_entry_error;
+
+    public static String jobs__rename_value_name_1;
+
+    public static String jobs__rename_value_name_n;
+
+    public static String jobs__rename_value_task_1;
+
+    public static String jobs__rename_value_task_n;
+
+    public static String jobs__rename_value_error_1;
+
+    public static String jobs__rename_value_error_n;
+
+    public static String jobs__search_name;
+
+    public static String jobs__search_task;
+
+    public static String jobs__search_error_1;
+
+    public static String jobs__search_error_n;
+
+    public static String model__empty_string_value;
+
+    public static String model__empty_binary_value;
+
+    public static String model__invalid_rdn;
+
+    public static String model_filter_missing_closing_parenthesis;
+
+    public static String model_filter_missing_filter_expression;
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePlugin.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePlugin.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePlugin.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePlugin.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,175 @@
+/*
+ *  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.core;
+
+
+import org.apache.directory.studio.ldapbrowser.core.events.CoreEventRunner;
+import org.apache.directory.studio.ldapbrowser.core.events.EventRunner;
+import org.apache.directory.studio.ldapbrowser.core.model.IReferralHandler;
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class BrowserCorePlugin extends Plugin
+{
+    /** The plugin ID */
+    public static final String PLUGIN_ID = "org.apache.directory.studio.ldapbrowser.core"; //$NON-NLS-1$
+
+    /** The shared instance. */
+    private static BrowserCorePlugin plugin;
+
+    /** The connection manager */
+    private BrowserConnectionManager connectionManager;
+
+    /** The connection provider */
+    private IReferralHandler referralHandler;
+
+    /** The preferences */
+    private BrowserCorePreferences preferences;
+
+    /** The event runner. */
+    private EventRunner eventRunner;
+
+
+    /**
+     * Creates a new instance of BrowserCorePlugin.
+     */
+    public BrowserCorePlugin()
+    {
+        super();
+        plugin = this;
+        this.preferences = new BrowserCorePreferences();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start( BundleContext context ) throws Exception
+    {
+        super.start( context );
+
+        if ( eventRunner == null )
+        {
+            eventRunner = new CoreEventRunner();
+        }
+
+        if ( connectionManager == null )
+        {
+            connectionManager = new BrowserConnectionManager();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void stop( BundleContext context ) throws Exception
+    {
+        super.stop( context );
+
+        if ( eventRunner != null )
+        {
+            eventRunner = null;
+        }
+
+        if ( connectionManager != null )
+        {
+//            IConnection[] connections = connectionManager.getConnections();
+//            for ( int i = 0; i < connections.length; i++ )
+//            {
+//                connections[i].close();
+//            }
+            connectionManager = null;
+        }
+    }
+
+
+    /**
+     * Returns the BrowserPlugin instance.
+     *
+     * @return The BrowserPlugin instance
+     */
+    public static BrowserCorePlugin getDefault()
+    {
+        return plugin;
+    }
+
+
+    /**
+     * Gets the Connection Manager
+     *
+     * @return
+     *      the connection manager
+     */
+    public BrowserConnectionManager getConnectionManager()
+    {
+        return connectionManager;
+    }
+
+
+    /**
+     *
+     * @return The preferences
+     */
+    public BrowserCorePreferences getCorePreferences()
+    {
+        return preferences;
+    }
+
+
+    /**
+     * Gets the ReferralHanlder
+     *
+     * @return
+     *      the ReferralHandler
+     */
+    public IReferralHandler getReferralHandler()
+    {
+        return referralHandler;
+    }
+
+
+    /**
+     * Sets the ReferralHandler
+     *
+     * @param referralHandler
+     *      the ReferralHandler to set
+     */
+    public void setReferralHandler( IReferralHandler referralHandler )
+    {
+        this.referralHandler = referralHandler;
+    }
+
+
+    /**
+     * Gets the event runner.
+     *
+     * @return the event runner
+     */
+    public EventRunner getEventRunner()
+    {
+        return eventRunner;
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferences.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferences.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferences.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferences.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,259 @@
+/*
+ *  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.core;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.studio.ldapbrowser.core.model.schema.BinaryAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.BinarySyntax;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+import org.eclipse.core.runtime.Preferences;
+
+
+/**
+ * This class is used to manage and access the preferences of the Browser Core Plugin
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserCorePreferences
+{
+    private Set<String> binaryAttributeCache;
+
+    private Set<String> binarySyntaxCache;
+
+
+    /**
+     * Gets the oids and names of the binary attributes
+     *
+     * @return
+     *      the oids and names of the binary attributes
+     */
+    public Set getBinaryAttributeOidsAndNames()
+    {
+        if ( binaryAttributeCache == null )
+        {
+            binaryAttributeCache = new HashSet<String>();
+            BinaryAttribute[] binaryAttributes =getBinaryAttributes();
+            for ( int i = 0; i < binaryAttributes.length; i++ )
+            {
+                if ( binaryAttributes[i].getAttributeNumericOidOrName() != null )
+                {
+                    binaryAttributeCache.add( binaryAttributes[i].getAttributeNumericOidOrName() );
+                }
+            }
+        }
+        return binaryAttributeCache;
+    }
+
+
+    /**
+     * Gets an array containing the binary attributes
+     * 
+     * @return
+     *      an array containing the binary attributes
+     */
+    public BinaryAttribute[] getBinaryAttributes()
+    {
+        BinaryAttribute[] binaryAttributes = ( BinaryAttribute[] ) load( BrowserCoreConstants.PREFERENCE_BINARY_ATTRIBUTES );
+        return binaryAttributes;
+    }
+
+
+    /**
+     * Sets the binary attributes
+     *
+     * @param binaryAttributes
+     *      the binary attributes to set
+     */
+    public void setBinaryAttributes( BinaryAttribute[] binaryAttributes )
+    {
+        store( BrowserCoreConstants.PREFERENCE_BINARY_ATTRIBUTES, binaryAttributes );
+        binaryAttributeCache = null;
+    }
+
+
+    /**
+     * Gets the default binary attributes
+     *
+     * @return
+     *      the default binary attributes
+     */
+    public BinaryAttribute[] getDefaultBinaryAttributes()
+    {
+        BinaryAttribute[] binaryAttributes = ( BinaryAttribute[] ) loadDefault( BrowserCoreConstants.PREFERENCE_BINARY_ATTRIBUTES );
+        return binaryAttributes;
+    }
+
+
+    /**
+     * Sets the default binary attributes
+     *
+     * @param defaultBinaryAttributes
+     *      the default binary attributes to set
+     */
+    public void setDefaultBinaryAttributes( BinaryAttribute[] defaultBinaryAttributes )
+    {
+        storeDefault( BrowserCoreConstants.PREFERENCE_BINARY_ATTRIBUTES, defaultBinaryAttributes );
+    }
+
+
+    /**
+     * Gets the binary syntax oids.
+     * 
+     * @return the binary syntax oids
+     */
+    public Set<String> getBinarySyntaxOids()
+    {
+        if ( binarySyntaxCache == null )
+        {
+            binarySyntaxCache = new HashSet<String>();
+            BinarySyntax[] binarySyntaxes = getBinarySyntaxes();
+            for ( int i = 0; i < binarySyntaxes.length; i++ )
+            {
+                if ( binarySyntaxes[i].getSyntaxNumericOid() != null )
+                {
+                    binarySyntaxCache.add( binarySyntaxes[i].getSyntaxNumericOid() );
+                }
+            }
+        }
+        return binarySyntaxCache;
+    }
+
+
+    /**
+     * Gets the binary syntaxes
+     *
+     * @return
+     *      the binary syntaxes
+     */
+    public BinarySyntax[] getBinarySyntaxes()
+    {
+        BinarySyntax[] binarySyntaxes = ( BinarySyntax[] ) load( BrowserCoreConstants.PREFERENCE_BINARY_SYNTAXES );
+        return binarySyntaxes;
+    }
+
+
+    /**
+     * Sets the binary syntaxes
+     *
+     * @param binarySyntaxes
+     *      the binary syntaxes to set
+     */
+    public void setBinarySyntaxes( BinarySyntax[] binarySyntaxes )
+    {
+        store( BrowserCoreConstants.PREFERENCE_BINARY_SYNTAXES, binarySyntaxes );
+        binarySyntaxCache = null;
+    }
+
+
+    /**
+     * Gets the default binary syntaxes
+     *
+     * @return
+     *      the default binary syntaxes
+     */
+    public BinarySyntax[] getDefaultBinarySyntaxes()
+    {
+        BinarySyntax[] binarySyntaxes = ( BinarySyntax[] ) loadDefault( BrowserCoreConstants.PREFERENCE_BINARY_SYNTAXES );
+        return binarySyntaxes;
+    }
+
+
+    /**
+     * Sets the default binary syntaxes
+     *
+     * @param defaultBinarySyntaxes
+     *      the default binary syntaxes to set
+     */
+    public void setDefaultBinarySyntaxes( BinarySyntax[] defaultBinarySyntaxes )
+    {
+        storeDefault( BrowserCoreConstants.PREFERENCE_BINARY_SYNTAXES, defaultBinarySyntaxes );
+    }
+
+
+    /**
+     * Loads the current value of the string-valued property with the given name.
+     *
+     * @param key
+     *      the name of the property
+     * @return
+     *      the corresponding object
+     */
+    private static Object load( String key )
+    {
+        Preferences store = BrowserCorePlugin.getDefault().getPluginPreferences();
+        String s = store.getString( key );
+        return Utils.deserialize( s );
+    }
+
+
+    /**
+     * Stores the current value of the string-valued property with the given name.
+     *
+     * @param key
+     *      the name of the property
+     * @param o
+     *      the new current value of the property
+     */
+    private static void store( String key, Object o )
+    {
+        Preferences store = BrowserCorePlugin.getDefault().getPluginPreferences();
+        String s = Utils.serialize( o );
+        store.setValue( key, s );
+        BrowserCorePlugin.getDefault().savePluginPreferences();
+    }
+
+
+    /**
+     * Loads the default value for the string-valued property with the given name.
+     *
+     * @param key
+     *      the name of the property
+     * @return
+     *      the default value of the named property
+     */
+    private static Object loadDefault( String key )
+    {
+        Preferences store = BrowserCorePlugin.getDefault().getPluginPreferences();
+        String s = store.getDefaultString( key );
+        return Utils.deserialize( s );
+    }
+
+
+    /**
+     * Stores the default value for the string-valued property with the given name.
+     *
+     * @param key
+     *      the name of the property
+     * @param o
+     *      the new default value for the property
+     */
+    private static void storeDefault( String key, Object o )
+    {
+        Preferences store = BrowserCorePlugin.getDefault().getPluginPreferences();
+        String s = Utils.serialize( o );
+        store.setDefault( key, s );
+        BrowserCorePlugin.getDefault().savePluginPreferences();
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java Mon Nov  5 08:51:43 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.core;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.schema.BinaryAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.BinarySyntax;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+
+
+/**
+ * This class is used to set default preference values.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserCorePreferencesInitializer extends AbstractPreferenceInitializer
+{
+    /**
+     * {@inheritDoc}
+     */
+    public void initializeDefaultPreferences()
+    {
+        Preferences store = BrowserCorePlugin.getDefault().getPluginPreferences();
+
+        store.setDefault( BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN, true );
+        store.setDefault( BrowserCoreConstants.PREFERENCE_SHOW_ALIAS_AND_REFERRAL_OBJECTS, true );
+        store.setDefault( BrowserCoreConstants.PREFERENCE_FETCH_SUBENTRIES, false );
+
+        store.setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_CSV_ATTRIBUTEDELIMITER, "," );
+        store.setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_CSV_VALUEDELIMITER, "|" );
+        store.setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_CSV_QUOTECHARACTER, "\"" );
+        store
+            .setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_CSV_LINESEPARATOR, BrowserCoreConstants.LINE_SEPARATOR );
+        store.setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_CSV_BINARYENCODING,
+            BrowserCoreConstants.BINARYENCODING_IGNORE );
+        store.setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_CSV_ENCODING, BrowserCoreConstants.DEFAULT_ENCODING );
+
+        store.setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_XLS_VALUEDELIMITER, "|" );
+        store.setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_XLS_BINARYENCODING,
+            BrowserCoreConstants.BINARYENCODING_IGNORE );
+
+        store.setDefault( BrowserCoreConstants.PREFERENCE_LDIF_LINE_WIDTH, 76 );
+        store.setDefault( BrowserCoreConstants.PREFERENCE_LDIF_LINE_SEPARATOR, BrowserCoreConstants.LINE_SEPARATOR );
+        store.setDefault( BrowserCoreConstants.PREFERENCE_LDIF_SPACE_AFTER_COLON, true );
+
+        // default binary attributes
+        BinaryAttribute[] defaultBinaryAttributes = new BinaryAttribute[]
+            { new BinaryAttribute( "0.9.2342.19200300.100.1.7" ), // photo
+                // //$NON-NLS-1$
+                new BinaryAttribute( "0.9.2342.19200300.100.1.53" ), // personalSignature
+                // //$NON-NLS-1$
+                new BinaryAttribute( "0.9.2342.19200300.100.1.55" ), // audio
+                // //$NON-NLS-1$
+                new BinaryAttribute( "0.9.2342.19200300.100.1.60" ), // jpegPhoto
+                // //$NON-NLS-1$
+                new BinaryAttribute( "1.3.6.1.4.1.42.2.27.4.1.8" ), // javaSerializedData
+                // //$NON-NLS-1$
+                new BinaryAttribute( "1.3.6.1.4.1.1466.101.120.35" ), // thumbnailPhoto
+                // //$NON-NLS-1$
+                new BinaryAttribute( "1.3.6.1.4.1.1466.101.120.36" ), // thumbnailLogo
+                // //$NON-NLS-1$
+                new BinaryAttribute( "2.5.4.35" ), // userPassword
+                // //$NON-NLS-1$
+                new BinaryAttribute( "2.5.4.36" ), // userCertificate
+                // //$NON-NLS-1$
+                new BinaryAttribute( "2.5.4.37" ), // cACertificate
+                // //$NON-NLS-1$
+                new BinaryAttribute( "2.5.4.38" ), // authorityRevocationList
+                // //$NON-NLS-1$
+                new BinaryAttribute( "2.5.4.39" ), // certificateRevocationList
+                // //$NON-NLS-1$
+                new BinaryAttribute( "2.5.4.40" ), // crossCertificatePair
+                // //$NON-NLS-1$
+                new BinaryAttribute( "2.5.4.45" ), // x500UniqueIdentifier
+            // //$NON-NLS-1$
+            };
+        BrowserCorePlugin.getDefault().getCorePreferences().setDefaultBinaryAttributes( defaultBinaryAttributes );
+
+        // default binary syntaxes
+        BinarySyntax[] defaultBinarySyntaxes = new BinarySyntax[]
+            { new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.5" ), // Binary
+                // //$NON-NLS-1$
+                new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.8" ), // Certificate
+                // //$NON-NLS-1$
+                new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.9" ), // Certificate
+                // List
+                // //$NON-NLS-1$
+                new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.10" ), // Certificate
+                // Pair
+                // //$NON-NLS-1$
+                new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.23" ), // Fax
+                // //$NON-NLS-1$
+                new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.28" ), // JPEG
+                // //$NON-NLS-1$
+                new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.40" ), // Octet
+                // String
+                // //$NON-NLS-1$
+                new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.49" ) // Supported
+            // Algorithm
+            // //$NON-NLS-1$
+            };
+        BrowserCorePlugin.getDefault().getCorePreferences().setDefaultBinarySyntaxes( defaultBinarySyntaxes );
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/SearchManager.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/SearchManager.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/SearchManager.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/SearchManager.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,209 @@
+/*
+ *  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.core;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+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.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.eclipse.osgi.util.NLS;
+
+
+/**
+ * This class is used to manages {@link ISearch}es of an {@link IBrowserConnection}
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchManager implements Serializable
+{
+
+    /** The Constant serialVersionUID. */
+    private static final long serialVersionUID = 8665227628274097691L;
+
+    /** The list of searches. */
+    private List<ISearch> searchList;
+
+    /** The connection. */
+    private IBrowserConnection connection;
+
+
+    /**
+     * Creates a new instance of SearchManager.
+     */
+    protected SearchManager()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of SearchManager.
+     *
+     * @param connection
+     *      the attached Connection
+     */
+    public SearchManager( IBrowserConnection connection )
+    {
+        this.connection = connection;
+        this.searchList = new ArrayList<ISearch>();
+    }
+
+
+    /**
+     * Gets the Connection.
+     *
+     * @return
+     *      the Connection
+     */
+    public IBrowserConnection getConnection()
+    {
+        return this.connection;
+    }
+
+
+    /**
+     * Adds a Search.
+     *
+     * @param search
+     *      the Search to add
+     */
+    public void addSearch( ISearch search )
+    {
+        this.addSearch( this.searchList.size(), search );
+    }
+
+
+    /**
+     * Adds a Search at a specified position.
+     *
+     * @param index
+     *      index at which the specified Search is to be inserted.
+     * @param search
+     *      the Search to be inserted
+     */
+    public void addSearch( int index, ISearch search )
+    {
+        if ( getSearch( search.getName() ) != null )
+        {
+            String newSearchName = NLS.bind( BrowserCoreMessages.copy_n_of_s, "", search.getName() ); //$NON-NLS-1$
+
+            for ( int i = 2; this.getSearch( newSearchName ) != null; i++ )
+            {
+                newSearchName = NLS.bind( BrowserCoreMessages.copy_n_of_s, i + " ", search.getName() ); //$NON-NLS-1$
+            }
+
+            search.setName( newSearchName );
+        }
+
+        searchList.add( index, search );
+        EventRegistry.fireSearchUpdated( new SearchUpdateEvent( search, SearchUpdateEvent.EventDetail.SEARCH_ADDED ), this );
+    }
+
+
+    /**
+     * Gets a Search.
+     *
+     * @param name
+     *      the name of the Search
+     * @return
+     *      the corresponding Search
+     */
+    public ISearch getSearch( String name )
+    {
+        for ( ISearch search:searchList )
+        {
+            if ( search.getName().equals( name ) )
+            {
+                return search;
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Returns the index in the Searches list of the first occurrence of the specified Search.
+     *
+     * @param search
+     *      the Search to search for
+     * @return
+     *      the index in the Searches list of the first occurrence of the specified Search
+     */
+    public int indexOf( ISearch search )
+    {
+        return searchList.indexOf( search );
+    }
+
+
+    /**
+     * Removes a Search
+     *
+     * @param search
+     *      the Search to remove
+     */
+    public void removeSearch( ISearch search )
+    {
+        searchList.remove( search );
+        EventRegistry.fireSearchUpdated( new SearchUpdateEvent( search, SearchUpdateEvent.EventDetail.SEARCH_REMOVED ), this );
+    }
+
+
+    /**
+     * Removes a Search
+     *
+     * @param name
+     *      the name of the Search to remove
+     */
+    public void removeSearch( String name )
+    {
+        this.removeSearch( this.getSearch( name ) );
+    }
+
+
+    /**
+     * Gets an array containing all the Searches
+     *
+     * @return
+     *      an array containing all the Searches
+     */
+    public ISearch[] getSearches()
+    {
+        return searchList.toArray( new ISearch[0] );
+    }
+
+
+    /**
+     * Gets the number of Searches
+     *
+     * @return
+     *      the number of Searches
+     */
+    public int getSearchCount()
+    {
+        return searchList.size();
+    }
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributeAddedEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributeAddedEvent.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributeAddedEvent.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributeAddedEvent.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,77 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.events;
+
+
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+
+/**
+ * An AttributeAddedEvent indicates that an {@link IAttribute} was added to an {@link IEntry}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeAddedEvent extends EntryModificationEvent
+{
+
+    /** The added attribute. */
+    private IAttribute addedAttribute;
+
+
+    /**
+     * Creates a new instance of AttributeAddedEvent.
+     * 
+     * @param connection the connection
+     * @param modifiedEntry the modified entry
+     * @param addedAttribute the added attribute
+     */
+    public AttributeAddedEvent( IBrowserConnection connection, IEntry modifiedEntry, IAttribute addedAttribute )
+    {
+        super( connection, modifiedEntry );
+        this.addedAttribute = addedAttribute;
+    }
+
+
+    /**
+     * Gets the added attribute.
+     * 
+     * @return the added attribute
+     */
+    public IAttribute getAddedAttribute()
+    {
+        return addedAttribute;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        return BrowserCoreMessages.bind( BrowserCoreMessages.event__added_att_to_dn, new String[]
+            { getAddedAttribute().getDescription(), getModifiedEntry().getDn().getUpName() } );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributeDeletedEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributeDeletedEvent.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributeDeletedEvent.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributeDeletedEvent.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,77 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.ldapbrowser.core.events;
+
+
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+
+/**
+ * An AttributeDeletedEvent indicates that an {@link IAttribute} was deleted from an {@link IEntry}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeDeletedEvent extends EntryModificationEvent
+{
+
+    /** The deleted attribute. */
+    private IAttribute deletedAttribute;
+
+
+    /**
+     * Creates a new instance of AttributeDeletedEvent.
+     * 
+     * @param connection the connection
+     * @param modifiedEntry the modified entry
+     * @param deletedAttribute the deleted attribute
+     */
+    public AttributeDeletedEvent( IBrowserConnection connection, IEntry modifiedEntry, IAttribute deletedAttribute )
+    {
+        super( connection, modifiedEntry );
+        this.deletedAttribute = deletedAttribute;
+    }
+
+
+    /**
+     * Gets the deleted attribute.
+     * 
+     * @return the deleted attribute
+     */
+    public IAttribute getDeletedAttribute()
+    {
+        return deletedAttribute;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        return BrowserCoreMessages.bind( BrowserCoreMessages.event__deleted_att_from_dn, new String[]
+            { getDeletedAttribute().getDescription(), getModifiedEntry().getDn().getUpName() } );
+    }
+    
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributesInitializedEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributesInitializedEvent.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributesInitializedEvent.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/AttributesInitializedEvent.java Mon Nov  5 08:51:43 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.core.events;
+
+
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+
+/**
+ * An AttributesInitializedEvent indicates that the {@link IAttribute}s
+ * of an {@link IEntry} were newly initialized from the underlying 
+ * directory.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributesInitializedEvent extends EntryModificationEvent
+{
+
+    /**
+     * Creates a new instance of AttributesInitializedEvent.
+     * 
+     * @param initializedEntry the initialized entry
+     */
+    public AttributesInitializedEvent( IEntry initializedEntry )
+    {
+        super( initializedEntry.getBrowserConnection(), initializedEntry );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        return BrowserCoreMessages.bind( BrowserCoreMessages.event__dn_attributes_initialized, new String[]
+            { getModifiedEntry().getDn().getUpName() } );
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/BookmarkUpdateEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/BookmarkUpdateEvent.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/BookmarkUpdateEvent.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/BookmarkUpdateEvent.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,92 @@
+/*
+ *  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.core.events;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+
+
+/**
+ * An BookmarkUpdateEvent indicates that an {@link IBookmark} was modified.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BookmarkUpdateEvent
+{
+
+    /**
+     * Contains constants to specify the event detail.
+     */
+    public enum Detail
+    {
+        /** Indicates that the bookmark was added. */
+        BOOKMARK_ADDED,
+
+        /** Indicates that the bookmark was updated. */
+        BOOKMARK_UPDATED,
+
+        /** Indicates that the bookmark was removed. */
+        BOOKMARK_REMOVED
+    }
+
+    /** The event detail. */
+    private Detail detail;
+
+    /** The updated bookmark. */
+    private IBookmark bookmark;
+
+
+    /**
+     * Creates a new instance of BookmarkUpdateEvent.
+     *
+     * @param bookmark the updated bookmark
+     * @param detail the event detail
+     */
+    public BookmarkUpdateEvent( IBookmark bookmark, Detail detail )
+    {
+        this.bookmark = bookmark;
+        this.detail = detail;
+    }
+
+
+    /**
+     * Gets the updated bookmark.
+     *
+     * @return the updated bookmark
+     */
+    public IBookmark getBookmark()
+    {
+        return bookmark;
+    }
+
+
+    /**
+     * Gets the event detail.
+     *
+     * @return the event detail
+     */
+    public Detail getDetail()
+    {
+        return detail;
+    }
+
+}

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

Added: directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/BookmarkUpdateListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/BookmarkUpdateListener.java?rev=592082&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/BookmarkUpdateListener.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/events/BookmarkUpdateListener.java Mon Nov  5 08:51:43 2007
@@ -0,0 +1,44 @@
+/*
+ *  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.core.events;
+
+import java.util.EventListener;
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+
+
+/**
+ * A listener for {@link BookmarkUpdateEvent}s
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface BookmarkUpdateListener extends EventListener
+{
+
+    /**
+     * Called when an {@link IBookmark} was updated.
+     *
+     * @param bookmarkUpdateEvent the bookmark update event
+     */
+    public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent );
+
+}

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



Mime
View raw message