use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class BuildConfigurationProjectStructureElement method check.
@Override
public void check(final ProjectStructureProblemsHolder problemsHolder) {
final FlexBCConfigurator configurator = FlexBuildConfigurationsExtension.getInstance().getConfigurator();
final FlexProjectConfigurationEditor editor = configurator.getConfigEditor();
assert editor != null;
/*
final SdkEntry sdkEntry = myBc.getDependencies().getSdkEntry();
if (sdkEntry == null) {
Pair<String, Object> location =
Pair.<String, Object>create(FlexBCConfigurable.LOCATION_ON_TAB, DependenciesConfigurable.Location.SDK);
PlaceInProjectStructure place = new PlaceInBuildConfiguration(this, DependenciesConfigurable.TAB_NAME, location);
problemsHolder.registerProblem(FlexBundle.message("bc.problem.no.sdk"), null, ProjectStructureProblemType.error("sdk"),
place, null);
}
else {
if (FlexSdkUtils.findFlexOrFlexmojosSdk(sdkEntry.getName()) == null) {
Pair<String, Object> location =
Pair.<String, Object>create(FlexBCConfigurable.LOCATION_ON_TAB, DependenciesConfigurable.Location.SDK);
PlaceInProjectStructure place = new PlaceInBuildConfiguration(this, DependenciesConfigurable.TAB_NAME, location);
problemsHolder.registerProblem(FlexBundle.message("bc.problem.sdk.not.found", sdkEntry.getName()), null,
ProjectStructureProblemType.error("flex-bc-sdk"), place, null);
}
}
*/
checkDependencies(problemsHolder, editor);
checkSameOutputPaths(problemsHolder, configurator, editor);
checkIfBCOutputUsedAs3rdPartyLib(problemsHolder, configurator, editor);
ValidateFlashConfigurationsPrecompileTask.checkConfiguration(myModule, myBc, true, problem -> {
if (!(problem instanceof FlashProjectStructureProblem.FlexUnitOutputFolderProblem)) {
PlaceInProjectStructure place = new PlaceInBuildConfiguration(this, problem.tabName, problem.locationOnTab);
final ProjectStructureProblemType problemType = problem.severity == ProjectStructureProblemType.Severity.ERROR ? ProjectStructureProblemType.error(problem.errorId) : ProjectStructureProblemType.warning(problem.errorId);
problemsHolder.registerProblem(problem.errorMessage, null, problemType, place, null);
}
});
}
use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class BuildConfigurationProjectStructureElement method getUsagesInElement.
@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
FlexBCConfigurator configurator = FlexBuildConfigurationsExtension.getInstance().getConfigurator();
final FlexProjectConfigurationEditor editor = configurator.getConfigEditor();
assert editor != null;
final ModulesConfigurator modulesConfigurator = myContext.getModulesConfigurator();
final List<ProjectStructureElementUsage> usages = new ArrayList<>();
for (DependencyEntry dependencyEntry : myBc.getDependencies().getEntries()) {
if (dependencyEntry instanceof SharedLibraryEntry) {
String libraryName = ((SharedLibraryEntry) dependencyEntry).getLibraryName();
String libraryLevel = ((SharedLibraryEntry) dependencyEntry).getLibraryLevel();
final Library library = myContext.getLibrary(libraryName, libraryLevel);
if (library != null) {
usages.add(new UsageInBcDependencies(this, new LibraryProjectStructureElement(myContext, library)) {
@Override
public void removeSourceElement() {
libraryReplaced(library, null);
}
@Override
public void replaceElement(final ProjectStructureElement newElement) {
libraryReplaced(library, ((LibraryProjectStructureElement) newElement).getLibrary());
}
});
}
} else if (dependencyEntry instanceof BuildConfigurationEntry) {
final BuildConfigurationEntry bcEntry = (BuildConfigurationEntry) dependencyEntry;
Module module = modulesConfigurator.getModule(bcEntry.getModuleName());
if (module != null) {
final ModifiableFlexBuildConfiguration bc = ContainerUtil.find(editor.getConfigurations(module), configuration -> bcEntry.getBcName().equals(configuration.getName()));
if (bc != null) {
usages.add(new UsageInBcDependencies(this, new BuildConfigurationProjectStructureElement(bc, module, myContext)) {
@Override
public void removeSourceElement() {
// ignore as editor already listens to BC removal
}
@Override
public void replaceElement(final ProjectStructureElement newElement) {
throw new UnsupportedOperationException();
}
});
}
}
bcEntry.findBuildConfiguration();
}
}
Sdk sdk = myBc.getSdk();
if (sdk != null) {
usages.add(new UsageInBcDependencies(this, new SdkProjectStructureElement(myContext, sdk)) {
@Override
public void removeSourceElement() {
myBc.getDependencies().setSdkEntry(null);
}
@Override
public void replaceElement(final ProjectStructureElement newElement) {
throw new UnsupportedOperationException();
}
});
}
return usages;
}
use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class FlexTestUtils method createConfigEditor.
public static FlexProjectConfigurationEditor createConfigEditor(final Module... modules) {
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection") final Map<Module, ModifiableRootModel> models = new FactoryMap<Module, ModifiableRootModel>() {
@Override
protected ModifiableRootModel create(final Module module) {
final ModifiableRootModel result = ModuleRootManager.getInstance(module).getModifiableModel();
Disposer.register(module, new Disposable() {
@Override
public void dispose() {
if (!result.isDisposed()) {
result.dispose();
}
}
});
return result;
}
};
return new FlexProjectConfigurationEditor(modules[0].getProject(), new FlexProjectConfigurationEditor.ProjectModifiableModelProvider() {
@Override
public Module[] getModules() {
return modules;
}
@Override
public ModifiableRootModel getModuleModifiableModel(Module module) {
return models.get(module);
}
@Override
public void addListener(FlexBCConfigurator.Listener listener, Disposable parentDisposable) {
// ignore
}
@Override
public void commitModifiableModels() throws ConfigurationException {
ApplicationManager.getApplication().runWriteAction(() -> {
for (ModifiableRootModel model : models.values()) {
if (model.isChanged()) {
model.commit();
}
}
});
}
public Library findSourceLibraryForLiveName(final String name, final String level) {
return findSourceLibrary(name, level);
}
public Library findSourceLibrary(final String name, final String level) {
return getLibrariesTable(level).getLibraryByName(name);
}
private LibraryTable getLibrariesTable(final String level) {
if (LibraryTablesRegistrar.APPLICATION_LEVEL.equals(level)) {
return ApplicationLibraryTable.getApplicationTable();
} else {
assert LibraryTablesRegistrar.PROJECT_LEVEL.equals(level);
return ProjectLibraryTable.getInstance(modules[0].getProject());
}
}
});
}
use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class ActionScriptCompletionTest method testTwoSdks.
public void testTwoSdks() throws Exception {
final Sdk sdk45 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.5"), null, true);
final Sdk sdk46 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.6"), null, false);
FlexTestUtils.modifyConfigs(myProject, new Consumer<FlexProjectConfigurationEditor>() {
public void consume(final FlexProjectConfigurationEditor editor) {
ModifiableFlexBuildConfiguration bc1 = editor.getConfigurations(myModule)[0];
bc1.setName("1");
FlexTestUtils.setSdk(bc1, sdk45);
ModifiableFlexBuildConfiguration bc2 = editor.createConfiguration(myModule);
bc2.setName("2");
FlexTestUtils.setSdk(bc2, sdk46);
}
});
final FlexBuildConfigurationManager m = FlexBuildConfigurationManager.getInstance(myModule);
class TestZZ implements ThrowableRunnable<Exception> {
private final String myBcName;
private final String myExpectedTypeText;
TestZZ(final String bcName, final String expectedTypeText) {
myBcName = bcName;
myExpectedTypeText = expectedTypeText;
}
@Override
public void run() throws Exception {
m.setActiveBuildConfiguration(m.findConfigurationByName(myBcName));
defaultTest();
for (LookupElement item : myItems) {
final LookupElementPresentation p = new LookupElementPresentation();
item.renderElement(p);
assertEquals(myExpectedTypeText, p.getTypeText());
}
}
}
new TestZZ("1", sdk45.getName()).run();
new TestZZ("2", sdk46.getName()).run();
new TestZZ("1", sdk45.getName()).run();
}
use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class FlexmojosImporter method process.
public void process(final IdeModifiableModelsProvider modelsProvider, final Module module, final MavenRootModelAdapter modelAdapter, final MavenProjectsTree mavenTree, final MavenProject mavenProject, final MavenProjectChanges changes, final Map<MavenProject, String> mavenProjectToModuleName, final List<MavenProjectsProcessorTask> postTasks) {
expireNotification();
final FlexProjectConfigurationEditor currentEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
final boolean needToCommit = currentEditor == null;
final LibraryTable.ModifiableModel projectLibrariesModel = modelsProvider.getModifiableProjectLibrariesModel();
final Map<Module, ModifiableRootModel> moduleToModifiableModel = Collections.singletonMap(module, modelAdapter.getRootModel());
final FlexProjectConfigurationEditor flexEditor = currentEditor != null ? currentEditor : new FlexProjectConfigurationEditor(module.getProject(), FlexProjectConfigurationEditor.createModelProvider(moduleToModifiableModel, projectLibrariesModel, null)) {
@Nullable
protected Module findModuleWithBC(final BuildConfigurationEntry bcEntry) {
// don't check BC presence here because corresponding BC may appear later in next import cycle
return modelAdapter.findModuleByName(bcEntry.getModuleName());
}
};
final MavenPlugin flexmojosPlugin = getFlexmojosPlugin(mavenProject);
final Flexmojos3Configurator configurator = StringUtil.compareVersionNumbers(flexmojosPlugin.getVersion(), "5") >= 0 ? new Flexmojos5Configurator(module, modelsProvider, flexEditor, mavenTree, mavenProjectToModuleName, mavenProject, flexmojosPlugin, getCompiledLocales(mavenProject), getRuntimeLocales(mavenProject), this) : StringUtil.compareVersionNumbers(flexmojosPlugin.getVersion(), "4") >= 0 ? new Flexmojos4Configurator(module, modelsProvider, flexEditor, mavenTree, mavenProjectToModuleName, mavenProject, flexmojosPlugin, getCompiledLocales(mavenProject), getRuntimeLocales(mavenProject), this) : new Flexmojos3Configurator(module, modelsProvider, flexEditor, mavenTree, mavenProjectToModuleName, mavenProject, flexmojosPlugin, getCompiledLocales(mavenProject), getRuntimeLocales(mavenProject), this);
configurator.configureAndAppendTasks(postTasks);
if (needToCommit) {
try {
flexEditor.commit();
} catch (ConfigurationException e) {
// can't happen
MavenLog.LOG.error(e);
}
}
}
Aggregations