1cd519653SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3cd519653SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4cd519653SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5cd519653SAndrew Rist  * distributed with this work for additional information
6cd519653SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7cd519653SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8cd519653SAndrew Rist  * "License"); you may not use this file except in compliance
9cd519653SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cd519653SAndrew Rist  *
11cd519653SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cd519653SAndrew Rist  *
13cd519653SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14cd519653SAndrew Rist  * software distributed under the License is distributed on an
15cd519653SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16cd519653SAndrew Rist  * KIND, either express or implied.  See the License for the
17cd519653SAndrew Rist  * specific language governing permissions and limitations
18cd519653SAndrew Rist  * under the License.
19cd519653SAndrew Rist  *
20cd519653SAndrew Rist  *************************************************************/
21cd519653SAndrew Rist 
22cd519653SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package org.openoffice.netbeans.modules.office.filesystem;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import java.awt.Image;
27cdf0e10cSrcweir import java.io.File;
28cdf0e10cSrcweir import java.beans.*;
29cdf0e10cSrcweir 
30cdf0e10cSrcweir import org.openide.ErrorManager;
31cdf0e10cSrcweir import org.openide.filesystems.FileSystem;
32cdf0e10cSrcweir import org.openide.util.NbBundle;
33cdf0e10cSrcweir import org.openide.util.Utilities;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /**
36cdf0e10cSrcweir  * Description of the OpenOffice.org Document filesystem.
37cdf0e10cSrcweir  *
38cdf0e10cSrcweir  * @author misha <misha@openoffice.org>
39cdf0e10cSrcweir  */
40cdf0e10cSrcweir public class OpenOfficeDocFileSystemBeanInfo
41cdf0e10cSrcweir     extends SimpleBeanInfo
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     private static String ICONLOCATION =
44cdf0e10cSrcweir         "org/openoffice/netbeans/modules/office/resources";
45cdf0e10cSrcweir     private static String COLORICON16NAME =
46cdf0e10cSrcweir         ICONLOCATION + File.separator + "OpenOfficeDocFileSystemIcon.png";
47cdf0e10cSrcweir     private static String COLORICON32NAME =
48cdf0e10cSrcweir         ICONLOCATION + File.separator + "OpenOfficeDocFileSystemIcon32.png";
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     /**
51*8cc42d09Smseidel      * Retrieves an additional bean information.
52cdf0e10cSrcweir      */
getAdditionalBeanInfo()53cdf0e10cSrcweir     public BeanInfo[] getAdditionalBeanInfo()
54cdf0e10cSrcweir     {
55cdf0e10cSrcweir         try {
56cdf0e10cSrcweir             return new BeanInfo[] {
57cdf0e10cSrcweir                 Introspector.getBeanInfo(FileSystem.class)
58cdf0e10cSrcweir             };
59cdf0e10cSrcweir         } catch (IntrospectionException ie) {
60cdf0e10cSrcweir             ErrorManager.getDefault().notify(ie);
61cdf0e10cSrcweir             return null;
62cdf0e10cSrcweir         }
63cdf0e10cSrcweir     }
64cdf0e10cSrcweir /*
65cdf0e10cSrcweir     // If you have a visual dialog to customize configuration of the
66cdf0e10cSrcweir     // filesystem:
67cdf0e10cSrcweir     public BeanDescriptor getBeanDescriptor()
68cdf0e10cSrcweir     {
69cdf0e10cSrcweir         return new BeanDescriptor(OpenOfficeDocFileSystem.class,
70cdf0e10cSrcweir             OpenOfficeDocFileSystemCustomizer.class);
71cdf0e10cSrcweir     }
72cdf0e10cSrcweir */
73cdf0e10cSrcweir     /**
74*8cc42d09Smseidel      * Retrieves bean property descriptors.
75cdf0e10cSrcweir      */
getPropertyDescriptors()76cdf0e10cSrcweir     public PropertyDescriptor[] getPropertyDescriptors()
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         try {
79cdf0e10cSrcweir             // Included only to make it a writable property (it is read-only
80cdf0e10cSrcweir             // in FileSystem):
81cdf0e10cSrcweir             PropertyDescriptor readOnly = new PropertyDescriptor(
82cdf0e10cSrcweir                 "readOnly", OpenOfficeDocFileSystem.class);
83cdf0e10cSrcweir             readOnly.setDisplayName(NbBundle.getMessage(
84cdf0e10cSrcweir                 OpenOfficeDocFileSystemBeanInfo.class, "PROP_readOnly"));
85cdf0e10cSrcweir             readOnly.setShortDescription(NbBundle.getMessage(
86cdf0e10cSrcweir                 OpenOfficeDocFileSystemBeanInfo.class, "HINT_readOnly"));
87cdf0e10cSrcweir 
88cdf0e10cSrcweir             // This could be whatever properties you use to configure the
89cdf0e10cSrcweir             // filesystem:
90cdf0e10cSrcweir             PropertyDescriptor document = new PropertyDescriptor(
91cdf0e10cSrcweir                 "Document", OpenOfficeDocFileSystem.class);
92cdf0e10cSrcweir             document.setDisplayName(NbBundle.getMessage(
93cdf0e10cSrcweir                 OpenOfficeDocFileSystemBeanInfo.class, "PROP_document"));
94cdf0e10cSrcweir             document.setShortDescription(NbBundle.getMessage(
95cdf0e10cSrcweir                 OpenOfficeDocFileSystemBeanInfo.class, "HINT_document"));
96cdf0e10cSrcweir             // Request to the property editor that it be permitted only to
97cdf0e10cSrcweir             // choose directories:
98cdf0e10cSrcweir             document.setValue("directories", Boolean.FALSE);    // NOI18N
99cdf0e10cSrcweir             document.setValue("files", Boolean.TRUE);           // NOI18N
100cdf0e10cSrcweir 
101cdf0e10cSrcweir             return new PropertyDescriptor[] {readOnly, document};
102cdf0e10cSrcweir         } catch (IntrospectionException ie) {
103cdf0e10cSrcweir             ErrorManager.getDefault().notify(ie);
104cdf0e10cSrcweir             return null;
105cdf0e10cSrcweir         }
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     /**
109*8cc42d09Smseidel      * Retrieves an icon by the icon type.
110cdf0e10cSrcweir      */
getIcon(int type)111cdf0e10cSrcweir     public Image getIcon(int type)
112cdf0e10cSrcweir     {
113cdf0e10cSrcweir         if((type == BeanInfo.ICON_COLOR_16x16) ||
114cdf0e10cSrcweir             (type == BeanInfo.ICON_MONO_16x16)) {
115cdf0e10cSrcweir             return Utilities.loadImage(COLORICON16NAME);
116cdf0e10cSrcweir         } else {
117cdf0e10cSrcweir             return Utilities.loadImage(COLORICON32NAME);
118cdf0e10cSrcweir         }
119cdf0e10cSrcweir     }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir }
122