mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
added option to ignore invalid facet
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.facet.FacetType;
|
||||
import com.intellij.facet.ProjectFacetManager;
|
||||
import com.intellij.facet.impl.ProjectFacetsConfigurator;
|
||||
import com.intellij.facet.impl.autodetecting.FacetAutodetectingManager;
|
||||
import com.intellij.facet.impl.invalid.InvalidFacetType;
|
||||
import com.intellij.facet.ui.DefaultFacetSettingsEditor;
|
||||
import com.intellij.facet.ui.FacetEditor;
|
||||
import com.intellij.facet.ui.MultipleFacetSettingsEditor;
|
||||
@@ -62,10 +63,12 @@ public class FacetTypeEditor extends UnnamedConfigurableGroup {
|
||||
myInitialConfigurables.add(new FacetAutodetectionConfigurable(project, context, facetType));
|
||||
}
|
||||
|
||||
C configuration = ProjectFacetManager.getInstance(project).createDefaultConfiguration(facetType);
|
||||
DefaultFacetSettingsEditor defaultSettingsEditor = facetType.createDefaultConfigurationEditor(project, configuration);
|
||||
if (defaultSettingsEditor != null) {
|
||||
myInitialConfigurables.add(new DefaultFacetSettingsConfigurable<C>(facetType, project, defaultSettingsEditor, configuration));
|
||||
if (!(facetType instanceof InvalidFacetType)) {
|
||||
C configuration = ProjectFacetManager.getInstance(project).createDefaultConfiguration(facetType);
|
||||
DefaultFacetSettingsEditor defaultSettingsEditor = facetType.createDefaultConfigurationEditor(project, configuration);
|
||||
if (defaultSettingsEditor != null) {
|
||||
myInitialConfigurables.add(new DefaultFacetSettingsConfigurable<C>(facetType, project, defaultSettingsEditor, configuration));
|
||||
}
|
||||
}
|
||||
|
||||
for (Configurable configurable : myInitialConfigurables) {
|
||||
|
||||
+1
-1
@@ -229,7 +229,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
}
|
||||
|
||||
private void addFacetsConfig() {
|
||||
if (FacetStructureConfigurable.isEnabled()) {
|
||||
if (myFacetStructureConfigurable.isVisible()) {
|
||||
addConfigurable(myFacetStructureConfigurable);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-11
@@ -21,6 +21,8 @@ import com.intellij.facet.FacetType;
|
||||
import com.intellij.facet.FacetTypeRegistry;
|
||||
import com.intellij.facet.impl.autodetecting.FacetAutodetectingManager;
|
||||
import com.intellij.facet.impl.autodetecting.FacetAutodetectingManagerImpl;
|
||||
import com.intellij.facet.impl.invalid.InvalidFacetManager;
|
||||
import com.intellij.facet.impl.invalid.InvalidFacetType;
|
||||
import com.intellij.facet.impl.ui.facetType.FacetTypeEditor;
|
||||
import com.intellij.facet.ui.FacetEditor;
|
||||
import com.intellij.facet.ui.MultipleFacetSettingsEditor;
|
||||
@@ -65,24 +67,31 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable {
|
||||
return ServiceManager.getService(project, FacetStructureConfigurable.class);
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return FacetTypeRegistry.getInstance().getFacetTypes().length > 0;
|
||||
public boolean isVisible() {
|
||||
return FacetTypeRegistry.getInstance().getFacetTypes().length > 0 || !InvalidFacetManager.getInstance(myProject).getInvalidFacets().isEmpty();
|
||||
}
|
||||
|
||||
protected void loadTree() {
|
||||
myTree.setRootVisible(false);
|
||||
myTree.setShowsRootHandles(true);
|
||||
for (FacetType<?,?> facetType : FacetTypeRegistry.getInstance().getFacetTypes()) {
|
||||
FacetTypeConfigurable facetTypeConfigurable = new FacetTypeConfigurable(this, facetType);
|
||||
MyNode facetTypeNode = new MyNode(facetTypeConfigurable);
|
||||
addNode(facetTypeNode, myRoot);
|
||||
addFacetTypeNode(facetType);
|
||||
}
|
||||
if (!InvalidFacetManager.getInstance(myProject).getInvalidFacets().isEmpty()) {
|
||||
addFacetTypeNode(InvalidFacetType.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
for (Module module : myModuleManager.getModules()) {
|
||||
Collection<? extends Facet> facets = FacetManager.getInstance(module).getFacetsByType(facetType.getId());
|
||||
for (Facet facet : facets) {
|
||||
FacetEditorFacadeImpl editorFacade = ModuleStructureConfigurable.getInstance(myProject).getFacetEditorFacade();
|
||||
addFacetNode(facetTypeNode, facet, editorFacade);
|
||||
}
|
||||
private void addFacetTypeNode(FacetType<?, ?> facetType) {
|
||||
FacetTypeConfigurable facetTypeConfigurable = new FacetTypeConfigurable(this, facetType);
|
||||
MyNode facetTypeNode = new MyNode(facetTypeConfigurable);
|
||||
addNode(facetTypeNode, myRoot);
|
||||
|
||||
for (Module module : myModuleManager.getModules()) {
|
||||
Collection<? extends Facet> facets = FacetManager.getInstance(module).getFacetsByType(facetType.getId());
|
||||
FacetEditorFacadeImpl editorFacade = ModuleStructureConfigurable.getInstance(myProject).getFacetEditorFacade();
|
||||
for (Facet facet : facets) {
|
||||
addFacetNode(facetTypeNode, facet, editorFacade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,13 +212,16 @@ public class FacetManagerImpl extends FacetManager implements ModuleComponent, P
|
||||
}
|
||||
|
||||
private void addInvalidFacet(final FacetState state, ModifiableFacetModel model, final Facet underlyingFacet, final String errorMessage) {
|
||||
final InvalidFacetManager invalidFacetManager = InvalidFacetManager.getInstance(myModule.getProject());
|
||||
final String typeId = StringUtil.notNullize(state.getFacetType());
|
||||
final InvalidFacetType type = InvalidFacetManager.getInstance(myModule.getProject()).getOrCreateType(typeId);
|
||||
final InvalidFacetType type = InvalidFacetType.getInstance();
|
||||
final InvalidFacetConfiguration configuration = new InvalidFacetConfiguration(state, errorMessage);
|
||||
final InvalidFacet facet = createFacet(type, StringUtil.notNullize(state.getName()), configuration, underlyingFacet);
|
||||
model.addFacet(facet);
|
||||
FacetLoadingErrorDescription description = new FacetLoadingErrorDescription(facet);
|
||||
ProjectLoadingErrorsNotifier.getInstance(myModule.getProject()).registerError(description);
|
||||
if (!invalidFacetManager.isIgnored(facet)) {
|
||||
FacetLoadingErrorDescription description = new FacetLoadingErrorDescription(facet);
|
||||
ProjectLoadingErrorsNotifier.getInstance(myModule.getProject()).registerError(description);
|
||||
}
|
||||
}
|
||||
|
||||
private <C extends FacetConfiguration> void addFacet(final FacetType<?, C> type, final FacetState state, final Facet underlyingFacet,
|
||||
@@ -263,25 +266,28 @@ public class FacetManagerImpl extends FacetManager implements ModuleComponent, P
|
||||
final Facet underlyingFacet = facet.getUnderlyingFacet();
|
||||
final List<FacetState> parent = states.get(underlyingFacet);
|
||||
|
||||
FacetState facetState = new FacetState();
|
||||
facetState.setFacetType(facet.getType().getStringId());
|
||||
facetState.setName(facet.getName());
|
||||
final Element config;
|
||||
try {
|
||||
FacetConfiguration configuration = facet.getConfiguration();
|
||||
config = FacetUtil.saveFacetConfiguration(configuration);
|
||||
if (configuration instanceof InvalidFacetConfiguration) {
|
||||
facetState.getSubFacets().addAll(((InvalidFacetConfiguration)configuration).getSubFacetsStates());
|
||||
}
|
||||
if (facet instanceof JDOMExternalizable) {
|
||||
//todo[nik] remove
|
||||
((JDOMExternalizable)facet).writeExternal(config);
|
||||
}
|
||||
FacetState facetState;
|
||||
if (facet instanceof InvalidFacet) {
|
||||
facetState = ((InvalidFacet)facet).getConfiguration().getFacetState();
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
continue;
|
||||
else {
|
||||
facetState = new FacetState();
|
||||
facetState.setFacetType(facet.getType().getStringId());
|
||||
facetState.setName(facet.getName());
|
||||
final Element config;
|
||||
try {
|
||||
FacetConfiguration configuration = facet.getConfiguration();
|
||||
config = FacetUtil.saveFacetConfiguration(configuration);
|
||||
if (facet instanceof JDOMExternalizable) {
|
||||
//todo[nik] remove
|
||||
((JDOMExternalizable)facet).writeExternal(config);
|
||||
}
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
continue;
|
||||
}
|
||||
facetState.setConfiguration(config);
|
||||
}
|
||||
facetState.setConfiguration(config);
|
||||
|
||||
parent.add(facetState);
|
||||
states.put(facet, facetState.getSubFacets());
|
||||
|
||||
+4
-17
@@ -20,17 +20,14 @@ import com.intellij.facet.impl.FacetState;
|
||||
import com.intellij.facet.ui.FacetEditorContext;
|
||||
import com.intellij.facet.ui.FacetEditorTab;
|
||||
import com.intellij.facet.ui.FacetValidatorsManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import org.jdom.Element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class InvalidFacetConfiguration implements FacetConfiguration, PersistentStateComponent<Element> {
|
||||
public class InvalidFacetConfiguration implements FacetConfiguration {
|
||||
private FacetState myFacetState;
|
||||
private final String myErrorMessage;
|
||||
|
||||
@@ -39,14 +36,14 @@ public class InvalidFacetConfiguration implements FacetConfiguration, Persistent
|
||||
myErrorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public List<FacetState> getSubFacetsStates() {
|
||||
return myFacetState.getSubFacets();
|
||||
public FacetState getFacetState() {
|
||||
return myFacetState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FacetEditorTab[] createEditorTabs(FacetEditorContext editorContext, FacetValidatorsManager validatorsManager) {
|
||||
return new FacetEditorTab[] {
|
||||
new InvalidFacetEditor(myErrorMessage)
|
||||
new InvalidFacetEditor(editorContext, myErrorMessage)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -61,14 +58,4 @@ public class InvalidFacetConfiguration implements FacetConfiguration, Persistent
|
||||
public String getErrorMessage() {
|
||||
return myErrorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
return myFacetState.getConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(Element state) {
|
||||
myFacetState.setConfiguration(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.facet.impl.invalid.InvalidFacetEditor">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
@@ -8,19 +8,41 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="c0c37" class="javax.swing.JLabel" binding="myErrorLabel">
|
||||
<component id="c0c37" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Label"/>
|
||||
<text value="Cannot load facet."/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="c57a2">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="cc50e" class="com.intellij.openapi.ui.ex.MultiLineLabel" binding="myDescriptionLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="136d7" class="javax.swing.JLabel" binding="myIconLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2e76e" class="javax.swing.JCheckBox" binding="myIgnoreCheckBox">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Ignore"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.intellij.facet.impl.invalid;
|
||||
|
||||
import com.intellij.facet.ui.FacetEditorContext;
|
||||
import com.intellij.facet.ui.FacetEditorTab;
|
||||
import com.intellij.openapi.ui.ex.MultiLineLabel;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
|
||||
@@ -27,10 +29,16 @@ import javax.swing.*;
|
||||
public class InvalidFacetEditor extends FacetEditorTab {
|
||||
private final String myErrorMessage;
|
||||
private JPanel myMainPanel;
|
||||
private JLabel myErrorLabel;
|
||||
private MultiLineLabel myDescriptionLabel;
|
||||
private JCheckBox myIgnoreCheckBox;
|
||||
private JLabel myIconLabel;
|
||||
private InvalidFacetManager myInvalidFacetManager;
|
||||
private InvalidFacet myFacet;
|
||||
|
||||
public InvalidFacetEditor(String errorMessage) {
|
||||
public InvalidFacetEditor(FacetEditorContext context, String errorMessage) {
|
||||
myErrorMessage = errorMessage;
|
||||
myFacet = (InvalidFacet)context.getFacet();
|
||||
myInvalidFacetManager = InvalidFacetManager.getInstance(context.getProject());
|
||||
}
|
||||
|
||||
@Nls
|
||||
@@ -39,20 +47,31 @@ public class InvalidFacetEditor extends FacetEditorTab {
|
||||
return "";
|
||||
}
|
||||
|
||||
public JCheckBox getIgnoreCheckBox() {
|
||||
return myIgnoreCheckBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
myErrorLabel.setText(myErrorMessage);
|
||||
myErrorLabel.setIcon(IconLoader.getIcon("/runConfigurations/configurationWarning.png"));
|
||||
myIconLabel.setIcon(IconLoader.getIcon("/runConfigurations/configurationWarning.png"));
|
||||
myDescriptionLabel.setText(myErrorMessage);
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return false;
|
||||
return myIgnoreCheckBox.isSelected() != myInvalidFacetManager.isIgnored(myFacet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
myIgnoreCheckBox.setSelected(myInvalidFacetManager.isIgnored(myFacet));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
myInvalidFacetManager.setIgnored(myFacet, myIgnoreCheckBox.isSelected());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,8 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
@@ -27,6 +29,8 @@ public abstract class InvalidFacetManager {
|
||||
return ServiceManager.getService(project, InvalidFacetManager.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract InvalidFacetType getOrCreateType(@NotNull String typeId);
|
||||
public abstract boolean isIgnored(@NotNull InvalidFacet facet);
|
||||
public abstract void setIgnored(@NotNull InvalidFacet facet, boolean ignored);
|
||||
|
||||
public abstract List<InvalidFacet> getInvalidFacets();
|
||||
}
|
||||
|
||||
+65
-11
@@ -15,25 +15,79 @@
|
||||
*/
|
||||
package com.intellij.facet.impl.invalid;
|
||||
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import com.intellij.facet.ProjectFacetManager;
|
||||
import com.intellij.facet.pointers.FacetPointersManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.xmlb.annotations.AbstractCollection;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class InvalidFacetManagerImpl extends InvalidFacetManager {
|
||||
private Map<String, InvalidFacetType> myTypes = new FactoryMap<String, InvalidFacetType>() {
|
||||
@Override
|
||||
protected InvalidFacetType create(String key) {
|
||||
return new InvalidFacetType(key);
|
||||
@State(
|
||||
name = "InvalidFacetManager",
|
||||
storages = {
|
||||
@Storage(
|
||||
id = "other",
|
||||
file = "$WORKSPACE_FILE$"
|
||||
)
|
||||
}
|
||||
};
|
||||
)
|
||||
public class InvalidFacetManagerImpl extends InvalidFacetManager implements PersistentStateComponent<InvalidFacetManagerImpl.InvalidFacetManagerState> {
|
||||
private InvalidFacetManagerState myState = new InvalidFacetManagerState();
|
||||
private final Project myProject;
|
||||
|
||||
public InvalidFacetManagerImpl(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InvalidFacetType getOrCreateType(@NotNull String typeId) {
|
||||
return myTypes.get(typeId);
|
||||
public boolean isIgnored(@NotNull InvalidFacet facet) {
|
||||
return myState.getIgnoredFacets().contains(FacetPointersManager.constructId(facet));
|
||||
}
|
||||
|
||||
public InvalidFacetManagerState getState() {
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(InvalidFacetManagerState state) {
|
||||
myState = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnored(@NotNull InvalidFacet facet, boolean ignored) {
|
||||
final String id = FacetPointersManager.constructId(facet);
|
||||
if (ignored) {
|
||||
myState.getIgnoredFacets().add(id);
|
||||
}
|
||||
else {
|
||||
myState.getIgnoredFacets().remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InvalidFacet> getInvalidFacets() {
|
||||
return ProjectFacetManager.getInstance(myProject).getFacets(InvalidFacetType.TYPE_ID);
|
||||
}
|
||||
|
||||
public static class InvalidFacetManagerState {
|
||||
private Set<String> myIgnoredFacets = new HashSet<String>();
|
||||
|
||||
@Tag("ignored-facets")
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "facet", elementValueAttribute = "id")
|
||||
public Set<String> getIgnoredFacets() {
|
||||
return myIgnoredFacets;
|
||||
}
|
||||
|
||||
public void setIgnoredFacets(Set<String> ignoredFacets) {
|
||||
myIgnoredFacets = ignoredFacets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,12 @@ package com.intellij.facet.impl.invalid;
|
||||
import com.intellij.facet.Facet;
|
||||
import com.intellij.facet.FacetType;
|
||||
import com.intellij.facet.FacetTypeId;
|
||||
import com.intellij.facet.ui.FacetEditor;
|
||||
import com.intellij.facet.ui.MultipleFacetSettingsEditor;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -30,10 +34,15 @@ import javax.swing.*;
|
||||
* @author nik
|
||||
*/
|
||||
public class InvalidFacetType extends FacetType<InvalidFacet, InvalidFacetConfiguration> {
|
||||
private static final Icon ICON = IconLoader.getIcon("/fileTypes/unknown.png");
|
||||
public static final FacetTypeId<InvalidFacet> TYPE_ID = new FacetTypeId<InvalidFacet>("invalid");
|
||||
public static final Icon ICON = IconLoader.getIcon("/fileTypes/unknown.png");
|
||||
|
||||
public InvalidFacetType(String typeId) {
|
||||
super(new FacetTypeId<InvalidFacet>("invalid:" + typeId), typeId, typeId, null);
|
||||
public static InvalidFacetType getInstance() {
|
||||
return ServiceManager.getService(InvalidFacetType.class);
|
||||
}
|
||||
|
||||
public InvalidFacetType() {
|
||||
super(TYPE_ID, "invalid", "Invalid", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,6 +68,11 @@ public class InvalidFacetType extends FacetType<InvalidFacet, InvalidFacetConfig
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultipleFacetSettingsEditor createMultipleConfigurationsEditor(@NotNull Project project, @NotNull FacetEditor[] editors) {
|
||||
return new MultipleInvalidFacetEditor(editors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ICON;
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.facet.impl.invalid.MultipleInvalidFacetEditor">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="50f17">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="4a323" class="com.intellij.util.ui.ThreeStateCheckBox" binding="myIgnoreFacetsCheckBox">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Ignore invalid facets"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.facet.impl.invalid;
|
||||
|
||||
import com.intellij.facet.impl.ui.MultipleFacetEditorHelperImpl;
|
||||
import com.intellij.facet.ui.FacetEditor;
|
||||
import com.intellij.facet.ui.MultipleFacetSettingsEditor;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.ui.ThreeStateCheckBox;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class MultipleInvalidFacetEditor extends MultipleFacetSettingsEditor {
|
||||
private MultipleFacetEditorHelperImpl myHelper;
|
||||
private JPanel myMainPanel;
|
||||
private ThreeStateCheckBox myIgnoreFacetsCheckBox;
|
||||
|
||||
public MultipleInvalidFacetEditor(FacetEditor[] editors) {
|
||||
myHelper = new MultipleFacetEditorHelperImpl();
|
||||
myHelper.bind(myIgnoreFacetsCheckBox, editors, new NotNullFunction<FacetEditor, JCheckBox>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public JCheckBox fun(FacetEditor editor) {
|
||||
return editor.getEditorTab(InvalidFacetEditor.class).getIgnoreCheckBox();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
myHelper.unbind();
|
||||
}
|
||||
}
|
||||
@@ -184,6 +184,7 @@
|
||||
|
||||
<projectService serviceInterface="com.intellij.facet.ProjectFacetManager"
|
||||
serviceImplementation="com.intellij.facet.impl.ProjectFacetManagerImpl"/>
|
||||
<applicationService serviceImplementation="com.intellij.facet.impl.invalid.InvalidFacetType"/>
|
||||
<projectService serviceInterface="com.intellij.facet.impl.invalid.InvalidFacetManager"
|
||||
serviceImplementation="com.intellij.facet.impl.invalid.InvalidFacetManagerImpl"/>
|
||||
<projectService serviceInterface="com.intellij.openapi.module.ProjectLoadingErrorsNotifier"
|
||||
|
||||
Reference in New Issue
Block a user