--- /dev/null
+class Anonymous {
+ int num1;
+ int num2;
+ Object o = new Object(){<caret>};
+
+ Anonymous() {}
+ void foo() {}
+}
\ No newline at end of file
--- /dev/null
+-Anonymous.java
+ -Anonymous
+ Anonymous()
+ foo():void
+ num1:int
+ num2:int
+ -[o:Object = new Object() {...}]
+ $1
\ No newline at end of file
--- /dev/null
+class AnonymousInAnonymous {
+ int num1;
+ int num2;
+
+ AnonymousInAnonymous() {}
+ void foo() {
+ new Object() {
+ public String toString() {
+ return new Object(){
+ void method() {<caret>}
+ }.toString();
+ }
+ };
+ }
+}
\ No newline at end of file
--- /dev/null
+-AnonymousInAnonymous.java
+ -AnonymousInAnonymous
+ AnonymousInAnonymous()
+ -foo():void
+ -$1
+ -toString():String
+ -Anonymous
+ [method():void]
+ num1:int
+ num2:int
\ No newline at end of file
--- /dev/null
+class Anonymous {
+ int num1;
+ int num2;
+ Object o = new Object(){
+ int num = 1;
+ };
+
+ Anonymous() {}
+ void foo() {}
+}
\ No newline at end of file
return "selection";
}
- public void testField() throws Exception {checkTree();}
- public void testMethod() throws Exception {checkTree();}
- public void testConstructor() throws Exception {checkTree();}
- public void testInsideClass() throws Exception {checkTree();}
+ public void testField() throws Exception {checkTree();}
+ public void testMethod() throws Exception {checkTree();}
+ public void testConstructor() throws Exception {checkTree();}
+ public void testInsideClass() throws Exception {checkTree();}
+ public void testAnonymous() throws Exception {checkTree();}
+ public void testAnonymousInAnonymous() throws Exception {checkTree();}
}
public void setUp() throws Exception {
super.setUp();
myShowAnonymousByDefault = PropertiesComponent.getInstance().getBoolean(getAnonymousPropertyName(), false);
+ if (getTestName(false).contains("Anonymous")) {
+ setShowAnonymous(true);
+ }
}
@Override
return "java";
}
+ public void setShowAnonymous(boolean show) throws Exception {
+ myPopup.setTreeActionState(JavaAnonymousClassesNodeProvider.class, show);
+ update();
+ }
+
@Override
public void tearDown() throws Exception {
PropertiesComponent.getInstance().setValue(getAnonymousPropertyName(), Boolean.toString(myShowAnonymousByDefault));
private int myPreferredWidth;
private final FilteringTreeStructure myFilteringStructure;
private PsiElement myInitialPsiElement;
+ private Map<Class, JCheckBox> myCheckBoxes = new HashMap<Class, JCheckBox>();
public FileStructurePopup(StructureViewModel structureViewModel,
@Nullable Editor editor,
myTreeStructure = new SmartTreeStructure(project, myTreeModel){
public void rebuildTree() {
- if (!myPopup.isDisposed()) {
+ if (ApplicationManager.getApplication().isUnitTestMode() || !myPopup.isDisposed()) {
super.rebuildTree();
}
}
return null;
}
- protected JComponent createCenterPanel() {
+ public JComponent createCenterPanel() {
List<FileStructureFilter> fileStructureFilters = new ArrayList<FileStructureFilter>();
List<FileStructureNodeProvider> fileStructureNodeProviders = new ArrayList<FileStructureNodeProvider>();
if (myTreeActionsOwner != null) {
}
chkFilter.setText(text);
panel.add(chkFilter);
+ myCheckBoxes.put(action.getClass(), chkFilter);
}
private static boolean getDefaultValue(TreeAction action) {
return myAbstractTreeBuilder;
}
+ public void setTreeActionState(Class<? extends TreeAction> action, boolean state) {
+ final JCheckBox checkBox = myCheckBoxes.get(action);
+ if (checkBox != null) {
+ checkBox.setSelected(state);
+ for (ActionListener listener : checkBox.getActionListeners()) {
+ listener.actionPerformed(new ActionEvent(this, 1, ""));
+ }
+ }
+ }
+
private class FileStructurePopupFilter implements ElementFilter {
private String myLastFilter = null;
private HashSet<Object> myVisibleParents = new HashSet<Object>();
* @author Konstantin Bulenkov
*/
public abstract class FileStructureTestBase extends CodeInsightFixtureTestCase {
- FileStructurePopup myPopup;
+ protected FileStructurePopup myPopup;
@Before
public void setUp() throws Exception {
myFixture.getProject(),
null,
TextEditorProvider.getInstance().getTextEditor(myFixture.getEditor()));
+ assert myPopup != null;
+ myPopup.createCenterPanel();
+ getBuilder().getUi().getUpdater().setPassThroughMode(true);
update();
}
}
- private void update() throws InterruptedException {
+ public void update() throws InterruptedException {
myPopup.getTreeBuilder().refilter().doWhenProcessed(new Runnable() {
@Override
public void run() {
+
getStructure().rebuild();
updateTree();
+ getBuilder().updateFromRoot();
TreeUtil.expandAll(getTree());
final FilteringTreeStructure.FilteringNode node = myPopup.selectPsiElement(myPopup.getCurrentElement(getFile()));
- getTree().getSelectionModel().setSelectionPath(getTree().getPath(node));
+ getBuilder().getUi().select(node, null);
}
});
}
--- /dev/null
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.testFramework;
+
+import com.intellij.ide.util.treeView.AbstractTreeBuilder;
+import com.intellij.ide.util.treeView.AbstractTreeUpdater;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public class TestTreeUpdater extends AbstractTreeUpdater {
+ public TestTreeUpdater(AbstractTreeBuilder treeBuilder) {
+ super(treeBuilder);
+ }
+}