use new FileUtilRt.createFilterByExtension method
[idea/community.git] / plugins / ui-designer / jps-plugin / src / org / jetbrains / jps / uiDesigner / compiler / FormsBuilder.java
1 /*
2  * Copyright 2000-2012 JetBrains s.r.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.jetbrains.jps.uiDesigner.compiler;
17
18 import com.intellij.openapi.diagnostic.Logger;
19 import com.intellij.openapi.util.Key;
20 import com.intellij.openapi.util.io.FileUtilRt;
21 import org.jetbrains.annotations.NotNull;
22 import org.jetbrains.jps.incremental.BuilderCategory;
23 import org.jetbrains.jps.incremental.ModuleLevelBuilder;
24
25 import java.io.File;
26 import java.io.FileFilter;
27 import java.util.ArrayList;
28 import java.util.Collection;
29 import java.util.Map;
30
31 /**
32  * @author Eugene Zhuravlev
33  *         Date: 11/20/12
34  */
35 public abstract class FormsBuilder extends ModuleLevelBuilder {
36   protected static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.uiDesigner.compiler.FormsInstrumenter");
37   protected static final Key<Map<File, Collection<File>>> FORMS_TO_COMPILE = Key.create("_forms-to_compile_");
38   protected static final String FORM_EXTENSION = "form";
39   protected static final FileFilter JAVA_SOURCES_FILTER = FileUtilRt.createFilterByExtension("java");
40   protected static final FileFilter FORM_SOURCES_FILTER = FileUtilRt.createFilterByExtension(FORM_EXTENSION);
41
42   private final String myBuilderName;
43
44   public FormsBuilder(BuilderCategory category, String name) {
45     super(category);
46     myBuilderName = name;
47   }
48
49   @NotNull
50   @Override
51   public String getPresentableName() {
52     return myBuilderName;
53   }
54
55   protected static void addBinding(File srcFile, File form, Map<File, Collection<File>> container) {
56     Collection<File> forms = container.get(srcFile);
57     if (forms == null) {
58       forms = new ArrayList<File>();
59       container.put(srcFile, forms);
60     }
61     forms.add(form);
62   }
63 }