JavaFrameworkSupportProvider: J2K
This commit is contained in:
@@ -14,81 +14,58 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.framework;
|
package org.jetbrains.kotlin.idea.framework
|
||||||
|
|
||||||
import com.intellij.framework.FrameworkTypeEx;
|
import com.intellij.framework.FrameworkTypeEx
|
||||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable;
|
import com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable
|
||||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
|
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider
|
||||||
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel;
|
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel
|
||||||
import com.intellij.openapi.module.JavaModuleType;
|
import com.intellij.openapi.module.JavaModuleType
|
||||||
import com.intellij.openapi.module.Module;
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.module.ModuleType;
|
import com.intellij.openapi.module.ModuleType
|
||||||
import com.intellij.openapi.roots.ModifiableModelsProvider;
|
import com.intellij.openapi.roots.ModifiableModelsProvider
|
||||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
import com.intellij.openapi.roots.ModifiableRootModel
|
||||||
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription;
|
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription
|
||||||
import org.jetbrains.annotations.NotNull;
|
import javax.swing.JComponent
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
internal class JavaFrameworkSupportProvider : FrameworkSupportInModuleProvider() {
|
||||||
|
override fun getFrameworkType(): FrameworkTypeEx = JavaFrameworkType.getInstance()
|
||||||
|
|
||||||
class JavaFrameworkSupportProvider extends FrameworkSupportInModuleProvider {
|
override fun createConfigurable(model: FrameworkSupportModel): FrameworkSupportInModuleConfigurable {
|
||||||
@NotNull
|
return object : FrameworkSupportInModuleConfigurable() {
|
||||||
@Override
|
private var description: JavaRuntimeLibraryDescription? = null
|
||||||
public FrameworkTypeEx getFrameworkType() {
|
|
||||||
return JavaFrameworkType.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
override fun createLibraryDescription(): CustomLibraryDescription? {
|
||||||
@Override
|
description = JavaRuntimeLibraryDescription(model.project)
|
||||||
public FrameworkSupportInModuleConfigurable createConfigurable(@NotNull final FrameworkSupportModel model) {
|
return description
|
||||||
return new FrameworkSupportInModuleConfigurable() {
|
|
||||||
private JavaRuntimeLibraryDescription description = null;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public CustomLibraryDescription createLibraryDescription() {
|
|
||||||
description = new JavaRuntimeLibraryDescription(model.getProject());
|
|
||||||
return description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
override fun createComponent(): JComponent? = null
|
||||||
@Override
|
|
||||||
public JComponent createComponent() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
override fun isOnlyLibraryAdded(): Boolean = true
|
||||||
public boolean isOnlyLibraryAdded() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
override fun addSupport(
|
||||||
public void addSupport(
|
module: Module,
|
||||||
@NotNull Module module,
|
rootModel: ModifiableRootModel,
|
||||||
@NotNull ModifiableRootModel rootModel,
|
modifiableModelsProvider: ModifiableModelsProvider) {
|
||||||
@NotNull ModifiableModelsProvider modifiableModelsProvider) {
|
|
||||||
FrameworksCompatibilityUtils.suggestRemoveIncompatibleFramework(
|
FrameworksCompatibilityUtils.suggestRemoveIncompatibleFramework(
|
||||||
rootModel,
|
rootModel,
|
||||||
JSLibraryStdDescription.SUITABLE_LIBRARY_KINDS,
|
JSLibraryStdDescription.SUITABLE_LIBRARY_KINDS,
|
||||||
JSFrameworkType.getInstance());
|
JSFrameworkType.getInstance())
|
||||||
|
|
||||||
description.finishLibConfiguration(module, rootModel);
|
description!!.finishLibConfiguration(module, rootModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun onFrameworkSelectionChanged(selected: Boolean) {
|
||||||
public void onFrameworkSelectionChanged(boolean selected) {
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
String providerId = JSFrameworkType.getInstance().getId();
|
val providerId = JSFrameworkType.getInstance().id
|
||||||
if (model.isFrameworkSelected(providerId)) {
|
if (model.isFrameworkSelected(providerId)) {
|
||||||
model.setFrameworkComponentEnabled(providerId, false);
|
model.setFrameworkComponentEnabled(providerId, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun isEnabledForModuleType(moduleType: ModuleType<*>): Boolean = moduleType is JavaModuleType
|
||||||
public boolean isEnabledForModuleType(@NotNull ModuleType moduleType) {
|
|
||||||
return moduleType instanceof JavaModuleType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user