Skip to content

Commit

Permalink
Added editor stubs in viewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
benjymin committed Jan 12, 2024
1 parent d0597b8 commit f689f76
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.gecko.viewmodel;

public class AutomatonEditorViewModel extends EditorViewModel {
public AutomatonEditorViewModel(SystemViewModel currentSystem) {
super(currentSystem);
}
}
36 changes: 36 additions & 0 deletions src/main/java/org/gecko/viewmodel/EditorViewModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.gecko.viewmodel;

import javafx.beans.property.Property;
import javafx.beans.value.ObservableObjectValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Point2D;
import lombok.Getter;
import lombok.Setter;
import org.gecko.tools.Tool;

import java.util.List;

@Getter @Setter
public abstract class EditorViewModel {
private Property<Point2D> pivot;
private Property<Double> zoomScale;
private ObservableObjectValue<Tool> currentTool;
private ObservableObjectValue<PositionableViewModelElement<?>> focusedElement;
private final SystemViewModel currentSystem;
private final ObservableList<PositionableViewModelElement<?>> containedPositionableViewModelElements;
private List<Tool> tools;
private SelectionManager selectionManager;

protected EditorViewModel(SystemViewModel systemViewModel) {
currentSystem = systemViewModel;
containedPositionableViewModelElements = FXCollections.observableArrayList();
//TODO stub
}

public List<RegionViewModel> getRegionViewModels(StateViewModel stateViewModel) {
//TODO stub
return null;
}

}
27 changes: 27 additions & 0 deletions src/main/java/org/gecko/viewmodel/GeckoViewModel.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
package org.gecko.viewmodel;

import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.value.ObservableObjectValue;
import lombok.Getter;
import lombok.Setter;
import org.gecko.model.Element;
import org.gecko.model.GeckoModel;

import java.util.HashMap;

@Getter @Setter
public class GeckoViewModel {
private final HashMap<Element, PositionableViewModelElement<?>> modelToViewModel;
private final GeckoModel geckoModel;
private final ViewModelFactory viewModelFactory;
private ObservableObjectValue<EditorViewModel> currentEditor;
private final ListProperty<EditorViewModel> openedEditors;

public GeckoViewModel(GeckoModel geckoModel) {
modelToViewModel = new HashMap<>();
this.geckoModel = geckoModel;
viewModelFactory = new ViewModelFactory(this, geckoModel.getModelFactory());
openedEditors = new SimpleListProperty<>();
}

public void switchEditor(SystemViewModel nextSystemViewModel, boolean isAutomatonEditor) {
//TODO stub
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.gecko.viewmodel;

public interface PositionableViewModelElementVisitor {
void visit(SystemViewModel systemViewModel);
void visit(RegionViewModel regionViewModel);
void visit(SystemConnectionViewModel systemConnectionViewModel);
void visit(EdgeViewModel edgeViewModel);
void visit(StateViewModel stateViewModel);
void visit(PortViewModel portViewModel);
}
37 changes: 37 additions & 0 deletions src/main/java/org/gecko/viewmodel/SelectionManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.gecko.viewmodel;

import javafx.collections.ObservableList;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
import java.util.Stack;

@Getter @Setter
public class SelectionManager {
private Stack<List<PositionableViewModelElement<?>>> undoSelectionStack;
private Stack<List<PositionableViewModelElement<?>>> redoSelectionStack;
private ObservableList<PositionableViewModelElement<?>> currentSelection;

public void goBack() {
//TODO stub
}
public void goForward() {
//TODO stub
}
public void select(PositionableViewModelElement<?> element) {
//TODO stub
}
public void select(List<PositionableViewModelElement<?>> elements) {
//TODO stub
}
public void deselect(PositionableViewModelElement<?> element) {
//TODO stub
}
public void deselect(List<PositionableViewModelElement<?>> elements) {
//TODO stub
}
public void deselectAll() {
//TODO stub
}
}
7 changes: 7 additions & 0 deletions src/main/java/org/gecko/viewmodel/SystemEditorViewModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.gecko.viewmodel;

public class SystemEditorViewModel extends EditorViewModel{
public SystemEditorViewModel(SystemViewModel currentSystem) {
super(currentSystem);
}
}
71 changes: 71 additions & 0 deletions src/main/java/org/gecko/viewmodel/ViewModelFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.gecko.viewmodel;

import org.gecko.model.*;
import org.gecko.model.System;

public class ViewModelFactory {
private final ModelFactory modelFactory;
private final GeckoViewModel geckoViewModel;

public ViewModelFactory(GeckoViewModel geckoViewModel, ModelFactory modelFactory) {
this.geckoViewModel = geckoViewModel;
this.modelFactory = modelFactory;
}
public EditorViewModel createEditorViewModel(SystemViewModel systemViewModel, boolean isAutomatonEditor) {
//TODO stub
return null;
}
public StateViewModel createStateViewModelIn(SystemViewModel parentSystem) {
//TODO stub
return null;
}
public StateViewModel createStateViewModelFrom(State state) {
//TODO stub
return null;
}
public EdgeViewModel createEdgeViewModelIn(SystemViewModel parentSystem) {
//TODO stub
return null;
}
public EdgeViewModel createEdgeViewModelFrom(Edge edge) {
//TODO stub
return null;
}
public SystemConnectionViewModel createSystemConnectionViewModelIn(SystemViewModel parentSystem) {
//TODO stub
return null;
}
public SystemConnectionViewModel createSystemConnectionViewModelFrom(SystemConnection systemConnection) {
//TODO stub
return null;
}
public SystemViewModel createSystemViewModelIn(SystemViewModel parentSystem) {
//TODO stub
return null;
}
public SystemViewModel createSystemViewModelFrom(System system) {
//TODO stub
return null;
}
public RegionViewModel createRegionViewModelIn(SystemViewModel parentSystem) {
//TODO stub
return null;
}
public RegionViewModel createRegionViewModelFrom(Region region) {
//TODO stub
return null;
}
public PortViewModel createPortViewModelIn(SystemViewModel systemViewModel) {
//TODO stub
return null;
}
public PortViewModel createPortViewModelFrom(Variable variable) {
//TODO stub
return null;
}
public ContractViewModel createContractViewModelIn(StateViewModel stateViewModel) {
//TODO stub
return null;
}

}

0 comments on commit f689f76

Please sign in to comment.