mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
[code] facet demo
This commit is contained in:
parent
93eb0590c0
commit
d65604a0e6
@ -1,43 +1,36 @@
|
|||||||
<idea-plugin version="2">
|
<idea-plugin version="2">
|
||||||
<id>com.yourcompany.unique.plugin.id</id>
|
<id>com.intellij.tutorials.facet</id>
|
||||||
<name>Plugin display name here</name>
|
<name>Facet Demo</name>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>
|
<vendor email="support@jrtbrains.com" url="http://www.yourcompany.com">JetBrains</vendor>
|
||||||
|
|
||||||
<description><![CDATA[
|
<description>Basic example of working with facets</description>
|
||||||
Enter short description for your plugin here.<br>
|
|
||||||
<em>most HTML tags may be used</em>
|
|
||||||
]]></description>
|
|
||||||
|
|
||||||
<change-notes><![CDATA[
|
<change-notes>Initial commit</change-notes>
|
||||||
Add change notes here.<br>
|
|
||||||
<em>most HTML tags may be used</em>
|
|
||||||
]]>
|
|
||||||
</change-notes>
|
|
||||||
|
|
||||||
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
|
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
|
||||||
<idea-version since-build="131"/>
|
<idea-version since-build="131"/>
|
||||||
|
|
||||||
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
|
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
|
||||||
on how to target different products -->
|
on how to target different products -->
|
||||||
<!-- uncomment to enable plugin in all products
|
<!-- uncomment to enable plugin in all products
|
||||||
<depends>com.intellij.modules.lang</depends>
|
<depends>com.intellij.modules.lang</depends>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<!-- Add your extensions here -->
|
<facetType implementation="com.intellij.tutorials.facet.DemoFacetType"/>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<application-components>
|
<application-components>
|
||||||
<!-- Add your application components here -->
|
<!-- Add your application components here -->
|
||||||
</application-components>
|
</application-components>
|
||||||
|
|
||||||
<project-components>
|
<project-components>
|
||||||
<!-- Add your project components here -->
|
<!-- Add your project components here -->
|
||||||
</project-components>
|
</project-components>
|
||||||
|
|
||||||
<actions>
|
<actions>
|
||||||
<!-- Add your actions here -->
|
<!-- Add your actions here -->
|
||||||
</actions>
|
</actions>
|
||||||
|
|
||||||
</idea-plugin>
|
</idea-plugin>
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.intellij.tutorials.facet;
|
||||||
|
|
||||||
|
import com.intellij.facet.Facet;
|
||||||
|
import com.intellij.facet.FacetType;
|
||||||
|
import com.intellij.openapi.module.Module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Anna Bulenkova
|
||||||
|
*/
|
||||||
|
public class DemoFacet extends Facet<DemoFacetConfiguration> {
|
||||||
|
public static final String ID = "DEMO_FACET_ID";
|
||||||
|
|
||||||
|
public DemoFacet(FacetType facetType, Module module, String name, DemoFacetConfiguration configuration, Facet underlyingFacet) {
|
||||||
|
super(facetType, module, name, configuration, underlyingFacet);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package com.intellij.tutorials.facet;
|
||||||
|
|
||||||
|
import com.intellij.facet.FacetConfiguration;
|
||||||
|
import com.intellij.facet.ui.FacetEditorContext;
|
||||||
|
import com.intellij.facet.ui.FacetEditorTab;
|
||||||
|
import com.intellij.facet.ui.FacetValidatorsManager;
|
||||||
|
import com.intellij.openapi.util.InvalidDataException;
|
||||||
|
import com.intellij.openapi.util.WriteExternalException;
|
||||||
|
import org.jdom.Element;
|
||||||
|
import org.jetbrains.annotations.Nls;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Anna Bulenkova
|
||||||
|
*/
|
||||||
|
public class DemoFacetConfiguration implements FacetConfiguration {
|
||||||
|
public static final String DEMO_FACET_TAG_NAME = "DemoFacet";
|
||||||
|
public static final String PATH_TO_SDK_ATTR_NAME = "pathToSdk";
|
||||||
|
private String myPathToSdk = "";
|
||||||
|
JTextField myPath = new JTextField(myPathToSdk);
|
||||||
|
@Override
|
||||||
|
public FacetEditorTab[] createEditorTabs(FacetEditorContext context, FacetValidatorsManager manager) {
|
||||||
|
return new FacetEditorTab[] {
|
||||||
|
new FacetEditorTab() {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public JComponent createComponent() {
|
||||||
|
JPanel top = new JPanel(new BorderLayout());
|
||||||
|
top.add(new JLabel("Path to SDK: "), BorderLayout.WEST);
|
||||||
|
top.add(myPath);
|
||||||
|
JPanel panel = new JPanel(new BorderLayout());
|
||||||
|
panel.add(top, BorderLayout.NORTH);
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nls
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "Demo Framework";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isModified() {
|
||||||
|
return myPath.getText().equalsIgnoreCase(myPathToSdk);
|
||||||
|
// return !StringUtil.equalsIgnoreWhitespaces(myPath.getText(), myPathToSdk);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
myPath.setText(myPathToSdk);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disposeUIResources() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readExternal(Element element) throws InvalidDataException {
|
||||||
|
Element facet = element.getChild(DEMO_FACET_TAG_NAME);
|
||||||
|
if (facet != null) {
|
||||||
|
myPathToSdk = facet.getAttributeValue(PATH_TO_SDK_ATTR_NAME, "");
|
||||||
|
myPath.setText(myPathToSdk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeExternal(Element element) throws WriteExternalException {
|
||||||
|
Element facet = new Element(DEMO_FACET_TAG_NAME);
|
||||||
|
facet.setAttribute(PATH_TO_SDK_ATTR_NAME, myPathToSdk);
|
||||||
|
element.addContent(facet);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.intellij.tutorials.facet;
|
||||||
|
|
||||||
|
import com.intellij.facet.Facet;
|
||||||
|
import com.intellij.facet.FacetType;
|
||||||
|
import com.intellij.facet.FacetTypeId;
|
||||||
|
import com.intellij.icons.AllIcons;
|
||||||
|
import com.intellij.openapi.module.Module;
|
||||||
|
import com.intellij.openapi.module.ModuleType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Anna Bulenkova
|
||||||
|
*/
|
||||||
|
public class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration> {
|
||||||
|
private static final FacetTypeId<DemoFacet> TYPE_ID = new FacetTypeId<DemoFacet>(DemoFacet.ID);
|
||||||
|
public DemoFacetType() {
|
||||||
|
super(TYPE_ID, DemoFacet.ID, "Demo Facet");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DemoFacetConfiguration createDefaultConfiguration() {
|
||||||
|
return new DemoFacetConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DemoFacet createFacet(@NotNull Module module, String s, @NotNull DemoFacetConfiguration configuration, Facet facet) {
|
||||||
|
return new DemoFacet(this, module, s, configuration, facet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSuitableModuleType(ModuleType type) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Icon getIcon() {
|
||||||
|
return AllIcons.General.Information;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user