Search in sources :

Example 6 with Place

use of com.intellij.ui.navigation.Place in project intellij-plugins by JetBrains.

the class FlexBuildConfigurationsExtension method selectOrderEntry.

@Nullable
public ActionCallback selectOrderEntry(@NotNull final Module module, @Nullable final OrderEntry entry) {
    if (ModuleType.get(module) != FlexModuleType.getInstance()) {
        return null;
    }
    if (entry instanceof LibraryOrderEntry) {
        final Library library = ((LibraryOrderEntry) entry).getLibrary();
        if (library != null && library.getTable() == null && ((LibraryEx) library).getKind() == FlexLibraryType.FLEX_LIBRARY) {
            final String libraryId = FlexProjectRootsUtil.getLibraryId(library);
            final List<CompositeConfigurable> configurables = myConfigurator.getBCConfigurables(module);
            // several build configurations may depend on the same library, here we select the first one we find
            for (CompositeConfigurable configurable : configurables) {
                final FlexBCConfigurable bcConfigurable = FlexBCConfigurable.unwrap(configurable);
                final Dependencies dependencies = bcConfigurable.getDependenciesConfigurable().getEditableObject();
                for (DependencyEntry e : dependencies.getEntries()) {
                    if (!(e instanceof ModuleLibraryEntry) || !((ModuleLibraryEntry) e).getLibraryId().equals(libraryId)) {
                        continue;
                    }
                    final Place p = FlexProjectStructureUtil.createPlace(bcConfigurable, DependenciesConfigurable.TAB_NAME);
                    final DependenciesConfigurable.Location.TableEntry tableEntry = DependenciesConfigurable.Location.TableEntry.forModuleLibrary(libraryId);
                    p.putPath(FlexBCConfigurable.LOCATION_ON_TAB, tableEntry);
                    return ProjectStructureConfigurable.getInstance(module.getProject()).navigateTo(p, true);
                }
            }
        }
    }
    return ProjectStructureConfigurable.getInstance(module.getProject()).select(module.getName(), null, true);
}
Also used : ModuleLibraryEntry(com.intellij.lang.javascript.flex.projectStructure.model.ModuleLibraryEntry) CompositeConfigurable(com.intellij.lang.javascript.flex.projectStructure.ui.CompositeConfigurable) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) FlexBCConfigurable(com.intellij.lang.javascript.flex.projectStructure.ui.FlexBCConfigurable) DependencyEntry(com.intellij.lang.javascript.flex.projectStructure.model.DependencyEntry) Library(com.intellij.openapi.roots.libraries.Library) Dependencies(com.intellij.lang.javascript.flex.projectStructure.model.Dependencies) Place(com.intellij.ui.navigation.Place) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with Place

use of com.intellij.ui.navigation.Place in project intellij-plugins by JetBrains.

the class BuildConfigurationProjectStructureElement method checkIfBCOutputUsedAs3rdPartyLib.

