1  /**************************************************************
2   *
3   * Licensed to the Apache Software Foundation (ASF) under one
4   * or more contributor license agreements.  See the NOTICE file
5   * distributed with this work for additional information
6   * regarding copyright ownership.  The ASF licenses this file
7   * to you under the Apache License, Version 2.0 (the
8   * "License"); you may not use this file except in compliance
9   * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   *
20   *************************************************************/
21  
22  
23  
24  package org.openoffice.netbeans.modules.office.loader;
25  
26  import java.io.IOException;
27  import java.io.File;
28  
29  import org.openide.actions.*;
30  import org.openide.filesystems.*;
31  import org.openide.loaders.*;
32  import org.openide.util.NbBundle;
33  import org.openide.util.actions.SystemAction;
34  
35  import org.openoffice.idesupport.zip.ParcelZipper;
36  import org.openoffice.netbeans.modules.office.actions.*;
37  
38  /** Recognizes single files in the Repository as being of a certain type.
39   *
40   * @author tomaso
41   */
42  
43  public class ParcelFolderDataLoader extends UniFileLoader {
44  
ParcelFolderDataLoader()45      public ParcelFolderDataLoader() {
46          this("org.openoffice.netbeans.modules.office.loader.ParcelFolder");
47      }
48  
ParcelFolderDataLoader(String recognizedObjectClass)49      protected ParcelFolderDataLoader(String recognizedObjectClass) {
50          super(recognizedObjectClass);
51      }
52  
defaultDisplayName()53      protected String defaultDisplayName() {
54          return "Office Script Parcel Folder";
55      }
56  
initialize()57      protected void initialize() {
58          super.initialize();
59      }
60  
findPrimaryFile(FileObject fo)61      protected FileObject findPrimaryFile(FileObject fo) {
62          if (fo.isFolder() == false)
63              return null;
64  
65          FileObject contents = fo.getFileObject(ParcelZipper.CONTENTS_DIRNAME);
66          if (contents == null)
67              return null;
68  
69          FileObject descriptor = contents.getFileObject(ParcelZipper.PARCEL_DESCRIPTOR_XML);
70          if (descriptor == null)
71              return null;
72  
73          return fo;
74      }
75  
defaultActions()76      protected SystemAction[] defaultActions() {
77          return new SystemAction[] {
78              // SystemAction.get(OpenLocalExplorerAction.class),
79              // SystemAction.get(FindAction.class),
80              // null,
81              // SystemAction.get(FileSystemAction.class),
82              // null,
83              SystemAction.get(CompileParcelAction.class),
84              SystemAction.get(BuildParcelAction.class),
85              SystemAction.get(ConfigureParcelAction.class),
86              null,
87              SystemAction.get(CutAction.class),
88              SystemAction.get(CopyAction.class),
89              // SystemAction.get(PasteAction.class),
90              null,
91              SystemAction.get(DeleteAction.class),
92              SystemAction.get(RenameAction.class),
93              null,
94              // SystemAction.get(SaveAsTemplateAction.class),
95              // null,
96              // SystemAction.get(ToolsAction.class),
97              SystemAction.get(PropertiesAction.class),
98          };
99      }
100  
createMultiObject(FileObject primaryFile)101      protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
102          return new ParcelFolder(primaryFile, this);
103      }
104  
createPrimaryEntry(MultiDataObject obj, FileObject primaryFile)105      protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
106          return new FileEntry.Folder(obj, primaryFile);
107      }
108  }
109