use of com.intellij.lang.javascript.flex.FlexModuleType in project intellij-plugins by JetBrains.
the class AirPackageAction method update.
public void update(final AnActionEvent e) {
final Project project = e.getProject();
boolean flexModulePresent = false;
boolean airAppPresent = false;
if (project != null) {
final FlexModuleType flexModuleType = FlexModuleType.getInstance();
MODULES_LOOP: for (Module module : ModuleManager.getInstance(project).getModules()) {
if (ModuleType.get(module) == flexModuleType) {
flexModulePresent = true;
for (FlexBuildConfiguration bc : FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations()) {
final BuildConfigurationNature nature = bc.getNature();
if (nature.isApp() && !nature.isWebPlatform()) {
airAppPresent = true;
break MODULES_LOOP;
}
}
}
}
}
e.getPresentation().setVisible(flexModulePresent);
e.getPresentation().setEnabled(airAppPresent && !CompilerManager.getInstance(project).isCompilationActive() && !AirPackageProjectParameters.getInstance(project).isPackagingInProgress());
}
use of com.intellij.lang.javascript.flex.FlexModuleType in project intellij-plugins by JetBrains.
the class FlexBuildConfigurationsExtension method getFlexModuleForNode.
@Nullable
private static Module getFlexModuleForNode(@Nullable MasterDetailsComponent.MyNode node) {
while (node != null) {
final NamedConfigurable configurable = node.getConfigurable();
final Object editableObject = configurable == null ? null : configurable.getEditableObject();
if (editableObject instanceof Module && ModuleType.get((Module) editableObject) instanceof FlexModuleType) {
return (Module) editableObject;
}
final TreeNode parent = node.getParent();
node = parent instanceof MasterDetailsComponent.MyNode ? (MasterDetailsComponent.MyNode) parent : null;
}
return null;
}
use of com.intellij.lang.javascript.flex.FlexModuleType in project intellij-plugins by JetBrains.
the class BCCombo method initCombo.
private void initCombo() {
setMinimumSize(new Dimension(150, getMinimumSize().height));
final Collection<FlexBuildConfiguration> allConfigs = new ArrayList<>();
final Module[] modules = ModuleManager.getInstance(myProject).getModules();
mySingleModuleProject = modules.length == 1;
for (final Module module : modules) {
if (ModuleType.get(module) instanceof FlexModuleType) {
for (final FlexBuildConfiguration config : FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations()) {
allConfigs.add(config);
myBCToModuleMap.put(config, module);
}
}
}
myAllConfigs = allConfigs.toArray(new FlexBuildConfiguration[allConfigs.size()]);
setRenderer(new ColoredListCellRendererWrapper() {
@Override
protected void doCustomize(final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) {
if (value instanceof Pair) {
final String moduleName = (String) ((Pair) value).first;
final String configName = (String) ((Pair) value).second;
//setIcon(PlatformIcons.ERROR_INTRODUCTION_ICON);
if (moduleName.isEmpty() || configName.isEmpty()) {
append(new SimpleColoredText("[none]", SimpleTextAttributes.ERROR_ATTRIBUTES));
} else {
append(BCUtils.renderMissingBuildConfiguration(configName, moduleName));
}
} else {
assert value instanceof FlexBuildConfiguration : value;
final FlexBuildConfiguration bc = (FlexBuildConfiguration) value;
setIcon(bc.getIcon());
append(BCUtils.renderBuildConfiguration(bc, mySingleModuleProject ? null : myBCToModuleMap.get(bc).getName()));
}
}
});
addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
// remove invalid entry
final Object selectedItem = getSelectedItem();
final Object firstItem = getItemAt(0);
if (selectedItem instanceof FlexBuildConfiguration && !(firstItem instanceof FlexBuildConfiguration)) {
setModel(new DefaultComboBoxModel(myAllConfigs));
setSelectedItem(selectedItem);
}
}
});
}
use of com.intellij.lang.javascript.flex.FlexModuleType in project intellij-plugins by JetBrains.
the class BCBasedRunnerParameters method checkAndGetModuleAndBC.
public Pair<Module, FlexBuildConfiguration> checkAndGetModuleAndBC(final Project project) throws RuntimeConfigurationError {
if (myModuleName.isEmpty() || myBCName.isEmpty()) {
throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
}
final Module module = ModuleManager.getInstance(project).findModuleByName(myModuleName);
if (module == null || !(ModuleType.get(module) instanceof FlexModuleType)) {
throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
}
final FlexBuildConfiguration bc = FlexBuildConfigurationManager.getInstance(module).findConfigurationByName(myBCName);
if (bc == null) {
throw new RuntimeConfigurationError(FlexBundle.message("module.does.not.contain.bc", myModuleName, myBCName));
}
final Sdk sdk = bc.getSdk();
if (sdk == null) {
throw new RuntimeConfigurationError(FlexCommonBundle.message("sdk.not.set.for.bc.0.of.module.1", bc.getName(), module.getName()));
}
return Pair.create(module, bc);
}
use of com.intellij.lang.javascript.flex.FlexModuleType in project intellij-plugins by JetBrains.
the class BCCombo method resetFrom.
public void resetFrom(final BCBasedRunnerParameters params) {
final Module module = ModuleManager.getInstance(myProject).findModuleByName(params.getModuleName());
final FlexBuildConfiguration config = module != null && (ModuleType.get(module) instanceof FlexModuleType) ? FlexBuildConfigurationManager.getInstance(module).findConfigurationByName(params.getBCName()) : null;
if (config == null) {
final Object[] model = new Object[myAllConfigs.length + 1];
model[0] = Pair.create(params.getModuleName(), params.getBCName());
System.arraycopy(myAllConfigs, 0, model, 1, myAllConfigs.length);
setModel(new DefaultComboBoxModel(model));
setSelectedIndex(0);
} else {
setModel(new DefaultComboBoxModel(myAllConfigs));
setSelectedItem(config);
}
}
Aggregations