[ooo-build-commit] ooeclipse: Branch 'master'

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Fri Sep 11 01:57:34 PDT 2009


 core/source/org/openoffice/ide/eclipse/core/OOEclipsePlugin.java                |   17 -
 core/source/org/openoffice/ide/eclipse/core/actions/AbstractPulldownAction.java |    3 
 core/source/org/openoffice/ide/eclipse/core/internal/model/UnoFactory.java      |   47 ----
 core/source/org/openoffice/ide/eclipse/core/utils/WorkbenchHelper.java          |  102 ++++++++++
 core/source/org/openoffice/ide/eclipse/core/wizards/NewInterfaceWizard.java     |    3 
 core/source/org/openoffice/ide/eclipse/core/wizards/NewServiceWizard.java       |    3 
 core/source/org/openoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java    |    3 
 cpp/plugin.xml                                                                  |    5 
 cpp/source/org/openoffice/ide/eclipse/cpp/CDTHelper.java                        |   78 +++++--
 cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java                |    3 
 cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java              |   84 ++++----
 cpp/source/org/openoffice/ide/eclipse/cpp/client/client.cxx                     |   41 ++++
 cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx                 |   40 +--
 cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.hxx                 |    8 
 14 files changed, 290 insertions(+), 147 deletions(-)

New commits:
commit b6edf49b0647278a763bc34c1cad1e91b670fb54
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Fri Sep 11 10:57:15 2009 +0200

    C++ UNO client wizard improvements
    
     * Opening the main file at the end of the wizard
     * Added the libraries -l options
     * Added a sample client connection use. Should be configurable

diff --git a/core/source/org/openoffice/ide/eclipse/core/OOEclipsePlugin.java b/core/source/org/openoffice/ide/eclipse/core/OOEclipsePlugin.java
index cd5667e..416ea6f 100755
--- a/core/source/org/openoffice/ide/eclipse/core/OOEclipsePlugin.java
+++ b/core/source/org/openoffice/ide/eclipse/core/OOEclipsePlugin.java
@@ -48,8 +48,6 @@ import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.RGB;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.openoffice.ide.eclipse.core.editors.Colors;
 import org.openoffice.ide.eclipse.core.i18n.ImageManager;
@@ -231,19 +229,4 @@ public class OOEclipsePlugin extends AbstractUIPlugin {
         
         store.setDefault(LOGLEVEL_PREFERENCE_KEY, LogLevels.INFO.toString());
     }
-
-    /**
-     * Convenience method returning the active workbench page.
-     * 
-     * @return the active page
-     */
-    public static IWorkbenchPage getActivePage() {
-        IWorkbenchPage page = null;
-        
-        IWorkbenchWindow window = getDefault().getWorkbench().getActiveWorkbenchWindow();
-        if (null != window) {
-            page = window.getActivePage();
-        }
-        return page;
-    }
 }
diff --git a/core/source/org/openoffice/ide/eclipse/core/actions/AbstractPulldownAction.java b/core/source/org/openoffice/ide/eclipse/core/actions/AbstractPulldownAction.java
index 0c1823f..2f631a3 100644
--- a/core/source/org/openoffice/ide/eclipse/core/actions/AbstractPulldownAction.java
+++ b/core/source/org/openoffice/ide/eclipse/core/actions/AbstractPulldownAction.java
@@ -68,6 +68,7 @@ import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowPulldownDelegate;
 import org.eclipse.ui.PlatformUI;
 import org.openoffice.ide.eclipse.core.OOEclipsePlugin;
