diff --git a/tools/idea/src/main/java/org/teavm/idea/TeaVMFacet.java b/tools/idea/src/main/java/org/teavm/idea/TeaVMFacet.java new file mode 100644 index 000000000..0a0c5a1e5 --- /dev/null +++ b/tools/idea/src/main/java/org/teavm/idea/TeaVMFacet.java @@ -0,0 +1,31 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * 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 org.teavm.idea; + +import com.intellij.facet.Facet; +import com.intellij.facet.FacetConfiguration; +import com.intellij.facet.FacetType; +import com.intellij.openapi.module.Module; +import org.jetbrains.annotations.NotNull; + +public class TeaVMFacet extends Facet { + public TeaVMFacet(@NotNull FacetType facetType, + @NotNull Module module, + @NotNull String name, + @NotNull FacetConfiguration configuration, Facet underlyingFacet) { + super(facetType, module, name, configuration, underlyingFacet); + } +} diff --git a/tools/idea/src/main/java/org/teavm/idea/TeaVMFacetConfiguration.java b/tools/idea/src/main/java/org/teavm/idea/TeaVMFacetConfiguration.java new file mode 100644 index 000000000..277db7b76 --- /dev/null +++ b/tools/idea/src/main/java/org/teavm/idea/TeaVMFacetConfiguration.java @@ -0,0 +1,60 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * 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 org.teavm.idea; + +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.components.PersistentStateComponent; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; +import com.intellij.openapi.util.InvalidDataException; +import com.intellij.openapi.util.WriteExternalException; +import org.jdom.Element; +import org.jetbrains.annotations.Nullable; +import org.teavm.idea.jps.model.TeaVMJpsConfiguration; + +@State(name = "teavm", storages = @Storage(id = "other", file = "$MODULE_FILE$")) +public class TeaVMFacetConfiguration implements FacetConfiguration, PersistentStateComponent { + private TeaVMJpsConfiguration state = new TeaVMJpsConfiguration(); + + @Override + public FacetEditorTab[] createEditorTabs(FacetEditorContext editorContext, + FacetValidatorsManager validatorsManager) { + return new FacetEditorTab[0]; + } + + @Override + public void readExternal(Element element) throws InvalidDataException { + } + + @Override + public void writeExternal(Element element) throws WriteExternalException { + } + + + @Nullable + @Override + public TeaVMJpsConfiguration getState() { + return state.createCopy(); + } + + @Override + public void loadState(TeaVMJpsConfiguration state) { + this.state.applyChanges(state); + } +} diff --git a/tools/idea/src/main/java/org/teavm/idea/TeaVMFacetType.java b/tools/idea/src/main/java/org/teavm/idea/TeaVMFacetType.java new file mode 100644 index 000000000..7c1729039 --- /dev/null +++ b/tools/idea/src/main/java/org/teavm/idea/TeaVMFacetType.java @@ -0,0 +1,58 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * 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 org.teavm.idea; + +import com.intellij.facet.Facet; +import com.intellij.facet.FacetType; +import com.intellij.facet.FacetTypeId; +import com.intellij.openapi.module.JavaModuleType; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleType; +import com.intellij.openapi.util.IconLoader; +import javax.swing.Icon; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class TeaVMFacetType extends FacetType { + public static final FacetTypeId TYPE_ID = new FacetTypeId<>("teavm-js"); + private static final Icon icon = IconLoader.getIcon("/teavm-16.png"); + + public TeaVMFacetType() { + super(TYPE_ID, "teavm-js", "TeaVM (JS)"); + } + + @Override + public TeaVMFacetConfiguration createDefaultConfiguration() { + return null; + } + + @Override + public TeaVMFacet createFacet(@NotNull Module module, String name, @NotNull TeaVMFacetConfiguration configuration, + @Nullable Facet underlyingFacet) { + return null; + } + + @Override + public boolean isSuitableModuleType(ModuleType moduleType) { + return moduleType instanceof JavaModuleType; + } + + @Nullable + @Override + public Icon getIcon() { + return icon; + } +}