[ooo-build-commit] ooeclipse: Branch 'master'
Cédric Bosdonnat
cbosdo at kemper.freedesktop.org
Fri Sep 11 13:14:39 PDT 2009
core/source/org/openoffice/ide/eclipse/core/gui/ConnectionConfigPanel.java | 250 ++++++++++
core/source/org/openoffice/ide/eclipse/core/gui/messages.properties | 6
cpp/plugin.xml | 8
cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java | 3
cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java | 24
5 files changed, 281 insertions(+), 10 deletions(-)
New commits:
commit 26da31508b24025d24221c20be82cec9867cd66c
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date: Fri Sep 11 22:15:50 2009 +0200
C++ Client wizard
The connection string is now configured in the wizard with default
values.
diff --git a/core/source/org/openoffice/ide/eclipse/core/gui/ConnectionConfigPanel.java b/core/source/org/openoffice/ide/eclipse/core/gui/ConnectionConfigPanel.java
new file mode 100644
index 0000000..504f8c9
--- /dev/null
+++ b/core/source/org/openoffice/ide/eclipse/core/gui/ConnectionConfigPanel.java
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the GNU Lesser General Public License Version 2.1
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2009 by Cédric Bosdonnat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * The Initial Developer of the Original Code is: Cédric Bosdonnat.
+ *
+ * Copyright: 2009 by Cédric Bosdonnat, Inc.
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.core.gui;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Label;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Generic component for the selection of the parameters of a UNO connection.
+ *
+ * <p>Use the {@link #setPatterns(String, String)} method to define the patterns
+ * depending on the implementation language.</p>
+ *
+ * @author cbosdonnat
+ *
+ */
+public class ConnectionConfigPanel {
+
+ private static final String[] TYPE_VALUES = {
+ Messages.getString("ConnectionConfigPanel.Pipe"), //$NON-NLS-1$
+ Messages.getString("ConnectionConfigPanel.Socket") }; //$NON-NLS-1$
+
+ private boolean mIsPipe;
+ private String[] mPatterns;
+
+ private Combo mTypeList;
+ private ArrayList<Composite> mDetails;
+
+ private Composite mDetailsComposite;
+ private Text mNameTxt;
+ private Text mHostTxt;
+ private Text mPortTxt;
+
+ private StackLayout mStackLayout;
+
+ /**
+ * Constructor.
+ *
+ * <p>In order to properly work, the parent composite has to have a
+ * {@link GridLayout} set.</p>
+ *
+ * @param pParent the parent composite to create the controls in.
+ */
+ public ConnectionConfigPanel( Composite pParent ) {
+ mIsPipe = false;
+ mPatterns = new String[TYPE_VALUES.length];
+
+ createControls( pParent );
+ }
+
+ /**
+ * Set the patterns to use in {@link #getConnectionCode()}.
+ *
+ * @param pPipe the pattern for the pipe connection type.
+ * The parameter <code>{0}</code> is the pipe's name.
+ *
+ * @param pSocket the pattern for the socket connection type.
+ * The parameters mapping is the following:
+ * <ul>
+ * <li><code>{0}</code> maps to the host</li>
+ * <li><code>{1}</code> maps to the port</li>
+ * </ul>
+ */
+ public void setPatterns( String pPipe, String pSocket ) {
+ mPatterns[0] = pPipe;
+ mPatterns[1] = pSocket;
+ }
+
+ /**
+ * @return the formatted connection code
+ *
+ * @see #setPatterns(String, String) for the used patterns
+ */
+ public String getConnectionCode( ) {
+
+ String cnxString = null;
+
+ if ( mIsPipe ) {
+ cnxString = MessageFormat.format( mPatterns[0],
+ mNameTxt.getText() );
+ } else {
+ cnxString = MessageFormat.format( mPatterns[1],
+ mHostTxt.getText(), mPortTxt.getText() );
+ }
+
+ return cnxString;
+ }
+
+ /**
+ * Creates all the component's controls.
+ *
+ * @param pParent the parent composite where to create the controls
+ */
+ protected void createControls( Composite pParent ) {
+ Layout layout = pParent.getLayout();
+ if ( layout instanceof GridLayout ) {
+ int layoutColumns = ((GridLayout)layout).numColumns;
+
+ Composite body = new Composite( pParent, SWT.NONE );
+ GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gd.horizontalSpan = layoutColumns;
+ body.setLayoutData( gd );
+ body.setLayout( new GridLayout( 2, false ) );
+
+ Label typeLbl = new Label( body, SWT.NONE );
+ typeLbl.setText( Messages.getString("ConnectionConfigPanel.CnxTypeLabel") ); //$NON-NLS-1$
+ typeLbl.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false ) );
+ mTypeList = new Combo( body, SWT.DROP_DOWN | SWT.READ_ONLY );
+ mTypeList.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, true, false ) );
+ mTypeList.setItems( TYPE_VALUES );
+ int pos = 1;
+ if ( mIsPipe ) {
+ pos = 0;
+ }
+ mTypeList.select( pos );
+ mTypeList.addSelectionListener( new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent pEvent ) {
+ mIsPipe = mTypeList.getSelectionIndex() == 0;
+ updateDetails();
+ }
+ });
+
+ mDetails = new ArrayList<Composite>();
+ mDetailsComposite = new Composite( body, SWT.NONE );
+ gd = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gd.horizontalSpan = 2;
+ mDetailsComposite.setLayoutData( gd );
+ mStackLayout = new StackLayout();
+ mDetailsComposite.setLayout( mStackLayout );
+
+
+ mDetails.add( createPipeControls( ) );
+ mDetails.add( createSocketControls( ) );
+
+ updateDetails();
+ }
+ }
+
+ /**
+ * Changes the shown details composite.
+ */
+ protected void updateDetails() {
+ int pos = 1;
+ if ( mIsPipe ) {
+ pos = 0;
+ }
+ mStackLayout.topControl = mDetails.get( pos );
+ mDetailsComposite.layout( );
+ }
+
+ /**
+ * @return the newly created composite containing the pipe's
+ * configuration controls.
+ */
+ private Composite createPipeControls() {
+ Composite body = new Composite( mDetailsComposite, SWT.NONE );
+ body.setLayout( new GridLayout( 2, false ) );
+
+ Label nameLbl = new Label( body, SWT.NONE );
+ nameLbl.setText( Messages.getString("ConnectionConfigPanel.Name") ); //$NON-NLS-1$
+ nameLbl.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false ) );
+
+ mNameTxt = new Text( body, SWT.SINGLE | SWT.BORDER );
+ mNameTxt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
+ mNameTxt.setText( "somename" ); //$NON-NLS-1$
+
+ return body;
+ }
+
+ /**
+ * @return the newly created composite containing the socket's
+ * configuration controls.
+ */
+ private Composite createSocketControls() {
+ Composite body = new Composite( mDetailsComposite, SWT.NONE );
+ body.setLayout( new GridLayout( 2, false ) );
+
+ Label hostLbl = new Label( body, SWT.NONE );
+ hostLbl.setText( Messages.getString("ConnectionConfigPanel.Host") ); //$NON-NLS-1$
+ hostLbl.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false ) );
+
+ mHostTxt = new Text( body, SWT.SINGLE | SWT.BORDER );
+ mHostTxt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
+ mHostTxt.setText( "localhost" ); //$NON-NLS-1$
+
+ Label portLbl = new Label( body, SWT.NONE );
+ portLbl.setText( Messages.getString("ConnectionConfigPanel.Port") ); //$NON-NLS-1$
+ portLbl.setLayoutData( new GridData( SWT.BEGINNING, SWT.CENTER, false, false ) );
+
+ mPortTxt = new Text( body, SWT.SINGLE | SWT.BORDER );
+ mPortTxt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
+ mPortTxt.setText( "8100" ); //$NON-NLS-1$
+ mPortTxt.addVerifyListener( new VerifyListener() {
+
+ public void verifyText( VerifyEvent pEvent ) {
+ try {
+ Integer.parseInt( pEvent.text );
+ } catch ( NumberFormatException e ) {
+ pEvent.doit = false;
+ }
+ }
+ });
+
+ return body;
+ }
+}
diff --git a/core/source/org/openoffice/ide/eclipse/core/gui/messages.properties b/core/source/org/openoffice/ide/eclipse/core/gui/messages.properties
index 886f4f7..6a95bed 100644
--- a/core/source/org/openoffice/ide/eclipse/core/gui/messages.properties
+++ b/core/source/org/openoffice/ide/eclipse/core/gui/messages.properties
@@ -1,5 +1,11 @@
AbstractTable.Add=Add
AbstractTable.Del=Del
+ConnectionConfigPanel.CnxTypeLabel=Connection type
+ConnectionConfigPanel.Host=Host
+ConnectionConfigPanel.Name=Name
+ConnectionConfigPanel.Pipe=Pipe
+ConnectionConfigPanel.Port=Port
+ConnectionConfigPanel.Socket=Socket
LocaleDialog.Title=Locale
OOoTable.Title=Available OpenOffice.org installations
OOoTable.NameTitle=Name
diff --git a/cpp/plugin.xml b/cpp/plugin.xml
index 4843729..df6fc15 100644
--- a/cpp/plugin.xml
+++ b/cpp/plugin.xml
@@ -17,13 +17,9 @@
hasPages="true"
icon="icons/uno_client.png"
id="org.openoffice.ide.eclipse.cpp.client"
- name="C++ UNO client application">
+ name="C++ UNO client application"
+ project="true">
</wizard>
</extension>
- <extension
- id="id1"
- name="name"
- point="org.eclipse.cdt.core.externalSettingsProvider">
- </extension>
</plugin>
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java b/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
index 7dd7d4a..e15aa2b 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
@@ -98,8 +98,7 @@ public class ClientWizard extends CCProjectWizard {
copyResource( "connection.hxx", srcDir, new String() ); //$NON-NLS-1$
copyResource( "connection.cxx", srcDir, new String() ); //$NON-NLS-1$
- // TODO Make that configurable in the wizard
- String cnxInitCode = "SocketConnection cnx( 8080, \"localhost\" );"; //$NON-NLS-1$
+ String cnxInitCode = mCnxPage.getConnectionCode();
copyResource( CLIENT_FILE, srcDir, cnxInitCode );
srcDir.refreshLocal( IResource.DEPTH_ONE, null );
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java b/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java
index 7478e77..f4fadbd 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java
@@ -37,6 +37,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.openoffice.ide.eclipse.core.gui.ConnectionConfigPanel;
import org.openoffice.ide.eclipse.core.gui.OOoConfigPanel;
import org.openoffice.ide.eclipse.core.model.OOoContainer;
import org.openoffice.ide.eclipse.core.model.SDKContainer;
@@ -52,8 +53,14 @@ import org.openoffice.ide.eclipse.core.model.config.ISdk;
public class UnoConnectionPage extends WizardPage {
private static final int LAYOUT_COLUMNS = 3;
+
+ private static final String PIPE_PATTERN = "PipeConnection cnx( \"{0}\" );"; //$NON-NLS-1$
+ private static final String SOCKET_PATTERN = "SocketConnection cnx( {1}, \"{0}\" );"; //$NON-NLS-1$
+
private UnoClientWizardPage mMainPage;
+
private OOoConfigPanel mOOoConfigPanel;
+ private ConnectionConfigPanel mCnxConfigPanel;
public UnoConnectionPage( ) {
super( "unocnxpage" ); //$NON-NLS-1$
@@ -75,10 +82,16 @@ public class UnoConnectionPage extends WizardPage {
confLbl.setLayoutData( gd );
confLbl.setText( "OpenOffice.org and SDK for building" );
- // TODO Add a section for the sample connection config
-
mOOoConfigPanel = new OOoConfigPanel( body );
+ Label sep = new Label( body, SWT.SEPARATOR | SWT.HORIZONTAL );
+ gd = new GridData( SWT.FILL, SWT.CENTER, true, false );
+ gd.horizontalSpan = LAYOUT_COLUMNS;
+ sep.setLayoutData( gd );
+
+ mCnxConfigPanel = new ConnectionConfigPanel( body );
+ mCnxConfigPanel.setPatterns( PIPE_PATTERN, SOCKET_PATTERN );
+
setControl( body );
}
@@ -97,6 +110,13 @@ public class UnoConnectionPage extends WizardPage {
}
/**
+ * @return the C++ connection code for the sample client
+ */
+ public String getConnectionCode( ) {
+ return mCnxConfigPanel.getConnectionCode();
+ }
+
+ /**
* @return the normal next page of the CDT main page.
*/
@Override
More information about the ooo-build-commit
mailing list