diff --git a/scripting/java/org/openoffice/idesupport/OfficeDocument.java b/scripting/java/org/openoffice/idesupport/OfficeDocument.java index 397e3678aee1..6764aed988ff 100644 --- a/scripting/java/org/openoffice/idesupport/OfficeDocument.java +++ b/scripting/java/org/openoffice/idesupport/OfficeDocument.java @@ -2,9 +2,9 @@ * * $RCSfile: OfficeDocument.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: toconnor $ $Date: 2002-11-26 12:46:44 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,10 +63,9 @@ package org.openoffice.idesupport; import java.io.*; import java.util.zip.*; +import java.util.Vector; import java.util.Enumeration; import java.util.StringTokenizer; -import java.beans.PropertyVetoException; -import javax.naming.InvalidNameException; import org.openoffice.idesupport.filter.FileFilter; import org.openoffice.idesupport.filter.BinaryOnlyFilter; @@ -74,58 +73,44 @@ import org.openoffice.idesupport.zip.ParcelZipper; public class OfficeDocument { - public static final String PARCEL_PREFIX_DIR = "Scripts/java/"; - public static final String OFFICE_EXTENSIONS = "sxc,sxw"; + public static final String PARCEL_PREFIX_DIR = + ParcelZipper.PARCEL_PREFIX_DIR; + + public static final String[] OFFICE_EXTENSIONS = {".sxc" , ".sxw"}; public static final String ARCHIVE_TAG = "[PARCEL_FILE]"; public static final String OFFICE_PRODUCT_NAME = "OpenOffice.org"; private static ParcelZipper zipper = ParcelZipper.getParcelZipper(); - private File officeFile = null; - private String parcelName = null; - private String extension = null; + private File file = null; - public OfficeDocument(File officeFile) throws InvalidNameException + public OfficeDocument(File file) throws IllegalArgumentException { - this.officeFile = officeFile; - if( !checkIfOfficeDocument() ) - { - throw new InvalidNameException("This is not a valid " + + if (!file.exists() || file.isDirectory() || !isOfficeFile(file)) { + throw new IllegalArgumentException("This is not a valid " + OFFICE_PRODUCT_NAME + " document."); } + this.file = file; } - private boolean checkIfOfficeDocument() - { - if( officeFile.isDirectory() ) - { - return false; - } - String tmpName = officeFile.getName(); - if( tmpName.lastIndexOf(".") == 0 ) - { - return false; - } - this.extension = tmpName.substring(tmpName.lastIndexOf(".")+1); - if( (OFFICE_EXTENSIONS.indexOf(extension)==-1) ) - { - return false; - } - this.parcelName = tmpName.substring(0,tmpName.lastIndexOf(".")); - return true; + private boolean isOfficeFile(File file) { + for (int i = 0; i < OFFICE_EXTENSIONS.length; i++) + if (file.getName().endsWith(OFFICE_EXTENSIONS[i])) + return true; + return false; } - public Enumeration getParcels() - { - java.util.Vector parcelEntries = new java.util.Vector(); + public Enumeration getParcels() { + + Vector parcels = new Vector(); ZipFile zp = null; try { - zp = new ZipFile(this.officeFile); + zp = new ZipFile(this.file); - for (Enumeration officeEntries = zp.entries(); officeEntries.hasMoreElements(); ) + for (Enumeration enum = zp.entries(); enum.hasMoreElements(); ) { - ZipEntry ze = (ZipEntry)officeEntries.nextElement(); + ZipEntry ze = (ZipEntry)enum.nextElement(); if (ze.getName().endsWith(ParcelZipper.PARCEL_DESCRIPTOR_XML)) { String tmp = ze.getName(); @@ -135,7 +120,7 @@ public class OfficeDocument String parcelName = ARCHIVE_TAG + ze.getName().substring(start, end); - parcelEntries.add(parcelName); + parcels.add(parcelName); } } } @@ -155,23 +140,18 @@ public class OfficeDocument } } - return parcelEntries.elements(); + return parcels.elements(); } - public String getParcelNameFromEntry(String parcelName) - { - return parcelName.substring(PARCEL_PREFIX_DIR.length(), parcelName.length()-1); - } - - public String getParcelEntryFromName(String parcelName) - { + public String getParcelEntryFromName(String parcelName) { return parcelName.substring(ARCHIVE_TAG.length()) + "/"; } - public boolean removeParcel(String parcelName) - { + public boolean removeParcel(String parcelName) { + try { - ParcelZipper.getParcelZipper().unzipToZipExceptParcel(this.officeFile, getParcelEntryFromName(parcelName)); + ParcelZipper.getParcelZipper().removeParcel( + file, getParcelEntryFromName(parcelName)); } catch (IOException ioe) { ioe.printStackTrace(); @@ -179,9 +159,4 @@ public class OfficeDocument } return true; } - - public String unzipOneParcel(String parcelName) - { - return new String("location"); - } } diff --git a/scripting/java/org/openoffice/idesupport/SVersionRCFile.java b/scripting/java/org/openoffice/idesupport/SVersionRCFile.java index c1600129d134..40e3a3893d12 100644 --- a/scripting/java/org/openoffice/idesupport/SVersionRCFile.java +++ b/scripting/java/org/openoffice/idesupport/SVersionRCFile.java @@ -2,9 +2,9 @@ * * $RCSfile: SVersionRCFile.java,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: toconnor $ $Date: 2003-01-16 11:42:46 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -105,7 +105,6 @@ public class SVersionRCFile { public SVersionRCFile(String name) { sverionrc = new File(name); - System.out.println("Created new SVersionRCFile: " + name); } public static SVersionRCFile createInstance() { @@ -126,6 +125,31 @@ public class SVersionRCFile { return result; } + public static String toFileURL(String path) { + File f = new File(path); + + if (!f.exists()) + return null; + + try { + path = f.getCanonicalPath(); + } + catch (IOException ioe) { + return null; + } + + if (System.getProperty("os.name").startsWith("Windows")) + path = path.replace(File.separatorChar, '/'); + + StringBuffer buf = new StringBuffer(FILE_URL_PREFIX); + buf.append(path); + + if (f.isDirectory()) + buf.append("/"); + + return buf.toString(); + } + public Hashtable getVersions() throws IOException { BufferedReader br; diff --git a/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java b/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java index fc674d2e77bb..ba6881ad4fee 100644 --- a/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java +++ b/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java @@ -2,9 +2,9 @@ * * $RCSfile: ConfigurePanel.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: toconnor $ $Date: 2003-01-16 17:47:56 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,8 @@ package org.openoffice.idesupport.ui; import java.io.File; +import java.io.FileNotFoundException; + import java.util.Vector; import java.util.Enumeration; @@ -88,23 +90,33 @@ public class ConfigurePanel extends JPanel { private File basedir; private Vector classpath; + private ParcelDescriptor descriptor; private MethodPanel methodPanel; private ScriptPanel scriptPanel; - private ParcelDescriptor descriptor = ParcelDescriptor.getParcelDescriptor(); - public static final String DIALOG_TITLE = "Choose What to Export as Scripts"; + public static final String DIALOG_TITLE = + "Choose What to Export as Scripts"; - public ConfigurePanel(String basedir, Vector classpath, Document doc, - String language) { + public ConfigurePanel(String basedir, Vector classpath, Document doc) { this.basedir = new File(basedir); this.classpath = classpath; - initUI(doc, language); + this.descriptor = new ParcelDescriptor(doc); + initUI(); } - public void reload(String basedir, Vector classpath, Document doc, - String language) { + public ConfigurePanel(String basedir, Vector classpath) + throws FileNotFoundException { + + this.basedir = new File(basedir); + this.classpath = classpath; + this.descriptor = new ParcelDescriptor(new File(this.basedir, + ParcelZipper.PARCEL_DESCRIPTOR_XML)); + initUI(); + } + + public void reload(String basedir, Vector classpath, Document doc) { if (basedir != null) this.basedir = new File(basedir); @@ -112,27 +124,51 @@ public class ConfigurePanel extends JPanel { if (classpath != null) this.classpath = classpath; - methodPanel.reload(this.basedir, this.classpath, language); + if (doc != null) { + descriptor = new ParcelDescriptor(doc); + } - if (doc != null) - scriptPanel.reload(descriptor.parse(doc)); + methodPanel.reload(this.basedir, this.classpath, + descriptor.getLanguage()); + scriptPanel.reload(descriptor.getScriptEntries()); + } + + public void reload(String basedir, Vector classpath) + throws FileNotFoundException { + + if (basedir != null) + this.basedir = new File(basedir); + + if (classpath != null) + this.classpath = classpath; + + this.descriptor = new ParcelDescriptor(new File(this.basedir, + ParcelZipper.PARCEL_DESCRIPTOR_XML)); + + methodPanel.reload(this.basedir, this.classpath, + descriptor.getLanguage()); + scriptPanel.reload(descriptor.getScriptEntries()); } public Document getConfiguration() throws Exception { Enumeration scripts = scriptPanel.getScriptEntries(); - return descriptor.generate(scripts); + descriptor.setScriptEntries(scripts); + return descriptor.getDocument(); } - private void initUI(Document doc, String language) { + private void initUI() { + JPanel leftPanel = new JPanel(); JPanel methodButtons = initMethodButtons(); - methodPanel = new MethodPanel(basedir, classpath, language); + methodPanel = new MethodPanel(basedir, classpath, descriptor.getLanguage()); + leftPanel.setLayout(new BorderLayout()); leftPanel.add(methodPanel, BorderLayout.CENTER); JPanel rightPanel = new JPanel(); JPanel scriptButtons = initScriptButtons(); - scriptPanel = new ScriptPanel(descriptor.parse(doc)); + scriptPanel = new ScriptPanel(descriptor.getScriptEntries()); + rightPanel.setLayout(new BorderLayout()); rightPanel.add(scriptPanel, BorderLayout.CENTER); rightPanel.add(scriptButtons, BorderLayout.SOUTH); diff --git a/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java b/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java index d30cff5e38fc..060b9352bcc9 100644 --- a/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java +++ b/scripting/java/org/openoffice/idesupport/ui/MethodPanel.java @@ -2,9 +2,9 @@ * * $RCSfile: MethodPanel.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: toconnor $ $Date: 2003-01-16 17:47:56 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,9 +75,12 @@ import javax.swing.JTable; import javax.swing.table.AbstractTableModel; import javax.swing.JLabel; import java.awt.BorderLayout; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.MalformedURLException; import org.openoffice.idesupport.ScriptEntry; -import org.openoffice.idesupport.DefaultScriptClassLoader; +import org.openoffice.idesupport.SVersionRCFile; import org.openoffice.idesupport.zip.ParcelZipper; public class MethodPanel extends JPanel { @@ -162,8 +165,7 @@ public class MethodPanel extends JPanel { classNames = findClassNames(); if (classNames != null && classNames.length != 0) { - DefaultScriptClassLoader classloader = - new DefaultScriptClassLoader(classpath); + ClassLoader classloader = getClassLoader(); for (int i = 0; i < classNames.length; i++) { @@ -203,6 +205,26 @@ public class MethodPanel extends JPanel { } } + private ClassLoader getClassLoader() { + + int len = classpath.size(); + ArrayList urls = new ArrayList(len); + + for (int i = 0; i < len; i++) { + try { + String s = (String)classpath.elementAt(i); + s = SVersionRCFile.toFileURL(s); + + if (s != null) + urls.add(new URL(s)); + } + catch (MalformedURLException mue) { + } + } + + return new URLClassLoader((URL[])urls.toArray(new URL[0])); + } + private void initBeanShellValues(String parcelName) { ArrayList bshFiles = findFiles(basedir, ".bsh"); diff --git a/scripting/java/org/openoffice/idesupport/xml/Manifest.java b/scripting/java/org/openoffice/idesupport/xml/Manifest.java index 03aac4ea8a31..86f2b335cf0c 100644 --- a/scripting/java/org/openoffice/idesupport/xml/Manifest.java +++ b/scripting/java/org/openoffice/idesupport/xml/Manifest.java @@ -2,9 +2,9 @@ * * $RCSfile: Manifest.java,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: toconnor $ $Date: 2002-11-13 17:44:14 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,12 +83,10 @@ import org.w3c.dom.Element; public class Manifest { private Document document = null; - private XMLParser parser = null; private boolean baseElementsExist = false; - public Manifest(InputStream inputStream, XMLParser parser) { - this.parser = parser; - document = parser.parse(inputStream); + public Manifest(InputStream inputStream) { + document = XMLParserFactory.getParser().parse(inputStream); } public void add(String entry) { @@ -119,7 +117,6 @@ public class Manifest { if (baseElementsExist == false) { baseElementsExist = true; add("Scripts/", "application/script-parcel"); - add("Scripts/java/", ""); } } @@ -194,6 +191,6 @@ public class Manifest { } public void write(OutputStream out) throws IOException { - parser.write(document, out); + XMLParserFactory.getParser().write(document, out); } } diff --git a/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java b/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java index 6db67ce013c1..594ce3a5b15f 100644 --- a/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java +++ b/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java @@ -2,9 +2,9 @@ * * $RCSfile: ParcelZipper.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: toconnor $ $Date: 2002-11-26 12:46:44 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,18 +70,17 @@ import org.openoffice.idesupport.filter.FileFilter; import org.openoffice.idesupport.filter.BinaryOnlyFilter; import org.openoffice.idesupport.filter.ExceptParcelFilter; -import org.openoffice.idesupport.xml.XMLParser; import org.openoffice.idesupport.xml.Manifest; +import org.openoffice.idesupport.xml.ParcelDescriptor; public class ParcelZipper { - public static final String PARCEL_PREFIX_DIR = "Scripts/java/"; + public static final String PARCEL_PREFIX_DIR = "Scripts/"; public static final String PARCEL_EXTENSION = "sxp"; public static final String CONTENTS_DIRNAME = "Contents"; public static final String PARCEL_DESCRIPTOR_XML = "parcel-descriptor.xml"; private static ParcelZipper zipper = null; - private static XMLParser parser = null; private static final FileFilter DEFAULT_FILTER = BinaryOnlyFilter.getInstance(); @@ -99,10 +98,6 @@ public class ParcelZipper return zipper; } - public static void setXMLParser(XMLParser parser) { - getParcelZipper().parser = parser; - } - public String zipParcel(File basedir) throws IOException { File targetfile, targetdir; @@ -197,7 +192,9 @@ public class ParcelZipper } } - public boolean isOverwriteNeeded(File parcel, File target) { + public boolean isOverwriteNeeded(File parcel, File target) + throws IOException + { boolean result; if (target.isDirectory()) @@ -219,7 +216,9 @@ public class ParcelZipper return false; } - private boolean isDocumentOverwriteNeeded(File parcel, File document) { + private boolean isDocumentOverwriteNeeded(File parcel, File document) + throws IOException + { ZipFile documentZip; boolean result = false; @@ -231,7 +230,8 @@ public class ParcelZipper } String name = - PARCEL_PREFIX_DIR + getParcelDirFromParcelZip(parcel.getName()) + + PARCEL_PREFIX_DIR + getParcelLanguage(parcel) + + "/" + getParcelDirFromParcelZip(parcel.getName()) + "/" + PARCEL_DESCRIPTOR_XML; if (documentZip.getEntry(name) != null) @@ -267,6 +267,7 @@ public class ParcelZipper ZipInputStream in; File parcelDir = new File(targetDirectory, + getParcelLanguage(parcel) + File.separator + getParcelDirFromParcelZip(parcel.getName())); if (isDirectoryOverwriteNeeded(parcel, targetDirectory)) { @@ -328,13 +329,14 @@ public class ParcelZipper if (isDocumentOverwriteNeeded(parcel, targetDocument)) { String parcelName = getParcelDirFromParcelZip(parcel.getName()); - unzipToZipExceptParcel(targetDocument, parcelName); + removeParcel(targetDocument, parcelName); } // first write contents of document to tmpfile File tmpfile = new File(targetDocument.getAbsolutePath() + ".tmp"); manifest = addParcelToManifest(targetDocument, parcel); + String language = getParcelLanguage(parcel); documentStream = new ZipInputStream(new FileInputStream(targetDocument)); @@ -343,7 +345,7 @@ public class ParcelZipper try { copyParcelToZip(parcelStream, outStream, PARCEL_PREFIX_DIR + - getParcelDirFromParcelZip(parcel.getName())); + language + "/" + getParcelDirFromParcelZip(parcel.getName())); copyDocumentToZip(documentStream, outStream, manifest); documentStream.close(); parcelStream.close(); @@ -416,7 +418,7 @@ public class ParcelZipper } } - public String unzipToZipExceptParcel(File document, String parcelName) + public String removeParcel(File document, String parcelName) throws IOException { ZipInputStream documentStream; @@ -494,7 +496,7 @@ public class ParcelZipper if (original != null) { try { result = - new Manifest(documentZip.getInputStream(original), parser); + new Manifest(documentZip.getInputStream(original)); } catch (IOException ioe) { result = null; @@ -510,7 +512,9 @@ public class ParcelZipper return result; } - private Manifest addParcelToManifest(File document, File parcel) { + private Manifest addParcelToManifest(File document, File parcel) + throws IOException { + ZipFile parcelZip; Manifest result = null; @@ -518,6 +522,8 @@ public class ParcelZipper if (result == null) return null; + String language = getParcelLanguage(parcel); + try { parcelZip = new ZipFile(parcel); } @@ -525,7 +531,7 @@ public class ParcelZipper return null; } - String prefix = PARCEL_PREFIX_DIR + + String prefix = PARCEL_PREFIX_DIR + language + "/" + getParcelDirFromParcelZip(parcel.getName()) + "/"; Enumeration entries = parcelZip.entries(); @@ -553,4 +559,17 @@ public class ParcelZipper result.remove(name); return result; } + + private String getParcelLanguage(File file) throws IOException { + ZipFile zf = new ZipFile(file); + ZipEntry ze = zf.getEntry(PARCEL_DESCRIPTOR_XML); + + if (ze == null) + throw new IOException("Could not find Parcel Descriptor in parcel"); + + InputStream is = zf.getInputStream(ze); + ParcelDescriptor pd = new ParcelDescriptor(is); + + return pd.getLanguage().toLowerCase(); + } } diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java index a95534eeb4ff..76349024e975 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java +++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java @@ -2,9 +2,9 @@ * * $RCSfile: DeployParcelAction.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: toconnor $ $Date: 2003-01-16 11:42:47 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -166,8 +166,7 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup } else { target = new File((String)versions.get(label) + - File.separator + "user" + File.separator + "Scripts" + - File.separator + "java"); + File.separator + "user" + File.separator + "Scripts"); if (!target.exists()) { boolean response = askIfCreateDirectory(target); if (response == false) { diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java index 985e0270112e..cd489d85a627 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java +++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java @@ -2,9 +2,9 @@ * * $RCSfile: OfficeDocumentSupport.java,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: toconnor $ $Date: 2002-11-13 17:44:23 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,7 +81,6 @@ import org.openide.filesystems.FileRenameEvent; import org.openide.cookies.OpenCookie; import org.openoffice.idesupport.OfficeDocument; -import org.openoffice.idesupport.zip.ParcelZipper; import org.openoffice.netbeans.modules.office.options.OfficeSettings; import org.openoffice.netbeans.modules.office.loader.OfficeDocumentDataObject; @@ -107,11 +106,6 @@ public class OfficeDocumentSupport implements OfficeDocumentCookie, OpenCookie, fo.addFileChangeListener(this); } - // ensure that ParcelZipper's XMLParser is set - static { - ParcelZipper.setXMLParser(ManifestParser.getManifestParser()); - } - public void mount() { File file = FileUtil.toFile(dataObj.getPrimaryFile()); diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java index 4f9b494c8abb..69a6479bc4df 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java +++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java @@ -2,9 +2,9 @@ * * $RCSfile: ParcelFolderCookie.java,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: toconnor $ $Date: 2002-11-13 17:44:24 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,5 +67,5 @@ public interface ParcelFolderCookie extends Node.Cookie { public void generate(); - public void configure(); + public boolean configure(); } diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java index 44ca2234b283..a91500cc1709 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java +++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java @@ -2,9 +2,9 @@ * * $RCSfile: ParcelFolderSupport.java,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: npower $ $Date: 2003-01-16 18:54:46 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -108,11 +108,6 @@ public class ParcelFolderSupport implements ParcelFolderCookie this.pf = pf; } - // ensure that ParcelZipper's XMLParser is set - static { - ParcelZipper.setXMLParser(ManifestParser.getManifestParser()); - } - public void generate() { ParcelFolder.ParcelFolderNode node = (ParcelFolder.ParcelFolderNode)pf.getNodeDelegate(); @@ -127,7 +122,9 @@ public class ParcelFolderSupport implements ParcelFolderCookie File targetfile = new File(node.getTargetDir() + File.separator + parcelBase.getName() + "." + ParcelZipper.PARCEL_EXTENSION); - configure(); + boolean proceed = configure(); + if (proceed == false) + return; final OutputWriter out = ParcelSupport.getOutputWindowWriter(parcelDir.getName() + " (generating)"); @@ -152,45 +149,29 @@ public class ParcelFolderSupport implements ParcelFolderCookie } } - public void configure() { + public boolean configure() { FileObject primary = pf.getPrimaryFile(); - ParcelFolder.ParcelFolderNode node = - (ParcelFolder.ParcelFolderNode)pf.getNodeDelegate(); - File contents = FileUtil.toFile( primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME)); File parcelDescriptor = new File(contents, ParcelZipper.PARCEL_DESCRIPTOR_XML); - InputSource is; - Document previous = null; - - try { - is = new InputSource(new FileInputStream(parcelDescriptor)); - previous = XMLUtil.parse(is, false, false, null, null); - } - catch (FileNotFoundException fnfe) { - System.out.println("Couldn't find file: " + parcelDescriptor.getName()); - } - catch (IOException ioe) { - System.out.println("IO Error parsing file: " + parcelDescriptor.getName()); - } - catch (SAXException se) { - System.out.println("Sax Error parsing file: " + parcelDescriptor.getName()); - } - Vector classpath = getClasspath(); classpath.addElement(contents.getAbsolutePath()); - if (configuror == null) - configuror = new ConfigurePanel(contents.getAbsolutePath(), - classpath, previous, node.getLanguage()); - else - configuror.reload(contents.getAbsolutePath(), classpath, previous, - node.getLanguage()); + try { + if (configuror == null) + configuror = new ConfigurePanel( + contents.getAbsolutePath(), classpath); + else + configuror.reload(contents.getAbsolutePath(), classpath); + } + catch (FileNotFoundException fnfe) { + ErrorManager.getDefault().notify(fnfe); + } DialogDescriptor descriptor = new DialogDescriptor(configuror, ConfigurePanel.DIALOG_TITLE); @@ -208,6 +189,10 @@ public class ParcelFolderSupport implements ParcelFolderCookie ErrorManager.getDefault().notify(e); } } + else { + return false; + } + return true; } private Vector getClasspath() { diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java index 4830946f482c..af311050883e 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java +++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java @@ -2,9 +2,9 @@ * * $RCSfile: ParcelSupport.java,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: toconnor $ $Date: 2002-11-13 17:44:25 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,11 +96,6 @@ public class ParcelSupport implements ParcelCookie this.fo = fo; } - // ensure that ParcelZipper's XMLParser is set - static { - ParcelZipper.setXMLParser(ManifestParser.getManifestParser()); - } - public File getFile() { return FileUtil.toFile(fo); } @@ -145,13 +140,20 @@ public class ParcelSupport implements ParcelCookie } } - if (zipper.isOverwriteNeeded(source, target) == true) - if (promptForOverwrite(source, target) == false) - return false; - OutputWriter out = getOutputWindowWriter(fo.getName() + " (deploying)"); + try { + if (zipper.isOverwriteNeeded(source, target) == true) + if (promptForOverwrite(source, target) == false) + return false; + } + catch (IOException ioe) { + out.println("DEPLOYMENT FAILED: reason: " + + ioe.getClass().getName() + ": "+ ioe.getMessage()); + return false; + } + try { out.println("Deploying: " + fo.getName() + "\nTo: " + target.getAbsolutePath(), null); diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java index 96ff7100dd1f..2dbeff585f00 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java +++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java @@ -2,9 +2,9 @@ * * $RCSfile: ParcelFolder.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: toconnor $ $Date: 2003-01-16 18:00:19 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -161,8 +161,8 @@ public class ParcelFolder extends DataFolder { prop = createFilterProperty(); props.put(prop); - prop = createLanguageProperty(); - props.put(prop); + // prop = createLanguageProperty(); + // props.put(prop); return sheet; } diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java index f98c30d59278..3373d20ae6ec 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java +++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java @@ -2,9 +2,9 @@ * * $RCSfile: OfficeModule.java,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: toconnor $ $Date: 2002-11-21 19:00:05 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,11 +62,16 @@ package org.openoffice.netbeans.modules.office.utils; import org.openide.modules.ModuleInstall; +import org.openoffice.idesupport.xml.XMLParserFactory; public class OfficeModule extends ModuleInstall { private static final long serialVersionUID = -8499324854301243852L; + public void restored () { + XMLParserFactory.setParser(ManifestParser.getManifestParser()); + } + public boolean closing () { FrameworkJarChecker.unmountDependencies(); return true; diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java index 34a76fdcb897..83bef3f23300 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java @@ -2,9 +2,9 @@ * * $RCSfile: ParcelContentsIterator.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: toconnor $ $Date: 2003-01-16 17:51:45 $ + * last change: $Author: toconnor $ $Date: 2003-01-28 20:52:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,6 +84,7 @@ import org.openide.util.NbBundle; import org.openide.filesystems.*; import org.openoffice.idesupport.zip.ParcelZipper; +import org.openoffice.idesupport.xml.ParcelDescriptor; import org.openoffice.netbeans.modules.office.loader.ParcelFolder; import org.openoffice.netbeans.modules.office.filesystem.OpenOfficeDocFileSystem; import org.openoffice.netbeans.modules.office.utils.PackageRemover; @@ -175,12 +176,20 @@ public class ParcelContentsIterator implements TemplateWizard.Iterator { } FileObject recipe = result.getPrimaryFile(); - recipe.setAttribute(ParcelFolder.LANGUAGE_ATTRIBUTE, language); - System.out.println("Called setAttribute from wizard: " + language); FileObject contents = recipe.getFileObject(ParcelZipper.CONTENTS_DIRNAME); + FileObject descriptor = + contents.getFileObject(ParcelZipper.PARCEL_DESCRIPTOR_XML); + + if (descriptor != null) { + ParcelDescriptor pd = + new ParcelDescriptor(FileUtil.toFile(descriptor)); + pd.setLanguage(language); + pd.write(); + } + if (contents != null) { DataFolder parent = DataFolder.findFolder(contents);