Search in sources :

Example 1 with FlexBCConfigurator

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);
    }
}
Also used : com.intellij.openapi.util(com.intellij.openapi.util) UIUtil(com.intellij.util.ui.UIUtil) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) EventDispatcher(com.intellij.util.EventDispatcher) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ProjectModelExternalSource(com.intellij.openapi.roots.ProjectModelExternalSource) VirtualFile(com.intellij.openapi.vfs.VirtualFile) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) ComponentSet(com.intellij.flex.model.bc.ComponentSet) ColumnInfo(com.intellij.util.ui.ColumnInfo) TableCellRenderer(javax.swing.table.TableCellRenderer) VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager) FlexCommonUtils(com.intellij.flex.FlexCommonUtils) EditExistingLibraryDialog(com.intellij.openapi.roots.ui.configuration.libraryEditor.EditExistingLibraryDialog) BCUtils(com.intellij.lang.javascript.flex.projectStructure.options.BCUtils) JBComboBoxTableCellEditorComponent(com.intellij.ui.components.editors.JBComboBoxTableCellEditorComponent) Nls(org.jetbrains.annotations.Nls) FlexmojosSdkType(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType) MasterDetailsComponent(com.intellij.openapi.ui.MasterDetailsComponent) JdkComboBox(com.intellij.openapi.roots.ui.configuration.JdkComboBox) com.intellij.openapi.roots.ui.configuration.projectRoot(com.intellij.openapi.roots.ui.configuration.projectRoot) Messages(com.intellij.openapi.ui.Messages) FileUtil(com.intellij.openapi.util.io.FileUtil) ChangeListener(javax.swing.event.ChangeListener) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) FlexLibraryType(com.intellij.lang.javascript.flex.library.FlexLibraryType) FlexBuildConfigurationsExtension(com.intellij.lang.javascript.flex.projectStructure.FlexBuildConfigurationsExtension) ChangeEvent(javax.swing.event.ChangeEvent) OrderRootType(com.intellij.openapi.roots.OrderRootType) FlexBundle(com.intellij.lang.javascript.flex.FlexBundle) com.intellij.ui(com.intellij.ui) ChooseLibrariesFromTablesDialog(com.intellij.util.ui.classpath.ChooseLibrariesFromTablesDialog) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Nullable(org.jetbrains.annotations.Nullable) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) List(java.util.List) LibraryTableModifiableModelProvider(com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider) FlexLibraryIdGenerator(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexLibraryIdGenerator) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) java.awt.event(java.awt.event) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) PopupStep(com.intellij.openapi.ui.popup.PopupStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) SdkType(com.intellij.openapi.projectRoots.SdkType) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) NotNull(org.jetbrains.annotations.NotNull) FilteringIterator(com.intellij.util.containers.FilteringIterator) java.util(java.util) OutputType(com.intellij.flex.model.bc.OutputType) ContainerUtil(com.intellij.util.containers.ContainerUtil) MessageFormat(java.text.MessageFormat) History(com.intellij.ui.navigation.History) FlexSdkType2(com.intellij.lang.javascript.flex.sdk.FlexSdkType2) TableCellEditor(javax.swing.table.TableCellEditor) Factory(com.intellij.lang.javascript.flex.projectStructure.model.impl.Factory) Project(com.intellij.openapi.project.Project) FlexSdkUtils(com.intellij.lang.javascript.flex.sdk.FlexSdkUtils) CreateModuleLibraryChooser(com.intellij.openapi.roots.ui.configuration.classpath.CreateModuleLibraryChooser) SdkTypeId(com.intellij.openapi.projectRoots.SdkTypeId) PlatformIcons(com.intellij.util.PlatformIcons) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) FlexBCConfigurator(com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator) com.intellij.openapi.roots.libraries(com.intellij.openapi.roots.libraries) ProjectBundle(com.intellij.openapi.project.ProjectBundle) StringUtil(com.intellij.openapi.util.text.StringUtil) SdkModel(com.intellij.openapi.projectRoots.SdkModel) ComboBoxTableRenderer(com.intellij.openapi.ui.ComboBoxTableRenderer) com.intellij.lang.javascript.flex.projectStructure.model(com.intellij.lang.javascript.flex.projectStructure.model) Disposable(com.intellij.openapi.Disposable) Sdk(com.intellij.openapi.projectRoots.Sdk) JBPopup(com.intellij.openapi.ui.popup.JBPopup) BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) LinkageType(com.intellij.flex.model.bc.LinkageType) FlexProjectRootsUtil(com.intellij.lang.javascript.flex.projectStructure.options.FlexProjectRootsUtil) java.awt(java.awt) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Place(com.intellij.ui.navigation.Place) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) JarFileSystem(com.intellij.openapi.vfs.JarFileSystem) FlexIcons(icons.FlexIcons) OrderEntryAppearanceService(com.intellij.openapi.roots.ui.OrderEntryAppearanceService) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) UIRootConfigurationAccessor(com.intellij.openapi.roots.ui.configuration.UIRootConfigurationAccessor) FlexLibraryProperties(com.intellij.lang.javascript.flex.library.FlexLibraryProperties) javax.swing(javax.swing) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) FlexBCConfigurator(com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module)