private void checkIfBCOutputUsedAs3rdPartyLib(final ProjectStructureProblemsHolder problemsHolder, final FlexBCConfigurator configurator, final DependencyEntry entry, final VirtualFile[] classesRoots) {
    for (VirtualFile libFile : classesRoots) {
        final VirtualFile realFile = FlexCompilerHandler.getRealFile(libFile);
        if (realFile != null && !realFile.isDirectory() && "swc".equalsIgnoreCase(realFile.getExtension())) {
            final List<ModifiableFlexBuildConfiguration> bcs = configurator.getBCsByOutputPath(realFile.getPath());
            if (bcs != null && !bcs.isEmpty()) {
                final ModifiableFlexBuildConfiguration otherLibBC = bcs.get(0);
                final FlexProjectConfigurationEditor editor = configurator.getConfigEditor();
                assert editor != null;
                final Module otherLibModule = editor.getModule(otherLibBC);
                final String message = FlexBundle.message("own.lib.used.as.3rd.party", realFile.getName(), otherLibBC.getName(), otherLibModule.getName());
                final Object location = entry instanceof ModuleLibraryEntry ? DependenciesConfigurable.Location.TableEntry.forModuleLibrary(((ModuleLibraryEntry) entry).getLibraryId()) : DependenciesConfigurable.Location.TableEntry.forSharedLibrary(((SharedLibraryEntry) entry).getLibraryLevel(), ((SharedLibraryEntry) entry).getLibraryName());
                final PlaceInProjectStructure placeInPS = new PlaceInBuildConfiguration(this, DependenciesConfigurable.TAB_NAME, location);
                final String quickFixName = FlexBundle.message("instead.setup.dependency.on.bc", otherLibBC.getName(), otherLibModule.getName());
                final ConfigurationErrorQuickFix quickFix = new ConfigurationErrorQuickFix(quickFixName) {

                    public void performFix() {
                        final FlexBCConfigurable configurable = configurator.getBCConfigurable(myBc);
                        final DependenciesConfigurable dependenciesConfigurable = configurable.getDependenciesConfigurable();
                        final FlexBCConfigurable otherLibConfigurable = configurator.getBCConfigurable(otherLibBC);
                        final LinkageType linkageType = entry.getDependencyType().getLinkageType();
                        dependenciesConfigurable.addBCDependency(otherLibConfigurable, linkageType);
                        if (entry instanceof ModuleLibraryEntry) {
                            dependenciesConfigurable.removeDependency(((ModuleLibraryEntry) entry).getLibraryId());
                        } else {
                            dependenciesConfigurable.removeDependency(((SharedLibraryEntry) entry).getLibraryLevel(), ((SharedLibraryEntry) entry).getLibraryName());
                        }
                        final Place place = configurator.getPlaceFor(myModule, myBc.getName());
                        place.putPath(CompositeConfigurable.TAB_NAME, DependenciesConfigurable.TAB_NAME);
                        place.putPath(FlexBCConfigurable.LOCATION_ON_TAB, DependenciesConfigurable.Location.TableEntry.forBc(otherLibConfigurable));
                        ProjectStructureConfigurable.getInstance(myModule.getProject()).navigateTo(place, true);
                    }
                };
                final String errorId = entry instanceof ModuleLibraryEntry ? ((ModuleLibraryEntry) entry).getLibraryId() : ((SharedLibraryEntry) entry).getLibraryName();
                problemsHolder.registerProblem(message, null, ProjectStructureProblemType.warning(errorId), placeInPS, quickFix);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) Module(com.intellij.openapi.module.Module) Place(com.intellij.ui.navigation.Place) LinkageType(com.intellij.flex.model.bc.LinkageType)

Example 8 with Place

use of com.intellij.ui.navigation.Place in project intellij-plugins by JetBrains.

the class FlexBCConfigurator method getPlaceFor.

public Place getPlaceFor(final Module module, final String bcName) {
    Place p = new Place();
    p = p.putPath(ProjectStructureConfigurable.CATEGORY, ModuleStructureConfigurable.getInstance(myConfigEditor.getProject()));
    p = p.putPath(MasterDetailsComponent.TREE_OBJECT, myConfigEditor.findCurrentConfiguration(module, bcName));
    return p;
}
Also used : Place(com.intellij.ui.navigation.Place)

Example 9 with Place

use of com.intellij.ui.navigation.Place in project intellij-plugins by JetBrains.

the class FlexBaseRunner method showBCCompilationSkippedWarning.

private static void showBCCompilationSkippedWarning(final Module module, final FlexBuildConfiguration bc) {
    final String message = FlexBundle.message("run.when.ide.builder.turned.off", bc.getName(), module.getName());
    COMPILE_BEFORE_LAUNCH_NOTIFICATION_GROUP.createNotification("", message, NotificationType.WARNING, new NotificationListener() {

        @Override
        public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
            if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                notification.expire();
                if ("BuildConfiguration".equals(event.getDescription())) {
                    final ProjectStructureConfigurable projectStructureConfigurable = ProjectStructureConfigurable.getInstance(module.getProject());
                    ShowSettingsUtil.getInstance().editConfigurable(module.getProject(), projectStructureConfigurable, () -> {
                        Place p = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getPlaceFor(module, bc.getName());
                        projectStructureConfigurable.navigateTo(p, true);
                    });
                } else if ("DisableWarning".equals(event.getDescription())) {
                    disableCompilationSkippedWarning(module.getProject());
                }
            }
        }
    }).notify(module.getProject());
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Place(com.intellij.ui.navigation.Place) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)

Example 10 with Place

use of com.intellij.ui.navigation.Place in project intellij-plugins by JetBrains.

the class DeclareConditionalCompilerDefinitionFix method applyFix.

protected void applyFix(final Project project, final PsiElement psiElement, final PsiFile file, final Editor editor) {
    final ProjectStructureConfigurable configurable = ProjectStructureConfigurable.getInstance(project);
    ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> {
        final FlexBuildConfiguration bc = FlexBuildConfigurationManager.getInstance(myModule).getActiveConfiguration();
        final Place place = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getPlaceFor(myModule, bc.getName()).putPath(CompositeConfigurable.TAB_NAME, CompilerOptionsConfigurable.TAB_NAME).putPath(FlexBCConfigurable.LOCATION_ON_TAB, CompilerOptionsConfigurable.Location.ConditionalCompilerDefinition).putPath(CompilerOptionsConfigurable.CONDITIONAL_COMPILER_DEFINITION_NAME, myConditionalCompilerDefinitionName);
        configurable.navigateTo(place, true);
    });
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Place(com.intellij.ui.navigation.Place) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)

Aggregations

Place (com.intellij.ui.navigation.Place)16 ProjectStructureConfigurable (com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)4 Module (com.intellij.openapi.module.Module)3 NotNull (org.jetbrains.annotations.NotNull)3 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)2 CompositeConfigurable (com.intellij.lang.javascript.flex.projectStructure.ui.CompositeConfigurable)2 Library (com.intellij.openapi.roots.libraries.Library)2 DependenciesPerspectiveConfigurable (com.android.tools.idea.gradle.structure.configurables.DependenciesPerspectiveConfigurable)1 ProjectStructureConfigurable (com.android.tools.idea.structure.dialog.ProjectStructureConfigurable)1 LinkageType (com.intellij.flex.model.bc.LinkageType)1 Dependencies (com.intellij.lang.javascript.flex.projectStructure.model.Dependencies)1 DependencyEntry (com.intellij.lang.javascript.flex.projectStructure.model.DependencyEntry)1 ModuleLibraryEntry (com.intellij.lang.javascript.flex.projectStructure.model.ModuleLibraryEntry)1 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)1 FlexBCConfigurable (com.intellij.lang.javascript.flex.projectStructure.ui.FlexBCConfigurable)1 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)1 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)1 ClasspathEditor (com.intellij.openapi.roots.ui.configuration.ClasspathEditor)1 ModuleEditor (com.intellij.openapi.roots.ui.configuration.ModuleEditor)1 ModuleStructureConfigurable (com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable)1