Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sample
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leona
I
idea
plugin
sample
Commits
91ba4fd3
Commit
91ba4fd3
authored
Oct 11, 2019
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
222 additions
and
0 deletions
+222
-0
resources/META-INF/plugin.xml
resources/META-INF/plugin.xml
+52
-0
src/com/duanledexianxianxian/plugin/component/project/MaxProject.java
...ledexianxianxian/plugin/component/project/MaxProject.java
+59
-0
src/com/duanledexianxianxian/plugin/constant/AppConstants.java
...om/duanledexianxianxian/plugin/constant/AppConstants.java
+11
-0
src/com/duanledexianxianxian/plugin/service/application/MyCounter.java
...edexianxianxian/plugin/service/application/MyCounter.java
+32
-0
src/com/duanledexianxianxian/plugin/service/application/SampleApplication.java
...ianxian/plugin/service/application/SampleApplication.java
+12
-0
src/com/duanledexianxianxian/plugin/service/application/impl/MyCounterImpl.java
...anxian/plugin/service/application/impl/MyCounterImpl.java
+46
-0
src/com/duanledexianxianxian/plugin/service/application/impl/SampleApplicationImpl.java
...lugin/service/application/impl/SampleApplicationImpl.java
+10
-0
No files found.
resources/META-INF/plugin.xml
0 → 100644
View file @
91ba4fd3
<idea-plugin>
<!-- 插件相关信息, 会展示在IDEA插件的描述中 -->
<!-- 插件唯一id, 遵循使用包名的原则 -->
<id>
com.duanledexianxianxian.plugin.sample
</id>
<!-- 插件名称 -->
<name>
sample
</name>
<!-- 插件版本 -->
<version>
1.0
</version>
<!-- 开发者信息 -->
<vendor
email=
"fengyuchenglun@foxmail.com"
url=
"https://github.com/fengyuchenglun"
>
fengyuchenglun
</vendor>
<!-- 插件的描述 -->
<description>
This is IDEA plugin. Just for test and study.
</description>
<!-- 插件版本变更信息 -->
<change-notes>
This is IDEA plugin. Just for test and study.
</change-notes>
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<!-- 插件兼容IDEA的最大和最小build号,不配置则不做限制 -->
<idea-version
since-build=
"173.0"
/>
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<!-- uncomment to enable plugin in all products
<depends>com.intellij.modules.lang</depends>
-->
<depends>
com.intellij.modules.platform
</depends>
<!-- 声明该插件对IDEA core或其他插件的扩展 -->
<extensions
defaultExtensionNs=
"com.intellij"
>
<!-- Add your extensions here -->
<applicationService
serviceInterface=
"com.duanledexianxianxian.plugin.service.application.SampleApplication"
serviceImplementation=
"com.duanledexianxianxian.plugin.service.application.impl.SampleApplicationImpl"
/>
<applicationService
serviceInterface=
"com.duanledexianxianxian.plugin.service.application.MyCounter"
serviceImplementation=
"com.duanledexianxianxian.plugin.service.application.impl.MyCounterImpl"
/>
</extensions>
<!-- Actions: 如添加一个文件右击菜单按钮 -->
<actions>
<!-- Add your actions here -->
</actions>
<project-components>
<component>
<implementation-class>
com.duanledexianxianxian.plugin.component.project.MaxProject
</implementation-class>
</component>
</project-components>
</idea-plugin>
\ No newline at end of file
src/com/duanledexianxianxian/plugin/component/project/MaxProject.java
0 → 100644
View file @
91ba4fd3
package
com.duanledexianxianxian.plugin.component.project
;
import
com.duanledexianxianxian.plugin.constant.AppConstants
;
import
com.duanledexianxianxian.plugin.service.application.MyCounter
;
import
com.intellij.openapi.components.ProjectComponent
;
import
com.intellij.openapi.components.ServiceManager
;
import
com.intellij.openapi.project.Project
;
import
com.intellij.openapi.project.ProjectManager
;
import
com.intellij.openapi.ui.Messages
;
import
org.jetbrains.annotations.NotNull
;
/**
* @author duanledexianxianxian
* @date 2019/10/11 0:08
* @since 1.0.0
*/
public
class
MaxProject
implements
ProjectComponent
{
public
MaxProject
(
Project
project
)
{
}
@Override
public
void
projectOpened
()
{
// called when project is opened
MyCounter
CommandCounter
=
ServiceManager
.
getService
(
MyCounter
.
class
);
if
(
CommandCounter
.
increaseCounter
()
==
-
1
)
{
Messages
.
showMessageDialog
(
"The maximum number of opened projects exceeds "
+
AppConstants
.
MAX_CNT
+
" projects!"
,
"Error"
,
Messages
.
getErrorIcon
());
ProjectManager
PM
=
ProjectManager
.
getInstance
();
Project
[]
AllProjects
=
PM
.
getOpenProjects
();
Project
project
=
AllProjects
[
AllProjects
.
length
-
1
];
PM
.
closeProject
(
project
);
}
}
@Override
public
void
projectClosed
()
{
// called when project is being closed
MyCounter
commandCounter
=
ServiceManager
.
getService
(
MyCounter
.
class
);
commandCounter
.
decreaseCounter
();
}
@Override
public
void
initComponent
()
{
// TODO: insert component initialization logic here
}
@Override
public
void
disposeComponent
()
{
// TODO: insert component disposal logic here
}
@NotNull
@Override
public
String
getComponentName
()
{
return
"MaxProject"
;
}
}
src/com/duanledexianxianxian/plugin/constant/AppConstants.java
0 → 100644
View file @
91ba4fd3
package
com.duanledexianxianxian.plugin.constant
;
/**
* @author duanledexianxianxian
* @date 2019/10/11 0:24
* @since 1.0.0
*/
public
class
AppConstants
{
public
static
int
MAX_CNT
=
1
;
}
src/com/duanledexianxianxian/plugin/service/application/MyCounter.java
0 → 100644
View file @
91ba4fd3
package
com.duanledexianxianxian.plugin.service.application
;
import
com.intellij.openapi.components.ServiceManager
;
/**
* The interface My counter.
*/
public
interface
MyCounter
{
/**
* Gets instance.
*
* @return the instance
*/
static
MyCounter
getInstance
()
{
return
ServiceManager
.
getService
(
MyCounter
.
class
);
}
/**
* Increase counter int.
*
* @return the int
*/
int
increaseCounter
();
/**
* Decrease counter int.
*
* @return the int
*/
int
decreaseCounter
();
}
src/com/duanledexianxianxian/plugin/service/application/SampleApplication.java
0 → 100644
View file @
91ba4fd3
package
com.duanledexianxianxian.plugin.service.application
;
import
com.intellij.openapi.components.ServiceManager
;
/**
* @author fengyuchenglun
*/
public
interface
SampleApplication
{
static
SampleApplication
getInstance
()
{
return
ServiceManager
.
getService
(
SampleApplication
.
class
);
}
}
src/com/duanledexianxianxian/plugin/service/application/impl/MyCounterImpl.java
0 → 100644
View file @
91ba4fd3
package
com.duanledexianxianxian.plugin.service.application.impl
;
import
com.duanledexianxianxian.plugin.service.application.MyCounter
;
import
static
com
.
duanledexianxianxian
.
plugin
.
constant
.
AppConstants
.
MAX_CNT
;
/**
* The type My counter.
*
* @author fengyuchenglun
* @version 1.0.0
*/
public
class
MyCounterImpl
implements
MyCounter
{
/**
* Sets the maximum allowed number of opened projects.
*/
private
int
count
=
0
;
/**
* Instantiates a new My counter.
*/
public
MyCounterImpl
()
{
}
/**
* Increase counter int.
*
* @return the int
*/
@Override
public
int
increaseCounter
()
{
count
++;
return
(
count
>
MAX_CNT
)
?
-
1
:
count
;
}
/**
* Decrease counter int.
*
* @return the int
*/
@Override
public
int
decreaseCounter
()
{
count
--;
return
(
count
>
MAX_CNT
)
?
-
1
:
count
;
}
}
src/com/duanledexianxianxian/plugin/service/application/impl/SampleApplicationImpl.java
0 → 100644
View file @
91ba4fd3
package
com.duanledexianxianxian.plugin.service.application.impl
;
import
com.duanledexianxianxian.plugin.service.application.SampleApplication
;
/**
* @author fengyuchenglun
*/
public
class
SampleApplicationImpl
implements
SampleApplication
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment