[ooo-build-commit] ooeclipse: Branch 'master'
Cédric Bosdonnat
cbosdo at kemper.freedesktop.org
Thu Oct 1 07:49:36 PDT 2009
core/source/org/openoffice/ide/eclipse/core/gui/ConnectionConfigPanel.java | 47 ++
core/source/org/openoffice/ide/eclipse/core/gui/OOoConfigPanel.java | 4
core/source/org/openoffice/ide/eclipse/core/gui/rows/ChoiceRow.java | 76 +---
core/source/org/openoffice/ide/eclipse/core/preferences/MainPage.java | 2
core/source/org/openoffice/ide/eclipse/core/unotypebrowser/UnoTypeBrowser.java | 2
core/source/org/openoffice/ide/eclipse/core/wizards/messages.properties | 3
core/source/org/openoffice/ide/eclipse/core/wizards/pages/BaseUnoConnectionPage.java | 137 ++++++++
core/source/org/openoffice/ide/eclipse/core/wizards/pages/InterfaceMemberDialog.java | 2
core/source/org/openoffice/ide/eclipse/core/wizards/pages/NewUnoProjectPage.java | 2
core/source/org/openoffice/ide/eclipse/core/wizards/pages/PackageExportWizardPage.java | 2
cpp/build/MANIFEST.MF.in | 9
cpp/doc/cheatsheets/unoclient.xml | 2
cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java | 73 ----
cpp/source/org/openoffice/ide/eclipse/cpp/client/messages.properties | 3
java/META-INF/MANIFEST.MF | 4
java/build/MANIFEST.MF.in | 2
java/doc/cheatsheets/unoclient.xml | 46 ++
java/icons/uno_client.png |binary
java/icons/uno_client_wiz.png |binary
java/plugin.xml | 23 +
java/source/org/openoffice/ide/eclipse/java/JavaWizardPage.java | 4
java/source/org/openoffice/ide/eclipse/java/client/AbstractConnection.java.tpl | 142 ++++++++
java/source/org/openoffice/ide/eclipse/java/client/ClientWizard.java | 165 ++++++++++
java/source/org/openoffice/ide/eclipse/java/client/Connection.java.tpl | 53 +++
java/source/org/openoffice/ide/eclipse/java/client/Messages.java | 70 ++++
java/source/org/openoffice/ide/eclipse/java/client/OpenOfficeException.java.tpl | 29 +
java/source/org/openoffice/ide/eclipse/java/client/PipeConnection.java.tpl | 32 +
java/source/org/openoffice/ide/eclipse/java/client/SocketConnection.java.tpl | 29 +
java/source/org/openoffice/ide/eclipse/java/client/UnoClient.java.tpl | 34 ++
java/source/org/openoffice/ide/eclipse/java/client/UnoConnectionPage.java | 52 +++
java/source/org/openoffice/ide/eclipse/java/client/messages.properties | 4
java/source/org/openoffice/ide/eclipse/java/messages.properties | 1
java/source/org/openoffice/ide/eclipse/java/registration/RegistrationHelper.java | 2
java/source/org/openoffice/ide/eclipse/java/tests/Messages.java | 54 +++
java/source/org/openoffice/ide/eclipse/java/utils/TemplatesHelper.java | 39 +-
35 files changed, 997 insertions(+), 152 deletions(-)
New commits:
commit d023f8eab878e08eadce406c89289c71ed48ce7f
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date: Thu Oct 1 11:50:34 2009 +0200
[Java]Added UNO Client wizard
* Extracted the common part of the UnoConnectionPage
* Small changes in the core rows
* Added Java UNO Client cheatsheet
diff --git a/core/source/org/openoffice/ide/eclipse/core/gui/ConnectionConfigPanel.java b/core/source/org/openoffice/ide/eclipse/core/gui/ConnectionConfigPanel.java
index 504f8c9..3486340 100644
--- a/core/source/org/openoffice/ide/eclipse/core/gui/ConnectionConfigPanel.java
+++ b/core/source/org/openoffice/ide/eclipse/core/gui/ConnectionConfigPanel.java
@@ -35,6 +35,8 @@ import java.util.ArrayList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.VerifyEvent;
@@ -65,6 +67,10 @@ public class ConnectionConfigPanel {
private boolean mIsPipe;
private String[] mPatterns;
+ private String mName;
+ private String mHost;
+ private String mPort;
+
private Combo mTypeList;
private ArrayList<Composite> mDetails;
@@ -87,6 +93,10 @@ public class ConnectionConfigPanel {
mIsPipe = false;
mPatterns = new String[TYPE_VALUES.length];
+ mName = "somename"; //$NON-NLS-1$
+ mPort = "8100"; //$NON-NLS-1$
+ mHost = "localhost"; //$NON-NLS-1$
+
createControls( pParent );
}
@@ -119,10 +129,10 @@ public class ConnectionConfigPanel {
if ( mIsPipe ) {
cnxString = MessageFormat.format( mPatterns[0],
- mNameTxt.getText() );
+ mName );
} else {
cnxString = MessageFormat.format( mPatterns[1],
- mHostTxt.getText(), mPortTxt.getText() );
+ mHost, mPort );
}
return cnxString;
@@ -206,7 +216,13 @@ public class ConnectionConfigPanel {
mNameTxt = new Text( body, SWT.SINGLE | SWT.BORDER );
mNameTxt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
- mNameTxt.setText( "somename" ); //$NON-NLS-1$
+ mNameTxt.addKeyListener( new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent pE) {
+ mName = mNameTxt.getText();
+ }
+ });
+ mNameTxt.setText( mName );
return body;
}
@@ -225,7 +241,14 @@ public class ConnectionConfigPanel {
mHostTxt = new Text( body, SWT.SINGLE | SWT.BORDER );
mHostTxt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
- mHostTxt.setText( "localhost" ); //$NON-NLS-1$
+ mHostTxt.addKeyListener( new KeyAdapter() {
+
+ @Override
+ public void keyReleased(KeyEvent pE) {
+ mHost = mHostTxt.getText();
+ }
+ });
+ mHostTxt.setText( mHost );
Label portLbl = new Label( body, SWT.NONE );
portLbl.setText( Messages.getString("ConnectionConfigPanel.Port") ); //$NON-NLS-1$
@@ -233,17 +256,25 @@ public class ConnectionConfigPanel {
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 ) {
+ public void verifyText(VerifyEvent pEvent) {
try {
- Integer.parseInt( pEvent.text );
- } catch ( NumberFormatException e ) {
+ if ( pEvent.text.length() > 0 ) {
+ Integer.parseInt( pEvent.text );
+ }
+ } catch (NumberFormatException e) {
pEvent.doit = false;
}
}
});
+ mPortTxt.addKeyListener( new KeyAdapter () {
+ @Override
+ public void keyReleased(KeyEvent pEvent) {
+ mPort = mPortTxt.getText();
+ }
+ });
+ mPortTxt.setText( mPort );
return body;
}
diff --git a/core/source/org/openoffice/ide/eclipse/core/gui/OOoConfigPanel.java b/core/source/org/openoffice/ide/eclipse/core/gui/OOoConfigPanel.java
index f404af5..db4c408 100644
--- a/core/source/org/openoffice/ide/eclipse/core/gui/OOoConfigPanel.java
+++ b/core/source/org/openoffice/ide/eclipse/core/gui/OOoConfigPanel.java
@@ -130,7 +130,7 @@ public class OOoConfigPanel {
* @return SDK name selected
*/
public String getSDKName() {
- String sdkName = ""; //$NON-NLS-1$
+ String sdkName = new String();
if (null != mSdkRow) {
sdkName = mSdkRow.getValue();
}
@@ -141,7 +141,7 @@ public class OOoConfigPanel {
* @return OOo name selected
*/
public String getOOoName() {
- String oooName = ""; //$NON-NLS-1$
+ String oooName = new String();
if (null != mOOoRow) {
oooName = mOOoRow.getValue();
}
diff --git a/core/source/org/openoffice/ide/eclipse/core/gui/rows/ChoiceRow.java b/core/source/org/openoffice/ide/eclipse/core/gui/rows/ChoiceRow.java
index b3baccb..abea4b9 100755
--- a/core/source/org/openoffice/ide/eclipse/core/gui/rows/ChoiceRow.java
+++ b/core/source/org/openoffice/ide/eclipse/core/gui/rows/ChoiceRow.java
@@ -43,6 +43,7 @@
************************************************************************/
package org.openoffice.ide.eclipse.core.gui.rows;
+import java.util.ArrayList;
import java.util.Hashtable;
import org.eclipse.swt.SWT;
@@ -71,18 +72,9 @@ import org.eclipse.swt.widgets.Label;
public class ChoiceRow extends LabeledRow {
private Hashtable<String, String> mTranslations;
+ private ArrayList<String> mItems;
+ private int mSelected;
- /**
- * Create a new choice row. The parent composite should have a grid layout
- * with 2 or 3 horizontal spans.
- *
- * @param pParent the parent composite where to create the raw
- * @param pProperty the property name of the raw
- * @param pLabel label the label to print on the left of the raw
- */
- public ChoiceRow (Composite pParent, String pProperty, String pLabel) {
- this(pParent, pProperty, pLabel, null);
- }
/**
* Create a new choice row with a button on the right. The parent
@@ -97,48 +89,39 @@ public class ChoiceRow extends LabeledRow {
String pBrowse) {
super(pProperty);
+
+ // mField is always created
+ int numFields = 1;
mTranslations = new Hashtable<String, String>();
+ mItems = new ArrayList<String>();
+ mSelected = -1;
- Label aLabel = new Label(pParent, SWT.NONE);
- aLabel.setText(pLabel);
+ Label aLabel = null;
+ if ( pLabel != null ) {
+ aLabel = new Label(pParent, SWT.NONE);
+ aLabel.setText(pLabel);
+ numFields++;
+ }
Combo aField = new Combo(pParent, SWT.READ_ONLY);
aField.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent pEvent) {
+ mSelected = ((Combo)mField).getSelectionIndex();
FieldEvent fe = new FieldEvent(mProperty, getValue());
fireFieldChangedEvent(fe);
}
});
createContent(pParent, aLabel, aField, pBrowse);
- }
-
- /**
- * Create a new choice row.
- *
- * @param pParent the parent composite
- * @param pProperty the property name to use in events
- */
- public ChoiceRow(Composite pParent, String pProperty) {
- super(pProperty);
- mTranslations = new Hashtable<String, String>();
-
- Combo aField = new Combo(pParent, SWT.READ_ONLY);
- aField.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent pEvent) {
- FieldEvent fe = new FieldEvent(mProperty, getValue());
- fireFieldChangedEvent(fe);
- }
- });
-
- createContent(pParent, null, aField, null);
+ if ( mBrowse != null ) {
+ numFields++;
+ }
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalSpan = ((GridLayout)pParent.getLayout()).numColumns;
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = ((GridLayout)pParent.getLayout()).numColumns - numFields;
aField.setLayoutData(gd);
}
@@ -164,6 +147,7 @@ public class ChoiceRow extends LabeledRow {
public void addAll(String[] pItems) {
for (int i = 0; i < pItems.length; i++) {
((Combo)mField).add(pItems[i]);
+ mItems.add(pItems[i]);
}
}
@@ -177,15 +161,17 @@ public class ChoiceRow extends LabeledRow {
*
* @param pText the translated item text
* @param pValue the item value
- * @param pIndex te item index
+ * @param pIndex the item index
*/
public void add(String pText, String pValue, int pIndex) {
if (!mTranslations.containsKey(pText)) {
mTranslations.put(pText, pValue);
if (pIndex >= 0) {
((Combo)mField).add(pText, pIndex);
+ mItems.add( pIndex, pText );
} else {
((Combo)mField).add(pText);
+ mItems.add( pText );
}
}
}
@@ -232,6 +218,7 @@ public class ChoiceRow extends LabeledRow {
public void remove(String pText) {
mTranslations.remove(pText);
((Combo)mField).remove(pText);
+ mItems.remove( pText );
}
/**
@@ -266,6 +253,7 @@ public class ChoiceRow extends LabeledRow {
public void removeAll() {
mTranslations.clear();
((Combo)mField).removeAll();
+ mItems.clear();
}
/**
@@ -276,6 +264,7 @@ public class ChoiceRow extends LabeledRow {
*/
public void select(int pIndex) {
((Combo)mField).select(pIndex);
+ mSelected = pIndex;
// Fire a modification event to the listener
FieldEvent fe = new FieldEvent(this.mProperty, getValue());
@@ -314,7 +303,7 @@ public class ChoiceRow extends LabeledRow {
* <code>getValue()</code> to get the selected value.
*/
public String getItem(int pIndex) {
- return ((Combo)mField).getItem(pIndex);
+ return mItems.get(pIndex);
}
/**
@@ -324,7 +313,7 @@ public class ChoiceRow extends LabeledRow {
* @see Combo#getItemCount()
*/
public int getItemCount() {
- return ((Combo)mField).getItemCount();
+ return mItems.size();
}
/**
@@ -336,9 +325,8 @@ public class ChoiceRow extends LabeledRow {
public String getValue() {
String result = null;
- int selectedId = ((Combo)mField).getSelectionIndex();
- if (-1 != selectedId) {
- result = getValue(selectedId);
+ if (-1 != mSelected) {
+ result = getValue(mSelected);
}
return result;
@@ -354,7 +342,7 @@ public class ChoiceRow extends LabeledRow {
String result = null;
if (pIndex >= 0 && pIndex < getItemCount()) {
- String text = ((Combo)mField).getItem(pIndex);
+ String text = mItems.get(pIndex);
result = text;
String value = mTranslations.get(text);
diff --git a/core/source/org/openoffice/ide/eclipse/core/preferences/MainPage.java b/core/source/org/openoffice/ide/eclipse/core/preferences/MainPage.java
index c3ad4b2..a8d5faa 100755
--- a/core/source/org/openoffice/ide/eclipse/core/preferences/MainPage.java
+++ b/core/source/org/openoffice/ide/eclipse/core/preferences/MainPage.java
@@ -83,7 +83,7 @@ public class MainPage extends PreferencePage implements IWorkbenchPreferencePage
body.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mLoglevel = new ChoiceRow(body, LOGLEVEL,
- Messages.getString("MainPage.LogLevel")); //$NON-NLS-1$
+ Messages.getString("MainPage.LogLevel"), null); //$NON-NLS-1$
mLoglevel.add(Messages.getString("MainPage.Error"), //$NON-NLS-1$
LogLevels.ERROR.toString());
mLoglevel.add(Messages.getString("MainPage.Warning"), //$NON-NLS-1$
diff --git a/core/source/org/openoffice/ide/eclipse/core/unotypebrowser/UnoTypeBrowser.java b/core/source/org/openoffice/ide/eclipse/core/unotypebrowser/UnoTypeBrowser.java
index 68acd27..fe05f1f 100755
--- a/core/source/org/openoffice/ide/eclipse/core/unotypebrowser/UnoTypeBrowser.java
+++ b/core/source/org/openoffice/ide/eclipse/core/unotypebrowser/UnoTypeBrowser.java
@@ -211,7 +211,7 @@ public class UnoTypeBrowser extends StatusDialog
// create the types filter row
mTypeFilterRow = new ChoiceRow(body, F_TYPE_FILTER,
- Messages.getString("UnoTypeBrowser.FilterLabel")); //$NON-NLS-1$
+ Messages.getString("UnoTypeBrowser.FilterLabel"), null); //$NON-NLS-1$
mTypeFilterRow.setTooltip(Messages.getString("UnoTypeBrowser.FilterTooltip")); //$NON-NLS-1$
mTypeFilterRow.setFieldChangedListener(this);
setFilterValues();
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/messages.properties b/core/source/org/openoffice/ide/eclipse/core/wizards/messages.properties
index eb86675..16516d4 100644
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/messages.properties
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/messages.properties
@@ -95,3 +95,6 @@ PackageExportWizardPage.WrongDestinationError=Invalid or missing destination dir
ServiceWizardSet.WrongInitDataWarning=Wrong data for service page set initizalization
ServiceWizardSet.ServiceCreationError=Error happened during service creation
ServiceWizardSet.IsIdlTypeExistingWarning=Error determining if the idl file exists: {0}
+UnoConnectionPage.ConnectionLabel=OpenOffice.org and SDK for building
+UnoConnectionPage.Description=Set some important informations for the UNO development
+UnoConnectionPage.Title=UNO configuration
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/BaseUnoConnectionPage.java b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/BaseUnoConnectionPage.java
new file mode 100644
index 0000000..af0d48c
--- /dev/null
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/BaseUnoConnectionPage.java
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * 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 Novell, 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 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.core.wizards.pages;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+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;
+import org.openoffice.ide.eclipse.core.model.config.IOOo;
+import org.openoffice.ide.eclipse.core.model.config.ISdk;
+import org.openoffice.ide.eclipse.core.wizards.Messages;
+
+/**
+ * Base wizard page for the UNO Client configuration.
+ *
+ * <p>This class has to be sub-classed by clients to change the pages order
+ * and set the patterns for the code to open the UNO connection.</p>
+ *
+ * @author cbosdonnat
+ *
+ */
+public class BaseUnoConnectionPage extends WizardPage {
+
+ private static final int LAYOUT_COLUMNS = 3;
+
+ private OOoConfigPanel mOOoConfigPanel;
+ private ConnectionConfigPanel mCnxConfigPanel;
+
+ /**
+ * Default constructor.
+ */
+ public BaseUnoConnectionPage( ) {
+ super( "unocnxpage" ); //$NON-NLS-1$
+ setTitle( Messages.getString("UnoConnectionPage.Title") ); //$NON-NLS-1$
+ setDescription( Messages.getString("UnoConnectionPage.Description") ); //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void createControl(Composite pParent) {
+
+ Composite body = new Composite( pParent, SWT.NONE );
+ body.setLayout( new GridLayout( LAYOUT_COLUMNS, false ) );
+ body.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+
+ // Add a title label here
+ Label confLbl = new Label( body, SWT.NONE );
+ GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.horizontalSpan = LAYOUT_COLUMNS;
+ confLbl.setLayoutData( gd );
+ confLbl.setText( Messages.getString("UnoConnectionPage.ConnectionLabel") ); //$NON-NLS-1$
+
+ 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 );
+ setControl( body );
+ }
+
+ /**
+ * Defines the patterns of code to instantiate a pipe or socket UNO connection.
+ *
+ * <p>For a pipe connection, the only parameter is the pipe's name.</p>
+ *
+ * <p>For a socket connection: the parameters are:</p>
+ * <ul>
+ * <li><b>{0}</b>: the host name</li>
+ * <li><b>{1}</b>: the port name</li>
+ * </ul>
+ *
+ * @param pPipe the pattern for the pipe connection
+ * @param pSocket the pattern for the socket connection
+ */
+ public void setConnectionPatterns( String pPipe, String pSocket ) {
+ mCnxConfigPanel.setPatterns( pPipe, pSocket );
+ }
+
+ /**
+ * @return the selected OOo instance
+ */
+ public IOOo getOoo( ) {
+ return OOoContainer.getOOo( mOOoConfigPanel.getOOoName() );
+ }
+
+ /**
+ * @return the selected SDK instance
+ */
+ public ISdk getSdk( ) {
+ return SDKContainer.getSDK( mOOoConfigPanel.getSDKName() );
+ }
+
+ /**
+ * @return the C++ connection code for the sample client
+ */
+ public String getConnectionCode( ) {
+ return mCnxConfigPanel.getConnectionCode();
+ }
+}
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/InterfaceMemberDialog.java b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/InterfaceMemberDialog.java
index 5f30b95..261dff6 100644
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/InterfaceMemberDialog.java
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/InterfaceMemberDialog.java
@@ -266,7 +266,7 @@ public class InterfaceMemberDialog extends TitleAreaDialog implements
typeComposite.setLayoutData(gd);
typeComposite.setLayout(new GridLayout(LabeledRow.LAYOUT_COLUMNS, false));
- mMemberTypeRow = new ChoiceRow(typeComposite, MEMBER_TYPE);
+ mMemberTypeRow = new ChoiceRow(typeComposite, MEMBER_TYPE, null, null );
mMemberTypeRow.add(
Messages.getString("InterfaceMemberDialog.MethodChoice"), "method"); //$NON-NLS-1$ //$NON-NLS-2$
mMemberTypeRow.add(
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/NewUnoProjectPage.java b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/NewUnoProjectPage.java
index 4b575e8..bd87064 100755
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/NewUnoProjectPage.java
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/NewUnoProjectPage.java
@@ -356,7 +356,7 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
// Adding the programming language row
mLanguageRow = new ChoiceRow(body, LANGUAGE,
- Messages.getString("NewUnoProjectPage.Language")); //$NON-NLS-1$
+ Messages.getString("NewUnoProjectPage.Language"), null); //$NON-NLS-1$
mLanguageRow.setTooltip(Messages.getString("NewUnoProjectPage.LanguageTooltip")); //$NON-NLS-1$
// Sets the available programming languages
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/PackageExportWizardPage.java b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/PackageExportWizardPage.java
index 14665c9..ea0db11 100644
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/PackageExportWizardPage.java
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/PackageExportWizardPage.java
@@ -208,7 +208,7 @@ public class PackageExportWizardPage extends WizardPage {
});
mOOoVersion = new ChoiceRow(body, OOVERSION,
- Messages.getString("PackageExportWizardPage.OOoVersionLabel")); //$NON-NLS-1$
+ Messages.getString("PackageExportWizardPage.OOoVersionLabel"), null); //$NON-NLS-1$
mOOoVersion.setTooltip(Messages.getString("PackageExportWizardPage.OOoVersionTooltip")); //$NON-NLS-1$
mOOoVersion.add("1.x", "zip"); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/cpp/build/MANIFEST.MF.in b/cpp/build/MANIFEST.MF.in
index c219353..f155010 100644
--- a/cpp/build/MANIFEST.MF.in
+++ b/cpp/build/MANIFEST.MF.in
@@ -2,17 +2,18 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: C++ extensions support for OOo
Bundle-SymbolicName: org.openoffice.ide.eclipse.cpp;singleton:=true
-Bundle-Version: 0.0.1
+Bundle-Version: @VERSION@
Bundle-Activator: org.openoffice.ide.eclipse.cpp.Activator
Bundle-Vendor: Cédric Bosdonnat
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.openoffice.ide.eclipse.core;bundle-version="1.1.0",
- org.eclipse.core.resources;bundle-version="3.4.1",
+ org.eclipse.core.resources,
org.eclipse.cdt.core;bundle-version="5.0.1",
org.eclipse.cdt.managedbuilder.core;bundle-version="5.0.1",
- org.eclipse.cdt.ui;bundle-version="5.1.0",
- org.eclipse.ui.ide;bundle-version="3.5.0"
+ org.eclipse.cdt.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.cheatsheets
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
diff --git a/cpp/doc/cheatsheets/unoclient.xml b/cpp/doc/cheatsheets/unoclient.xml
index 5742df5..8cd4c60 100644
--- a/cpp/doc/cheatsheets/unoclient.xml
+++ b/cpp/doc/cheatsheets/unoclient.xml
@@ -11,7 +11,7 @@
<item
title="Create the C++ UNO Client">
<description>
- <b>Create a new project of type C++ UNO Client application.</b>
+ Create a new project of type <b>C++ UNO Client application</b>.
<br/><br/>
Configure the OpenOffice.org instance and SDK used to build to program and configure the OpenOffice.org connection.
</description>
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 6811142..210e648 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java
@@ -31,18 +31,8 @@
package org.openoffice.ide.eclipse.cpp.client;
import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-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;
-import org.openoffice.ide.eclipse.core.model.config.IOOo;
-import org.openoffice.ide.eclipse.core.model.config.ISdk;
+import org.openoffice.ide.eclipse.core.wizards.pages.BaseUnoConnectionPage;
/**
* Wizard page for the UNO Client configuration.
@@ -50,73 +40,18 @@ import org.openoffice.ide.eclipse.core.model.config.ISdk;
* @author cbosdonnat
*
*/
-public class UnoConnectionPage extends WizardPage {
-
- private static final int LAYOUT_COLUMNS = 3;
+public class UnoConnectionPage extends BaseUnoConnectionPage {
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;
-
- /**
- * Default constructor.
- */
- public UnoConnectionPage( ) {
- super( "unocnxpage" ); //$NON-NLS-1$
- setTitle( Messages.getString("UnoConnectionPage.Title") ); //$NON-NLS-1$
- setDescription( Messages.getString("UnoConnectionPage.Description") ); //$NON-NLS-1$
- }
-
@Override
public void createControl(Composite pParent) {
- Composite body = new Composite( pParent, SWT.NONE );
- body.setLayout( new GridLayout( LAYOUT_COLUMNS, false ) );
- body.setLayoutData( new GridData( GridData.FILL_BOTH ) );
-
- // Add a title label here
- Label confLbl = new Label( body, SWT.NONE );
- GridData gd = new GridData( GridData.FILL_HORIZONTAL );
- gd.horizontalSpan = LAYOUT_COLUMNS;
- confLbl.setLayoutData( gd );
- confLbl.setText( Messages.getString("UnoConnectionPage.ConnectionLabel") ); //$NON-NLS-1$
-
- 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 );
- }
-
- /**
- * @return the selected OOo instance
- */
- public IOOo getOoo( ) {
- return OOoContainer.getOOo( mOOoConfigPanel.getOOoName() );
- }
-
- /**
- * @return the selected SDK instance
- */
- public ISdk getSdk( ) {
- return SDKContainer.getSDK( mOOoConfigPanel.getSDKName() );
- }
-
- /**
- * @return the C++ connection code for the sample client
- */
- public String getConnectionCode( ) {
- return mCnxConfigPanel.getConnectionCode();
+ super.createControl( pParent );
+ setConnectionPatterns( PIPE_PATTERN, SOCKET_PATTERN );
}
/**
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/messages.properties b/cpp/source/org/openoffice/ide/eclipse/cpp/client/messages.properties
index b191293..b0c4257 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/client/messages.properties
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/messages.properties
@@ -2,6 +2,3 @@ ClientWizard.ClientConfigError=Couldn't set OOo Client config
ClientWizard.ClientWizardBanner=icons/uno_client_wiz.png
ClientWizard.Description=Create the UNO C++ client application project
ClientWizard.Title=UNO Client C++ project
-UnoConnectionPage.ConnectionLabel=OpenOffice.org and SDK for building
-UnoConnectionPage.Description=Set some important informations for the UNO development
-UnoConnectionPage.Title=UNO configuration
diff --git a/java/META-INF/MANIFEST.MF b/java/META-INF/MANIFEST.MF
index 049fba1..d74c71c 100644
--- a/java/META-INF/MANIFEST.MF
+++ b/java/META-INF/MANIFEST.MF
@@ -14,6 +14,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.jdt,
org.eclipse.jdt.ui,
org.eclipse.jface.text,
- org.eclipse.jdt.junit;bundle-version="3.5.0"
+ org.eclipse.jdt.junit;bundle-version="3.5.0",
+ org.eclipse.ui.ide,
+ org.eclipse.ui.cheatsheets
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/java/build/MANIFEST.MF.in b/java/build/MANIFEST.MF.in
index 68b7489..9dfeed6 100644
--- a/java/build/MANIFEST.MF.in
+++ b/java/build/MANIFEST.MF.in
@@ -4,7 +4,7 @@ Bundle-Name: Java Plug-in for OOo eclipse integration
Bundle-SymbolicName: org.openoffice.ide.eclipse.java; singleton:=true
Bundle-Version: @VERSION@
Bundle-Activator: org.openoffice.ide.eclipse.java.OOoJavaPlugin
-Bundle-Vendor: OpenOffice.org
+Bundle-Vendor: Cédric Bosdonnat
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
diff --git a/java/doc/cheatsheets/unoclient.xml b/java/doc/cheatsheets/unoclient.xml
new file mode 100644
index 0000000..d14510c
--- /dev/null
+++ b/java/doc/cheatsheets/unoclient.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cheatsheet
+ title="Create a Java UNO client">
+ <intro>
+ <description>
+ OpenOffice.org can be used as well as a server. Creating clients connecting to it is not an easy task for beginners and the informations are split all over the web.
+<br/><br/>
+<b>Follow the next steps to create a new Java UNO Client really quickly.</b>
+ </description>
+ </intro>
+ <item
+ title="Create the Java UNO Client">
+ <description>
+ Create a new project of type <b>Java UNO Client application</b> .
+<br/><br/>
+Configure the OpenOffice.org instance and SDK used to build to program and configure the OpenOffice.org connection.
+ </description>
+ <command
+ required="true"
+ serialization="org.eclipse.ui.newWizard(newWizardId=org.openoffice.ide.eclipse.java.client)"/>
+ </item>
+ <item
+ title="Write the client code">
+ <description>
+ <b>Replace the TODO comment</b> by the code using the UNO connection to OpenOffice.org.
+ </description>
+ </item>
+ <item
+ title="Start OpenOffice.org">
+ <description>
+ OpenOffice.org needs to be started with the following parameter depending on your connection configuration:
+<br/><br/>
+<b>Pipe connection: </b><br/> -accept="pipe,name=<b>pipename</b>;urp;StarOffice.ServiceManager"
+<br/><br/>
+<b>Socket connection: </b><br/> -accept="socket,host=<b>host</b>,port=<b>port</b>;urp;StarOffice.ServiceManager"
+ </description>
+ </item>
+ <item
+ title="Run the client">
+ <description>
+ <b>Everything is done!</b> Now run the new UNO client program.
+<br/><br/>
+To run your application, right-click on your class in the Package Explorer and select Run As > Java Application. The Console view should appear at the bottom and display the output.
+ </description>
+ </item>
+</cheatsheet>
diff --git a/java/icons/uno_client.png b/java/icons/uno_client.png
new file mode 100644
index 0000000..d58ec3e
Binary files /dev/null and b/java/icons/uno_client.png differ
diff --git a/java/icons/uno_client_wiz.png b/java/icons/uno_client_wiz.png
new file mode 100644
index 0000000..ae74ced
Binary files /dev/null and b/java/icons/uno_client_wiz.png differ
diff --git a/java/plugin.xml b/java/plugin.xml
index 508bbfd..e9e7f82 100644
--- a/java/plugin.xml
+++ b/java/plugin.xml
@@ -35,5 +35,28 @@
name="OpenOffice.org Libraries">
</classpathContainerPage>
</extension>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ canFinishEarly="false"
+ category="org.openoffice.ide.eclipse.core"
+ class="org.openoffice.ide.eclipse.java.client.ClientWizard"
+ hasPages="true"
+ icon="icons/uno_client.png"
+ id="org.openoffice.ide.eclipse.java.client"
+ name="Java UNO client application"
+ project="true">
+ </wizard>
+ </extension>
+ <extension
+ point="org.eclipse.ui.cheatsheets.cheatSheetContent">
+ <cheatsheet
+ category="org.openoffice.ide.eclipse.core.cheatsheets"
+ composite="false"
+ contentFile="doc/cheatsheets/unoclient.xml"
+ id="org.openoffice.ide.eclipse.java.unoclient"
+ name="Create a Java UNO client">
+ </cheatsheet>
+ </extension>
</plugin>
diff --git a/java/source/org/openoffice/ide/eclipse/java/JavaWizardPage.java b/java/source/org/openoffice/ide/eclipse/java/JavaWizardPage.java
index a90087e..fbc4dd9 100644
--- a/java/source/org/openoffice/ide/eclipse/java/JavaWizardPage.java
+++ b/java/source/org/openoffice/ide/eclipse/java/JavaWizardPage.java
@@ -119,7 +119,7 @@ public class JavaWizardPage extends LanguageWizardPage {
// Create the Java version row
mJavaVersionRow = new ChoiceRow(body, JAVA_VERSION,
- Messages.getString("JavaWizardPage.JavaVersion")); //$NON-NLS-1$
+ Messages.getString("JavaWizardPage.JavaVersion"), null); //$NON-NLS-1$
mJavaVersionRow.add(Messages.getString("JavaWizardPage.Java4"), "java4"); //$NON-NLS-1$ //$NON-NLS-2$
mJavaVersionRow.add(Messages.getString("JavaWizardPage.Java5"), "java5"); //$NON-NLS-1$ //$NON-NLS-2$
mJavaVersionRow.setFieldChangedListener( new IFieldChangedListener() {
@@ -133,7 +133,7 @@ public class JavaWizardPage extends LanguageWizardPage {
// Create the test row
mJavaTestsRow = new BooleanRow( body, JAVA_TESTS,
- "Include base classes for tests" );
+ Messages.getString("JavaWizardPage.IncludeTestClasses") ); //$NON-NLS-1$
mJavaTestsRow.setValue( true );
mJavaTestsRow.setFieldChangedListener( new IFieldChangedListener() {
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/AbstractConnection.java.tpl b/java/source/org/openoffice/ide/eclipse/java/client/AbstractConnection.java.tpl
new file mode 100644
index 0000000..f1fe970
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/AbstractConnection.java.tpl
@@ -0,0 +1,142 @@
+//
+// JODConverter - Java OpenDocument Converter
+// Copyright (C) 2004-2007 - Mirko Nasato <mirko at artofsolving.com>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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.
+// http://www.gnu.org/copyleft/lesser.html
+//
+// Contributor:
+// Laurent Godard <lgodard at nuxeo.com>
+//
+package {0};
+
+import java.net.ConnectException;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.bridge.XBridge;
+import com.sun.star.bridge.XBridgeFactory;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.connection.NoConnectException;
+import com.sun.star.connection.XConnection;
+import com.sun.star.connection.XConnector;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.ucb.XFileIdentifierConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+public abstract class AbstractConnection implements Connection, XEventListener '{'
+
+ private String connectionString;
+ private XComponent bridgeComponent;
+ private XMultiComponentFactory serviceManager;
+ private XComponentContext componentContext;
+ private XBridge bridge;
+ private boolean connected = false;
+ private boolean expectingDisconnection = false;
+
+ protected AbstractConnection(String connectionString) '{'
+ this.connectionString = connectionString;
+ }
+
+ public synchronized void connect() throws ConnectException '{'
+ System.err.println("connecting");
+ try '{'
+ XComponentContext localContext = Bootstrap.createInitialComponentContext(null);
+ XMultiComponentFactory localServiceManager = localContext.getServiceManager();
+ XConnector connector = (XConnector) UnoRuntime.queryInterface(XConnector.class,
+ localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext));
+ XConnection connection = connector.connect(connectionString);
+ XBridgeFactory bridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class,
+ localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext));
+ bridge = bridgeFactory.createBridge("", "urp", connection, null);
+ bridgeComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, bridge);
+ bridgeComponent.addEventListener(this);
+ serviceManager = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class,
+ bridge.getInstance("StarOffice.ServiceManager"));
+ XPropertySet properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, serviceManager);
+ componentContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class,
+ properties.getPropertyValue("DefaultContext"));
+ connected = true;
+ System.err.println("connected");
+ } catch (NoConnectException connectException) '{'
+ throw new ConnectException("connection failed: "+ connectionString +": " + connectException.getMessage());
+ } catch (Exception exception) '{'
+ throw new OpenOfficeException("connection failed: "+ connectionString, exception);
+ }
+ }
+
+ public synchronized void disconnect() '{'
+ System.err.println("disconnecting");
+ expectingDisconnection = true;
+ bridgeComponent.dispose();
+ }
+
+ public boolean isConnected() '{'
+ return connected;
+ }
+
+ public void disposing(EventObject event) '{'
+ connected = false;
+ if (expectingDisconnection) '{'
+ System.err.println("disconnected");
+ } else '{'
+ System.err.println("disconnected unexpectedly");
+ }
+ expectingDisconnection = false;
+ }
+
+ // for unit tests only
+ void simulateUnexpectedDisconnection() '{'
+ disposing(null);
+ if ( bridgeComponent != null ) '{'
+ bridgeComponent.dispose();
+ }
+ }
+
+ private Object getService(String className) '{'
+ try '{'
+ if (!connected) '{'
+ System.err.println("trying to (re)connect");
+ connect();
+ }
+ return serviceManager.createInstanceWithContext(className, componentContext);
+ } catch (Exception exception) '{'
+ throw new OpenOfficeException("could not obtain service: " + className, exception);
+ }
+ }
+
+ public XComponentLoader getDesktop() '{'
+ return (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,
+ getService("com.sun.star.frame.Desktop"));
+ }
+
+ public XFileIdentifierConverter getFileContentProvider() '{'
+ return (XFileIdentifierConverter) UnoRuntime.queryInterface(XFileIdentifierConverter.class,
+ getService("com.sun.star.ucb.FileContentProvider"));
+ }
+
+ public XBridge getBridge() '{'
+ return bridge;
+ }
+
+ public XMultiComponentFactory getRemoteServiceManager() '{'
+ return serviceManager;
+ }
+
+ public XComponentContext getComponentContext() '{'
+ return componentContext;
+ }
+
+}
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/ClientWizard.java b/java/source/org/openoffice/ide/eclipse/java/client/ClientWizard.java
new file mode 100644
index 0000000..17c53e7
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/ClientWizard.java
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * 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 Novell, 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 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.java.client;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne;
+import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageTwo;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+import org.openoffice.ide.eclipse.core.PluginLogger;
+import org.openoffice.ide.eclipse.core.utils.WorkbenchHelper;
+import org.openoffice.ide.eclipse.java.OOoJavaPlugin;
+import org.openoffice.ide.eclipse.java.build.OOoContainerPage;
+import org.openoffice.ide.eclipse.java.utils.TemplatesHelper;
+
+/**
+ * Class for the Java UNO client wizard.
+ *
+ * @author cbosdonnat
+ *
+ */
+public class ClientWizard extends BasicNewResourceWizard {
+
+ private static final String[] HELPER_CLASSES = {
+ "AbstractConnection", //$NON-NLS-1$
+ "Connection", //$NON-NLS-1$
+ "OpenOfficeException", //$NON-NLS-1$
+ "PipeConnection", //$NON-NLS-1$
+ "SocketConnection" //$NON-NLS-1$
+ };
+
+ private static final String DEST_PACKAGE = "org.openoffice.connection"; //$NON-NLS-1$
+ private static final String CLIENT_CLASS = "UnoClient"; //$NON-NLS-1$
+
+ private IWorkbenchPage mActivePage;
+
+ private NewJavaProjectWizardPageOne mFirstPage;
+ private NewJavaProjectWizardPageTwo mThirdPage;
+ private UnoConnectionPage mCnxPage;
+
+ /**
+ * Default constructor.
+ */
+ public ClientWizard() {
+ super();
+ setWindowTitle( Messages.getString("ClientWizard.Title") ); //$NON-NLS-1$
+ mActivePage = WorkbenchHelper.getActivePage();
+ }
+
+ @Override
+ public boolean performFinish() {
+ boolean res = true;
+
+ Job job = new Job( Messages.getString("ClientWizard.CreationJobTitle") ) { //$NON-NLS-1$
+ @Override
+ protected IStatus run( IProgressMonitor pMonitor ) {
+
+ Status status = new Status( IStatus.OK, OOoJavaPlugin.PLUGIN_ID,
+ Messages.getString("ClientWizard.ProjectCreated") ); //$NON-NLS-1$
+
+ try {
+ mThirdPage.performFinish( pMonitor );
+ setupClientProject( mThirdPage.getJavaProject() );
+ } catch ( Exception e ) {
+ PluginLogger.error( Messages.getString("ClientWizard.ProjectCreationError"), e ); //$NON-NLS-1$
+ status = new Status( IStatus.ERROR, OOoJavaPlugin.PLUGIN_ID,
+ Messages.getString("ClientWizard.ProjectCreationError") ); //$NON-NLS-1$
+ }
+ return status;
+ }
+ };
+
+ job.schedule();
+
+ return res;
+ }
+
+ /**
+ * Configure the Java project in order to have a Java UNO client project.
+ *
+ * @param pJavaProject the Java project to configure
+ */
+ protected void setupClientProject(IJavaProject pJavaProject ) {
+ // Generate the sample classes in org.openoffice.connection
+ IProject prj = pJavaProject.getProject();
+ IClasspathEntry[] srcEntries = mFirstPage.getSourceClasspathEntries();
+ IFolder srcFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder( srcEntries[0].getPath() );
+ IPath srcPath = srcFolder.getProjectRelativePath();
+
+ String path = srcPath.append( DEST_PACKAGE.replace( '.', '/' ) ).toString();
+ for ( String helperClass : HELPER_CLASSES ) {
+ TemplatesHelper.copyTemplate( prj, helperClass, ClientWizard.class, path, DEST_PACKAGE );
+ }
+
+ TemplatesHelper.copyTemplate( prj, CLIENT_CLASS, ClientWizard.class,
+ path, DEST_PACKAGE, mCnxPage.getConnectionCode() );
+
+ // Add the OpenOffice.org libraries to the project
+ OOoContainerPage.addOOoDependencies( mCnxPage.getOoo(), pJavaProject );
+
+ // Refresh the project
+ try {
+ prj.refreshLocal( IResource.DEPTH_INFINITE, null);
+ } catch (Exception e ) {
+ }
+
+ // Show the Uno client class
+ IFolder srcDir = prj.getFolder( path );
+ IFile javaClientFile = srcDir.getFile( CLIENT_CLASS + ".java" ); //$NON-NLS-1$
+ selectAndReveal( javaClientFile );
+ WorkbenchHelper.showFile( javaClientFile, mActivePage );
+ }
+
+ @Override
+ public void addPages() {
+
+ mFirstPage = new NewJavaProjectWizardPageOne();
+ addPage( mFirstPage );
+
+ mCnxPage = new UnoConnectionPage();
+ addPage( mCnxPage );
+
+ mThirdPage = new NewJavaProjectWizardPageTwo( mFirstPage );
+ addPage( mThirdPage );
+ }
+}
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/Connection.java.tpl b/java/source/org/openoffice/ide/eclipse/java/client/Connection.java.tpl
new file mode 100644
index 0000000..675031a
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/Connection.java.tpl
@@ -0,0 +1,53 @@
+//
+// JODConverter - Java OpenDocument Converter
+// Copyright (C) 2004-2007 - Mirko Nasato <mirko at artofsolving.com>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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.
+// http://www.gnu.org/copyleft/lesser.html
+//
+package {0};
+
+import java.net.ConnectException;
+
+import com.sun.star.bridge.XBridge;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.ucb.XFileIdentifierConverter;
+import com.sun.star.uno.XComponentContext;
+
+/**
+ * A UNO remote protocol connection to a listening OpenOffice.org instance
+ */
+public interface Connection '{'
+
+ public void connect() throws ConnectException;
+
+ public void disconnect();
+
+ public boolean isConnected();
+
+ /**
+ * @return the com.sun.star.frame.Desktop service
+ */
+ public XComponentLoader getDesktop();
+
+ /**
+ * @return the com.sun.star.ucb.FileContentProvider service
+ */
+ public XFileIdentifierConverter getFileContentProvider();
+
+ public XBridge getBridge();
+
+ public XMultiComponentFactory getRemoteServiceManager();
+
+ public XComponentContext getComponentContext();
+
+}
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/Messages.java b/java/source/org/openoffice/ide/eclipse/java/client/Messages.java
new file mode 100644
index 0000000..e6b5067
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/Messages.java
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * 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 Novell, 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 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.java.client;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Messages for the package.
+ *
+ * @author cbosdonnat
+ *
+ */
+public class Messages {
+
+ private static final String BUNDLE_NAME = "org.openoffice.ide.eclipse.java.client.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ /**
+ * Default constructor.
+ */
+ private Messages() {
+ }
+
+ /**
+ * Get the string from it's key.
+ *
+ * @param pKey the key of the string
+ *
+ * @return the internationalized string
+ */
+ public static String getString(String pKey) {
+ String string = '!' + pKey + '!';
+ try {
+ string = RESOURCE_BUNDLE.getString(pKey);
+ } catch (MissingResourceException e) {
+ }
+ return string;
+ }
+}
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/OpenOfficeException.java.tpl b/java/source/org/openoffice/ide/eclipse/java/client/OpenOfficeException.java.tpl
new file mode 100644
index 0000000..6cb68ce
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/OpenOfficeException.java.tpl
@@ -0,0 +1,29 @@
+//
+// JODConverter - Java OpenDocument Converter
+// Copyright (C) 2004-2007 - Mirko Nasato <mirko at artofsolving.com>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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.
+// http://www.gnu.org/copyleft/lesser.html
+//
+package {0};
+
+public class OpenOfficeException extends RuntimeException '{'
+
+ private static final long serialVersionUID = 1L;
+
+ public OpenOfficeException(String message) '{'
+ super(message);
+ }
+
+ public OpenOfficeException(String message, Throwable cause) '{'
+ super(message, cause);
+ }
+}
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/PipeConnection.java.tpl b/java/source/org/openoffice/ide/eclipse/java/client/PipeConnection.java.tpl
new file mode 100644
index 0000000..81efdc1
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/PipeConnection.java.tpl
@@ -0,0 +1,32 @@
+//
+// JODConverter - Java OpenDocument Converter
+// Copyright (C) 2004-2007 - Mirko Nasato <mirko at artofsolving.com>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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.
+// http://www.gnu.org/copyleft/lesser.html
+//
+package {0};
+
+/**
+ * OpenOffice connection using a named pipe
+ * <p>
+ * <b>Warning!</b> This requires the <i>sal3</i> native library shipped with OpenOffice.org;
+ * it must be made available via the <i>java.library.path</i> parameter, e.g.
+ * <pre>
+ * java -Djava.library.path=/opt/openoffice.org/program my.App
+ * </pre>
+ */
+public class PipeConnection extends AbstractConnection '{'
+
+ public PipeConnection(String pipeName) '{'
+ super("pipe,name="+ pipeName);
+ }
+}
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/SocketConnection.java.tpl b/java/source/org/openoffice/ide/eclipse/java/client/SocketConnection.java.tpl
new file mode 100644
index 0000000..0ca779a
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/SocketConnection.java.tpl
@@ -0,0 +1,29 @@
+//
+// JODConverter - Java OpenDocument Converter
+// Copyright (C) 2004-2007 - Mirko Nasato <mirko at artofsolving.com>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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.
+// http://www.gnu.org/copyleft/lesser.html
+//
+package {0};
+
+public class SocketConnection extends AbstractConnection '{'
+
+ public static final String DEFAULT_HOST = "localhost";
+
+ public SocketConnection(int port) '{'
+ this(DEFAULT_HOST, port);
+ }
+
+ public SocketConnection(String host, int port) '{'
+ super("socket,host=" + host + ",port=" + port + ",tcpNoDelay=1");
+ }
+}
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/UnoClient.java.tpl b/java/source/org/openoffice/ide/eclipse/java/client/UnoClient.java.tpl
new file mode 100644
index 0000000..78a5df7
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/UnoClient.java.tpl
@@ -0,0 +1,34 @@
+package {0};
+
+import com.sun.star.frame.XDesktop;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+public class UnoClient '{'
+
+ public static void main(String[] args) '{'
+ AbstractConnection cnx = null;
+
+ try '{'
+ {1}
+ System.out.println("Connecting to OOo...");
+ cnx.connect();
+
+ System.out.println( "Trying to get the component context" );
+ if ( cnx.getComponentContext() != null ) '{'
+ XComponentContext xCtx = cnx.getComponentContext();
+
+ // TODO Use the UNO connection here
+
+ }
+ } catch (Exception e) '{'
+ e.printStackTrace();
+ } finally '{'
+ if ( cnx != null ) '{'
+ System.out.println( "Disconnecting from OOo..." );
+ cnx.disconnect();
+ }
+ }
+ }
+}
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/UnoConnectionPage.java b/java/source/org/openoffice/ide/eclipse/java/client/UnoConnectionPage.java
new file mode 100644
index 0000000..f846238
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/UnoConnectionPage.java
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * 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 Novell, 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 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.java.client;
+
+import org.eclipse.swt.widgets.Composite;
+import org.openoffice.ide.eclipse.core.wizards.pages.BaseUnoConnectionPage;
+
+/**
+ * Wizard page for the UNO Client configuration.
+ *
+ * @author cbosdonnat
+ *
+ */
+public class UnoConnectionPage extends BaseUnoConnectionPage {
+
+ private static final String PIPE_PATTERN = "cnx = new PipeConnection( \"{0}\" );"; //$NON-NLS-1$
+ private static final String SOCKET_PATTERN = "cnx = new SocketConnection( \"{0}\", {1} );"; //$NON-NLS-1$
+
+ @Override
+ public void createControl(Composite pParent) {
+ super.createControl(pParent);
+ setConnectionPatterns( PIPE_PATTERN, SOCKET_PATTERN );
+ }
+}
diff --git a/java/source/org/openoffice/ide/eclipse/java/client/messages.properties b/java/source/org/openoffice/ide/eclipse/java/client/messages.properties
new file mode 100644
index 0000000..cb3a33d
--- /dev/null
+++ b/java/source/org/openoffice/ide/eclipse/java/client/messages.properties
@@ -0,0 +1,4 @@
+ClientWizard.CreationJobTitle=Java UNO client creation
+ClientWizard.ProjectCreated=Project created
+ClientWizard.ProjectCreationError=Error creating UNO client application
+ClientWizard.Title=Java UNO Client wizard
diff --git a/java/source/org/openoffice/ide/eclipse/java/messages.properties b/java/source/org/openoffice/ide/eclipse/java/messages.properties
index 5f6590f..0a2d00f 100644
--- a/java/source/org/openoffice/ide/eclipse/java/messages.properties
+++ b/java/source/org/openoffice/ide/eclipse/java/messages.properties
@@ -4,6 +4,7 @@ Language.UnreadableOutputError=Unreadable output error
Language.ClasspathSetFailed=Error while setting the project classpath
Language.CreateCodeError=Code generation failed
Language.GetClasspathError=Failed to get the project classpath
+JavaWizardPage.IncludeTestClasses=Include base classes for tests
JavaWizardPage.InvalidClassNameError=Not a valid class name
JavaWizardPage.RegistrationClassName=Registration class name
JavaWizardPage.RegistrationClassNameTooltip=Defines the implementation name of the service.
diff --git a/java/source/org/openoffice/ide/eclipse/java/registration/RegistrationHelper.java b/java/source/org/openoffice/ide/eclipse/java/registration/RegistrationHelper.java
index 06ac9e5..34e67b1 100644
--- a/java/source/org/openoffice/ide/eclipse/java/registration/RegistrationHelper.java
+++ b/java/source/org/openoffice/ide/eclipse/java/registration/RegistrationHelper.java
@@ -49,9 +49,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
-import java.text.MessageFormat;
import java.util.Vector;
import org.eclipse.core.resources.IFile;
diff --git a/java/source/org/openoffice/ide/eclipse/java/tests/Messages.java b/java/source/org/openoffice/ide/eclipse/java/tests/Messages.java
index 4e5f522..e0dda99 100644
--- a/java/source/org/openoffice/ide/eclipse/java/tests/Messages.java
+++ b/java/source/org/openoffice/ide/eclipse/java/tests/Messages.java
@@ -1,22 +1,70 @@
+/*************************************************************************
+ *
+ * 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 Novell, 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 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
package org.openoffice.ide.eclipse.java.tests;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+/**
+ * Messages for the package.
+ *
+ * @author cbosdonnat
+ *
+ */
public class Messages {
+
private static final String BUNDLE_NAME = "org.openoffice.ide.eclipse.java.tests.messages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
+ /**
+ * Default constructor.
+ */
private Messages() {
}
- public static String getString(String key) {
+ /**
+ * Get the string from it's key.
+ *
+ * @param pKey the key of the string
+ *
+ * @return the internationalized string
+ */
+ public static String getString(String pKey) {
+ String string = '!' + pKey + '!';
try {
- return RESOURCE_BUNDLE.getString(key);
+ string = RESOURCE_BUNDLE.getString(pKey);
} catch (MissingResourceException e) {
- return '!' + key + '!';
}
+ return string;
}
}
diff --git a/java/source/org/openoffice/ide/eclipse/java/utils/TemplatesHelper.java b/java/source/org/openoffice/ide/eclipse/java/utils/TemplatesHelper.java
index 748ed2b..f9f3d28 100644
--- a/java/source/org/openoffice/ide/eclipse/java/utils/TemplatesHelper.java
+++ b/java/source/org/openoffice/ide/eclipse/java/utils/TemplatesHelper.java
@@ -40,6 +40,8 @@ import java.text.MessageFormat;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.openoffice.ide.eclipse.core.PluginLogger;
import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
@@ -73,27 +75,50 @@ public class TemplatesHelper {
* @param pClazz the class from which to load the resource file
* @param pDestSuffix the subpath in which the file should be copied, relatively to
* the implementation package.
+ * @param pArgs additional arguments to pass to the formatter
*/
public static void copyTemplate( IUnoidlProject pProject, String pTemplateName,
- Class<?> pClazz, String pDestSuffix ) {
+ Class<?> pClazz, String pDestSuffix, Object... pArgs ) {
- String fileName = pTemplateName + TEMPLATE_EXT;
+ IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( pProject.getName() );
- // Get the path where to place the files
IPath relPath = pProject.getImplementationPath();
relPath = relPath.append( pDestSuffix );
IFolder dest = pProject.getFolder(relPath);
- relPath.toFile().mkdirs();
-
// Compute the name of the project's implementation package
String implPkg = pProject.getCompanyPrefix() + "." + pProject.getOutputExtension(); //$NON-NLS-1$
+ Object[] args = new Object[ pArgs.length + 1 ];
+ args[0] = implPkg;
+ System.arraycopy( pArgs, 0, args, 1, pArgs.length );
+
+ copyTemplate( prj, pTemplateName, pClazz,
+ dest.getProjectRelativePath().toString(), args );
+ }
+
+ /**
+ * Copies the template to the project.
+ *
+ * @param pProject the project where to copy the file
+ * @param pTemplateName the template name (without the extension)
+ * @param pClazz the class from which to load the resource file
+ * @param pDestPath the path in which the file should be copied, relatively to
+ * the project root.
+ * @param pArgs additional arguments to pass to the formatter
+ */
+ public static void copyTemplate( IProject pProject, String pTemplateName,
+ Class<?> pClazz, String pDestPath, Object... pArgs ) {
+
+ String fileName = pTemplateName + TEMPLATE_EXT;
+
+ // Get the path where to place the files
+ IFolder dest = pProject.getFolder( pDestPath );
+ dest.getProjectRelativePath().toFile().mkdirs();
// Read the template into a buffer
FileWriter writer = null;
-
BufferedReader patternReader = null;
InputStream in = null;
try {
@@ -114,7 +139,7 @@ public class TemplatesHelper {
// Loop over the lines, format and write them.
String line = patternReader.readLine();
while (line != null) {
- line = MessageFormat.format(line, new Object[]{implPkg});
+ line = MessageFormat.format(line, pArgs );
writer.append(line + "\n"); //$NON-NLS-1$
line = patternReader.readLine();
}
More information about the ooo-build-commit
mailing list