update copyright
[fedora-idea.git] / plugins / maven / src / main / java / org / jetbrains / idea / maven / vfs / MavenPropertiesVirtualFileSystem.java
blobe7d9d9b92f48ceec81296c291a589c22a09addb9
1 /*
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.
16 package org.jetbrains.idea.maven.vfs;
18 import com.intellij.openapi.application.ApplicationManager;
19 import com.intellij.openapi.components.ApplicationComponent;
20 import com.intellij.openapi.vfs.VirtualFile;
21 import com.intellij.openapi.vfs.ex.dummy.DummyFileSystem;
22 import gnu.trove.THashMap;
23 import org.jetbrains.annotations.NonNls;
24 import org.jetbrains.annotations.NotNull;
25 import org.jetbrains.annotations.Nullable;
26 import org.jetbrains.idea.maven.utils.MavenUtil;
28 import java.util.Map;
30 public class MavenPropertiesVirtualFileSystem extends DummyFileSystem implements ApplicationComponent {
31 @NonNls public static final String PROTOCOL = "maven-properties";
33 @NonNls public static final String SYSTEM_PROPERTIES_FILE = "System.properties";
34 @NonNls public static final String ENV_PROPERTIES_FILE = "Environment.properties";
36 public static final String[] PROPERTIES_FILES = new String[] { SYSTEM_PROPERTIES_FILE, ENV_PROPERTIES_FILE };
38 private final Map<String, VirtualFile> myFiles = new THashMap<String, VirtualFile>();
40 public static MavenPropertiesVirtualFileSystem getInstance() {
41 return ApplicationManager.getApplication().getComponent(MavenPropertiesVirtualFileSystem.class);
44 @NotNull
45 public String getComponentName() {
46 return MavenPropertiesVirtualFileSystem.class.getName();
49 public void initComponent() {
52 public void disposeComponent() {
55 @NotNull
56 public String getProtocol() {
57 return PROTOCOL;
60 //@Override
61 //public boolean isPhysical() {
62 // return false;
63 //}
65 public synchronized VirtualFile findFileByPath(@NotNull @NonNls String path) {
66 VirtualFile result = myFiles.get(path);
67 if (result != null) return result;
69 result = createFile(path);
70 if (result != null) {
71 myFiles.put(path, result);
73 return result;
76 @Nullable
77 private VirtualFile createFile(String path) {
78 if (SYSTEM_PROPERTIES_FILE.equals(path)) return new MavenPropertiesVirtualFile(path, MavenUtil.getSystemProperties(), this);
79 if (ENV_PROPERTIES_FILE.equals(path)) return new MavenPropertiesVirtualFile(path, MavenUtil.getEnvProperties(), this);
80 return null;
84 public void refresh(boolean asynchronous) {
87 public VirtualFile refreshAndFindFileByPath(@NotNull String path) {
88 return findFileByPath(path);
91 //protected void deleteFile(Object requestor, VirtualFile vFile) throws IOException {
92 // throw new UnsupportedOperationException();
93 //}
95 //protected void moveFile(Object requestor, VirtualFile vFile, VirtualFile newParent) throws IOException {
96 // throw new UnsupportedOperationException();
97 //}
99 //protected void renameFile(Object requestor, VirtualFile vFile, String newName) throws IOException {
100 // throw new UnsupportedOperationException();
103 //protected VirtualFile createChildFile(Object requestor, VirtualFile vDir, String fileName) throws IOException {
104 // throw new UnsupportedOperationException();
107 //protected VirtualFile createChildDirectory(Object requestor, VirtualFile vDir, String dirName) throws IOException {
108 // throw new UnsupportedOperationException();
111 //protected VirtualFile copyFile(Object requestor, VirtualFile virtualFile, VirtualFile newParent, String copyName)
112 // throws IOException {
113 // throw new UnsupportedOperationException();