You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/11/16 17:56:37 UTC

svn commit: r475813 [2/3] - in /directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser: ./ META-INF/ resources/ resources/icons/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main...

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RefreshAction.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,148 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.controller.actions;
+
+
+import org.apache.directory.ldapstudio.browser.Activator;
+import org.apache.directory.ldapstudio.browser.model.Connection;
+import org.apache.directory.ldapstudio.browser.view.ImageKeys;
+import org.apache.directory.ldapstudio.browser.view.views.AttributesView;
+import org.apache.directory.ldapstudio.browser.view.views.BrowserView;
+import org.apache.directory.ldapstudio.browser.view.views.wrappers.ConnectionWrapper;
+import org.apache.directory.ldapstudio.browser.view.views.wrappers.EntryWrapper;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2ResponseParser;
+import org.apache.directory.ldapstudio.dsmlv2.engine.Dsmlv2Engine;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.ErrorResponse;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResponse;
+
+
+/**
+ * This class implements the Refresh Action
+ */
+public class RefreshAction extends Action
+{
+    private BrowserView view;
+
+
+    public RefreshAction( BrowserView view, String text )
+    {
+        super( text );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, ImageKeys.REFRESH ) );
+        setToolTipText( "Refresh" );
+        this.view = view;
+    }
+
+
+    public void run()
+    {
+        TreeViewer viewer = view.getViewer();
+
+        Object selection = ( ( TreeSelection ) viewer.getSelection() ).getFirstElement();
+
+        // Clearing the children of the selected node
+        if ( selection instanceof ConnectionWrapper )
+        {
+            ConnectionWrapper connectionWrapper = ( ConnectionWrapper ) selection;
+            connectionWrapper.clearChildren();
+        }
+        else if ( selection instanceof EntryWrapper )
+        {
+            EntryWrapper entryWrapper = ( EntryWrapper ) selection;
+            updateEntry( entryWrapper );
+            entryWrapper.clearChildren();
+        }
+
+        // Refreshing the Browser View
+        viewer.refresh( selection );
+        viewer.setExpandedState( selection, true );
+
+        // Refreshing the Attributes View
+        AttributesView attributesView = ( AttributesView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+            .getActivePage().findView( AttributesView.ID );
+        attributesView.refresh();
+    }
+
+
+    public void updateEntry( EntryWrapper entryWrapper )
+    {
+        try
+        {
+            Connection connection = entryWrapper.getConnection();
+
+            // Initialization of the DSML Engine and the DSML Response Parser
+            Dsmlv2Engine engine = new Dsmlv2Engine( connection.getHost(), connection.getPort(), connection.getUserDN()
+                .getNormName(), connection.getPassword() );
+            Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
+
+            String request = "<batchRequest>" + "	<searchRequest dn=\""
+                + entryWrapper.getEntry().getObjectName().getNormName() + "\""
+                + "			scope=\"baseObject\" derefAliases=\"neverDerefAliases\">"
+                + "		<filter><present name=\"objectclass\"></present></filter>" + "       <attributes>"
+                + "			<attribute name=\"*\"/>" + "			<attribute name=\"namingContexts\"/>"
+                + "			<attribute name=\"subSchemaSubEntry\"/>" + "			<attribute name=\"altServer\"/>"
+                + "			<attribute name=\"supportedExtension\"/>" + "			<attribute name=\"supportedControl\"/>"
+                + "			<attribute name=\"supportedSaslMechanism\"/>" + "			<attribute name=\"supportedLdapVersion\"/>"
+                + "       </attributes>" + "	</searchRequest>" + "</batchRequest>";
+
+            // Executing the request and sending the result to the Response Parser
+            parser.setInput( engine.processDSML( request ) );
+            parser.parse();
+
+            LdapResponse ldapResponse = parser.getBatchResponse().getCurrentResponse();
+
+            if ( ldapResponse instanceof ErrorResponse )
+            {
+                ErrorResponse errorResponse = ( ( ErrorResponse ) ldapResponse );
+
+                // Displaying an error
+                MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error !",
+                    "An error has ocurred.\n" + errorResponse.getMessage() );
+                return;
+            }
+            else if ( ldapResponse instanceof SearchResponse )
+            {
+
+                // Getting the Search Result Entry List containing our objects for the response
+                SearchResponse searchResponse = ( ( SearchResponse ) ldapResponse );
+
+                SearchResultEntry sre = searchResponse.getSearchResultEntryList().get( 0 );
+
+                entryWrapper.getEntry().setPartialAttributeList( sre.getPartialAttributeList() );
+                return;
+            }
+        }
+        catch ( Exception e )
+        {
+            // Displaying an error
+            MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error !",
+                "An error has ocurred.\n" + e.getMessage() );
+            return;
+        }
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/controller/actions/RenameAttributeAction.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,203 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.controller.actions;
+
+
+import org.apache.directory.ldapstudio.browser.view.views.AttributesView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+
+public class RenameAttributeAction extends Action
+{
+    private static final int COLUMN_TO_EDIT = 1;
+    private final AttributesView view;
+    private final Table table;
+    private final TableEditor tableEditor;
+    //	private final Text textActionHandler;
+    private Composite editorParent;
+    private Text editor;
+    private String originalText;
+
+
+    public RenameAttributeAction( AttributesView view, Table table, String text )
+    {
+        super( text );
+        this.view = view;
+        this.table = table;
+        tableEditor = new TableEditor( table );
+    }
+
+
+    public void run()
+    {
+        originalText = getTextToEdit();
+        if ( originalText == null )
+        {
+            return;
+        }
+        if ( editor == null )
+        {
+            createEditor();
+        }
+        showEditor( originalText );
+    }
+
+
+    private void createEditor()
+    {
+        // Create the parent so that a simple border
+        // can be painted around the text editor
+        editorParent = new Composite( table, SWT.NONE );
+        TableItem[] tableItems = table.getSelection();
+        tableEditor.horizontalAlignment = SWT.LEFT;
+        tableEditor.grabHorizontal = true;
+        tableEditor.setEditor( editorParent, tableItems[0], COLUMN_TO_EDIT );
+        editorParent.setVisible( false );
+        editorParent.addListener( SWT.Paint, new Listener()
+        {
+            public void handleEvent( Event e )
+            {
+                // Paint a simple border around the text editor
+                Point textSize = editor.getSize();
+                Point parentSize = editorParent.getSize();
+                int w = Math.min( textSize.x + 4, parentSize.x - 1 );
+                int h = parentSize.y - 1;
+                e.gc.drawRectangle( 0, 0, w, h );
+            }
+        } );
+
+        // Create the editor itself
+        editor = new Text( editorParent, SWT.NONE );
+        editorParent.setBackground( editor.getBackground() );
+        editor.addListener( SWT.Modify, new Listener()
+        {
+            public void handleEvent( Event e )
+            {
+                Point textSize = editor.computeSize( SWT.DEFAULT, SWT.DEFAULT );
+                textSize.x += textSize.y;
+
+                // Add extra space for new characters
+                Point parentSize = editorParent.getSize();
+                int w = Math.min( textSize.x, textSize.y );
+                int h = parentSize.y - 2;
+                editor.setBounds( 2, 1, w, h );
+                editorParent.redraw();
+            }
+        } );
+        editor.addListener( SWT.Traverse, new Listener()
+        {
+            public void handleEvent( Event event )
+            {
+                // Workaround for bug 20214 due to extra traverse events
+                switch ( event.detail )
+                {
+                    case SWT.TRAVERSE_ESCAPE:
+                        // Do nothing in this case
+                        disposeEditor();
+                        event.doit = true;
+                        event.detail = SWT.TRAVERSE_NONE;
+                        break;
+                    case SWT.TRAVERSE_RETURN:
+                        saveChangesAndDisposeEditor();
+                        event.doit = true;
+                        event.detail = SWT.TRAVERSE_NONE;
+                        break;
+                }
+            }
+        } );
+        editor.addFocusListener( new FocusAdapter()
+        {
+            public void focusLost( FocusEvent fe )
+            {
+                saveChangesAndDisposeEditor();
+            }
+        } );
+
+        // Add a handler to redirect global cut, copy, etc.
+        // textActionHandler.......
+    }
+
+
+    private void showEditor( String name )
+    {
+        editor.setText( name );
+        editorParent.setVisible( true );
+        Point textSize = editor.computeSize( SWT.DEFAULT, SWT.DEFAULT );
+        textSize.x += textSize.y;
+        // Add extra space for new characters
+        Point parentSize = editorParent.getSize();
+        int w = Math.min( textSize.x, parentSize.x - 4 );
+        int h = parentSize.y - 2;
+        editor.setBounds( 2, 1, w, h );
+        editorParent.redraw();
+        editor.selectAll();
+        editor.setFocus();
+    }
+
+
+    protected void saveChangesAndDisposeEditor()
+    {
+        String newText = editor.getText();
+        if ( !originalText.equals( newText ) )
+        {
+            saveChanges( newText );
+        }
+        disposeEditor();
+    }
+
+
+    protected void disposeEditor()
+    {
+        if ( editorParent != null )
+        {
+            editorParent.dispose();
+            editorParent = null;
+            editor = null;
+            tableEditor.setEditor( null, null, COLUMN_TO_EDIT );
+        }
+    }
+
+
+    protected String getTextToEdit()
+    {
+        TableItem item = view.getSelectedAttributeTableItem();
+        return item.getText( 1 );
+    }
+
+
+    protected void saveChanges( String newText )
+    {
+        TableItem item = view.getSelectedAttributeTableItem();
+        item.setText( 1, newText );
+        view.getViewer().refresh( item );
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/AbstractGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/AbstractGrammar.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/AbstractGrammar.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/AbstractGrammar.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,90 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+import java.util.HashMap;
+
+
+/**
+ * The abstract IGrammar which is the Mother of all the grammars. It contains
+ * the transitions table.
+ */
+public abstract class AbstractGrammar implements IGrammar
+{
+
+    /**
+     * Table of transitions. It's a two dimension array, the first dimension
+     * indice the states, the second dimension indices the Tag value, so it is
+     * 256 wide.
+     */
+    protected HashMap<Tag, GrammarTransition>[] transitions;
+
+    /** The grammar name */
+    protected String name;
+
+
+    public AbstractGrammar()
+    {
+
+    }
+
+
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * Return the grammar's name
+     * 
+     * @return The grammar name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * Set the grammar's name
+     * 
+     * @param name
+     *            DOCUMENT ME!
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    /**
+     * Get the transition associated with the state and tag
+     * 
+     * @param state
+     *            The current state
+     * @param tag
+     *            The current tag
+     * @return A valid transition if any, or null.
+     */
+    public GrammarTransition getTransition( int state, Tag tag )
+    {
+        return transitions[state].get( tag );
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,370 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * This class represents a LDAP Connection used in the preferences
+ */
+public class Connection implements Comparable<Connection>
+{
+    private String name;
+    private String host = "localhost";
+    private int port = 389;
+    private LdapDN baseDN;
+    private boolean anonymousBind = true;
+    private LdapDN userDN;
+    private boolean prefixUserDNWithBaseDN = false;
+    private String password;
+
+    /** The Listeners List */
+    private List<ConnectionListener> listeners;
+
+
+    /**
+     * Default Constructor 
+     */
+    public Connection()
+    {
+        listeners = new ArrayList<ConnectionListener>();
+    }
+
+
+    /**
+     * Constructor for a Connection
+     * @param name the Name of the connection
+     * @param host the Host
+     * @param port the Port
+     * @param baseDN the Base DN
+     * @param anonymousBind the value of the Anonymous Bind flag
+     * @param userDN the User DN
+     * @param prefixUserDNWithBaseDN the value of the prefixUserDNWithBaseDN flag
+     * @param password the Password
+     */
+    public Connection( String name, String host, int port, LdapDN baseDN, boolean anonymousBind, LdapDN userDN,
+        boolean prefixUserDNWithBaseDN, String password )
+    {
+        this.name = name;
+        this.host = host;
+        this.port = port;
+        this.baseDN = baseDN;
+        this.anonymousBind = anonymousBind;
+        this.userDN = userDN;
+        this.prefixUserDNWithBaseDN = prefixUserDNWithBaseDN;
+        this.password = password;
+    }
+
+
+    /**
+     * Get the Anonymous Bind Flag
+     * @return the anonymousBind
+     */
+    public boolean isAnonymousBind()
+    {
+        return anonymousBind;
+    }
+
+
+    /**
+     * Set the Anonymous Bind flag
+     * @param anonymousBind the anonymousBind to set
+     */
+    public void setAnonymousBind( boolean anonymousBind )
+    {
+        this.anonymousBind = anonymousBind;
+    }
+
+
+    /**
+     * Get the Base DN
+     * @return the BaseDN
+     */
+    public LdapDN getBaseDN()
+    {
+        return baseDN;
+    }
+
+
+    /**
+     * Set the BaseDN
+     * @param baseDN the BaseDN to set
+     */
+    public void setBaseDN( LdapDN baseDN )
+    {
+        this.baseDN = baseDN;
+    }
+
+
+    /**
+     * Get the Host
+     * @return the Host
+     */
+    public String getHost()
+    {
+        return host;
+    }
+
+
+    /**
+     * Set the Host
+     * @param host the Host to set
+     */
+    public void setHost( String host )
+    {
+        this.host = host;
+    }
+
+
+    /**
+     * Get the Name of the connection
+     * @return the Name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * Set the Name of the connection
+     * @param name the Name to set
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    /**
+     * Get the Password
+     * @return the Password
+     */
+    public String getPassword()
+    {
+        return password;
+    }
+
+
+    /**
+     * Set the Password
+     * @param password the Password to set
+     */
+    public void setPassword( String password )
+    {
+        this.password = password;
+    }
+
+
+    /**
+     * Get the Port
+     * @return the Port
+     */
+    public int getPort()
+    {
+        return port;
+    }
+
+
+    /**
+     * Set the Port
+     * @param port the Port to set
+     */
+    public void setPort( int port )
+    {
+        this.port = port;
+    }
+
+
+    /**
+     * Get the User DN
+     * @return the User DN
+     */
+    public LdapDN getUserDN()
+    {
+        return userDN;
+    }
+
+
+    /**
+     * Set the User DN
+     * @param userDN the User DN to set
+     */
+    public void setUserDN( LdapDN userDN )
+    {
+        this.userDN = userDN;
+    }
+
+
+    /**
+     * Get the prefixUserDNWithBaseDN Flag
+     * @return the prefixUserDNWithBaseDN Flag
+     */
+    public boolean isPrefixUserDNWithBaseDN()
+    {
+        return prefixUserDNWithBaseDN;
+    }
+
+
+    /**
+     * Sets prefixUserDNWithBaseDN Flag
+     * @param prefixUserDNWithBaseDN the prefixUserDNWithBaseDN Flag
+     */
+    public void setPrefixUserDNWithBaseDN( boolean prefixUserDNWithBaseDN )
+    {
+        this.prefixUserDNWithBaseDN = prefixUserDNWithBaseDN;
+    }
+
+
+    /**
+     * Converts a Connection into XML Format
+     * @return the corresponding XML String
+     */
+    public String toXml()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "<connection>" );
+        sb.append( "<name>" + ( ( "".equals( name ) ) ? "null" : name ) + "</name>" );
+        sb.append( "<host>" + ( ( "".equals( host ) ) ? "null" : host ) + "</host>" );
+        sb.append( "<port>" + ( ( "".equals( port ) ) ? "null" : port ) + "</port>" );
+        sb
+            .append( "<baseDN>" + ( ( "".equals( baseDN.getNormName() ) ) ? "null" : baseDN.getNormName() )
+                + "</baseDN>" );
+        sb.append( "<anonymousBind>" + anonymousBind + "</anonymousBind>" );
+        sb
+            .append( "<userDN>" + ( ( "".equals( userDN.getNormName() ) ) ? "null" : userDN.getNormName() )
+                + "</userDN>" );
+        sb.append( "<prefixUserDNWithBaseDN>" + prefixUserDNWithBaseDN + "</prefixUserDNWithBaseDN>" );
+        sb.append( "<password>" + ( ( "".equals( password ) ) ? "null" : password ) + "</password>" );
+        sb.append( "</connection>" );
+
+        return sb.toString();
+    }
+
+
+    /**
+     * Checks if the connection is valid to connect
+     * @return true if the connection is valid to connect
+     */
+    public boolean validToConnect()
+    {
+        // Host
+        if ( ( host == null ) || ( "".equals( host ) ) )
+        {
+            return false;
+        }
+        // Port
+        if ( ( port <= 0 ) || ( port > 65535 ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "[" );
+        sb.append( "name=\"" + name );
+        sb.append( "\" | " );
+        sb.append( "host=\"" + host );
+        sb.append( "\" | " );
+        sb.append( "port=\"" + port );
+        sb.append( "\" | " );
+        sb.append( "baseDN=\"" + baseDN.getNormName() );
+        sb.append( "\" | " );
+        sb.append( "anonymousBind=\"" + anonymousBind );
+        sb.append( "\" | " );
+        sb.append( "userDN=\"" + userDN.getNormName() );
+        sb.append( "\" | " );
+        sb.append( "prefixUserDNWithBaseDN=\"" + prefixUserDNWithBaseDN );
+        sb.append( "\" | " );
+        sb.append( "password=\"" + password );
+        sb.append( "\"]" );
+
+        return sb.toString();
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Comparable#compareTo(java.lang.Object)
+     */
+    public int compareTo( Connection o )
+    {
+        Connection otherWrapper = ( Connection ) o;
+        return getName().compareToIgnoreCase( otherWrapper.getName() );
+    }
+
+
+    /**
+     * Adds a listener for the Connections modifications
+     * @param listener the listener to add
+     * @return true (as per the general contract of Collection.add).
+     */
+    public boolean addListener( ConnectionListener listener )
+    {
+        return listeners.add( listener );
+    }
+
+
+    /**
+     * Removes a listener for the Connections modifications
+     * @param listener the listener to remove
+     * @return true if the list contained the specified element.
+     */
+    public boolean removeListener( ConnectionListener listener )
+    {
+        return listeners.remove( listener );
+    }
+
+
+    /**
+     * Notifies all the listeners that the Connection has changed
+     */
+    private void notifyChanged()
+    {
+        for ( ConnectionListener listener : listeners )
+        {
+            listener.connectionChanged( this );
+        }
+    }
+
+
+    /**
+     * Notifies all the listeners that the Connection has changed
+     */
+    public void notifyListeners()
+    {
+        notifyChanged();
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,543 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.util.HashMap;
+
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * This class represent the Connection Grammar used to parsed the XML 
+ * representation of a connection.
+ */
+public class ConnectionGrammar extends AbstractGrammar
+{
+    /** The initial state */
+    public static int GRAMMAR_START = 0;
+
+    /** The ending state */
+    public static int GRAMMAR_END = -1;
+
+    // States for Connections tag
+    public static int CONNECTIONS_LOOP = 1;
+
+    // States for Connection tag
+    public static int CONNECTION_START = 2;
+    public static int CONNECTION_END = 3;
+
+    // States for Name tag
+    public static int NAME_START = 4;
+    public static int NAME_END = 5;
+
+    // States for Host tag
+    public static int HOST_START = 6;
+    public static int HOST_END = 7;
+
+    // States for Port tag
+    public static int PORT_START = 8;
+    public static int PORT_END = 9;
+
+    // States for BaseDN tag
+    public static int BASEDN_START = 10;
+    public static int BASEDN_END = 11;
+
+    // States for AnonymousBind tag
+    public static int ANONYMOUSBIND_START = 12;
+    public static int ANONYMOUSBIND_END = 13;
+
+    // States for UserDN tag
+    public static int USERDN_START = 14;
+    public static int USERDN_END = 15;
+
+    // States for prefixUserDNWithBaseDN tag
+    public static int PREFIXUSERDNWITHBASEDN_START = 18;
+    public static int PREFIXUSERDNWITHBASEDN_END = 19;
+
+    // States for Password tag
+    public static int PASSWORD_START = 16;
+    public static int PASSWORD_END = 17;
+
+
+    /**
+     * Default constructor
+     */
+    @SuppressWarnings("unchecked")
+    public ConnectionGrammar()
+    {
+        // Create the transitions table
+        super.transitions = ( HashMap<Tag, GrammarTransition>[] ) Array.newInstance( HashMap.class, 20 );
+
+        // Initilization of the HashMaps
+        super.transitions[GRAMMAR_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[CONNECTIONS_LOOP] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[CONNECTION_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[CONNECTION_END] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[NAME_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[NAME_END] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[HOST_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[HOST_END] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[PORT_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[PORT_END] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[BASEDN_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[BASEDN_END] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[ANONYMOUSBIND_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[ANONYMOUSBIND_END] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[USERDN_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[USERDN_END] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[PREFIXUSERDNWITHBASEDN_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[PREFIXUSERDNWITHBASEDN_END] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[PASSWORD_START] = new HashMap<Tag, GrammarTransition>();
+        super.transitions[PASSWORD_END] = new HashMap<Tag, GrammarTransition>();
+
+        // State: [GRAMMAR_START] - Tag: <connections>
+        super.transitions[GRAMMAR_START].put( new Tag( "connections", Tag.START ), new GrammarTransition(
+            GRAMMAR_START, CONNECTIONS_LOOP, null ) );
+
+        // State: [CONNECTIONS_LOOP] - Tag: <connection>
+        super.transitions[CONNECTIONS_LOOP].put( new Tag( "connection", Tag.START ), new GrammarTransition(
+            CONNECTIONS_LOOP, CONNECTION_START, createConnection ) );
+
+        // State: [CONNECTION_START] - Tag: <name>
+        super.transitions[CONNECTION_START].put( new Tag( "name", Tag.START ), new GrammarTransition( CONNECTION_START,
+            NAME_START, addName ) );
+
+        // State: [NAME_START] - Tag: </name>
+        super.transitions[NAME_START].put( new Tag( "name", Tag.END ), new GrammarTransition( NAME_START, NAME_END,
+            null ) );
+
+        // State: [NAME_END] - Tag: <host>
+        super.transitions[NAME_END].put( new Tag( "host", Tag.START ), new GrammarTransition( NAME_END, HOST_START,
+            addHost ) );
+
+        // State: [HOST_START] - Tag: </host>
+        super.transitions[HOST_START].put( new Tag( "host", Tag.END ), new GrammarTransition( HOST_START, HOST_END,
+            null ) );
+
+        // State: [HOST_END] - Tag: <port>
+        super.transitions[HOST_END].put( new Tag( "port", Tag.START ), new GrammarTransition( HOST_END, PORT_START,
+            addPort ) );
+
+        // State: [PORT_START] - Tag: </port>
+        super.transitions[PORT_START].put( new Tag( "port", Tag.END ), new GrammarTransition( PORT_START, PORT_END,
+            null ) );
+
+        // State: [PORT_END] - Tag: <baseDN>
+        super.transitions[PORT_END].put( new Tag( "baseDN", Tag.START ), new GrammarTransition( PORT_END, BASEDN_START,
+            addBaseDN ) );
+
+        // State: [BASEDN_START] - Tag: </baseDN>
+        super.transitions[BASEDN_START].put( new Tag( "baseDN", Tag.END ), new GrammarTransition( BASEDN_START,
+            BASEDN_END, null ) );
+
+        // State: [BASEDN_END] - Tag: <anonymousBind>
+        super.transitions[BASEDN_END].put( new Tag( "anonymousBind", Tag.START ), new GrammarTransition( BASEDN_END,
+            ANONYMOUSBIND_START, addAnonymousBind ) );
+
+        // State: [ANONYMOUSBIND_START] - Tag: </anonymousBind>
+        super.transitions[ANONYMOUSBIND_START].put( new Tag( "anonymousBind", Tag.END ), new GrammarTransition(
+            ANONYMOUSBIND_START, ANONYMOUSBIND_END, null ) );
+
+        // State: [ANONYMOUSBIND_END] - Tag: <userDN>
+        super.transitions[ANONYMOUSBIND_END].put( new Tag( "userDN", Tag.START ), new GrammarTransition(
+            ANONYMOUSBIND_END, USERDN_START, addUserDN ) );
+
+        // State: [USERDN_START] - Tag: </userDN>
+        super.transitions[USERDN_START].put( new Tag( "userDN", Tag.END ), new GrammarTransition( USERDN_START,
+            USERDN_END, null ) );
+
+        // State: [USERDN_END] - Tag: <prefixUserDNWithBaseDN>
+        super.transitions[USERDN_END].put( new Tag( "prefixUserDNWithBaseDN", Tag.START ), new GrammarTransition(
+            USERDN_END, PREFIXUSERDNWITHBASEDN_START, addPrefixUserDNWithBaseDN ) );
+
+        // State: [PREFIXUSERDNWITHBASEDN_START] - Tag: </prefixUserDNWithBaseDN>
+        super.transitions[PREFIXUSERDNWITHBASEDN_START].put( new Tag( "prefixUserDNWithBaseDN", Tag.END ),
+            new GrammarTransition( PREFIXUSERDNWITHBASEDN_START, PREFIXUSERDNWITHBASEDN_END, null ) );
+
+        // State: [PREFIXUSERDNWITHBASEDN_END] - Tag: <password>
+        super.transitions[PREFIXUSERDNWITHBASEDN_END].put( new Tag( "password", Tag.START ), new GrammarTransition(
+            PREFIXUSERDNWITHBASEDN_END, PASSWORD_START, addPassword ) );
+
+        // State: [PASSWORD_START] - Tag: </password>
+        super.transitions[PASSWORD_START].put( new Tag( "password", Tag.END ), new GrammarTransition( PASSWORD_START,
+            PASSWORD_END, null ) );
+
+        // State: [PASSWORD_END] - Tag: </connection>
+        super.transitions[PASSWORD_END].put( new Tag( "connection", Tag.END ), new GrammarTransition( PASSWORD_END,
+            CONNECTIONS_LOOP, null ) );
+
+        // State: [CONNECTIONS_LOOP] - Tag: </connections>
+        super.transitions[CONNECTIONS_LOOP].put( new Tag( "connections", Tag.END ), new GrammarTransition(
+            CONNECTIONS_LOOP, GRAMMAR_END, null ) );
+    }
+
+    /**
+     * GrammarAction that create a Connection
+     */
+    private final GrammarAction createConnection = new GrammarAction( "Create Connection" )
+    {
+        public void action( ConnectionParserContainer container ) throws XmlPullParserException
+        {
+            container.addConnection( new Connection() );
+        }
+    };
+
+    /**
+     * GrammarAction that adds a Name to a Connection
+     */
+    private final GrammarAction addName = new GrammarAction( "Add Name" )
+    {
+        public void action( ConnectionParserContainer container ) throws XmlPullParserException
+        {
+            Connection connection = container.getCurrentConnection();
+
+            XmlPullParser xpp = container.getParser();
+
+            int eventType = 0;
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
+            }
+
+            if ( eventType != XmlPullParser.TEXT )
+            {
+                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+            }
+            else
+            {
+                if ( xpp.getText().equals( "null" ) )
+                {
+                    connection.setName( null );
+                }
+                else
+                {
+                    connection.setName( xpp.getText() );
+                }
+            }
+        }
+    };
+
+    /**
+     * GrammarAction that adds a Host to a Connection
+     */
+    private final GrammarAction addHost = new GrammarAction( "Add Host" )
+    {
+        public void action( ConnectionParserContainer container ) throws XmlPullParserException
+        {
+            Connection connection = container.getCurrentConnection();
+
+            XmlPullParser xpp = container.getParser();
+
+            int eventType = 0;
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
+            }
+
+            if ( eventType != XmlPullParser.TEXT )
+            {
+                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+            }
+            else
+            {
+                if ( xpp.getText().equals( "null" ) )
+                {
+                    connection.setHost( null );
+                }
+                else
+                {
+                    connection.setHost( xpp.getText() );
+                }
+            }
+        }
+    };
+
+    /**
+     * GrammarAction that adds a Port to a Connection
+     */
+    private final GrammarAction addPort = new GrammarAction( "Add Port" )
+    {
+        public void action( ConnectionParserContainer container ) throws XmlPullParserException
+        {
+            Connection connection = container.getCurrentConnection();
+
+            XmlPullParser xpp = container.getParser();
+
+            int eventType = 0;
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
+            }
+
+            if ( eventType != XmlPullParser.TEXT )
+            {
+                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+            }
+            else
+            {
+                if ( xpp.getText().equals( "0" ) )
+                {
+                    connection.setPort( 0 );
+                }
+                else
+                {
+                    connection.setPort( Integer.parseInt( xpp.getText() ) );
+                }
+            }
+        }
+    };
+
+    /**
+     * GrammarAction that adds a BaseDN to a Connection
+     */
+    private final GrammarAction addBaseDN = new GrammarAction( "Add BaseDN" )
+    {
+        public void action( ConnectionParserContainer container ) throws XmlPullParserException
+        {
+            Connection connection = container.getCurrentConnection();
+
+            XmlPullParser xpp = container.getParser();
+
+            int eventType = 0;
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
+            }
+
+            if ( eventType != XmlPullParser.TEXT )
+            {
+                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+            }
+            else
+            {
+                if ( xpp.getText().equals( "null" ) )
+                {
+                    connection.setBaseDN( LdapDN.EMPTY_LDAPDN );
+                }
+                else
+                {
+                    try
+                    {
+                        connection.setBaseDN( new LdapDN( xpp.getText() ) );
+                    }
+                    catch ( InvalidNameException e )
+                    {
+                        throw new XmlPullParserException( "An error has ocurred. " + e.getMessage(), xpp, null );
+                    }
+                }
+            }
+        }
+    };
+
+    /**
+     * GrammarAction that adds a AnonymousBind to a Connection
+     */
+    private final GrammarAction addAnonymousBind = new GrammarAction( "Add AnonymousBind" )
+    {
+        public void action( ConnectionParserContainer container ) throws XmlPullParserException
+        {
+            Connection connection = container.getCurrentConnection();
+
+            XmlPullParser xpp = container.getParser();
+
+            int eventType = 0;
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
+            }
+
+            if ( eventType != XmlPullParser.TEXT )
+            {
+                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+            }
+            else
+            {
+                if ( xpp.getText().equals( "false" ) )
+                {
+                    connection.setAnonymousBind( false );
+                }
+                else if ( xpp.getText().equals( "true" ) )
+                {
+                    connection.setAnonymousBind( true );
+                }
+                else
+                {
+                    throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+                }
+            }
+        }
+    };
+
+    /**
+     * GrammarAction that adds a UserDN to a Connection
+     */
+    private final GrammarAction addUserDN = new GrammarAction( "Add UserDN" )
+    {
+        public void action( ConnectionParserContainer container ) throws XmlPullParserException
+        {
+            Connection connection = container.getCurrentConnection();
+
+            XmlPullParser xpp = container.getParser();
+
+            int eventType = 0;
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
+            }
+
+            if ( eventType != XmlPullParser.TEXT )
+            {
+                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+            }
+            else
+            {
+                if ( xpp.getText().equals( "null" ) )
+                {
+                    connection.setUserDN( LdapDN.EMPTY_LDAPDN );
+                }
+                else
+                {
+                    try
+                    {
+                        connection.setUserDN( new LdapDN( xpp.getText() ) );
+                    }
+                    catch ( InvalidNameException e )
+                    {
+                        throw new XmlPullParserException( "An error has ocurred. " + e.getMessage(), xpp, null );
+                    }
+                }
+            }
+        }
+    };
+
+    /**
+     * GrammarAction that adds a prefixUserDNWithBaseDN to a Connection
+     */
+    private final GrammarAction addPrefixUserDNWithBaseDN = new GrammarAction( "Add prefixUserDNWithBaseDN" )
+    {
+        public void action( ConnectionParserContainer container ) throws XmlPullParserException
+        {
+            Connection connection = container.getCurrentConnection();
+
+            XmlPullParser xpp = container.getParser();
+
+            int eventType = 0;
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
+            }
+
+            if ( eventType != XmlPullParser.TEXT )
+            {
+                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+            }
+            else
+            {
+                if ( xpp.getText().equals( "false" ) )
+                {
+                    connection.setPrefixUserDNWithBaseDN( false );
+                }
+                else if ( xpp.getText().equals( "true" ) )
+                {
+                    connection.setPrefixUserDNWithBaseDN( true );
+                }
+                else
+                {
+                    throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+                }
+            }
+        }
+    };
+
+    /**
+     * GrammarAction that adds a Password to a Connection
+     */
+    private final GrammarAction addPassword = new GrammarAction( "Add Password" )
+    {
+        public void action( ConnectionParserContainer container ) throws XmlPullParserException
+        {
+            Connection connection = container.getCurrentConnection();
+
+            XmlPullParser xpp = container.getParser();
+
+            int eventType = 0;
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( e.getMessage(), xpp, null );
+            }
+
+            if ( eventType != XmlPullParser.TEXT )
+            {
+                throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+            }
+            else
+            {
+                if ( xpp.getText().equals( "null" ) )
+                {
+                    connection.setPassword( null );
+                }
+                else
+                {
+                    connection.setPassword( xpp.getText() );
+                }
+            }
+        }
+    };
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionListener.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionListener.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+/**
+ * Interface that has to be implemented by each Class that wants to listen on changes 
+ * on a Connection
+ */
+public interface ConnectionListener
+{
+    /**
+     * This method is called if the Connection have been modified
+     * @param connection the Connection
+     */
+    public void connectionChanged( Connection connection );
+
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParser.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParser.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParser.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,132 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.List;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+
+/**
+ * This class is a Connection Parser
+ */
+public class ConnectionParser
+{
+
+    private ConnectionParserContainer container;
+
+
+    /**
+     * Default constructor
+     * @throws XmlPullParserException
+     */
+    public ConnectionParser() throws XmlPullParserException
+    {
+        this.container = new ConnectionParserContainer();
+
+        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+
+        XmlPullParser xpp = factory.newPullParser();
+
+        container.setParser( xpp );
+    }
+
+
+    public void parse( String str ) throws XmlPullParserException
+    {
+        XmlPullParser xpp = container.getParser();
+
+        xpp.setInput( new StringReader( str ) );
+
+        container.setState( ConnectionGrammar.GRAMMAR_START );
+
+        int eventType = xpp.getEventType();
+        do
+        {
+            if ( eventType == XmlPullParser.START_DOCUMENT )
+            {
+                container.setState( ConnectionGrammar.GRAMMAR_START );
+            }
+            else if ( eventType == XmlPullParser.END_DOCUMENT )
+            {
+                container.setState( ConnectionGrammar.GRAMMAR_END );
+            }
+            else if ( eventType == XmlPullParser.START_TAG )
+            {
+                processTag( Tag.START );
+            }
+            else if ( eventType == XmlPullParser.END_TAG )
+            {
+                processTag( Tag.END );
+            }
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+                    null );
+            }
+        }
+        while ( container.getState() != ConnectionGrammar.GRAMMAR_END );
+    }
+
+
+    private void processTag( int tagType ) throws XmlPullParserException
+    {
+        XmlPullParser xpp = container.getParser();
+
+        String tagName = xpp.getName().toLowerCase();
+
+        GrammarTransition transition = container.getTransition( container.getState(), new Tag( tagName, tagType ) );
+
+        if ( transition != null )
+        {
+            container.setState( transition.getNextState() );
+
+            if ( transition.hasAction() )
+            {
+                transition.getAction().action( container );
+            }
+        }
+        else
+        {
+            throw new XmlPullParserException( "The tag " + new Tag( tagName, tagType )
+                + " can't be found at this position", xpp, null );
+        }
+    }
+
+
+    /**
+     * Gets a List of the parsed Connections
+     * @return a List of the parsed Connections
+     */
+    public List<Connection> getConnections()
+    {
+        return container.getConnections();
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParserContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParserContainer.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParserContainer.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParserContainer.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,176 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xmlpull.v1.XmlPullParser;
+
+
+/**
+ * This container is used for parsing connections
+ */
+/**
+ * @author pajbam
+ *
+ */
+public class ConnectionParserContainer
+{
+
+    /** The current state of the decoding */
+    private int state;
+
+    /** The current transition */
+    private int transition;
+
+    /** The pool parser */
+    private XmlPullParser parser;
+
+    /** The connections */
+    private List<Connection> connections;
+
+    private ConnectionGrammar grammar;
+
+
+    public ConnectionParserContainer()
+    {
+        grammar = new ConnectionGrammar();
+        connections = new ArrayList<Connection>();
+    }
+
+
+    /**
+     * Get the parser
+     * 
+     * @return Returns the parser
+     */
+    public XmlPullParser getParser()
+    {
+        return parser;
+    }
+
+
+    /**
+     * Set the parser
+     * 
+     * @param state
+     *            The parser
+     */
+    public void setParser( XmlPullParser parser )
+    {
+        this.parser = parser;
+    }
+
+
+    /**
+     * Get the current grammar state
+     * 
+     * @return Returns the current grammar state
+     */
+    public int getState()
+    {
+        return state;
+    }
+
+
+    /**
+     * Set the new current state
+     * 
+     * @param state
+     *            The new state
+     */
+    public void setState( int state )
+    {
+        this.state = state;
+    }
+
+
+    /**
+     * Get the transition
+     * 
+     * @return Returns the transition from the previous state to the new state
+     */
+    public int getTransition()
+    {
+        return transition;
+    }
+
+
+    /**
+     * Update the transition from a state to another
+     * 
+     * @param transition
+     *            The transition to set
+     */
+    public void setTransition( int transition )
+    {
+        this.transition = transition;
+    }
+
+
+    /**
+     * Get the connections
+     * 
+     * @return Returns the parsed connections
+     */
+    public List<Connection> getConnections()
+    {
+        return this.connections;
+    }
+
+
+    /**
+     * Get the transition associated with the state and tag
+     * 
+     * @param state
+     *            The current state
+     * @param tag
+     *            The current tag
+     * @return A valid transition if any, or null.
+     */
+    public GrammarTransition getTransition( int state, Tag tag )
+    {
+        return grammar.getTransition( state, tag );
+    }
+
+
+    /**
+     * Returns the current Connection
+     * @return A Connection
+     */
+    public Connection getCurrentConnection()
+    {
+        return connections.get( connections.size() - 1 );
+    }
+
+
+    /**
+     * Adds a connection to the Connection List
+     * @param connection The Connection to add
+     * @return true (as per the general contract of the Collection.add method).
+     */
+    public boolean addConnection( Connection connection )
+    {
+        return connections.add( connection );
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connections.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connections.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connections.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connections.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,308 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.Activator;
+import org.apache.directory.ldapstudio.browser.model.ConnectionsEvent.ConnectionsEventType;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.PlatformUI;
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * This class represent the Connections class used to store all the connections
+ */
+public class Connections implements ConnectionListener
+{
+    /**
+     * The Preferences identifier for storing the Connections
+     */
+    private static final String CONNECTIONS_PREFS = "connections_prefs";
+
+    /**
+     * The Connections List
+     */
+    private List<Connection> connections;
+
+    /**
+     * The Listeners List
+     */
+    private List<ConnectionsListener> listeners;
+
+    /**
+     * The instance (used to access Connections as a Singleton)
+     */
+    private static Connections instance;
+
+    // Static thread-safe singleton initializer
+    static
+    {
+        instance = new Connections();
+    }
+
+
+    /**
+     * Private constructor
+     */
+    private Connections()
+    {
+        connections = new ArrayList<Connection>();
+        listeners = new ArrayList<ConnectionsListener>();
+
+        loadConnections();
+    }
+
+
+    /**
+     * Loads the Connections
+     */
+    private void loadConnections()
+    {
+        Preferences store = Activator.getDefault().getPluginPreferences();
+
+        String connectionsAsXml = store.getString( CONNECTIONS_PREFS );
+
+        try
+        {
+            ConnectionParser parser = new ConnectionParser();
+
+            parser.parse( connectionsAsXml );
+
+            connections = parser.getConnections();
+
+            // Registering this class as a listener for modification on any Connection.
+            for ( Connection connection : connections )
+            {
+                connection.addListener( this );
+            }
+        }
+        catch ( XmlPullParserException e )
+        {
+            MessageDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
+                "An error ocurred while recovering the connections." );
+        }
+    }
+
+
+    /**
+     * Stores the Connections
+     */
+    private void storeConnections()
+    {
+        Preferences store = Activator.getDefault().getPluginPreferences();
+
+        StringBuffer sb = new StringBuffer();
+
+        // Constructing the XML String representing all the Connections
+        sb.append( "<connections>" );
+        for ( int i = 0; i < connections.size(); i++ )
+        {
+            sb.append( connections.get( i ).toXml() );
+        }
+        sb.append( "</connections>" );
+
+        store.setValue( CONNECTIONS_PREFS, sb.toString() );
+    }
+
+
+    /**
+     * Use this method to get the singleton instance of the controller
+     * @return
+     */
+    public static Connections getInstance()
+    {
+        return instance;
+    }
+
+
+    /**
+     * Adds a Connection
+     * @param connection the Connection to add
+     * @return true (as per the general contract of Collection.add).
+     */
+    public boolean addConnection( Connection connection )
+    {
+        if ( connection != null )
+        {
+            boolean bool = connections.add( connection );
+
+            connection.addListener( this );
+
+            // Notifying the listeners
+            notifyChanged( new ConnectionsEvent( ConnectionsEventType.ADD, connection ) );
+
+            // Saving the Connections
+            storeConnections();
+
+            return bool;
+        }
+        return false;
+    }
+
+
+    /**
+     * Removes a Connection
+     * @param connection the Connection to remove
+     * @return true if the list contained the specified element.
+     */
+    public boolean removeConnection( Connection connection )
+    {
+        if ( connection != null )
+        {
+            boolean bool = connections.remove( connection );
+
+            connection.removeListener( this );
+
+            // Notifying the listeners
+            notifyChanged( new ConnectionsEvent( ConnectionsEventType.REMOVE, connection ) );
+
+            // Saving the Connections
+            storeConnections();
+
+            return bool;
+        }
+        return false;
+    }
+
+
+    /**
+     * Notifies all the listeners that the Connections have changed
+     * @param event the associated event
+     */
+    private void notifyChanged( ConnectionsEvent event )
+    {
+        for ( ConnectionsListener listener : listeners )
+        {
+            listener.connectionsChanged( this, event );
+        }
+    }
+
+
+    /**
+     * Return the Connection at the specified position in the list
+     * @param index index of element to return
+     * @return the element at the specified position in this list
+     * @throws IndexOutOfBoundsException if the index is out of range 
+     * (index < 0 || index >= size())
+     */
+    public Connection getConnection( int index ) throws IndexOutOfBoundsException
+    {
+        return connections.get( index );
+    }
+
+
+    /**
+     * Returns the number of elements in this list. If this list contains 
+     * more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE
+     * @return the number of elements in this list
+     */
+    public int size()
+    {
+        return connections.size();
+    }
+
+
+    /**
+     * Adds a listener for the Connections modifications
+     * @param listener the listener to add
+     * @return true (as per the general contract of Collection.add).
+     */
+    public boolean addListener( ConnectionsListener listener )
+    {
+        return listeners.add( listener );
+    }
+
+
+    /**
+     * Removes a listener for the Connections modifications
+     * @param listener the listener to remove
+     * @return true if the list contained the specified element.
+     */
+    public boolean removeListener( ConnectionsListener listener )
+    {
+        return listeners.remove( listener );
+    }
+
+
+    /**
+     * Sorts the connections into ascending order, according to the 
+     * natural ordering.
+     */
+    public void sort()
+    {
+        Collections.sort( connections );
+    }
+
+
+    /**
+     * Verifies if the name is already used by a connection
+     * @param name the name
+     * @param excludeName a name to exclude from the verification 
+     * @return true if the name is available, false if a connection
+     * 				already has a same name
+     */
+    public boolean isConnectionNameAvailable( String name, String excludeName )
+    {
+        for ( int i = 0; i < size(); i++ )
+        {
+            if ( name.equals( getConnection( i ).getName() ) )
+            {
+                if ( !name.equals( excludeName ) )
+                {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+
+    /**
+     * Verifies if the name is already used by a connection
+     * @param name the name
+     * @return true if the name is available, false if a connection
+     * 				already has a same name
+     */
+    public boolean isConnectionNameAvailable( String name )
+    {
+        return isConnectionNameAvailable( name, null );
+    }
+
+
+    /**
+     * This method is called if the Connection have been modified
+     * @param connection the Connection
+     */
+    public void connectionChanged( Connection connection )
+    {
+        // Notifying the listeners
+        notifyChanged( new ConnectionsEvent( ConnectionsEventType.UPDATE, connection ) );
+
+        // Saving the Connections
+        storeConnections();
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsEvent.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsEvent.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,68 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+/**
+ * This class is used to represent the events related to 
+ * modifications on the Connections Class, such as :
+ *    - "Add",
+ *    - "Update" or 
+ *    - "Remove"
+ * of a Connection
+ */
+public class ConnectionsEvent
+{
+    /**
+     * This enum represents the different types of a ConnectionEvent
+     */
+    public enum ConnectionsEventType
+    {
+        ADD, UPDATE, REMOVE
+    };
+
+    private ConnectionsEventType type;
+    private Connection connection;
+
+
+    /**
+     * Default constructor
+     * @param type the type of the event
+     * @param connection the connection associated with the event
+     */
+    public ConnectionsEvent( ConnectionsEventType type, Connection connection )
+    {
+        this.type = type;
+        this.connection = connection;
+    }
+
+
+    public Connection getConnection()
+    {
+        return connection;
+    }
+
+
+    public ConnectionsEventType getType()
+    {
+        return type;
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsListener.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionsListener.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+/**
+ * Interface that has to be implemented by each Class that wants to listen on changes 
+ * on Connections
+ */
+public interface ConnectionsListener
+{
+    /**
+     * This method is called if the Connections have changed
+     * @param connections the Connections
+     * @param event the event associated
+     */
+    public void connectionsChanged( Connections connections, ConnectionsEvent event );
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarAction.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarAction.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+/**
+ * A top level grammar class that store meta informations about the actions.
+ * Those informations are not mandatory, but they can be usefull for debugging.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class GrammarAction implements IAction
+{
+    // ~ Instance fields
+    // ----------------------------------------------------------------------------
+
+    /** The action's name */
+    protected String name;
+
+
+    // ~ Constructors
+    // -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new GrammarAction object.
+     * 
+     * @param name
+     *            The name of the create daction
+     */
+    public GrammarAction( String name )
+    {
+        this.name = name;
+    }
+
+
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * Print the action's name
+     * 
+     * @return The action's name
+     */
+    public String toString()
+    {
+        return name;
+    }
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarTransition.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarTransition.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarTransition.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/GrammarTransition.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,97 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+/**
+ * Define a transition between two states of a grammar. It stores the next
+ * state, and the action to execute while transiting.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class GrammarTransition
+{
+    // ~ Instance fields
+    // ----------------------------------------------------------------------------
+
+    /** The next state in the grammar */
+    private int nextState;
+
+    /** The action associated to the transition */
+    private GrammarAction action;
+
+    /** The current state */
+    private int currentState;
+
+
+    // ~ Constructors
+    // -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new GrammarTransition object.
+     * 
+     * @param currentState
+     *            The current transition
+     * @param nextState
+     *            The target state
+     * @param action
+     *            The action to execute. It could be null.
+     */
+    public GrammarTransition( int currentState, int nextState, GrammarAction action )
+    {
+        this.currentState = currentState;
+        this.nextState = nextState;
+        this.action = action;
+    }
+
+
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * @return Returns the target state.
+     */
+    public int getNextState()
+    {
+        return nextState;
+    }
+
+
+    /**
+     * Tells if the transition has an associated action.
+     * 
+     * @return <code>true</code> if an action has been asociated to the
+     *         transition
+     */
+    public boolean hasAction()
+    {
+        return action != null;
+    }
+
+
+    /**
+     * @return Returns the action associated with the transition
+     */
+    public GrammarAction getAction()
+    {
+        return action;
+    }
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/IAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/IAction.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/IAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/IAction.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,47 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * IAction interface just contains the method 'action' which must be implemented
+ * in all the implementong classes.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface IAction
+{
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * The action to be executed.
+     * 
+     * @param container
+     *            The container which stores the current data
+     * @throws DecoderException
+     *             Thrown if something went wrong.
+     */
+    public void action( ConnectionParserContainer container ) throws XmlPullParserException;
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/IGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/IGrammar.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/IGrammar.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/IGrammar.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,57 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+/**
+ * The interface which expose common behavior of a Gramar implementer.
+ */
+public interface IGrammar
+{
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * This method, when called, execute an action on the current data stored in
+     * the container.
+     * 
+     * @param asn1Container
+     *            Store the data being processed.
+     * @throws DecoderException
+     *             Thrown when an unrecoverable error occurs.
+     */
+    //void executeAction( ConnectionParserContainer container ) throws Exception;
+    /**
+     * Get the grammar name
+     * 
+     * @return Return the grammar's name
+     */
+    String getName();
+
+
+    /**
+     * Set the grammar's name
+     * 
+     * @param name
+     *            The grammar name
+     */
+    void setName( String name );
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Tag.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Tag.java?view=auto&rev=475813
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Tag.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser/src/main/java/org/apache/directory/ldapstudio/browser/model/Tag.java Thu Nov 16 08:56:34 2006
@@ -0,0 +1,102 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.browser.model;
+
+
+public class Tag
+{
+
+    private String name;
+    private int type;
+
+    public static int START = 0;
+    public static int END = 1;
+
+
+    public Tag( String name, int type )
+    {
+        setName( name );
+        setType( type );
+    }
+
+
+    public String getName()
+    {
+        return name;
+    }
+
+
+    public void setName( String name )
+    {
+        this.name = name.toLowerCase();
+    }
+
+
+    public int getType()
+    {
+        return type;
+    }
+
+
+    public void setType( int type )
+    {
+        this.type = type;
+    }
+
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj instanceof Tag )
+        {
+            Tag tag = ( Tag ) obj;
+            return ( ( this.name.equals( tag.getName() ) ) && ( this.type == tag.getType() ) );
+
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    @Override
+    public int hashCode()
+    {
+
+        return name.hashCode() + type << 24;
+    }
+
+
+    @Override
+    public String toString()
+    {
+        if ( name != null )
+        {
+            return "<" + ( ( type == Tag.END ) ? "/" : "" ) + name + ">";
+        }
+        else
+        {
+            return "Unknown tag";
+        }
+    }
+
+}