tesis-dynaware / graph-editor

Eclipse Public License 1.0
132 stars 42 forks source link

SelectionCopier paste with CommandAppender #7

Closed eckig closed 9 years ago

eckig commented 9 years ago

If I paste previously copied nodes with a CommandAppender I can not append commands to sync my domain model. If think it is a bug in SelectionCopier#addPastedElements where the command is executed before the CommandAppender is called..?

rmfisher commented 9 years ago

Thanks for the report, I'll look into this a.s.a.p.

rmfisher commented 9 years ago

It's intentional that the command is executed before the command appender is called. Even after a compound command is executed, you can still append-and-execute additional commands to it.

Can you provide an example of what you are trying to do and what exactly is not working?

eckig commented 9 years ago
paste.setOnAction(ev -> mEditor.getSelectionManager().paste(this::doPaste));

private void doPaste(List<GNode> pNodes, CompoundCommand pCommand)
    {
        GraphModelBridge wrapper = GraphModelBridge.getInstanceFor(getBean().getGraphModel());
        for (GNode node : pNodes)
        {
            clone = ...;
            pCommand.append(EMFUtils.addCommand(getBean().getDomainModel(), clone));
        }
    }

Then I will get an Exception that the command is already prepared (see CompoundCommand#append()). I swapped both elements, so the CommandAppender is called first and afterwards executed - Then it works perfectly fine.

rmfisher commented 9 years ago

Ok, previously I have just tested it using CompoundCommand#appendAndExecute(). Did you try that?

eckig commented 9 years ago

Ah okay, did not know that and it works just fine. Thanks for the hint, you may want to put it down in writing (JavaDoc) :-)