directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r510997 - in /directory/ldapstudio/trunk/ldapstudio-proxy: ./ resources/icons/ src/main/java/org/apache/directory/ldapstudio/proxy/ src/main/java/org/apache/directory/ldapstudio/proxy/controller/ src/main/java/org/apache/directory/ldapstudi...
Date Fri, 23 Feb 2007 16:01:09 GMT
Author: pamarcelot
Date: Fri Feb 23 08:01:07 2007
New Revision: 510997

URL: http://svn.apache.org/viewvc?view=rev&rev=510997
Log:
Added:
	- Build an Ivy files.
	- Icons for views.
	- A first implementation of the LDAP Proxy (needing to be improved).
	- Links between ConnectWizard and LDAP Proxy.

The ConnectWizard now selects a specific page if the LDAP Browser Plugin is available or not on the platform.
The pages of the ConnectWizard now saves previous values entered in the fields.

Added:
    directory/ldapstudio/trunk/ldapstudio-proxy/build.xml
    directory/ldapstudio/trunk/ldapstudio-proxy/ivy.xml
    directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/in.png   (with props)
    directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/ldap-message_view.png   (with props)
    directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/out.png   (with props)
    directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/proxy_view.png   (with props)
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/ProxyConstants.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxy.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyListener.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyThread.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/HistoryUtils.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserAvailablePage.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserNotAvailablePage.java
Removed:
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardSettingsPage.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml
    directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/perspective.png
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/Activator.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/LdapMessageViewController.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/ProxyViewController.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/ConnectAction.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/DisconnectAction.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/BaseWidgetUtils.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/IImageKeys.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/LdapMessageView.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/Perspective.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/ProxyView.java
    directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizard.java

