use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElementUsage in project intellij-community by JetBrains.
the class FindUsagesInProjectStructureActionBase method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final ProjectStructureElement selected = getSelectedElement();
if (selected == null)
return;
final Collection<ProjectStructureElementUsage> usages = getContext().getDaemonAnalyzer().getUsages(selected);
if (usages.isEmpty()) {
Messages.showInfoMessage(myParentComponent, FindBundle.message("find.usage.view.no.usages.text"), FindBundle.message("find.pointcut.applications.not.found.title"));
return;
}
RelativePoint point = getPointToShowResults();
final ProjectStructureElementUsage[] usagesArray = usages.toArray(new ProjectStructureElementUsage[usages.size()]);
Arrays.sort(usagesArray, (o1, o2) -> o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName()));
BaseListPopupStep<ProjectStructureElementUsage> step = new BaseListPopupStep<ProjectStructureElementUsage>(ProjectBundle.message("dependencies.used.in.popup.title"), usagesArray) {
@Override
public PopupStep onChosen(final ProjectStructureElementUsage selected, final boolean finalChoice) {
selected.getPlace().navigate();
return FINAL_CHOICE;
}
@NotNull
@Override
public String getTextFor(ProjectStructureElementUsage value) {
return value.getPresentableName();
}
@Override
public Icon getIconFor(ProjectStructureElementUsage selection) {
return selection.getIcon();
}
};
new ListPopupImpl(step) {
@Override
protected ListCellRenderer getListElementRenderer() {
return new ListCellRendererWithRightAlignedComponent<ProjectStructureElementUsage>() {
@Override
protected void customize(ProjectStructureElementUsage value) {
setLeftText(value.getPresentableName());
setIcon(value.getIcon());
setRightForeground(Color.GRAY);
setRightText(value.getPresentableLocationInElement());
}
};
}
}.show(point);
}
use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElementUsage in project intellij-community by JetBrains.
the class ChangeLibraryLevelAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final ProjectStructureElement selectedElement = mySourceConfigurable.getSelectedElement();
if (!(selectedElement instanceof LibraryProjectStructureElement))
return;
final StructureConfigurableContext context = mySourceConfigurable.myContext;
final LibraryProjectStructureElement libraryElement = (LibraryProjectStructureElement) selectedElement;
final LibraryEx oldLibrary = (LibraryEx) context.getLibrary(libraryElement.getLibrary().getName(), mySourceConfigurable.getLevel());
LOG.assertTrue(oldLibrary != null);
final Library newLibrary = doCopy(oldLibrary);
if (newLibrary == null)
return;
final Collection<ProjectStructureElementUsage> usages = context.getDaemonAnalyzer().getUsages(libraryElement);
for (ProjectStructureElementUsage usage : usages) {
usage.replaceElement(new LibraryProjectStructureElement(context, newLibrary));
}
if (!myCopy) {
mySourceConfigurable.removeLibrary(libraryElement);
}
ProjectStructureConfigurable.getInstance(myProject).selectProjectOrGlobalLibrary(newLibrary, true);
}
Aggregations