use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class Commander method getData.
@Override
public Object getData(final String dataId) {
if (PlatformDataKeys.HELP_ID.is(dataId)) {
return HelpID.COMMANDER;
} else if (CommonDataKeys.PROJECT.is(dataId)) {
return myProject;
} else if (LangDataKeys.TARGET_PSI_ELEMENT.is(dataId)) {
final AbstractTreeNode parentElement = getInactivePanel().getBuilder().getParentNode();
if (parentElement == null)
return null;
final Object element = parentElement.getValue();
return element instanceof PsiElement && ((PsiElement) element).isValid() ? element : null;
} else if (CompareFilesAction.DIFF_REQUEST.is(dataId)) {
PsiElement primary = getActivePanel().getSelectedElement();
PsiElement secondary = getInactivePanel().getSelectedElement();
if (primary != null && secondary != null && primary.isValid() && secondary.isValid() && !PsiTreeUtil.isAncestor(primary, secondary, false) && !PsiTreeUtil.isAncestor(secondary, primary, false)) {
return PsiDiffContentFactory.comparePsiElements(primary, secondary);
}
return null;
} else {
return getActivePanel().getDataImpl(dataId);
}
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-community by JetBrains.
the class Commander method writePanel.
private static void writePanel(final CommanderPanel panel, final Element element) {
/*TODO[anton,vova]: it's a patch!!!*/
final AbstractListBuilder builder = panel.getBuilder();
if (builder == null)
return;
final AbstractTreeNode parentNode = builder.getParentNode();
final Object parentElement = parentNode != null ? parentNode.getValue() : null;
if (parentElement instanceof PsiDirectory) {
final PsiDirectory directory = (PsiDirectory) parentElement;
element.setAttribute(ATTRIBUTE_URL, directory.getVirtualFile().getUrl());
} else if (parentElement instanceof PsiClass) {
for (PsiElement e = (PsiElement) parentElement; e != null && e.isValid(); e = e.getParent()) {
if (e instanceof PsiClass) {
final String qualifiedName = ((PsiClass) e).getQualifiedName();
if (qualifiedName != null) {
element.setAttribute(ATTRIBUTE_CLASS, qualifiedName);
break;
}
}
}
}
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-plugins by JetBrains.
the class FlexStructureViewTest method testGroupByClass2.
public void testGroupByClass2() throws Exception {
configureByFile(BASE_PATH + "15.js2");
final Object[] items = getTopLevelItems();
assertEquals(3, items.length);
assertEquals("ZZZ", getText(items[1]));
assertEquals("ZZZ2", getText(items[2]));
assertEquals("A15", getText(items[0]));
List<? extends AbstractTreeNode> treeNodes = getChildren(items[0]);
assertEquals(7, treeNodes.size());
final Iterator<? extends AbstractTreeNode> iterator = treeNodes.iterator();
final AbstractTreeNode node = iterator.next();
assertEquals("mypackage.ZZZ", getText(node));
Collection<? extends AbstractTreeNode> treeNodes2 = getChildren(node);
assertEquals(2, treeNodes2.size());
final Iterator<? extends AbstractTreeNode> iterator2 = treeNodes2.iterator();
assertEquals("aaa", getText(iterator2.next()));
assertEquals("c2", getText(iterator2.next()));
assertEquals("Object", getText(iterator.next()));
assertEquals("automation():Object", getText(iterator.next()));
assertEquals("initialized():Boolean", getText(iterator.next()));
assertEquals("register(c:Object):void", getText(iterator.next()));
assertEquals("_automation:Object", getText(iterator.next()));
assertEquals("delegate:Object", getText(iterator.next()));
final PsiElement element = checkIfCurrentEditorElementIsValid((AbstractTreeNode) items[1], JSClass.class);
assertTrue(JSStructureViewModel.shouldEnterElementStatic(element));
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project intellij-plugins by JetBrains.
the class FlexStructureViewTest method testBug3.
public void testBug3() throws Exception {
configureByFiles(null, BASE_PATH + "22.js2", BASE_PATH + "22_2.js2");
final Object[] items = getTopLevelItems();
assertEquals(2, items.length);
assertEquals("XXX", getText(items[0]));
assertEquals("YYY", getText(items[1]));
List<? extends AbstractTreeNode> treeNodes = getChildren(items[0]);
assertEquals(3 + OBJECT_METHODS_COUNT, treeNodes.size());
assertEquals("constructor():*", getText(treeNodes.get(0)));
assertEquals("aaa", getText(treeNodes.get(OBJECT_METHODS_COUNT + 1)));
assertEquals("bbb", getText(treeNodes.get(OBJECT_METHODS_COUNT + 2)));
AbstractTreeNode node = treeNodes.get(OBJECT_METHODS_COUNT - 5);
assertEquals("staticFun()", getText(node));
Icon icon = getIcon(node);
assertTrue(icon instanceof RowIcon);
// static mark blended in
assertTrue(((RowIcon) icon).getIcon(0) instanceof LayeredIcon);
treeNodes = getChildren(items[1]);
assertEquals(2 + OBJECT_METHODS_COUNT, treeNodes.size());
assertEquals("aaa", getText(treeNodes.get(OBJECT_METHODS_COUNT)));
assertEquals("bbb", getText(treeNodes.get(OBJECT_METHODS_COUNT + 1)));
}
use of com.intellij.ide.util.treeView.AbstractTreeNode in project android by JetBrains.
the class GradleSyncTest method jdkNodeModificationInProjectView.
@Test
public void jdkNodeModificationInProjectView() throws IOException {
guiTest.importSimpleApplication();
Project project = guiTest.ideFrame().getProject();
AndroidTreeStructureProvider treeStructureProvider = null;
TreeStructureProvider[] treeStructureProviders = Extensions.getExtensions(TreeStructureProvider.EP_NAME, project);
for (TreeStructureProvider current : treeStructureProviders) {
if (current instanceof AndroidTreeStructureProvider) {
treeStructureProvider = (AndroidTreeStructureProvider) current;
}
}
List<AbstractTreeNode> changedNodes = Lists.newArrayList();
treeStructureProvider.addChangeListener((parent, newChildren) -> changedNodes.add(parent));
ProjectViewFixture projectView = guiTest.ideFrame().getProjectView();
ProjectViewFixture.PaneFixture projectPane = projectView.selectProjectPane();
ProjectViewFixture.NodeFixture externalLibrariesNode = projectPane.findExternalLibrariesNode();
projectPane.expand();
// 2 nodes should be changed: JDK (remove all children except rt.jar) and rt.jar (remove all children except packages 'java' and
// 'javax'.
Wait.seconds(1).expecting("'Project View' to be customized").until(() -> changedNodes.size() == 2);
List<ProjectViewFixture.NodeFixture> libraryNodes = externalLibrariesNode.getChildren();
ProjectViewFixture.NodeFixture jdkNode = null;
// Find JDK node.
for (ProjectViewFixture.NodeFixture node : libraryNodes) {
if (node.isJdk()) {
jdkNode = node;
break;
}
}
ProjectViewFixture.NodeFixture finalJdkNode = jdkNode;
Wait.seconds(1).expecting("JDK node to be customized").until(() -> finalJdkNode.getChildren().size() == 1);
// Now we verify that the JDK node has only these children:
// - jdk
// - rt.jar
// - java
// - javax
List<ProjectViewFixture.NodeFixture> jdkChildren = jdkNode.getChildren();
assertThat(jdkChildren).hasSize(1);
ProjectViewFixture.NodeFixture rtJarNode = jdkChildren.get(0);
rtJarNode.requireDirectory("rt.jar");
List<ProjectViewFixture.NodeFixture> rtJarChildren = rtJarNode.getChildren();
assertThat(rtJarChildren).hasSize(2);
rtJarChildren.get(0).requireDirectory("java");
rtJarChildren.get(1).requireDirectory("javax");
}
Aggregations