diff options
Diffstat (limited to 'scripting/java/org/openoffice/netbeans/modules/office/actions')
15 files changed, 0 insertions, 1438 deletions
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java deleted file mode 100644 index 9aa998cfe77a..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import java.util.Vector; -import java.util.Enumeration; - -import org.openide.nodes.Node; -import org.openide.util.HelpCtx; -import org.openide.util.RequestProcessor; -import org.openide.actions.BuildAllAction; - -import org.openide.compiler.Compiler; -import org.openide.compiler.CompilerJob; -import org.openide.compiler.CompilerTask; - -import org.openoffice.netbeans.modules.office.utils.FrameworkJarChecker; - -public class BuildParcelAction extends BuildAllAction { - public String getName() { - return "Build"; - } - - protected void performAction(Node[] activatedNodes) { - FrameworkJarChecker.mountDependencies(); - - for (int i = 0; i < activatedNodes.length; i++) { - ArrayList v = new ArrayList(1); - v.addElement(activatedNodes[i]); - - CompilerJob job = createJob(v.elements(), Compiler.DEPTH_INFINITE); - CompilerTask task = job.start(); - task.waitFinished(); - - if (task.isSuccessful()) { - ParcelFolderCookie cookie = (ParcelFolderCookie) - activatedNodes[i].getCookie(ParcelFolderCookie.class); - - if (cookie != null) - cookie.generate(); - } - } - } -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/CompileParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/CompileParcelAction.java deleted file mode 100644 index f494c7ab66f0..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/CompileParcelAction.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import org.openide.nodes.Node; -import org.openide.actions.CompileAllAction; - -import org.openoffice.netbeans.modules.office.utils.FrameworkJarChecker; - -public class CompileParcelAction extends CompileAllAction { - public String getName() { - return "Compile"; - } - - protected void performAction(Node[] activatedNodes) { - FrameworkJarChecker.mountDependencies(); - super.performAction(activatedNodes); - } -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java deleted file mode 100644 index fa64996ced70..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import org.openide.nodes.Node; -import org.openide.util.HelpCtx; -import org.openide.util.RequestProcessor; -import org.openide.util.actions.CookieAction; - -import org.openoffice.netbeans.modules.office.utils.FrameworkJarChecker; - -public class ConfigureParcelAction extends CookieAction { - - public String getName() { - return "Configure"; - } - - protected java.lang.Class[] cookieClasses() { - return new Class[] {ParcelFolderCookie.class}; - } - - protected int mode() { - return CookieAction.MODE_EXACTLY_ONE; - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } - - protected void performAction(final Node[] activatedNodes) { - FrameworkJarChecker.mountDependencies(); - - RequestProcessor.getDefault().post(new Runnable() { - public void run() { - for (int i = 0; i < activatedNodes.length; i++) { - ParcelFolderCookie pfc = (ParcelFolderCookie) - activatedNodes[i].getCookie(ParcelFolderCookie.class); - - if (pfc != null) - pfc.configure(); - } - } - }); - } -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java deleted file mode 100644 index 04a17a8976fc..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import java.io.File; -import java.io.IOException; -import java.util.Hashtable; -import java.util.List; -import java.util.ArrayList; -import java.util.Enumeration; - -import javax.swing.JMenuItem; -import javax.swing.JFileChooser; -import javax.swing.filechooser.FileFilter; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; - -import org.openide.TopManager; -import org.openide.NotifyDescriptor; -import org.openide.awt.Actions; -import org.openide.nodes.Node; -import org.openide.util.HelpCtx; -import org.openide.util.NbBundle; -import org.openide.util.RequestProcessor; -import org.openide.util.actions.*; -import org.openide.awt.JMenuPlus; - -import org.openoffice.idesupport.SVersionRCFile; -import org.openoffice.idesupport.OfficeInstallation; -import org.openoffice.idesupport.zip.ParcelZipper; -import org.openoffice.idesupport.LocalOffice; - -import org.openoffice.netbeans.modules.office.utils.NagDialog; -import org.openoffice.netbeans.modules.office.options.OfficeSettings; - -public class DeployParcelAction extends CookieAction implements - Presenter.Popup { - - private static final String BROWSE_LABEL = "Office Document..."; - private static final String DEPLOY_LABEL = "Deploy To"; - - public String getName() { - return DEPLOY_LABEL; - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } - - public JMenuItem getPopupPresenter() { - JMenuPlus menu = new JMenuPlus(DEPLOY_LABEL); - JMenuItem item, user, share; - final OfficeInstallation oi = OfficeSettings.getDefault().getOfficeDirectory(); - - ActionListener listener = new ActionListener() { - public void actionPerformed(ActionEvent e) { - JMenuItem choice = (JMenuItem)e.getSource(); - String label = choice.getText(); - - Node[] nodes = getActivatedNodes(); - final ParcelCookie parcelCookie = - (ParcelCookie)nodes[0].getCookie(ParcelCookie.class); - - File target = new File(oi.getPath(File.separator + label + - File.separator + "Scripts")); - - File langdir = new File(target, parcelCookie.getLanguage()); - - if (!langdir.exists()) { - boolean response = askIfCreateDirectory(langdir); - - if (!response) { - return; - } - } - - deploy(target); - } - }; - - user = new JMenuItem("user"); - user.addActionListener(listener); - - share = new JMenuItem("share"); - share.addActionListener(listener); - - item = new JMenuPlus(oi.getName()); - item.add(user); - item.add(share); - menu.add(item); - - menu.addSeparator(); - item = new JMenuItem(BROWSE_LABEL); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - File target = getTargetFile(); - - if (target == null) - return; - - deploy(target); - } - }); - menu.add(item); - - return menu; - } - - protected int mode() { - return MODE_ONE; - } - - protected Class[] cookieClasses() { - return new Class[] { ParcelCookie.class }; - } - - protected void performAction(Node[] activatedNodes) { - // do nothing, should not happen - } - - private void deploy(final File target) { - Node[] nodes = getActivatedNodes(); - final ParcelCookie parcelCookie = - (ParcelCookie)nodes[0].getCookie(ParcelCookie.class); - - RequestProcessor.getDefault().post(new Runnable() { - public void run() { - boolean result = parcelCookie.deploy(target); - - if (result && target.isDirectory()) { - showNagDialog(); - } - } - }); - } - - private boolean askIfCreateDirectory(File directory) { - String message = directory.getAbsolutePath() + " does not exist. " + - "Do you want to create it now?"; - - NotifyDescriptor d = new NotifyDescriptor.Confirmation( - message, NotifyDescriptor.OK_CANCEL_OPTION); - TopManager.getDefault().notify(d); - - if (d.getValue() == NotifyDescriptor.CANCEL_OPTION) - return false; - - boolean result; - - try { - result = directory.mkdirs(); - } catch (SecurityException se) { - result = false; - } - - if (!result) { - String tmp = "Error creating: " + directory.getAbsolutePath(); - NotifyDescriptor d2 = new NotifyDescriptor.Message( - tmp, NotifyDescriptor.ERROR_MESSAGE); - TopManager.getDefault().notify(d2); - } - - return result; - } - - private void refreshOffice(String path) { - ClassLoader syscl = TopManager.getDefault().currentClassLoader(); - LocalOffice office = LocalOffice.create(syscl, path, 8100); - office.refreshStorage("file://" + path + "/program/../user"); - office.disconnect(); - } - - private void showNagDialog() { - String message = "If you currently have Office running you will " + - "need to click on the Tools/Scripting Add-on's/Refresh All Scripts " + - " menu item in Office so that the scripts in this parcel can be detected."; - - OfficeSettings settings = OfficeSettings.getDefault(); - - if (settings.getWarnAfterDirDeploy()) { - NagDialog warning = NagDialog.createInformationDialog( - message, "Show this message in future", true); - - warning.show(); - - if (!warning.getState()) - settings.setWarnAfterDirDeploy(false); - } - } - - private File getTargetFile() { - File target = null; - - JFileChooser chooser = new JFileChooser(); - chooser.setDialogTitle("Deploy Parcel To Office Document"); - chooser.setApproveButtonText("Deploy"); - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setFileFilter(new FileFilter() { - public boolean accept(File file) { - return file.isDirectory() || - file.getName().endsWith(".sxw") || - file.getName().endsWith(".sxc") || - file.getName().endsWith(".sxd") || - file.getName().endsWith(".sxi"); - } - - public String getDescription() { - return "Office Documents"; - } - }); - - int result = chooser.showDialog(null, null); - - if (result == JFileChooser.APPROVE_OPTION) { - target = chooser.getSelectedFile(); - } - - return target; - } -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java deleted file mode 100644 index 8b22e93ef9c4..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import org.openide.nodes.Node; -import org.openide.util.HelpCtx; -import org.openide.util.RequestProcessor; -import org.openide.util.actions.CookieAction; - -/** - * @version 1.0 - */ -public class MountDocumentAction extends CookieAction { - public String getName() { - return "Mount Document"; //NOI18N - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } - - protected int mode() { - // enable duplication for as many qualifying nodes as are selected: - return CookieAction.MODE_ALL; - } - - protected java.lang.Class[] cookieClasses() { - // just the DuplicateCookie: - return new Class[] {OfficeDocumentCookie.class}; - } - - protected void performAction(final Node[] activatedNodes) { - RequestProcessor.getDefault().post(new Runnable() { - public void run() { - for (int i = 0; i < activatedNodes.length; i++) { - OfficeDocumentCookie cookie = (OfficeDocumentCookie)activatedNodes[i].getCookie( - OfficeDocumentCookie.class); - - if (cookie != null) { - cookie.mount(); - } - } - } - }); - } -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java deleted file mode 100644 index 01395dc3fb7d..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import org.openide.nodes.Node; -import org.openide.util.HelpCtx; -import org.openide.util.RequestProcessor; -import org.openide.util.actions.CookieAction; - -/** - * @version 1.0 - */ -public class MountParcelAction extends CookieAction { - public String getName() { - return "Mount Parcel"; //NOI18N - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } - - protected int mode() { - // enable duplication for as many qualifying nodes as are selected: - return CookieAction.MODE_ALL; - } - - protected java.lang.Class[] cookieClasses() { - return new Class[] {ParcelCookie.class}; - } - - protected void performAction(final Node[] activatedNodes) { - RequestProcessor.getDefault().post(new Runnable() { - public void run() { - for (int i = 0; i < activatedNodes.length; i++) { - ParcelCookie mpc = (ParcelCookie)activatedNodes[i].getCookie( - ParcelCookie.class); - - if (mpc != null) { - mpc.mount(); - } - } - } - }); - } -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java deleted file mode 100644 index df57575020f4..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import java.util.Enumeration; -import javax.swing.event.ChangeListener; -import org.openide.nodes.Node; - -public interface OfficeDocumentCookie extends Node.Cookie { - void mount(); - Enumeration getParcels(); - void removeParcel(String name); - - void addChangeListener(ChangeListener cl); - void removeChangeListener(ChangeListener cl); -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java deleted file mode 100644 index c77fc63a7cbc..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import java.io.IOException; -import java.io.File; -import java.beans.PropertyVetoException; -import java.util.Enumeration; -import java.util.Set; -import java.util.HashSet; -import java.util.Iterator; -import javax.swing.event.ChangeListener; -import javax.swing.event.ChangeEvent; - -import org.openide.ErrorManager; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; -import org.openide.filesystems.FileChangeListener; -import org.openide.filesystems.FileEvent; -import org.openide.filesystems.FileAttributeEvent; -import org.openide.filesystems.FileRenameEvent; -import org.openide.cookies.OpenCookie; - -import org.openoffice.idesupport.OfficeDocument; - -import org.openoffice.netbeans.modules.office.options.OfficeSettings; -import org.openoffice.netbeans.modules.office.loader.OfficeDocumentDataObject; -import org.openoffice.netbeans.modules.office.utils.ZipMounter; -import org.openoffice.netbeans.modules.office.utils.ManifestParser; - -public class OfficeDocumentSupport implements OfficeDocumentCookie, OpenCookie, - FileChangeListener { - protected OfficeDocumentDataObject dataObj; - private boolean isMounted = false; - private OfficeDocument document; - private Set listeners; - - public OfficeDocumentSupport(OfficeDocumentDataObject dataObj) { - this.dataObj = dataObj; - FileObject fo = dataObj.getPrimaryFile(); - - try { - this.document = new OfficeDocument(FileUtil.toFile(fo)); - } catch (Exception e) { - e.printStackTrace(); - } - - fo.addFileChangeListener(this); - } - - public void mount() { - File file = FileUtil.toFile(dataObj.getPrimaryFile()); - - try { - ZipMounter.getZipMounter().mountZipFile(file); - isMounted = true; - } catch (IOException ioe) { - ErrorManager.getDefault().notify(ioe); - } catch (PropertyVetoException pve) { - ErrorManager.getDefault().notify(pve); - } - } - - public void open() { - File file = FileUtil.toFile(dataObj.getPrimaryFile()); - - OfficeSettings settings = OfficeSettings.getDefault(); - File soffice = new File(settings.getOfficeDirectory().getPath( - File.separator + "soffice")); - - try { - Process p = Runtime.getRuntime().exec(new String[] { - soffice.getAbsolutePath(), file.getAbsolutePath() - }); - } catch (IOException ioe) { - ErrorManager.getDefault().notify(ioe); - } - } - - public Enumeration getParcels() { - return document.getParcels(); - } - - public void removeParcel(String name) { - document.removeParcel(name); - dataObj.getPrimaryFile().refresh(true); - } - - public void addChangeListener(ChangeListener cl) { - if (listeners == null) - listeners = new HashSet(); - - listeners.add(cl); - } - - public void removeChangeListener(ChangeListener cl) { - if (listeners == null) - return; - - listeners.remove(cl); - } - - public void fileChanged(FileEvent fe) { - if (listeners != null) { - Iterator iter = listeners.iterator(); - - while (iter.hasNext()) - ((ChangeListener)iter.next()).stateChanged(new ChangeEvent(this)); - } - } - - public void fileAttributeChanged(FileAttributeEvent fe) {} - public void fileDataCreated(FileEvent fe) {} - public void fileDeleted(FileEvent fe) {} - public void fileFolderCreated(FileEvent fe) {} - public void fileRenamed(FileRenameEvent fe) {} -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java deleted file mode 100644 index 1c782ae6bf22..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import java.io.File; -import org.openide.nodes.Node; - -public interface ParcelCookie extends Node.Cookie { - File getFile(); - - String getLanguage(); - - void mount(); - - boolean deploy(File target); -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java deleted file mode 100644 index c4378ceff24d..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import java.io.IOException; - -import org.openide.cookies.*; -import org.openide.filesystems.FileLock; -import org.openide.filesystems.FileObject; -import org.openide.loaders.DataObject; -import org.openide.text.DataEditorSupport; -import org.openide.windows.CloneableOpenSupport; - -import org.openoffice.netbeans.modules.office.loader.ParcelDescriptorDataObject; - -/** Support for editing a data object as text. - */ -// Replace OpenCookie with EditCookie or maybe ViewCookie as desired: -public class ParcelDescriptorEditorSupport extends DataEditorSupport implements - EditorCookie, OpenCookie, CloseCookie, PrintCookie { - - /** Create a new editor support. - * @param obj the data object whose primary file will be edited as text - */ - public ParcelDescriptorEditorSupport(ParcelDescriptorDataObject obj) { - super(obj, new ParcelDescriptorEnv(obj)); - // Set a MIME type as needed, e.g.: - setMIMEType("text/xml"); - } - - /** Called when the document is modified. - * Here, adding a save cookie to the object and marking it modified. - * @return true if the modification is acceptable - */ - protected boolean notifyModified() { - if (!super.notifyModified()) { - return false; - } - - ParcelDescriptorDataObject obj = (ParcelDescriptorDataObject)getDataObject(); - - if (obj.getCookie(SaveCookie.class) == null) { - obj.setModified(true); - // You must implement this method on the object: - obj.addSaveCookie(new Save()); - } - - return true; - } - - /** Called when the document becomes unmodified. - * Here, removing the save cookie from the object and marking it unmodified. - */ - protected void notifyUnmodified() { - ParcelDescriptorDataObject obj = (ParcelDescriptorDataObject)getDataObject(); - SaveCookie save = (SaveCookie)obj.getCookie(SaveCookie.class); - - if (save != null) { - // You must implement this method on the object: - obj.removeSaveCookie(save); - obj.setModified(false); - } - - super.notifyUnmodified(); - } - - /** A save cookie to use for the editor support. - * When saved, saves the document to disk and marks the object unmodified. - */ - private class Save implements SaveCookie { - public void save() throws IOException { - saveDocument(); - getDataObject().setModified(false); - } - } - - /** A description of the binding between the editor support and the object. - * Note this may be serialized as part of the window system and so - * should be static, and use the transient modifier where needed. - */ - private static class ParcelDescriptorEnv extends DataEditorSupport.Env { - - /** Create a new environment based on the data object. - * @param obj the data object to edit - */ - public ParcelDescriptorEnv(ParcelDescriptorDataObject obj) { - super(obj); - } - - /** Get the file to edit. - * @return the primary file normally - */ - protected FileObject getFile() { - return getDataObject().getPrimaryFile(); - } - - /** Lock the file to edit. - * Should be taken from the file entry if possible, helpful during - * e.g. deletion of the file. - * @return a lock on the primary file normally - * @throws IOException if the lock could not be taken - */ - protected FileLock takeLock() throws IOException { - return ((ParcelDescriptorDataObject) - getDataObject()).getPrimaryEntry().takeLock(); - } - - /** Find the editor support this environment represents. - * Note that we have to look it up, as keeping a direct - * reference would not permit this environment to be serialized. - * @return the editor support - */ - public CloneableOpenSupport findCloneableOpenSupport() { - return (ParcelDescriptorEditorSupport)getDataObject().getCookie( - ParcelDescriptorEditorSupport.class); - } - - } - -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java deleted file mode 100644 index 0e7e4226d657..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import org.w3c.dom.NodeList; -import javax.swing.event.ChangeListener; -import org.openide.nodes.Node; - -public interface ParcelDescriptorParserCookie extends Node.Cookie { - // should return a NodeList of org.w3c.dom.Element - NodeList getScriptElements(); - - void addChangeListener(ChangeListener cl); - - void removeChangeListener(ChangeListener cl); -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java deleted file mode 100644 index f3f105679677..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import java.io.*; -import java.util.*; -import javax.swing.event.ChangeListener; -import javax.swing.event.ChangeEvent; - -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import org.openide.filesystems.*; -import org.openide.xml.XMLUtil; - -public class ParcelDescriptorParserSupport - implements ParcelDescriptorParserCookie, FileChangeListener { - private FileObject fo; - private Document document; - private Set listeners; - - public ParcelDescriptorParserSupport(FileObject fo) { - this.fo = fo; - fo.addFileChangeListener(this); - } - - private synchronized void parseFile() { - File file = FileUtil.toFile(fo); - InputSource is; - - try { - is = new InputSource(new FileInputStream(file)); - } catch (FileNotFoundException fnfe) { - System.out.println("Couldn't find file: " + file.getName()); - return; - } - - document = null; - - try { - document = XMLUtil.parse(is, false, false, null, null); - } catch (IOException ioe) { - System.out.println("IO Error parsing file: " + file.getName()); - } catch (SAXException se) { - System.out.println("Sax Error parsing file: " + file.getName()); - } - } - - public synchronized NodeList getScriptElements() { - if (document == null) - parseFile(); - - if (document != null) - return document.getElementsByTagName("script"); - - return null; - } - - public void addChangeListener(ChangeListener cl) { - if (listeners == null) - listeners = new HashSet(); - - listeners.add(cl); - } - - public void removeChangeListener(ChangeListener cl) { - if (listeners == null) - return; - - listeners.remove(cl); - } - - public void fileChanged(FileEvent fe) { - parseFile(); - - if (listeners != null) { - Iterator iter = listeners.iterator(); - - while (iter.hasNext()) - ((ChangeListener)iter.next()).stateChanged(new ChangeEvent(this)); - } - } - - public void fileAttributeChanged(FileAttributeEvent fe) {} - public void fileDataCreated(FileEvent fe) {} - public void fileDeleted(FileEvent fe) {} - public void fileFolderCreated(FileEvent fe) {} - public void fileRenamed(FileRenameEvent fe) {} -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java deleted file mode 100644 index 6a17ee13ab31..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import org.openide.nodes.Node; - -public interface ParcelFolderCookie extends Node.Cookie { - void generate(); - - boolean configure(); - - void setClasspath(String value); - String getClasspath(); - - String getLanguage(); -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java deleted file mode 100644 index ce0ac563b0a5..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import java.util.Vector; -import java.util.StringTokenizer; - -import java.io.*; -import java.beans.PropertyVetoException; -import java.awt.Dialog; - -import org.w3c.dom.Document; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import org.openide.TopManager; -import org.openide.DialogDescriptor; -import org.openide.ErrorManager; -import org.openide.xml.XMLUtil; -import org.openide.execution.NbClassPath; - -import org.openide.cookies.OpenCookie; -import org.openide.loaders.DataObject; -import org.openide.loaders.DataNode; - -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileSystem; -import org.openide.filesystems.JarFileSystem; -import org.openide.filesystems.FileUtil; -import org.openide.filesystems.Repository; - -import org.openide.nodes.*; -import org.openide.windows.OutputWriter; - -import org.openoffice.netbeans.modules.office.loader.ParcelFolder; -import org.openoffice.netbeans.modules.office.options.OfficeSettings; -import org.openoffice.netbeans.modules.office.utils.ManifestParser; - -import com.sun.star.script.framework.container.ParcelDescriptor; - -import org.openoffice.idesupport.zip.ParcelZipper; -import org.openoffice.idesupport.filter.FileFilter; -import org.openoffice.idesupport.ui.ConfigurePanel; - -public class ParcelFolderSupport implements ParcelFolderCookie { - protected ParcelFolder parcelFolder; - private ConfigurePanel configuror = null; - - public ParcelFolderSupport(ParcelFolder parcelFolder) { - this.parcelFolder = parcelFolder; - } - - public String getLanguage() { - ParcelDescriptor descriptor = getParcelDescriptor(); - - if (descriptor == null) { - return ""; - } else { - return descriptor.getLanguage(); - } - } - - public String getClasspath() { - ParcelDescriptor descriptor = getParcelDescriptor(); - - if (descriptor == null) { - return ""; - } else { - return descriptor.getLanguageProperty("classpath"); - } - } - - public void setClasspath(String value) { - ParcelDescriptor descriptor = getParcelDescriptor(); - - if (descriptor != null) { - descriptor.setLanguageProperty("classpath", value); - - try { - descriptor.write(); - } catch (IOException ioe) { - ErrorManager.getDefault().notify(ioe); - } - } - } - - private ParcelDescriptor getParcelDescriptor() { - FileObject primary = parcelFolder.getPrimaryFile(); - - File contents = FileUtil.toFile( - primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME)); - - return ParcelDescriptor.getParcelDescriptor(contents); - } - - public void generate() { - ParcelFolder.ParcelFolderNode node = - (ParcelFolder.ParcelFolderNode)parcelFolder.getNodeDelegate(); - - FileObject parcelBase = parcelFolder.getPrimaryFile(); - FileObject contentsBase = - parcelBase.getFileObject(ParcelZipper.CONTENTS_DIRNAME); - - File parcelDir = FileUtil.toFile(parcelBase); - File contentsDir = FileUtil.toFile(contentsBase); - - // The Location property is not displayed so just - // use the Parcel Recipe directory as the target directory - File targetDir = FileUtil.toFile(parcelFolder.getPrimaryFile()); - File targetfile = new File(targetDir, File.separator + - parcelBase.getName() + "." + ParcelZipper.PARCEL_EXTENSION); - - boolean proceed = configure(); - - if (!proceed) { - return; - } - - final OutputWriter out = - ParcelSupport.getOutputWindowWriter(parcelDir.getName() + " (generating)"); - - try { - out.println("Generating: " + parcelDir.getName(), null); - ParcelZipper.getParcelZipper().zipParcel(contentsDir, targetfile, - node.getFileFilter()); - out.println("\nGENERATION SUCCESSFUL."); - out.println("\nRight click on the generated parcel to deploy it"); - - if (targetDir.equals(parcelDir)) { - parcelBase.refresh(true); - } - } catch (IOException ioe) { - out.println("GENERATION FAILED: reason: " + ioe.getClass().getName() + ": " + - ioe.getMessage()); - } finally { - if (out != null) { - out.close(); - } - } - } - - public boolean configure() { - - FileObject primary = parcelFolder.getPrimaryFile(); - - File contents = FileUtil.toFile( - primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME)); - - ArrayList<String> classpath = getConfigureClasspath(); - classpath.add(contents.getAbsolutePath()); - - try { - ParcelDescriptor descriptor = getParcelDescriptor(); - - if (descriptor == null) { - descriptor = ParcelDescriptor.createParcelDescriptor(contents); - } - - if (configuror == null) { - configuror = new ConfigurePanel(contents.getAbsolutePath(), - classpath, descriptor); - } else { - configuror.reload(contents.getAbsolutePath(), classpath, - descriptor); - } - } catch (IOException ioe) { - ErrorManager.getDefault().notify(ioe); - return false; - } - - DialogDescriptor dd = new DialogDescriptor(configuror, - ConfigurePanel.DIALOG_TITLE); - - Dialog dialog = TopManager.getDefault().createDialog(dd); - dialog.show(); - - if (dd.getValue() == DialogDescriptor.OK_OPTION) { - try { - ParcelDescriptor descriptor = configuror.getConfiguration(); - descriptor.write(); - } catch (Exception e) { - ErrorManager.getDefault().notify(e); - } - } else { - return false; - } - - return true; - } - - private ArrayList<String> getConfigureClasspath() { - ArrayList<String> result = new ArrayList<String>(); - - String classpath = NbClassPath.createRepositoryPath().getClassPath(); - - if (System.getProperty("os.name").startsWith("Windows")) { - // under windows path is enclosed by quotes - // e.g. C:\path1;d:\path2 would appear as - // "C:\path1;d:\path2" therefore for us - // we need to remove 1 character at either end of the - // classpath returned from "createRepositoryPath().getClassPath()" - - if (classpath.startsWith("\"") && classpath.endsWith("\"")) { - StringBuffer buff = new StringBuffer(classpath); - buff.delete(0, 1); - buff.delete(buff.length() - 1, buff.length()); - classpath = buff.toString(); - } - } - - StringTokenizer tokens = new StringTokenizer(classpath, File.pathSeparator); - - while (tokens.hasMoreTokens()) - result.addElement(tokens.nextToken()); - - OfficeSettings settings = OfficeSettings.getDefault(); - File classesDir = new File(settings.getOfficeDirectory().getPath( - File.separator + "program" + File.separator + "classes")); - File[] jarfiles = classesDir.listFiles(); - - for (int i = 0; i < jarfiles.length; i++) - result.addElement(jarfiles[i].getAbsolutePath()); - - return result; - } -} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java deleted file mode 100644 index 381be44ccadb..000000000000 --- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.netbeans.modules.office.actions; - -import java.io.File; -import java.io.IOException; -import java.beans.PropertyVetoException; -import java.util.Enumeration; -import java.util.Calendar; - -import org.openide.TopManager; -import org.openide.NotifyDescriptor; -import org.openide.windows.OutputWriter; -import org.openide.windows.InputOutput; - -import org.openide.ErrorManager; -import org.openide.nodes.Node; -import org.openide.filesystems.Repository; -import org.openide.filesystems.FileSystem; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileUtil; -import org.openide.filesystems.FileEvent; - -import org.openoffice.idesupport.zip.ParcelZipper; - -import org.openoffice.netbeans.modules.office.options.OfficeSettings; -import org.openoffice.netbeans.modules.office.utils.NagDialog; -import org.openoffice.netbeans.modules.office.utils.ZipMounter; -import org.openoffice.netbeans.modules.office.utils.ManifestParser; - -public class ParcelSupport implements ParcelCookie { - private FileObject fo; - private ParcelZipper zipper = ParcelZipper.getParcelZipper(); - private String language = null; - - public ParcelSupport(FileObject fo) { - this.fo = fo; - } - - public File getFile() { - return FileUtil.toFile(fo); - } - - public String getLanguage() { - if (language == null) { - try { - language = zipper.getParcelLanguage(getFile()); - } catch (IOException ioe) { - return null; - } - } - - return language; - } - - public void mount() { - File parcel = FileUtil.toFile(fo); - - if (parcel != null) { - try { - ZipMounter.getZipMounter().mountZipFile(parcel); - } catch (IOException ioe) { - ErrorManager.getDefault().notify(ioe); - } catch (PropertyVetoException pve) { - ErrorManager.getDefault().notify(pve); - } - } - } - - public boolean deploy(File target) { - File source = FileUtil.toFile(fo); - - if (!target.isDirectory()) { - OfficeSettings settings = OfficeSettings.getDefault(); - String message = "If you already have this document open in " + - "Office, please close it before continuing. Click OK to " + - "continue deployment."; - - if (settings.getWarnBeforeDocDeploy()) { - NagDialog warning = NagDialog.createConfirmationDialog( - message, "Show this message in future", true); - - boolean result = warning.show(); - - if (!warning.getState()) - settings.setWarnBeforeDocDeploy(false); - - if (!result) - return false; - } - } - - OutputWriter out = - getOutputWindowWriter(fo.getName() + " (deploying)"); - - try { - if (!zipper.isOverwriteNeeded(source, target)) - if (!promptForOverwrite(source, target)) - 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); - - zipper.deployParcel(source, target); - - out.println("\nDEPLOYMENT SUCCESSFUL."); - - FileObject[] fileobjs = FileUtil.fromFile(target); - - if (fileobjs != null) { - for (int i = 0; i < fileobjs.length; i++) - fileobjs[i].refresh(true); - } - } catch (IOException ioe) { - out.println("DEPLOYMENT FAILED: reason: " + - ioe.getClass().getName() + ": " + ioe.getMessage()); - return false; - } finally { - if (out != null) - out.close(); - } - - return true; - } - - public static OutputWriter getOutputWindowWriter(String title) { - InputOutput io = TopManager.getDefault().getIO(title, false); - io.setFocusTaken(true); - io.setOutputVisible(true); - - OutputWriter out = io.getOut(); - - try { - out.reset(); - } catch (IOException e) { - e.printStackTrace(System.err); - } - - out.println(Calendar.getInstance().getTime() + ":\n"); - return out; - } - - private boolean promptForOverwrite(File source, File target) { - String message = source.getName() + " has already been deployed " + - "to this target. Do you wish to overwrite it?"; - - NotifyDescriptor d = new NotifyDescriptor.Confirmation( - message, NotifyDescriptor.OK_CANCEL_OPTION); - TopManager.getDefault().notify(d); - - return (d.getValue() != NotifyDescriptor.CANCEL_OPTION); - } -} |