mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Updated version of the VFS sample plugin.
This commit is contained in:
@@ -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>
|
||||
@@ -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>
|
||||
@@ -13,15 +13,16 @@
|
||||
<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>
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -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>
|
||||
|
||||
+66
-19
@@ -12,33 +12,28 @@
|
||||
<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" />
|
||||
@@ -183,15 +178,67 @@
|
||||
<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="/* * Copyright (c) $today.year Your Corporation. All Rights Reserved. */" />
|
||||
<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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user