Skip to content

Commit

Permalink
Merge branch 'main' into various_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crissNb committed Feb 12, 2024
2 parents 002679b + 3a55b84 commit 91794a3
Show file tree
Hide file tree
Showing 161 changed files with 711 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import org.gecko.viewmodel.PositionableViewModelElement;

/**
* An abstract representation of an {@link Action} that has a target-{@link PositionableViewModelElement}.
*/
public abstract class AbstractPositionableViewModelElementAction extends Action {
abstract PositionableViewModelElement<?> getTarget();
}
4 changes: 4 additions & 0 deletions src/main/java/org/gecko/actions/Action.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import org.gecko.exceptions.GeckoException;

/**
* An abstract representation of an operation that can be executed in the Gecko Graphic Editor. An {@link Action} can be
* run or undone. The provided methods must be implemented by concrete actions.
*/
public abstract class Action {
/**
* Runs the action.
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/gecko/actions/ActionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import org.gecko.viewmodel.SystemConnectionViewModel;
import org.gecko.viewmodel.SystemViewModel;

/**
* Represents a factory for actions. Provides a method for the creation of each subtype of {@link Action}.
*/
public class ActionFactory {
private final GeckoViewModel geckoViewModel;

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/gecko/actions/ActionGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import lombok.EqualsAndHashCode;
import org.gecko.exceptions.GeckoException;

/**
* A concrete representation of an {@link Action}, which encapsulates a list of other concrete actions, which are
* iteratively run or undone.
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ActionGroup extends Action {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/gecko/actions/ActionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import org.gecko.exceptions.GeckoException;
import org.gecko.viewmodel.GeckoViewModel;

/**
* Represents a manager for the actions of the active {@link org.gecko.application.Gecko Gecko}. Holds an
* {@link ActionFactory}, a stack of currently undoable {@link Action}s and a stack of currently redoable
* {@link Action}s, thus providing methods for running, undoing and redoing actions.
*/
public class ActionManager {
@Getter
private final ActionFactory actionFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import org.gecko.exceptions.GeckoException;
import org.gecko.viewmodel.RegionViewModel;

/**
* A concrete representation of an {@link Action} that changes the color of a {@link RegionViewModel}. Additionally,
* holds the old and new {@link Color}s of the region for undo/redo purposes.
*/
public class ChangeColorRegionViewModelElementAction extends Action {

private final RegionViewModel regionViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import org.gecko.viewmodel.ContractViewModel;
import org.gecko.viewmodel.EdgeViewModel;

/**
* A concrete representation of an {@link Action} that changes the contract of an {@link EdgeViewModel}, which it holds
* a reference to. Additionally, holds the old and new {@link ContractViewModel}s of the edge for undo/redo purposes.
*/
public class ChangeContractEdgeViewModelAction extends Action {

private final EdgeViewModel edgeViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import org.gecko.exceptions.GeckoException;
import org.gecko.viewmodel.RegionViewModel;

/**
* A concrete representation of an {@link Action} that changes the invariant of a {@link RegionViewModel}, which it
* holds a reference to. Additionally, holds the old and new {@link String invariants}s of the region for undo/redo
* purposes
*/
public class ChangeInvariantViewModelElementAction extends Action {

private final RegionViewModel regionViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import org.gecko.model.Kind;
import org.gecko.viewmodel.EdgeViewModel;


/**
* Represents a type of {@link Action} that changes the {@link Kind} of an {@link EdgeViewModel}, which it holds a
* references to. Additionally, holds the old and new {@link Kind}s of the edge for undo/redo purposes.
*/
public class ChangeKindEdgeViewModelAction extends Action {

private final Kind kind;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import org.gecko.exceptions.GeckoException;
import org.gecko.viewmodel.ContractViewModel;

/**
* A concrete representation of an {@link Action} that changes the postcondition of a {@link ContractViewModel}, which
* it holds a reference to. Additionally, holds the old and new {@link String postcondition}s of the contract for
* undo/redo purposes.
*/
public class ChangePostconditionViewModelElementAction extends Action {

private final ContractViewModel contractViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import org.gecko.exceptions.GeckoException;
import org.gecko.viewmodel.ContractViewModel;

/**
* A concrete representation of an {@link Action} that changes the precondition of a {@link ContractViewModel}, which it
* holds a reference to. Additionally, holds the old and new {@link String precondition}s of the contract for undo/redo
* purposes.
*/
public class ChangePreconditionViewModelElementAction extends Action {

private final ContractViewModel contractViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import org.gecko.exceptions.GeckoException;
import org.gecko.viewmodel.PortViewModel;

/**
* A concrete representation of an {@link Action} that changes the type of a {@link PortViewModel}, which it holds a
* reference to. Additionally, holds the old and new {@link String type}s of the contract for undo/redo purposes.
*/
public class ChangeTypePortViewModelElementAction extends Action {

private final PortViewModel portViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
import org.gecko.viewmodel.PortViewModel;
import org.gecko.viewmodel.SystemConnectionViewModel;

/**
* A concrete representation of an {@link Action} that changes the visibility of a {@link PortViewModel}, which it holds
* a reference to. Additionally, holds the old and new {@link Visibility Visibilities} of the contract for undo/redo
* purposes.
*/
public class ChangeVisibilityPortViewModelAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import org.gecko.viewmodel.StateViewModel;
import org.gecko.viewmodel.ViewModelFactory;

/**
* A concrete representation of an {@link Action} that creates a {@link ContractViewModel} in a given
* {@link StateViewModel} through the {@link ViewModelFactory} of the
* {@link org.gecko.viewmodel.GeckoViewModel GeckoViewModel}.
*/
public class CreateContractViewModelElementAction extends Action {

private final ViewModelFactory viewModelFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import org.gecko.viewmodel.StateViewModel;
import org.gecko.viewmodel.SystemViewModel;

/**
* A concrete representation of an {@link Action} that creates an {@link EdgeViewModel} in the
* current-{@link SystemViewModel} with given source- and destination-{@link StateViewModel}s through the
* {@link org.gecko.viewmodel.ViewModelFactory ViewModelFactory} of the {@link GeckoViewModel}.
*/
public class CreateEdgeViewModelElementAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import org.gecko.viewmodel.PortViewModel;
import org.gecko.viewmodel.SystemViewModel;

/**
* A concrete representation of an {@link Action} that creates a {@link PortViewModel} in a given
* {@link SystemViewModel} through the {@link org.gecko.viewmodel.ViewModelFactory ViewModelFactory} of the
* {@link GeckoViewModel}.
*/
public class CreatePortViewModelElementAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
import org.gecko.viewmodel.RegionViewModel;
import org.gecko.viewmodel.SystemViewModel;

/**
* A concrete representation of an {@link Action} that creates a {@link RegionViewModel} in the
* current-{@link SystemViewModel} through the {@link org.gecko.viewmodel.ViewModelFactory} of the
* {@link GeckoViewModel}. Additionally, holds the current {@link org.gecko.viewmodel.EditorViewModel EditorViewModel}
* for setting the correct size and position for the created region.
*/
public class CreateRegionViewModelElementAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
import org.gecko.viewmodel.StateViewModel;
import org.gecko.viewmodel.SystemViewModel;

/**
* A concrete representation of an {@link Action} that creates a {@link StateViewModel} in the
* current-{@link SystemViewModel} through the {@link org.gecko.viewmodel.ViewModelFactory ViewModelFactory} of the
* {@link GeckoViewModel}. Additionally, holds the {@link Point2D position} and the current {@link EditorViewModel} for
* setting the correct position for the created state.
*/
public class CreateStateViewModelElementAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import org.gecko.viewmodel.SystemConnectionViewModel;
import org.gecko.viewmodel.SystemViewModel;

/**
* A concrete representation of an {@link Action} that creates an {@link SystemConnectionViewModel} in the
* current-{@link SystemViewModel} with given source- and destination-{@link PortViewModel}s through the
* {@link org.gecko.viewmodel.ViewModelFactory ViewModelFactory} of the {@link GeckoViewModel}.
*/
public class CreateSystemConnectionViewModelElementAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
import org.gecko.viewmodel.GeckoViewModel;
import org.gecko.viewmodel.SystemViewModel;

/**
* A concrete representation of an {@link Action} that creates a {@link SystemViewModel} in the
* current-{@link SystemViewModel} through the {@link org.gecko.viewmodel.ViewModelFactory ViewModelFactory} of the
* {@link GeckoViewModel}. Additionally, holds the {@link Point2D position} and the current {@link EditorViewModel} for
* setting the correct position for the created system.
*/
public class CreateSystemViewModelElementAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/gecko/actions/CreateVariableAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import org.gecko.viewmodel.GeckoViewModel;
import org.gecko.viewmodel.PortViewModel;

/**
* A concrete representation of an {@link Action} that creates a {@link PortViewModel} in the
* current-{@link org.gecko.viewmodel.SystemViewModel SystemViewModel} through the
* {@link org.gecko.viewmodel.ViewModelFactory ViewModelFactory} of the {@link GeckoViewModel}. Additionally, holds the
* {@link Point2D position} and the current {@link EditorViewModel} for setting the correct position for the created
* port.
*/
public class CreateVariableAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
import org.gecko.viewmodel.SystemConnectionViewModel;
import org.gecko.viewmodel.SystemViewModel;


/**
* Follows the visitor pattern, implementing the {@link PositionableViewModelElementVisitor} interface. Determines all
* necessary delete-{@link Action}s for deleting all "lower level"-dependencies of a given parent-@link
* SystemViewModel}.
*/
public class DeleteActionsCreatorVisitor implements PositionableViewModelElementVisitor {

private final GeckoViewModel geckoViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import org.gecko.viewmodel.GeckoViewModel;
import org.gecko.viewmodel.PositionableViewModelElement;

/**
* A concrete representation of an {@link Action} that removes the target of an {@link EdgeViewModel} from the given
* {@link Automaton} and the afferent {@link EdgeViewModel} from the list of outgoing- and
* ingoing-{@link EdgeViewModel}s of its source- and destination-{@link org.gecko.viewmodel.StateViewModel}s.
*/
public class DeleteEdgeViewModelElementAction extends AbstractPositionableViewModelElementAction {
private final GeckoViewModel geckoViewModel;
private final EdgeViewModel edgeViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import org.gecko.viewmodel.PositionableViewModelElement;
import org.gecko.viewmodel.SystemViewModel;

/**
* A concrete representation of an {@link Action} that removes a {@link PortViewModel} from the given
* parent-{@link SystemViewModel}.
*/
public class DeletePortViewModelElementAction extends AbstractPositionableViewModelElementAction {
private final GeckoViewModel geckoViewModel;
private final PortViewModel portViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import org.gecko.viewmodel.GeckoViewModel;
import org.gecko.viewmodel.PositionableViewModelElement;

/**
* A concrete representation of an {@link Action} that deletes a set of {@link PositionableViewModelElement}s and their
* dependencies from the {@link GeckoViewModel}.
*/
public class DeletePositionableViewModelElementAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import org.gecko.viewmodel.PositionableViewModelElement;
import org.gecko.viewmodel.RegionViewModel;

/**
* A concrete representation of an {@link Action} that removes a {@link RegionViewModel} from the {@link GeckoViewModel}
* and its target-{@link org.gecko.model.Region} from the given {@link Automaton}.
*/
public class DeleteRegionViewModelElementAction extends AbstractPositionableViewModelElementAction {
private final GeckoViewModel geckoViewModel;
private final RegionViewModel regionViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
import org.gecko.viewmodel.StateViewModel;
import org.gecko.viewmodel.SystemViewModel;

/**
* A concrete representation of an {@link Action} that removes a {@link StateViewModel} from the {@link GeckoViewModel}
* and its target-{@link State} from the given {@link Automaton}.
*/
public class DeleteStateViewModelElementAction extends AbstractPositionableViewModelElementAction {
private final GeckoViewModel geckoViewModel;
private final EditorViewModel editorViewModel;
private final StateViewModel stateViewModel;
private final Automaton automaton;
private final SystemViewModel systemViewModel;
private boolean wasStartState;
private final boolean wasStartState;

DeleteStateViewModelElementAction(
GeckoViewModel geckoViewModel, StateViewModel stateViewModel, SystemViewModel systemViewModel) {
Expand Down Expand Up @@ -52,6 +56,7 @@ boolean run() throws GeckoException {
systemViewModel.setStartState(null);
}
systemViewModel.updateTarget();
automaton.removeState(stateViewModel.getTarget());
geckoViewModel.deleteViewModelElement(stateViewModel);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import org.gecko.viewmodel.PositionableViewModelElement;
import org.gecko.viewmodel.SystemConnectionViewModel;

/**
* A concrete representation of an {@link Action} that removes a {@link SystemConnectionViewModel} from a given
* {@link org.gecko.viewmodel.SystemViewModel}.
*/
public class DeleteSystemConnectionViewModelElementAction extends AbstractPositionableViewModelElementAction {
private final GeckoViewModel geckoViewModel;
private final SystemConnectionViewModel systemConnectionViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import org.gecko.viewmodel.PositionableViewModelElement;
import org.gecko.viewmodel.SystemViewModel;

/**
* A concrete representation of an {@link Action} that removes a {@link SystemViewModel} from a given
* {@link SystemViewModel}.
*/
public class DeleteSystemViewModelElementAction extends AbstractPositionableViewModelElementAction {
private final GeckoViewModel geckoViewModel;
private final SystemViewModel systemViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import org.gecko.viewmodel.EditorViewModel;
import org.gecko.viewmodel.PositionableViewModelElement;

/**
* A concrete representation of an {@link Action} that selects and focuses on a {link PositionableViewModelElement}.
*/
public class FocusPositionableViewModelElementAction extends Action {

private final EditorViewModel editorViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import org.gecko.exceptions.GeckoException;
import org.gecko.viewmodel.EdgeViewModel;

/**
* A concrete representation of an {@link Action} that changes the priority of an {@link EdgeViewModel}. Holds the old
* and new priorities of the edge.
*/
public class ModifyEdgeViewModelPriorityAction extends Action {

private final EdgeViewModel edgeViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import org.gecko.viewmodel.EditorViewModel;
import org.gecko.viewmodel.PositionableViewModelElement;

/**
* A concrete representation of an {@link Action} that moves a set of {link PositionableViewModelElement}s with a given
* {@link Point2D delta value}.
*/
public class MoveBlockViewModelElementAction extends Action {

private final EditorViewModel editorViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import org.gecko.viewmodel.GeckoViewModel;
import org.gecko.viewmodel.StateViewModel;

/**
* A concrete representation of an {@link Action} that moves an {link EdgeViewModelElement} with a given
* {@link Point2D delta value}.
*/
public class MoveEdgeViewModelElementAction extends Action {

private final GeckoViewModel geckoViewModel;
Expand Down
Loading

0 comments on commit 91794a3

Please sign in to comment.