[ooo-build-commit] ooeclipse: Branch 'master'
Cédric Bosdonnat
cbosdo at kemper.freedesktop.org
Tue Sep 8 10:41:36 PDT 2009
core/source/org/openoffice/ide/eclipse/core/gui/OOoConfigPanel.java | 296 ++++++++++
core/source/org/openoffice/ide/eclipse/core/gui/messages.properties | 7
core/source/org/openoffice/ide/eclipse/core/wizards/messages.properties | 6
core/source/org/openoffice/ide/eclipse/core/wizards/pages/NewUnoProjectPage.java | 245 --------
cpp/META-INF/MANIFEST.MF | 4
cpp/icons/uno_client.gif |binary
cpp/icons/uno_client_wiz.png |binary
cpp/plugin.xml | 12
cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java | 49 -
cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java | 139 ++++
cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoClientWizardPage.java | 93 +++
cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java | 110 +++
cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx | 201 ++++++
cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.hxx | 89 +++
14 files changed, 992 insertions(+), 259 deletions(-)
New commits:
commit 6a55caa349458a7c6efee11e4b0f13706938bc7a
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date: Tue Sep 8 19:41:28 2009 +0200
Added a C++ UNO Client wizard
The C++ project is now generated. The includes for the UNO types of the
OOo installation aren't added yet, and the launch configuration isn't
modified.
diff --git a/core/source/org/openoffice/ide/eclipse/core/gui/OOoConfigPanel.java b/core/source/org/openoffice/ide/eclipse/core/gui/OOoConfigPanel.java
new file mode 100644
index 0000000..f404af5
--- /dev/null
+++ b/core/source/org/openoffice/ide/eclipse/core/gui/OOoConfigPanel.java
@@ -0,0 +1,296 @@
+/*************************************************************************
+ *
+ * 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.gui;
+
+import java.util.Vector;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.openoffice.ide.eclipse.core.gui.rows.ChoiceRow;
+import org.openoffice.ide.eclipse.core.model.OOoContainer;
+import org.openoffice.ide.eclipse.core.model.SDKContainer;
+import org.openoffice.ide.eclipse.core.model.config.IConfigListener;
+import org.openoffice.ide.eclipse.core.model.config.IOOo;
+import org.openoffice.ide.eclipse.core.model.config.ISdk;
+
+/**
+ * Class providing the OOo and SDK configuration rows.
+ *
+ * @author cbosdonnat
+ *
+ */
+public class OOoConfigPanel {
+
+ private static final String SDK = "__sdk"; //$NON-NLS-1$
+ private static final String OOO = "__ooo"; //$NON-NLS-1$
+
+ /**
+ * SDK used for the project selection row.
+ */
+ private ChoiceRow mSdkRow;
+
+ /**
+ * OOo used for the project selection row.
+ */
+ private ChoiceRow mOOoRow;
+ private ConfigListener mConfigListener;
+
+ /**
+ * Constructor.
+ *
+ * @param pParent the parent composite where to create the fields
+ */
+ public OOoConfigPanel ( Composite pParent ) {
+
+ OOoContainer.addListener( mConfigListener );
+ SDKContainer.addListener( mConfigListener );
+
+ // Add the SDK choice field
+ mSdkRow = new ChoiceRow(pParent, SDK,
+ Messages.getString("OOoConfigPanel.UsedSdk"), //$NON-NLS-1$
+ Messages.getString("OOoConfigPanel.SdkBrowse")); //$NON-NLS-1$
+ mSdkRow.setBrowseSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent pEvent) {
+ super.widgetSelected(pEvent);
+
+ // Open the SDK Configuration page
+ TableDialog dialog = new TableDialog( Display.getDefault().getActiveShell(), true);
+ dialog.create();
+ dialog.open();
+
+ }
+ });
+
+ fillSDKRow();
+ mSdkRow.setTooltip(Messages.getString("OOoConfigPanel.SdkTooltip")); //$NON-NLS-1$
+
+
+ // Add the OOo choice field
+ mOOoRow = new ChoiceRow(pParent, OOO,
+ Messages.getString("OOoConfigPanel.UsedOOo"), //$NON-NLS-1$
+ Messages.getString("OOoConfigPanel.OOoBrowse")); //$NON-NLS-1$
+ mOOoRow.setBrowseSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent pEvent) {
+ super.widgetSelected(pEvent);
+
+ // Open the OOo Configuration page
+ TableDialog dialog = new TableDialog( Display.getDefault().getActiveShell(), false);
+ dialog.create();
+ dialog.open();
+ }
+ });
+
+ fillOOoRow();
+ mOOoRow.setTooltip(Messages.getString("OOoConfigPanel.OOoTooltip")); //$NON-NLS-1$
+ }
+
+ /**
+ * Disposes the object, mainly to unregister the listeners.
+ */
+ public void dispose( ) {
+ OOoContainer.removeListener( mConfigListener );
+ SDKContainer.removeListener( mConfigListener );
+ }
+
+ /**
+ * @return SDK name selected
+ */
+ public String getSDKName() {
+ String sdkName = ""; //$NON-NLS-1$
+ if (null != mSdkRow) {
+ sdkName = mSdkRow.getValue();
+ }
+ return sdkName;
+ }
+
+ /**
+ * @return OOo name selected
+ */
+ public String getOOoName() {
+ String oooName = ""; //$NON-NLS-1$
+ if (null != mOOoRow) {
+ oooName = mOOoRow.getValue();
+ }
+ return oooName;
+ }
+
+ /**
+ * Set the SDK names to the SDK list-box.
+ */
+ private void fillSDKRow () {
+
+ if (null != mSdkRow) {
+ // Adding the SDK names to the combo box
+ String[] sdks = new String[SDKContainer.getSDKCount()];
+ Vector<String> sdkKeys = SDKContainer.getSDKKeys();
+ for (int i = 0, length = SDKContainer.getSDKCount(); i < length; i++) {
+ sdks[i] = sdkKeys.get(i);
+ }
+
+ mSdkRow.removeAll();
+ mSdkRow.addAll(sdks);
+ // The default SDK is randomly the first one
+ mSdkRow.select(0);
+ }
+ }
+
+ /**
+ * Set the OOo names to the OOo list-box.
+ */
+ private void fillOOoRow() {
+
+ if (null != mOOoRow) {
+
+ // Adding the OOo names to the combo box
+ String[] ooos = new String[OOoContainer.getOOoCount()];
+ Vector<String> oooKeys = OOoContainer.getOOoKeys();
+ for (int i = 0, length = OOoContainer.getOOoCount(); i < length; i++) {
+ ooos[i] = oooKeys.get(i);
+ }
+
+ mOOoRow.removeAll();
+ mOOoRow.addAll(ooos);
+ // The default OOo is randomly the first one
+ mOOoRow.select(0);
+ }
+ }
+
+ /**
+ * Class listening for the OOo and SDK config changes and updating the fields.
+ *
+ * @author cbosdonnat
+ *
+ */
+ private class ConfigListener implements IConfigListener {
+ /**
+ * {@inheritDoc}
+ */
+ public void ConfigAdded(Object pElement) {
+ if (pElement instanceof IOOo) {
+ fillOOoRow();
+ } else {
+ fillSDKRow();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void ConfigRemoved(Object pElement) {
+
+ if (null == pElement || pElement instanceof IOOo) {
+ fillOOoRow();
+ }
+
+ if (null == pElement || pElement instanceof ISdk) {
+ fillSDKRow();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void ConfigUpdated(Object pElement) {
+ if (pElement instanceof IOOo) {
+ fillOOoRow();
+ } else {
+ fillSDKRow();
+ }
+ };
+ }
+
+ /**
+ * Dialog for OOo and SDK configuration.
+ *
+ * @author cedribosdo
+ */
+ private class TableDialog extends Dialog {
+
+ private boolean mEditSdk = true;
+
+ private Object mTable;
+
+ /**
+ * Constructor.
+ *
+ * @param pParentShell the parent shell of the dialog.
+ * @param pEditSDK <code>true</code> for SDK, <code>false</code> for OOo edition.
+ */
+ TableDialog (Shell pParentShell, boolean pEditSDK) {
+ super(pParentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ mEditSdk = pEditSDK;
+
+ // This dialog is a modal one
+ setBlockOnOpen(true);
+ if (pEditSDK) {
+ getShell().setText(Messages.getString("OOoConfigPanel.SdkBrowse")); //$NON-NLS-1$
+ } else {
+ getShell().setText(Messages.getString("OOoConfigPanel.OOoBrowse")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Control createDialogArea(Composite pParent) {
+
+ if (mEditSdk) {
+ mTable = new SDKTable(pParent);
+ ((SDKTable)mTable).getPreferences();
+ } else {
+ mTable = new OOoTable(pParent);
+ ((OOoTable)mTable).getPreferences();
+ }
+
+ return pParent;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void okPressed() {
+ super.okPressed();
+
+ if (mEditSdk) {
+ ((SDKTable)mTable).savePreferences();
+ } else {
+ ((OOoTable)mTable).savePreferences();
+ }
+ }
+ }
+}
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 7dd2bbf..886f4f7 100644
--- a/core/source/org/openoffice/ide/eclipse/core/gui/messages.properties
+++ b/core/source/org/openoffice/ide/eclipse/core/gui/messages.properties
@@ -15,3 +15,10 @@ SDKTable.DialogTitle=OpenOffice.org SDK configuration
SDKTable.MissingFieldError=All the fields have to be filled
SDKTable.SpacesSdkPathWarning=The path of the SDK contains white spaces, the build might not work
ProjectSelectionDialog.Title=Project content chooser
+
+OOoConfigPanel.UsedSdk=Used SDK
+OOoConfigPanel.SdkBrowse=Configure SDKs
+OOoConfigPanel.SdkTooltip=Defines the SDK to use for the project devevelopment.
+OOoConfigPanel.UsedOOo=Used OOo
+OOoConfigPanel.OOoBrowse=OOo installations
+OOoConfigPanel.OOoTooltip=Defines the OOo or URE instance for which the project is for.
\ No newline at end of file
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 ba9a150..eb86675 100644
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/messages.properties
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/messages.properties
@@ -26,17 +26,11 @@ NewUnoProjectPage.CustomIdlLabel=IDL files
NewUnoProjectPage.CompExtensionTooltip=Defines the extension package name, usually comp.\nIt means that the implementation classes should\nbe in the <root.package>.comp package
NewUnoFilePage.UnoProjectError=Not a UNO project
NewUnoFilePage.NoIdlFolderError=Not a UNO-IDL capable folder
-NewUnoProjectPage.UsedSdk=Used SDK
-NewUnoProjectPage.SdkBrowse=Configure SDKs
-NewUnoProjectPage.SdkTooltip=Defines the SDK to use for the project devevelopment.
-NewUnoProjectPage.UsedOOo=Used OOo
NewServiceWizard.JobName=Service creation Job
NewServiceWizardPage.Title=Service creation page
NewServiceWizard.DefaultName=MyService
NewServiceWizardPage.Type=Service name
-NewUnoProjectPage.OOoBrowse=OOo installations
NewUreAppWizard.Description=Create a new URE based application.
-NewUnoProjectPage.OOoTooltip=Defines the OOo or URE instance for which the project is for.
NewUnoProjectPage.Language=Programming language
NewUnoProjectPage.LanguageTooltip=Defines the implementation language.
NewUnoProjectPage.CustomDirsLabel=Use custom project directories
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 c6f71ed..4b575e8 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
@@ -57,25 +57,20 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
import org.openoffice.ide.eclipse.core.OOEclipsePlugin;
import org.openoffice.ide.eclipse.core.PluginLogger;
-import org.openoffice.ide.eclipse.core.gui.OOoTable;
-import org.openoffice.ide.eclipse.core.gui.SDKTable;
+import org.openoffice.ide.eclipse.core.gui.OOoConfigPanel;
import org.openoffice.ide.eclipse.core.gui.rows.BooleanRow;
import org.openoffice.ide.eclipse.core.gui.rows.ChoiceRow;
import org.openoffice.ide.eclipse.core.gui.rows.FieldEvent;
@@ -87,12 +82,7 @@ import org.openoffice.ide.eclipse.core.internal.helpers.LanguagesHelper;
import org.openoffice.ide.eclipse.core.internal.helpers.UnoidlProjectHelper;
import org.openoffice.ide.eclipse.core.model.IUnoFactoryConstants;
import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
-import org.openoffice.ide.eclipse.core.model.OOoContainer;
-import org.openoffice.ide.eclipse.core.model.SDKContainer;
import org.openoffice.ide.eclipse.core.model.UnoFactoryData;
-import org.openoffice.ide.eclipse.core.model.config.IConfigListener;
-import org.openoffice.ide.eclipse.core.model.config.IOOo;
-import org.openoffice.ide.eclipse.core.model.config.ISdk;
import org.openoffice.ide.eclipse.core.model.language.ILanguage;
import org.openoffice.ide.eclipse.core.wizards.Messages;
import org.openoffice.ide.eclipse.core.wizards.NewUnoProjectWizard;
@@ -105,13 +95,12 @@ import org.openoffice.ide.eclipse.core.wizards.NewUnoProjectWizard;
*
*/
public class NewUnoProjectPage extends WizardNewProjectCreationPage
- implements IFieldChangedListener, IConfigListener {
+ implements IFieldChangedListener {
/* Constants defining the field properties used to react to field change events */
private static final String PREFIX = "__prefix"; //$NON-NLS-1$
private static final String OUTPUT_EXT = "__output_ext"; //$NON-NLS-1$
- private static final String SDK = "__sdk"; //$NON-NLS-1$
- private static final String OOO = "__ooo"; //$NON-NLS-1$
+
private static final String LANGUAGE = "__language"; //$NON-NLS-1$
private static final String CUSTOM_DIRS = "__custom_dirs"; //$NON-NLS-1$
@@ -131,16 +120,6 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
private TextRow mOutputExt;
/**
- * SDK used for the project selection row.
- */
- private ChoiceRow mSdkRow;
-
- /**
- * OOo used for the project selection row.
- */
- private ChoiceRow mOOoRow;
-
- /**
* Programming language to use for code generation.
*/
private ChoiceRow mLanguageRow;
@@ -174,6 +153,7 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
((NewUnoProjectWizard)getWizard()).pageChanged(NewUnoProjectPage.this);
}
};
+ private OOoConfigPanel mOOoConfigPanel;
/**
* Default constructor.
@@ -189,9 +169,6 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
setImageDescriptor(OOEclipsePlugin.getImageDescriptor(
ImagesConstants.NEWPROJECT_WIZ));
-
- OOoContainer.addListener(this);
- SDKContainer.addListener(this);
}
/**
@@ -208,9 +185,6 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
mListenedTexts.clear();
super.dispose();
-
- OOoContainer.removeListener(this);
- SDKContainer.removeListener(this);
}
/**
@@ -236,28 +210,6 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
}
/**
- * @return SDK name selected
- */
- public String getSDKName() {
- String sdkName = ""; //$NON-NLS-1$
- if (null != mSdkRow) {
- sdkName = mSdkRow.getValue();
- }
- return sdkName;
- }
-
- /**
- * @return OOo name selected
- */
- public String getOOoName() {
- String oooName = ""; //$NON-NLS-1$
- if (null != mOOoRow) {
- oooName = mOOoRow.getValue();
- }
- return oooName;
- }
-
- /**
* @return the chosen implementation language.
*/
public ILanguage getChosenLanguage() {
@@ -270,6 +222,13 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
}
/**
+ * @return the selected OOo name
+ */
+ public String getOOoName( ) {
+ return mOOoConfigPanel.getOOoName();
+ }
+
+ /**
* Creates a new project resource with the selected name.
* <p>
* In normal usage, this method is invoked after the user has pressed Finish
@@ -392,45 +351,7 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
mOutputExt.setFieldChangedListener(this);
mOutputExt.setTooltip(Messages.getString("NewUnoProjectPage.CompExtensionTooltip")); //$NON-NLS-1$
- // Add the SDK choice field
- mSdkRow = new ChoiceRow(body, SDK,
- Messages.getString("NewUnoProjectPage.UsedSdk"), //$NON-NLS-1$
- Messages.getString("NewUnoProjectPage.SdkBrowse")); //$NON-NLS-1$
- mSdkRow.setFieldChangedListener(this);
- mSdkRow.setBrowseSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent pEvent) {
- super.widgetSelected(pEvent);
-
- // Open the SDK Configuration page
- TableDialog dialog = new TableDialog(getShell(), true);
- dialog.create();
- dialog.open();
-
- }
- });
-
- fillSDKRow();
- mSdkRow.setTooltip(Messages.getString("NewUnoProjectPage.SdkTooltip")); //$NON-NLS-1$
-
-
- // Add the OOo choice field
- mOOoRow = new ChoiceRow(body, OOO,
- Messages.getString("NewUnoProjectPage.UsedOOo"), //$NON-NLS-1$
- Messages.getString("NewUnoProjectPage.OOoBrowse")); //$NON-NLS-1$
- mOOoRow.setFieldChangedListener(this);
- mOOoRow.setBrowseSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent pEvent) {
- super.widgetSelected(pEvent);
-
- // Open the OOo Configuration page
- TableDialog dialog = new TableDialog(getShell(), false);
- dialog.create();
- dialog.open();
- }
- });
-
- fillOOoRow();
- mOOoRow.setTooltip(Messages.getString("NewUnoProjectPage.OOoTooltip")); //$NON-NLS-1$
+ mOOoConfigPanel = new OOoConfigPanel( body );
// Adding the programming language row
@@ -475,47 +396,6 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
mIdlDirRow.setEnabled(false);
mIdlDirRow.setFieldChangedListener(this);
}
-
- /**
- * Set the SDK names to the SDK list-box.
- */
- private void fillSDKRow () {
-
- if (null != mSdkRow) {
- // Adding the SDK names to the combo box
- String[] sdks = new String[SDKContainer.getSDKCount()];
- Vector<String> sdkKeys = SDKContainer.getSDKKeys();
- for (int i = 0, length = SDKContainer.getSDKCount(); i < length; i++) {
- sdks[i] = sdkKeys.get(i);
- }
-
- mSdkRow.removeAll();
- mSdkRow.addAll(sdks);
- // The default SDK is randomly the first one
- mSdkRow.select(0);
- }
- }
-
- /**
- * Set the OOo names to the OOo list-box.
- */
- private void fillOOoRow() {
-
- if (null != mOOoRow) {
-
- // Adding the OOo names to the combo box
- String[] ooos = new String[OOoContainer.getOOoCount()];
- Vector<String> oooKeys = OOoContainer.getOOoKeys();
- for (int i = 0, length = OOoContainer.getOOoCount(); i < length; i++) {
- ooos[i] = oooKeys.get(i);
- }
-
- mOOoRow.removeAll();
- mOOoRow.addAll(ooos);
- // The default OOo is randomly the first one
- mOOoRow.select(0);
- }
- }
/**
* Shows a warning if there are spaces in the project directory on Windows.
@@ -609,42 +489,6 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
}
/**
- * {@inheritDoc}
- */
- public void ConfigAdded(Object pElement) {
- if (pElement instanceof IOOo) {
- fillOOoRow();
- } else {
- fillSDKRow();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void ConfigRemoved(Object pElement) {
-
- if (null == pElement || pElement instanceof IOOo) {
- fillOOoRow();
- }
-
- if (null == pElement || pElement instanceof ISdk) {
- fillSDKRow();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void ConfigUpdated(Object pElement) {
- if (pElement instanceof IOOo) {
- fillOOoRow();
- } else {
- fillSDKRow();
- }
- };
-
- /**
* @param pData the data to fill.
* @param pForce forces the project creation. Otherwise, the project handle won't be set
*
@@ -667,8 +511,8 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
pData.setProperty(IUnoFactoryConstants.PROJECT_PREFIX, getPrefix());
pData.setProperty(IUnoFactoryConstants.PROJECT_COMP, getOutputExt());
pData.setProperty(IUnoFactoryConstants.PROJECT_LANGUAGE, getChosenLanguage());
- pData.setProperty(IUnoFactoryConstants.PROJECT_SDK, getSDKName());
- pData.setProperty(IUnoFactoryConstants.PROJECT_OOO, getOOoName());
+ pData.setProperty(IUnoFactoryConstants.PROJECT_SDK, mOOoConfigPanel.getSDKName());
+ pData.setProperty(IUnoFactoryConstants.PROJECT_OOO, mOOoConfigPanel.getOOoName());
pData.setProperty(IUnoFactoryConstants.PROJECT_SRC_DIR, mSourceRow.getValue());
pData.setProperty(IUnoFactoryConstants.PROJECT_IDL_DIR, mIdlDirRow.getValue());
@@ -683,65 +527,4 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage
public IUnoidlProject getUnoidlProject() {
return mUnoProject;
}
-
- /**
- * Dialog for OOo and SDK configuration.
- *
- * @author cedribosdo
- */
- private class TableDialog extends Dialog {
-
- private boolean mEditSdk = true;
-
- private Object mTable;
-
- /**
- * Constructor.
- *
- * @param pParentShell the parent shell of the dialog.
- * @param pEditSDK <code>true</code> for SDK, <code>false</code> for OOo edition.
- */
- TableDialog (Shell pParentShell, boolean pEditSDK) {
- super(pParentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- mEditSdk = pEditSDK;
-
- // This dialog is a modal one
- setBlockOnOpen(true);
- if (pEditSDK) {
- setTitle(Messages.getString("NewUnoProjectPage.SdkBrowse")); //$NON-NLS-1$
- } else {
- setTitle(Messages.getString("NewUnoProjectPage.OOoBrowse")); //$NON-NLS-1$
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected Control createDialogArea(Composite pParent) {
-
- if (mEditSdk) {
- mTable = new SDKTable(pParent);
- ((SDKTable)mTable).getPreferences();
- } else {
- mTable = new OOoTable(pParent);
- ((OOoTable)mTable).getPreferences();
- }
-
- return pParent;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void okPressed() {
- super.okPressed();
-
- if (mEditSdk) {
- ((SDKTable)mTable).savePreferences();
- } else {
- ((OOoTable)mTable).savePreferences();
- }
- }
- }
}
diff --git a/cpp/META-INF/MANIFEST.MF b/cpp/META-INF/MANIFEST.MF
index ffdb100..54c59d4 100644
--- a/cpp/META-INF/MANIFEST.MF
+++ b/cpp/META-INF/MANIFEST.MF
@@ -10,6 +10,8 @@ Require-Bundle: org.eclipse.ui,
org.openoffice.ide.eclipse.core;bundle-version="1.1.0",
org.eclipse.core.resources;bundle-version="3.4.1",
org.eclipse.cdt.core;bundle-version="5.0.1",
- org.eclipse.cdt.managedbuilder.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"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
diff --git a/cpp/icons/uno_client.gif b/cpp/icons/uno_client.gif
new file mode 100644
index 0000000..f794b29
Binary files /dev/null and b/cpp/icons/uno_client.gif differ
diff --git a/cpp/icons/uno_client_wiz.png b/cpp/icons/uno_client_wiz.png
new file mode 100644
index 0000000..1d1ef9b
Binary files /dev/null and b/cpp/icons/uno_client_wiz.png differ
diff --git a/cpp/plugin.xml b/cpp/plugin.xml
index a4dcf3f..8cce159 100644
--- a/cpp/plugin.xml
+++ b/cpp/plugin.xml
@@ -8,5 +8,17 @@
name="C++">
</language>
</extension>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ canFinishEarly="true"
+ category="org.openoffice.ide.eclipse.core"
+ class="org.openoffice.ide.eclipse.cpp.client.ClientWizard"
+ hasPages="true"
+ icon="icons/uno_client.gif"
+ id="org.openoffice.ide.eclipse.cpp.client"
+ name="C++ UNO client application">
+ </wizard>
+ </extension>
</plugin>
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java b/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java
index dceecb4..c32734d 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java
@@ -69,6 +69,7 @@ import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
import org.openoffice.ide.eclipse.core.model.ProjectsManager;
import org.openoffice.ide.eclipse.core.model.UnoFactoryData;
import org.openoffice.ide.eclipse.core.model.config.IOOo;
+import org.openoffice.ide.eclipse.core.model.config.ISdk;
import org.openoffice.ide.eclipse.core.model.language.IProjectHandler;
public class CppProjectHandler implements IProjectHandler {
@@ -82,18 +83,7 @@ public class CppProjectHandler implements IProjectHandler {
@Override
public void addOOoDependencies(IOOo ooo, IProject project) {
IUnoidlProject unoprj = ProjectsManager.getProject( project.getName() );
-
- CIncludePathEntry sdkIncludes = new CIncludePathEntry( unoprj.getSdk().getIncludePath(), 0 );
- ArrayList< CLibraryPathEntry > libs = new ArrayList<CLibraryPathEntry>();
- String[] oooLibs = ooo.getLibsPath();
- for (String libPath : oooLibs) {
- libs.add( new CLibraryPathEntry( new Path( libPath ), 0 ) );
- }
-
- addEntries( project, new CIncludePathEntry[] { sdkIncludes }, ICSettingEntry.INCLUDE_PATH );
- addEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
- addEntries( project, getMacrosForPlatform( Platform.getOS() ), ICSettingEntry.MACRO );
-
+ addOOoDependencies( ooo, unoprj.getSdk(), project );
}
@Override
@@ -220,15 +210,7 @@ public class CppProjectHandler implements IProjectHandler {
@Override
public void removeOOoDependencies(IOOo ooo, IProject project) {
IUnoidlProject unoprj = ProjectsManager.getProject( project.getName() );
-
- CIncludePathEntry sdkIncludes = new CIncludePathEntry( unoprj.getSdk().getIncludePath(), 0 );
- ArrayList< CLibraryPathEntry > libs = new ArrayList<CLibraryPathEntry>();
- String[] oooLibs = ooo.getLibsPath();
- for (String libPath : oooLibs) {
- libs.add( new CLibraryPathEntry( new Path( libPath ), 0 ) );
- }
- removeEntries( project, new CIncludePathEntry[] { sdkIncludes }, ICSettingEntry.INCLUDE_PATH );
- removeEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
+ removeOOoDependencies( ooo, unoprj.getSdk(), project );
}
private static ICLanguageSettingEntry[] getMacrosForPlatform(String pOs ) {
@@ -306,4 +288,29 @@ public class CppProjectHandler implements IProjectHandler {
PluginLogger.error( "Error setting the includes and libaries", e );
}
}
+
+ static public void addOOoDependencies(IOOo ooo, ISdk sdk, IProject project) {
+ CIncludePathEntry sdkIncludes = new CIncludePathEntry( sdk.getIncludePath(), 0 );
+ ArrayList< CLibraryPathEntry > libs = new ArrayList<CLibraryPathEntry>();
+ String[] oooLibs = ooo.getLibsPath();
+ for (String libPath : oooLibs) {
+ libs.add( new CLibraryPathEntry( new Path( libPath ), 0 ) );
+ }
+
+ addEntries( project, new CIncludePathEntry[] { sdkIncludes }, ICSettingEntry.INCLUDE_PATH );
+ addEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
+ addEntries( project, getMacrosForPlatform( Platform.getOS() ), ICSettingEntry.MACRO );
+
+ }
+
+ static public void removeOOoDependencies(IOOo ooo, ISdk sdk, IProject project) {
+ CIncludePathEntry sdkIncludes = new CIncludePathEntry( sdk.getIncludePath(), 0 );
+ ArrayList< CLibraryPathEntry > libs = new ArrayList<CLibraryPathEntry>();
+ String[] oooLibs = ooo.getLibsPath();
+ for (String libPath : oooLibs) {
+ libs.add( new CLibraryPathEntry( new Path( libPath ), 0 ) );
+ }
+ removeEntries( project, new CIncludePathEntry[] { sdkIncludes }, ICSettingEntry.INCLUDE_PATH );
+ removeEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
+ }
}
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java b/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
new file mode 100644
index 0000000..abadc54
--- /dev/null
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * 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.cpp.client;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.wizards.CCProjectWizard;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.openoffice.ide.eclipse.core.model.config.IOOo;
+import org.openoffice.ide.eclipse.core.model.config.ISdk;
+import org.openoffice.ide.eclipse.cpp.Activator;
+import org.openoffice.ide.eclipse.cpp.CppProjectHandler;
+
+
+public class ClientWizard extends CCProjectWizard {
+
+ private static final String HELPER_DIR_NAME = "helper";
+ private UnoConnectionPage mCnxPage;
+
+ public ClientWizard() {
+ super( );
+ setWindowTitle( "UNO Client C++ project" );
+ }
+
+ @Override
+ public void addPages() {
+ mCnxPage = new UnoConnectionPage();
+ UnoClientWizardPage mainPage = new UnoClientWizardPage( "cdtmain", mCnxPage );
+ fMainPage = mainPage;
+ fMainPage.setTitle( getWindowTitle() );
+ fMainPage.setDescription( "Create the UNO C++ client application project" );
+ fMainPage.setImageDescriptor( Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+ "icons/uno_client_wiz.png" ) );
+
+ addPage(fMainPage);
+
+ mCnxPage.setMainPage( mainPage );
+ addPage( mCnxPage );
+
+ }
+
+ /**
+ * Do the final configuration for UNO client and generate some code here.
+ */
+ @Override
+ protected boolean setCreated() throws CoreException {
+
+ boolean created = super.setCreated();
+
+ IOOo ooo = mCnxPage.getOoo();
+ ISdk sdk = mCnxPage.getSdk();
+
+ // Add the necessary includes/libs/macros
+ CppProjectHandler.addOOoDependencies( ooo, sdk, newProject );
+
+ // Copy the helper files in the helper source dir
+ IFolder srcDir = newProject.getFolder( HELPER_DIR_NAME );
+ srcDir.create( true, true, null );
+
+ copyResource( "connection.hxx", srcDir ); //$NON-NLS-1$
+ copyResource( "connection.cxx", srcDir ); //$NON-NLS-1$
+
+ srcDir.refreshLocal( IResource.DEPTH_ONE, null );
+
+ // Add the helper dir to the source path entries
+ ICProject cprj = CoreModel.getDefault().getCModel().getCProject( newProject.getName() );
+ IPathEntry[] entries = CoreModel.getRawPathEntries( cprj );
+ IPathEntry[] newEntries = new IPathEntry[ entries.length + 1 ];
+ System.arraycopy( entries, 0, newEntries, 0, entries.length );
+ newEntries[ newEntries.length - 1 ] = CoreModel.newSourceEntry( srcDir.getFullPath() );
+ CoreModel.setRawPathEntries( cprj, newEntries, null );
+
+ // TODO Run the cppumaker on the ooo types ( asynchronous )
+
+ // TODO Setup the launch config
+
+ return created;
+ }
+
+ private void copyResource(String pResName, IFolder pSrcDir) {
+ InputStream in = this.getClass().getResourceAsStream( pResName );
+ File destFile = pSrcDir.getFile( pResName ).getLocation().toFile();
+
+ FileWriter out = null;
+ try {
+
+ LineNumberReader reader = new LineNumberReader( new InputStreamReader( in ) );
+ out = new FileWriter( destFile );
+
+ String line = reader.readLine();
+ while ( line != null ) {
+ out.append( line + "\n" ); //$NON-NLS-1$
+ line = reader.readLine();
+ }
+
+ } catch ( Exception e ) {
+
+ } finally {
+ try { in.close(); } catch ( Exception e ) { }
+ try { out.close(); } catch ( Exception e ) { }
+ }
+ }
+}
\ No newline at end of file
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoClientWizardPage.java b/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoClientWizardPage.java
new file mode 100644
index 0000000..8875ff0
--- /dev/null
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoClientWizardPage.java
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * 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.cpp.client;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.ui.wizards.CDTMainWizardPage;
+import org.eclipse.cdt.ui.wizards.EntryDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+
+public class UnoClientWizardPage extends CDTMainWizardPage {
+
+ private UnoConnectionPage mUnoCnxPage;
+
+ /**
+ * Creates a new project creation wizard page.
+ *
+ * @param pageName the name of this page
+ */
+ public UnoClientWizardPage(String pPageName, UnoConnectionPage pUnoPage ) {
+ super(pPageName);
+ mUnoCnxPage= pUnoPage;
+ setPageComplete(false);
+ }
+
+ /**
+ * Only show the executable project types here
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public List filterItems(List items) {
+ ArrayList filtered = new ArrayList();
+
+ for (Object item : items) {
+ EntryDescriptor desc = (EntryDescriptor)item;
+ String parentId = desc.getParentId();
+ boolean exeParent = parentId != null && parentId.equals( ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_EXE );
+ boolean exe = desc.getId().equals( ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_EXE );
+
+ boolean kept = exeParent || exe;
+ if ( kept ) {
+ filtered.add( item );
+ }
+ }
+
+ return filtered;
+ }
+
+ /**
+ * @return the Uno connection page, instead of the normal CDT next page.
+ */
+ @Override
+ public IWizardPage getNextPage() {
+ return mUnoCnxPage;
+ }
+
+ /**
+ * @return the normal CDT next page
+ */
+ public IWizardPage getNextCdtPage( ) {
+ return super.getNextPage();
+ }
+}
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java b/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java
new file mode 100644
index 0000000..7478e77
--- /dev/null
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/UnoConnectionPage.java
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * 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.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.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;
+
+/**
+ * Wizard page for the UNO Client configuration.
+ *
+ * @author cbosdonnat
+ *
+ */
+public class UnoConnectionPage extends WizardPage {
+
+ private static final int LAYOUT_COLUMNS = 3;
+ private UnoClientWizardPage mMainPage;
+ private OOoConfigPanel mOOoConfigPanel;
+
+ public UnoConnectionPage( ) {
+ super( "unocnxpage" ); //$NON-NLS-1$
+ setTitle( "UNO configuration" );
+ setDescription( "Set some important informations for the UNO development" );
+ }
+
+ @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( "OpenOffice.org and SDK for building" );
+
+ // TODO Add a section for the sample connection config
+
+ mOOoConfigPanel = new OOoConfigPanel( body );
+
+ 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 normal next page of the CDT main page.
+ */
+ @Override
+ public IWizardPage getNextPage() {
+ return mMainPage.getNextCdtPage();
+ }
+
+ public void setMainPage(UnoClientWizardPage pMainPage) {
+ mMainPage = pMainPage;
+ }
+}
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx
new file mode 100644
index 0000000..0f9b421
--- /dev/null
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx
@@ -0,0 +1,201 @@
+/*
+ * This file has been automatically generated by the ooeclipse integration.
+ * http://cedric.bosdonnat.free.fr/ooeclipseintegration
+ *
+ * Ported by Cedric Bosdonnat from the JODConverter code.
+ * The original Java code has been written by Mirko Nasato <mirko at artofsolving.com>
+ *
+ * Copyright (C) 2009 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 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:
+ * Mirko Nasato <mirko at artofsolving.com>
+ * Laurent Godard <lgodard at nuxeo.com>
+ */
+
+#include <iostream>
+
+#include <rtl/bootstrap.hxx>
+#include <cppuhelper/bootstrap.hxx>
+
+#include <com/sun/star/connection/XConnector.hpp>
+#include <com/sun/star/connection/XConnection.hpp>
+#include <com/sun/star/connection/NoConnectException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include "connection.hxx"
+
+using namespace com::sun::star::frame;
+using namespace com::sun::star::connection;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star;
+
+#define OUSTRING_TO_C( x ) rtl::OUStringToOString( x, RTL_TEXTENCODING_UTF8 ).getStr( )
+
+namespace unoclienthelper {
+
+SocketConnection::SocketConnection( int nPort, char* pHost )
+{
+ rtl::OUString sCnxString = rtl::OUString::createFromAscii( "socket,host=" );
+ sCnxString = sCnxString.concat( rtl::OUString::createFromAscii( pHost ) );
+ sCnxString = sCnxString.concat( rtl::OUString::createFromAscii( ",port=" ) );
+ m_sConnectionString = sCnxString.concat( rtl::OUString::valueOf( sal_Int32( nPort ) ) );
+}
+
+SocketConnection::~SocketConnection()
+{
+}
+
+PipeConnection::PipeConnection( char* pPipeName )
+{
+ rtl::OUString sCnxString = rtl::OUString::createFromAscii( "pipe,name=" );
+ m_sConnectionString = sCnxString.concat( rtl::OUString::createFromAscii( pPipeName ) );
+}
+
+PipeConnection::~PipeConnection()
+{
+}
+
+AbstractConnection::AbstractConnection() :
+ m_bExpectingDisconnect( false ),
+ m_bConnected ( false )
+{
+}
+
+AbstractConnection::~AbstractConnection()
+{
+}
+
+bool AbstractConnection::connect( )
+{
+ // Try to connect
+ try
+ {
+ Reference< XComponentContext > xCtx = cppu::defaultBootstrap_InitialComponentContext();
+ Reference< XMultiServiceFactory > xServiceFactory ( xCtx->getServiceManager(), UNO_QUERY );
+
+ // Get a connection
+ Reference< XConnector> xConnector ( xServiceFactory->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.connection.Connector" ) ), UNO_QUERY );
+ Reference< XConnection > xConnection = xConnector->connect( m_sConnectionString );
+
+ // Get a Bridge
+ Reference< XBridgeFactory > xBridgeFactory( xServiceFactory->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.bridge.BridgeFactory" ) ), UNO_QUERY );
+ m_xBridge = xBridgeFactory->createBridge( rtl::OUString( ), rtl::OUString::createFromAscii( "urp" ),
+ xConnection, NULL );
+
+ // Register a listener on the bridge
+ Reference< XComponent > xBridgeComponent( m_xBridge, UNO_QUERY );
+ xBridgeComponent->addEventListener( this );
+
+ // Get the Remote service manager
+ Reference< XMultiComponentFactory > xServiceMngr(
+ m_xBridge->getInstance( rtl::OUString::createFromAscii( "StarOffice.ServiceManager" ) ),
+ UNO_QUERY );
+ m_xServiceMngr = xServiceMngr;
+
+ // Get the remote default context
+ Reference<XPropertySet> xPropSet( m_xServiceMngr, UNO_QUERY );
+ Reference<XComponentContext> xRemoteCtxt(
+ xPropSet->getPropertyValue( rtl::OUString::createFromAscii( "DefaultContext" ) ),
+ UNO_QUERY );
+ m_xCtx = xRemoteCtxt;
+
+#if DEBUG
+ fprintf( stderr, "Connected\n" );
+#endif
+
+ m_bConnected = true;
+ }
+ catch ( NoConnectException e )
+ {
+ fprintf( stderr, "connection failed: %s : %s\n",
+ OUSTRING_TO_C( m_sConnectionString ),
+ OUSTRING_TO_C( e.Message ) );
+ }
+}
+
+void AbstractConnection::disconnect()
+{
+ m_bExpectingDisconnect = true;
+ Reference< XComponent > xBridgeComponent( m_xBridge, UNO_QUERY );
+ xBridgeComponent->dispose( );
+}
+
+bool AbstractConnection::isConnected( )
+{
+ return m_bConnected;
+}
+
+Reference<XComponentContext> AbstractConnection::getContext( )
+{
+ return m_xCtx;
+}
+
+Reference<XMultiComponentFactory> AbstractConnection::getServiceManager( )
+{
+ return m_xServiceMngr;
+}
+
+Reference<XDesktop> AbstractConnection::getDesktop()
+{
+ Reference<XDesktop> xDesktop(
+ getService( rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ),
+ UNO_QUERY );
+ return xDesktop;
+}
+
+Reference<XInterface> AbstractConnection::getService( rtl::OUString sServiceName )
+{
+ Reference< XInterface > xIface;
+
+ bool bManagedConnection = true;
+ if ( !m_bConnected )
+ {
+#if DEBUG
+ fprintf( stderr, "Trying to (re)connect\n" );
+#endif
+ bManagedConnection = connect();
+ }
+
+ if ( bManagedConnection )
+ xIface = m_xServiceMngr->createInstanceWithContext( sServiceName, m_xCtx );
+
+ return xIface;
+}
+
+void AbstractConnection::disposing( const EventObject& source ) throw ( RuntimeException )
+{
+ m_bConnected = false;
+#if DEBUG
+ if ( m_bExpectingDisconnect )
+ {
+ fprintf( stderr, "Disconnected\n" );
+ }
+ else
+ {
+ fprintf( stderr, "Disconnected unexpectedly\n" );
+ }
+#endif
+ m_bExpectingDisconnect = false;
+}
+
+} // End of namespace unoclienthelper
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.hxx b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.hxx
new file mode 100644
index 0000000..21e8f0f
--- /dev/null
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.hxx
@@ -0,0 +1,89 @@
+/*
+ * This file has been automatically generated by the ooeclipse integration.
+ * http://cedric.bosdonnat.free.fr/ooeclipseintegration
+ *
+ * Ported by Cedric Bosdonnat from the JODConverter code.
+ * The original Java code has been written by Mirko Nasato <mirko at artofsolving.com>
+ *
+ * Copyright (C) 2009 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 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:
+ * Mirko Nasato <mirko at artofsolving.com>
+ * Laurent Godard <lgodard at nuxeo.com>
+ */
+
+#ifndef CONNECTION_HXX_
+#define CONNECTION_HXX_
+
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/bridge/XBridge.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+#include <rtl/ustring.hxx>
+
+
+namespace unoclienthelper {
+
+class AbstractConnection : public cppu::WeakImplHelper1< com::sun::star::lang::XEventListener >
+{
+private:
+ com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> m_xCtx;
+ com::sun::star::uno::Reference<com::sun::star::bridge::XBridge> m_xBridge;
+ com::sun::star::uno::Reference<com::sun::star::lang::XMultiComponentFactory> m_xServiceMngr;
+
+ bool m_bExpectingDisconnect;
+ bool m_bConnected;
+
+protected:
+ rtl::OUString m_sConnectionString;
+
+public:
+ AbstractConnection( );
+ ~AbstractConnection( );
+
+ bool connect( );
+ void disconnect( );
+ bool isConnected( );
+
+ com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> getContext( );
+ com::sun::star::uno::Reference<com::sun::star::lang::XMultiComponentFactory> getServiceManager( );
+ com::sun::star::uno::Reference<com::sun::star::frame::XDesktop> getDesktop( );
+
+ void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ com::sun::star::uno::Reference<com::sun::star::uno::XInterface> getService( rtl::OUString sServiceName );
+};
+
+class PipeConnection : public AbstractConnection
+{
+public:
+ PipeConnection( char* pPipeName );
+ ~PipeConnection( );
+};
+
+class SocketConnection : public AbstractConnection
+{
+public:
+ SocketConnection( int nPort, char* pHost = "localhost" );
+ ~SocketConnection( );
+};
+
+} // End of namespace unoclienthelper
+
+#endif /* CONNECTION_HXX_ */
More information about the ooo-build-commit
mailing list