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);
}
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);
}
}
}
}
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;
}
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());
}
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);
});
}
Aggregations