Added: directory/ldapstudio/trunk/ldapstudio-proxy/build.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/build.xml?view=auto&rev=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/build.xml (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/build.xml Fri Feb 23 08:01:07 2007
@@ -0,0 +1,152 @@
+<!--
+  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.
+-->
+<project default="jar" xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
+	<property name="project.name" value="org.apache.directory.ldapstudio.proxy" />
+	<property name="project.version" value="0.7.0" />
+
+	<property name="project.output" value="${basedir}/target" />
+	<property name="project.build" value="${project.output}/build" />
+	<property name="project.src" value="${basedir}/src/main/java" />
+
+	<property name="lib.dir" value="lib" />
+
+	<property name="repository.dir" location="../dependencies/externals/"/>
+
+	<!-- Configuring Ivy (Needs to be AFTER the $repository.dir declaration) -->
+	<ivy:configure file="../tools/ivyconf.xml"/>
+	
+	<!-- ================================== -->
+	<!--               RESOLVE              -->
+	<!-- ================================== -->
+	<target name="resolve" description="--> retreive dependencies with ivy">
+		<mkdir dir="${basedir}/${lib.dir}" />
+		<ivy:retrieve/>
+	</target>
+		
+	<!-- ================================== -->
+	<!--             CLASSPATH              -->
+	<!-- ================================== -->
+	<target name="build-classpath" description="Computes a classpath according to current OS" >
+		
+		<path id="classpath">
+			<fileset dir="../dependencies/eclipse/3.2">
+				<include name="**/*.jar"/>
+			</fileset>
+			<fileset dir="${lib.dir}" />
+			<pathelement location="${basedir}/../ldapstudio-browser-core/target/classes"/>
+			<pathelement location="${basedir}/../ldapstudio-browser-core/target/build"/>
+			<pathelement location="${basedir}/../ldapstudio-browser-ui/target/classes"/>
+			<pathelement location="${basedir}/../ldapstudio-browser-ui/target/build"/>
+	        <pathelement location="target/classes"/>
+		</path>
+				
+	</target>
+	
+	<!-- ================================== -->
+	<!--             COMPILE                -->
+	<!-- ================================== -->
+	<target name="compile" depends="resolve,checkclasses,build-classpath" unless="classes-up2date" description="Compiles the plugin">
+		
+		<mkdir dir="${project.build}" />
+		<copy todir="${project.build}">
+			<fileset dir="${basedir}">
+				<include name="plugin.xml" />
+				<include name="plugin.properties" />
+			</fileset>
+		</copy>
+		<mkdir dir="${project.build}/${lib.dir}" />
+		<copy todir="${project.build}/${lib.dir}">
+			<fileset dir="${basedir}/${lib.dir}">
+				<include name="*.jar" />
+			</fileset>
+		</copy>		
+		<mkdir dir="${project.build}/META-INF" />
+		<copy todir="${project.build}/META-INF">
+			<fileset dir="${basedir}/META-INF">
+				<include name="**" />
+			</fileset>
+		</copy>
+		<mkdir dir="${project.build}/resources" />
+		<copy todir="${project.build}/resources">
+			<fileset dir="${basedir}/resources">
+				<include name="**" />
+			</fileset>
+		</copy>
+			
+		<javac
+			source="1.5"
+			debug="yes"
+			srcdir="${project.src}"
+			excludes=""
+			destdir="${project.build}"
+			classpathref="classpath"
+			listfiles="yes" verbose="false" />
+
+		<tstamp>
+			<format pattern="yyyy-MMM-dd, HH:mm 'GMT'Z" property="timestamp" locale="en" />
+		</tstamp>
+		<echo message="${project.name}-${project.version} compiled ${timestamp} by ${user.name}" file="${project.build}/compile.timestamp" />
+	</target>
+
+	<target name="checkclasses">
+		<uptodate property="classes-up2date" targetfile="${project.build}/compile.timestamp">
+			<srcfiles dir="${project.src}" />
+		</uptodate>
+	</target>
+
+	<!-- ================================== -->
+	<!--              JAVADOC               -->
+	<!-- ================================== -->
+	<target name="javadoc" description="Generate Javadoc files">
+		<mkdir dir="${basedir}/doc" />
+		<javadoc destdir="${basedir}/doc">
+			<fileset dir="src/main/java" defaultexcludes="yes">
+				<include name="org/apache/directory/ldapstudio/**/*.java"/>
+			</fileset>
+		</javadoc>
+	</target>
+	
+	<!-- ================================== -->
+	<!--              JAR                   -->
+	<!-- ================================== -->
+	<target name="jar" description="Creates jar file" depends="compile">
+		<jar destfile="${project.output}/${project.name}_${project.version}.jar" manifest="${project.build}/META-INF/MANIFEST.MF">
+			<fileset dir="${project.build}" excludes="compile.timestamp" />
+		</jar>
+	</target>
+
+	<!-- ================================== -->
+	<!--               CLEAN                -->
+	<!-- ================================== -->
+	<target name="clean" description="Deletes any generated file (javadoc, classes, jars, distribution)">
+		<delete includeemptydirs="true">
+			<fileset dir="${basedir}">
+				<exclude name=".classpath"/>
+				<exclude name=".project"/>
+				<exclude name="build.properties"/>
+				<exclude name="build.xml"/>
+				<exclude name="ivy.xml"/>
+				<exclude name="plugin.xml"/>
+				<exclude name="META-INF/**"/>
+				<exclude name="src/**" />
+				<exclude name="resources**"/>
+			</fileset>
+		</delete>
+	</target>
+</project>

Added: directory/ldapstudio/trunk/ldapstudio-proxy/ivy.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/ivy.xml?view=auto&rev=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/ivy.xml (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/ivy.xml Fri Feb 23 08:01:07 2007
@@ -0,0 +1,24 @@
+<!--
+  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.
+-->
+<ivy-module version="1.0">
+	<info organisation="org.apache.directory.ldapstudio" module="ldapstudio-proxy"/>
+	<dependencies>
+		<dependency org="org.apache.directory.shared" name="shared-ldap" rev="0.9.6-SNAPSHOT"/>
+    </dependencies>
+</ivy-module>
\ No newline at end of file

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml Fri Feb 23 08:01:07 2007
@@ -24,11 +24,13 @@
       <view
             allowMultiple="false"
             class="org.apache.directory.ldapstudio.proxy.view.ProxyView"
+            icon="resources/icons/proxy_view.png"
             id="org.apache.directory.ldapstudio.proxy.view.ProxyView"
             name="Proxy"/>
       <view
             allowMultiple="false"
             class="org.apache.directory.ldapstudio.proxy.view.LdapMessageView"
+            icon="resources/icons/ldap-message_view.png"
             id="org.apache.directory.ldapstudio.proxy.view.LdapMessageView"
             name="LDAP Message"/>
    </extension>
@@ -37,6 +39,6 @@
       <perspective
             class="org.apache.directory.ldapstudio.proxy.view.Perspective"
             icon="resources/icons/perspective.png"
-            id="org.apache.directory.ldapstudio.proxy.perpective"
+            id="org.apache.directory.ldapstudio.proxy.perspective"
             name="LDAP Proxy"/>
    </extension></plugin>

Added: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/in.png
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/in.png?view=auto&rev=510997
==============================================================================
Binary file - no diff available.

Propchange: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/in.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/ldap-message_view.png
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/ldap-message_view.png?view=auto&rev=510997
==============================================================================
Binary file - no diff available.

Propchange: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/ldap-message_view.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/out.png
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/out.png?view=auto&rev=510997
==============================================================================
Binary file - no diff available.

Propchange: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/out.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/perspective.png
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/perspective.png?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
Binary files - no diff available.

Added: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/proxy_view.png
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/proxy_view.png?view=auto&rev=510997
==============================================================================
Binary file - no diff available.

Propchange: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/proxy_view.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/Activator.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/Activator.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/Activator.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/Activator.java Fri Feb 23 08:01:07 2007
@@ -17,7 +17,6 @@
  *  under the License. 
  *  
  */
-
 package org.apache.directory.ldapstudio.proxy;
 
 
@@ -34,7 +33,7 @@
 public class Activator extends AbstractUIPlugin
 {
     /** The plug-in ID */
-    public static final String PLUGIN_ID = "org.apache.directory.ldapstudio.proxy"; //$NON-NLS-1$
+    public static final String PLUGIN_ID = ProxyConstants.PLUGIN_ID; //$NON-NLS-1$
 
     /** The shared instance */
     private static Activator plugin;

Added: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/ProxyConstants.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/ProxyConstants.java?view=auto&rev=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/ProxyConstants.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/ProxyConstants.java Fri Feb 23 08:01:07 2007
@@ -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.proxy;
+
+
+/**
+ * This class contains all the constants used by the Proxy Plugin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ProxyConstants
+{
+    /** The plugin ID */
+    public static final String PLUGIN_ID = "org.apache.directory.ldapstudio.proxy";
+    
+    /** The size of the Dialog History */
+    public static final int DIALOG_HISTORY_SIZE = 20;
+
+    /** The dialog setting key for Proxy Port History */
+    public static final String DIALOGSETTING_KEY_PROXY_PORT_HISTORY = "proxyPortHistory";
+
+    /** The dialog setting key for Server Host History */
+    public static final String DIALOGSETTING_KEY_SERVER_HOST_HISTORY = "serverHostHistory";
+
+    /** The dialog setting key for Server Port History */
+    public static final String DIALOGSETTING_KEY_SERVER_PORT_HISTORY = "serverPortHistory";
+
+    /** The dialog setting value for Use Connection */
+    public static final String DIALOGSETTING_KEY_SERVER_USE_CONNECTION = "useConnection";
+}

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/LdapMessageViewController.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/LdapMessageViewController.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/LdapMessageViewController.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/LdapMessageViewController.java Fri Feb 23 08:01:07 2007
@@ -21,7 +21,6 @@
 
 
 import org.apache.directory.ldapstudio.proxy.view.LdapMessageView;
-import org.eclipse.jface.action.IToolBarManager;
 
 
 /**

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/ProxyViewController.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/ProxyViewController.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/ProxyViewController.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/ProxyViewController.java Fri Feb 23 08:01:07 2007
@@ -22,6 +22,7 @@
 
 import org.apache.directory.ldapstudio.proxy.controller.actions.ConnectAction;
 import org.apache.directory.ldapstudio.proxy.controller.actions.DisconnectAction;
+import org.apache.directory.ldapstudio.proxy.model.LdapProxy;
 import org.apache.directory.ldapstudio.proxy.view.ProxyView;
 import org.eclipse.jface.action.IToolBarManager;
 
@@ -37,6 +38,9 @@
     /** The associated view */
     private ProxyView view;
 
+    /** The LDAP Proxy */
+    private LdapProxy ldapProxy;
+
     // Actions
     private ConnectAction connect;
     private DisconnectAction disconnect;
@@ -62,8 +66,8 @@
      */
     private void initActions()
     {
-        connect = new ConnectAction();
-        disconnect = new DisconnectAction();
+        connect = new ConnectAction( view );
+        disconnect = new DisconnectAction( view );
     }
 
 
@@ -75,5 +79,48 @@
         IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
         toolbar.add( connect );
         toolbar.add( disconnect );
+    }
+
+
+    /**
+     * Gets the LDAP Proxy.
+     *
+     * @return
+     *      the LDAP Proxy
+     */
+    public LdapProxy getLdapProxy()
+    {
+        return ldapProxy;
+    }
+
+
+    /**
+     * Sets the LDAP Proxy.
+     *
+     * @param ldapProxy
+     *      the LDAP Proxy to set
+     */
+    public void setLdapProxy( LdapProxy ldapProxy )
+    {
+        this.ldapProxy = ldapProxy;
+        updateActions();
+    }
+
+
+    /**
+     * Enables/Disables Actions.
+     */
+    private void updateActions()
+    {
+        if ( ldapProxy == null )
+        {
+            connect.setEnabled( true );
+            disconnect.setEnabled( false );
+        }
+        else
+        {
+            connect.setEnabled( false );
+            disconnect.setEnabled( true );
+        }
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/ConnectAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/ConnectAction.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/ConnectAction.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/ConnectAction.java Fri Feb 23 08:01:07 2007
@@ -19,14 +19,21 @@
  */
 package org.apache.directory.ldapstudio.proxy.controller.actions;
 
+
+import java.io.IOException;
+
 import org.apache.directory.ldapstudio.proxy.Activator;
+import org.apache.directory.ldapstudio.proxy.model.LdapProxy;
 import org.apache.directory.ldapstudio.proxy.view.IImageKeys;
+import org.apache.directory.ldapstudio.proxy.view.ProxyView;
 import org.apache.directory.ldapstudio.proxy.view.wizards.ConnectWizard;
 import org.eclipse.jface.action.Action;
+import org.eclipse.jface.window.Window;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 
+
 /**
  * This class implements the Connect action.
  *
@@ -35,28 +42,50 @@
  */
 public class ConnectAction extends Action
 {
+    /** The associated view */
+    private ProxyView view;
+
+
     /**
      * Creates a new instance of ConnectAction.
+     *
+     * @param view
+     *      the associated view
      */
-    public ConnectAction()
+    public ConnectAction( ProxyView view )
     {
-        super( "Connect");
+        super( "Connect" );
         setToolTipText( getText() );
-        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.CONNECT )  );
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.CONNECT ) );
         setEnabled( true );
