Skip to content

Commit

Permalink
inspector implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
crissNb committed Jan 14, 2024
1 parent e5e1497 commit 4bdb01b
Show file tree
Hide file tree
Showing 55 changed files with 857 additions and 216 deletions.
50 changes: 33 additions & 17 deletions src/main/java/org/gecko/actions/ActionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import javafx.geometry.Point2D;
import org.gecko.model.SystemConnection;
import org.gecko.model.Visibility;
import org.gecko.tools.Tool;
import org.gecko.viewmodel.ContractViewModel;
import org.gecko.viewmodel.EdgeViewModel;
import org.gecko.viewmodel.EditorViewModel;
import org.gecko.viewmodel.GeckoViewModel;
Expand Down Expand Up @@ -30,45 +32,41 @@ public CopyPositionableViewModelElementAction createCopyPositionableViewModelEle
}

public CreateContractViewModelElementAction createCreateContractViewModelElementAction(
GeckoViewModel geckoViewModel, StateViewModel stateViewModel) {
StateViewModel stateViewModel) {
return new CreateContractViewModelElementAction(this, geckoViewModel, stateViewModel);
}

public CreateEdgeViewModelElementAction createCreateEdgeViewModelElementAction(
GeckoViewModel geckoViewModel,
ViewModelFactory viewModelFactory,
StateViewModel source,
StateViewModel destination) {
ViewModelFactory viewModelFactory, StateViewModel source, StateViewModel destination) {
return new CreateEdgeViewModelElementAction(
this, geckoViewModel, viewModelFactory, source, destination);
}

public CreatePortViewModelElementAction createCreatePortViewModelElementAction(
GeckoViewModel geckoViewModel, ViewModelFactory viewModelFactory) {
ViewModelFactory viewModelFactory) {
return new CreatePortViewModelElementAction(this, geckoViewModel, viewModelFactory);
}

public CreatePortViewModelElementAction createCreatePortViewModelElementAction(
GeckoViewModel geckoViewModel, ViewModelFactory viewModelFactory, Point2D position) {
ViewModelFactory viewModelFactory, Point2D position) {
return new CreatePortViewModelElementAction(
this, geckoViewModel, viewModelFactory, position);
}

public CreateRegionViewModelElementAction createCreateRegionViewModelElementAction(
GeckoViewModel geckoViewModel, ViewModelFactory viewModelFactory, Point2D position) {
ViewModelFactory viewModelFactory, Point2D position) {
return new CreateRegionViewModelElementAction(
this, geckoViewModel, viewModelFactory, position);
}

public CreateStateViewModelElementAction createCreateStateViewModelElementAction(
GeckoViewModel geckoViewModel, ViewModelFactory viewModelFactory, Point2D position) {
ViewModelFactory viewModelFactory, Point2D position) {
return new CreateStateViewModelElementAction(
this, geckoViewModel, viewModelFactory, position);
}

public CreateSystemConnectionViewModelElementAction
createCreateSystemConnectionViewModelElementAction(
GeckoViewModel geckoViewModel,
ViewModelFactory viewModelFactory,
PortViewModel source,
PortViewModel destination) {
Expand All @@ -77,19 +75,33 @@ public CreateStateViewModelElementAction createCreateStateViewModelElementAction
}

public CreateSystemViewModelElementAction createCreateSystemViewModelElementAction(
GeckoViewModel geckoViewModel, ViewModelFactory viewModelFactory, Point2D position) {
ViewModelFactory viewModelFactory, Point2D position) {
return new CreateSystemViewModelElementAction(
this, geckoViewModel, viewModelFactory, position);
}

public CreateVariableAction createCreateVariableAction(SystemViewModel systemViewModel, Visibility visibility) {
return new CreateVariableAction(this, systemViewModel, visibility);
}

public CutPositionableViewModelElementAction createCutPositionableViewModelElementAction(
EditorViewModel editorViewModel, List<PositionableViewModelElement<?>> elements) {
return new CutPositionableViewModelElementAction(this, editorViewModel, elements);
}

public DeleteContractViewModelAction createDeleteContractViewModelAction(
GeckoViewModel geckoViewModel, StateViewModel parent) {
return new DeleteContractViewModelAction(this, geckoViewModel, parent);
StateViewModel parent, ContractViewModel contractViewModel) {
return new DeleteContractViewModelAction(this, geckoViewModel, parent, contractViewModel);
}

public DeletePositionableViewModelElementAction createDeletePositionableViewModelElementAction(
PositionableViewModelElement<?> element) {
return new DeletePositionableViewModelElementAction(this, geckoViewModel, element);
}

public DeletePositionableViewModelElementAction createDeletePositionableViewModelElementAction(
List<PositionableViewModelElement<?>> elements) {
return new DeletePositionableViewModelElementAction(this, geckoViewModel, elements);
}

public MoveBlockViewModelElementAction createMoveBlockViewModelElementAction(
Expand All @@ -114,13 +126,12 @@ public PanAction createPanAction(EditorViewModel editorViewModel, Point2D pivot)
return new PanAction(this, editorViewModel, pivot);
}

