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 2009/10/05 14:31:50 UTC
svn commit: r821775 - in /directory/studio/trunk:
connection-core/src/main/java/org/apache/directory/studio/connection/core/event/ConnectionUpdateAdapter.java
ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
Author: pamarcelot
Date: Mon Oct 5 12:31:50 2009
New Revision: 821775
URL: http://svn.apache.org/viewvc?rev=821775&view=rev
Log:
DIRSTUDIO-515 (Add extensibility to Entry Editor).
o Added a new listener on the EntryEditorManager which listens for "connection closed" or "connection deleted" events.
o The editors associated with a closed or deleted connection are closed
Added:
directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/event/ConnectionUpdateAdapter.java
Modified:
directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
Added: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/event/ConnectionUpdateAdapter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/event/ConnectionUpdateAdapter.java?rev=821775&view=auto
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/event/ConnectionUpdateAdapter.java (added)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/event/ConnectionUpdateAdapter.java Mon Oct 5 12:31:50 2009
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.connection.core.event;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionFolder;
+
+
+/**
+ * This class implements a simple {@link ConnectionUpdateListener} which does nothing.
+ * <p>
+ * All methods are "empty".
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectionUpdateAdapter implements ConnectionUpdateListener
+{
+ /**
+ * {@inheritDoc}
+ */
+ public void connectionOpened( Connection connection )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void connectionClosed( Connection connection )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void connectionAdded( Connection connection )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void connectionRemoved( Connection connection )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void connectionUpdated( Connection connection )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void connectionFolderModified( ConnectionFolder connectionFolder )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void connectionFolderAdded( ConnectionFolder connectionFolder )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void connectionFolderRemoved( ConnectionFolder connectionFolder )
+ {
+ }
+}
Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java?rev=821775&r1=821774&r2=821775&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java (original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/entryeditors/EntryEditorManager.java Mon Oct 5 12:31:50 2009
@@ -32,6 +32,11 @@
import java.util.Set;
import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
+import org.apache.directory.studio.connection.core.event.ConnectionUpdateAdapter;
+import org.apache.directory.studio.connection.core.event.ConnectionUpdateListener;
+import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
import org.apache.directory.studio.connection.ui.RunnableContextRunner;
import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent;
@@ -140,6 +145,21 @@
}
};
+ /** The listener for connection update */
+ private ConnectionUpdateListener connectionUpdateListener = new ConnectionUpdateAdapter()
+ {
+ public void connectionClosed( Connection connection )
+ {
+ closeEditorsBelongingToConnection( connection );
+ };
+
+
+ public void connectionRemoved( Connection connection )
+ {
+ closeEditorsBelongingToConnection( connection );
+ };
+ };
+
/**
* Creates a new instance of EntryEditorManager.
@@ -150,6 +170,9 @@
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( partListener );
EventRegistry
.addEntryUpdateListener( entryUpdateListener, BrowserCommonActivator.getDefault().getEventRunner() );
+ ConnectionEventRegistry.addConnectionUpdateListener( connectionUpdateListener, ConnectionUIPlugin.getDefault()
+ .getEventRunner() );
+
}
@@ -350,6 +373,34 @@
/**
+ * Closes the open editors belonging to the given connection.
+ *
+ * @param connection
+ * the connection
+ */
+ private void closeEditorsBelongingToConnection( Connection connection )
+ {
+ if ( connection != null )
+ {
+ IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .getEditorReferences();
+ for ( IEditorReference ref : editorReferences )
+ {
+ IEntryEditor editor = getEntryEditor( ref );
+ if ( editor != null )
+ {
+ IBrowserConnection bc = editor.getEntryEditorInput().getResolvedEntry().getBrowserConnection();
+ if ( connection.equals( bc.getConnection() ) )
+ {
+ ref.getPage().closeEditor( ref.getEditor( false ), false );
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
* Opens an entry editor with the given entry editor extension and one of
* the given entries, search results or bookmarks.
*
@@ -826,7 +877,6 @@
private EntryUpdateListener entryUpdateListener = new EntryUpdateListener()
{
-
public void entryUpdated( EntryModificationEvent event )
{
IEntry modifiedEntry = event.getModifiedEntry();