summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic SMADJA <ludovic.smadja@jalios.com>2012-08-14 10:35:26 +0200
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-08-14 10:35:26 +0200
commit6d316d8c5a1cb2a04c6a5d1712b536a073e2bb66 (patch)
treeaedf512996722b4ebad4ed99ef5788fa001d0347
parenta0b6bf7306e3c27074d35b2ceb5e09b47086e7fd (diff)
Add compatibility with LibreOffice 3.5
-rw-r--r--core/build.xml22
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java7
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java33
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/internal/model/OOo.java359
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/internal/model/RelativeFileLocator.java73
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/internal/model/URE.java12
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java7
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/internal/model/messages.properties1
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java6
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/model/config/IOOo.java1
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/model/description/DescriptionModel.java8
-rw-r--r--cpp/build.xml25
-rw-r--r--java/.classpath1
-rw-r--r--java/build.xml19
-rw-r--r--java/source/org/openoffice/ide/eclipse/java/JavaDebugExtraOptionsProvider.java13
-rw-r--r--java/source/org/openoffice/ide/eclipse/java/JavaProjectHandler.java213
16 files changed, 564 insertions, 236 deletions
diff --git a/core/build.xml b/core/build.xml
index e11f6f6..6d5cae2 100644
--- a/core/build.xml
+++ b/core/build.xml
@@ -42,7 +42,7 @@
<project name="core" default="core.error">
- <import file="../packager/build/build.xml"/>
+ <import file="../packager/build.xml"/>
<target name="core.error">
<fail>Wrong target!
@@ -64,6 +64,7 @@
<fileset dir="${eclipse.home}/plugins/">
<include name="org.eclipse*.jar"/>
+ <include name="org.junit*/*.jar"/>
</fileset>
<fileset dir="${packager.basedir}">
@@ -114,6 +115,25 @@
</zipfileset>
</jar>
</target>
+
+ <target name="core.site" depends="core.plugin, packager.site">
+
+ <!-- Echo the needed bits for site.xml -->
+ <copy tofile="${out.path}/site-core.xml" file="${build.basedir}/site-feature.xml" />
+ <replace file="${out.path}/site-core.xml" token="@@URL@@" value="features/org.openoffice.ide.eclipse.core_${core.Bundle-Version}.jar"/>
+ <replace file="${out.path}/site-core.xml" token="@@ID@@" value="org.openoffice.ide.eclipse.core"/>
+ <replace file="${out.path}/site-core.xml" token="@@VERSION@@" value="${core.Bundle-Version}"/>
+
+ <!-- Copying the plugins -->
+ <copy todir="${out.path}/plugins">
+ <fileset dir="${core.out.path}/plugins/"
+ includes="*.jar" />
+ <mapper type="flatten" />
+ </copy>
+
+ <!-- Preparing the plugins for p2 update site -->
+ <prepareJar jar="${out.path}/plugins/${package.prefix}.core_${core.Bundle-Version}.jar" outdir="${out.path}/plugins"/>
+ </target>
<target name="check-javadocs">
<condition property="javadocs.do">
diff --git a/core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java b/core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java
index 6ffcd74..b770492 100644
--- a/core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java
+++ b/core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java
@@ -121,6 +121,9 @@ public class TypesBuilder extends IncrementalProjectBuilder {
IProject prj = getProject();
IUnoidlProject unoprj = ProjectsManager.getProject(prj.getName());
+ if(unoprj == null){
+ return false;
+ }
IPath idlPath = unoprj.getIdlPath();
IPath resPath = pDelta.getResource().getProjectRelativePath();
@@ -217,6 +220,10 @@ public class TypesBuilder extends IncrementalProjectBuilder {
IUnoidlProject unoprj = ProjectsManager.getProject(
pPrj.getName());
+ if(unoprj == null){
+ return ;
+ }
+
try {
IPath rdbPath = unoprj.getTypesPath();
IFile rdbFile = pPrj.getFile(rdbPath);
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java
index 9480f68..5305b49 100644
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java
@@ -433,4 +433,37 @@ public abstract class AbstractOOo implements IOOo, ITableElement {
}
return result;
}
+
+ protected static String getPlatformOS(){
+ return Platform.getOS();
+ }
+
+ /**
+ * indicates if a code is a symbolic link or not.
+ * The code is an adaptation from apache commons
+ * @param file
+ * @return true if the file is a symbolic link, false otherwise
+ * @throws IOException
+ */
+ protected static boolean isSymbolicLink(File file) throws IOException{
+ if(file == null){
+ return false;
+ }
+ File fileInCanonicalParent = null;
+ if(file.getParentFile() == null){
+ fileInCanonicalParent = file;
+ }
+ else{
+ File canonicalParent= file.getParentFile().getCanonicalFile();
+ fileInCanonicalParent = new File(canonicalParent, file.getName());
+ }
+ return !fileInCanonicalParent.getCanonicalFile().equals(fileInCanonicalParent.getAbsoluteFile());
+ }
+
+ public static File getTargetLink(File link) throws IOException {
+ if(link == null){
+ return null;
+ }
+ return new File(link.getCanonicalPath());
+ }
}
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/OOo.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/OOo.java
index ad3c499..89a7fbd 100644
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/OOo.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/OOo.java
@@ -45,9 +45,13 @@ package org.openoffice.ide.eclipse.core.internal.model;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.Properties;
import org.eclipse.core.runtime.IPath;
@@ -144,15 +148,7 @@ public class OOo extends AbstractOOo {
* {@inheritDoc}
*/
public String[] getClassesPath() {
-
- String[] paths = new String[] { getLibsPath()[0] + FILE_SEP + "classes" //$NON-NLS-1$
- };
-
- if (mMapper.isVersion3()) {
- paths = mMapper.getClasses();
- }
-
- return paths;
+ return mMapper.getClasses();
}
/**
@@ -161,7 +157,6 @@ public class OOo extends AbstractOOo {
public String[] getLibsPath() {
// Nothing if not OOo3
String[] otherPaths = mMapper.getAdditionnalLibs();
-
String libs = getHome() + FILE_SEP + "program"; //$NON-NLS-1$
if (getPlatform().equals(Platform.OS_MACOSX)) {
libs = getHome() + FILE_SEP + "MacOS"; //$NON-NLS-1$
@@ -189,28 +184,14 @@ public class OOo extends AbstractOOo {
* {@inheritDoc}
*/
public String[] getTypesPath() {
- String[] paths = { getLibsPath()[0] + FILE_SEP + "types.rdb" //$NON-NLS-1$
- };
-
- if (mMapper.isVersion3()) {
- paths = mMapper.getTypes();
- }
-
- return paths;
+ return mMapper.getTypes();
}
/**
* {@inheritDoc}
*/
public String[] getServicesPath() {
- String[] paths = new String[] { getLibsPath()[0] + FILE_SEP + "services.rdb" //$NON-NLS-1$
- };
-
- // Change the paths for OOo3 installs
- if (mMapper.isVersion3()) {
- paths = mMapper.getServices();
- }
- return paths;
+ return mMapper.getServices();
}
/**
@@ -230,17 +211,7 @@ public class OOo extends AbstractOOo {
* {@inheritDoc}
*/
public String getUnoPath() {
- String uno = "uno.bin"; //$NON-NLS-1$
- if (getPlatform().equals(Platform.OS_WIN32)) {
- uno = "uno.exe"; //$NON-NLS-1$
- }
- String unoPath = getLibsPath()[0] + FILE_SEP + uno;
-
- if (mMapper.isVersion3()) {
- unoPath = mMapper.getUnoPath();
- }
-
- return unoPath;
+ return mMapper.getUnoPath();
}
/**
@@ -374,8 +345,8 @@ public class OOo extends AbstractOOo {
mDoRemovePackage = false;
Display.getDefault().syncExec(new Runnable() {
public void run() {
- mDoRemovePackage = MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages
- .getString("OOo.PackageExportTitle"), //$NON-NLS-1$
+ mDoRemovePackage = MessageDialog.openConfirm(Display.getDefault().getActiveShell(),
+ Messages.getString("OOo.PackageExportTitle"), //$NON-NLS-1$
Messages.getString("OOo.PackageAlreadyInstalled")); //$NON-NLS-1$
}
});
@@ -391,8 +362,8 @@ public class OOo extends AbstractOOo {
} catch (Exception e) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- MessageDialog.openError(Display.getDefault().getActiveShell(), Messages
- .getString("OOo.PackageExportTitle"), //$NON-NLS-1$
+ MessageDialog.openError(Display.getDefault().getActiveShell(),
+ Messages.getString("OOo.PackageExportTitle"), //$NON-NLS-1$
Messages.getString("OOo.DeploymentError")); //$NON-NLS-1$
}
});
@@ -453,7 +424,7 @@ public class OOo extends AbstractOOo {
* @param pName
* the name of the package to remove
* @param pUserInstallation
- * the path to the office user installation to use
+ * the path to the office user installation to use
* @throws Exception
* if anything wrong happens
*/
@@ -521,69 +492,155 @@ public class OOo extends AbstractOOo {
private class OOo3PathMapper {
private String mHome;
- private String mBasis;
-
- private boolean mVersionChecked = false;
/**
* This field holds the URE instance to use for OOo3.
*/
private URE mUre;
+ // private fields
+ private File mapperBasisLibs;
+ private File mapperBasisBins;
+ private File mapperBasisClasses;
+ private List<File> mapperBasisTypes;
+ private List<File> mapperBasisServices;
+
/**
* Create a new mapper object to get the OOo3 layers paths.
*
* @param pHome
* the OOo install home
+ * @throws InvalidConfigException
*/
- public OOo3PathMapper(String pHome) {
+ public OOo3PathMapper(String pHome) throws InvalidConfigException {
mHome = pHome;
+ initPaths();
}
- /**
- * @return <code>true</code> if the openoffice install corresponds to a 3.0 installation layout,
- * <code>false</code> otherwise.
- */
- public boolean isVersion3() {
- boolean version3 = false;
-
- if (!mVersionChecked) {
- try {
- Path homePath = new Path(mHome);
- File homeFile = homePath.toFile();
-
- File basis = getPortableLink("basis-link", homeFile); //$NON-NLS-1$
- File ure = getPortableLink("ure-link", basis); //$NON-NLS-1$
-
- version3 = basis.isDirectory() && ure.isDirectory();
+ private void initPaths() throws InvalidConfigException {
+ // locate ure directory (directory which contains bin/uno.bin or bin/uno.exe
+ String unoRelativePath = "bin/" + URE.getUnoExecutable();
+ File ureDir = locateUniqueContainer(mHome, unoRelativePath);
+ if (ureDir == null) {
+ mHome = null;
+ throw new InvalidConfigException(Messages.getString("AbstractOOo.NoFileError") + unoRelativePath,
+ InvalidConfigException.INVALID_OOO_HOME);
+ }
+ mUre = new URE(ureDir.getAbsolutePath());
+ }
- if (version3) {
- mBasis = basis.getCanonicalPath();
- mUre = new URE(ure.getCanonicalPath());
+ private File locateUniqueContainer(String baseDir, String pUnoRelativePath) throws InvalidConfigException {
+ try {
+ File base = new File(baseDir);
+ if (!base.exists() || !base.isDirectory() || !base.canRead()) {
+ return null;
+ }
+ List<File> dirs = new RelativeFileLocator(base, pUnoRelativePath).getFiles();
+ if (dirs == null) {
+ throw new InvalidConfigException(Messages.getString("AbstractOOo.NoFileError") + pUnoRelativePath,
+ InvalidConfigException.INVALID_OOO_HOME);
+ }
+ // remove link if there is duplicate
+ if (dirs.size() > 1) {
+ List<File> linksList = new ArrayList<File>();
+ for (File tmpFile : dirs) {
+ if (AbstractOOo.isSymbolicLink(tmpFile)) {
+ linksList.add(tmpFile);
+ }
+ }
+ if(!linksList.isEmpty()) {
+ for(File link : linksList){
+ File linkTarget = AbstractOOo.getTargetLink(link);
+ if(dirs.contains(linkTarget)){
+ dirs.remove(linkTarget);
+ }
+ }
}
- } catch (Exception e) {
- version3 = false;
}
-
- mVersionChecked = true;
- } else {
- version3 = mUre != null;
+ if (dirs.size() != 1) {
+ throw new InvalidConfigException(Messages.getString("AbstractOOo.NoFileError") + pUnoRelativePath,
+ InvalidConfigException.INVALID_OOO_HOME);
+ } else {
+ return dirs.get(0);
+ }
+ } catch (IOException e) {
+ throw new InvalidConfigException(Messages.getString("AbstractOOo.NoFileError") + pUnoRelativePath,
+ InvalidConfigException.INVALID_OOO_HOME);
}
-
- return version3;
}
+ private List<File> locateFiles(String baseDir, String pUnoRelativePath) throws InvalidConfigException {
+ try {
+ File base = new File(baseDir);
+ if (!base.exists() || !base.isDirectory() || !base.canRead()) {
+ return null;
+ }
+ List<File> dirs = new RelativeFileLocator(base, pUnoRelativePath).getFiles();
+ if (dirs == null) {
+ return Collections.emptyList();
+ }
+ // remove link if there is duplicate
+ if (dirs.size() > 1) {
+ List<File> linksList = new ArrayList<File>();
+ for (File tmpFile : dirs) {
+ if (AbstractOOo.isSymbolicLink(tmpFile)) {
+ linksList.add(tmpFile);
+ }
+ }
+ if(!linksList.isEmpty()) {
+ for(File link : linksList){
+ File linkTarget = AbstractOOo.getTargetLink(link);
+ if(dirs.contains(linkTarget)){
+ dirs.remove(linkTarget);
+ }
+ }
+ }
+ }
+ if(dirs.size() == 0){
+ return Collections.emptyList();
+ }
+ List<File> returnList = new ArrayList<File>();
+ for (File tmpFile : dirs) {
+ returnList.add(new File(tmpFile, pUnoRelativePath));
+ }
+ return returnList;
+ } catch (IOException e) {
+ throw new InvalidConfigException(Messages.getString("AbstractOOo.NoFileError") + pUnoRelativePath,
+ InvalidConfigException.INVALID_OOO_HOME);
+ }
+ }
+
/**
* @return the libraries path to add for OOo3 or an empty array if not an OOo3 install.
+ * @throws InvalidConfigException
*/
public String[] getAdditionnalLibs() {
String[] additionnal = new String[0];
- if (isVersion3()) {
- String[] ureLibs = mUre.getLibsPath();
- String basisLibs = mBasis + FILE_SEP + "program"; //$NON-NLS-1$
+ String[] ureLibs = new String[0];
+ if (mUre != null) {
+ ureLibs = mUre.getLibsPath();
+ }
- additionnal = mergeArrays(ureLibs, new String[] { basisLibs });
+ File basisLibs = this.mapperBasisLibs;
+ if(basisLibs == null){
+ try {
+ String extension = ".so";
+ if (getPlatform().equals(Platform.OS_WIN32)) {
+ extension = ".dll";
+ } else if (getPlatform().equals(Platform.OS_MACOSX)) {
+ extension = ".dylib";
+ }
+ basisLibs = locateUniqueContainer(mHome, "libpyuno" + extension);
+ this.mapperBasisLibs = basisLibs;
+ } catch (InvalidConfigException e) {
+ e.printStackTrace();
+ }
+ }
+ if (basisLibs != null) {
+ additionnal = mergeArrays(ureLibs, new String[] { basisLibs.getAbsolutePath() });
+ } else {
+ additionnal = ureLibs;
}
return additionnal;
@@ -595,11 +652,25 @@ public class OOo extends AbstractOOo {
public String[] getAdditionnalBins() {
String[] additionnal = new String[0];
- if (isVersion3()) {
- String[] ureBins = mUre.getBinPath();
- String basisBins = mBasis + FILE_SEP + "program"; //$NON-NLS-1$
+ String[] ureLibs = new String[0];
+ if (mUre != null) {
+ ureLibs = mUre.getBinPath();
+ }
- additionnal = mergeArrays(ureBins, new String[] { basisBins });
+ File basisLibs = this.mapperBasisBins;
+ if(basisLibs == null){
+ try {
+ basisLibs = locateUniqueContainer(mHome, "uno.pyc");
+ this.mapperBasisBins = basisLibs;
+ } catch (InvalidConfigException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (basisLibs != null) {
+ additionnal = mergeArrays(ureLibs, new String[] { basisLibs.getAbsolutePath() });
+ } else {
+ additionnal = ureLibs;
}
return additionnal;
@@ -611,12 +682,25 @@ public class OOo extends AbstractOOo {
public String[] getClasses() {
String[] classes = new String[0];
- if (isVersion3()) {
- String[] ureClasses = mUre.getClassesPath();
- String basisClasses = mBasis + FILE_SEP + "program" + //$NON-NLS-1$
- FILE_SEP + "classes"; //$NON-NLS-1$
+ String[] ureClasses = new String[0];
+ if (mUre != null) {
+ ureClasses = mUre.getClassesPath();
+ }
+
+ File basisClasses = this.mapperBasisClasses;
+ if(mapperBasisClasses == null){
+ try {
+ basisClasses = locateUniqueContainer(mHome, "unoil.jar");
+ mapperBasisClasses= basisClasses;
+ } catch (InvalidConfigException e) {
+ e.printStackTrace();
+ }
+ }
- classes = mergeArrays(ureClasses, new String[] { basisClasses });
+ if (basisClasses != null) {
+ classes = mergeArrays(ureClasses, new String[] { basisClasses.getAbsolutePath() });
+ } else {
+ classes = ureClasses;
}
return classes;
@@ -628,12 +712,31 @@ public class OOo extends AbstractOOo {
public String[] getTypes() {
String[] types = new String[0];
- if (isVersion3()) {
- String[] ureTypes = mUre.getTypesPath();
- String basisTypes = mBasis + FILE_SEP + "program" + //$NON-NLS-1$
- FILE_SEP + "offapi.rdb"; //$NON-NLS-1$
+ String[] ureTypes = new String[0];
+ if (mUre != null) {
+ ureTypes = mUre.getTypesPath();
+ }
- types = mergeArrays(ureTypes, new String[] { basisTypes });
+ List<File> basisTypes = this.mapperBasisTypes;
+ if(mapperBasisTypes == null){
+ try {
+ basisTypes = locateFiles(mHome, "offapi.rdb");
+ mapperBasisTypes = basisTypes;
+ } catch (InvalidConfigException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (basisTypes != null && basisTypes.size() > 0) {
+ List<String> servicesPathList = new ArrayList<String>();
+ for(File typeFile : basisTypes){
+ if(typeFile != null){
+ servicesPathList.add(typeFile.getAbsolutePath());
+ }
+ }
+ types = mergeArrays(ureTypes, (String[]) servicesPathList.toArray(new String[servicesPathList.size()]));
+ } else {
+ types = ureTypes;
}
return types;
@@ -645,12 +748,31 @@ public class OOo extends AbstractOOo {
public String[] getServices() {
String[] types = new String[0];
- if (isVersion3()) {
- String[] ureTypes = mUre.getServicesPath();
- String basisTypes = mBasis + FILE_SEP + "program" + //$NON-NLS-1$
- FILE_SEP + "services.rdb"; //$NON-NLS-1$
+ String[] ureTypes = new String[0];
+ if (mUre != null) {
+ ureTypes = mUre.getServicesPath();
+ }
+
+ List<File> basisTypes = this.mapperBasisServices;
+ if(mapperBasisServices == null){
+ try {
+ basisTypes = locateFiles(mHome, "services.rdb");
+ mapperBasisServices = basisTypes;
+ } catch (InvalidConfigException e) {
+ e.printStackTrace();
+ }
+ }
- types = mergeArrays(ureTypes, new String[] { basisTypes });
+ if (basisTypes != null && basisTypes.size() > 0) {
+ List<String> servicesPathList = new ArrayList<String>();
+ for(File typeFile : basisTypes){
+ if(typeFile != null){
+ servicesPathList.add(typeFile.getAbsolutePath());
+ }
+ }
+ types = mergeArrays(ureTypes, (String[]) servicesPathList.toArray(new String[servicesPathList.size()]));
+ } else {
+ types = ureTypes;
}
return types;
@@ -661,7 +783,7 @@ public class OOo extends AbstractOOo {
*/
public String getUnoPath() {
String path = null;
- if (isVersion3()) {
+ if (mUre != null) {
path = mUre.getUnoPath();
}
@@ -681,6 +803,12 @@ public class OOo extends AbstractOOo {
* @return the array with the elements of both arrays
*/
public String[] mergeArrays(String[] pArray1, String[] pArray2) {
+ if (pArray1 == null) {
+ return pArray2;
+ }
+ if (pArray2 == null) {
+ return pArray1;
+ }
String[] result = new String[pArray1.length + pArray2.length];
System.arraycopy(pArray1, 0, result, 0, pArray1.length);
@@ -688,42 +816,5 @@ public class OOo extends AbstractOOo {
return result;
}
-
- /**
- * Get the file object for the link defined as a child of a folder.
- *
- * On Windows platform, the link relative location is specified as the content of a file named after the link
- * name. On Unix-based systems symbolic links are supported.
- *
- * @param pName
- * the name of the symbolic link
- * @param pParent
- * the parent directory file
- *
- * @return the file representing the link target or <code>null</code>
- */
- private File getPortableLink(String pName, File pParent) {
- File link = null;
-
- File linkFile = new File(pParent, pName);
- if (getPlatform().equals(Platform.OS_WIN32)) {
- // Read the content of the file to get the true folder
- try {
- FileInputStream is = new FileInputStream(linkFile);
- byte[] buf = new byte[is.available()];
- is.read(buf);
-
- String relativePath = new String(buf);
- linkFile = new File(pParent, relativePath);
- link = linkFile;
- } catch (Exception e) {
- // the returned link is null to show the error
- }
- } else {
- link = linkFile;
- }
-
- return link;
- }
}
}
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/RelativeFileLocator.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/RelativeFileLocator.java
new file mode 100644
index 0000000..613e7af
--- /dev/null
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/RelativeFileLocator.java
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * 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 3 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program.
+ * If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright: 2012 by Ludovic Smadja
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.core.internal.model;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class RelativeFileLocator {
+
+ private File mBaseDir = null;
+ private String mRelativePath = null;
+
+ public RelativeFileLocator(File baseDir, String pRelativePath) {
+ super();
+ this.mBaseDir = baseDir;
+ this.mRelativePath = pRelativePath;
+ }
+
+ public List<File> getFiles(){
+ if(mBaseDir == null || !mBaseDir.isDirectory()){
+ return null;
+ }
+ List<File> fileList = new ArrayList<File>();
+ List<File> scannedDirList = new ArrayList<File>();
+ scannedDirList.add(mBaseDir);
+ locateRelativeFile(scannedDirList, fileList, mRelativePath);
+ return fileList;
+ }
+
+ private void locateRelativeFile(List<File> scannedDirList, List<File> fileList, String relativePath) {
+ if( scannedDirList == null || scannedDirList.isEmpty()){
+ return;
+ }
+ List<File> newScannedDirList = new ArrayList<File>();
+ for(File scanFile : scannedDirList){
+ if( scanFile.exists() && scanFile.isDirectory()){
+ File tmpFile = new File(scanFile, relativePath);
+ if(tmpFile.exists()){
+ fileList.add(scanFile);
+ }
+ File[] children = scanFile.listFiles();
+ if(children != null && children.length > 0){
+ newScannedDirList.addAll(Arrays.asList(children));
+ }
+ }
+ }
+ if(!newScannedDirList.isEmpty()){
+ locateRelativeFile(newScannedDirList,fileList,relativePath);
+ }
+ }
+
+}
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/URE.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/URE.java
index c8ec6eb..f982c31 100644
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/URE.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/URE.java
@@ -168,14 +168,18 @@ public class URE extends AbstractOOo {
* {@inheritDoc}
*/
public String getUnoPath() {
+ return getHome() + FILE_SEP + "bin" + FILE_SEP + getUnoExecutable(); //$NON-NLS-1$
+ }
+
+ public static String getUnoExecutable(){
String uno = "uno.bin"; //$NON-NLS-1$
- if (getPlatform().equals(Platform.OS_WIN32)) {
+ if (getPlatformOS().equals(Platform.OS_WIN32)) {
uno = "uno.exe"; //$NON-NLS-1$
}
-
- return getHome() + FILE_SEP + "bin" + FILE_SEP + uno; //$NON-NLS-1$
+ return uno;
}
-
+
+
/**
* {@inheritDoc}
*/
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java
index 2457b90..4e45a3c 100644
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/UnoidlProject.java
@@ -633,6 +633,11 @@ public class UnoidlProject implements IUnoidlProject, IProjectNature {
*/
public void saveAllProperties() {
+ if( mLanguage == null || mOOo == null || mSdk == null){
+ PluginLogger.warning(Messages.getString("UnoidlProject.InconsistentConfigurationError")); //$NON-NLS-1$
+ return;
+ }
+
Properties properties = new Properties();
File configFile = getConfigFile();
@@ -646,7 +651,7 @@ public class UnoidlProject implements IUnoidlProject, IProjectNature {
try {
in = new FileInputStream(configFile);
properties.load(in);
-
+
properties.setProperty(LANGUAGE, mLanguage.getName());
properties.setProperty(OOO_NAME, mOOo.getName());
properties.setProperty(SDK_NAME, mSdk.getId());
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/messages.properties b/core/source/org/openoffice/ide/eclipse/core/internal/model/messages.properties
index 5d99548..658878c 100644
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/messages.properties
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/messages.properties
@@ -9,6 +9,7 @@ UnoidlProject.UnreadableConfigFileWarning=Unreadable uno project configuration f
UnoidlProject.ConfigFileComment=UNO project configuration file
UnoidlProject.PropertyChangeError=Error during project property change ({0}, {1})
UnoidlProject.ConfigFileSaveError=Error saving all the project properties
+UnoidlProject.InconsistentConfigurationError=The configuration cannot be saved because it's inconsistent
SDK.NoSettingsDirError=settings directory is missing
SDK.MinSdkVersionError=SDK version has to be at least 2.0.4
SDK.NoDirectoryError=Not an existing directory
diff --git a/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java b/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java
index 6672d57..b7147c3 100644
--- a/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java
+++ b/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java
@@ -111,6 +111,12 @@ public class OfficeLaunchDelegate extends LaunchConfigurationDelegate {
// Deploy the component
deployComponent(unoprj, userInstallation, destFile);
+
+ //remove lock file not cleaned by unopkg gui
+ File lockFile = new File(userInstallation.toFile(), ".lock");
+ if (lockFile.exists()) {
+ lockFile.delete();
+ }
pMonitor.worked(1);
// Run an OpenOffice instance
diff --git a/core/source/org/openoffice/ide/eclipse/core/model/config/IOOo.java b/core/source/org/openoffice/ide/eclipse/core/model/config/IOOo.java
index 96c307c..b4eefec 100644
--- a/core/source/org/openoffice/ide/eclipse/core/model/config/IOOo.java
+++ b/core/source/org/openoffice/ide/eclipse/core/model/config/IOOo.java
@@ -143,6 +143,7 @@ public interface IOOo {
*/
public String getJavaldxPath();
+
/**
* Returns a command to execute a <code>uno</code> component.
*
diff --git a/core/source/org/openoffice/ide/eclipse/core/model/description/DescriptionModel.java b/core/source/org/openoffice/ide/eclipse/core/model/description/DescriptionModel.java
index e4bb50b..8fb3107 100644
--- a/core/source/org/openoffice/ide/eclipse/core/model/description/DescriptionModel.java
+++ b/core/source/org/openoffice/ide/eclipse/core/model/description/DescriptionModel.java
@@ -540,9 +540,13 @@ public class DescriptionModel implements IModel {
writer.startTag( XMLTokens.ELEMENT_DESCRIPTION, mapping );
// Write the version element
- printValueElement( writer, XMLTokens.ELEMENT_VERSION, mVersion );
+ if(mVersion != null && !"".equals(mVersion)){
+ printValueElement( writer, XMLTokens.ELEMENT_VERSION, mVersion );
+ }
printValueElement( writer, XMLTokens.ELEMENT_IDENTIFIER, mId );
- printValueElement( writer, XMLTokens.ELEMENT_PLATFORM, mPlatforms );
+ if(mPlatforms != null && !"".equals(mPlatforms)){
+ printValueElement( writer, XMLTokens.ELEMENT_PLATFORM, mPlatforms );
+ }
writeDependencies( writer );
writeUpdateInfos( writer );
diff --git a/cpp/build.xml b/cpp/build.xml
index 1628203..7ddea43 100644
--- a/cpp/build.xml
+++ b/cpp/build.xml
@@ -71,12 +71,12 @@
<mkdir dir="${cpp.out.classes}" />
</target>
- <target name="cpp.version" depends="init-env">
+ <target name="cpp.version" depends="init-env" unless="cpp.nobuild">
<property name="manifest.properties" value="MANIFEST-MF.properties"/>
<copy tofile="${manifest.properties}" file="${cpp.basedir}/META-INF/MANIFEST.MF"/>
<replace file="${manifest.properties}" token=":" value="="/>
<property file="${manifest.properties}" prefix="cpp"/>
- <delete file="${manifest.properties}" />
+ <delete file="${manifest.properties}" />
</target>
<target name="purge" depends="init-env">
@@ -103,7 +103,26 @@
<zipfileset prefix="icons" dir="${cpp.basedir}/icons"/>
<zipfileset prefix="" file="${cpp.basedir}/plugin.xml" />
</jar>
- </target>
+ </target>
+
+ <target name="cpp.site" depends="cpp.plugin" unless="cpp.nobuild">
+
+ <!-- Echo the needed bits for site.xml -->
+ <copy tofile="${out.path}/site-cpp.xml" file="${build.basedir}/site-feature.xml" />
+ <replace file="${out.path}/site-cpp.xml" token="@@URL@@" value="features/org.openoffice.ide.eclipse.cpp_${cpp.Bundle-Version}.jar"/>
+ <replace file="${out.path}/site-cpp.xml" token="@@ID@@" value="org.openoffice.ide.eclipse.cpp"/>
+ <replace file="${out.path}/site-cpp.xml" token="@@VERSION@@" value="${cpp.Bundle-Version}"/>
+
+ <!-- Copying the plugins -->
+ <copy todir="${out.path}/plugins">
+ <fileset dir="${cpp.out.path}/plugins/"
+ includes="*.jar" />
+ <mapper type="flatten" />
+ </copy>
+
+ <!-- Preparing the plugins for p2 update site -->
+ <prepareJar jar="${out.path}/plugins/${package.prefix}.cpp_${cpp.Bundle-Version}.jar" outdir="${out.path}/plugins"/>
+ </target>
</project>
diff --git a/java/.classpath b/java/.classpath
index d6914fe..55be196 100644
--- a/java/.classpath
+++ b/java/.classpath
@@ -4,5 +4,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="src" path="source"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/ANT"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/java/build.xml b/java/build.xml
index b591473..d85291a 100644
--- a/java/build.xml
+++ b/java/build.xml
@@ -106,5 +106,24 @@
</jar>
</target>
+ <target name="java.site" depends="java.plugin" unless="java.nobuild">
+
+ <!-- Echo the needed bits for site.xml -->
+ <copy tofile="${out.path}/site-java.xml" file="${build.basedir}/site-feature.xml" />
+ <replace file="${out.path}/site-java.xml" token="@@URL@@" value="features/org.openoffice.ide.eclipse.java_${java.Bundle-Version}.jar"/>
+ <replace file="${out.path}/site-java.xml" token="@@ID@@" value="org.openoffice.ide.eclipse.java"/>
+ <replace file="${out.path}/site-java.xml" token="@@VERSION@@" value="${java.Bundle-Version}"/>
+
+ <!-- Copying the plugins -->
+ <copy todir="${out.path}/plugins">
+ <fileset dir="${java.out.path}/plugins/"
+ includes="*.jar" />
+ <mapper type="flatten" />
+ </copy>
+
+ <!-- Preparing the plugins for p2 update site -->
+ <prepareJar jar="${out.path}/plugins/${package.prefix}.java_${java.Bundle-Version}.jar" outdir="${out.path}/plugins"/>
+ </target>
+
</project>
diff --git a/java/source/org/openoffice/ide/eclipse/java/JavaDebugExtraOptionsProvider.java b/java/source/org/openoffice/ide/eclipse/java/JavaDebugExtraOptionsProvider.java
index d0b7443..39f18cf 100644
--- a/java/source/org/openoffice/ide/eclipse/java/JavaDebugExtraOptionsProvider.java
+++ b/java/source/org/openoffice/ide/eclipse/java/JavaDebugExtraOptionsProvider.java
@@ -12,6 +12,7 @@ import org.openoffice.ide.eclipse.core.model.utils.SystemHelper;
public class JavaDebugExtraOptionsProvider implements IExtraOptionsProvider {
private String mPort;
+ private String OOO_EXTRA_JAVA_TOOL_OPTIONS = "OOO_EXTRA_JAVA_TOOL_OPTIONS"; //$NON-NLS-1$
/**
*
@@ -26,8 +27,16 @@ public class JavaDebugExtraOptionsProvider implements IExtraOptionsProvider {
* {@inheritDoc}
*/
public String[] addEnv(String[] pEnv) {
- pEnv = SystemHelper.addEnv(pEnv, "JAVA_TOOL_OPTIONS", "\"-Xdebug\" "
- + "\"-Xrunjdwp:transport=dt_socket,address=localhost:" + mPort + "\"", null);
+ String extraJavaOptEnv = System.getenv(OOO_EXTRA_JAVA_TOOL_OPTIONS);
+ if ( extraJavaOptEnv == null )
+ extraJavaOptEnv = new String( );
+ else
+ extraJavaOptEnv = extraJavaOptEnv.replaceAll("\"","\\\""); //$NON-NLS-1$//$NON-NLS-2$
+
+
+ pEnv = SystemHelper.addEnv(pEnv, "JAVA_TOOL_OPTIONS", //$NON-NLS-1$
+ extraJavaOptEnv + "\"-Xdebug\" " + //$NON-NLS-1$
+ "\"-Xrunjdwp:transport=dt_socket,address=localhost:" + mPort + "\"", null); //$NON-NLS-1$ //$NON-NLS-2$
return pEnv;
}
diff --git a/java/source/org/openoffice/ide/eclipse/java/JavaProjectHandler.java b/java/source/org/openoffice/ide/eclipse/java/JavaProjectHandler.java
index 36136f8..d2cbc5c 100644
--- a/java/source/org/openoffice/ide/eclipse/java/JavaProjectHandler.java
+++ b/java/source/org/openoffice/ide/eclipse/java/JavaProjectHandler.java
@@ -44,9 +44,16 @@
package org.openoffice.ide.eclipse.java;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Vector;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathException;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -72,25 +79,26 @@ import org.openoffice.ide.eclipse.core.model.language.IProjectHandler;
import org.openoffice.ide.eclipse.java.build.OOoContainerPage;
import org.openoffice.ide.eclipse.java.registration.RegistrationHelper;
import org.openoffice.ide.eclipse.java.tests.TestsHelper;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
/**
* The Project handler implementation for Java.
*
* @author cedricbosdo
- *
+ *
*/
public class JavaProjectHandler implements IProjectHandler {
- private static final String P_REGISTRATION_CLASSNAME = "regclassname"; //$NON-NLS-1$
- private static final String P_JAVA_VERSION = "javaversion"; //$NON-NLS-1$
-
- private static final String[] KEPT_JARS = {
- "unoil.jar", //$NON-NLS-1$
- "ridl.jar", //$NON-NLS-1$
- "juh.jar", //$NON-NLS-1$
- "jurt.jar", //$NON-NLS-1$
- "unoloader.jar", //$NON-NLS-1$
- "officebean.jar" //$NON-NLS-1$
+ private static final String P_REGISTRATION_CLASSNAME = "regclassname"; //$NON-NLS-1$
+ private static final String P_JAVA_VERSION = "javaversion"; //$NON-NLS-1$
+
+ private static final String[] KEPT_JARS = { "unoil.jar", //$NON-NLS-1$
+ "ridl.jar", //$NON-NLS-1$
+ "juh.jar", //$NON-NLS-1$
+ "jurt.jar", //$NON-NLS-1$
+ "unoloader.jar", //$NON-NLS-1$
+ "officebean.jar" //$NON-NLS-1$
};
/**
@@ -99,7 +107,7 @@ public class JavaProjectHandler implements IProjectHandler {
public void addOOoDependencies(IOOo pOoo, IProject pProject) {
IJavaProject javaProject = JavaCore.create(pProject);
-
+
OOoContainerPage.addOOoDependencies(pOoo, javaProject);
}
@@ -110,27 +118,26 @@ public class JavaProjectHandler implements IProjectHandler {
try {
if (!pProject.exists()) {
pProject.create(null);
- PluginLogger.debug(
- "Project created during language specific operation"); //$NON-NLS-1$
+ PluginLogger.debug("Project created during language specific operation"); //$NON-NLS-1$
}
-
+
if (!pProject.isOpen()) {
pProject.open(null);
PluginLogger.debug("Project opened"); //$NON-NLS-1$
}
-
+
IProjectDescription description = pProject.getDescription();
String[] natureIds = description.getNatureIds();
String[] newNatureIds = new String[natureIds.length + 1];
System.arraycopy(natureIds, 0, newNatureIds, 0, natureIds.length);
-
+
// Adding the nature
newNatureIds[natureIds.length] = JavaCore.NATURE_ID;
-
+
description.setNatureIds(newNatureIds);
pProject.setDescription(description, null);
PluginLogger.debug(Messages.getString("Language.JavaNatureSet")); //$NON-NLS-1$
-
+
} catch (CoreException e) {
PluginLogger.error(Messages.getString("Language.NatureSettingFailed")); //$NON-NLS-1$
}
@@ -142,8 +149,7 @@ public class JavaProjectHandler implements IProjectHandler {
public void configureProject(UnoFactoryData pData, IProgressMonitor pMonitor) throws Exception {
// Get the project from data
- IProject prj = (IProject)pData.getProperty(
- IUnoFactoryConstants.PROJECT_HANDLE);
+ IProject prj = (IProject) pData.getProperty(IUnoFactoryConstants.PROJECT_HANDLE);
IUnoidlProject unoprj = ProjectsManager.getProject(prj.getName());
// Set some properties on the project
@@ -153,38 +159,34 @@ public class JavaProjectHandler implements IProjectHandler {
unoprj.setProperty(P_REGISTRATION_CLASSNAME, regclass);
// Java version
- String javaversion = (String)pData.getProperty(
- JavaWizardPage.JAVA_VERSION);
+ String javaversion = (String) pData.getProperty(JavaWizardPage.JAVA_VERSION);
unoprj.setProperty(P_JAVA_VERSION, javaversion);
-
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- unoprj.getName());
-
+
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(unoprj.getName());
+
// Create the project structure
IJavaProject javaProject = JavaCore.create(project);
- javaProject.open( pMonitor );
-
+ javaProject.open(pMonitor);
+
IPath sourcePath = unoprj.getFolder(unoprj.getSourcePath()).getFullPath();
IPath buildPath = unoprj.getFolder(unoprj.getBuildPath()).getFullPath();
-
- IClasspathEntry[] entries = new IClasspathEntry[] {
- JavaCore.newSourceEntry(sourcePath),
- JavaRuntime.getDefaultJREContainerEntry(),
- JavaCore.newLibraryEntry(buildPath, null, null, false)
- };
-
+
+ IClasspathEntry[] entries = new IClasspathEntry[] { JavaCore.newSourceEntry(sourcePath),
+ JavaRuntime.getDefaultJREContainerEntry(),
+ JavaCore.newLibraryEntry(buildPath, null, null, false) };
+
javaProject.setRawClasspath(entries, pMonitor);
-
+
// Add the registration files
- RegistrationHelper.generateFiles( unoprj );
-
+ RegistrationHelper.generateFiles(unoprj);
+
// Tests creation
- Boolean usetests = (Boolean)pData.getProperty( JavaWizardPage.JAVA_TESTS );
- if ( usetests.booleanValue() ) {
- TestsHelper.writeTestClasses( unoprj );
-
- IJavaProject javaprj = JavaCore.create( prj );
- TestsHelper.addJUnitLibraries( javaprj );
+ Boolean usetests = (Boolean) pData.getProperty(JavaWizardPage.JAVA_TESTS);
+ if (usetests.booleanValue()) {
+ TestsHelper.writeTestClasses(unoprj);
+
+ IJavaProject javaprj = JavaCore.create(prj);
+ TestsHelper.addJUnitLibraries(javaprj);
}
}
@@ -194,24 +196,24 @@ public class JavaProjectHandler implements IProjectHandler {
public String getImplementationName(IUnoidlProject pPrj, String pService) throws Exception {
String prefix = pPrj.getCompanyPrefix();
String comp = pPrj.getOutputExtension();
-
+
String implementationName = null;
-
+
if (pService.startsWith(prefix)) {
String localName = pService.substring(prefix.length());
implementationName = prefix + "." + comp + localName + "Impl"; //$NON-NLS-1$ //$NON-NLS-2$
} else {
throw new Exception("Cannot find implementation name for service: " + pService); //$NON-NLS-1$
}
-
+
return implementationName;
}
-
+
/**
* {@inheritDoc}
*/
public IPath getImplementationFile(String pImplementationName) {
-
+
return new Path(pImplementationName.replace(".", "/") + ".java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@@ -220,10 +222,9 @@ public class JavaProjectHandler implements IProjectHandler {
*/
public String getSkeletonMakerLanguage(UnoFactoryData pData) throws Exception {
// Get the project from data
- String name = (String)pData.getProperty(
- IUnoFactoryConstants.PROJECT_NAME);
+ String name = (String) pData.getProperty(IUnoFactoryConstants.PROJECT_NAME);
IUnoidlProject unoprj = ProjectsManager.getProject(name);
-
+
return "--" + unoprj.getProperty(P_JAVA_VERSION); //$NON-NLS-1$
}
@@ -232,33 +233,68 @@ public class JavaProjectHandler implements IProjectHandler {
*/
public void removeOOoDependencies(IOOo pOoo, IProject pProject) {
IJavaProject javaProject = JavaCore.create(pProject);
-
+
OOoContainerPage.removeOOoDependencies(javaProject);
}
-
+
/**
* {@inheritDoc}
*/
public String getLibraryPath(IUnoidlProject pProject) {
return getJarFile(pProject).getLocation().toOSString();
}
-
+
/**
- * Returns a handle to the project jar file. Beware that this handle
- * may refer to a non-existing file. Users have to create it if necessary.
+ * Returns a handle to the project jar file. Beware that this handle may refer to a non-existing file. Users have to
+ * create it if necessary.
*
- * @param pProject the concerned UNO project
+ * @param pProject
+ * the concerned UNO project
* @return a handle to the jar file of the project
*/
public IFile getJarFile(IUnoidlProject pProject) {
String filename = pProject.getName().replace(" ", "") + ".jar"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return pProject.getFile(filename);
}
-
+
+ /**
+ * Returns a handle to the project jar file. Beware that this handle may refer to a non-existing file. Users have to
+ * create it if necessary.
+ *
+ * @param pProjectDir
+ * the concerned UNO project directory
+ * @return a handle to the jar file of the project
+ */
+ public File getJarFile(File pProjectDir) throws IOException, XPathException {
+ String filename = getName(pProjectDir).replace(" ", "") + ".jar"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return new File(pProjectDir, filename);
+ }
+
+ private String getName(File projectDir) throws IOException, XPathException {
+ File projectFile = new File(projectDir, ".project");
+ if (!projectFile.exists()) {
+ return null;
+ }
+ final FileInputStream byteStream = new FileInputStream(projectFile);
+ InputSource source = new InputSource(byteStream);
+
+ // evaluation de l'expression XPath
+ XPathFactory factory = XPathFactory.newInstance();
+ javax.xml.xpath.XPath xpath = factory.newXPath();
+ final String xPathExpr = "//projectDescription/name";
+ XPathExpression exp = xpath.compile(xPathExpr);
+ Node node = (Node) exp.evaluate(source, XPathConstants.NODE);
+ if (node == null) {
+ return null;
+ }
+ return node.getTextContent();
+ }
+
/**
* Get the UNO registration class name of the project.
*
- * @param pProject the project for witch to get the registration class.
+ * @param pProject
+ * the project for witch to get the registration class.
*
* @return the registration class name
*/
@@ -270,69 +306,68 @@ public class JavaProjectHandler implements IProjectHandler {
* {@inheritDoc}
*/
public IFolder[] getBinFolders(IUnoidlProject pUnoidlProject) {
- ArrayList< IFolder > folders = new ArrayList<IFolder>();
-
+ ArrayList<IFolder> folders = new ArrayList<IFolder>();
+
IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
- IProject prj = workspace.getProject( pUnoidlProject.getName() );
- IJavaProject javaPrj = JavaCore.create( prj );
+ IProject prj = workspace.getProject(pUnoidlProject.getName());
+ IJavaProject javaPrj = JavaCore.create(prj);
try {
- folders.add( workspace.getFolder( javaPrj.getOutputLocation() ) );
-
+ folders.add(workspace.getFolder(javaPrj.getOutputLocation()));
+
IClasspathEntry[] entries = javaPrj.getRawClasspath();
for (IClasspathEntry entry : entries) {
- if ( entry.getEntryKind() == IClasspathEntry.CPE_SOURCE &&
- entry.getOutputLocation() != null ) {
- folders.add( workspace.getFolder( entry.getOutputLocation() ) );
+ if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getOutputLocation() != null) {
+ folders.add(workspace.getFolder(entry.getOutputLocation()));
}
}
- } catch ( JavaModelException e ) {
+ } catch (JavaModelException e) {
}
-
- return folders.toArray( new IFolder[folders.size()] );
+
+ return folders.toArray(new IFolder[folders.size()]);
}
-
- //--------------------------------------------- Jar finding private methods
-
+
+ // --------------------------------------------- Jar finding private methods
+
/**
* returns the path of all the kept jars contained in the folder pointed by path.
*
- * @param pOoo the OOo instance from which to get the jars
+ * @param pOoo
+ * the OOo instance from which to get the jars
* @return a vector of Path pointing to each jar.
*/
public static Vector<Path> findJarsFromPath(IOOo pOoo) {
Vector<Path> jarsPath = new Vector<Path>();
-
+
String[] paths = pOoo.getClassesPath();
for (String path : paths) {
Path folderPath = new Path(path);
File programFolder = folderPath.toFile();
-
+
String[] content = programFolder.list();
for (int i = 0, length = content.length; i < length; i++) {
String contenti = content[i];
if (isKeptJar(contenti)) {
- Path jariPath = new Path (
- path + "/" + contenti); //$NON-NLS-1$
+ Path jariPath = new Path(path + "/" + contenti); //$NON-NLS-1$
jarsPath.add(jariPath);
}
- }
+ }
}
-
+
return jarsPath;
}
-
+
/**
* Check if the specified jar file is one of those define in the KEPT_JARS constant.
*
- * @param pJarName name of the jar file to check
- * @return <code>true</code> if jarName is one of those defined in KEPT_JARS,
- * <code>false</code> otherwise.
+ * @param pJarName
+ * name of the jar file to check
+ * @return <code>true</code> if jarName is one of those defined in KEPT_JARS, <code>false</code> otherwise.
*/
private static boolean isKeptJar(String pJarName) {
-
+
int i = 0;
boolean isKept = false;
-
+
while (i < KEPT_JARS.length && !isKept) {
if (pJarName.equals(KEPT_JARS[i])) {
isKept = true;