incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ar...@apache.org
Subject svn commit: r1236486 [37/43] - in /incubator/ooo/devtools/netbeansintegration: ./ build/ build/public-package-jars/ javahelp/ javahelp/org/ javahelp/org/openoffice/ javahelp/org/openoffice/extensions/ javahelp/org/openoffice/extensions/docs/ javahelp/o...
Date Fri, 27 Jan 2012 01:29:58 GMT
Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/BackgroundIdlCompilation.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/BackgroundIdlCompilation.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/BackgroundIdlCompilation.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/BackgroundIdlCompilation.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,247 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: BackgroundIdlCompilation.java,v $
+ *
+ *  $Revision: 1.4 $
+ *
+ *  last change: $Author: sg $ $Date: 2009/01/08 11:24:20 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+package org.openoffice.extensions.util.listeners;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+import org.openide.filesystems.FileUtil;
+import org.openoffice.extensions.config.ConfigurationSettings;
+import org.openoffice.extensions.config.office.OpenOfficeLocation;
+import org.openoffice.extensions.util.LogWriter;
+import org.openoffice.extensions.config.office.PlatformInfo;
+import org.openoffice.extensions.util.ScriptExecutor;
+import sun.tools.jar.Main;
+
+/**
+ * Compile Idl files in the background and add the compiled jar file to
+ * the classpath of the project.
+ * @author sg128468
+ */
+public class BackgroundIdlCompilation extends Thread {
+
+    //sleep time in milliseconds
+    private static final int INITIAL_SLEEP_TIME = 500;
+    // number of intervals
+    private static final int SLEEP_INTERVALS = 10;
+    // static reference to compile class
+    static BackgroundIdlCompilation sm_idlCompile;
+
+    public static void compileInBackground(String[] allIdlFiles) {
+        // do nothing when no files exist
+        if (allIdlFiles == null || allIdlFiles.length == 0) return; // TODO: remove eventually created dirs?
+        if (sm_idlCompile == null || !sm_idlCompile.isAlive()) {
+            sm_idlCompile = new BackgroundIdlCompilation(allIdlFiles);
+        } else {
+            sm_idlCompile.halt();
+            // wait for thread to die
+            // TODO: evaluate if this is a bottleneck...
+            while (sm_idlCompile.isAlive()) {
+                try {
+                    Thread.sleep(50);
+                } catch (InterruptedException ex) {
+                    LogWriter.getLogWriter().printStackTrace(ex);
+                }
+            }
+            sm_idlCompile = new BackgroundIdlCompilation(allIdlFiles);
+        }
+        sm_idlCompile.start();
+    }
+    private String[] m_idlFiles;
+    private boolean m_Halt;
+
+    public BackgroundIdlCompilation(String[] idlFiles) {
+        m_Halt = false;
+        m_idlFiles = idlFiles;
+    }
+
+    @Override
+    public void run() {
+        // simple idea: to avoid compiling too often, wait for five seconds; if
+        // idl file is changed again, start new
+        for (int i = 0; !m_Halt && i < SLEEP_INTERVALS; i++) {
+            try {
+                sleep(BackgroundIdlCompilation.INITIAL_SLEEP_TIME);
+            } catch (InterruptedException e) {
+                LogWriter.getLogWriter().printStackTrace(e);
+            }
+        }
+
+        try {
+            // ok, five seconds passed and nothing happened, start compilation.
+            ConfigurationSettings settings = ConfigurationSettings.getSettings();
+            String sdkPath = settings.getValue(ConfigurationSettings.KEY_SDK_INSTALLATION);
+            String sdkBinPath = sdkPath.concat(File.separator).concat(PlatformInfo.getPlatformBinDir()).concat(File.separator).concat("bin"); // NOI18N
+            String soProgram = settings.getValue(ConfigurationSettings.KEY_OFFICE_INSTALLATION).concat(File.separator).concat(PlatformInfo.getOfficeProgramDir());
+            String outPath = System.getProperty("java.io.tmpdir");
+            String buildDir = "build".concat(OOoListenerHelper.getProjectName());
+
+            String soPath = "";
+            String[] typesRdbPath = null;
+            OpenOfficeLocation loc = OpenOfficeLocation.getOpenOfficeLocation();
+            if (loc != null) {
+                soPath = loc.getPathVariable();
+                typesRdbPath = loc.getUnoTypesPath();
+            }
+            else {
+                typesRdbPath = new String[0];
+            }
+            
+            Map<String,String> p = new HashMap<String,String>(5);
+            p.put(ScriptExecutor.PATH, soPath);
+            p.put(ScriptExecutor.LD_LIBRARY_PATH, soPath);
+            p.put(ScriptExecutor.DYLD_LIBRARY_PATH, soPath);
+            p.put(ScriptExecutor.TEMP, System.getProperty("java.io.tmpdir"));
+            p.put(ScriptExecutor.TMP, System.getProperty("java.io.tmpdir"));
+            // tempdir is needed for idlc
+            ScriptExecutor.setEnv(p);
+
+            // idlc
+            File projectDir = FileUtil.toFile(OOoListenerHelper.getProjectDir());
+            String projDir = projectDir.getCanonicalPath();
+            String srcIdlPath = projDir.concat(File.separator).concat("src"); // NOI18N
+            String sdkIdlIncludes = sdkPath.concat(File.separator).concat("idl").concat(";").concat(srcIdlPath); // NOI18N
+            String urdOutPath = outPath.concat(File.separator).concat(buildDir).concat(File.separator).concat("urd"); // NOI18N
+            String[] command = new String[3 + m_idlFiles.length];
+            command[0] = sdkBinPath.concat(File.separator).concat("idlc"); // NOI18N
+            command[1] = "-I".concat(sdkIdlIncludes); // NOI18N
+            command[2] = "-O".concat(urdOutPath); // NOI18N
+            for (int i = 0; i < m_idlFiles.length; i++) {
+                command[3 + i] = m_idlFiles[i];
+                // afterwards, path to idl file is not needed anymore
+                m_idlFiles[i] = m_idlFiles[i].substring(m_idlFiles[i].lastIndexOf(File.separatorChar) + 1);
+            }
+
+            // halt now and exit if idl file was changed
+            if (m_Halt) {
+                return;
+            }  // not sure if this is a good idea like this.
+
+            ScriptExecutor.executeScript(command, projectDir); // NOI18N
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, ScriptExecutor.getOutput());
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_CRITICAL, ScriptExecutor.getErrors());
+
+            // halt now and exit if idl file was changed
+            if (m_Halt) {
+                return;
+            }  // not sure if this is a good idea like this.
+
+            // regmerge
+            File f = new File(outPath.concat(File.separator).concat(buildDir).concat(File.separator).concat("rdb")); // NOI18N
+            f.mkdirs();
+            String rdbPath = outPath.concat(File.separator).concat("build").concat(File.separator).concat("idl").concat(File.separator).concat("rdb").concat(File.separator).concat("types.rdb"); // NOI18N
+            command = new String[3 + m_idlFiles.length];
+            command[0] = sdkBinPath.concat(File.separator).concat("regmerge"); // NOI18N
+            command[1] = rdbPath;
+            command[2] = "/UCR"; // NOI18N
+            for (int i = 0; i < m_idlFiles.length; i++) {
+                command[3 + i] = urdOutPath.concat(File.separator).concat(m_idlFiles[i]).replaceAll("\\.idl", ".urd"); // NOI18N
+            }
+
+            // halt now and exit if idl file was changed
+            if (m_Halt) {
+                return;
+            }  // not sure if this is a good idea like this.
+
+            ScriptExecutor.executeScript(command);
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, ScriptExecutor.getOutput());
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_CRITICAL, ScriptExecutor.getErrors());
+
+            // halt now and exit if idl file was changed
+            if (m_Halt) {
+                return;
+            }  // not sure if this is a good idea like this.
+
+            // javamaker
+            String classOutPath = outPath.concat(File.separator).concat(buildDir).concat(File.separator).concat("class");
+            f = new File(classOutPath);
+            f.mkdirs();
+            command = new String[4 + typesRdbPath.length];
+            command[0] = sdkBinPath.concat(File.separator).concat("javamaker"); // NOI18N
+            command[1] = "-BUCR"; // NOI18N
+            command[2] = "-O".concat(projDir).concat(File.separator).concat(classOutPath);
+            command[3] = rdbPath;
+            for (int i = 0; i < typesRdbPath.length; i++) {
+                command[4] = "-X ".concat(typesRdbPath[i]);
+            }
+
+            // halt now and exit if idl file was changed
+            if (m_Halt) {
+                return;
+            }  // not sure if this is a good idea like this.
+
+            ScriptExecutor.executeScript(command);
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, ScriptExecutor.getOutput());
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_CRITICAL, ScriptExecutor.getErrors());
+
+            // halt now and exit if idl file was changed
+            if (m_Halt) {
+                return;
+            }  // not sure if this is a good idea like this.
+
+            // make a jar
+            PrintStream outStream = new PrintStream(LogWriter.getLogWriter().getLogStream(LogWriter.LEVEL_INFO));
+            PrintStream errStream = new PrintStream(LogWriter.getLogWriter().getLogStream(LogWriter.LEVEL_CRITICAL));
+            Main jartool = new Main(outStream, errStream, "jar");
+            
+            File tmpJarFile = File.createTempFile("types", "jar", new File(classOutPath));
+            tmpJarFile.deleteOnExit();
+            command = new String[4];
+            command[0] = "cf";
+            command[1] = tmpJarFile.getCanonicalPath();
+            command[2] = "-C ".concat(projDir).concat(File.separator).concat("build").concat(File.separator).concat("class");
+            command[3] = ".";
+
+            // halt now and exit if idl file was changed
+            if (m_Halt) {
+                return;
+            }  // not sure if this is a good idea like this.
+
+            jartool.run(command);
+
+        } catch (IOException ex) {
+            LogWriter.getLogWriter().printStackTrace(ex);
+        }
+    }
+
+    /**
+     * stop the thread
+     */
+    public void halt() {
+        m_Halt = true;
+    }
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/DirectoryListener.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/DirectoryListener.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/DirectoryListener.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/DirectoryListener.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: DirectoryListener.java,v $
+ *
+ *  $Revision: 1.2 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/10/07 08:59:26 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+
+package org.openoffice.extensions.util.listeners;
+
+import org.netbeans.api.project.Project;
+import org.openide.filesystems.FileChangeAdapter;
+import org.openide.filesystems.FileEvent;
+import org.openide.filesystems.FileObject;
+import org.openoffice.extensions.util.LogWriter;
+
+/**
+ *
+ * @author sg128468
+ */
+public class DirectoryListener extends FileChangeAdapter {
+    
+    // directories whose changes are listened to
+    // TODO: think about offering arrays here: these should not be too big
+    String[] m_dirNames;
+    private String m_fileName;
+    private DirectoryListener m_parent;
+    private FileObject m_fileObject;
+    private Project m_currentProject;
+    private FileObject m_currentDir;
+    private DirectoryListener[] m_subListeners;
+    private IdlTypesListener m_subFileListener;
+    
+    public DirectoryListener(DirectoryListener parent, FileObject currentDir, String[] dirNames, String fileName) {
+        this(parent, null, currentDir, dirNames, fileName);
+    }
+    
+    public DirectoryListener(Project currentProject, String[] dirNames, String fileName) {
+        this(null, currentProject, currentProject.getProjectDirectory(), dirNames, fileName);
+    }
+    
+    private DirectoryListener(DirectoryListener parent, Project currentProject, FileObject currentDir, String[] dirNames, String fileName) {
+        m_parent = parent; // may be null!
+        m_currentProject = currentProject; // may be null!
+        // just make sure: parent and project must not be both null!
+        if (m_parent == null && m_currentProject == null) {
+            throw new IllegalArgumentException("Parent and Project parameters are both null."); // NOI18N
+        }
+        m_currentDir = currentDir;
+        m_dirNames = dirNames;
+        m_fileName = fileName;
+        m_subListeners = new DirectoryListener[dirNames.length];
+        LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### DirectoryListener ctor");
+        // initialize the stuff...
+        for (int i = 0; i < m_dirNames.length; i++) {
+            FileObject subDir = m_currentDir.getFileObject(m_dirNames[i]);
+            if (subDir != null && subDir.isValid() && subDir.isFolder()) {
+                m_subListeners[i] = new DirectoryListener(this, subDir, m_dirNames, m_fileName);
+            }
+        }
+        // TODO: stop pretending that this is a general class?
+        if (m_currentDir != null && m_fileName != null) {
+            m_fileObject = m_currentDir.getFileObject(m_fileName);
+            if (m_fileObject != null && m_fileObject.isValid() && m_fileObject.isData()) {
+                m_subFileListener = new IdlTypesListener(this);
+                m_fileObject.addFileChangeListener(m_subFileListener);
+            }
+            m_currentDir.addFileChangeListener(this);
+        }
+    }
+    
+    public void removeListenerRecursively() {
+        LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### DirectoryListener remove");
+        for (int i = 0; i < m_subListeners.length; i++) {
+            if(m_subListeners[i] != null) {
+                m_subListeners[i].removeListenerRecursively();
+            }
+        }
+        if (m_fileObject != null && m_fileObject.isValid() && m_subFileListener !=  null) {
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### IDL_type listener remove");
+            m_fileObject.removeFileChangeListener(m_subFileListener);
+        }
+        m_currentDir.removeFileChangeListener(this);
+    }
+    
+    @Override
+    public void fileDataCreated(FileEvent event) {
+        String name = event.getFile().getNameExt();
+        LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### File Data created " + name);
+        if (name.equals(m_fileName)) {
+            // TODO: filename is selectable, but listener is hard coded IDL_types.jar listener...
+            m_subFileListener = new IdlTypesListener(this);
+            event.getFile().addFileChangeListener(m_subFileListener);
+        }
+    }
+
+    @Override
+    public void fileFolderCreated(FileEvent event) {
+        FileObject newDir = event.getFile();
+        String name = newDir.getName();
+        LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### File Folder created " + name);
+        for (int i = 0; i < m_dirNames.length; i++) {
+            if (name.equals(m_dirNames[i])) {
+                event.getFile().addFileChangeListener(new DirectoryListener(this, newDir, m_dirNames, m_fileName));
+            }
+        }
+    }
+    
+    protected Project getProject() {
+        if (m_currentProject == null) {
+            return m_parent.getProject();
+        }
+        return m_currentProject;
+    }
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/IdlFileListener.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/IdlFileListener.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/IdlFileListener.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/IdlFileListener.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: IdlFileListener.java,v $
+ *
+ *  $Revision: 1.1 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/04/28 11:23:44 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+
+package org.openoffice.extensions.util.listeners;
+
+import java.io.File;
+import java.io.IOException;
+import org.openide.filesystems.FileAttributeEvent;
+import org.openide.filesystems.FileChangeAdapter;
+import org.openide.filesystems.FileEvent;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileRenameEvent;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+import org.openoffice.extensions.util.LogWriter;
+
+/**
+ *
+ * @author sg128468
+ */
+public class IdlFileListener extends FileChangeAdapter {
+
+    private static String[] sm_idlFiles = new String[0]; // TODO: evaluate usage of container
+
+    static void addIdlFile(String idlFileName) {
+        synchronized (sm_idlFiles) {
+            String[] keepFiles = new String[sm_idlFiles.length + 1];
+            for (int i = 0; i < sm_idlFiles.length; i++) {
+                keepFiles[i] = sm_idlFiles[i];
+                // file already there: do not add again
+                if (idlFileName.equals(sm_idlFiles[i]))
+                    return;
+            }
+            keepFiles[sm_idlFiles.length] = idlFileName;
+            sm_idlFiles = keepFiles;
+        }
+    }
+    
+    static void removeIdlFile(String idlFileName) {
+        synchronized(sm_idlFiles) {
+            String[] keepFiles = new String[sm_idlFiles.length - 1];
+            int j = 0;
+            for (int i = 0; i < keepFiles.length; i++) {
+                if (sm_idlFiles[i].equals(idlFileName))
+                    j = 1;
+                else
+                    keepFiles[i] = sm_idlFiles[i + j];
+            }
+            // file not there: do not remove
+            if (j == 0) return;
+            sm_idlFiles = keepFiles;
+        }
+    }
+    
+    /**
+     * get idl files for background compilation: do not return a reference
+     * but a clone.
+     * @return
+     */
+    public static void compileIdlFiles() { 
+        synchronized (sm_idlFiles) {
+            BackgroundIdlCompilation.compileInBackground(sm_idlFiles);
+        }
+    }
+    
+    public IdlFileListener(FileObject file) {
+        File f = FileUtil.toFile(file);
+        if (f.exists()) {
+            try {
+                addIdlFile(f.getCanonicalPath());
+            } catch (IOException ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            }
+        }
+    }
+    
+    @Override
+    public void fileChanged(FileEvent event) {
+        try {
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### changed thrown");
+            String name = FileUtil.toFile(event.getFile()).getCanonicalPath();
+            addIdlFile(name);
+            compileIdlFiles();
+        } catch (IOException ex) {
+            LogWriter.getLogWriter().printStackTrace(ex);
+        }
+    }
+
+    @Override
+    public void fileDeleted(FileEvent event) {
+        try {
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### deleted thrown");
+            String name = FileUtil.toFile(event.getFile()).getCanonicalPath();
+            removeIdlFile(name);
+            compileIdlFiles();
+        } catch (IOException ex) {
+            LogWriter.getLogWriter().printStackTrace(ex);
+        }
+    }
+
+    @Override
+    public void fileRenamed(FileRenameEvent event) {
+        try {
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### renamed thrown");
+            String oldName = event.getName();
+            removeIdlFile(oldName);
+            String name = FileUtil.toFile(event.getFile()).getCanonicalPath();
+            addIdlFile(name);
+            compileIdlFiles();
+        } catch (IOException ex) {
+            LogWriter.getLogWriter().printStackTrace(ex);
+        }
+    }
+
+    @Override
+    public void fileAttributeChanged(FileAttributeEvent event) {
+        LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### attribute changed thrown");
+    }
+
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/IdlTypesListener.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/IdlTypesListener.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/IdlTypesListener.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/IdlTypesListener.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: IdlTypesListener.java,v $
+ *
+ *  $Revision: 1.2 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/10/07 08:59:26 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+
+package org.openoffice.extensions.util.listeners;
+
+import java.io.IOException;
+import org.netbeans.api.project.Project;
+import org.openide.filesystems.FileAttributeEvent;
+import org.openide.filesystems.FileChangeAdapter;
+import org.openide.filesystems.FileEvent;
+import org.openide.filesystems.FileRenameEvent;
+import org.openide.filesystems.FileUtil;
+import org.openoffice.extensions.util.ClasspathUpdater;
+import org.openoffice.extensions.util.LogWriter;
+
+/**
+ *
+ * @author sg128468
+ */
+public class IdlTypesListener extends FileChangeAdapter {
+
+    private DirectoryListener m_parent;
+    
+    public IdlTypesListener(DirectoryListener parent) {
+        LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### IdlTypesListener ctor");
+        // only react to create and delete: just notice the other stuff because I am curious
+        m_parent = parent;
+        ClasspathUpdater.extendJavaClasspathWithIdlTypes(getProject());
+    }
+    
+    private Project getProject() {
+        return m_parent.getProject();
+/*        FileObject parent = subDir.getParent();
+        if (parent == null) {
+            // gone to root without finding nbproject?
+            // return original dir and hope for the best
+            return subDir;
+        }
+        // nbproject should exist only once
+        if (!parent.getFileObject("nbproject").isValid()) {
+            return getProjectDir(parent);
+        }
+        return parent; */
+    }
+    
+    @Override
+    public void fileChanged(FileEvent event) {
+        try {
+            String name = FileUtil.toFile(event.getFile()).getCanonicalPath();
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### changed thrown: " + name);
+            ClasspathUpdater.extendJavaClasspathWithIdlTypes(getProject());
+        } catch (IOException ex) {
+            LogWriter.getLogWriter().printStackTrace(ex);
+        }
+    }
+
+    @Override
+    public void fileDeleted(FileEvent event) {
+        try {
+            String name = FileUtil.toFile(event.getFile()).getCanonicalPath();
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### deleted thrown: " + name);
+            ClasspathUpdater.removeIdlTypesFromJavaClasspath(getProject());
+        } catch (IOException ex) {
+            LogWriter.getLogWriter().printStackTrace(ex);
+        }
+    }
+
+    @Override
+    public void fileRenamed(FileRenameEvent event) {
+        try {
+            String oldName = event.getName();
+            String name = FileUtil.toFile(event.getFile()).getCanonicalPath();
+            LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### renamed thrown: " + oldName + " to " + name);
+        } catch (IOException ex) {
+            LogWriter.getLogWriter().printStackTrace(ex);
+        }
+    }
+
+    @Override
+    public void fileAttributeChanged(FileAttributeEvent event) {
+        String name = event.getName();
+        LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### attribute changed thrown " + name);
+    }
+    
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/OOoListenerHelper.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/OOoListenerHelper.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/OOoListenerHelper.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/listeners/OOoListenerHelper.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: OOoListenerHelper.java,v $
+ *
+ *  $Revision: 1.1 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/04/28 11:23:44 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+
+package org.openoffice.extensions.util.listeners;
+
+import java.io.File;
+import java.io.IOException;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openoffice.extensions.util.LogWriter;
+
+/**
+ *
+ * @author sg128468
+ */
+public class OOoListenerHelper {
+
+    private static FileObject ms_ProjectDir;
+    // not really the name, but the name of the top directory
+    private static String ms_ProjectName;
+            
+    public static void addOOoListeners(FileObject projectDir) {
+        ms_ProjectDir = projectDir;
+        // TODO: make this more dynamic if src is not the source dir?
+        FileObject sourceDir = projectDir.getFileObject("src");
+        addListenersRecursively(sourceDir);
+        try {
+            String path = FileUtil.toFile(projectDir).getCanonicalPath();
+            ms_ProjectName = path.substring(path.lastIndexOf(File.separatorChar) + 1);
+        } catch (IOException ex) {
+            LogWriter.getLogWriter().printStackTrace(ex);
+            ms_ProjectName = "default";
+        }
+        
+    }
+
+    public static FileObject getProjectDir() { return ms_ProjectDir; }
+    
+    public static String getProjectName() { return ms_ProjectName; }
+
+    private static void addListenersRecursively(FileObject startDir) {
+//        startDir.addFileChangeListener(new DirectoryListener());
+//        FileObject[] object = startDir.getChildren();
+//        for (int i = 0; i < object.length; i++) {
+//            if (object[i].isData() && object[i].getExt().equals("idl"))
+//                object[i].addFileChangeListener(new IdlFileListener(object[i]));
+//            if (object[i].isFolder())
+//                addListenersRecursively(object[i]);
+//        }
+    }
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/DummyHook.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/DummyHook.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/DummyHook.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/DummyHook.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: DummyHook.java,v $
+ *
+ *  $Revision: 1.1 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/10/07 08:59:38 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+package org.openoffice.extensions.util.lookup;
+
+import org.netbeans.api.project.Project;
+
+/**
+ *
+ * @author sg128468
+ */
+public class DummyHook {
+
+    public DummyHook(Project prj) {
+    }
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/LookupProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/LookupProviderImpl.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/LookupProviderImpl.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/LookupProviderImpl.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: LookupProviderImpl.java,v $
+ *
+ *  $Revision: 1.3 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/10/07 08:59:38 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+
+package org.openoffice.extensions.util.lookup;
+
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.LookupProvider;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openoffice.extensions.util.ProjectTypeHelper;
+
+/**
+ *
+ * @author sg128468
+ */
+public class LookupProviderImpl implements LookupProvider {
+
+    public Lookup createAdditionalLookup(Lookup lookup) {
+        Project prj = lookup.lookup(Project.class);
+        if (prj != null && ProjectTypeHelper.isExtensionProject(prj.getProjectDirectory())) {
+            return Lookups.fixed(new Object[]{new OOoProjectHook(prj), new DummyHook(prj)});
+        }
+        else {
+            return Lookups.fixed();
+        }
+    }
+
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/OOoProjectHook.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/OOoProjectHook.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/OOoProjectHook.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/lookup/OOoProjectHook.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: OOoProjectHook.java,v $
+ *
+ *  $Revision: 1.1 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/10/07 08:59:38 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+package org.openoffice.extensions.util.lookup;
+
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ui.ProjectOpenedHook;
+import org.openide.filesystems.FileObject;
+import org.openoffice.extensions.projecttemplates.actions.ProjectVersion;
+import org.openoffice.extensions.util.LogWriter;
+import org.openoffice.extensions.util.ProjectTypeHelper;
+import org.openoffice.extensions.util.listeners.DirectoryListener;
+
+/**
+ *
+ * @author sg128468
+ */
+public class OOoProjectHook extends ProjectOpenedHook {
+    
+    private Project m_prj;
+    private DirectoryListener m_listener;
+    
+    public OOoProjectHook(Project prj) {
+        this.m_prj = prj;
+    }
+
+
+    @Override
+    protected void projectOpened() {
+        // should listener be static to avoid adding more than one: no, remove when closing
+        if (m_prj != null && ProjectTypeHelper.isExtensionProject(m_prj.getProjectDirectory())) {
+            // not sure if good idea, but let listener do all the work recursively
+            final String IDL_JAR_NAME = (String)ProjectTypeHelper.getObjectFromUnoProperties(m_prj, 
+                    "idl_types.jar"); // NOI18N
+            m_listener = new DirectoryListener(m_prj,
+                    new String[]{"dist"}, 
+                    IDL_JAR_NAME);
+            // update project when necessary
+            try {
+                ProjectVersion.updateProjectFiles(m_prj.getProjectDirectory());
+            }
+            catch (Exception ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            }
+        }
+    }
+
+    @Override
+    protected void projectClosed() {
+        // remove listeners...
+        if (m_prj != null && m_listener != null) {
+            if (ProjectTypeHelper.isExtensionProject(m_prj.getProjectDirectory())) {
+                m_listener.removeListenerRecursively();
+                m_listener = null;
+            }
+        }
+    }
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/Bundle.properties
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/Bundle.properties?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/Bundle.properties (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/Bundle.properties Fri Jan 27 01:29:33 2012
@@ -0,0 +1,5 @@
+OOoCustomizerProvider.TopCategory.Name=OpenOffice.org
+OOoCustomizerProvider.DisplayCategory.Name=Display
+OOoCustomizerProvider.VersionCategory.Name=Version
+# NOI18N
+ImportantOOoFilesFolderNode.OXT.Name=OXT
\ No newline at end of file

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantFilesFolderChildren.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantFilesFolderChildren.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantFilesFolderChildren.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantFilesFolderChildren.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: ImportantFilesFolderChildren.java,v $
+ *
+ *  $Revision: 1.3 $
+ *
+ *  last change: $Author: sg $ $Date: 2009/07/10 08:32:42 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+package org.openoffice.extensions.util.nodes;
+
+import java.util.Vector;
+import org.openide.filesystems.FileChangeAdapter;
+import org.openide.filesystems.FileEvent;
+import org.openide.filesystems.FileObject;
+import org.openide.loaders.DataObjectNotFoundException;
+import org.openide.nodes.Children;
+import org.openide.nodes.Node;
+import org.openoffice.extensions.util.LogWriter;
+
+/**
+ *
+ * @author sg128468
+ */
+public class ImportantFilesFolderChildren extends Children.Keys<String[]> {
+
+    private FileObject m_projDir;
+    // react on extensions to keep it simple: let createNodes(String[] subdirs) decide what is displayed
+    private String[] m_fileExtensionList = new String[] {
+            "xml",
+            "xcu",
+            "xcs",
+        };
+    
+    public ImportantFilesFolderChildren(FileObject projDir) {
+        this.m_projDir = projDir;
+        ImportantFolderListener listener = new ImportantFolderListener();
+        m_projDir.addFileChangeListener(listener);
+        FileObject sourceDir = m_projDir.getFileObject("src"); // TODO: replace src with better stuff
+        if (sourceDir != null) {
+            // get notified of creations in source dir: description.xml, uno-extension-manifest.xml, xcu, xcs files maybe
+            ImportantFileListener fListener = new ImportantFileListener();
+            sourceDir.addFileChangeListener(fListener);
+        }
+    }
+    
+    @Override
+    protected Node[] createNodes(String[] subdirs) {
+        Vector<ImportantOOoFilesNode> myNodes = new Vector<ImportantOOoFilesNode>();
+        // these are not really subdirs, but also files: description.xml and uno-extension-manifest.xml
+        for (int i = 0; i < subdirs.length; i++) {
+            FileObject subdir = m_projDir.getFileObject(subdirs[i]);
+            if (subdir != null && !subdir.getName().startsWith(".")) {
+                try {
+                    // add listener for files additionally, because delete and create will not be recognized else
+                    ImportantOOoFilesNode node = new ImportantOOoFilesNode(subdir);
+                    myNodes.add(node);
+                } catch (DataObjectNotFoundException ex) {
+                    LogWriter.getLogWriter().printStackTrace(ex);
+                }
+            }
+        }
+        return myNodes.toArray(new ImportantOOoFilesNode[myNodes.size()]);
+    }
+
+    @Override
+    protected void addNotify() {
+        Node node = getNode();
+        String[] subdirs = node.getLookup().lookup(String[].class);
+        String[][] keys = new String[1][subdirs.length];
+        for (int i = 0; i < keys[0].length; i++) {
+            keys[0][i] = subdirs[i];
+        }
+        this.setKeys(keys);
+    }
+
+    /**
+     * Listener for updateing this node when a directory is created or deleted.
+     * 
+     */
+    private class ImportantFolderListener extends FileChangeAdapter {
+        @Override
+        public void fileFolderCreated(FileEvent event) {
+            // TODO: Should listener check for the directory names? this reacts on all
+            addNotify();
+        }
+        @Override
+        public void fileDeleted(FileEvent arg0) {
+            // TODO: Should listener check for the directory names? this reacts on all
+            addNotify();
+        }
+    }
+
+    /**
+     * Listener for updateing this node when a file is created or deleted.
+     * 
+     */
+    private class ImportantFileListener extends FileChangeAdapter {
+        @Override
+        public void fileDataCreated(FileEvent arg0) {
+            // TODO: Should listener check for the directory names? this reacts on all
+            FileObject file = arg0.getFile();
+            if (file != null) {
+                String ext = file.getExt();
+                for (int i = 0; i < m_fileExtensionList.length; i++) {
+                    String fileExt = m_fileExtensionList[i];
+                    if (ext.equals(fileExt)) {
+                        addNotify();
+                    }
+                }
+            }
+        }
+        @Override
+        public void fileDeleted(FileEvent arg0) {
+            // TODO: Should listener check for the file names? this reacts on all
+            addNotify();
+        }
+    }
+
+    /**
+     * class to get notified when a file is deleted. Only needed for nodes where
+     * the file is recognized, not the folder it is located in. 
+     *
+    private class ImportantFileNodeListener implements NodeListener {
+        
+        public void childrenAdded(NodeMemberEvent arg0) { //ignore event
+        }
+        public void childrenRemoved(NodeMemberEvent arg0) { //ignore event
+        }
+        public void childrenReordered(NodeReorderEvent arg0) { //ignore event
+        }
+        public void nodeDestroyed(NodeEvent arg0) {
+            // update view on OXT folder
+            addNotify();
+        }
+        public void propertyChange(PropertyChangeEvent evt) { //ignore event
+        }
+        
+    }*/
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantFilesNodeFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantFilesNodeFactoryImpl.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantFilesNodeFactoryImpl.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantFilesNodeFactoryImpl.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: ImportantFilesNodeFactoryImpl.java,v $
+ *
+ *  $Revision: 1.1 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/10/07 10:32:07 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+package org.openoffice.extensions.util.nodes;
+
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.Vector;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ui.support.NodeFactory;
+import org.netbeans.spi.project.ui.support.NodeFactorySupport;
+import org.netbeans.spi.project.ui.support.NodeList;
+import org.openide.filesystems.FileObject;
+import org.openoffice.extensions.util.ProjectTypeHelper;
+import org.openoffice.extensions.util.lookup.DummyHook;
+
+/**
+ *
+ * @author sg128468
+ */
+public class ImportantFilesNodeFactoryImpl implements NodeFactory {
+
+    Project m_prj;
+    Properties m_props;
+    FileObject m_projectRoot;
+    
+    public NodeList<?> createNodes(Project prj) {
+        m_prj = prj;
+        //return a new node in the node list: only for our projects
+        DummyHook hook = m_prj.getLookup().lookup(DummyHook.class);
+        if (hook != null) {
+            m_projectRoot = m_prj.getProjectDirectory();
+            if (m_projectRoot != null) {
+                m_props = ProjectTypeHelper.getUnoProperties(m_projectRoot);
+                Vector<String> v = new Vector<String>();
+                String dir = m_props.getProperty("images.dir"); // NOI18N
+                if (dir != null) {
+                    v.add(dir);
+                }
+                dir = m_props.getProperty("help.dir"); // NOI18N
+                if (dir != null) {
+                    v.add(dir);
+                }
+                dir = m_props.getProperty("dialogs.dir"); // NOI18N
+                if (dir != null) {
+                    v.add(dir);
+                }
+                dir = m_props.getProperty("description.dir"); // NOI18N
+                if (dir != null) {
+                    v.add(dir);
+                }
+                dir = m_props.getProperty("licenses.dir"); // NOI18N
+                if (dir != null) {
+                    v.add(dir);
+                }
+                dir = m_props.getProperty("registry.dir"); // NOI18N
+                if (dir != null) {
+                    v.add(dir);
+                }
+                // TODO: change src with something better
+                v.add("src/description.xml");
+                v.add("src/uno-extension-manifest.xml");
+                // find xcu files recursively
+                FileObject sourceRoot = m_projectRoot.getFileObject("src");
+                if (sourceRoot != null) {
+                    Enumeration<? extends FileObject> dataFiles = sourceRoot.getData(true);
+                    int projectPathLength = m_projectRoot.getPath().length();
+                    while (dataFiles.hasMoreElements()) {
+                        FileObject cand = dataFiles.nextElement();
+                        String ext = cand.getExt();
+                        if (ext.equals("xcu") || ext.equals("xcs")) {
+                            String path = cand.getPath();
+                            String searchPath = path.substring(projectPathLength + 1);
+                            v.add(searchPath);
+                        }
+                    }
+                }
+                if (v.size() > 0) {
+                    ImportantOOoFilesFolderNode node = ImportantOOoFilesFolderNode.createNodeStructure(m_projectRoot, v);
+                    return NodeFactorySupport.fixedNodeList(node);
+                }
+            }
+        }
+
+        // return empty list
+        return NodeFactorySupport.fixedNodeList();        
+    }
+    
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantOOoFilesFolderNode.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantOOoFilesFolderNode.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantOOoFilesFolderNode.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantOOoFilesFolderNode.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: ImportantOOoFilesFolderNode.java,v $
+ *
+ *  $Revision: 1.2 $
+ *
+ *  last change: $Author: sg $ $Date: 2009/07/10 08:32:42 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+package org.openoffice.extensions.util.nodes;
+
+import java.awt.Image;
+import java.util.Vector;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataFolder;
+import org.openide.nodes.AbstractNode;
+import org.openide.nodes.Children;
+import org.openide.util.NbBundle;
+import org.openide.util.lookup.Lookups;
+
+/**
+ *
+ * @author sg128468
+ */
+public class ImportantOOoFilesFolderNode extends AbstractNode {
+
+    public static ImportantOOoFilesFolderNode createNodeStructure(FileObject projDir, Vector<String> subdirs) {
+        return new ImportantOOoFilesFolderNode(subdirs.toArray(new String[subdirs.size()]), new ImportantFilesFolderChildren(projDir));
+    }
+    
+    public ImportantOOoFilesFolderNode(String[] obj, Children children) {
+        super(children, Lookups.singleton(obj));
+    }
+
+    @Override
+    public String getDisplayName() {
+        return NbBundle.getMessage(ImportantOOoFilesFolderNode.class, "ImportantOOoFilesFolderNode.OXT.Name"); // NOI18N
+    }
+    
+    @Override
+    public Image getIcon(int type) {        
+        DataFolder root = DataFolder.findFolder(FileUtil.getConfigRoot());
+        Image original = root.getNodeDelegate().getIcon(type);
+        return original; //Utilities.mergeImages(original, smallImage, 7, 7);
+    }
+    
+    @Override
+    public Image getOpenedIcon (int type) {
+        DataFolder root = DataFolder.findFolder(FileUtil.getConfigRoot());
+        Image original = root.getNodeDelegate().getOpenedIcon(type);
+        return original; //Utilities.mergeImages(original, smallImage, 7, 7);
+    }
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantOOoFilesNode.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantOOoFilesNode.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantOOoFilesNode.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/ImportantOOoFilesNode.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: ImportantOOoFilesNode.java,v $
+ *
+ *  $Revision: 1.2 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/10/07 10:32:07 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+package org.openoffice.extensions.util.nodes;
+
+import java.awt.Image;
+import java.io.File;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataObject;
+import org.openide.loaders.DataObjectNotFoundException;
+import org.openide.nodes.FilterNode;
+import org.openide.nodes.Node;
+
+/**
+ *
+ * @author sg128468
+ */
+public class ImportantOOoFilesNode extends FilterNode {
+
+    private String m_DisplayName;
+    private Node m_OriginalNode;
+    
+    public ImportantOOoFilesNode(FileObject importantFileObject) throws DataObjectNotFoundException {
+        super(DataObject.find(importantFileObject).getNodeDelegate()); // NOI18N
+//        File object = FileUtil.toFile(importantFileObject);
+        m_DisplayName = importantFileObject.getNameExt();
+        m_OriginalNode = DataObject.find(importantFileObject).getNodeDelegate();
+    }
+
+    @Override
+    public String getDisplayName() {
+        return m_DisplayName;
+    }
+
+    @Override
+    public Image getIcon(int type) {
+        Image original = m_OriginalNode.getIcon(type);
+        return original; //Utilities.mergeImages(original, smallImage, 7, 7);
+    }
+
+    @Override
+    public Image getOpenedIcon(int type) {
+        Image original = m_OriginalNode.getOpenedIcon(type);
+        return original; //Utilities.mergeImages(original, smallImage, 7, 7);
+    }
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/OOoCustomizerProvider.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/OOoCustomizerProvider.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/OOoCustomizerProvider.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/nodes/OOoCustomizerProvider.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: OOoCustomizerProvider.java,v $
+ *
+ *  $Revision: 1.5 $
+ *
+ *  last change: $Author: sg $ $Date: 2009/01/08 11:26:24 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+package org.openoffice.extensions.util.nodes;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ui.support.ProjectCustomizer;
+import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category;
+import org.openide.filesystems.FileObject;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+import org.openoffice.extensions.projecttemplates.actions.panel.DataHandler;
+import org.openoffice.extensions.projecttemplates.actions.panel.PropsPanel;
+import org.openoffice.extensions.projecttemplates.actions.panel.VersionPanel;
+import org.openoffice.extensions.util.ProjectTypeHelper;
+
+/**
+ *
+ * @author sg128468
+ */
+public class OOoCustomizerProvider implements ProjectCustomizer.CompositeCategoryProvider, ActionListener {
+
+    private static final String DISPLAY = "Display"; // NOI18N
+    private static final String VERSION = "Version"; // NOI18N
+    private static final String OOO_PROPERTIES_NAME = "OOoPropsTop"; // NOI18N
+    
+    private DataHandler m_DataHandler;
+    
+    public ProjectCustomizer.Category createCategory(Lookup arg0) {
+        Project prj = arg0.lookup(Project.class);
+        if (ProjectTypeHelper.isExtensionProject(prj)) {
+            ProjectCustomizer.Category[] subEntries = new ProjectCustomizer.Category[]{
+                ProjectCustomizer.Category.create(DISPLAY, 
+                        NbBundle.getMessage(OOoCustomizerProvider.class, "OOoCustomizerProvider.DisplayCategory.Name"), // NOI18N 
+                        null, new ProjectCustomizer.Category[0]),
+                ProjectCustomizer.Category.create(VERSION, 
+                        NbBundle.getMessage(OOoCustomizerProvider.class, "OOoCustomizerProvider.VersionCategory.Name"), // NOI18N
+                        null, new ProjectCustomizer.Category[0])
+            };
+            ProjectCustomizer.Category toReturn = 
+                ProjectCustomizer.Category.create(OOO_PROPERTIES_NAME,
+                NbBundle.getMessage(OOoCustomizerProvider.class, "OOoCustomizerProvider.TopCategory.Name"), // NOI18N
+                null, subEntries);
+            toReturn.setStoreListener(this);
+            return toReturn;
+        }
+        return null;
+    }
+
+    public JComponent createComponent(Category arg0, Lookup arg1) {
+        Project prj = arg1.lookup(Project.class);
+        if (prj != null) {
+            FileObject m_ProjectDir= prj.getProjectDirectory();
+            if (m_ProjectDir != null) {
+                if (m_DataHandler == null || !m_DataHandler.getProjectDir().equals(m_ProjectDir)) {
+                    m_DataHandler = new DataHandler(m_ProjectDir);
+                }
+                if (arg0.getName().equals(DISPLAY))
+                    return new PropsPanel(m_DataHandler); 
+                if (arg0.getName().equals(VERSION))
+                    return new VersionPanel(m_DataHandler); 
+                
+            }
+        }
+        return new JLabel();
+    }
+
+    public static OOoCustomizerProvider create() {
+        return new OOoCustomizerProvider();
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        if (m_DataHandler != null) { // npe happened in Addin project
+            m_DataHandler.store();
+        }
+    }
+}

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/office/JarClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/office/JarClassLoader.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/office/JarClassLoader.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/office/JarClassLoader.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: JarClassLoader.java,v $
+ *
+ *  $Revision: 1.5 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/07/03 08:35:06 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+
+package org.openoffice.extensions.util.office;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileStateInvalidException;
+import org.openide.filesystems.FileUtil;
+import org.openoffice.extensions.util.LogWriter;
+
+/**
+ *
+ */
+public class JarClassLoader  {
+
+    // cache of loaded classes
+    private Hashtable<String, Class> cache;
+
+    // search paths for classes: either jars or directories
+    private static Vector<File> searchPaths;
+
+    private static URLClassLoader theJarClassLoader;
+    
+    /**
+     * Keep the class loader for a set of searchPaths, so use a factory
+     * method to make sure of that.
+     * @param searchPaths directorys or jar files that have to be added
+     * to the class path.
+     */
+    public static URLClassLoader getClassLoader(Vector<File> _searchPaths) {
+        if (theJarClassLoader == null || searchPaths == null || !searchPaths.equals(_searchPaths)) {
+            searchPaths = _searchPaths;
+            // now the class loader needs a new setup
+            theJarClassLoader = new URLClassLoader(makeUrlArrayFromPaths(), searchPaths.getClass().getClassLoader());
+        }
+        return theJarClassLoader;
+    }
+    
+    private static URL[] makeUrlArrayFromPaths() {
+        Vector<URL> urls = new Vector<URL>(searchPaths.size());
+        for (Iterator<File> it = searchPaths.iterator(); it.hasNext();) {
+            File path = it.next();
+            FileObject obj = FileUtil.toFileObject(path);
+            try {
+                urls.add(obj.getURL());
+            } catch (FileStateInvalidException ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            }
+        }
+        return urls.toArray(new URL[urls.size()]);
+    }
+    
+}
\ No newline at end of file

Added: incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/office/OfficeConnection.java
URL: http://svn.apache.org/viewvc/incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/office/OfficeConnection.java?rev=1236486&view=auto
==============================================================================
--- incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/office/OfficeConnection.java (added)
+++ incubator/ooo/devtools/netbeansintegration/src/org/openoffice/extensions/util/office/OfficeConnection.java Fri Jan 27 01:29:33 2012
@@ -0,0 +1,272 @@
+/*************************************************************************
+ *
+ *  OpenOffice.org - a multi-platform office productivity suite
+ *
+ *  $RCSfile: OfficeConnection.java,v $
+ *
+ *  $Revision: 1.9 $
+ *
+ *  last change: $Author: sg $ $Date: 2008/07/03 08:35:07 $
+ *
+ *  The Contents of this file are made available subject to
+ *  the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ *    GNU Lesser General Public License Version 2.1
+ *    =============================================
+ *    Copyright 2005 by Sun Microsystems, Inc.
+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *    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
+ *
+ ************************************************************************/
+
+package org.openoffice.extensions.util.office;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Vector;
+import org.openoffice.extensions.config.ConfigurationSettings;
+import org.openoffice.extensions.config.LibraryManager;
+import org.openoffice.extensions.config.office.OpenOfficeLocation;
+import org.openoffice.extensions.config.office.PlatformInfo;
+import org.openoffice.extensions.util.LogWriter;
+import org.openoffice.extensions.util.typebrowser.logic.UnoTypes;
+
+/**
+ *
+ * @author sg128468
+ */
+public class OfficeConnection {
+    
+    // TODO: this class was conceived with storing the Office and SDK location
+    // inside of a project - but it's stored in NB settings now. Review the class.
+    
+    private static OfficeConnection theOfficeConnection = null;
+    
+    public static Object getComponentContext() {
+        if (theOfficeConnection == null) {
+            theOfficeConnection = new OfficeConnection();
+        }
+        else {  // acess a different office?
+            ConfigurationSettings settings = ConfigurationSettings.getSettings();
+            String path = theOfficeConnection.mOfficeProgramPath;
+            String settingsPath = settings.getValue(ConfigurationSettings.KEY_OFFICE_INSTALLATION);
+            if (!path.equals(settingsPath)) {
+                theOfficeConnection.connect();
+            }
+        }
+        return theOfficeConnection.getContext();
+    }
+
+    public static void disposeContext() {
+        if (theOfficeConnection != null) {
+            theOfficeConnection.disconnect();
+        }
+    }
+    
+    public static ReflectionWrapper getReflectionWrapper() {
+        if (theOfficeConnection == null) {
+            getComponentContext();
+        }
+        return theOfficeConnection.mWrapper;
+    }
+    
+    String mUnorcName;
+    String mUnorcPath;
+    Object mxCtx;
+    String mOfficeProgramPath;
+    ReflectionWrapper mWrapper;
+    boolean mLocalConnection;    
+    boolean mFirstConnection;    
+    
+    /** Creates a new instance of OfficeConnection */
+    private OfficeConnection() {
+        mUnorcName = PlatformInfo.getUnorcName();
+        mFirstConnection = true;
+        connect();
+    }
+    
+    private Object getContext() {
+        if (mxCtx == null) {
+            connect();
+        }
+        else {  // check if Office still alive!
+            Object sManager = null;
+            Exception e = null;
+            try {
+                sManager = mWrapper.executeMethod(
+                    mxCtx, "getServiceManager", new Object[0]); // NOI18N
+            } catch (InvocationTargetException ex) {
+                e = ex;
+            } catch (NoSuchMethodException ex) {
+                e = ex;
+            } catch (IllegalAccessException ex) {
+                e = ex;
+            }
+            finally {
+                if (e != null) {
+                    String message = e.getMessage()!=null?e.getMessage():""; // NOI18N
+                    LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, 
+                        "Office not alive: ".concat(message)); // NOI18N
+                }
+                if (sManager == null) {
+                    setLocalVariablesNull();
+                    connect();
+                }
+            }
+        }
+        return mxCtx;
+    }
+    
+    private void connect() {
+        disconnect();  // avoid reconecting the office: dispose first
+        Vector<File> repository = createRepository();
+        mWrapper = new ReflectionWrapper(repository);
+        if (mLocalConnection || mFirstConnection) {
+            mFirstConnection = false;
+            java.util.Hashtable<String,String> htBootParams = new java.util.Hashtable<String,String>();
+
+            // bootstrap simple uno if that's possible
+            htBootParams.put("SYSBINDIR", mOfficeProgramPath); // NOI18N
+            try {
+                // unused code.
+//                String targetUnorcPath = System.getProperty("java.io.tmpdir") + File.separator + mUnorcName; // NOI18N
+//                if (TypeBrowser.hasTempRdbFileName()) {
+//                    // copy unorc and add the own rdb file
+//                    File source = new File(mUnorcPath);
+//                    File target = new File(targetUnorcPath);
+//                    try {
+//                        BufferedReader srcReader = new BufferedReader(new FileReader(source));
+//                        FileWriter trgtWriter = new FileWriter(target);
+//                        try {
+//                            char[] charBuff = new char[256];
+//                            while(srcReader.ready()) {
+//                                srcReader.read(charBuff);
+//                                trgtWriter.write(charBuff, 0, charBuff.length);
+//                            }
+//                        }
+//                        catch (java.io.IOException e) {
+//                            LogWriter.getLogWriter().printStackTrace(e);   
+//                        }
+//                        finally {
+//                            srcReader.close();
+//                            trgtWriter.close();
+//                        }
+//                    }
+//                    catch (java.io.IOException e) {
+//                        LogWriter.getLogWriter().printStackTrace(e);   
+//                    }
+//                }
+                mLocalConnection = false;
+                mxCtx = mWrapper.executeStaticMethod(
+                        "com.sun.star.comp.helper.Bootstrap", 
+                        "defaultBootstrap_InitialComponentContext", 
+                        new Object[]{mUnorcPath, htBootParams}); // NOI18N
+                if (mxCtx != null) {
+                    mLocalConnection = true;
+                }
+            } catch (NoSuchMethodException ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            } catch (IllegalAccessException ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            } catch (InvocationTargetException ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            } catch (ClassNotFoundException ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            }
+        }    
+        for (int i=0; mxCtx == null && i<10; i++) { // if bootstrapping of a single uno does not work we boot an Office
+            try {
+                mxCtx = mWrapper.executeStaticMethod(
+                        "com.sun.star.comp.helper.Bootstrap", "bootstrap", null); // NOI18N
+            } catch (NoSuchMethodException ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            } catch (InvocationTargetException ex) {
+                LogWriter.getLogWriter().log(LogWriter.LEVEL_INFO, "### incvocation target"); // NOI18N
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException e) {
+                    LogWriter.getLogWriter().printStackTrace(e);
+                }
+            } catch (IllegalAccessException ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            } catch (ClassNotFoundException ex) {
+                LogWriter.getLogWriter().printStackTrace(ex);
+            }
+        }
+    }
+    
+    private Vector<File> createRepository() {
+        ConfigurationSettings settings = ConfigurationSettings.getSettings();
+        String officeInstallation = settings.getValue(ConfigurationSettings.KEY_OFFICE_INSTALLATION);
+        mOfficeProgramPath = officeInstallation.concat(File.separator).concat(PlatformInfo.getOfficeProgramDir());
+                
+        Vector<File> repository = new Vector<File>();
+        // add program path, so resource for soffice binary is found
+        repository.add(new File(mOfficeProgramPath));
+        OpenOfficeLocation loc = OpenOfficeLocation.getOpenOfficeLocation();
+        if (loc != null) {
+            mUnorcPath = loc.getUnorcPath().concat(File.separator).concat(mUnorcName);
+            // add juh, jurt, java_uno, jut, unoil, ridl
+            for (int i = 0; i < LibraryManager.JAR_LIBRARIES_ESSENTIAL.length; i++) {
+                String jarName = LibraryManager.JAR_LIBRARIES_ESSENTIAL[i];
+                repository.add(new File(loc.getFullPathForJar(jarName)));
+            }
+        }
+        return repository;
+    }
+
+    private void setLocalVariablesNull() {
+        mxCtx = null;
+        mOfficeProgramPath = ""; // NOI18N
+        mWrapper = null;
+    }
+    
+    private void disconnect() {
+        if (mLocalConnection) {
+            setLocalVariablesNull();
+        }
+        else {
+            if (mxCtx != null) {
+                try {
+                    Object xMgr = mWrapper.executeMethod(mxCtx, "getServiceManager", new Object[0]); // NOI18N
+                    Class classType = mWrapper.forName("com.sun.star.uno.XComponentContext"); // NOI18N
+                    Object desk = mWrapper.executeMethod(xMgr, "createInstanceWithContext",  // NOI18N
+                            new Object[]{"com.sun.star.frame.Desktop", mxCtx}, // NOI18N
+                            new Class[]{String.class, classType});
+
+                    classType = mWrapper.forName("com.sun.star.frame.XDesktop"); // NOI18N
+                    Object aDesktop = mWrapper.executeStaticMethod("com.sun.star.uno.AnyConverter", "toObject", new Object[]{classType, desk}); // NOI18N
+                    mWrapper.executeMethod(aDesktop, "terminate", null); // NOI18N
+                } catch (InvocationTargetException ex) {
+                    LogWriter.getLogWriter().printStackTrace(ex);
+                } catch (IllegalAccessException ex) {
+                    LogWriter.getLogWriter().printStackTrace(ex);
+                } catch (NoSuchMethodException ex) {
+                    LogWriter.getLogWriter().printStackTrace(ex);
+                } catch (ClassNotFoundException ex) {
+                    LogWriter.getLogWriter().printStackTrace(ex);
+                }
+                finally {  // reset all variables
+                    setLocalVariablesNull();
+                }
+            }
+        }
+    }
+}



Mime
View raw message