+import org.openoffice.ide.eclipse.core.utils.WorkbenchHelper;
 
 /**
  * Abstract class to create a pulldown menu action.
@@ -204,7 +205,7 @@ public abstract class AbstractPulldownAction implements IWorkbenchWindowPulldown
     private IStructuredSelection getSelection() {
         IStructuredSelection strucSelection = StructuredSelection.EMPTY;
         
-        IWorkbenchWindow window = OOEclipsePlugin.getActivePage().getWorkbenchWindow();
+        IWorkbenchWindow window = WorkbenchHelper.getActivePage().getWorkbenchWindow();
         if (window != null) {
             ISelection selection = window.getSelectionService().getSelection();
             if (selection instanceof IStructuredSelection) {
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoFactory.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoFactory.java
index 425beec..4600710 100644
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoFactory.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoFactory.java
@@ -52,16 +52,9 @@ import java.util.Arrays;
 import java.util.Locale;
 
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
 import org.openoffice.ide.eclipse.core.PluginLogger;
 import org.openoffice.ide.eclipse.core.internal.helpers.UnoidlProjectHelper;
 import org.openoffice.ide.eclipse.core.model.CompositeFactory;
@@ -73,6 +66,7 @@ import org.openoffice.ide.eclipse.core.model.UnoFactoryData;
 import org.openoffice.ide.eclipse.core.model.description.DescriptionModel;
 import org.openoffice.ide.eclipse.core.model.language.ILanguage;
 import org.openoffice.ide.eclipse.core.model.language.IProjectHandler;
+import org.openoffice.ide.eclipse.core.utils.WorkbenchHelper;
 
 /**
  * This class is a factory creating UNO projects and types from data sets
@@ -242,7 +236,7 @@ public final class UnoFactory {
             implementationPath = prj.getSourcePath().append(implementationPath);
             IFile implementationFile = prj.getFile(implementationPath);
 
-            showFile(implementationFile, pActivePage);
+            WorkbenchHelper.showFile(implementationFile, pActivePage);
         }
     }
     
@@ -474,7 +468,7 @@ public final class UnoFactory {
         String filename = pTypepath.replace("::", "/") + ".idl"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         UnoidlProjectHelper.refreshProject(pPrj, null);
         IFile interfaceFile = pPrj.getFile(pPrj.getIdlPath().append(filename));
-        showFile(interfaceFile, pActivePage);
+        WorkbenchHelper.showFile(interfaceFile, pActivePage);
     }
 
     /**
@@ -540,39 +534,4 @@ public final class UnoFactory {
             pFileContent.addChild(CompositeFactory.createInclude(pTypes[i]));
         }
     }
-    
-    /**
-     * Simply shows the file in the IDE.
-     * 
-     * @param pFile the file to show
-     * @param pPage the active workbench page
-     */
-    private static void showFile(IFile pFile, IWorkbenchPage pPage) {
-        
-        try {
-            IWorkbench workbench = PlatformUI.getWorkbench();
-            BasicNewResourceWizard.selectAndReveal(
-                    pFile, workbench.getActiveWorkbenchWindow());
-
-            final IWorkbenchPage activePage = pPage;
-            final IFile toShow = pFile;
-
-            if (activePage != null) {
-                final Display display = Display.getDefault();
-                if (display != null) {
-                    display.asyncExec(new Runnable() {
-                        public void run() {
-                            try {
-                                IDE.openEditor(activePage, toShow, true);
-                            } catch (PartInitException e) {
-                                PluginLogger.debug(e.getMessage());
-                            }
-                        }
-                    });
-                }
-            }
-        } catch (Exception e) {
-            PluginLogger.error("Can't open file", e); //$NON-NLS-1$
-        }
-    }
 }
