use of com.intellij.ide.projectView.impl.ModuleGroup in project intellij-community by JetBrains.
the class ModuleGroupNode method getChildren.
@Override
@NotNull
public Collection<AbstractTreeNode> getChildren() {
ModuleGrouper grouper = ModuleGrouper.instanceFor(getProject());
final Collection<ModuleGroup> childGroups = getValue().childGroups(grouper);
final List<AbstractTreeNode> result = new ArrayList<>();
for (final ModuleGroup childGroup : childGroups) {
result.add(createModuleGroupNode(childGroup));
}
Collection<Module> modules = getValue().modulesInGroup(grouper, false);
try {
for (Module module : modules) {
result.add(createModuleNode(module));
}
} catch (Exception e) {
LOG.error(e);
}
return result;
}
use of com.intellij.ide.projectView.impl.ModuleGroup in project intellij-community by JetBrains.
the class PsiPackageFavoriteNodeProvider method getFavoriteNodes.
@Override
public Collection<AbstractTreeNode> getFavoriteNodes(final DataContext context, final ViewSettings viewSettings) {
final Project project = CommonDataKeys.PROJECT.getData(context);
if (project == null)
return null;
PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(context);
if (elements == null) {
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
if (element != null) {
elements = new PsiElement[] { element };
}
}
final Collection<AbstractTreeNode> result = new ArrayList<>();
if (elements != null) {
for (PsiElement element : elements) {
if (element instanceof PsiPackage) {
final PsiPackage psiPackage = (PsiPackage) element;
final PsiDirectory[] directories = psiPackage.getDirectories();
if (directories.length > 0) {
final VirtualFile firstDir = directories[0].getVirtualFile();
final boolean isLibraryRoot = ProjectRootsUtil.isLibraryRoot(firstDir, project);
final PackageElement packageElement = new PackageElement(LangDataKeys.MODULE.getData(context), psiPackage, isLibraryRoot);
result.add(new PackageElementNode(project, packageElement, viewSettings));
}
}
}
return result.isEmpty() ? null : result;
}
final String currentViewId = ProjectView.getInstance(project).getCurrentViewId();
final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(context);
if (modules != null) {
for (Module module : modules) {
if (PackageViewPane.ID.equals(currentViewId)) {
result.add(new PackageViewModuleNode(project, module, viewSettings));
} else {
result.add(new ProjectViewModuleNode(project, module, viewSettings));
}
}
} else {
final ModuleGroup[] data = ModuleGroup.ARRAY_DATA_KEY.getData(context);
if (data != null) {
for (ModuleGroup moduleGroup : data) {
if (PackageViewPane.ID.equals(currentViewId)) {
result.add(new PackageViewModuleGroupNode(project, moduleGroup, viewSettings));
} else {
result.add(new ProjectViewModuleGroupNode(project, moduleGroup, viewSettings));
}
}
}
}
return null;
}
use of com.intellij.ide.projectView.impl.ModuleGroup in project intellij-community by JetBrains.
the class CommanderPanel method getDataImpl.
public final Object getDataImpl(final String dataId) {
if (myBuilder == null)
return null;
final Object selectedValue = getSelectedValue();
if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
final PsiElement selectedElement = getSelectedElement();
return selectedElement != null && selectedElement.isValid() ? selectedElement : null;
}
if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
return filterInvalidElements(getSelectedElements());
}
if (LangDataKeys.PASTE_TARGET_PSI_ELEMENT.is(dataId)) {
final AbstractTreeNode parentNode = myBuilder.getParentNode();
final Object element = parentNode != null ? parentNode.getValue() : null;
return element instanceof PsiElement && ((PsiElement) element).isValid() ? element : null;
}
if (CommonDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
return getNavigatables();
}
if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
return myCopyPasteDelegator != null ? myCopyPasteDelegator.getCopyProvider() : null;
}
if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
return myCopyPasteDelegator != null ? myCopyPasteDelegator.getCutProvider() : null;
}
if (PlatformDataKeys.PASTE_PROVIDER.is(dataId)) {
return myCopyPasteDelegator != null ? myCopyPasteDelegator.getPasteProvider() : null;
}
if (LangDataKeys.IDE_VIEW.is(dataId)) {
return myIdeView;
}
if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
return myDeleteElementProvider;
}
if (LangDataKeys.MODULE.is(dataId)) {
return selectedValue instanceof Module ? selectedValue : null;
}
if (ModuleGroup.ARRAY_DATA_KEY.is(dataId)) {
return selectedValue instanceof ModuleGroup ? new ModuleGroup[] { (ModuleGroup) selectedValue } : null;
}
if (LibraryGroupElement.ARRAY_DATA_KEY.is(dataId)) {
return selectedValue instanceof LibraryGroupElement ? new LibraryGroupElement[] { (LibraryGroupElement) selectedValue } : null;
}
if (NamedLibraryElement.ARRAY_DATA_KEY.is(dataId)) {
return selectedValue instanceof NamedLibraryElement ? new NamedLibraryElement[] { (NamedLibraryElement) selectedValue } : null;
}
if (myProjectTreeStructure != null) {
return myProjectTreeStructure.getDataFromProviders(getSelectedNodes(), dataId);
}
return null;
}
Aggregations