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.filesystem; 25 26 import java.awt.Image; 27 import java.io.File; 28 import java.beans.*; 29 30 import org.openide.ErrorManager; 31 import org.openide.filesystems.FileSystem; 32 import org.openide.util.NbBundle; 33 import org.openide.util.Utilities; 34 35 /** 36 * Description of the OpenOffice.org Document filesystem. 37 * 38 * @author misha <misha@openoffice.org> 39 */ 40 public class OpenOfficeDocFileSystemBeanInfo 41 extends SimpleBeanInfo 42 { 43 private static String ICONLOCATION = 44 "org/openoffice/netbeans/modules/office/resources"; 45 private static String COLORICON16NAME = 46 ICONLOCATION + File.separator + "OpenOfficeDocFileSystemIcon.png"; 47 private static String COLORICON32NAME = 48 ICONLOCATION + File.separator + "OpenOfficeDocFileSystemIcon32.png"; 49 50 /** 51 * Retrieves an additional bean information. 52 */ getAdditionalBeanInfo()53 public BeanInfo[] getAdditionalBeanInfo() 54 { 55 try { 56 return new BeanInfo[] { 57 Introspector.getBeanInfo(FileSystem.class) 58 }; 59 } catch (IntrospectionException ie) { 60 ErrorManager.getDefault().notify(ie); 61 return null; 62 } 63 } 64 /* 65 // If you have a visual dialog to customize configuration of the 66 // filesystem: 67 public BeanDescriptor getBeanDescriptor() 68 { 69 return new BeanDescriptor(OpenOfficeDocFileSystem.class, 70 OpenOfficeDocFileSystemCustomizer.class); 71 } 72 */ 73 /** 74 * Retrieves bean property descriptors. 75 */ getPropertyDescriptors()76 public PropertyDescriptor[] getPropertyDescriptors() 77 { 78 try { 79 // Included only to make it a writable property (it is read-only 80 // in FileSystem): 81 PropertyDescriptor readOnly = new PropertyDescriptor( 82 "readOnly", OpenOfficeDocFileSystem.class); 83 readOnly.setDisplayName(NbBundle.getMessage( 84 OpenOfficeDocFileSystemBeanInfo.class, "PROP_readOnly")); 85 readOnly.setShortDescription(NbBundle.getMessage( 86 OpenOfficeDocFileSystemBeanInfo.class, "HINT_readOnly")); 87 88 // This could be whatever properties you use to configure the 89 // filesystem: 90 PropertyDescriptor document = new PropertyDescriptor( 91 "Document", OpenOfficeDocFileSystem.class); 92 document.setDisplayName(NbBundle.getMessage( 93 OpenOfficeDocFileSystemBeanInfo.class, "PROP_document")); 94 document.setShortDescription(NbBundle.getMessage( 95 OpenOfficeDocFileSystemBeanInfo.class, "HINT_document")); 96 // Request to the property editor that it be permitted only to 97 // choose directories: 98 document.setValue("directories", Boolean.FALSE); // NOI18N 99 document.setValue("files", Boolean.TRUE); // NOI18N 100 101 return new PropertyDescriptor[] {readOnly, document}; 102 } catch (IntrospectionException ie) { 103 ErrorManager.getDefault().notify(ie); 104 return null; 105 } 106 } 107 108 /** 109 * Retrieves an icon by the icon type. 110 */ getIcon(int type)111 public Image getIcon(int type) 112 { 113 if((type == BeanInfo.ICON_COLOR_16x16) || 114 (type == BeanInfo.ICON_MONO_16x16)) { 115 return Utilities.loadImage(COLORICON16NAME); 116 } else { 117 return Utilities.loadImage(COLORICON32NAME); 118 } 119 } 120 121 } 122