You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2007/02/20 18:28:36 UTC
svn commit: r509671 - in /directory/ldapstudio/trunk/ldapstudio-proxy: ./
META-INF/ resources/ resources/icons/
src/main/java/org/apache/directory/ldapstudio/proxy/controller/
src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/
src/...
Author: pamarcelot
Date: Tue Feb 20 09:28:34 2007
New Revision: 509671
URL: http://svn.apache.org/viewvc?view=rev&rev=509671
Log:
Added :
- the LDAP Proxy Perspective
- the Proxy and LDAP Message Views
- the Connect Wizard which allow to launch the Proxy (Connections defined in the Browser Plugin are available in this wizard)
Added:
directory/ldapstudio/trunk/ldapstudio-proxy/resources/
directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/
directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/connect.gif (with props)
directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/disconnect.gif (with props)
directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/perspective.png (with props)
directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/
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/
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/model/
directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/
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/
directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizard.java
directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardSettingsPage.java
Modified:
directory/ldapstudio/trunk/ldapstudio-proxy/META-INF/MANIFEST.MF
directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml
Modified: directory/ldapstudio/trunk/ldapstudio-proxy/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/META-INF/MANIFEST.MF?view=diff&rev=509671&r1=509670&r2=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/META-INF/MANIFEST.MF (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/META-INF/MANIFEST.MF Tue Feb 20 09:28:34 2007
@@ -8,6 +8,8 @@
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.jface.text
+ org.eclipse.jface.text,
+ org.apache.directory.ldapstudio.browser.ui;resolution:=optional,
+ org.apache.directory.ldapstudio.browser.core;resolution:=optional
Eclipse-LazyStart: true
Bundle-ClassPath: .
Modified: directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml?view=diff&rev=509671&r1=509670&r2=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml (original)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/plugin.xml Tue Feb 20 09:28:34 2007
@@ -18,4 +18,25 @@
specific language governing permissions and limitations
under the License.
-->
-<plugin></plugin>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ allowMultiple="false"
+ class="org.apache.directory.ldapstudio.proxy.view.ProxyView"
+ id="org.apache.directory.ldapstudio.proxy.view.ProxyView"
+ name="Proxy"/>
+ <view
+ allowMultiple="false"
+ class="org.apache.directory.ldapstudio.proxy.view.LdapMessageView"
+ id="org.apache.directory.ldapstudio.proxy.view.LdapMessageView"
+ name="LDAP Message"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ class="org.apache.directory.ldapstudio.proxy.view.Perspective"
+ icon="resources/icons/perspective.png"
+ id="org.apache.directory.ldapstudio.proxy.perpective"
+ name="LDAP Proxy"/>
+ </extension></plugin>
Added: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/connect.gif
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/connect.gif?view=auto&rev=509671
==============================================================================
Binary file - no diff available.
Propchange: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/connect.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/disconnect.gif
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/disconnect.gif?view=auto&rev=509671
==============================================================================
Binary file - no diff available.
Propchange: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/disconnect.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: 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=auto&rev=509671
==============================================================================
Binary file - no diff available.
Propchange: directory/ldapstudio/trunk/ldapstudio-proxy/resources/icons/perspective.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/LdapMessageViewController.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/LdapMessageViewController.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.ldapstudio.proxy.controller;
+
+
+import org.apache.directory.ldapstudio.proxy.view.LdapMessageView;
+import org.eclipse.jface.action.IToolBarManager;
+
+
+/**
+ * This class implements the controller for the LDAP Message View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapMessageViewController
+{
+ /** The associated view */
+ private LdapMessageView view;
+
+
+ /**
+ * Creates a new instance of LdapMessageViewController.
+ *
+ * @param view
+ * the associated view
+ */
+ public LdapMessageViewController( LdapMessageView view )
+ {
+ this.view = view;
+
+ initActions();
+ initToolbar();
+ }
+
+
+ /**
+ * Initializes the actions.
+ */
+ private void initActions()
+ {
+ }
+
+
+ /**
+ * Initializes the toolbar.
+ */
+ private void initToolbar()
+ {
+ }
+}
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/ProxyViewController.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/ProxyViewController.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.controller;
+
+
+import org.apache.directory.ldapstudio.proxy.controller.actions.ConnectAction;
+import org.apache.directory.ldapstudio.proxy.controller.actions.DisconnectAction;
+import org.apache.directory.ldapstudio.proxy.view.ProxyView;
+import org.eclipse.jface.action.IToolBarManager;
+
+
+/**
+ * This class implements the controller for the Proxy View.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ProxyViewController
+{
+ /** The associated view */
+ private ProxyView view;
+
+ // Actions
+ private ConnectAction connect;
+ private DisconnectAction disconnect;
+
+
+ /**
+ * Creates a new instance of ProxyViewController.
+ *
+ * @param view
+ * the associated view
+ */
+ public ProxyViewController( ProxyView view )
+ {
+ this.view = view;
+
+ initActions();
+ initToolbar();
+ }
+
+
+ /**
+ * Initializes the actions.
+ */
+ private void initActions()
+ {
+ connect = new ConnectAction();
+ disconnect = new DisconnectAction();
+ }
+
+
+ /**
+ * Initializes the toolbar.
+ */
+ private void initToolbar()
+ {
+ IToolBarManager toolbar = view.getViewSite().getActionBars().getToolBarManager();
+ toolbar.add( connect );
+ toolbar.add( disconnect );
+ }
+}
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/ConnectAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/ConnectAction.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.ldapstudio.proxy.controller.actions;
+
+import org.apache.directory.ldapstudio.proxy.Activator;
+import org.apache.directory.ldapstudio.proxy.view.IImageKeys;
+import org.apache.directory.ldapstudio.proxy.view.wizards.ConnectWizard;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * This class implements the Connect action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectAction extends Action
+{
+ /**
+ * Creates a new instance of ConnectAction.
+ */
+ public ConnectAction()
+ {
+ super( "Connect");
+ setToolTipText( getText() );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.CONNECT ) );
+ setEnabled( true );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ WizardDialog dialog = new WizardDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), new ConnectWizard() );
+ dialog.create();
+ dialog.open();
+
+ super.run();
+ }
+}
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/DisconnectAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/controller/actions/DisconnectAction.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.ldapstudio.proxy.controller.actions;
+
+
+import org.apache.directory.ldapstudio.proxy.Activator;
+import org.apache.directory.ldapstudio.proxy.view.IImageKeys;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+/**
+ * This class implements the Disconnect action.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DisconnectAction extends Action
+{
+ /**
+ * Creates a new instance of DisconnectAction.
+ */
+ public DisconnectAction()
+ {
+ super( "Disconnect" );
+ setToolTipText( getText() );
+ setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, IImageKeys.DISCONNECT ) );
+ setEnabled( true );
+ }
+}
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/BaseWidgetUtils.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/BaseWidgetUtils.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,310 @@
+/*
+ * 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 org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+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.Link;
+import org.eclipse.swt.widgets.Text;
+
+
+public class BaseWidgetUtils
+{
+
+ public static Group createGroup( Composite parent, String label, int span )
+ {
+ Group group = new Group( parent, SWT.NONE );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.horizontalSpan = span;
+ group.setLayoutData( gd );
+ group.setText( label );
+ group.setLayout( new GridLayout() );
+ return group;
+ }
+
+
+ public static Composite createColumnContainer( Composite parent, int columnCount, int span )
+ {
+ Composite container = new Composite( parent, SWT.NONE );
+ GridLayout gl = new GridLayout( columnCount, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ container.setLayout( gl );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ container.setLayoutData( gd );
+ return container;
+ }
+
+
+ public static Label createLabel( Composite parent, String text, int span )
+ {
+ Label l = new Label( parent, SWT.NONE );
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ // gd.verticalAlignment = SWT.BEGINNING;
+ l.setLayoutData( gd );
+ l.setText( text );
+ return l;
+ }
+
+
+ public static Label createWrappedLabel( Composite parent, String text, int span )
+ {
+ Label l = new Label( parent, SWT.WRAP );
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ // gd.verticalAlignment = SWT.BEGINNING;
+ l.setLayoutData( gd );
+ l.setText( text );
+ return l;
+ }
+
+
+ public static Text createText( Composite parent, String text, int span )
+ {
+ Text t = new Text( parent, SWT.NONE | SWT.BORDER );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ t.setLayoutData( gd );
+ t.setText( text );
+ return t;
+ }
+
+
+ public static Text createText( Composite parent, String text, int textWidth, int span )
+ {
+ Text t = new Text( parent, SWT.NONE | SWT.BORDER );
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ gd.widthHint = 9 * textWidth;
+ t.setLayoutData( gd );
+ t.setText( text );
+ t.setTextLimit( textWidth );
+ return t;
+ }
+
+
+ public static Text createPasswordText( Composite parent, String text, int span )
+ {
+ Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ t.setLayoutData( gd );
+ t.setText( text );
+ return t;
+ }
+
+
+ public static Text createReadonlyPasswordText( Composite parent, String text, int span )
+ {
+ Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD | SWT.READ_ONLY );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ t.setLayoutData( gd );
+ t.setEditable( false );
+ t.setBackground( parent.getBackground() );
+ t.setText( text );
+ return t;
+ }
+
+
+ public static Text createLabeledText( Composite parent, String text, int span )
+ {
+ Text t = new Text( parent, SWT.NONE );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ t.setLayoutData( gd );
+ t.setEditable( false );
+ t.setBackground( parent.getBackground() );
+ t.setText( text );
+ return t;
+ }
+
+
+ public static Text createWrappedLabeledText( Composite parent, String text, int span )
+ {
+ Text t = new Text( parent, SWT.WRAP );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ gd.widthHint = 10;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+ t.setLayoutData( gd );
+ t.setEditable( false );
+ t.setBackground( parent.getBackground() );
+ t.setText( text );
+ return t;
+ }
+
+
+ public static Text createReadonlyText( Composite parent, String text, int span )
+ {
+ Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.READ_ONLY );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ t.setLayoutData( gd );
+ t.setEditable( false );
+ t.setBackground( parent.getBackground() );
+ t.setText( text );
+ return t;
+ }
+
+
+ public static String getNonNullString( String s )
+ {
+ return s == null ? "-" : s;
+ }
+
+
+ public static Combo createCombo( Composite parent, String[] items, int selectedIndex, int span )
+ {
+ Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.BORDER );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ c.setLayoutData( gd );
+ c.setItems( items );
+ c.select( selectedIndex );
+ c.setVisibleItemCount( 20 );
+ return c;
+ }
+
+
+ public static Combo createReadonlyCombo( Composite parent, String[] items, int selectedIndex, int span )
+ {
+ Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ c.setLayoutData( gd );
+ // c.setBackground(parent.getBackground());
+ c.setItems( items );
+ c.select( selectedIndex );
+ c.setVisibleItemCount( 20 );
+ return c;
+ }
+
+
+ public static Combo createReadonlyReadonlyCombo( Composite parent, String[] items, int selectedIndex, int span )
+ {
+ Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ c.setLayoutData( gd );
+ c.setBackground( parent.getBackground() );
+ c.setItems( items );
+ c.select( selectedIndex );
+ c.setVisibleItemCount( 20 );
+ return c;
+ }
+
+
+ public static Button createCheckbox( Composite composite, String text, int span )
+ {
+ Button checkbox = new Button( composite, SWT.CHECK );
+ checkbox.setText( text );
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ checkbox.setLayoutData( gd );
+ return checkbox;
+ }
+
+
+ public static Button createRadiobutton( Composite composite, String text, int span )
+ {
+ Button radio = new Button( composite, SWT.RADIO );
+ radio.setText( text );
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ radio.setLayoutData( gd );
+ return radio;
+ }
+
+
+ public static Button createButton( Composite composite, String text, int span )
+ {
+ GC gc = new GC( composite );
+ gc.setFont( JFaceResources.getDialogFont() );
+ FontMetrics fontMetrics = gc.getFontMetrics();
+ gc.dispose();
+
+ Button button = new Button( composite, SWT.PUSH );
+ GridData gd = new GridData();
+ gd.widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH );
+ button.setLayoutData( gd );
+ button.setText( text );
+ return button;
+ }
+
+
+ public static void createRadioIndent( Composite composite, int span )
+ {
+ Label l = new Label( composite, SWT.NONE );
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ gd.horizontalIndent = 22;
+ l.setLayoutData( gd );
+ }
+
+
+ public static void createSpacer( Composite composite, int span )
+ {
+ Label l = new Label( composite, SWT.NONE );
+ // GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ gd.heightHint = 1;
+ l.setLayoutData( gd );
+ }
+
+
+ public static void createSeparator( Composite composite, int span )
+ {
+ Label l = new Label( composite, SWT.SEPARATOR | SWT.HORIZONTAL );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = span;
+ // gd.heightHint = 1;
+ l.setLayoutData( gd );
+ }
+
+
+ public static Link createLink( Composite parent, String text, int span )
+ {
+ Link link = new Link( parent, SWT.NONE );
+ link.setText( text );
+ GridData gd = new GridData( SWT.FILL, SWT.BEGINNING, true, false );
+ gd.horizontalSpan = span;
+ gd.widthHint = 150;
+ link.setLayoutData( gd );
+ return link;
+ }
+
+}
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/IImageKeys.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/IImageKeys.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+
+/**
+ * This class is used to define path for images.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface IImageKeys
+{
+ // 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$
+}
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/LdapMessageView.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/LdapMessageView.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.ldapstudio.proxy.view;
+
+
+import org.apache.directory.ldapstudio.proxy.Activator;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * This class implements the LDAP Message View where a LDAP Message is displayed.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapMessageView extends ViewPart
+{
+ /** The view ID*/
+ public static final String ID = Activator.PLUGIN_ID + ".view.LdapMessageView";
+
+ /** The Source Viewer */
+ private SourceViewer sourceViewer;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl( Composite parent )
+ {
+ sourceViewer = new SourceViewer( parent, null, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
+ GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gd.heightHint = 10;
+ sourceViewer.getTextWidget().setLayoutData( gd );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ public void setFocus()
+ {
+ sourceViewer.getControl().setFocus();
+ }
+}
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/Perspective.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/Perspective.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,49 @@
+/*
+ * 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 org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+
+/**
+ * This class implements the default perpective for the Proxy Plugin.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Perspective implements IPerspectiveFactory
+{
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
+ */
+ public void createInitialLayout( IPageLayout layout )
+ {
+ String editorArea = layout.getEditorArea();
+ layout.setEditorAreaVisible( false );
+
+ layout.addStandaloneView( ProxyView.ID, true, IPageLayout.LEFT, 0.5f, editorArea );
+ layout.getViewLayout( ProxyView.ID ).setCloseable( false );
+
+ layout.addStandaloneView( LdapMessageView.ID, true, IPageLayout.RIGHT, 0.5f, ProxyView.ID );
+ layout.getViewLayout( LdapMessageView.ID ).setCloseable( false );
+ }
+}
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/ProxyView.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/ProxyView.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.ldapstudio.proxy.view;
+
+
+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.ui.part.ViewPart;
+
+
+/**
+ * This class implements the Proxy View where all LDAP Messages Hierarchy (LDAP Requests and Responses) is displayed.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ProxyView extends ViewPart
+{
+ /** The view ID*/
+ public static final String ID = Activator.PLUGIN_ID + ".view.ProxyView";
+
+ /** The tree viewer */
+ private TreeViewer viewer;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl( Composite parent )
+ {
+ viewer = new TreeViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER );
+
+ new ProxyViewController( this );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ public void setFocus()
+ {
+ viewer.getControl().setFocus();
+ }
+}
Added: 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=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizard.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizard.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,55 @@
+/*
+ * 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.eclipse.jface.wizard.Wizard;
+
+
+/**
+ * This class implements the Connect Wizard.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectWizard extends Wizard
+{
+ /** The Settings page*/
+ private ConnectWizardSettingsPage settings;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages()
+ {
+ settings = new ConnectWizardSettingsPage();
+ addPage( settings );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish()
+ {
+ return false;
+ }
+}
Added: directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardSettingsPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardSettingsPage.java?view=auto&rev=509671
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardSettingsPage.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-proxy/src/main/java/org/apache/directory/ldapstudio/proxy/view/wizards/ConnectWizardSettingsPage.java Tue Feb 20 09:28:34 2007
@@ -0,0 +1,254 @@
+/*
+ * 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.view.BaseWidgetUtils;
+import org.eclipse.core.internal.registry.BundleHelper;
+import org.eclipse.core.internal.registry.osgi.EclipseBundleListener;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.adaptor.EclipseStarter;
+import org.eclipse.core.runtime.internal.adaptor.EclipseEnvironmentInfo;
+import org.eclipse.core.runtime.internal.adaptor.PluginParser.PluginInfo;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.framework.internal.core.BundleContextImpl;
+import org.eclipse.osgi.framework.internal.core.BundleLoader;
+import org.eclipse.osgi.framework.internal.core.BundleLoaderProxy;
+import org.eclipse.osgi.internal.baseadaptor.BundleInstall;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+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 ConnectWizardSettingsPage extends WizardPage
+{
+ private Combo proxyPortCombo;
+ private Button useConnectionButton;
+ private Text connectionText;
+ private Button connectionButton;
+ private Button useThisSettingsButton;
+ private Combo settingsHostnameCombo;
+ private Combo settingsPortCombo;
+ private IConnection selectedConnection;
+
+
+ /**
+ * Creates a new instance of ConnectWizardSettingsPage.
+ */
+ public ConnectWizardSettingsPage()
+ {
+ super( ConnectWizardSettingsPage.class.getName() );
+ setTitle( "Connect Wizard" );
+ setDescription( "Specify the settings for the LDAP Proxy." );
+ }
+
+
+ /* (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 );
+
+ 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 );
+ settingsHostnameCombo = BaseWidgetUtils.createCombo( settingsComposite, new String[0], -1, 1 );
+
+ BaseWidgetUtils.createRadioIndent( settingsComposite, 1 );
+ BaseWidgetUtils.createLabel( settingsComposite, "Port:", 1 );
+ settingsPortCombo = BaseWidgetUtils.createCombo( settingsComposite, new String[0], -1, 1 );
+
+ setControl( parent );
+
+ checkBrowserPluginAvailability();
+
+ initFieldsFromPreferences();
+
+ setUiEnableState();
+
+ initListeners();
+ }
+
+ 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 );
+ }
+ }
+
+
+ private void initFieldsFromPreferences()
+ {
+ useConnectionButton.setSelection( useConnectionButton.isEnabled() );
+ useThisSettingsButton.setSelection( !useConnectionButton.isEnabled() );
+ }
+
+
+ /**
+ * Initializes the listeners.
+ */
+ private void initListeners()
+ {
+ useConnectionButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ setUiEnableState();
+ }
+ } );
+
+ useThisSettingsButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ 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 );
+ }
+ } );
+ }
+
+ /**
+ * Enables the UI fields.
+ */
+ private void setUiEnableState()
+ {
+ if ( ( useConnectionButton.isEnabled() ) && ( useConnectionButton.getSelection() ) )
+ {
+ connectionText.setEnabled( true );
+ connectionButton.setEnabled( true );
+ settingsHostnameCombo.setEnabled( false );
+ settingsPortCombo.setEnabled( false );
+ }
+ else
+ {
+ connectionText.setEnabled( false );
+ connectionButton.setEnabled( false );
+ settingsHostnameCombo.setEnabled( true );
+ settingsPortCombo.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() : "" );
+ }
+}