Search in sources :

Example 1 with ProducerIdentifiedMessage

use of org.openlcb.ProducerIdentifiedMessage in project JMRI by JMRI.

the class TreePaneDemo method testWithSelect.

@Test
public void testWithSelect() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    frame.setTitle("listener test");
    pane.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            JTree tree = (JTree) e.getSource();
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            System.out.print("Test prints selected treenode " + node);
            if (node.getUserObject() instanceof NodeTreeRep.SelectionKey) {
                System.out.println(" and invokes");
                ((NodeTreeRep.SelectionKey) node.getUserObject()).select(node);
            } else {
                System.out.println();
            }
        }
    });
    Message msg;
    msg = new ProducerIdentifiedMessage(nid2, eventA, EventState.Unknown);
    store.put(msg, null);
    store.put(pipmsg, null);
    msg = new SimpleNodeIdentInfoReplyMessage(nid2, nid2, new byte[] { 0x01, 0x31, 0x32, 0x33, 0x41, 0x42, (byte) 0xC2, (byte) 0xA2, 0x44, 0x00 });
    store.put(msg, null);
}
Also used : JTree(javax.swing.JTree) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) SimpleNodeIdentInfoReplyMessage(org.openlcb.SimpleNodeIdentInfoReplyMessage) Message(org.openlcb.Message) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) ProtocolIdentificationReplyMessage(org.openlcb.ProtocolIdentificationReplyMessage) SimpleNodeIdentInfoReplyMessage(org.openlcb.SimpleNodeIdentInfoReplyMessage) NodeTreeRep(org.openlcb.swing.networktree.NodeTreeRep) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) Test(org.junit.Test)

Example 2 with ProducerIdentifiedMessage

use of org.openlcb.ProducerIdentifiedMessage in project JMRI by JMRI.

the class TreePaneDemo method testWith1stSNII.

@Test
public void testWith1stSNII() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    frame.setTitle("3rd has PIP && 1st SNII");
    Message msg;
    msg = new ProducerIdentifiedMessage(nid2, eventA, EventState.Unknown);
    store.put(msg, null);
    store.put(pipmsg, null);
    msg = new SimpleNodeIdentInfoReplyMessage(nid2, nid2, new byte[] { 0x01, 0x31, 0x32, 0x33, 0x41, 0x42, (byte) 0xC2, (byte) 0xA2, 0x44, 0x00 });
    store.put(msg, null);
}
Also used : SimpleNodeIdentInfoReplyMessage(org.openlcb.SimpleNodeIdentInfoReplyMessage) Message(org.openlcb.Message) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) ProtocolIdentificationReplyMessage(org.openlcb.ProtocolIdentificationReplyMessage) SimpleNodeIdentInfoReplyMessage(org.openlcb.SimpleNodeIdentInfoReplyMessage) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) Test(org.junit.Test)

Example 3 with ProducerIdentifiedMessage

use of org.openlcb.ProducerIdentifiedMessage in project JMRI by JMRI.

the class TreePaneDemo method testWithProtocolID.

@Test
public void testWithProtocolID() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    frame.setTitle("2nd has protocol id");
    Message msg;
    msg = new ProducerIdentifiedMessage(nid2, eventA, EventState.Unknown);
    store.put(msg, null);
    store.put(pipmsg, null);
}
Also used : SimpleNodeIdentInfoReplyMessage(org.openlcb.SimpleNodeIdentInfoReplyMessage) Message(org.openlcb.Message) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) ProtocolIdentificationReplyMessage(org.openlcb.ProtocolIdentificationReplyMessage) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) Test(org.junit.Test)

Example 4 with ProducerIdentifiedMessage

use of org.openlcb.ProducerIdentifiedMessage in project JMRI by JMRI.

the class TreePaneDemo method setUp.

@Before
public void setUp() throws Exception {
    store = new MimicNodeStore(connection, nid1);
    Message msg = new ProducerIdentifiedMessage(nid1, eventA, EventState.Unknown);
    store.put(msg, null);
    // build the TreePane, but don't put it in a frame (yet).
    pane = new TreePane();
    pane.initComponents(store, null, null, new NodeTreeRep.SelectionKeyLoader() {

        @Override
        public NodeTreeRep.SelectionKey cdiKey(String name, NodeID node) {
            return new NodeTreeRep.SelectionKey(name, node) {

                @Override
                public void select(DefaultMutableTreeNode rep) {
                    System.out.println("Making special fuss over: " + rep + " for " + name + " on " + node);
                }
            };
        }
    });
    if (GraphicsEnvironment.isHeadless()) {
        // don't bother setting up a frame in headless.
        return;
    }
    // Test is really popping a window before doing all else
    frame = new JFrame();
    frame.setTitle("TreePane Test");
    frame.add(pane);
    frame.pack();
    frame.setMinimumSize(new java.awt.Dimension(200, 200));
    frame.setVisible(true);
}
Also used : MimicNodeStore(org.openlcb.MimicNodeStore) SimpleNodeIdentInfoReplyMessage(org.openlcb.SimpleNodeIdentInfoReplyMessage) Message(org.openlcb.Message) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) ProtocolIdentificationReplyMessage(org.openlcb.ProtocolIdentificationReplyMessage) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) TreePane(org.openlcb.swing.networktree.TreePane) JFrame(javax.swing.JFrame) NodeTreeRep(org.openlcb.swing.networktree.NodeTreeRep) NodeID(org.openlcb.NodeID) Before(org.junit.Before)

Example 5 with ProducerIdentifiedMessage

use of org.openlcb.ProducerIdentifiedMessage in project JMRI by JMRI.

the class TreePaneDemo method testAfterMessage.

@Test
public void testAfterMessage() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    frame.setTitle("After Message");
    Message msg = new ProducerIdentifiedMessage(nid2, eventA, EventState.Unknown);
    store.put(msg, null);
}
Also used : SimpleNodeIdentInfoReplyMessage(org.openlcb.SimpleNodeIdentInfoReplyMessage) Message(org.openlcb.Message) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) ProtocolIdentificationReplyMessage(org.openlcb.ProtocolIdentificationReplyMessage) ProducerIdentifiedMessage(org.openlcb.ProducerIdentifiedMessage) Test(org.junit.Test)

Aggregations

Message (org.openlcb.Message)5 ProducerIdentifiedMessage (org.openlcb.ProducerIdentifiedMessage)5 ProtocolIdentificationReplyMessage (org.openlcb.ProtocolIdentificationReplyMessage)5 SimpleNodeIdentInfoReplyMessage (org.openlcb.SimpleNodeIdentInfoReplyMessage)5 Test (org.junit.Test)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 NodeTreeRep (org.openlcb.swing.networktree.NodeTreeRep)2 JFrame (javax.swing.JFrame)1 JTree (javax.swing.JTree)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 Before (org.junit.Before)1 MimicNodeStore (org.openlcb.MimicNodeStore)1 NodeID (org.openlcb.NodeID)1 TreePane (org.openlcb.swing.networktree.TreePane)1