Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Get out of infinite loop

OstapBenderOstapBender GermanyMember Posts: 1

Hallo,
am a newbie and have to customise existing Java code in an Eclipse RCP application. I try to catch anytime the CommandStack is changed and simply save the changes directly. The problem is my save method calls the CommandSatckChanged event and I get in the infinite loop. Can somebody help me?

@Override
public void commandStackChanged(EventObject event) {
firePropertyChange(IEditorPart.PROP_DIRTY);
doSave(null);
setDirty(false);
}

public void doSave(final IProgressMonitor progressMonitor) {

    editorSaving = true;
    SafeRunner.run(new SafeRunnable() {

        public void run() throws Exception {
            IFile targetFile = getFile();

            List<GraphicalEditPart> editParts = DiagramUtil.getAllEditParts(NetEditor.this);
            Rectangle offsetBounds = DiagramUtil.getBounds(editParts);

            saveDiagramProperties();
            List<INetTransition> transitionsToExpand = saveSubdiagramGroups();
            FileUtil.saveDiagram(getNetDiagram(), targetFile,
                    NetEditor.this);
            getCommandStack().markSaveLocation();


            for (INetTransition trans : transitionsToExpand) {
                trans.setExpanded(true);
            }
        }
    });
    setDirty(false);
    editorSaving = false;
}
Tagged:
Sign In or Register to comment.