2 * Copyright 2000-2016 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.openapi.roots.impl;
18 import com.intellij.openapi.components.PersistentStateComponent;
19 import com.intellij.openapi.components.State;
20 import com.intellij.openapi.components.Storage;
21 import com.intellij.openapi.components.StoragePathMacros;
22 import com.intellij.openapi.module.Module;
23 import com.intellij.openapi.module.ModulePointer;
24 import com.intellij.openapi.module.ModulePointerManager;
25 import com.intellij.openapi.roots.TestModuleProperties;
26 import com.intellij.util.xmlb.annotations.Attribute;
27 import org.jetbrains.annotations.NotNull;
28 import org.jetbrains.annotations.Nullable;
34 name = "TestModuleProperties",
35 storages = @Storage(file = StoragePathMacros.MODULE_FILE)
37 public class TestModulePropertiesImpl extends TestModuleProperties implements PersistentStateComponent<TestModulePropertiesImpl.TestModulePropertiesState> {
38 private final ModulePointerManager myModulePointerManager;
39 private ModulePointer myProductionModulePointer;
41 public TestModulePropertiesImpl(@NotNull ModulePointerManager modulePointerManager) {
42 myModulePointerManager = modulePointerManager;
47 public String getProductionModuleName() {
48 return myProductionModulePointer != null ? myProductionModulePointer.getModuleName() : null;
53 public Module getProductionModule() {
54 return myProductionModulePointer != null ? myProductionModulePointer.getModule() : null;
58 public void setProductionModuleName(@Nullable String moduleName) {
59 myProductionModulePointer = moduleName != null ? myModulePointerManager.create(moduleName) : null;
64 public TestModulePropertiesState getState() {
65 TestModulePropertiesState state = new TestModulePropertiesState();
66 state.moduleName = getProductionModuleName();
71 public void loadState(TestModulePropertiesState state) {
75 public static class TestModulePropertiesState {
76 @Attribute("production-module")
77 public String moduleName;