+        this.view = view;
     }
-    
+
 
     /* (non-Javadoc)
      * @see org.eclipse.jface.action.Action#run()
      */
     public void run()
     {
-        WizardDialog dialog = new WizardDialog(
-            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), new ConnectWizard() );
+        ConnectWizard connectWizard = new ConnectWizard();
+
+        WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+            connectWizard );
         dialog.create();
-        dialog.open();
-        
-        super.run();
+        if ( dialog.open() == Window.OK )
+        {
+            LdapProxy ldapProxy = new LdapProxy( connectWizard.getLocalPort(), connectWizard.getRemoteHost(),
+                connectWizard.getRemotePort() );
+            view.getController().setLdapProxy( ldapProxy );
+            try
+            {
+                ldapProxy.connect();
+            }
+            catch ( IOException e )
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/DisconnectAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/DisconnectAction.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/DisconnectAction.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/DisconnectAction.java Fri Feb 23 08:01:07 2007
@@ -22,6 +22,7 @@
 
 import org.apache.directory.ldapstudio.proxy.Activator;
 import org.apache.directory.ldapstudio.proxy.view.IImageKeys;
+import org.apache.directory.ldapstudio.proxy.view.ProxyView;
 import org.eclipse.jface.action.Action;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 
@@ -34,14 +35,32 @@
  */
 public class DisconnectAction extends Action
 {
+    /** The associated view */
+    private ProxyView view;
+
+
     /**
      * Creates a new instance of DisconnectAction.
+     * 
+     * @param view
+     *      the associated view
      */
-    public DisconnectAction()
+    public DisconnectAction( ProxyView view )
     {
         super( "Disconnect" );
         setToolTipText( getText() );
         setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.DISCONNECT ) );
-        setEnabled( true );
+        setEnabled( false );
+        this.view = view;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    public void run()
+    {
+        view.getController().getLdapProxy().disconnect();
+        view.getController().setLdapProxy( null );
     }
 }

