2 * Copyright 2000-2009 JetBrains s.r.o.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com
.intellij
.ide
.fileTemplates
;
19 import com
.intellij
.openapi
.components
.ServiceManager
;
20 import com
.intellij
.openapi
.util
.Key
;
21 import org
.jetbrains
.annotations
.NonNls
;
22 import org
.jetbrains
.annotations
.NotNull
;
24 import java
.util
.Collection
;
25 import java
.util
.Properties
;
31 public abstract class FileTemplateManager
{
32 public static final Key
<Properties
> DEFAULT_TEMPLATE_PROPERTIES
= Key
.create("DEFAULT_TEMPLATE_PROPERTIES");
33 public static final int RECENT_TEMPLATES_SIZE
= 25;
35 @NonNls public static final String INTERNAL_HTML_TEMPLATE_NAME
= "Html";
36 @NonNls public static final String INTERNAL_XHTML_TEMPLATE_NAME
= "Xhtml";
37 @NonNls public static final String FILE_HEADER_TEMPLATE_NAME
= "File Header";
39 public static FileTemplateManager
getInstance(){
40 return ServiceManager
.getService(FileTemplateManager
.class);
43 @NotNull public abstract FileTemplate
[] getAllTemplates();
45 public abstract FileTemplate
getTemplate(@NotNull @NonNls String templateName
);
47 @NotNull public abstract Properties
getDefaultProperties();
50 * Creates a new template with specified name.
52 * @return created template
54 @NotNull public abstract FileTemplate
addTemplate(@NotNull @NonNls String name
, @NotNull @NonNls String extension
);
56 public abstract void removeTemplate(@NotNull FileTemplate template
, boolean fromDiskOnly
);
57 public abstract void removeInternal(@NotNull FileTemplate template
);
59 @NotNull public abstract Collection
<String
> getRecentNames();
61 public abstract void addRecentName(@NotNull @NonNls String name
);
63 public abstract void saveAll();
65 public abstract FileTemplate
getInternalTemplate(@NotNull @NonNls String templateName
);
66 @NotNull public abstract FileTemplate
[] getInternalTemplates();
68 public abstract FileTemplate
getJ2eeTemplate(@NotNull @NonNls String templateName
);
69 public abstract FileTemplate
getCodeTemplate(@NotNull @NonNls String templateName
);
71 @NotNull public abstract FileTemplate
[] getAllPatterns();
73 public abstract FileTemplate
addPattern(@NotNull @NonNls String name
, @NotNull @NonNls String extension
);
75 @NotNull public abstract FileTemplate
[] getAllCodeTemplates();
76 @NotNull public abstract FileTemplate
[] getAllJ2eeTemplates();
78 @NotNull public abstract FileTemplate
addCodeTemplate(@NotNull @NonNls String name
, @NotNull @NonNls String extension
);
79 @NotNull public abstract FileTemplate
addJ2eeTemplate(@NotNull @NonNls String name
, @NotNull @NonNls String extension
);
81 public abstract void removePattern(@NotNull FileTemplate template
, boolean fromDiskOnly
);
82 public abstract void removeCodeTemplate(@NotNull FileTemplate template
, boolean fromDiskOnly
);
83 public abstract void removeJ2eeTemplate(@NotNull FileTemplate template
, boolean fromDiskOnly
);
85 @NotNull public abstract String
internalTemplateToSubject(@NotNull @NonNls String templateName
);
87 @NotNull public abstract String
localizeInternalTemplateName(final FileTemplate template
);
89 public abstract FileTemplate
getPattern(@NotNull @NonNls String name
);
92 public abstract FileTemplate
getDefaultTemplate(@NotNull @NonNls String name
);
94 public abstract FileTemplate
addInternal(@NotNull @NonNls String name
, @NotNull @NonNls String extension
);