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/12/18 18:15:08 UTC
svn commit: r488345 [3/12] - in /directory/sandbox/pamarcelot/ldapstudio:
ldapstudio-browser-core/ ldapstudio-browser-core/META-INF/
ldapstudio-browser-core/about_files/ ldapstudio-browser-core/lib/
ldapstudio-browser-core/src/ ldapstudio-browser-core/...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryModificationEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryModificationEvent.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryModificationEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryModificationEvent.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+
+public abstract class EntryModificationEvent
+{
+
+ protected IConnection originalConnection;
+
+ protected IEntry modifiedEntry;
+
+ protected ModelModifier source;
+
+
+ public EntryModificationEvent( IConnection connection, IEntry modifiedEntry, ModelModifier source )
+ {
+ this.originalConnection = connection;
+ this.modifiedEntry = modifiedEntry;
+ this.source = source;
+ }
+
+
+ public ModelModifier getSource()
+ {
+ return this.source;
+ }
+
+
+ public IConnection getOriginalConnection()
+ {
+ return this.originalConnection;
+ }
+
+
+ public IEntry getModifiedEntry()
+ {
+ return this.modifiedEntry;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryMovedEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryMovedEvent.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryMovedEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryMovedEvent.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,64 @@
+/*
+ * 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.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+
+public class EntryMovedEvent extends EntryModificationEvent
+{
+
+ private IEntry oldEntry;
+
+ private IEntry newEntry;
+
+
+ public EntryMovedEvent( IEntry oldEntry, IEntry newEntry, ModelModifier source )
+ {
+ super( newEntry.getConnection(), newEntry.getParententry(), source );
+ this.oldEntry = oldEntry;
+ this.newEntry = newEntry;
+ }
+
+
+ public IEntry getNewEntry()
+ {
+ return newEntry;
+ }
+
+
+ public IEntry getOldEntry()
+ {
+ return oldEntry;
+ }
+
+
+ public String toString()
+ {
+ return BrowserCoreMessages.bind( BrowserCoreMessages.event__moved_oldrdn_from_oldparent_to_newparent,
+ new String[]
+ { getOldEntry().getDn().getRdn().toString(), getOldEntry().getParententry().getDn().toString(),
+ getNewEntry().getParententry().getDn().toString() } );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryRenamedEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryRenamedEvent.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryRenamedEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryRenamedEvent.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,62 @@
+/*
+ * 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.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+
+
+public class EntryRenamedEvent extends EntryModificationEvent
+{
+
+ private IEntry oldEntry;
+
+ private IEntry newEntry;
+
+
+ public EntryRenamedEvent( IEntry oldEntry, IEntry newEntry, ModelModifier source )
+ {
+ super( newEntry.getConnection(), newEntry.getParententry(), source );
+ this.oldEntry = oldEntry;
+ this.newEntry = newEntry;
+ }
+
+
+ public IEntry getNewEntry()
+ {
+ return newEntry;
+ }
+
+
+ public IEntry getOldEntry()
+ {
+ return oldEntry;
+ }
+
+
+ public String toString()
+ {
+ return BrowserCoreMessages.bind( BrowserCoreMessages.event__renamed_olddn_to_newdn, new String[]
+ { getOldEntry().getDn().toString(), getNewEntry().getDn().toString() } );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryUpdateListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryUpdateListener.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryUpdateListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EntryUpdateListener.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,29 @@
+/*
+ * 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.core.events;
+
+
+public interface EntryUpdateListener extends EventListener
+{
+
+ public void entryUpdated( EntryModificationEvent event );
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventDispatcher.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventDispatcher.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventDispatcher.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventDispatcher.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,38 @@
+/*
+ * 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.core.events;
+
+
+public interface EventDispatcher
+{
+
+ public void dispatchEvent( Object source, EventListener target, EventRunnable runnable );
+
+
+ public void resumeEventFireingInCurrentThread();
+
+
+ public void suspendEventFireingInCurrentThread();
+
+
+ public boolean isEventFireingSuspendInCurrentThread();
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventListener.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventListener.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,27 @@
+/*
+ * 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.core.events;
+
+
+public interface EventListener
+{
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventPerformanceMeter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventPerformanceMeter.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventPerformanceMeter.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventPerformanceMeter.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,75 @@
+/*
+ * 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.core.events;
+
+
+public class EventPerformanceMeter implements ConnectionUpdateListener, EntryUpdateListener, SearchUpdateListener,
+ BookmarkUpdateListener
+{
+
+ public EventPerformanceMeter()
+ {
+
+ }
+
+
+ public void start()
+ {
+ EventRegistry.addConnectionUpdateListener( this );
+ EventRegistry.addEntryUpdateListener( this );
+ EventRegistry.addSearchUpdateListener( this );
+ EventRegistry.addBookmarkUpdateListener( this );
+ }
+
+
+ public void stop()
+ {
+ EventRegistry.removeConnectionUpdateListener( this );
+ EventRegistry.removeEntryUpdateListener( this );
+ EventRegistry.removeSearchUpdateListener( this );
+ EventRegistry.removeBookmarkUpdateListener( this );
+ }
+
+
+ public void connectionUpdated( ConnectionUpdateEvent event )
+ {
+ System.out.println( event.getClass().getName() + ": " + event );
+ }
+
+
+ public void entryUpdated( EntryModificationEvent event )
+ {
+ System.out.println( event.getClass().getName() + ": " + event );
+ }
+
+
+ public void searchUpdated( SearchUpdateEvent event )
+ {
+ System.out.println( event.getClass().getName() + ": " + event );
+ }
+
+
+ public void bookmarkUpdated( BookmarkUpdateEvent event )
+ {
+ System.out.println( event.getClass().getName() + ": " + event );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventRegistry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventRegistry.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventRegistry.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventRegistry.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,350 @@
+/*
+ * 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.core.events;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.LdapSyntaxDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleUseDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription;
+
+
+public class EventRegistry
+{
+
+ private static EventDispatcher eventDispatcher;
+
+
+ public static void init( EventDispatcher eventDispatcher )
+ {
+ EventRegistry.eventDispatcher = eventDispatcher;
+ }
+
+
+ public static void resumeEventFireingInCurrentThread()
+ {
+ eventDispatcher.resumeEventFireingInCurrentThread();
+ }
+
+
+ public static void suspendEventFireingInCurrentThread()
+ {
+ eventDispatcher.suspendEventFireingInCurrentThread();
+ }
+
+ private static List searchUpdateListenerList = new ArrayList();
+
+
+ public static void addSearchUpdateListener( SearchUpdateListener listener )
+ {
+ if ( !searchUpdateListenerList.contains( listener ) )
+ searchUpdateListenerList.add( listener );
+ }
+
+
+ public static void removeSearchUpdateListener( SearchUpdateListener listener )
+ {
+ if ( searchUpdateListenerList.contains( listener ) )
+ searchUpdateListenerList.remove( listener );
+ }
+
+
+ public static void fireSearchUpdated( final SearchUpdateEvent searchUpdateEvent, final Object source )
+ {
+ for ( int i = 0; i < searchUpdateListenerList.size(); i++ )
+ {
+ final SearchUpdateListener listener = ( SearchUpdateListener ) searchUpdateListenerList.get( i );
+ EventRunnable runnable = new EventRunnable()
+ {
+ public Object getEventObject()
+ {
+ return searchUpdateEvent.getSearch();
+ }
+
+
+ public void run()
+ {
+ listener.searchUpdated( searchUpdateEvent );
+ }
+ };
+ eventDispatcher.dispatchEvent( source, listener, runnable );
+ }
+ }
+
+ private static List bookmarkUpdateListenerList = new ArrayList();
+
+
+ public static void addBookmarkUpdateListener( BookmarkUpdateListener listener )
+ {
+ if ( !bookmarkUpdateListenerList.contains( listener ) )
+ bookmarkUpdateListenerList.add( listener );
+ }
+
+
+ public static void removeBookmarkUpdateListener( BookmarkUpdateListener listener )
+ {
+ if ( bookmarkUpdateListenerList.contains( listener ) )
+ bookmarkUpdateListenerList.remove( listener );
+ }
+
+
+ public static void fireBookmarkUpdated( final BookmarkUpdateEvent bookmarkUpdateEvent, final Object source )
+ {
+ for ( int i = 0; i < bookmarkUpdateListenerList.size(); i++ )
+ {
+ final BookmarkUpdateListener listener = ( BookmarkUpdateListener ) bookmarkUpdateListenerList.get( i );
+ EventRunnable runnable = new EventRunnable()
+ {
+ public Object getEventObject()
+ {
+ return bookmarkUpdateEvent.getBookmark();
+ }
+
+
+ public void run()
+ {
+ listener.bookmarkUpdated( bookmarkUpdateEvent );
+ }
+ };
+ eventDispatcher.dispatchEvent( source, listener, runnable );
+ }
+ }
+
+ private static List connectionUpdateListenerList = new ArrayList();
+
+
+ public static void addConnectionUpdateListener( ConnectionUpdateListener listener )
+ {
+ if ( !connectionUpdateListenerList.contains( listener ) )
+ connectionUpdateListenerList.add( listener );
+ }
+
+
+ public static void removeConnectionUpdateListener( ConnectionUpdateListener listener )
+ {
+ if ( connectionUpdateListenerList.contains( listener ) )
+ connectionUpdateListenerList.remove( listener );
+ }
+
+
+ public static void fireConnectionUpdated( final ConnectionUpdateEvent connectionUpdateEvent, final Object source )
+ {
+ for ( int i = 0; i < connectionUpdateListenerList.size(); i++ )
+ {
+ final ConnectionUpdateListener listener = ( ConnectionUpdateListener ) connectionUpdateListenerList.get( i );
+ EventRunnable runnable = new EventRunnable()
+ {
+ public Object getEventObject()
+ {
+ return connectionUpdateEvent.getConnection();
+ }
+
+
+ public void run()
+ {
+ listener.connectionUpdated( connectionUpdateEvent );
+ }
+ };
+ eventDispatcher.dispatchEvent( source, listener, runnable );
+ }
+ }
+
+ private static List entryUpdateListenerList = new ArrayList();
+
+
+ public static void addEntryUpdateListener( EntryUpdateListener listener )
+ {
+ if ( !entryUpdateListenerList.contains( listener ) )
+ entryUpdateListenerList.add( listener );
+ }
+
+
+ public static void removeEntryUpdateListener( EntryUpdateListener listener )
+ {
+ if ( entryUpdateListenerList.contains( listener ) )
+ entryUpdateListenerList.remove( listener );
+ }
+
+
+ public static void fireEntryUpdated( final EntryModificationEvent event, final Object source )
+ {
+ for ( int i = 0; i < entryUpdateListenerList.size(); i++ )
+ {
+ final EntryUpdateListener listener = ( EntryUpdateListener ) entryUpdateListenerList.get( i );
+ EventRunnable runnable = new EventRunnable()
+ {
+ public Object getEventObject()
+ {
+ return event;
+ }
+
+
+ public void run()
+ {
+ listener.entryUpdated( event );
+ }
+ };
+ eventDispatcher.dispatchEvent( source, listener, runnable );
+ }
+ }
+
+ private static List schemaElementSelectionListenerList = new ArrayList();
+
+
+ public static void addSchemaElementSelectionListener( SchemaElementSelectionListener listener )
+ {
+ if ( !schemaElementSelectionListenerList.contains( listener ) )
+ schemaElementSelectionListenerList.add( listener );
+ }
+
+
+ public static void removeSchemaElementSelectionListener( SchemaElementSelectionListener listener )
+ {
+ if ( schemaElementSelectionListenerList.contains( listener ) )
+ schemaElementSelectionListenerList.remove( listener );
+ }
+
+
+ public static void fireObjectClassDescriptionSelected( final ObjectClassDescription ocd, final Object source )
+ {
+ for ( int i = 0; i < schemaElementSelectionListenerList.size(); i++ )
+ {
+ final SchemaElementSelectionListener listener = ( SchemaElementSelectionListener ) schemaElementSelectionListenerList
+ .get( i );
+ EventRunnable runnable = new EventRunnable()
+ {
+ public Object getEventObject()
+ {
+ return ocd;
+ }
+
+
+ public void run()
+ {
+ listener.objectClassDescriptionSelected( ocd );
+ }
+ };
+ eventDispatcher.dispatchEvent( source, listener, runnable );
+ }
+ }
+
+
+ public static void fireAttributeTypeDescriptionSelected( final AttributeTypeDescription atd, final Object source )
+ {
+ for ( int i = 0; i < schemaElementSelectionListenerList.size(); i++ )
+ {
+ final SchemaElementSelectionListener listener = ( SchemaElementSelectionListener ) schemaElementSelectionListenerList
+ .get( i );
+ EventRunnable runnable = new EventRunnable()
+ {
+ public Object getEventObject()
+ {
+ return atd;
+ }
+
+
+ public void run()
+ {
+ listener.attributeTypeDescriptionSelected( atd );
+ }
+ };
+ eventDispatcher.dispatchEvent( source, listener, runnable );
+ }
+ }
+
+
+ public static void fireMatchingRuleDescriptionSelected( final MatchingRuleDescription mrd, final Object source )
+ {
+ for ( int i = 0; i < schemaElementSelectionListenerList.size(); i++ )
+ {
+ final SchemaElementSelectionListener listener = ( SchemaElementSelectionListener ) schemaElementSelectionListenerList
+ .get( i );
+ EventRunnable runnable = new EventRunnable()
+ {
+ public Object getEventObject()
+ {
+ return mrd;
+ }
+
+
+ public void run()
+ {
+ listener.matchingRuleDescriptionSelected( mrd );
+ }
+ };
+ eventDispatcher.dispatchEvent( source, listener, runnable );
+ }
+ }
+
+
+ public static void fireLdapSyntaxDescriptionSelected( final LdapSyntaxDescription lsd, final Object source )
+ {
+ for ( int i = 0; i < schemaElementSelectionListenerList.size(); i++ )
+ {
+ final SchemaElementSelectionListener listener = ( SchemaElementSelectionListener ) schemaElementSelectionListenerList
+ .get( i );
+ EventRunnable runnable = new EventRunnable()
+ {
+ public Object getEventObject()
+ {
+ return lsd;
+ }
+
+
+ public void run()
+ {
+ listener.ldapSyntacDescriptionSelected( lsd );
+ }
+ };
+ eventDispatcher.dispatchEvent( source, listener, runnable );
+ }
+ }
+
+
+ public static void fireMatchingRuleUseDescriptionSelected( final MatchingRuleUseDescription mrud,
+ final Object source )
+ {
+ for ( int i = 0; i < schemaElementSelectionListenerList.size(); i++ )
+ {
+ final SchemaElementSelectionListener listener = ( SchemaElementSelectionListener ) schemaElementSelectionListenerList
+ .get( i );
+ EventRunnable runnable = new EventRunnable()
+ {
+ public Object getEventObject()
+ {
+ return mrud;
+ }
+
+
+ public void run()
+ {
+ listener.matchingRuleUseDescriptionSelected( mrud );
+ }
+ };
+ eventDispatcher.dispatchEvent( source, listener, runnable );
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventRunnable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventRunnable.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventRunnable.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/EventRunnable.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,29 @@
+/*
+ * 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.core.events;
+
+
+public interface EventRunnable extends Runnable
+{
+
+ public Object getEventObject();
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ModelModifier.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ModelModifier.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ModelModifier.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ModelModifier.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,27 @@
+/*
+ * 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.core.events;
+
+
+public interface ModelModifier
+{
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SchemaElementSelectionListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SchemaElementSelectionListener.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SchemaElementSelectionListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SchemaElementSelectionListener.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,48 @@
+/*
+ * 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.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.LdapSyntaxDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.MatchingRuleUseDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription;
+
+
+public interface SchemaElementSelectionListener extends EventListener
+{
+
+ public void attributeTypeDescriptionSelected( AttributeTypeDescription atd );
+
+
+ public void objectClassDescriptionSelected( ObjectClassDescription ocd );
+
+
+ public void matchingRuleDescriptionSelected( MatchingRuleDescription mrd );
+
+
+ public void matchingRuleUseDescriptionSelected( MatchingRuleUseDescription mrud );
+
+
+ public void ldapSyntacDescriptionSelected( LdapSyntaxDescription lsd );
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SearchUpdateEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SearchUpdateEvent.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SearchUpdateEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SearchUpdateEvent.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+
+
+public class SearchUpdateEvent
+{
+
+ public static final int SEARCH_ADDED = 1;
+
+ public static final int SEARCH_REMOVED = 2;
+
+ public static final int SEARCH_PERFORMED = 3;
+
+ public static final int SEARCH_PARAMETER_UPDATED = 4;
+
+ public static final int SEARCH_RENAMED = 5;
+
+ private int detail;
+
+ private ISearch search;
+
+
+ public SearchUpdateEvent( ISearch search, int detail )
+ {
+ this.search = search;
+ this.detail = detail;
+ }
+
+
+ public ISearch getSearch()
+ {
+ return search;
+ }
+
+
+ public int getDetail()
+ {
+ return detail;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SearchUpdateListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SearchUpdateListener.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SearchUpdateListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/SearchUpdateListener.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,29 @@
+/*
+ * 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.core.events;
+
+
+public interface SearchUpdateListener extends EventListener
+{
+
+ public void searchUpdated( SearchUpdateEvent searchUpdateEvent );
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueAddedEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueAddedEvent.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueAddedEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueAddedEvent.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,67 @@
+/*
+ * 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.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+
+
+public class ValueAddedEvent extends EntryModificationEvent
+{
+
+ private IAttribute modifiedAttribute;
+
+ private IValue addedValue;
+
+
+ public ValueAddedEvent( IConnection connection, IEntry modifiedEntry, IAttribute modifiedAttribute,
+ IValue addedValue, ModelModifier source )
+ {
+ super( connection, modifiedEntry, source );
+ this.modifiedAttribute = modifiedAttribute;
+ this.addedValue = addedValue;
+ }
+
+
+ public IAttribute getModifiedAttribute()
+ {
+ return this.modifiedAttribute;
+ }
+
+
+ public IValue getAddedValue()
+ {
+ return this.addedValue;
+ }
+
+
+ public String toString()
+ {
+ return BrowserCoreMessages.bind( BrowserCoreMessages.event__added_val_to_att_at_dn, new String[]
+ { getAddedValue().getStringValue(), getModifiedAttribute().getDescription(),
+ getModifiedEntry().getDn().toString() } );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueDeletedEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueDeletedEvent.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueDeletedEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueDeletedEvent.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,67 @@
+/*
+ * 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.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+
+
+public class ValueDeletedEvent extends EntryModificationEvent
+{
+
+ private IAttribute modifiedAttribute;
+
+ private IValue deletedValue;
+
+
+ public ValueDeletedEvent( IConnection connection, IEntry modifiedEntry, IAttribute modifiedAttribute,
+ IValue deletedValue, ModelModifier source )
+ {
+ super( connection, modifiedEntry, source );
+ this.modifiedAttribute = modifiedAttribute;
+ this.deletedValue = deletedValue;
+ }
+
+
+ public IAttribute getModifiedAttribute()
+ {
+ return this.modifiedAttribute;
+ }
+
+
+ public IValue getDeletedValue()
+ {
+ return this.deletedValue;
+ }
+
+
+ public String toString()
+ {
+ return BrowserCoreMessages.bind( BrowserCoreMessages.event__deleted_val_from_att_at_dn, new String[]
+ { getDeletedValue().getStringValue(), getModifiedAttribute().getDescription(),
+ getModifiedEntry().getDn().toString() } );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueModifiedEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueModifiedEvent.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueModifiedEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueModifiedEvent.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+
+
+public class ValueModifiedEvent extends EntryModificationEvent
+{
+
+ private IAttribute modifiedAttribute;
+
+ private IValue oldValue;
+
+ private IValue newValue;
+
+
+ public ValueModifiedEvent( IConnection connection, IEntry modifiedEntry, IAttribute modifiedAttribute,
+ IValue oldValue, IValue newValue, ModelModifier source )
+ {
+ super( connection, modifiedEntry, source );
+ this.modifiedAttribute = modifiedAttribute;
+ this.oldValue = oldValue;
+ this.newValue = newValue;
+ }
+
+
+ public IAttribute getModifiedAttribute()
+ {
+ return this.modifiedAttribute;
+ }
+
+
+ public IValue getOldValue()
+ {
+ return this.oldValue;
+ }
+
+
+ public IValue getNewValue()
+ {
+ return this.newValue;
+ }
+
+
+ public String toString()
+ {
+ return BrowserCoreMessages.bind( BrowserCoreMessages.event__replaced_oldval_by_newval_at_att_at_dn,
+ new String[]
+ { getOldValue().getStringValue(), getNewValue().getStringValue(),
+ getModifiedAttribute().getDescription(), getModifiedEntry().getDn().toString() } );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueRenamedEvent.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueRenamedEvent.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueRenamedEvent.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/events/ValueRenamedEvent.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,65 @@
+/*
+ * 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.core.events;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+
+
+public class ValueRenamedEvent extends EntryModificationEvent
+{
+
+ private IValue oldValue;
+
+ private IValue newValue;
+
+
+ public ValueRenamedEvent( IConnection connection, IEntry modifiedEntry, IValue oldValue, IValue newValue,
+ ModelModifier source )
+ {
+ super( connection, modifiedEntry, source );
+ this.oldValue = oldValue;
+ this.newValue = newValue;
+ }
+
+
+ public IValue getNewValue()
+ {
+ return this.newValue;
+ }
+
+
+ public IValue getOldValue()
+ {
+ return this.oldValue;
+ }
+
+
+ public String toString()
+ {
+ return BrowserCoreMessages.bind( BrowserCoreMessages.event__renamed_oldval_by_newval_at_dn, new String[]
+ { getOldValue().toString(), getNewValue().toString(), getModifiedEntry().getDn().toString() } );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/AbstractEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/AbstractEntry.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/AbstractEntry.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/AbstractEntry.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,681 @@
+/*
+ * 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.core.internal.model;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.events.AttributeAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.AttributeDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.AttributesInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ChildrenInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.search.LdapSearchPageScoreComputer;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.RDN;
+import org.apache.directory.ldapstudio.browser.core.model.URL;
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.ObjectClassDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.Subschema;
+import org.eclipse.search.ui.ISearchPageScoreComputer;
+
+
+public abstract class AbstractEntry implements IEntry
+{
+
+ public static final int HAS_CHILDREN_HINT_FLAG = 1;
+
+ public static final int IS_DIRECTORY_ENTRY_FLAG = 2;
+
+ public static final int IS_ALIAS_FLAG = 4;
+
+ public static final int IS_REFERRAL_FLAG = 8;
+
+ public static final int IS_SUBENTRY_FLAG = 16;
+
+ private volatile int flags;
+
+
+ protected AbstractEntry()
+ {
+ this.flags = HAS_CHILDREN_HINT_FLAG;
+ }
+
+
+ protected abstract void setParent( IEntry newParent );
+
+
+ protected abstract void setRdn( RDN newRdn );
+
+
+ public void addChild( IEntry childToAdd, ModelModifier source )
+ {
+
+ ChildrenInfo ci = this.getJNDIConnection().getChildrenInfo( this );
+ if ( ci == null )
+ {
+ ci = new ChildrenInfo();
+ this.getJNDIConnection().setChildrenInfo( this, ci );
+ }
+
+ if ( ci.childrenSet == null )
+ {
+ ci.childrenSet = new LinkedHashSet();
+ }
+ ci.childrenSet.add( childToAdd );
+ this.entryModified( new EntryAddedEvent( childToAdd.getConnection(), childToAdd, source ) );
+ }
+
+
+ public void deleteChild( IEntry childToDelete, ModelModifier source )
+ {
+
+ ChildrenInfo ci = this.getJNDIConnection().getChildrenInfo( this );
+
+ if ( ci != null )
+ {
+ ci.childrenSet.remove( childToDelete );
+ if ( ci.childrenSet == null || ci.childrenSet.isEmpty() )
+ {
+ this.getJNDIConnection().setChildrenInfo( this, null );
+ }
+ this.entryModified( new EntryDeletedEvent( this.getJNDIConnection(), childToDelete, source ) );
+ }
+ }
+
+
+ public void addAttribute( IAttribute attributeToAdd, ModelModifier source ) throws ModelModificationException
+ {
+
+ String oidString = attributeToAdd.getAttributeDescription().toOidString( getConnection().getSchema() );
+
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ if ( ai == null )
+ {
+ ai = new AttributeInfo();
+ this.getJNDIConnection().setAttributeInfo( this, ai );
+ }
+
+ if ( !this.equals( attributeToAdd.getEntry() ) )
+ {
+ throw new ModelModificationException( BrowserCoreMessages.model__attributes_entry_is_not_myself );
+ }
+ // else
+ // if(ai.attributeMap.containsKey(attributeToAdd.getDescription().toLowerCase()))
+ // {
+ else if ( ai.attributeMap.containsKey( oidString.toLowerCase() ) )
+ {
+ throw new ModelModificationException( BrowserCoreMessages.model__attribute_already_exists );
+ }
+ else
+ {
+ // ai.attributeMap.put(attributeToAdd.getDescription().toLowerCase(),
+ // attributeToAdd);
+ ai.attributeMap.put( oidString.toLowerCase(), attributeToAdd );
+ this.entryModified( new AttributeAddedEvent( this.getJNDIConnection(), this, attributeToAdd, source ) );
+ }
+ }
+
+
+ public void deleteAttribute( IAttribute attributeToDelete, ModelModifier source ) throws ModelModificationException
+ {
+
+ String oidString = attributeToDelete.getAttributeDescription().toOidString( getConnection().getSchema() );
+
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+
+ // if(ai != null && ai.attributeMap != null &&
+ // ai.attributeMap.containsKey(attributeToDelete.getDescription().toLowerCase()))
+ // {
+ // IAttribute attribute =
+ // (IAttribute)ai.attributeMap.get(attributeToDelete.getDescription().toLowerCase());
+ // ai.attributeMap.remove(attributeToDelete.getDescription().toLowerCase());
+ if ( ai != null && ai.attributeMap != null && ai.attributeMap.containsKey( oidString.toLowerCase() ) )
+ {
+ IAttribute attribute = ( IAttribute ) ai.attributeMap.get( oidString.toLowerCase() );
+ ai.attributeMap.remove( oidString.toLowerCase() );
+ if ( ai.attributeMap.isEmpty() )
+ {
+ this.getJNDIConnection().setAttributeInfo( this, null );
+ }
+ this.entryModified( new AttributeDeletedEvent( this.getJNDIConnection(), this, attribute, source ) );
+ }
+ else
+ {
+ throw new ModelModificationException( BrowserCoreMessages.model__attribute_does_not_exist );
+ }
+ }
+
+
+ public boolean isConsistent()
+ {
+
+ // if(!this.isAttributesInitialized() && this.isDirectoryEntry())
+ // return true;
+
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+
+ if ( ai == null || ai.attributeMap == null )
+ {
+ return isDirectoryEntry();
+ }
+
+ // check empty attributes and empty values
+ Iterator attributeIterator = ai.attributeMap.values().iterator();
+ while ( attributeIterator.hasNext() )
+ {
+ IAttribute attribute = ( IAttribute ) attributeIterator.next();
+ if ( !attribute.isConsistent() )
+ return false;
+ }
+
+ if ( !this.isDirectoryEntry() )
+ {
+ // check objectclass attribute
+ if ( !ai.attributeMap.containsKey( IAttribute.OBJECTCLASS_ATTRIBUTE_OID.toLowerCase() ) )
+ {
+ return false;
+ }
+ IAttribute ocAttribute = ( IAttribute ) ai.attributeMap.get( IAttribute.OBJECTCLASS_ATTRIBUTE_OID
+ .toLowerCase() );
+ String[] ocValues = ocAttribute.getStringValues();
+ boolean structuralObjectClassAvailable = false;
+ for ( int i = 0; i < ocValues.length; i++ )
+ {
+ ObjectClassDescription ocd = this.getConnection().getSchema().getObjectClassDescription( ocValues[i] );
+ if ( ocd.isStructural() )
+ {
+ structuralObjectClassAvailable = true;
+ break;
+ }
+ }
+ if ( !structuralObjectClassAvailable )
+ {
+ return false;
+ }
+
+ // check must-attributes
+ // String[] mustAttributeNames =
+ // this.getSubschema().getMustAttributeNames();
+ // for(int i=0; i<mustAttributeNames.length; i++) {
+ // if(!ai.attributeMap.containsKey(mustAttributeNames[i].toLowerCase()))
+ // return false;
+ // }
+ AttributeTypeDescription[] mustAtds = this.getSubschema().getMustAttributeTypeDescriptions();
+ for ( int i = 0; i < mustAtds.length; i++ )
+ {
+ AttributeTypeDescription mustAtd = mustAtds[i];
+ if ( !ai.attributeMap.containsKey( mustAtd.getNumericOID().toLowerCase() ) )
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+ public boolean isDirectoryEntry()
+ {
+ return ( this.flags & IS_DIRECTORY_ENTRY_FLAG ) != 0;
+ }
+
+
+ public void setDirectoryEntry( boolean isDirectoryEntry )
+ {
+ if ( isDirectoryEntry )
+ this.flags = this.flags | IS_DIRECTORY_ENTRY_FLAG;
+ else
+ this.flags = this.flags & ~IS_DIRECTORY_ENTRY_FLAG;
+ }
+
+
+ public boolean isAlias()
+ {
+ if ( ( this.flags & IS_ALIAS_FLAG ) != 0 )
+ {
+ return true;
+ }
+
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ if ( ai != null )
+ {
+ return Arrays.asList( this.getSubschema().getObjectClassNames() )
+ .contains( ObjectClassDescription.OC_ALIAS );
+ }
+
+ return false;
+ }
+
+
+ public void setAlias( boolean b )
+ {
+ if ( b )
+ this.flags = this.flags | IS_ALIAS_FLAG;
+ else
+ this.flags = this.flags & ~IS_ALIAS_FLAG;
+ }
+
+
+ public boolean isReferral()
+ {
+ if ( ( this.flags & IS_REFERRAL_FLAG ) != 0 )
+ {
+ return true;
+ }
+
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ if ( ai != null )
+ {
+ return Arrays.asList( this.getSubschema().getObjectClassNames() ).contains(
+ ObjectClassDescription.OC_REFERRAL );
+ }
+
+ return false;
+ }
+
+
+ public void setReferral( boolean b )
+ {
+ if ( b )
+ this.flags = this.flags | IS_REFERRAL_FLAG;
+ else
+ this.flags = this.flags & ~IS_REFERRAL_FLAG;
+ }
+
+
+ public boolean isSubentry()
+ {
+ if ( ( this.flags & IS_SUBENTRY_FLAG ) != 0 )
+ {
+ return true;
+ }
+
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ if ( ai != null )
+ {
+ return Arrays.asList( this.getSubschema().getObjectClassNames() ).contains(
+ ObjectClassDescription.OC_SUBENTRY );
+ }
+
+ return false;
+ }
+
+
+ public void setSubentry( boolean b )
+ {
+ if ( b )
+ this.flags = this.flags | IS_SUBENTRY_FLAG;
+ else
+ this.flags = this.flags & ~IS_SUBENTRY_FLAG;
+ }
+
+
+ /**
+ * Triggers firering of the modification event.
+ *
+ * @param event
+ */
+ private void entryModified( EntryModificationEvent event )
+ {
+ EventRegistry.fireEntryUpdated( event, this );
+ }
+
+
+ public RDN getRdn()
+ {
+ return this.getDn().getRdn();
+ }
+
+
+ public boolean isAttributesInitialized()
+ {
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ return ai != null && ai.attributesInitialzed;
+ }
+
+
+ public void setAttributesInitialized( boolean b, ModelModifier source )
+ {
+
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ if ( ai == null && b )
+ {
+ ai = new AttributeInfo();
+ this.getJNDIConnection().setAttributeInfo( this, ai );
+ }
+
+ if ( ai != null )
+ {
+ ai.attributesInitialzed = b;
+ }
+
+ if ( ai != null && !b )
+ {
+ ai.attributeMap.clear();
+ this.getJNDIConnection().setAttributeInfo( this, null );
+ }
+
+ this.entryModified( new AttributesInitializedEvent( this, source ) );
+ }
+
+
+ public IAttribute[] getAttributes()
+ {
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ if ( ai == null || ai.attributeMap == null )
+ {
+ return null;
+ }
+ else
+ {
+ return ( IAttribute[] ) ai.attributeMap.values().toArray( new IAttribute[0] );
+ }
+ }
+
+
+ public IAttribute getAttribute( String attributeDescription )
+ {
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ if ( ai == null || ai.attributeMap == null )
+ {
+ return null;
+ }
+ else
+ {
+ AttributeDescription ad = new AttributeDescription( attributeDescription );
+ String oidString = ad.toOidString( getConnection().getSchema() );
+ return ( IAttribute ) ai.attributeMap.get( oidString.toLowerCase() );
+ }
+ }
+
+
+ public AttributeHierachie getAttributeWithSubtypes( String attributeDescription )
+ {
+
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ if ( ai == null || ai.attributeMap == null )
+ {
+ return null;
+ }
+ else
+ {
+ List attributeList = new ArrayList();
+
+ IAttribute myAttribute = getAttribute( attributeDescription );
+ if ( myAttribute != null )
+ {
+ attributeList.add( myAttribute );
+ }
+
+ AttributeDescription ad = new AttributeDescription( attributeDescription );
+ Map clonedAttributeMap = new HashMap( ai.attributeMap );
+ Iterator iterator = clonedAttributeMap.values().iterator();
+ while ( iterator.hasNext() )
+ {
+ IAttribute attribute = ( IAttribute ) iterator.next();
+
+ AttributeDescription other = attribute.getAttributeDescription();
+ if ( other.isSubtypeOf( ad, getConnection().getSchema() ) )
+ {
+ attributeList.add( attribute );
+ }
+ }
+
+ if ( attributeList.isEmpty() )
+ {
+ return null;
+ }
+ else
+ {
+ IAttribute[] attributes = ( IAttribute[] ) attributeList.toArray( new IAttribute[attributeList.size()] );
+ AttributeHierachie ah = new AttributeHierachie( this, attributeDescription, attributes );
+ return ah;
+ }
+ }
+ }
+
+
+ public Subschema getSubschema()
+ {
+ AttributeInfo ai = this.getJNDIConnection().getAttributeInfo( this );
+ if ( ai == null )
+ {
+ ai = new AttributeInfo();
+ this.getJNDIConnection().setAttributeInfo( this, ai );
+ }
+ if ( ai.subschema == null )
+ {
+ ai.subschema = new Subschema( this );
+ }
+
+ return ai.subschema;
+ }
+
+
+ public void setChildrenInitialized( boolean b, ModelModifier source )
+ {
+ ChildrenInfo ci = this.getJNDIConnection().getChildrenInfo( this );
+ if ( ci == null && b )
+ {
+ ci = new ChildrenInfo();
+ this.getJNDIConnection().setChildrenInfo( this, ci );
+ }
+
+ if ( ci != null )
+ {
+ ci.childrenInitialzed = b;
+ }
+
+ if ( ci != null && !b )
+ {
+ if ( ci.childrenSet != null )
+ {
+ ci.childrenSet.clear();
+ }
+ this.getJNDIConnection().setChildrenInfo( this, null );
+ }
+
+ this.entryModified( new ChildrenInitializedEvent( this, source ) );
+ }
+
+
+ public boolean isChildrenInitialized()
+ {
+ ChildrenInfo ci = this.getJNDIConnection().getChildrenInfo( this );
+ return ci != null && ci.childrenInitialzed;
+ }
+
+
+ public IEntry[] getChildren()
+ {
+ int count = getChildrenCount();
+ if ( count < 0 )
+ {
+ return null;
+ }
+ else if ( count == 0 )
+ {
+ return new IEntry[0];
+ }
+ else
+ {
+ IEntry[] children = new IEntry[count];
+ ChildrenInfo ci = this.getJNDIConnection().getChildrenInfo( this );
+ int i = 0;
+ if ( ci.childrenSet != null )
+ {
+ Iterator it = ci.childrenSet.iterator();
+ for ( ; it.hasNext(); i++ )
+ {
+ children[i] = ( IEntry ) it.next();
+ }
+ }
+ return children;
+ }
+ }
+
+
+ public int getChildrenCount()
+ {
+ if ( isSubentry() )
+ {
+ return 0;
+ }
+ ChildrenInfo ci = this.getJNDIConnection().getChildrenInfo( this );
+ if ( ci == null )
+ {
+ return -1;
+ }
+ else
+ {
+ return ci.childrenSet == null ? 0 : ci.childrenSet.size();
+ }
+ }
+
+
+ public void setHasMoreChildren( boolean b, ModelModifier source )
+ {
+ ChildrenInfo ci = this.getJNDIConnection().getChildrenInfo( this );
+ if ( ci == null )
+ {
+ ci = new ChildrenInfo();
+ this.getJNDIConnection().setChildrenInfo( this, ci );
+ }
+ ci.hasMoreChildren = b;
+
+ this.entryModified( new ChildrenInitializedEvent( this, source ) );
+ }
+
+
+ public boolean hasMoreChildren()
+ {
+ ChildrenInfo ci = this.getJNDIConnection().getChildrenInfo( this );
+ return ci != null && ci.hasMoreChildren;
+ }
+
+
+ public void setHasChildrenHint( boolean b, ModelModifier source )
+ {
+ if ( b )
+ this.flags = this.flags | HAS_CHILDREN_HINT_FLAG;
+ else
+ this.flags = this.flags & ~HAS_CHILDREN_HINT_FLAG;
+ }
+
+
+ public boolean hasChildren()
+ {
+ return ( this.flags & HAS_CHILDREN_HINT_FLAG ) != 0 || this.getChildrenCount() > 0;
+ }
+
+
+ public String getChildrenFilter()
+ {
+ return this.getJNDIConnection().getChildrenFilter( this );
+ }
+
+
+ public void setChildrenFilter( String childrenFilter )
+ {
+ this.getJNDIConnection().setChildrenFilter( this, childrenFilter );
+ }
+
+
+ public boolean hasParententry()
+ {
+ return this.getParententry() != null;
+ }
+
+
+ private Connection getJNDIConnection()
+ {
+ return ( Connection ) this.getConnection();
+ }
+
+
+ public String toString()
+ {
+ return this.getDn().toString();
+ }
+
+
+ public boolean equals( Object o )
+ {
+
+ // check argument
+ if ( o == null || !( o instanceof IEntry ) )
+ {
+ return false;
+ }
+ IEntry e = ( IEntry ) o;
+
+ // compare dn and connection
+ return this.getDn() == null ? e.getDn() == null : ( this.getDn().equals( e.getDn() ) && this.getConnection()
+ .equals( e.getConnection() ) );
+ }
+
+
+ public Object getAdapter( Class adapter )
+ {
+
+ if ( adapter.isAssignableFrom( ISearchPageScoreComputer.class ) )
+ {
+ return new LdapSearchPageScoreComputer();
+ }
+ if ( adapter == IConnection.class )
+ {
+ return this.getConnection();
+ }
+ if ( adapter == IEntry.class )
+ {
+ return this;
+ }
+ return null;
+ }
+
+
+ public IEntry getEntry()
+ {
+ return this;
+ }
+
+
+ public URL getUrl()
+ {
+ return new URL( getConnection(), getDn() );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/AliasBaseEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/AliasBaseEntry.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/AliasBaseEntry.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/AliasBaseEntry.java Mon Dec 18 09:15:00 2006
@@ -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.ldapstudio.browser.core.internal.model;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.DN;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+
+
+public class AliasBaseEntry extends DelegateEntry
+{
+
+ private static final long serialVersionUID = -3599038109979581295L;
+
+
+ protected AliasBaseEntry()
+ {
+ }
+
+
+ public AliasBaseEntry( IConnection connection, DN dn )
+ {
+ super( connection, dn );
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/Attribute.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/Attribute.java?view=auto&rev=488345
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/Attribute.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-core/src/org/apache/directory/ldapstudio/browser/core/internal/model/Attribute.java Mon Dec 18 09:15:00 2006
@@ -0,0 +1,420 @@
+/*
+ * 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.core.internal.model;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
+import org.apache.directory.ldapstudio.browser.core.events.EmptyValueAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EmptyValueDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.events.ValueAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ValueDeletedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ValueModifiedEvent;
+import org.apache.directory.ldapstudio.browser.core.internal.search.LdapSearchPageScoreComputer;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaUtils;
+import org.eclipse.search.ui.ISearchPageScoreComputer;
+
+
+public class Attribute implements IAttribute
+{
+
+ private static final long serialVersionUID = -5679384884002589786L;
+
+ private AttributeDescription attributeDescription;
+
+ private IEntry entry;
+
+ private List valueList;
+
+
+ protected Attribute()
+ {
+ }
+
+
+ /**
+ * Creates an Attribute with the given description and no value for the
+ * given entry.
+ *
+ * @param entry
+ * The entry of this attribute, mustn't be null
+ * @param description
+ * The attribute descrption, mustn't be null or empty.
+ * @throws ModelModificationException
+ * if the attribute name is null or empty.
+ */
+ public Attribute( IEntry entry, String description ) throws ModelModificationException
+ {
+ if ( entry == null )
+ {
+ throw new ModelModificationException( BrowserCoreMessages.model__empty_entry );
+ }
+ if ( description == null /* || "".equals(description) */)
+ { //$NON-NLS-1$
+ throw new ModelModificationException( BrowserCoreMessages.model__empty_attribute );
+ }
+
+ this.entry = entry;
+ this.attributeDescription = new AttributeDescription( description );
+ this.valueList = new ArrayList();
+ // this.valueList = new LinkedHashSet();
+
+ }
+
+
+ public IEntry getEntry()
+ {
+ return this.entry;
+ }
+
+
+ public boolean isConsistent()
+ {
+ if ( this.valueList.isEmpty() )
+ {
+ return false;
+ }
+
+ for ( Iterator it = this.valueList.iterator(); it.hasNext(); )
+ {
+ IValue value = ( IValue ) it.next();
+ if ( value.isEmpty() )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+ public boolean isMustAttribute()
+ {
+ if ( this.isObjectClassAttribute() )
+ {
+ return true;
+ }
+ else
+ {
+ String[] mustAttributeNames = this.entry.getSubschema().getMustAttributeNames();
+ for ( int i = 0; i < mustAttributeNames.length; i++ )
+ {
+ String must = mustAttributeNames[i];
+ if ( must.equalsIgnoreCase( this.getType() ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+
+ public boolean isMayAttribute()
+ {
+ // return
+ // Arrays.asList(this.entry.getSubschema().getMayAttributeNames()).contains(this.getType());
+ return !isObjectClassAttribute() && !isMustAttribute() && !isOperationalAttribute();
+ }
+
+
+ public boolean isOperationalAttribute()
+ {
+ return getAttributeTypeDescription() == null || SchemaUtils.isOperational( getAttributeTypeDescription() );
+ }
+
+
+ public boolean isObjectClassAttribute()
+ {
+ return OBJECTCLASS_ATTRIBUTE.equalsIgnoreCase( this.getDescription() );
+ }
+
+
+ public boolean isString()
+ {
+ return !this.isBinary();
+ }
+
+
+ public boolean isBinary()
+ {
+ return this.getAttributeTypeDescription().isBinary();
+ }
+
+
+ public void addEmptyValue( ModelModifier source )
+ {
+ try
+ {
+ IValue emptyValue = new Value( this );
+ this.valueList.add( emptyValue );
+ this.attributeModified( new EmptyValueAddedEvent( this.entry.getConnection(), this.entry, this, emptyValue,
+ source ) );
+ }
+ catch ( ModelModificationException mme )
+ {
+ // Shouldn't occur
+ }
+ }
+
+
+ public void deleteEmptyValue( ModelModifier source )
+ {
+ for ( Iterator it = this.valueList.iterator(); it.hasNext(); )
+ {
+ IValue value = ( IValue ) it.next();
+ if ( value.isEmpty() )
+ {
+ it.remove();
+ this.attributeModified( new EmptyValueDeletedEvent( this.entry.getConnection(), this.entry, this,
+ value, source ) );
+ return;
+ }
+ }
+ }
+
+
+ private void attributeModified( EntryModificationEvent event )
+ {
+ EventRegistry.fireEntryUpdated( event, this.getEntry() );
+ }
+
+
+ private void checkValue( IValue value ) throws ModelModificationException
+ {
+ if ( value == null )
+ {
+ throw new ModelModificationException( BrowserCoreMessages.model__empty_value );
+ }
+ if ( !value.getAttribute().equals( this ) )
+ {
+ throw new ModelModificationException( BrowserCoreMessages.model__values_attribute_is_not_myself );
+ }
+ }
+
+
+ private boolean deleteValue( IValue valueToDelete )
+ {
+ for ( Iterator it = this.valueList.iterator(); it.hasNext(); )
+ {
+ IValue value = ( IValue ) it.next();
+ if ( value.equals( valueToDelete ) )
+ {
+ it.remove();
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public void addValue( IValue valueToAdd, ModelModifier source ) throws ModelModificationException
+ {
+ this.checkValue( valueToAdd );
+
+ this.valueList.add( valueToAdd );
+ this
+ .attributeModified( new ValueAddedEvent( this.entry.getConnection(), this.entry, this, valueToAdd, source ) );
+ }
+
+
+ public void deleteValue( IValue valueToDelete, ModelModifier source ) throws ModelModificationException
+ {
+ this.checkValue( valueToDelete );
+
+ if ( this.deleteValue( valueToDelete ) )
+ {
+ this.attributeModified( new ValueDeletedEvent( this.entry.getConnection(), this.entry, this, valueToDelete,
+ source ) );
+ }
+ }
+
+
+ public void modifyValue( IValue oldValue, IValue newValue, ModelModifier source ) throws ModelModificationException
+ {
+ this.checkValue( oldValue );
+ this.checkValue( newValue );
+
+ this.deleteValue( oldValue );
+ this.valueList.add( newValue );
+ this.attributeModified( new ValueModifiedEvent( this.entry.getConnection(), this.entry, this, oldValue,
+ newValue, source ) );
+ }
+
+
+ public IValue[] getValues()
+ {
+ return ( IValue[] ) this.valueList.toArray( new IValue[0] );
+ }
+
+
+ public int getValueSize()
+ {
+ return this.valueList.size();
+ }
+
+
+ public String getDescription()
+ {
+ return this.attributeDescription.getDescription();
+ }
+
+
+ public String getType()
+ {
+ return this.attributeDescription.getParsedAttributeType();
+ }
+
+
+ public String toString()
+ {
+ return this.getDescription();
+ }
+
+
+ public boolean equals( Object o )
+ {
+ // check argument
+ if ( o == null || !( o instanceof IAttribute ) )
+ {
+ return false;
+ }
+ IAttribute a = ( IAttribute ) o;
+
+ // compare entries
+ if ( !this.getEntry().equals( a.getEntry() ) )
+ {
+ return false;
+ }
+
+ // compare attribute description
+ return this.getDescription().equals( a.getDescription() );
+ }
+
+
+ public int hashCode()
+ {
+ return this.getDescription().hashCode();
+ }
+
+
+ public byte[][] getBinaryValues()
+ {
+ List binaryValueList = new ArrayList();
+
+ IValue[] values = this.getValues();
+ for ( int i = 0; i < values.length; i++ )
+ {
+ binaryValueList.add( values[i].getBinaryValue() );
+ }
+
+ return ( byte[][] ) binaryValueList.toArray( new byte[0][] );
+ }
+
+
+ public String getStringValue()
+ {
+ if ( getValueSize() > 0 )
+ {
+ return ( ( IValue ) this.valueList.get( 0 ) ).getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ public String[] getStringValues()
+ {
+ List stringValueList = new ArrayList();
+
+ IValue[] values = this.getValues();
+ for ( int i = 0; i < values.length; i++ )
+ {
+ stringValueList.add( values[i].getStringValue() );
+ }
+
+ return ( String[] ) stringValueList.toArray( new String[stringValueList.size()] );
+ }
+
+
+ public AttributeTypeDescription getAttributeTypeDescription()
+ {
+ return getEntry().getConnection().getSchema().getAttributeTypeDescription( this.getType() );
+ }
+
+
+ public Object getAdapter( Class adapter )
+ {
+
+ if ( adapter.isAssignableFrom( ISearchPageScoreComputer.class ) )
+ {
+ return new LdapSearchPageScoreComputer();
+ }
+ if ( adapter == IConnection.class )
+ {
+ return this.getConnection();
+ }
+ if ( adapter == IEntry.class )
+ {
+ return this.getEntry();
+ }
+ if ( adapter == IAttribute.class )
+ {
+ return this;
+ }
+
+ return null;
+ }
+
+
+ public IConnection getConnection()
+ {
+ return this.entry.getConnection();
+ }
+
+
+ public IAttribute getAttribute()
+ {
+ return this;
+ }
+
+
+ public AttributeDescription getAttributeDescription()
+ {
+ return attributeDescription;
+ }
+
+}