directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r986655 - in /directory/studio/trunk/plugins/ldapservers: ./ src/main/java/org/apache/directory/studio/ldapservers/actions/
Date Wed, 18 Aug 2010 13:08:55 GMT
Author: pamarcelot
Date: Wed Aug 18 13:08:55 2010
New Revision: 986655

URL: http://svn.apache.org/viewvc?rev=986655&view=rev
Log:
Added an Action Helper class to help other plugins create a connection from an LDAP Server.

Added:
    directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/CreateConnectionActionHelper.java
Modified:
    directory/studio/trunk/plugins/ldapservers/plugin.properties
    directory/studio/trunk/plugins/ldapservers/pom.xml
    directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages.properties
    directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_de.properties
    directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_fr.properties

Modified: directory/studio/trunk/plugins/ldapservers/plugin.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/plugin.properties?rev=986655&r1=986654&r2=986655&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/plugin.properties (original)
+++ directory/studio/trunk/plugins/ldapservers/plugin.properties Wed Aug 18 13:08:55 2010
@@ -59,4 +59,6 @@ Cmd_OpenConfiguration_description=Open C
 
 Ctx_ServersView_id=org.apache.directory.studio.ldapservers.contexts.serversView
 Ctx_ServersView_name=In LDAP Servers View
-Ctx_ServersView_description=In LDAP Servers View
\ No newline at end of file
+Ctx_ServersView_description=In LDAP Servers View
+
+Perspective_LdapBrowserPerspective_id=org.apache.directory.studio.ldapbrowser.ui.perspective.BrowserPerspective

Modified: directory/studio/trunk/plugins/ldapservers/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/pom.xml?rev=986655&r1=986654&r2=986655&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/pom.xml (original)
+++ directory/studio/trunk/plugins/ldapservers/pom.xml Wed Aug 18 13:08:55 2010
@@ -119,6 +119,7 @@
  org.apache.commons.io;bundle-version="${org.apache.commons.io.version}",
  org.apache.directory.studio.common.core,
  org.apache.directory.studio.common.ui,
+ org.apache.directory.studio.connection.core,
  org.apache.mina.core;bundle-version="${org.apache.mina.core.validversion}",
  org.dom4j.dom4j;bundle-version="${org.dom4j.version}",
  org.eclipse.core.resources,
@@ -194,6 +195,11 @@
       <artifactId>common.ui</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.directory.studio</groupId>
+      <artifactId>connection.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
     
 	<!-- Eclipse plugins dependencies -->
     <dependency>

