use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlexBCTree method getBCNode.
private CheckedTreeNode getBCNode(final String moduleName, final String bcName) {
final Enumeration moduleNodes = ((CheckedTreeNode) getModel().getRoot()).children();
while (moduleNodes.hasMoreElements()) {
final CheckedTreeNode moduleNode = (CheckedTreeNode) moduleNodes.nextElement();
final Object userObject = moduleNode.getUserObject();
if (userObject instanceof Module && ((Module) userObject).getName().equals(moduleName)) {
final Enumeration bcNodes = moduleNode.children();
while (bcNodes.hasMoreElements()) {
final CheckedTreeNode bcNode = (CheckedTreeNode) bcNodes.nextElement();
final Object bcUserObject = bcNode.getUserObject();
if (bcUserObject instanceof FlexBuildConfiguration && ((FlexBuildConfiguration) bcUserObject).getName().equals(bcName)) {
return bcNode;
}
}
return null;
}
}
return null;
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class AirPackageDialog method checkDisabledCompilation.
private static boolean checkDisabledCompilation(final Project project, final Collection<Pair<Module, FlexBuildConfiguration>> selectedBCs) {
final Collection<FlexBuildConfiguration> bcsWithDisabledCompilation = new ArrayList<>();
for (Pair<Module, FlexBuildConfiguration> moduleAndBC : selectedBCs) {
if (moduleAndBC.second.isSkipCompile()) {
bcsWithDisabledCompilation.add(moduleAndBC.second);
}
}
if (!bcsWithDisabledCompilation.isEmpty()) {
final StringBuilder bcs = new StringBuilder();
for (FlexBuildConfiguration bc : bcsWithDisabledCompilation) {
bcs.append("<b>").append(StringUtil.escapeXml(bc.getName())).append("</b><br>");
}
final String message = FlexBundle.message("package.bc.with.disabled.compilation", bcsWithDisabledCompilation.size(), bcs.toString());
final int answer = Messages.showYesNoDialog(project, message, FlexBundle.message("package.air.application.title"), Messages.getWarningIcon());
return answer == Messages.YES;
}
return true;
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class ChooseActiveBuildConfigurationAction method createPopup.
public static ListPopup createPopup(@NotNull Module module) {
final DefaultActionGroup actionGroup = new DefaultActionGroup();
final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
final FlexBuildConfiguration activeBc = manager.getActiveConfiguration();
final FlexBuildConfiguration[] bcs = manager.getBuildConfigurations();
Arrays.sort(bcs, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
for (final FlexBuildConfiguration bc : bcs) {
actionGroup.add(new SelectBcAction(bc, manager));
}
actionGroup.addSeparator();
actionGroup.add(new EditBcsAction(module));
final DataContext dataContext = SimpleDataContext.getProjectContext(module.getProject());
return new PopupFactoryImpl.ActionGroupPopup(FlexBundle.message("choose.build.configuration.popup.title", module.getName()), actionGroup, dataContext, false, false, false, true, null, -1, anAction -> anAction instanceof SelectBcAction && ((SelectBcAction) anAction).getBC() == activeBc, null) {
@Override
protected ListCellRenderer getListElementRenderer() {
return new PopupListElementRenderer(this) {
{
//myRendererComponent.setBorder(new EmptyBorder(5, 0, 5, 0));
}
@Override
protected JComponent createItemComponent() {
return new MyPanel();
}
@Override
public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
MyPanel p = (MyPanel) myComponent;
p.clear();
PopupFactoryImpl.ActionItem actionItem = (PopupFactoryImpl.ActionItem) value;
AnAction anAction = actionItem.getAction();
SimpleColoredText text;
Icon icon;
boolean isActive;
if (anAction instanceof SelectBcAction) {
FlexBuildConfiguration bc = ((SelectBcAction) anAction).getBC();
isActive = bc == activeBc;
text = BCUtils.renderBuildConfiguration(bc, null, isActive);
icon = bc.getIcon();
} else {
text = new SimpleColoredText(anAction.getTemplatePresentation().getText(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
icon = anAction.getTemplatePresentation().getIcon();
isActive = false;
}
RowIcon rowIcon = new RowIcon(2);
rowIcon.setIcon(isActive ? (isSelected ? ICON_ACTIVE_SELECTED : ICON_ACTIVE) : ICON_EMPTY, 0);
rowIcon.setIcon(icon, 1);
p.setIcon(rowIcon);
if (isSelected) {
text = text.derive(SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES, true);
setSelected(p);
} else {
setDeselected(p);
}
p.setText(text);
mySeparatorComponent.setVisible(actionItem.isPrependWithSeparator());
return myRendererComponent;
}
};
}
};
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlexOrderEnumerationHandler method processModuleWithBuildConfiguration.
// configuration is null for root module (one for which scope is being computed)
private static void processModuleWithBuildConfiguration(@NotNull Module module, @Nullable FlexBuildConfiguration bc, Map<Module, ModuleData> modules2activeConfigurations, Set<FlexBuildConfiguration> processedConfigurations, boolean productionDependency) {
if (ModuleType.get(module) != FlexModuleType.getInstance()) {
return;
}
final boolean isRootModule = bc == null;
if (isRootModule) {
bc = getActiveConfiguration(module);
}
if (bc == null || !processedConfigurations.add(bc)) {
return;
}
ModuleData moduleData = modules2activeConfigurations.get(module);
if (moduleData == null) {
modules2activeConfigurations.put(module, moduleData = new ModuleData());
}
moduleData.addBc(bc, productionDependency);
for (DependencyEntry entry : bc.getDependencies().getEntries()) {
if (!(entry instanceof BuildConfigurationEntry)) {
continue;
}
final LinkageType linkageType = entry.getDependencyType().getLinkageType();
if (linkageType == LinkageType.LoadInRuntime) {
continue;
}
FlexBuildConfiguration dependencyBc = ((BuildConfigurationEntry) entry).findBuildConfiguration();
if (dependencyBc == null || !FlexCommonUtils.checkDependencyType(bc.getOutputType(), dependencyBc.getOutputType(), linkageType)) {
continue;
}
if (!isRootModule && !BCUtils.isTransitiveDependency(linkageType)) {
continue;
}
Module dependencyModule = ((BuildConfigurationEntry) entry).findModule();
if (dependencyModule == null || dependencyModule == module) {
continue;
}
processModuleWithBuildConfiguration(dependencyModule, dependencyBc, modules2activeConfigurations, processedConfigurations, entry.getDependencyType().getLinkageType() != LinkageType.Test);
}
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlexOrderEnumerationHandler method shouldAddDependency.
@NotNull
@Override
public AddDependencyType shouldAddDependency(@NotNull OrderEntry orderEntry, @NotNull OrderEnumeratorSettings settings) {
Module module = orderEntry.getOwnerModule();
if (ModuleType.get(module) != FlexModuleType.getInstance()) {
return super.shouldAddDependency(orderEntry, settings);
}
if (orderEntry instanceof ModuleSourceOrderEntry) {
return AddDependencyType.DEFAULT;
}
if (orderEntry instanceof JdkOrderEntry) {
if (module != myRootModule) {
// never add transitive dependency to Flex SDK
return AddDependencyType.DO_NOT_ADD;
}
if (myActiveConfigurations == null) {
return AddDependencyType.DEFAULT;
}
ModuleData moduleData = myActiveConfigurations.get(module);
for (FlexBuildConfiguration bc : moduleData.bcs) {
if (bc.getSdk() != null) {
return AddDependencyType.DEFAULT;
}
}
return AddDependencyType.DO_NOT_ADD;
}
Collection<FlexBuildConfiguration> accessibleConfigurations;
if (myActiveConfigurations != null) {
ModuleData moduleData = myActiveConfigurations.get(module);
accessibleConfigurations = moduleData != null ? moduleData.bcs : Collections.emptyList();
} else {
// let all configurations be accessible in ProjectOrderEnumerator
accessibleConfigurations = Arrays.asList(FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations());
}
if (orderEntry instanceof LibraryOrderEntry) {
final LibraryEx library = (LibraryEx) ((LibraryOrderEntry) orderEntry).getLibrary();
if (library == null) {
return AddDependencyType.DEFAULT;
}
if (library.getKind() == FlexLibraryType.FLEX_LIBRARY) {
return FlexProjectRootsUtil.dependOnLibrary(accessibleConfigurations, library, module != myRootModule, settings.isProductionOnly()) ? AddDependencyType.DEFAULT : AddDependencyType.DO_NOT_ADD;
} else {
// foreign library
return AddDependencyType.DO_NOT_ADD;
}
} else if (orderEntry instanceof ModuleOrderEntry) {
final Module dependencyModule = ((ModuleOrderEntry) orderEntry).getModule();
if (dependencyModule == null) {
return AddDependencyType.DO_NOT_ADD;
}
if (myActiveConfigurations != null) {
ModuleData moduleData = myActiveConfigurations.get(dependencyModule);
return moduleData != null && (moduleData.accessibleInProduction || !settings.isProductionOnly()) ? AddDependencyType.DEFAULT : AddDependencyType.DO_NOT_ADD;
} else {
// let all modules dependencies be accessible in ProjectOrderEnumerator
return AddDependencyType.DEFAULT;
}
} else {
return AddDependencyType.DEFAULT;
}
}
Aggregations