Added: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxy.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxy.java?view=auto&rev=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxy.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxy.java Fri Feb 23 08:01:07 2007
@@ -0,0 +1,105 @@
+/*
+ *  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.proxy.model;
+
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * This class implements a LDAP Proxy
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapProxy
+{
+    /** Default timeout in milli seconds */
+    public static final int DEFAULT_TIMEOUT = 30000;
+
+    /** The listeners list */
+    private List<LdapProxyListener> listeners;
+
+    private LdapProxyThread proxyThread;
+
+
+    /**
+     * Creates a new instance of LdapProxy.
+     *
+     * @param localPort
+     *      the local port
+     * @param remoteHost
+     *      the host name of the LDAP Server
+     * @param remotePort
+     *      the port of the LDAP Server
+     */
+    public LdapProxy( int localPort, String remoteHost, int remotePort )
+    {
+        listeners = new ArrayList<LdapProxyListener>();
+
+        proxyThread = new LdapProxyThread( localPort, remoteHost, remotePort, DEFAULT_TIMEOUT );
+    }
+
+
+    /**
+     * Connects the LDAP Proxy.
+     *
+     * @throws IOException
+     */
+    public void connect() throws IOException
+    {
+        proxyThread.start();
+    }
+
+
+    /**
+     * Disconnects the LDAP Proxy.
+     */
+    public void disconnect()
+    {
+        proxyThread.interrupt();
+    }
+
+
+    /**
+     * Adds a LDAP Proxy Listener.
+     *
+     * @param listener
+     *      the listener to add
+     */
+    public void addListener( LdapProxyListener listener )
+    {
+        listeners.add( listener );
+    }
+
+
+    /**
+     * Removes the LDAP Proxy Listener.
+     *
+     * @param listener
+     *      the listener to remove
+     */
+    public void removeListener( LdapProxyListener listener )
+    {
+        listeners.remove( listener );
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyListener.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyListener.java?view=auto&rev=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyListener.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyListener.java Fri Feb 23 08:01:07 2007
@@ -0,0 +1,31 @@
+/*
+ *  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.proxy.model;
+
+
+/**
+ * This interface defines a LDAP Proxy Listener.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface LdapProxyListener
+{
+}

Added: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyThread.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyThread.java?view=auto&rev=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyThread.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/model/LdapProxyThread.java Fri Feb 23 08:01:07 2007
@@ -0,0 +1,285 @@
+/*
+ *  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.proxy.model;
+
+
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.nio.ByteBuffer;
+import java.util.Date;
+
+
+/**
+ * This class implements the thread for LDAP Proxy.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapProxyThread extends Thread
+{
+    /** The proxy port */
+    private int localPort;
+
+    /** The LDAP Server hostname */
+    private String remoteHost;
+
+    /** The LDAP Server port */
+    private int remotePort;
+
+    /** The timeout */
+    private long timeout;
+
+    /** The client socket */
+    private Socket cSocket;
+
+    /** The last message ID */
+    private int lastMessageId = -1;
+
+
+    /**
+     * Creates a new instance of LdapProxyThread.
+     *
+     * @param localPort
+     * @param remoteHost
+     * @param remotePort
+     * @param timeout
+     * @param cSocket
+     */
+    public LdapProxyThread( int localPort, String remoteHost, int remotePort, long timeout )
+    {
+        this.localPort = localPort;
+        this.remoteHost = remoteHost;
+        this.remotePort = remotePort;
+        this.timeout = timeout;
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Thread#run()
+     */
+    public void run()
+    {
+        try
+        {
+            ServerSocket sSocket = new ServerSocket( localPort );
+            cSocket = sSocket.accept();
+
+            if ( cSocket != null )
+            {
+                InputStream clientIn = null;
+                OutputStream clientOut = null;
+                InputStream serverIn = null;
+                OutputStream serverOut = null;
+                Socket toServer = null;
+                int r0 = -1;
+                int r1 = -1;
+                int ch = -1;
+                int i = -1;
+                long time0 = System.currentTimeMillis();
+                long time1 = time0 + timeout;
+
+                try
+                {
+                    toServer = new Socket( remoteHost, remotePort );
+                    System.out.println( "open connection to:" + toServer + "(timeout=" + timeout + " ms)" );
+                    clientIn = cSocket.getInputStream();
+                    clientOut = new BufferedOutputStream( cSocket.getOutputStream() );
+                    serverIn = toServer.getInputStream();
+                    serverOut = new BufferedOutputStream( toServer.getOutputStream() );
+
+                    while ( r0 != 0 || r1 != 0 || ( time1 - time0 ) <= timeout )
+                    {
+                        r0 = clientIn.available();
+
+                        if ( r0 != 0 )
+                        {
+                            System.out.println( "" );
+                            // LdapProxy.setTextIn("<<<" + r0 + " bytes from client
+                            // \n","red");
+                            System.out.println( "" );
+                            System.out.println( "<<<" + r0 + " bytes from client" );
+                            System.out.println( "<<<" + r1 + " bytes from server" );
+                        }
+
+                        ByteBuffer bb = null;
+
+                        while ( ( r0 = clientIn.available() ) > 0 )
+                        {
+                            byte[] in = new byte[r0];
+                            int k = 0;
+
+                            for ( i = 0; i < r0; i++ )
+                            {
+                                ch = clientIn.read();
+
+                                if ( ch != -1 )
+                                {
+                                    in[k++] = ( byte ) ch;
+                                    serverOut.write( ch );
+                                }
+                                else
+                                {
+                                    System.out.println( "client stream closed" );
+                                    // LdapProxy.setTextIn("client stream closed
+                                    // \n","redbold");
+                                }
+                            }
+
+                            bb = ByteBuffer.allocate( r0 );
+                            bb.put( in );
+                            bb.flip();
+
+                            //                    while ( bb.hasRemaining() )
+                            //                    {
+                            //                        decode( bb );
+                            //                    }
+
+                            /*
+                             * LdapProxy.setTextIn("--->>>\n", "regular");
+                             * LdapProxy.setTextIn(result, "regular");
+                             * LdapProxy.setTextIn("----------------------------------\n",
+                             * "regular");
+                             */
+
+                            time0 = System.currentTimeMillis();
+                            serverOut.flush();
+                        }
+
+                        bb = null;
+
+                        while ( ( r1 = serverIn.available() ) > 0 )
+                        {
+                            System.out.println( "" );
+                            System.out.println( ">>>" + r1 + " bytes from server" );
+                            // LdapProxy.setTextOut(">>>" + r1 + " bytes from server
+                            // \n","red");
+                            System.out.println( "" );
+                            System.out.println( ">>>" + r1 + " bytes from server" );
+
+                            byte[] out = new byte[r1];
+                            int k = 0;
+
+                            for ( i = 0; i < r1; i++ )
+                            {
+                                ch = serverIn.read();
+
+                                if ( ch != -1 )
+                                {
+                                    out[k++] = ( byte ) ch;
+                                }
+                                else
+                                {
+                                    System.out.println( "server stream closed" );
+                                    // LdapProxy.setTextOut("server stream closed
+                                    // \n","redbold");
+                                    break;
+                                }
+
+                                clientOut.write( ch );
+                            }
+
+                            bb = ByteBuffer.allocate( r1 );
+                            bb.put( out );
+                            bb.flip();
+
+                            //                    while ( true )
+                            //                    {
+                            //                        try
+                            //                        {
+                            //                            String result = decode( bb );
+                            //                            System.out.println( result );
+                            //                            /*
+                            //                             * LdapProxy.setTextOut("<<<---\n", "blue");
+                            //                             * LdapProxy.setTextOut(result, "blue");
+                            //                             * LdapProxy.setTextOut("----------------------------------\n",
+                            //                             * "regular");
+                            //                             */
+                            //                            if ( bb.hasRemaining() == false )
+                            //                            {
+                            //                                break;
+                            //                            }
+                            //                        }
+                            //                        catch ( DecoderException de )
+                            //                        {
+                            //                            StringBuffer result = new StringBuffer();
+                            //                            result.append( de.getMessage() ).append( '\n' );
+                            //
+                            //                            byte[] tmp = new byte[out.length - bb.position()];
+                            //                            System.arraycopy( out, bb.position(), tmp, 0, out.length - bb.position() );
+                            //                            result.append( StringUtils.dumpBytes( tmp ) );
+                            //
+                            //                            System.out.println( result );
+                            //                            /*
+                            //                             * LdapProxy.setTextOut("<<<---\n", "regular");
+                            //                             * LdapProxy.setTextOut(new String(tmp), "regular");
+                            //                             * LdapProxy.setTextOut("----------------------------------\n",
+                            //                             * "regular");
+                            //                             */
+                            //                            break;
+                            //                        }
+                            //                    }
+
+                            time0 = new Date().getTime();
+                            clientOut.flush();
+                        }
+                        if ( r0 == 0 && r1 == 0 )
+                        {
+                            time1 = new Date().getTime();
+                            Thread.sleep( 100 );
+                            // Proxy.display("waiting:"+(time1-time0)+" ms");
+                        }
+                    }
+                }
+                catch ( Throwable t )
+                {
+                    System.out.println( "i=" + i + " ch=" + ch );
+                    t.printStackTrace( System.err );
+                }
+                finally
+                {
+                    try
+                    {
+                        clientIn.close();
+                        clientOut.close();
+                        serverIn.close();
+                        serverOut.close();
+                        cSocket.close();
+                        toServer.close();
+                        //                LdapProxy.quit( time1 - time0 );
+                    }
+                    catch ( Exception e )
+                    {
+                        e.printStackTrace( System.err );
+                    }
+                }
+            }
+        }
+        catch ( IOException e1 )
+        {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+        }
+
+    }
+}

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/BaseWidgetUtils.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/BaseWidgetUtils.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/BaseWidgetUtils.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/BaseWidgetUtils.java Fri Feb 23 08:01:07 2007
@@ -17,7 +17,6 @@
  *  under the License. 
  *  
  */
-
 package org.apache.directory.ldapstudio.proxy.view;
 
 
@@ -38,9 +37,14 @@
 import org.eclipse.swt.widgets.Text;
 
 
+/**
+ * This class is a helper class that is used to create widgets.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class BaseWidgetUtils
 {
-
     public static Group createGroup( Composite parent, String label, int span )
     {
         Group group = new Group( parent, SWT.NONE );
@@ -306,5 +310,4 @@
         link.setLayoutData( gd );
         return link;
     }
-
 }

Added: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/HistoryUtils.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/HistoryUtils.java?view=auto&rev=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/HistoryUtils.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/HistoryUtils.java Fri Feb 23 08:01:07 2007
@@ -0,0 +1,74 @@
+/*
+ *  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.proxy.view;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.proxy.Activator;
+import org.apache.directory.ldapstudio.proxy.ProxyConstants;
+
+
+/**
+ * This class is used to load and save Dialog History.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class HistoryUtils
+{
+    public static void save( String key, String value )
+    {
+        // get current history
+        String[] history = load( key );
+        List<String> list = new ArrayList<String>( Arrays.asList( history ) );
+
+        // add new value or move to first position
+        if ( list.contains( value ) )
+        {
+            list.remove( value );
+        }
+        list.add( 0, value );
+
+        // check history size
+        while ( list.size() > ProxyConstants.DIALOG_HISTORY_SIZE )
+        {
+            list.remove( list.size() - 1 );
+        }
+
+        // save
+        history = ( String[] ) list.toArray( new String[list.size()] );
+        Activator.getDefault().getDialogSettings().put( key, history );
+
+    }
+
+
+    public static String[] load( String key )
+    {
+        String[] history = Activator.getDefault().getDialogSettings().getArray( key );
+        if ( history == null )
+        {
+            history = new String[0];
+        }
+        return history;
+    }
+}

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/IImageKeys.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/IImageKeys.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/IImageKeys.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/IImageKeys.java Fri Feb 23 08:01:07 2007
@@ -31,4 +31,8 @@
     // Images for Actions
     public static final String CONNECT = "resources/icons/connect.gif"; //$NON-NLS-1$
     public static final String DISCONNECT = "resources/icons/disconnect.gif"; //$NON-NLS-1$
+
+    // Images for Views
+    public static final String IN = "resources/icons/in.png";
+    public static final String OUT = "resources/icons/out.png";
 }

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/LdapMessageView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/LdapMessageView.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/LdapMessageView.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/LdapMessageView.java Fri Feb 23 08:01:07 2007
@@ -38,7 +38,7 @@
 {
     /** The view ID*/
     public static final String ID = Activator.PLUGIN_ID + ".view.LdapMessageView";
-    
+
     /** The Source Viewer */
     private SourceViewer sourceViewer;
 

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/Perspective.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/Perspective.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/Perspective.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/Perspective.java Fri Feb 23 08:01:07 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.ldapstudio.proxy.view;
 
 
+import org.apache.directory.ldapstudio.proxy.Activator;
 import org.eclipse.ui.IPageLayout;
 import org.eclipse.ui.IPerspectiveFactory;
 
@@ -32,6 +33,10 @@
  */
 public class Perspective implements IPerspectiveFactory
 {
+    /** The Perspective ID */
+    public static final String ID = Activator.PLUGIN_ID + ".perspective"; //$NON-NLS-1$
+
+
     /* (non-Javadoc)
      * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
      */
@@ -45,5 +50,14 @@
 
         layout.addStandaloneView( LdapMessageView.ID, true, IPageLayout.RIGHT, 0.5f, ProxyView.ID );
         layout.getViewLayout( LdapMessageView.ID ).setCloseable( false );
+
+        // Perspective shortcuts
+        layout.addPerspectiveShortcut( "org.apache.directory.ldapstudio.browser.ui.perspective.BrowserPerspective" );
+        layout.addPerspectiveShortcut( "org.apache.directory.ldapstudio.schemas.perspective" );
+        layout.addPerspectiveShortcut( Perspective.ID );
+
+        // View shortcuts
+        layout.addShowViewShortcut( ProxyView.ID );
+        layout.addShowViewShortcut( LdapMessageView.ID );
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/ProxyView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/ProxyView.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/ProxyView.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/ProxyView.java Fri Feb 23 08:01:07 2007
@@ -22,10 +22,12 @@
 
 import org.apache.directory.ldapstudio.proxy.Activator;
 import org.apache.directory.ldapstudio.proxy.controller.ProxyViewController;
-import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
 import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
 
 
 /**
@@ -39,8 +41,11 @@
     /** The view ID*/
     public static final String ID = Activator.PLUGIN_ID + ".view.ProxyView";
 
+    /** The controller */
+    private ProxyViewController controller;
+
     /** The tree viewer */
-    private TreeViewer viewer;
+    private Tree viewer;
 
 
     /* (non-Javadoc)
@@ -48,9 +53,50 @@
      */
     public void createPartControl( Composite parent )
     {
-        viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
-        
-        new ProxyViewController( this );
+        viewer = new Tree( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
+        controller = new ProxyViewController( this );
+
+        // TODO Remove
+        TreeItem treeItem = new TreeItem( viewer, SWT.NONE );
+        treeItem.setText( "Bind [id=1]" );
+
+        treeItem = new TreeItem( treeItem, SWT.NONE );
+        treeItem.setText( "Bind Request" );
+        treeItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.IN )
+            .createImage() );
+
+        treeItem = new TreeItem( viewer.getTopItem(), SWT.NONE );
+        treeItem.setText( "Bind Response" );
+        treeItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.OUT )
+            .createImage() );
+
+        TreeItem treeItem2 = new TreeItem( viewer, SWT.NONE );
+        treeItem2.setText( "Search [id=2]" );
+
+        treeItem = new TreeItem( treeItem2, SWT.NONE );
+        treeItem.setText( "Search Request" );
+        treeItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.IN )
+            .createImage() );
+
+        treeItem = new TreeItem( treeItem2, SWT.NONE );
+        treeItem.setText( "Search Result Entry" );
+        treeItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.OUT )
+            .createImage() );
+
+        treeItem = new TreeItem( treeItem2, SWT.NONE );
+        treeItem.setText( "Search Result Entry" );
+        treeItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.OUT )
+            .createImage() );
+
+        treeItem = new TreeItem( treeItem2, SWT.NONE );
+        treeItem.setText( "Search Result Entry" );
+        treeItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.OUT )
+            .createImage() );
+
+        treeItem = new TreeItem( treeItem2, SWT.NONE );
+        treeItem.setText( "Search Result Done" );
+        treeItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.OUT )
+            .createImage() );
     }
 
 
