I need to, each time an edge is selected, update the information in the table. That is, if you select the edge (no matter how: if you create it, or click the mouse on it), then the information in the table of my application should be updated. How to do it? Perhaps need to use some listener or a handler?

asked 10 Nov '11, 02:20

DeadMeat's gravatar image

DeadMeat
55
accept rate: 0%

edited 14 Nov '12, 16:29

David's gravatar image

David
4.9k21831


Use mxEvent.CHANGE in mxGraphSelectionModel (see userobject.html lines 210 ff. for an example) for JavaScript. In Java, an example may be found in the mxGraphSelectionModel API specification.

link

answered 10 Nov '11, 04:26

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

Thank you very much! But I had another problem.

(11 Nov '11, 03:41) DeadMeat

Like the stack says, the cell you are trying to cast is not of the expected type.

link

answered 11 Nov '11, 04:02

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

But when I do the same thing in another way, everything is repeated.

(11 Nov '11, 04:21) DeadMeat

I understand, but why? I did the same thing in another way:

graphComponent.getGraph().getSelectionModel().addListener(mxEvent.CHANGE, new mxIEventListener()
            {
                 public void invoke(Object sender, mxEventObject evt) 
                 {
                     ArrayList temp;
                     Iterator<EditorCell> it;
                     String text;

                     temp = (ArrayList) evt.getProperty("removed");
                     if (temp != null)
                     {
                         it = temp.iterator();
                         while (it.hasNext())
                         {
                             if (it.next().isEdge())
                             {
                                 text = (String) it.next().getValue();
                                 if (text != "")
                                     currentTable.setText(it.next().getValue().toString());
                                 else
                                     currentTable.setText("??? ????????");
                                 paramTable.setValueAt(it.next().getId().toString(), 0, 0);
                             }                             }
                     }
                 }
            });

Now the exception is thrown on this line "text = (String) it.next().getValue();" I don't understand why there is an exception.

link

answered 11 Nov '11, 04:20

DeadMeat's gravatar image

DeadMeat
55
accept rate: 0%

edited 14 Nov '12, 16:27

David's gravatar image

David
4.9k21831

You are calling it.next() several times for each it.hasNext() call. Every call to it.next() advanced the iterator, so you're getting a null pointer exception.

(14 Nov '12, 16:17) John Feiler
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×194
×45
×13

Asked: 10 Nov '11, 02:20

Seen: 1,667 times

Last updated: 14 Nov '12, 16:30