use of com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator in project intellij-plugins by JetBrains.
the class DependenciesConfigurable method resetTable.
private void resetTable(SdkEntry sdkEntry, boolean keepSelection) {
int[] selectedRows = keepSelection ? myTable.getSelectedRows() : new int[0];
DefaultMutableTreeNode root = myTable.getRoot();
root.removeAllChildren();
if (sdkEntry != null) {
Sdk flexSdk = FlexSdkUtils.findFlexOrFlexmojosSdk(sdkEntry.getName());
if (flexSdk != null) {
DefaultMutableTreeNode sdkNode = new DefaultMutableTreeNode(new SdkItem(flexSdk), true);
myTable.getRoot().insert(sdkNode, 0);
updateSdkEntries(sdkNode, flexSdk);
}
}
FlexBCConfigurator configurator = FlexBuildConfigurationsExtension.getInstance().getConfigurator();
for (DependencyEntry entry : myDependencies.getEntries()) {
MyTableItem item = null;
if (entry instanceof BuildConfigurationEntry) {
final BuildConfigurationEntry bcEntry = (BuildConfigurationEntry) entry;
Module module = bcEntry.findModule();
CompositeConfigurable configurable = module != null ? ContainerUtil.find(configurator.getBCConfigurables(module), configurable1 -> configurable1.getDisplayName().equals(bcEntry.getBcName())) : null;
if (configurable == null) {
item = new BCItem(bcEntry.getModuleName(), bcEntry.getBcName());
} else {
item = new BCItem(FlexBCConfigurable.unwrap(configurable));
}
((BCItem) item).dependencyType.copyFrom(entry.getDependencyType());
} else if (entry instanceof ModuleLibraryEntry) {
ModuleLibraryEntry moduleLibraryEntry = (ModuleLibraryEntry) entry;
item = new ModuleLibraryItem(moduleLibraryEntry.getLibraryId(), myConfigEditor.findLibraryOrderEntry(myDependencies, moduleLibraryEntry), myProject);
((ModuleLibraryItem) item).dependencyType.copyFrom(entry.getDependencyType());
} else if (entry instanceof SharedLibraryEntry) {
SharedLibraryEntry sharedLibraryEntry = (SharedLibraryEntry) entry;
LibrariesModifiableModel model = ProjectStructureConfigurable.getInstance(myProject).getContext().createModifiableModelProvider(sharedLibraryEntry.getLibraryLevel()).getModifiableModel();
LibraryEx library = (LibraryEx) model.getLibraryByName(sharedLibraryEntry.getLibraryName());
item = new SharedLibraryItem(sharedLibraryEntry.getLibraryName(), sharedLibraryEntry.getLibraryLevel(), library, myProject);
((SharedLibraryItem) item).dependencyType.copyFrom(entry.getDependencyType());
}
if (item != null) {
root.add(new DefaultMutableTreeNode(item, false));
}
}
myTable.refresh();
myTable.clearSelection();
for (int row : selectedRows) {
myTable.getSelectionModel().addSelectionInterval(row, row);
}
}
use of com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator 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.FlexBCConfigurator 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.FlexBCConfigurator in project intellij-plugins by JetBrains.
the class ChooseBuildConfigurationDialog method createForApplicableBCs.
/**
* @param project
* @param filter
* @return <code>null</code> if there's no applicable BC configurables according to the filter provided
*/
@Nullable
public static ChooseBuildConfigurationDialog createForApplicableBCs(String title, @Nullable String labelText, Project project, boolean allowEmptySelection, Condition<FlexBCConfigurable> filter) {
Map<Module, List<FlexBCConfigurable>> treeItems = new HashMap<>();
FlexBCConfigurator configurator = FlexBuildConfigurationsExtension.getInstance().getConfigurator();
for (Module module : ModuleStructureConfigurable.getInstance(project).getModules()) {
if (ModuleType.get(module) != FlexModuleType.getInstance()) {
continue;
}
for (CompositeConfigurable configurable : configurator.getBCConfigurables(module)) {
FlexBCConfigurable flexBCConfigurable = FlexBCConfigurable.unwrap(configurable);
if (!filter.value(flexBCConfigurable)) {
continue;
}
List<FlexBCConfigurable> list = treeItems.get(module);
if (list == null) {
list = new ArrayList<>();
treeItems.put(module, list);
}
list.add(flexBCConfigurable);
}
}
if (treeItems.isEmpty()) {
return null;
}
return new ChooseBuildConfigurationDialog(title, labelText, project, allowEmptySelection, treeItems);
}
Aggregations