Search in sources :

Example 96 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project darkFunction-Editor by darkFunction.

the class SpritesheetReader method getTreeModel.

public DefaultTreeModel getTreeModel() {
    DefaultTreeModel retTree = null;
    NodeList defList = doc.getElementsByTagName("definitions");
    // only support one bunch of definitions, use the first
    if (defList.getLength() > 0) {
        Element first = (Element) defList.item(0);
        if (first != null) {
            NodeList children = first.getChildNodes();
            Element firstChild = null;
            for (int i = 0; i < children.getLength(); i++) {
                Node child = children.item(i);
                if (child.getNodeType() == Node.ELEMENT_NODE) {
                    firstChild = (Element) child;
                    break;
                }
            }
            if (firstChild != null) {
                retTree = createTreeModelFromDOM(firstChild);
            }
        }
    }
    return retTree;
}
Also used : CustomNode(dfEditor.CustomNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 97 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project buck by facebook.

the class BuckEventsConsumerTest method hasUIWorkBeenDoneOnNonAwtThreadInConsumeBuckProjectGenerationFinishedThenFail.

@Test
public void hasUIWorkBeenDoneOnNonAwtThreadInConsumeBuckProjectGenerationFinishedThenFail() {
    DefaultTreeModel treeModel = new DefaultTreeModel(null);
    BuckEventsConsumer buckEventsConsumer = initialiseEventsConsumer();
    MockTreeModelListener listener = addListeners(treeModel);
    buckEventsConsumer.attach(null, treeModel);
    assertFalse(listener.calledOnWrongThread);
    assertTrue(buckEventsConsumer.isAttached());
    buckEventsConsumer.consumeBuckProjectGenerationFinished(0);
    assertFalse(listener.calledOnWrongThread);
}
Also used : MockTreeModelListener(com.facebook.buck.intellij.ideabuck.test.util.MockTreeModelListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Test(org.junit.Test)

Example 98 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project buck by facebook.

the class BuckEventsConsumerTest method hasUIWorkBeenDoneOnNonAwtThreadInConsumeBuckProjectGenerationProgressThenFail.

@Test
public void hasUIWorkBeenDoneOnNonAwtThreadInConsumeBuckProjectGenerationProgressThenFail() {
    DefaultTreeModel treeModel = new DefaultTreeModel(null);
    BuckEventsConsumer buckEventsConsumer = initialiseEventsConsumer();
    MockTreeModelListener listener = addListeners(treeModel);
    buckEventsConsumer.attach(null, treeModel);
    assertFalse(listener.calledOnWrongThread);
    assertTrue(buckEventsConsumer.isAttached());
    buckEventsConsumer.consumeBuckProjectGenerationProgress(0, 0);
    assertFalse(listener.calledOnWrongThread);
}
Also used : MockTreeModelListener(com.facebook.buck.intellij.ideabuck.test.util.MockTreeModelListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Test(org.junit.Test)

Example 99 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project buck by facebook.

the class BuckEventsConsumerTest method hasUIWorkBeenDoneOnNonAwtThreadInAttachThenFail.

@Test
public void hasUIWorkBeenDoneOnNonAwtThreadInAttachThenFail() {
    DefaultTreeModel treeModel = new DefaultTreeModel(null);
    BuckEventsConsumer buckEventsConsumer = initialiseEventsConsumer();
    MockTreeModelListener listener = addListeners(treeModel);
    buckEventsConsumer.attach(null, treeModel);
    assertFalse(listener.calledOnWrongThread);
    assertTrue(buckEventsConsumer.isAttached());
}
Also used : MockTreeModelListener(com.facebook.buck.intellij.ideabuck.test.util.MockTreeModelListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Test(org.junit.Test)

Example 100 with DefaultTreeModel

use of javax.swing.tree.DefaultTreeModel in project buck by facebook.

the class BuckEventsConsumerTest method hasUIWorkBeenDoneOnNonAwtThreadInConsumeConsoleEventThenFail.

@Test
public void hasUIWorkBeenDoneOnNonAwtThreadInConsumeConsoleEventThenFail() {
    DefaultTreeModel treeModel = new DefaultTreeModel(null);
    BuckEventsConsumer buckEventsConsumer = initialiseEventsConsumer();
    MockTreeModelListener listener = addListeners(treeModel);
    buckEventsConsumer.attach(null, treeModel);
    assertFalse(listener.calledOnWrongThread);
    assertTrue(buckEventsConsumer.isAttached());
    buckEventsConsumer.consumeConsoleEvent("");
    assertFalse(listener.calledOnWrongThread);
}
Also used : MockTreeModelListener(com.facebook.buck.intellij.ideabuck.test.util.MockTreeModelListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Test(org.junit.Test)

Aggregations

DefaultTreeModel (javax.swing.tree.DefaultTreeModel)167 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)86 TreePath (javax.swing.tree.TreePath)43 Tree (com.intellij.ui.treeStructure.Tree)22 Test (org.junit.Test)21 MockTreeModelListener (com.facebook.buck.intellij.ideabuck.test.util.MockTreeModelListener)16 JTree (javax.swing.JTree)15 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)15 JScrollPane (javax.swing.JScrollPane)14 TreeSelectionListener (javax.swing.event.TreeSelectionListener)14 ArrayList (java.util.ArrayList)10 TreeNode (javax.swing.tree.TreeNode)10 NotNull (org.jetbrains.annotations.NotNull)10 Module (com.intellij.openapi.module.Module)9 DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)9 MouseEvent (java.awt.event.MouseEvent)8 List (java.util.List)8 Project (com.intellij.openapi.project.Project)7 javax.swing (javax.swing)7 JPanel (javax.swing.JPanel)7