Updated version of the VFS sample plugin.
authorAlexey <Alexey.Chursin@jetbrains.com>
Thu, 2 Sep 2010 17:13:09 +0000 (21:13 +0400)
committerAlexey <Alexey.Chursin@jetbrains.com>
Thu, 2 Sep 2010 17:22:03 +0000 (21:22 +0400)
samples/vfs/build/build.xml [deleted file]
samples/vfs/src/META-INF/plugin.xml
samples/vfs/src/com/intellij/openapi/samples/VfsSamplePlugin.java [deleted file]
samples/vfs/src/myVFS/VfsSamplePlugin.java [new file with mode: 0644]
samples/vfs/vfs.iml
samples/vfs/vfs.ipr

diff --git a/samples/vfs/build/build.xml b/samples/vfs/build/build.xml
deleted file mode 100644 (file)
index fe6278a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<project name="deploy" default="jar_plugin" basedir="..">
-  <property name="plugname" value="VfsSample"/>
-  <property name="build.path" value="${project.path}/build_out"/>
-
-  <target name="jar_plugin">
-
-    <delete includeEmptyDirs="true" failonerror="false">
-      <fileset dir="${build.path}/com" />
-      <fileset dir="${build.path}/META-INF" />
-    </delete>
-
-    <mkdir dir="${build.path}"/>
-
-    <copy todir="${build.path}/META-INF">
-       <fileset dir="${project.path}/src/META-INF"/>
-    </copy>
-
-    <copy todir="${build.path}/com">
-       <fileset dir="${project.path}/classes/com"/>
-    </copy>
-
-    <jar jarfile="${build.path}/${plugname}.jar" basedir="${build.path}"
-      excludes="${plugname}.jar"/>
-
-  </target>
-</project>
\ No newline at end of file
index eb43ce4e4b4ae494ebaceff8fe9b4100b7aa0ff1..ff45e7859720710c076237f22b60b771565a66e3 100644 (file)
@@ -4,7 +4,7 @@
   <name>VfsSample</name>
 
   <!-- Description -->
-  <description>An example of using IDEA's virtual file system, dynamically keeps the count of Java files in sourcepaths</description>
+  <description>This plugin monitors the number of Java files in sourcepaths.</description>
 
   <!-- Plugin version -->
   <version>1.0</version>
   <vendor logo="/general/ijLogo.png">IntelliJ</vendor>
 
   <!-- Minimum IDEA build number with which the plugin is compatible -->
+    <!--
   <idea-version since-build="2000"/>
-
+       -->
   <!-- Plugin's application components -->
   <project-components>
     <component>
       <!-- Component's implementation class -->
-      <implementation-class>com.intellij.openapi.samples.VfsSamplePlugin</implementation-class>
+      <implementation-class> myVFS.VfsSamplePlugin</implementation-class>
       <!-- Component's interface class -->
-      <interface-class>com.intellij.openapi.samples.VfsSamplePlugin</interface-class>
+      <interface-class> myVFS.VfsSamplePlugin</interface-class>
     </component>
   </project-components>
 </idea-plugin>