@@ -59,6 +105,12 @@
      */
     public void setFocus()
     {
-        viewer.getControl().setFocus();
+        viewer.setFocus();
+    }
+
+
+    public ProxyViewController getController()
+    {
+        return controller;
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizard.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizard.java?view=diff&rev=510997&r1=510996&r2=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizard.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizard.java Fri Feb 23 08:01:07 2007
@@ -20,7 +20,11 @@
 package org.apache.directory.ldapstudio.proxy.view.wizards;
 
 
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.internal.util.BundleUtility;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
 
 
 /**
@@ -32,7 +36,20 @@
 public class ConnectWizard extends Wizard
 {
     /** The Settings page*/
-    private ConnectWizardSettingsPage settings;
+    private ConnectWizardBrowserAvailablePage browserAvailablePage;
+    private ConnectWizardBrowserNotAvailablePage browserNotAvailablePage;
+
+    /** The availability of the BrowserPlugin */
+    private boolean isBrowserPluginAvailable;
+
+    /** The proxy port */
+    private int localPort = 0;
+
+    /** The LDAP Server hostname */
+    private String remoteHost = "";
+
+    /** The LDAP Server port */
+    private int remotePort = 0;
 
 
     /* (non-Javadoc)
@@ -40,8 +57,30 @@
      */
     public void addPages()
     {
-        settings = new ConnectWizardSettingsPage();
-        addPage( settings );
+        isBrowserPluginAvailable = isBrowserPluginAvailable();
+
+        if ( isBrowserPluginAvailable )
+        {
+            browserAvailablePage = new ConnectWizardBrowserAvailablePage();
+            addPage( browserAvailablePage );
+        }
+        else
+        {
+            browserNotAvailablePage = new ConnectWizardBrowserNotAvailablePage();
+            addPage( browserNotAvailablePage );
+        }
+    }
+
+
+    /**
+     * Checks if the Browser Plugin is available.
+     *
+     * @return
+     *      true if the Browser Plugin is available, false if not
+     */
+    private boolean isBrowserPluginAvailable()
+    {
+        return ( isPluginAvailable( "org.apache.directory.ldapstudio.browser.core" ) && isPluginAvailable( "org.apache.directory.ldapstudio.browser.core" ) );
     }
 
 
@@ -50,6 +89,95 @@
      */
     public boolean performFinish()
     {
-        return false;
+        if ( isBrowserPluginAvailable )
+        {
+            browserAvailablePage.saveDialogHistory();
+            localPort = browserAvailablePage.getLocalPort();
+            remoteHost = browserAvailablePage.getRemoteHost();
+            remotePort = browserAvailablePage.getRemotePort();
+        }
+        else
+        {
+            browserNotAvailablePage.saveDialogHistory();
+            localPort = browserNotAvailablePage.getLocalPort();
+            remoteHost = browserNotAvailablePage.getRemoteHost();
+            remotePort = browserNotAvailablePage.getRemotePort();
+        }
+
+        return true;
+    }
+
+
+    /**
+     * Checks if the given plugin is available (installed and active).
+     * The plugin is actived if it's not already active.
+     *
+     * @param bundleId
+     *      the id of the plugin
+     * @return
+     *      true if the given plugin is available, false if not.
+     */
+    public boolean isPluginAvailable( String bundleId )
+    {
+        Bundle pluginBundle = Platform.getBundle( bundleId );
+
+        if ( pluginBundle == null )
+        {
+            return false;
+        }
+
+        if ( BundleUtility.isActive( pluginBundle ) )
+        {
+            return true;
+        }
+        else
+        {
+            try
+            {
+                pluginBundle.start();
+            }
+            catch ( BundleException e )
+            {
+                return false;
+            }
+
+            return BundleUtility.isActive( pluginBundle );
+        }
+    }
+
+
+    /**
+     * Gets the local port defined by the user.
+     * 
+     * @return
+     *      the local port defined by the user
+     */
+    public int getLocalPort()
+    {
+        return localPort;
+    }
+
+
+    /**
+     * Gets the remote host defined by the user.
+     *
+     * @return
+     *      the remote host defined by the user
+     */
+    public String getRemoteHost()
+    {
+        return remoteHost;
+    }
+
+
+    /**
+     * Gets the remote port defined by the user.
+     *
+     * @return
+     *      the remote port defined by the user
+     */
+    public int getRemotePort()
+    {
+        return remotePort;
     }
 }

