赞
踩
package
com.cdai.plugin.rapidg;
import
com.intellij.openapi.components.ApplicationComponent;
import
com.intellij.openapi.ui.Messages;
import
org.jetbrains.annotations.NotNull;
/**
* My Component
* User: cdai
* Date: 13-11-4
* Time: 上午10:08
*/
public
class
MyComponent
implements
ApplicationComponent {
public
MyComponent() {
}
public
void
initComponent() {
// TODO: insert component initialization logic here
}
public
void
disposeComponent() {
// TODO: insert component disposal logic here
}
@NotNull
public
String getComponentName() {
return
"MyComponent"
;
}
public
void
sayHello() {
// Show dialog with message
Messages.showMessageDialog(
"Hello World!"
,
"Sample"
,
Messages.getInformationIcon()
);
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package
com.cdai.plugin.rapidg;
import
com.intellij.openapi.actionSystem.AnAction;
import
com.intellij.openapi.actionSystem.AnActionEvent;
import
com.intellij.openapi.application.Application;
import
com.intellij.openapi.application.ApplicationManager;
/**
* Say Hello Action
* User: cdai
* Date: 13-11-4
* Time: 上午10:16
*/
public
class
SayHelloAction
extends
AnAction {
@Override
public
void
actionPerformed(AnActionEvent e) {
Application application = ApplicationManager.getApplication();
MyComponent myComponent = application.getComponent(MyComponent.
class
);
myComponent.sayHello();
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<
idea-plugin
version
=
"2"
>
<
id
>com.cdai.plugin.rapidg</
id
>
<
name
>CDai's Rapid Generator Plugin</
name
>
<
version
>1.0</
version
>
<
description
>
<![CDATA[
Enter short description for your plugin here.<br>
<small>most HTML tags may be used</small>
]]>
</
description
>
<
change-notes
>
<![CDATA[
Add change notes here.<br>
<small>most HTML tags may be used</small>
]]>
</
change-notes
>
<!-- please see http://confluence.jetbrains.net/display/IDEADEV/Build+Number+Ranges for description -->
<
idea-version
since-build
=
"107.105"
/>
<!-- please see http://confluence.jetbrains.net/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
on how to target different products -->
<!-- uncomment to enable plugin in all products
<depends>com.intellij.modules.lang</depends>
-->
<
application-components
>
<!-- Add your application components here -->
<
component
>
<
implementation-class
>com.cdai.plugin.rapidg.MyComponent</
implementation-class
>
</
component
>
</
application-components
>
<
project-components
>
<!-- Add your project components here -->
</
project-components
>
<
actions
>
<!-- Add your actions here -->
<
action
id
=
"SayHello"
class
=
"com.cdai.plugin.rapidg.SayHelloAction"
text
=
"Say Hello!"
>
<
add-to-group
group-id
=
"WindowMenu"
anchor
=
"first"
/>
</
action
>
</
actions
>
<
extensions
defaultExtensionNs
=
"com.intellij"
>
<!-- Add your extensions here -->
</
extensions
>
</
idea-plugin
>
|
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。