Skip to content

Commit

Permalink
fixes region restoration not updating region list in state inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
crissNb committed Mar 10, 2024
1 parent 080831a commit e6f90d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.gecko.actions;

import java.util.ArrayList;
import java.util.List;
import org.gecko.exceptions.GeckoException;
import org.gecko.model.Automaton;
import org.gecko.viewmodel.GeckoViewModel;
import org.gecko.viewmodel.PositionableViewModelElement;
import org.gecko.viewmodel.RegionViewModel;
import org.gecko.viewmodel.StateViewModel;

/**
* A concrete representation of an {@link Action} that removes a {@link RegionViewModel} from the {@link GeckoViewModel}
Expand All @@ -25,6 +28,12 @@ public class DeleteRegionViewModelElementAction extends AbstractPositionableView
@Override
boolean run() throws GeckoException {
automaton.removeRegion(regionViewModel.getTarget());
List<StateViewModel> states = new ArrayList<>(regionViewModel.getStatesProperty());

for (StateViewModel state : states) {
regionViewModel.removeState(state);
}

geckoViewModel.deleteViewModelElement(regionViewModel);
geckoViewModel.getCurrentEditor().updateRegions();
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.gecko.actions;

import org.gecko.exceptions.ModelException;
import org.gecko.model.Automaton;
import org.gecko.viewmodel.GeckoViewModel;
import org.gecko.viewmodel.RegionViewModel;
Expand All @@ -22,9 +23,10 @@ public class RestoreRegionViewModelElementAction extends Action {


@Override
boolean run() {
boolean run() throws ModelException {
automaton.addRegion(regionViewModel.getTarget());
geckoViewModel.addViewModelElement(regionViewModel);
geckoViewModel.getCurrentEditor().updateRegions();
return true;
}

Expand Down

0 comments on commit e6f90d7

Please sign in to comment.