diff --git a/core/source/org/openoffice/ide/eclipse/core/utils/WorkbenchHelper.java b/core/source/org/openoffice/ide/eclipse/core/utils/WorkbenchHelper.java
new file mode 100644
index 0000000..99ba0ae
--- /dev/null
+++ b/core/source/org/openoffice/ide/eclipse/core/utils/WorkbenchHelper.java
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * 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.utils;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+import org.openoffice.ide.eclipse.core.OOEclipsePlugin;
+import org.openoffice.ide.eclipse.core.PluginLogger;
+
+/**
+ * Provides a set of useful method to perform actions on the Eclipse workbench.
+ * 
+ * @author cbosdonnat
+ *
+ */
+public class WorkbenchHelper {
+
+    /**
+     * Simply shows the file in the IDE.
+     * 
+     * @param pFile the file to show
+     * @param pPage the active workbench page
+     */
+    public static void showFile(IFile pFile, IWorkbenchPage pPage) {
+        
+        try {
+            IWorkbench workbench = PlatformUI.getWorkbench();
+            BasicNewResourceWizard.selectAndReveal(
+                    pFile, workbench.getActiveWorkbenchWindow());
+
+            final IWorkbenchPage activePage = pPage;
+            final IFile toShow = pFile;
+
+            if (activePage != null) {
+                final Display display = Display.getDefault();
+                if (display != null) {
+                    display.asyncExec(new Runnable() {
+                        public void run() {
+                            try {
+                                IDE.openEditor(activePage, toShow, true);
+                            } catch (PartInitException e) {
+                                PluginLogger.debug(e.getMessage());
+                            }
+                        }
+                    });
+                }
+            }
+        } catch (Exception e) {
+            PluginLogger.error("Can't open file", e); //$NON-NLS-1$
+        }
+    }
+    
+    /**
+     * Convenience method returning the active workbench page.
+     * 
+     * @return the active page
+     */
+    public static IWorkbenchPage getActivePage() {
+        IWorkbenchPage page = null;
+        
+        IWorkbenchWindow window = OOEclipsePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+        if (null != window) {
+            page = window.getActivePage();
+        }
+        return page;
+    }
+}
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/NewInterfaceWizard.java b/core/source/org/openoffice/ide/eclipse/core/wizards/NewInterfaceWizard.java
index 609ab31..a79d49a 100644
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/NewInterfaceWizard.java
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/NewInterfaceWizard.java
@@ -66,6 +66,7 @@ import org.openoffice.ide.eclipse.core.internal.model.UnoFactory;
 import org.openoffice.ide.eclipse.core.internal.model.UnoidlProject;
 import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
 import org.openoffice.ide.eclipse.core.model.UnoFactoryData;