public PastePositionableViewModelElementAction createPastePositionableViewModelElementAction(
GeckoViewModel geckoViewModel) {
public PastePositionableViewModelElementAction createPastePositionableViewModelElementAction() {
return new PastePositionableViewModelElementAction(this, geckoViewModel);
}

public PastePositionableViewModelElementAction createPastePositionableViewModelElementAction(
GeckoViewModel geckoViewModel, List<PositionableViewModelElement<?>> elements) {
List<PositionableViewModelElement<?>> elements) {
return new PastePositionableViewModelElementAction(this, geckoViewModel, elements);
}

Expand All @@ -131,7 +142,7 @@ public RenameViewModelElementAction createRenameViewModelElementAction(

public RestorePositionableViewModelElementAction
createRestorePositionableViewModelElementAction(
GeckoViewModel geckoViewModel, List<PositionableViewModelElement<?>> elements) {
List<PositionableViewModelElement<?>> elements) {
return new RestorePositionableViewModelElementAction(this, geckoViewModel, elements);
}

Expand All @@ -140,6 +151,11 @@ public ScaleBlockViewModelElementAction createScaleBlockViewModelElementAction(
return new ScaleBlockViewModelElementAction(this, selectionManager, scaleFactor);
}

public FocusPositionableViewModelElementAction createFocusPositionableViewModelElementAction(
EditorViewModel editorViewModel, PositionableViewModelElement<?> element) {
return new FocusPositionableViewModelElementAction(this, editorViewModel, element);
}

public SelectAction createSelectAction(
EditorViewModel editorViewModel,
PositionableViewModelElement<?> element,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/gecko/actions/ActionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void redo() {
//TODO stub
}

void run(Action action) {
public void run(Action action) {
//TODO register action if undoable
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/gecko/actions/CreateVariableAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.gecko.actions;

import org.gecko.model.Visibility;
import org.gecko.viewmodel.SystemViewModel;

public class CreateVariableAction extends Action {

public CreateVariableAction(ActionFactory actionFactory, SystemViewModel systemViewModel, Visibility visibility) {}

@Override
void run() {}

@Override
Action getUndoAction(ActionFactory actionFactory) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.gecko.actions;

import org.gecko.viewmodel.ContractViewModel;
import org.gecko.viewmodel.GeckoViewModel;
import org.gecko.viewmodel.StateViewModel;

public class DeleteContractViewModelAction extends Action {
DeleteContractViewModelAction(
ActionFactory actionFactory, GeckoViewModel geckoViewModel, StateViewModel parent) {}
ActionFactory actionFactory,
GeckoViewModel geckoViewModel,
StateViewModel parent,
ContractViewModel contractViewModel) {}

@Override
void run() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DeletePositionableViewModelElementAction extends Action {
DeletePositionableViewModelElementAction(
ActionFactory actionFactory,
GeckoViewModel geckoViewModel,
List<PositionableViewModelElement<?>> element) {}
List<PositionableViewModelElement<?>> elements) {}

@Override
void run() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.gecko.actions;

import org.gecko.viewmodel.PositionableViewModelElement;
import org.gecko.viewmodel.EditorViewModel;

public class FocusPositionableViewModelElementAction extends Action {
public FocusPositionableViewModelElementAction(
ActionFactory actionFactory,
EditorViewModel editorViewModel,
PositionableViewModelElement<?> positionableViewModelElement) {
}

@Override
void run() {

}

@Override
Action getUndoAction(ActionFactory actionFactory) {
return null;
}
}
51 changes: 46 additions & 5 deletions src/main/java/org/gecko/view/inspector/Inspector.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
package org.gecko.view.inspector;

import javafx.scene.Node;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import org.gecko.actions.ActionManager;
import org.gecko.view.inspector.element.InspectorElement;
import org.gecko.viewmodel.PositionableViewModelElement;

import javafx.scene.control.ScrollPane;
import org.gecko.view.inspector.element.button.InspectorCollapseButton;
import org.gecko.view.inspector.element.button.InspectorSelectionBackwardButton;
import org.gecko.view.inspector.element.button.InspectorSelectionForwardButton;
import org.gecko.view.views.EditorView;
import org.gecko.viewmodel.EditorViewModel;

import java.util.List;

public class Inspector<T extends PositionableViewModelElement<?>> {
public class Inspector extends ScrollPane {

public Inspector(
List<InspectorElement<?>> elements,
ActionManager actionManager,
EditorView editorView,
EditorViewModel editorViewModel) {
VBox vBox = new VBox();

// Inspector decorations
HBox inspectorDecorations = new HBox();

// Selection forward/backward buttons
HBox selectionButtons = new HBox();
selectionButtons
.getChildren()
.addAll(
new InspectorSelectionBackwardButton(
actionManager, editorViewModel.getSelectionManager())
.getControl(),
new InspectorSelectionForwardButton(
actionManager, editorViewModel.getSelectionManager())
.getControl());
inspectorDecorations
.getChildren()
.addAll(
selectionButtons,
// Collapse button
new InspectorCollapseButton(editorView));

private T element;
vBox.getChildren().add(inspectorDecorations);

public Inspector(List<InspectorElement<?>> elements) {
for (InspectorElement<?> element : elements) {
vBox.getChildren().add(element.getControl());
}

setContent(vBox);
setFitToWidth(true);
}

public Node getView() {
return null;
return this;
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/gecko/view/inspector/InspectorColorPicker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.gecko.view.inspector;

import javafx.beans.property.Property;
import javafx.scene.control.ColorPicker;
import javafx.scene.paint.Color;
import org.gecko.view.inspector.element.InspectorElement;

public class InspectorColorPicker extends ColorPicker implements InspectorElement<ColorPicker> {
public InspectorColorPicker(Property<Color> targetColorProperty) {
valueProperty().bindBidirectional(targetColorProperty);
}

@Override
public ColorPicker getControl() {
return this;
}
}
59 changes: 35 additions & 24 deletions src/main/java/org/gecko/view/inspector/InspectorFactory.java
Original file line number Diff line number Diff line change
@@ -1,54 +1,65 @@
package org.gecko.view.inspector;

import lombok.Getter;
import org.gecko.actions.ActionManager;
import org.gecko.view.inspector.builder.AbstractInspectorBuilder;
import org.gecko.view.inspector.builder.EdgeInspectorBuilder;
import org.gecko.view.inspector.builder.RegionInspectorBuilder;
import org.gecko.view.inspector.builder.StateInspectorBuilder;
import org.gecko.view.inspector.builder.SystemInspectorBuilder;
import org.gecko.view.inspector.builder.VariableBlockInspectorBuilder;
import org.gecko.view.views.EditorView;
import org.gecko.view.views.viewelement.EdgeViewElement;
import org.gecko.view.views.viewelement.RegionViewElement;
import org.gecko.view.views.viewelement.StateViewElement;
import org.gecko.view.views.viewelement.SystemConnectionViewElement;
import org.gecko.view.views.viewelement.SystemViewElement;
import org.gecko.view.views.viewelement.VariableBlockViewElement;
import org.gecko.view.views.viewelement.ViewElement;
import org.gecko.viewmodel.EdgeViewModel;
import org.gecko.viewmodel.EditorViewModel;
import org.gecko.viewmodel.PortViewModel;
import org.gecko.viewmodel.PositionableViewModelElement;
import org.gecko.viewmodel.PositionableViewModelElementVisitor;
import org.gecko.viewmodel.RegionViewModel;
import org.gecko.viewmodel.StateViewModel;
import org.gecko.viewmodel.SystemConnectionViewModel;
import org.gecko.viewmodel.SystemViewModel;

public class InspectorFactory {

private EditorView editorView;

public InspectorFactory(EditorView editorView) {
@Getter private final EditorView editorView;
@Getter private final EditorViewModel editorViewModel;
@Getter private final ActionManager actionManager;

public InspectorFactory(
ActionManager actionManager, EditorView editorView, EditorViewModel editorViewModel) {
this.actionManager = actionManager;
this.editorView = editorView;
this.editorViewModel = editorViewModel;
}

public<T extends PositionableViewModelElement<?>> Inspector<T> createInspector(ViewElement<T> viewElement) {
return null;
public Inspector createInspector(PositionableViewModelElement<?> viewElement) {
InspectorFactoryVisitor visitor = new InspectorFactoryVisitor(this);
viewElement.accept(visitor);
return visitor.getInspector();
}

public Inspector<StateViewModel> createStateInspector(StateViewElement stateViewElement) {
return null;
public Inspector createStateInspector(StateViewModel stateViewModel) {
return buildInspector(new StateInspectorBuilder(actionManager, editorViewModel, stateViewModel));
}

public Inspector<EdgeViewModel> createEdgeInspector(EdgeViewElement edgeViewElement) {
return null;
public Inspector createEdgeInspector(EdgeViewModel edgeViewModel) {
return buildInspector(
new EdgeInspectorBuilder(actionManager, editorViewModel, edgeViewModel));
}

public Inspector<SystemConnectionViewModel> createSystemConnectionInspector(SystemConnectionViewElement systemConnectionViewElement) {
return null;
public Inspector createRegionInspector(RegionViewModel regionViewModel) {
return buildInspector(new RegionInspectorBuilder(actionManager, regionViewModel));
}

public Inspector<RegionViewModel> createRegionInspector(RegionViewElement regionViewElement) {
return null;
public Inspector createSystemInspector(SystemViewModel systemViewModel) {
return buildInspector(new SystemInspectorBuilder(actionManager, editorViewModel, systemViewModel));
}

public Inspector<SystemViewModel> createSystemInspector(SystemViewElement systemViewElement) {
return null;
public Inspector createVariableBlockInspector(PortViewModel portviewModel) {
return buildInspector(new VariableBlockInspectorBuilder(actionManager, portviewModel));
}

public Inspector<PortViewModel> createVariableBlockInspector(VariableBlockViewElement variableBlockViewElement) {
return null;
private Inspector buildInspector(AbstractInspectorBuilder<?> builder) {
return builder.build(editorView, editorViewModel);
}
}
Loading

0 comments on commit 4bdb01b

Please sign in to comment.