mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
IDEA: creating facet
This commit is contained in:
parent
1335476abe
commit
dcef7fc996
31
tools/idea/src/main/java/org/teavm/idea/TeaVMFacet.java
Normal file
31
tools/idea/src/main/java/org/teavm/idea/TeaVMFacet.java
Normal file
|
@ -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<FacetConfiguration> {
|
||||
public TeaVMFacet(@NotNull FacetType facetType,
|
||||
@NotNull Module module,
|
||||
@NotNull String name,
|
||||
@NotNull FacetConfiguration configuration, Facet underlyingFacet) {
|
||||
super(facetType, module, name, configuration, underlyingFacet);
|
||||
}
|
||||
}
|
|
@ -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<TeaVMJpsConfiguration> {
|
||||
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);
|
||||
}
|
||||
}
|
58
tools/idea/src/main/java/org/teavm/idea/TeaVMFacetType.java
Normal file
58
tools/idea/src/main/java/org/teavm/idea/TeaVMFacetType.java
Normal file
|
@ -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<TeaVMFacet, TeaVMFacetConfiguration> {
|
||||
public static final FacetTypeId<TeaVMFacet> 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user