Added: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserAvailablePage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserAvailablePage.java?view=auto&rev=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserAvailablePage.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserAvailablePage.java Fri Feb 23 08:01:07 2007
@@ -0,0 +1,446 @@
+/*
+ *  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.proxy.view.wizards;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.SelectConnectionDialog;
+import org.apache.directory.ldapstudio.proxy.Activator;
+import org.apache.directory.ldapstudio.proxy.ProxyConstants;
+import org.apache.directory.ldapstudio.proxy.view.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.proxy.view.HistoryUtils;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.util.BundleUtility;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+
+/**
+ * This class implements the Connect Wizard Settings Page.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectWizardBrowserAvailablePage extends WizardPage implements ModifyListener, SelectionListener
+{
+    /** The choosen Connection */
+    private IConnection selectedConnection;
+
+    // UI Fields
+    private Combo proxyPortCombo;
+    private Button useConnectionButton;
+    private Text connectionText;
+    private Button connectionButton;
+    private Button useThisSettingsButton;
+    private Combo serverHostCombo;
+    private Combo serverPortCombo;
+
+
+    /**
+     * Creates a new instance of ConnectWizardSettingsPage.
+     */
+    public ConnectWizardBrowserAvailablePage()
+    {
+        super( ConnectWizardBrowserAvailablePage.class.getName() );
+        setTitle( "Connect Wizard" );
+        setDescription( "Specify the settings for the LDAP Proxy." );
+        setPageComplete( false );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+
+        Group proxyGroup = BaseWidgetUtils.createGroup( composite, "LDAP Proxy", 1 );
+        proxyGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+        Composite proxyGroupComposite = BaseWidgetUtils.createColumnContainer( proxyGroup, 2, 1 );
+
+        BaseWidgetUtils.createLabel( proxyGroupComposite, "Proxy port:", 1 );
+        proxyPortCombo = BaseWidgetUtils.createCombo( proxyGroupComposite, new String[0], -1, 1 );
+        proxyPortCombo.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) )
+                {
+                    e.doit = false;
+                }
+                if ( serverPortCombo.getText().length() > 4 && e.text.length() > 0 )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        Group serverGroup = BaseWidgetUtils.createGroup( composite, "LDAP Server", 1 );
+        serverGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+        useConnectionButton = BaseWidgetUtils.createRadiobutton( serverGroup,
+            "Use settings from an existing connection:", 1 );
+
+        Composite connectionComposite = BaseWidgetUtils.createColumnContainer( serverGroup, 4, 1 );
+
+        BaseWidgetUtils.createRadioIndent( connectionComposite, 1 );
+        BaseWidgetUtils.createLabel( connectionComposite, "Connection:", 1 );
+        connectionText = BaseWidgetUtils.createReadonlyText( connectionComposite, "", 1 );
+        connectionButton = BaseWidgetUtils.createButton( connectionComposite, "B&rowse...", 1 );
+
+        Label connectionInformationLabel = BaseWidgetUtils.createLabel( connectionComposite,
+            "(Warning: This feature requires the LDAP Browser Plugin.)", 1 );
+        connectionInformationLabel.setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, true, false, 4, 1 ) );
+
+        useThisSettingsButton = BaseWidgetUtils.createRadiobutton( serverGroup, "Use this settings:", 1 );
+
+        Composite settingsComposite = BaseWidgetUtils.createColumnContainer( serverGroup, 3, 1 );
+        BaseWidgetUtils.createRadioIndent( settingsComposite, 1 );
+        BaseWidgetUtils.createLabel( settingsComposite, "Hostname:", 1 );
+        serverHostCombo = BaseWidgetUtils.createCombo( settingsComposite, new String[0], -1, 1 );
+
+        BaseWidgetUtils.createRadioIndent( settingsComposite, 1 );
+        BaseWidgetUtils.createLabel( settingsComposite, "Port:", 1 );
+        serverPortCombo = BaseWidgetUtils.createCombo( settingsComposite, new String[0], -1, 1 );
+        serverPortCombo.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) )
+                {
+                    e.doit = false;
+                }
+                if ( serverPortCombo.getText().length() > 4 && e.text.length() > 0 )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        setControl( parent );
+
+        checkBrowserPluginAvailability();
+        loadDialogHistory();
+        initListeners();
+        setUiEnableState();
+    }
+
+
+    private void checkBrowserPluginAvailability()
+    {
+        if ( !isPluginAvailable( "org.apache.directory.ldapstudio.browser.core" )
+            || !isPluginAvailable( "org.apache.directory.ldapstudio.browser.ui" ) )
+        {
+            useConnectionButton.setEnabled( false );
+            connectionButton.setEnabled( false );
+            connectionText.setEnabled( false );
+        }
+    }
+
+
+    /**
+     * Loads the last values entered by the user from the Dialog History.
+     */
+    private void loadDialogHistory()
+    {
+        proxyPortCombo.setItems( HistoryUtils.load( ProxyConstants.DIALOGSETTING_KEY_PROXY_PORT_HISTORY ) );
+        serverHostCombo.setItems( HistoryUtils.load( ProxyConstants.DIALOGSETTING_KEY_SERVER_HOST_HISTORY ) );
+        serverPortCombo.setItems( HistoryUtils.load( ProxyConstants.DIALOGSETTING_KEY_SERVER_PORT_HISTORY ) );
+
+        boolean useConnection = Activator.getDefault().getDialogSettings().getBoolean(
+            ProxyConstants.DIALOGSETTING_KEY_SERVER_USE_CONNECTION );
+        useConnectionButton.setSelection( useConnection );
+        useThisSettingsButton.setSelection( !useConnection );
+    }
+
+
+    /**
+     * Saves the values entered by the user in the Dialog History.
+     */
+    public void saveDialogHistory()
+    {
+        HistoryUtils.save( ProxyConstants.DIALOGSETTING_KEY_PROXY_PORT_HISTORY, proxyPortCombo.getText() );
+        HistoryUtils.save( ProxyConstants.DIALOGSETTING_KEY_SERVER_HOST_HISTORY, serverHostCombo.getText() );
+        HistoryUtils.save( ProxyConstants.DIALOGSETTING_KEY_SERVER_PORT_HISTORY, serverPortCombo.getText() );
+
+        Activator.getDefault().getDialogSettings().put( ProxyConstants.DIALOGSETTING_KEY_SERVER_USE_CONNECTION,
+            useConnectionButton.getSelection() );
+    }
+
+
+    /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        proxyPortCombo.addModifyListener( this );
+        useConnectionButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+                setUiEnableState();
+            }
+        } );
+        connectionButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                SelectConnectionDialog dialog = new SelectConnectionDialog( PlatformUI.getWorkbench()
+                    .getActiveWorkbenchWindow().getShell(), "Select Connection", null );
+                dialog.open();
+                IConnection connection = dialog.getSelectedConnection();
+                setConnection( connection );
+                validate();
+            }
+        } );
+        useThisSettingsButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                validate();
+                setUiEnableState();
+            }
+        } );
+        serverHostCombo.addModifyListener( this );
+        serverPortCombo.addModifyListener( this );
+    }
+
+
+    /**
+     * Enables the UI fields.
+     */
+    private void setUiEnableState()
+    {
+        if ( ( useConnectionButton.isEnabled() ) && ( useConnectionButton.getSelection() ) )
+        {
+            connectionText.setEnabled( true );
+            connectionButton.setEnabled( true );
+            serverHostCombo.setEnabled( false );
+            serverPortCombo.setEnabled( false );
+        }
+        else
+        {
+            connectionText.setEnabled( false );
+            connectionButton.setEnabled( false );
+            serverHostCombo.setEnabled( true );
+            serverPortCombo.setEnabled( true );
+        }
+    }
+
+
+    /**
+     * Checks if the given plugin is available (installed and active).
+     * The plugin is actived if it's not already active.
+     *
+     * @param bundleId
+     *      the id of the plugin
+     * @return
+     *      true if the given plugin is available, false if not.
+     */
+    public boolean isPluginAvailable( String bundleId )
+    {
+        Bundle pluginBundle = Platform.getBundle( bundleId );
+
+        if ( pluginBundle == null )
+        {
+            return false;
+        }
+
+        if ( BundleUtility.isActive( pluginBundle ) )
+        {
+            return true;
+        }
+        else
+        {
+            try
+            {
+                pluginBundle.start();
+            }
+            catch ( BundleException e )
+            {
+                return false;
+            }
+
+            return BundleUtility.isActive( pluginBundle );
+        }
+    }
+
+
+    public void setConnection( IConnection connection )
+    {
+        this.selectedConnection = connection;
+        connectionText.setText( this.selectedConnection != null ? this.selectedConnection.getName() : "" );
+    }
+
+
+    /**
+     * Gets the local port defined by the user.
+     * 
+     * @return
+     *      the local port defined by the user
+     */
+    public int getLocalPort()
+    {
+        int port = 0;
+
+        try
+        {
+            port = Integer.parseInt( proxyPortCombo.getText() );
+        }
+        catch ( NumberFormatException e )
+        {
+        }
+
+        return port;
+    }
+
+
+    /**
+     * Gets the remote host defined by the user.
+     *
+     * @return
+     *      the remote host defined by the user
+     */
+    public String getRemoteHost()
+    {
+        if ( useConnectionButton.getSelection() )
+        {
+            return selectedConnection.getHost();
+        }
+        else
+        {
+            return serverHostCombo.getText();
+        }
+    }
+
+
+    /**
+     * Gets the remote port defined by the user.
+     *
+     * @return
+     *      the remote port defined by the user
+     */
+    public int getRemotePort()
+    {
+        int port = 0;
+
+        if ( useConnectionButton.getSelection() )
+        {
+            port = selectedConnection.getPort();
+        }
+        else
+        {
+            try
+            {
+                port = Integer.parseInt( serverPortCombo.getText() );
+            }
+            catch ( NumberFormatException e )
+            {
+            }
+        }
+
+        return port;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+     */
+    public void modifyText( ModifyEvent e )
+    {
+        validate();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+     */
+    public void widgetDefaultSelected( SelectionEvent e )
+    {
+        validate();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+     */
+    public void widgetSelected( SelectionEvent e )
+    {
+        validate();
+    }
+
+
+    /**
+     * Validates the page.
+     */
+    private void validate()
+    {
+        String errorMessage = null;
+
+        if ( useConnectionButton.getSelection() )
+        {
+            if ( selectedConnection == null )
+            {
+                errorMessage = "Please select a connection.";
+            }
+        }
+        else
+        {
+            if ( "".equals( serverPortCombo.getText() ) )
+            {
+                errorMessage = "Please enter a port for the LDAP Server. The default LDAP port is 389.";
+            }
+            if ( "".equals( serverHostCombo.getText() ) )
+            {
+                errorMessage = "Please enter a hostname for the LDAP Server.";
+            }
+        }
+
+        if ( "".equals( proxyPortCombo.getText() ) )
+        {
+            errorMessage = "Please enter a port for the LDAP Proxy.";
+        }
+
+        setErrorMessage( errorMessage );
+        setPageComplete( getErrorMessage() == null );
+    }
+}

Added: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserNotAvailablePage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserNotAvailablePage.java?view=auto&rev=510997
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserNotAvailablePage.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardBrowserNotAvailablePage.java Fri Feb 23 08:01:07 2007
@@ -0,0 +1,267 @@
+/*
+ *  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.proxy.view.wizards;
+
+
+import org.apache.directory.ldapstudio.proxy.ProxyConstants;
+import org.apache.directory.ldapstudio.proxy.view.BaseWidgetUtils;
+import org.apache.directory.ldapstudio.proxy.view.HistoryUtils;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+
+/**
+ * This class implements the Connect Wizard Settings Page.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectWizardBrowserNotAvailablePage extends WizardPage implements ModifyListener, SelectionListener
+{
+    // UI fields
+    private Combo proxyPortCombo;
+    private Combo serverHostCombo;
+    private Combo serverPortCombo;
+
+
+    /**
+     * Creates a new instance of ConnectWizardSettingsPage.
+     */
+    public ConnectWizardBrowserNotAvailablePage()
+    {
+        super( ConnectWizardBrowserNotAvailablePage.class.getName() );
+        setTitle( "Connect Wizard" );
+        setDescription( "Specify the settings for the LDAP Proxy." );
+        setPageComplete( false );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl( Composite parent )
+    {
+        Composite composite = new Composite( parent, SWT.NONE );
+        GridLayout gl = new GridLayout( 1, false );
+        composite.setLayout( gl );
+
+        Group proxyGroup = BaseWidgetUtils.createGroup( composite, "LDAP Proxy", 1 );
+        proxyGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+        Composite proxyGroupComposite = BaseWidgetUtils.createColumnContainer( proxyGroup, 2, 1 );
+
+        BaseWidgetUtils.createLabel( proxyGroupComposite, "Proxy port:", 1 );
+        proxyPortCombo = BaseWidgetUtils.createCombo( proxyGroupComposite, new String[0], -1, 1 );
+        proxyPortCombo.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) )
+                {
+                    e.doit = false;
+                }
+                if ( serverPortCombo.getText().length() > 4 && e.text.length() > 0 )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        Group serverGroup = BaseWidgetUtils.createGroup( composite, "LDAP Server", 1 );
+        serverGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+        Composite serverComposite = BaseWidgetUtils.createColumnContainer( serverGroup, 2, 1 );
+        BaseWidgetUtils.createLabel( serverComposite, "Hostname:", 1 );
+        serverHostCombo = BaseWidgetUtils.createCombo( serverComposite, new String[0], -1, 1 );
+
+        BaseWidgetUtils.createLabel( serverComposite, "Port:", 1 );
+        serverPortCombo = BaseWidgetUtils.createCombo( serverComposite, new String[0], -1, 1 );
+        serverPortCombo.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                if ( !e.text.matches( "[0-9]*" ) )
+                {
+                    e.doit = false;
+                }
+                if ( serverPortCombo.getText().length() > 4 && e.text.length() > 0 )
+                {
+                    e.doit = false;
+                }
+            }
+        } );
+
+        setControl( parent );
+
+        loadDialogHistory();
+        initListeners();
+    }
+
+
+    /**
+     * Loads the last values entered by the user from the Dialog History.
+     */
+    private void loadDialogHistory()
+    {
+        proxyPortCombo.setItems( HistoryUtils.load( ProxyConstants.DIALOGSETTING_KEY_PROXY_PORT_HISTORY ) );
+        serverHostCombo.setItems( HistoryUtils.load( ProxyConstants.DIALOGSETTING_KEY_SERVER_HOST_HISTORY ) );
+        serverPortCombo.setItems( HistoryUtils.load( ProxyConstants.DIALOGSETTING_KEY_SERVER_PORT_HISTORY ) );
+    }
+
+
+    /**
+     * Saves the values entered by the user in the Dialog History.
+     */
+    public void saveDialogHistory()
+    {
+        HistoryUtils.save( ProxyConstants.DIALOGSETTING_KEY_PROXY_PORT_HISTORY, proxyPortCombo.getText() );
+        HistoryUtils.save( ProxyConstants.DIALOGSETTING_KEY_SERVER_HOST_HISTORY, serverHostCombo.getText() );
+        HistoryUtils.save( ProxyConstants.DIALOGSETTING_KEY_SERVER_PORT_HISTORY, serverPortCombo.getText() );
+    }
+
+
+    /**
+     * Initializes the listeners.
+     */
+    private void initListeners()
+    {
+        proxyPortCombo.addModifyListener( this );
+        serverHostCombo.addModifyListener( this );
+        serverPortCombo.addModifyListener( this );
+    }
+
+
+    /**
+     * Gets the local port defined by the user.
+     * 
+     * @return
+     *      the local port defined by the user
+     */
+    public int getLocalPort()
+    {
+        int port = 0;
+
+        try
+        {
+            port = Integer.parseInt( proxyPortCombo.getText() );
+        }
+        catch ( NumberFormatException e )
+        {
+        }
+
+        return port;
+    }
+
+
+    /**
+     * Gets the remote host defined by the user.
+     *
+     * @return
+     *      the remote host defined by the user
+     */
+    public String getRemoteHost()
+    {
+        return serverHostCombo.getText();
+    }
+
+
+    /**
+     * Gets the remote port defined by the user.
+     *
+     * @return
+     *      the remote port defined by the user
+     */
+    public int getRemotePort()
+    {
+        int port = 0;
+
+        try
+        {
+            port = Integer.parseInt( serverPortCombo.getText() );
+        }
+        catch ( NumberFormatException e )
+        {
+        }
+
+        return port;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+     */
+    public void modifyText( ModifyEvent e )
+    {
+        validate();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+     */
+    public void widgetDefaultSelected( SelectionEvent e )
+    {
+        validate();
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+     */
+    public void widgetSelected( SelectionEvent e )
+    {
+        validate();
+    }
+
+
+    /**
+     * Validates the page.
+     */
+    private void validate()
+    {
+        String errorMessage = null;
+
+        if ( "".equals( serverPortCombo.getText() ) )
+        {
+            errorMessage = "Please enter a port for the LDAP Server. The default LDAP port is 389.";
+        }
+        if ( "".equals( serverHostCombo.getText() ) )
+        {
+            errorMessage = "Please enter a hostname for the LDAP Server.";
+        }
+        if ( "".equals( proxyPortCombo.getText() ) )
+        {
+            errorMessage = "Please enter a port for the LDAP Proxy.";
+        }
+
+        setErrorMessage( errorMessage );
+        setPageComplete( getErrorMessage() == null );
+    }
+}



Mime
View raw message