merge the formfield patch from ooo-build
[ooovba.git] / scripting / java / org / openoffice / netbeans / modules / office / loader / ParcelDataNode.java
blob8ae74deba4802ca2c63736ed08a79c8a1f2c465d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ParcelDataNode.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package org.openoffice.netbeans.modules.office.loader;
33 import java.io.*;
34 import java.awt.datatransfer.Transferable;
35 import java.util.zip.*;
37 import org.openide.loaders.*;
38 import org.openide.nodes.*;
39 import org.openide.filesystems.FileObject;
40 import org.openide.util.NbBundle;
41 import org.openide.util.datatransfer.*;
42 import org.openide.ErrorManager;
43 import org.openide.windows.OutputWriter;
45 import org.openoffice.netbeans.modules.office.actions.ParcelCookie;
47 /** A node to represent this object.
49 * @author tomaso
51 public class ParcelDataNode extends DataNode {
53 public ParcelDataNode(ParcelDataObject obj) {
54 this(obj, Children.LEAF);
57 public ParcelDataNode(ParcelDataObject obj, Children ch) {
58 super(obj, ch);
59 setIconBase("/org/openoffice/netbeans/modules/office/resources/ParcelIcon");
62 protected ParcelDataObject getParcelDataObject() {
63 return (ParcelDataObject)getDataObject();
66 public static class ParcelPasteType extends PasteType {
67 ParcelDataNode sourceParcel = null;
68 File targetDocument = null;
69 boolean isCut = false;
71 public ParcelPasteType(ParcelDataNode sourceParcel,
72 File targetDocument, boolean isCut) {
73 this.sourceParcel = sourceParcel;
74 this.targetDocument = targetDocument;
75 this.isCut = isCut;
78 public Transferable paste() {
79 ParcelCookie parcelCookie =
80 (ParcelCookie)sourceParcel.getCookie(ParcelCookie.class);
81 parcelCookie.deploy(targetDocument);
83 if (isCut == true) {
84 FileObject fo = sourceParcel.getDataObject().getPrimaryFile();
85 try {
86 fo.delete();
88 catch (IOException ioe) {}
89 return ExTransferable.EMPTY;
91 else {
92 return null;
97 /* Example of adding Executor / Debugger / Arguments to node:
98 protected Sheet createSheet() {
99 Sheet sheet = super.createSheet();
100 Sheet.Set set = sheet.get(ExecSupport.PROP_EXECUTION);
101 if (set == null) {
102 set = new Sheet.Set();
103 set.setName(ExecSupport.PROP_EXECUTION);
104 set.setDisplayName(NbBundle.getMessage(ParcelDataNode.class, "LBL_DataNode_exec_sheet"));
105 set.setShortDescription(NbBundle.getMessage(ParcelDataNode.class, "HINT_DataNode_exec_sheet"));
107 ((ExecSupport)getCookie(ExecSupport.class)).addProperties(set);
108 // Maybe:
109 ((CompilerSupport)getCookie(CompilerSupport.class)).addProperties(set);
110 sheet.put(set);
111 return sheet;
115 // Don't use getDefaultAction(); just make that first in the data loader's getActions list