diff --git a/samples/vfs/src/com/intellij/openapi/samples/VfsSamplePlugin.java b/samples/vfs/src/com/intellij/openapi/samples/VfsSamplePlugin.java
deleted file mode 100644 (file)
index e839231..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2000-2005 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.openapi.samples;
-
-import com.intellij.openapi.components.ProjectComponent;
-import com.intellij.openapi.fileTypes.FileTypeManager;
-import com.intellij.openapi.fileTypes.StdFileTypes;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileAdapter;
-import com.intellij.openapi.vfs.VirtualFileEvent;
-import com.intellij.openapi.vfs.VirtualFileManager;
-import org.jetbrains.annotations.NotNull;
-
-public class VfsSamplePlugin implements ProjectComponent {
-  private final Project myProject;
-
-  private static int ourJavaFilesCount;
-
-  public VfsSamplePlugin(Project project) {
-    myProject = project;
-  }
-
-  public void projectOpened() {
-    ProjectRootManager projectRootManager = ProjectRootManager.getInstance(myProject);
-    VirtualFile[] sourceRoots = projectRootManager.getContentSourceRoots();
-
-    ourJavaFilesCount = 0;
-
-    for (VirtualFile sourceRoot : sourceRoots) {
-      countJavaFiles(sourceRoot);
-    }
-
-    MyVfsListener vfsListener = new MyVfsListener();
-    VirtualFileManager.getInstance().addVirtualFileListener(vfsListener,myProject);
-  }
-
-  public void projectClosed() {
-  }
-
-  public void initComponent() {
-    // empty
-  }
-
-  public void disposeComponent() {
-    // empty
-  }
-
- @NotNull
-  public String getComponentName() {
-    return "VfsSample.VfsSamplePlugin";
-  }
-
-  private static void updateCount(VirtualFile file, int increase) {
-    FileTypeManager fileTypeManager = FileTypeManager.getInstance();
-    if (!fileTypeManager.isFileIgnored(file.getName())
-      && fileTypeManager.getFileTypeByFile(file) == StdFileTypes.JAVA) {
-      ourJavaFilesCount += increase;
-      //System.out.println("ourJavaFilesCount = " + ourJavaFilesCount);
-    }
-  }
-
-  private static void countJavaFiles(VirtualFile virtualFile) {
-    VirtualFile[] children = virtualFile.getChildren();
-    if (children == null) return;
-
-    for (VirtualFile child : children) {
-      updateCount(child, +1);
-      countJavaFiles(child);
-    }
-    
-  }
-
-  // -------------------------------------------------------------------------
-  // MyVfsListener
-  // -------------------------------------------------------------------------
-
-  private static class MyVfsListener extends VirtualFileAdapter {
-    public void fileCreated(VirtualFileEvent event) {
-      updateCount(event.getFile(), +1);
-        Messages.showMessageDialog("A new Java file added. Now " + String.valueOf(ourJavaFilesCount) +
-                                   " Java files in this project.","Notification", Messages.getInformationIcon() );
-    }
-
-    public void fileDeleted(VirtualFileEvent event) {
-      updateCount(event.getFile(), -1);
-         Messages.showMessageDialog("A Java file deleted. Now " + String.valueOf(ourJavaFilesCount) +
-                                   " Java files in this project.","Notification", Messages.getInformationIcon() );
-    }
-  }
-}
diff --git a/samples/vfs/src/myVFS/VfsSamplePlugin.java b/samples/vfs/src/myVFS/VfsSamplePlugin.java
new file mode 100644 (file)
index 0000000..6e3b8fa
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2000-2005 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package myVFS;
+
+import com.intellij.openapi.components.ProjectComponent;
+import com.intellij.openapi.fileTypes.FileTypeManager;
+import com.intellij.openapi.fileTypes.StdFileTypes;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileAdapter;
+import com.intellij.openapi.vfs.VirtualFileEvent;
+import com.intellij.openapi.vfs.VirtualFileManager;
+import org.jetbrains.annotations.NotNull;
+
+public class VfsSamplePlugin implements ProjectComponent {
+    private final Project myProject;
+
+    private static int ourJavaFilesCount;
+
+    public VfsSamplePlugin(Project project) {
+        myProject = project;
+    }
+
+    public void projectOpened() {
+        ProjectRootManager projectRootManager = ProjectRootManager.getInstance(myProject);
+        VirtualFile[] sourceRoots = projectRootManager.getContentSourceRoots();
+
+        ourJavaFilesCount = 0;
+         // Count the current number of Java files in the opened project.
+        for (VirtualFile sourceRoot : sourceRoots) {
+            countJavaFiles(sourceRoot);
+        }
+         // Add the Virtual File listener
+        MyVfsListener vfsListener = new MyVfsListener();
+        VirtualFileManager.getInstance().addVirtualFileListener(vfsListener, myProject);
+    }
+
+    public void projectClosed() {
+    }
+
+    public void initComponent() {
+        // empty
+    }
+
+    public void disposeComponent() {
+        // empty
+    }
+
+    @NotNull
+    public String getComponentName() {
+        return "VfsSample.VfsSamplePlugin";
+    }
+         // Increase or decrease the current number of Java files. Return true when a Java file has been added or removed from the opened project.
+    private static boolean updateCount(VirtualFile file, int increase) {
+
+        FileTypeManager fileTypeManager = FileTypeManager.getInstance();
+        if (!fileTypeManager.isFileIgnored(file.getName())
+                && fileTypeManager.getFileTypeByFile(file) == StdFileTypes.JAVA) {
+            ourJavaFilesCount += increase;
+            return true;
+            //System.out.println("ourJavaFilesCount = " + ourJavaFilesCount);
+        }
+        return false;
+    }
+         // Count current number of Java file in the project.
+    private static void countJavaFiles(VirtualFile virtualFile) {
+        VirtualFile[] children = virtualFile.getChildren();
+        if (children == null) return;
+
+        for (VirtualFile child : children) {
+            updateCount(child, +1);
+            countJavaFiles(child);
+        }
+
+    }
+
+    // -------------------------------------------------------------------------
+    // MyVfsListener
+    // -------------------------------------------------------------------------
+
+    private static class MyVfsListener extends VirtualFileAdapter {
+        public void fileCreated(VirtualFileEvent event) {
+            if (updateCount(event.getFile(), +1)) {
+                Messages.showMessageDialog("A new Java file added. Now " + String.valueOf(ourJavaFilesCount) +
+                        " Java files in this project.", "Notification", Messages.getInformationIcon());
+            }
+        }
+
+        public void fileDeleted(VirtualFileEvent event) {
+            if (updateCount(event.getFile(), -1)) {
+                Messages.showMessageDialog("A Java file deleted. Now " + String.valueOf(ourJavaFilesCount) +
+                        " Java files in this project.", "Notification", Messages.getInformationIcon());
+            }
+        }
+    }
+}
index 74945e395e446c3ad0e90958b798e9ece6877b9f..09647c68eae8c29c7f909d64c7c117197b74eef7 100644 (file)
@@ -1,13 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<module relativePaths="true" type="PLUGIN_MODULE" version="4">
+<module type="PLUGIN_MODULE" version="4">
   <component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/src/META-INF/plugin.xml" />
