parent
c4670a498b
commit
42a4db90e7
@ -1 +1,3 @@
|
||||
# intellij-plugin-template
|
||||
IntelliJ Plugin Template
|
||||
========================
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
package org.jetbrains.plugins.template;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MyProjectService {
|
||||
public MyProjectService(@NotNull Project project) {
|
||||
System.out.println("MyProjectService");
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 hsz Jakub Chrzanowski <jakub@hsz.mobi>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.jetbrains.plugins.template;
|
||||
|
||||
import com.intellij.DynamicBundle;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
public class TemplateBundle extends DynamicBundle {
|
||||
@NonNls
|
||||
public static final String BUNDLE = "messages.TemplateBundle";
|
||||
|
||||
private static final TemplateBundle INSTANCE = new TemplateBundle();
|
||||
|
||||
private TemplateBundle() {
|
||||
super(BUNDLE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
|
||||
return INSTANCE.getMessage(key, params);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.jetbrains.plugins.template.listeners;
|
||||
|
||||
import com.intellij.ide.plugins.CannotUnloadPluginException;
|
||||
import com.intellij.ide.plugins.DynamicPluginListener;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.template.services.MyApplicationService;
|
||||
|
||||
class MyDynamicPluginListener implements DynamicPluginListener {
|
||||
@Override
|
||||
public void beforePluginLoaded(@NotNull IdeaPluginDescriptor pluginDescriptor) {
|
||||
ServiceManager.getService(MyApplicationService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pluginLoaded(@NotNull IdeaPluginDescriptor pluginDescriptor) {
|
||||
System.out.println("xx");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforePluginUnload(@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUnloadPlugin(@NotNull IdeaPluginDescriptor pluginDescriptor) throws CannotUnloadPluginException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pluginUnloaded(@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package org.jetbrains.plugins.template.listeners;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManagerListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.template.services.MyProjectService;
|
||||
|
||||
class MyProjectManagerListener implements ProjectManagerListener {
|
||||
@Override
|
||||
public void projectOpened(@NotNull Project project) {
|
||||
project.getService(MyProjectService.class);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.jetbrains.plugins.template;
|
||||
package org.jetbrains.plugins.template.services;
|
||||
|
||||
public class MyApplicationService {
|
||||
public MyApplicationService() {
|
@ -0,0 +1,11 @@
|
||||
package org.jetbrains.plugins.template.services;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.template.TemplateBundle;
|
||||
|
||||
public class MyProjectService {
|
||||
public MyProjectService(@NotNull Project project) {
|
||||
System.out.println(TemplateBundle.message("projectService", project.getName()));
|
||||
}
|
||||
}
|
@ -1,17 +1,22 @@
|
||||
<idea-plugin url="www.jetbrains.com">
|
||||
<id>org.jetbrains.plugins.template</id>
|
||||
<name>Template</name>
|
||||
<version>1.0.0</version>
|
||||
<vendor>JetBrains</vendor>
|
||||
<idea-version since-build="201"/>
|
||||
<description>Demonstrates various aspects of interacting with project model</description>
|
||||
|
||||
<!-- Product and plugin compatibility requirements -->
|
||||
<!-- http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html?search=depend#dependency-declaration-in-pluginxml -->
|
||||
<depends>com.intellij.modules.java</depends>
|
||||
<depends>com.intellij.java</depends>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.template.MyApplicationService" />
|
||||
<projectService serviceImplementation="org.jetbrains.plugins.template.MyProjectService" />
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.template.services.MyApplicationService"/>
|
||||
<projectService serviceImplementation="org.jetbrains.plugins.template.services.MyProjectService"/>
|
||||
</extensions>
|
||||
|
||||
<projectListeners>
|
||||
<listener class="org.jetbrains.plugins.template.listeners.MyProjectManagerListener"
|
||||
topic="com.intellij.openapi.project.ProjectManagerListener"/>
|
||||
<listener class="org.jetbrains.plugins.template.listeners.MyDynamicPluginListener"
|
||||
topic="com.intellij.ide.plugins.DynamicPluginListener"/>
|
||||
</projectListeners>
|
||||
</idea-plugin>
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
@ -0,0 +1,2 @@
|
||||
name=Template Plugin
|
||||
projectService=Project service: {0}
|
Loading…
Reference in new issue