+import org.openoffice.ide.eclipse.core.utils.WorkbenchHelper;
 import org.openoffice.ide.eclipse.core.wizards.pages.NewInterfaceWizardPage;
 
 /**
@@ -86,7 +87,7 @@ public class NewInterfaceWizard extends BasicNewResourceWizard implements
     public NewInterfaceWizard() {
         super();
         
-        mActivePage = OOEclipsePlugin.getActivePage();
+        mActivePage = WorkbenchHelper.getActivePage();
     }
 
     /**
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/NewServiceWizard.java b/core/source/org/openoffice/ide/eclipse/core/wizards/NewServiceWizard.java
index 93801e6..39923b7 100755
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/NewServiceWizard.java
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/NewServiceWizard.java
@@ -62,6 +62,7 @@ import org.openoffice.ide.eclipse.core.PluginLogger;
 import org.openoffice.ide.eclipse.core.internal.model.UnoidlProject;
 import org.openoffice.ide.eclipse.core.model.IUnoFactoryConstants;
 import org.openoffice.ide.eclipse.core.model.UnoFactoryData;
+import org.openoffice.ide.eclipse.core.utils.WorkbenchHelper;
 import org.openoffice.ide.eclipse.core.wizards.utils.NoSuchPageException;
 
 /**
@@ -81,7 +82,7 @@ public class NewServiceWizard extends BasicNewResourceWizard implements INewWiza
      */
     public NewServiceWizard() {
         super();
-        mActivePage = OOEclipsePlugin.getActivePage();
+        mActivePage = WorkbenchHelper.getActivePage();
     }
 
     /**
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java b/core/source/org/openoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java
index bfb3468..ec71815 100755
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java
@@ -66,6 +66,7 @@ import org.openoffice.ide.eclipse.core.model.OOoContainer;
 import org.openoffice.ide.eclipse.core.model.UnoFactoryData;
 import org.openoffice.ide.eclipse.core.model.language.ILanguage;
 import org.openoffice.ide.eclipse.core.model.language.LanguageWizardPage;
+import org.openoffice.ide.eclipse.core.utils.WorkbenchHelper;
 import org.openoffice.ide.eclipse.core.wizards.pages.NewUnoProjectPage;
 import org.openoffice.ide.eclipse.core.wizards.utils.NoSuchPageException;
 
@@ -91,7 +92,7 @@ public class NewUnoProjectWizard extends BasicNewProjectResourceWizard implement
     public NewUnoProjectWizard() {
         
         super();
-        mActivePage = OOEclipsePlugin.getActivePage();
+        mActivePage = WorkbenchHelper.getActivePage();
         setForcePreviousAndNextButtons(false);
     }
     
diff --git a/cpp/plugin.xml b/cpp/plugin.xml
index 2f7ac45..4843729 100644
--- a/cpp/plugin.xml
+++ b/cpp/plugin.xml
@@ -20,5 +20,10 @@
             name="C++ UNO client application">
       </wizard>
    </extension>
+   <extension
+         id="id1"
+         name="name"
+         point="org.eclipse.cdt.core.externalSettingsProvider">
+   </extension>
 
 </plugin>
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/CDTHelper.java b/cpp/source/org/openoffice/ide/eclipse/cpp/CDTHelper.java
index f5ca7a3..2b08d40 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/CDTHelper.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/CDTHelper.java
@@ -1,5 +1,7 @@
 package org.openoffice.ide.eclipse.cpp;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.eclipse.cdt.core.CCProjectNature;
@@ -10,6 +12,11 @@ import org.eclipse.cdt.core.settings.model.ICFolderDescription;
 import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
 import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
 import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
 import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
@@ -36,6 +43,15 @@ public class CDTHelper {
     }
     
     public static void addEntries( IProject pProject, ICLanguageSettingEntry[] pNewEntries, int pEntriesType ) {
+        changeEntries( pProject, pNewEntries, pEntriesType, false );
+    }
+    
+    public static void removeEntries( IProject pProject, ICLanguageSettingEntry[] pOldEntries, int pEntriesType ) {
+        changeEntries( pProject, pOldEntries, pEntriesType, true );
+    }
+    
+    private static void changeEntries( IProject pProject, ICLanguageSettingEntry[] pEntries, 
+            int pEntriesType, boolean pRemove ) {
         ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription( pProject );
         ICConfigurationDescription[] configs = prjDesc.getConfigurations();
         
@@ -45,9 +61,12 @@ public class CDTHelper {
             ICLanguageSetting[] languages = folder.getLanguageSettings();
             for (ICLanguageSetting lang : languages) {
                 List<ICLanguageSettingEntry> entries = lang.getSettingEntriesList( pEntriesType );
-                for ( ICLanguageSettingEntry newEntry : pNewEntries ) {
-                    if ( !entries.contains( newEntry ) ) {
-                        entries.add( newEntry );
+                for ( ICLanguageSettingEntry entry : pEntries ) {
+                    boolean contained = entries.contains( entry );
+                    if ( contained && pRemove ) {
+                        entries.remove( entry );
+                    } else if ( !contained && !pRemove ) {
+                        entries.add( entry );
                     }
                 }
                 lang.setSettingEntries( pEntriesType, entries );
@@ -57,33 +76,46 @@ public class CDTHelper {
         try {
             CoreModel.getDefault().setProjectDescription( pProject, prjDesc );
         } catch ( CoreException e ) {
-            PluginLogger.error( "Error setting the includes and libraries", e );
+            PluginLogger.error( "Error setting a path entry", e );
         }
     }
     
-    public static void removeEntries( IProject pProject, ICLanguageSettingEntry[] pOldEntries, int pEntriesType ) {
-        ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription( pProject );
-        ICConfigurationDescription[] configs = prjDesc.getConfigurations();
+    public static void addLibs( IProject pProject, String[] pLibNames ) {
+        changeLibs( pProject, pLibNames, false );
+    }
+    
+    public static void removeLibs( IProject pProject, String[] pLibNames ) {
+        changeLibs( pProject, pLibNames, true );
+    }
+    
+    private static void changeLibs( IProject pProject, String[] pLibNames, boolean pRemove ) {
+        IManagedBuildInfo infos = ManagedBuildManager.getBuildInfo( pProject );
+        IConfiguration[] configs = infos.getManagedProject().getConfigurations();
         
-        // Set them on all the languages of all the configurations
-        for (ICConfigurationDescription config : configs) {
-            ICFolderDescription folder = config.getRootFolderDescription();
-            ICLanguageSetting[] languages = folder.getLanguageSettings();
-            for (ICLanguageSetting lang : languages) {
-                List<ICLanguageSettingEntry> entries = lang.getSettingEntriesList( pEntriesType );
-                for ( ICLanguageSettingEntry oldEntry : pOldEntries ) {
-                    if ( entries.contains( oldEntry ) ) {
-                        entries.remove( oldEntry );
+        for (IConfiguration config : configs ) {
+            ITool tool = config.calculateTargetTool();
+            IOption[] options = tool.getOptions();
+            for (IOption option : options) {
+                try {
+                    if ( option.getValueType() == IOption.LIBRARIES ) {
+                        // Append the libraries if not already set
+                        String[] libs = option.getLibraries();
+                        ArrayList<String> newLibs = new ArrayList<String>( Arrays.asList( libs ) );
+                        for ( String lib : pLibNames ) {
+                            boolean contained = newLibs.contains( lib );
+                            if ( !contained && !pRemove ) {
+                                newLibs.add( lib );
+                            } else if ( contained && pRemove ) {
+                                newLibs.remove( lib );
+                            }
+                        }
+                        ManagedBuildManager.setOption(config, tool, option, newLibs.toArray( new String[ newLibs.size() ] ) );
                     }
+                } catch ( Exception e ) {
+                    PluginLogger.error( "Error setting linker libraries option", e );
                 }
-                lang.setSettingEntries( pEntriesType, entries );
             }
         }
-        
-        try {
-            CoreModel.getDefault().setProjectDescription( pProject, prjDesc );
-        } catch ( CoreException e ) {
-            PluginLogger.error( "Error setting the includes and libaries", e );
-        }
+        ManagedBuildManager.saveBuildInfo( pProject, false );
     }
 }
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java b/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java
index f2064de..3a0d751 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java
@@ -238,6 +238,7 @@ public class CppProjectHandler implements IProjectHandler {
         CDTHelper.addEntries( project, new CIncludePathEntry[] { sdkIncludes, includes }, ICSettingEntry.INCLUDE_PATH );
         CDTHelper.addEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
         CDTHelper.addEntries( project, getMacrosForPlatform( Platform.getOS() ), ICSettingEntry.MACRO );
+        CDTHelper.addLibs( project, LIBS );
         
         // Run the cppumaker on the ooo types ( asynchronous )
         OOoSdkProjectJob job = new OOoSdkProjectJob(ooo, sdk );
@@ -261,6 +262,6 @@ public class CppProjectHandler implements IProjectHandler {
         CDTHelper.removeEntries( project, new CIncludePathEntry[] { sdkIncludes, includes }, ICSettingEntry.INCLUDE_PATH );
         CDTHelper.removeEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
         CDTHelper.removeEntries( project, getMacrosForPlatform( Platform.getOS() ), ICSettingEntry.MACRO );
-
+        CDTHelper.removeLibs( project, LIBS );
     }
 }
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java b/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
index 380a579..7dd7d4a 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
@@ -34,28 +34,36 @@ import java.io.FileWriter;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.LineNumberReader;
+import java.text.MessageFormat;
 
 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.IContainer;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ui.IWorkbenchPage;
+import org.openoffice.ide.eclipse.core.PluginLogger;
 import org.openoffice.ide.eclipse.core.model.config.IOOo;
 import org.openoffice.ide.eclipse.core.model.config.ISdk;
+import org.openoffice.ide.eclipse.core.utils.WorkbenchHelper;
 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"; //$NON-NLS-1$
+    private static final String SRC_DIR_NAME = "src"; //$NON-NLS-1$
+    private static final String CLIENT_FILE = "client.cxx"; //$NON-NLS-1$
+    
     private UnoConnectionPage mCnxPage;
+    private IWorkbenchPage mActivePage;
 
     public ClientWizard() {
         super( );
         setWindowTitle( "UNO Client C++ project" );
+        mActivePage = WorkbenchHelper.getActivePage();
     }
     
     @Override
@@ -75,44 +83,52 @@ public class ClientWizard extends CCProjectWizard {
         
     }
     
-    /**
-     * 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();
-        
-        // 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$
+    public boolean performFinish() {
+        boolean finished = super.performFinish();
         
-        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 );
-        
-        CppProjectHandler.addOOoDependencies( ooo, sdk, newProject );
+        try {
+            IOOo ooo = mCnxPage.getOoo();
+            ISdk sdk = mCnxPage.getSdk();
+
+            // Copy the helper files in the helper source dir
+            IFolder srcDir = newProject.getFolder( SRC_DIR_NAME );
+            srcDir.create( true, true, null );
+
+            copyResource( "connection.hxx", srcDir, new String() ); //$NON-NLS-1$
+            copyResource( "connection.cxx", srcDir, new String() ); //$NON-NLS-1$
+            
+            // TODO Make that configurable in the wizard
+            String cnxInitCode = "SocketConnection cnx( 8080, \"localhost\" );"; //$NON-NLS-1$
+            copyResource( CLIENT_FILE, srcDir, cnxInitCode );
+
+            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 );
+
+            CppProjectHandler.addOOoDependencies( ooo, sdk, newProject );
+            
+            // TODO Setup the launch config
+            
+            selectAndReveal( srcDir.getFile( CLIENT_FILE ) );
+            WorkbenchHelper.showFile( srcDir.getFile( CLIENT_FILE ), mActivePage );
         
-        // TODO Setup the launch config
+        } catch ( Exception e ) {
+            PluginLogger.error( "Couldn't set OOo Client config", e );
+        }
         
-        return created;
+        return finished;
     }
 
-    private void copyResource(String pResName, IFolder pSrcDir) {
+    private void copyResource(String pResName, IContainer pSrcDir, String pReplacement ) {
         InputStream in = this.getClass().getResourceAsStream( pResName );
-        File destFile = pSrcDir.getFile( pResName ).getLocation().toFile();
+        File destFile = new File( pSrcDir.getLocation().toFile(), pResName );
         
         FileWriter out = null;
         try {
@@ -122,7 +138,7 @@ public class ClientWizard extends CCProjectWizard {
             
             String line = reader.readLine();
             while ( line != null ) {
-                out.append( line + "\n" ); //$NON-NLS-1$
+                out.append( MessageFormat.format( line, pReplacement ) + "\n" ); //$NON-NLS-1$
                 line = reader.readLine();
             }
             
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/client.cxx b/cpp/source/org/openoffice/ide/eclipse/cpp/client/client.cxx
new file mode 100644
index 0000000..7bde5a0
--- /dev/null
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/client.cxx
@@ -0,0 +1,41 @@
+/*
+ * This file has been automatically generated by the ooeclipse integration.
+ * http://cedric.bosdonnat.free.fr/ooeclipseintegration
+ *
+ * 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
+ */
+#include <iostream>
+
+#include "connection.hxx"
+
+using namespace unoclienthelper;
+using namespace com::sun::star::uno;
+
+int main( int argc, char** argv )
+'{'
+	int bRet = 1;
+
+	{0}
+	if ( cnx.connect() )
+	'{'
+		Reference< XComponentContext > xCtx = cnx.getContext();
+
+		// TODO Use the UNO Context here
+
+		cnx.disconnect();
+		bRet = 0;
+	}
+
+	return bRet;
+}
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx
index 7c3a9d8..5729fce 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx
@@ -49,10 +49,10 @@ using namespace com::sun::star;
 
 #define OUSTRING_TO_C( x )		rtl::OUStringToOString( x, RTL_TEXTENCODING_UTF8 ).getStr( )
 
