-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #561 from JLLeitschuh/feat/dragAndDropOperations
Feat/drag and drop operations
- Loading branch information
Showing
17 changed files
with
490 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
ui/src/main/java/edu/wpi/grip/ui/dragging/DragService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package edu.wpi.grip.ui.dragging; | ||
|
||
|
||
import javafx.beans.property.ObjectProperty; | ||
import javafx.beans.property.ReadOnlyObjectProperty; | ||
import javafx.beans.property.SimpleObjectProperty; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* A service to provide data transfer capabilities between two controllers. | ||
* Concrete versions of the service are usually {@link com.google.inject.Singleton Singletons} | ||
* so that they can be injected into the two controllers. | ||
* | ||
* @param <T> The value that the object property holds. | ||
*/ | ||
public abstract class DragService<T> { | ||
private final ObjectProperty<T> dragProperty; | ||
|
||
/** | ||
* @param name The name for the {@link SimpleObjectProperty} | ||
*/ | ||
public DragService(String name) { | ||
this.dragProperty = new SimpleObjectProperty<>(this, name); | ||
} | ||
|
||
/** | ||
* @return The read only version of this object property. | ||
*/ | ||
public ReadOnlyObjectProperty<T> getDragProperty() { | ||
return dragProperty; | ||
} | ||
|
||
/** | ||
* @return The value stored in the object property. | ||
*/ | ||
public Optional<T> getValue() { | ||
return Optional.ofNullable(dragProperty.get()); | ||
} | ||
|
||
/** | ||
* Begins the drag action | ||
* | ||
* @param value The value to be transferred during the drag. | ||
*/ | ||
public void beginDrag(T value) { | ||
this.dragProperty.set(value); | ||
} | ||
|
||
/** | ||
* This should be called when the drag action is complete. | ||
*/ | ||
public void completeDrag() { | ||
dragProperty.setValue(null); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
ui/src/main/java/edu/wpi/grip/ui/dragging/OperationDragService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package edu.wpi.grip.ui.dragging; | ||
|
||
|
||
import com.google.inject.Singleton; | ||
import edu.wpi.grip.core.Operation; | ||
|
||
/** | ||
* Service for dragging an {@link Operation} from the {@link edu.wpi.grip.ui.pipeline.PipelineController} | ||
* to the {@link edu.wpi.grip.ui.pipeline.PipelineController}. | ||
*/ | ||
@Singleton | ||
public class OperationDragService extends DragService<Operation> { | ||
|
||
public OperationDragService() { | ||
super("operation"); | ||
} | ||
} |
Oops, something went wrong.