-  <component name="NewModuleRootManager" inherit-compiler-output="false">
-    <output url="file://$MODULE_DIR$/classes" />
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
     </content>
-    <orderEntry type="inheritedJdk" />
+    <orderEntry type="jdk" jdkName="IDEA IC-96.1068" jdkType="IDEA JDK" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
 </module>
index 94cc51f0f8b529b74fd3f51734eb71309a9b6c36..5b460280c13b5ff7c0d6bb53aa9da944b9eb587f 100644 (file)
     <wildcardResourcePatterns>
       <entry name="?*.properties" />
       <entry name="?*.xml" />
-      <entry name="?*.html" />
-      <entry name="?*.dtd" />
-      <entry name="?*.tld" />
       <entry name="?*.gif" />
       <entry name="?*.png" />
       <entry name="?*.jpeg" />
       <entry name="?*.jpg" />
+      <entry name="?*.html" />
+      <entry name="?*.dtd" />
+      <entry name="?*.tld" />
+      <entry name="?*.ftl" />
     </wildcardResourcePatterns>
     <annotationProcessing enabled="false" useClasspath="true" />
   </component>
   <component name="CopyrightManager" default="">
     <module2copyright />
   </component>
-  <component name="DependenciesAnalyzeManager">
-    <option name="myForwardDirection" value="false" />
-  </component>
   <component name="DependencyValidationManager">
     <option name="SKIP_IMPORT_STATEMENTS" value="false" />
   </component>
   <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
-  <component name="EntryPointsManager">
-    <entry_points />
-  </component>
-  <component name="ExportToHTMLSettings">
-    <option name="PRINT_LINE_NUMBERS" value="false" />
-    <option name="OPEN_IN_BROWSER" value="false" />
-    <option name="OUTPUT_DIRECTORY" />
+  <component name="Git.Settings">
+    <option name="GIT_EXECUTABLE" value="C:\Program Files (x86)\Git\bin\git.exe" />
+    <option name="CHECKOUT_INCLUDE_TAGS" value="false" />
+    <option name="UPDATE_CHANGES_POLICY" value="STASH" />
   </component>
   <component name="JavadocGenerationManager">
     <option name="OUTPUT_DIRECTORY" />
       <module fileurl="file://$PROJECT_DIR$/vfs.iml" filepath="$PROJECT_DIR$/vfs.iml" />
     </modules>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA IC-96.705" project-jdk-type="IDEA JDK" />
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA IC-96.1068" project-jdk-type="IDEA JDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+  <component name="SvnConfiguration" maxAnnotateRevisions="500">
+    <option name="USER" value="" />
+    <option name="PASSWORD" value="" />
+    <option name="LAST_MERGED_REVISION" />
+    <option name="UPDATE_RUN_STATUS" value="false" />
+    <option name="MERGE_DRY_RUN" value="false" />
+    <option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
+    <option name="UPDATE_LOCK_ON_DEMAND" value="false" />
+    <option name="IGNORE_SPACES_IN_MERGE" value="false" />
+    <option name="DETECT_NESTED_COPIES" value="true" />
+    <option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
+    <option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
+    <option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
+    <myIsUseDefaultProxy>false</myIsUseDefaultProxy>
+  </component>
   <component name="VcsDirectoryMappings">
     <mapping directory="" vcs="" />
   </component>
-  <component name="copyright">
-    <option name="body" value="/*&#10; * Copyright (c) $today.year Your Corporation. All Rights Reserved.&#10; */" />
-    <option name="location" value="1" />
-    <option name="remove" value="true" />
-    <option name="replace" value="2" />
+  <component name="masterDetails">
+    <states>
+      <state key="ArtifactsStructureConfigurable.UI">
+        <UIState>
+          <splitter-proportions>
+            <SplitterProportionsDataImpl />
+          </splitter-proportions>
+          <settings />
+        </UIState>
+      </state>
+      <state key="Copyright.UI">
+        <UIState>
+          <splitter-proportions>
+            <SplitterProportionsDataImpl />
+          </splitter-proportions>
+        </UIState>
+      </state>
+      <state key="ProjectJDKs.UI">
+        <UIState>
+          <splitter-proportions>
+            <SplitterProportionsDataImpl>
+              <option name="proportions">
+                <list>
+                  <option value="0.2" />
+                </list>
+              </option>
+            </SplitterProportionsDataImpl>
+          </splitter-proportions>
+          <last-edited>IDEA IC-96.705</last-edited>
+        </UIState>
+      </state>
+      <state key="ScopeChooserConfigurable.UI">
+        <UIState>
+          <splitter-proportions>
+            <SplitterProportionsDataImpl />
+          </splitter-proportions>
+          <settings />
+        </UIState>
+      </state>
+    </states>
   </component>
 </project>