Example 2 with FlexBCConfigurator

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);
        }
    });
}
Also used : FlexBCConfigurator(com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)

Example 3 with FlexBCConfigurator

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;
}
Also used : FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContainerUtil(com.intellij.util.containers.ContainerUtil) ArrayList(java.util.ArrayList) Library(com.intellij.openapi.roots.libraries.Library) FlexCompilerHandler(com.intellij.lang.javascript.flex.build.FlexCompilerHandler) StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) com.intellij.openapi.roots.ui.configuration.projectRoot.daemon(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon) FileUtil(com.intellij.openapi.util.io.FileUtil) Module(com.intellij.openapi.module.Module) FlexCommonBundle(com.intellij.flex.FlexCommonBundle) FlexBuildConfigurationsExtension(com.intellij.lang.javascript.flex.projectStructure.FlexBuildConfigurationsExtension) FlexBCConfigurator(com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator) OrderRootType(com.intellij.openapi.roots.OrderRootType) FlexBundle(com.intellij.lang.javascript.flex.FlexBundle) ValidateFlashConfigurationsPrecompileTask(com.intellij.lang.javascript.flex.build.ValidateFlashConfigurationsPrecompileTask) com.intellij.lang.javascript.flex.projectStructure.model(com.intellij.lang.javascript.flex.projectStructure.model) Sdk(com.intellij.openapi.projectRoots.Sdk) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) LinkageType(com.intellij.flex.model.bc.LinkageType) FlexProjectRootsUtil(com.intellij.lang.javascript.flex.projectStructure.options.FlexProjectRootsUtil) FlashProjectStructureProblem(com.intellij.lang.javascript.flex.build.FlashProjectStructureProblem) Nullable(org.jetbrains.annotations.Nullable) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Place(com.intellij.ui.navigation.Place) List(java.util.List) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) Condition(com.intellij.openapi.util.Condition) ArrayList(java.util.ArrayList) FlexBCConfigurator(com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) Library(com.intellij.openapi.roots.libraries.Library) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module)

Example 4 with FlexBCConfigurator

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);
}
Also used : FlexBCConfigurator(com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator) HashMap(com.intellij.util.containers.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FlexBCConfigurator (com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator)4 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)3 Module (com.intellij.openapi.module.Module)3 List (java.util.List)3 Nullable (org.jetbrains.annotations.Nullable)3 LinkageType (com.intellij.flex.model.bc.LinkageType)2 FlexBundle (com.intellij.lang.javascript.flex.FlexBundle)2 FlexBuildConfigurationsExtension (com.intellij.lang.javascript.flex.projectStructure.FlexBuildConfigurationsExtension)2 com.intellij.lang.javascript.flex.projectStructure.model (com.intellij.lang.javascript.flex.projectStructure.model)2 FlexProjectRootsUtil (com.intellij.lang.javascript.flex.projectStructure.options.FlexProjectRootsUtil)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)2 OrderRootType (com.intellij.openapi.roots.OrderRootType)2 ProjectStructureConfigurable (com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)2 FileUtil (com.intellij.openapi.util.io.FileUtil)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Place (com.intellij.ui.navigation.Place)2 ContainerUtil (com.intellij.util.containers.ContainerUtil)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2