Graph DeleteProvider

Hi,
i want to be able to delete nodes/edges from my graph
using the Graph2D to delete and update the view works very fast, but doesn't update the model
using GraphBuilder updateGraph() after updating the data model takes too long

i just notices the DeleteProvider class
but i can't understand how do i use it (where do i can the actual provider from)

or maybe there is another way to quickly remove nodes/edges with keeping the data model updated ?

2 comments

Hi,

You have to implement getDeleteProvider method of your GraphPresentationModel,
for instance:

public class GraphPresentationModel {

public DeleteProvider getDeleteProvider() {
return new DeleteProvider() {
public boolean canDeleteNode(@NotNull final java.io.File file) {
return file.exists();
}

public boolean canDeleteEdge(@NotNull final MyEdgeObject edge) {
return false;
}

public boolean deleteNode(@NotNull final java.io.File file) {
return file.delete();
}

public boolean deleteEdge(@NotNull final MyEdgeObject edge) {
return false;
}
};
}

}

Delete actions must appear in graph toolbar and graph popup. Delete key must
work too.

Serega.

Hi,
i want to be able to delete nodes/edges from my graph
using the Graph2D to delete and update the view works very fast, but
doesn't update the model
using GraphBuilder updateGraph() after updating the data model takes
too long
i just notices the DeleteProvider class
but i can't understand how do i use it (where do i can the actual
provider from)
or maybe there is another way to quickly remove nodes/edges with
keeping the data model updated ?



0

how do i add the DeleteSelectionAction to my own popup menu (which is at the end a JPopupMenu) ?

0

Please sign in to leave a comment.