-namespace unoclienthelper {
+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=" ) );
@@ -60,34 +60,34 @@ SocketConnection::SocketConnection( int nPort, char* pHost )
 }
 
 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 );
 
@@ -126,7 +126,7 @@ bool AbstractConnection::connect( )
 		m_bConnected = true;
 	}
 	catch ( NoConnectException e )
-	{
+	'{'
 #if DEBUG
 		fprintf( stderr, "connection failed: %s : %s\n",
 				OUSTRING_TO_C( m_sConnectionString ),
@@ -138,29 +138,29 @@ bool AbstractConnection::connect( )
 }
 
 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 );
@@ -168,12 +168,12 @@ Reference<XDesktop> AbstractConnection::getDesktop()
 }
 
 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
@@ -187,15 +187,15 @@ Reference<XInterface> AbstractConnection::getService( rtl::OUString sServiceName
 }
 
 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
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.hxx b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.hxx
index 21e8f0f..a93eccd 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.hxx
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.hxx
@@ -36,10 +36,10 @@
 #include <rtl/ustring.hxx>
 
 
-namespace unoclienthelper {
+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;
@@ -71,14 +71,14 @@ private:
 };
 
 class PipeConnection : public AbstractConnection
-{
+'{'
 public:
 	PipeConnection( char* pPipeName );
 	~PipeConnection( );
 };
 
 class SocketConnection : public AbstractConnection
-{
+'{'
 public:
 	SocketConnection( int nPort, char* pHost = "localhost" );
 	~SocketConnection( );


More information about the ooo-build-commit mailing list