Added: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/CreateConnectionActionHelper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/CreateConnectionActionHelper.java?rev=986655&view=auto
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/CreateConnectionActionHelper.java
(added)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/CreateConnectionActionHelper.java
Wed Aug 18 13:08:55 2010
@@ -0,0 +1,111 @@
+/*
+ *  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.ldapservers.actions;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.apache.directory.studio.ldapservers.LdapServersPlugin;
+import org.apache.directory.studio.ldapservers.model.LdapServer;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * This class implements a helper class of the create connection action for a server.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CreateConnectionActionHelper
+{
+    public static void createLdapBrowserConnection( LdapServer server, Connection connection
)
+    {
+        // Adding the connection to the connection manager
+        ConnectionCorePlugin.getDefault().getConnectionManager().addConnection( connection
);
+
+        // Adding the connection to the root connection folder
+        ConnectionCorePlugin.getDefault().getConnectionFolderManager().getRootConnectionFolder()
+            .addConnectionId( connection.getId() );
+
+        // Getting the window, LDAP perspective and current perspective
+        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+        IPerspectiveDescriptor ldapPerspective = getLdapPerspective();
+        IPerspectiveDescriptor currentPerspective = window.getActivePage().getPerspective();
+
+        // Checking if we are already in the LDAP perspective
+        if ( ( ldapPerspective != null ) && ( ldapPerspective.equals( currentPerspective
) ) )
+        {
+            // As we're already in the LDAP perspective, we only indicate to the user 
+            // the name of the connection that has been created
+            MessageDialog dialog = new MessageDialog(
+                window.getShell(),
+                Messages.getString( "CreateConnectionActionHelper.ConnectionCreated" ), null,
//$NON-NLS-1$
+                NLS.bind(
+                    Messages.getString( "CreateConnectionActionHelper.ConnectionCalledCreated"
), new String[] { connection.getName() } ), MessageDialog.INFORMATION, //$NON-NLS-1$
+                new String[]
+                    { IDialogConstants.OK_LABEL }, MessageDialog.OK );
+            dialog.open();
+        }
+        else
+        {
+            // We're not already in the LDAP perspective, we indicate to the user
+            // the name of the connection that has been created and we ask him
+            // if we wants to switch to the LDAP perspective
+            MessageDialog dialog = new MessageDialog(
+                window.getShell(),
+                Messages.getString( "CreateConnectionActionHelper.ConnectionCreated" ), null,
//$NON-NLS-1$
+                NLS.bind(
+                    Messages.getString( "CreateConnectionActionHelper.ConnectionCalledCreatedSwitch"
), new String[] { connection.getName() } ), //$NON-NLS-1$
+                MessageDialog.INFORMATION, new String[]
+                    { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, MessageDialog.OK
);
+            if ( dialog.open() == MessageDialog.OK )
+            {
+                // Switching to the LDAP perspective
+                window.getActivePage().setPerspective( ldapPerspective );
+            }
+        }
+    }
+
+
+    /**
+     * Get the LDAP perspective.
+     *
+     * @return
+     *      the LDAP perspective
+     */
+    private static IPerspectiveDescriptor getLdapPerspective()
+    {
+        for ( IPerspectiveDescriptor perspective : PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives()
)
+        {
+            if ( LdapServersPlugin.getDefault().getPluginProperties()
+                .getString( "Perspective_LdapBrowserPerspective_id" ) //$NON-NLS-1$
+                .equalsIgnoreCase( perspective.getId() ) )
+            {
+                return perspective;
+            }
+        }
+
+        return null;
+    }
+}

Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages.properties?rev=986655&r1=986654&r2=986655&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages.properties
(original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages.properties
Wed Aug 18 13:08:55 2010
@@ -15,6 +15,10 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
+CreateConnectionActionHelper.ConnectionCalledCreated=A connection called "{0}" has been created.
+CreateConnectionActionHelper.ConnectionCalledCreatedSwitch=A connection called "{0}" has
been created.\n\nDo you want to switch to the LDAP perspective ?
+CreateConnectionActionHelper.ConnectionCreated=Connection created
+
 DeleteAction.Delete=&Delete
 DeleteAction.DeleteToolTip=Delete
 DeleteAction.ErrorWhileStopping=An error occurred when stopping the server.\n\n

Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_de.properties?rev=986655&r1=986654&r2=986655&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_de.properties
(original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_de.properties
Wed Aug 18 13:08:55 2010
@@ -15,6 +15,10 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
+CreateConnectionActionHelper.ConnectionCalledCreated=Eine Verbindung mit Namen "{0}" ist
erstellt worden.
+CreateConnectionActionHelper.ConnectionCalledCreatedSwitch=Eine Verbindung mit Namen "{0}"
ist erstellt worden.\n\nM\u00F6chten Sie zur LDAP Perspektive wechseln?
+CreateConnectionActionHelper.ConnectionCreated=Verbindung erstellt
+
 DeleteAction.Delete=&L\u00F6schen
 DeleteAction.DeleteToolTip=L\u00F6schen
 DeleteAction.ErrorWhileStopping=Beim Stoppen des Servers ist ein Fehler aufgetreten.\n\n

Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_fr.properties?rev=986655&r1=986654&r2=986655&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_fr.properties
(original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/actions/messages_fr.properties
Wed Aug 18 13:08:55 2010
@@ -23,6 +23,11 @@
 # ^P : Propri\u00E9t\u00E9s
 # ^R : Renommer
 # ^S : Supprimer
+
+CreateConnectionActionHelper.ConnectionCalledCreated=Une connexion nomm\u00E9e "{0}" a \u00E9t\u00E9
cr\u00E9\u00E9e.
+CreateConnectionActionHelper.ConnectionCalledCreatedSwitch=Une connexion nomm\u00E9e "{0}"
a \u00E9t\u00E9 cr\u00E9\u00E9e.\n\nSouhaitez-vous basculer vers la perspective LDAP ?
+CreateConnectionActionHelper.ConnectionCreated=Connexion cr\u00E9\u00E9e
+
 DeleteAction.Delete=&Supprimer
 DeleteAction.DeleteToolTip=Supprimer
 DeleteAction.ErrorWhileStopping=Une erreur est survenue lors de l'arr\u00EAt du serveur.\n\n



Mime
View raw message