]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/IFileFilter.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / IFileFilter.java
1 /** @file
2
3 The file is used to override FileFilter to provides customized interfaces
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 package org.tianocore.frameworkwizard.common;
17
18 import java.io.File;
19
20 import javax.swing.filechooser.FileFilter;
21
22 /**
23 The class is used to override FileFilter to provides customized interfaces
24
25 **/
26 public class IFileFilter extends FileFilter {
27
28 private String strExt;
29
30 /**
31 Reserved for test
32
33 @param args
34
35 **/
36 public static void main(String[] args) {
37 // TODO Auto-generated method stub
38
39 }
40
41 /**
42 This is the default constructor
43
44 @param ext
45
46 **/
47 public IFileFilter(String ext) {
48 this.strExt = ext;
49 }
50
51 /* (non-Javadoc)
52 * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
53 *
54 * Override method "accept"
55 *
56 */
57 public boolean accept(File file) {
58 if (file.isDirectory()) {
59 return true;
60 }
61 String strFileName = file.getName();
62 int intIndex = strFileName.lastIndexOf('.');
63 if (intIndex > 0 && intIndex < strFileName.length() - 1) {
64 String strExtension = strFileName.substring(intIndex + 1).toLowerCase();
65 if (strExtension.equals(strExt))
66 return true;
67 }
68 return false;
69 }
70
71 /* (non-Javadoc)
72 * @see javax.swing.filechooser.FileFilter#getDescription()
73 *
74 * Override method "getDescription" to config description via different file type
75 *
76 */
77 public String getDescription() {
78 if (strExt.equals(DataType.MODULE_SURFACE_AREA_EXT))
79 return DataType.MODULE_SURFACE_AREA_EXT_DESCRIPTION;
80 if (strExt.equals(DataType.PACKAGE_SURFACE_AREA_EXT))
81 return DataType.PACKAGE_SURFACE_AREA_EXT_DESCRIPTION;
82 if (strExt.equals(DataType.PLATFORM_SURFACE_AREA_EXT))
83 return DataType.PLATFORM_SURFACE_AREA_EXT_DESCRIPTION;
84 if (strExt.equals(DataType.TEXT_FILE_EXT))
85 return DataType.TEXT_FILE_EXT_DESCRIPTION;
86 if (strExt.equals(DataType.FAR_SURFACE_AREA_EXT))
87 return DataType.FAR_SURFACE_AREA_EXT_DESCRIPTION;
88 return "";
89 }
90
91 }