Compare commits

..

5 Commits

Author SHA1 Message Date
d117052ca4 Aggregate Change
All checks were successful
zdm/undo-redo/pipeline/head This commit looks good
The aggregate change combines multiple changes into one while
implementing the Change interface.
2022-02-11 09:48:41 +01:00
b30f806894 Improve Javadoc, make wrapper properties final 2022-02-11 09:48:34 +01:00
4872fd3db3 Merge pull request 'Bump Version to 0.1.0' (#9) from r/0.1.0 into develop
All checks were successful
zdm/undo-redo/pipeline/head This commit looks good
Reviewed-on: https://git.kske.dev/zdm/undo-redo/pulls/9
Reviewed-by: DieGurke <maxi@kske.dev>
Reviewed-by: delvh <leon@kske.dev>
2021-12-25 21:33:57 +01:00
833c346914 Bump version to 0.1.0
All checks were successful
zdm/undo-redo/pipeline/head This commit looks good
2021-12-25 22:27:28 +02:00
8ef4a9a572 Fix typo in Javadoc tag 2021-12-25 22:27:03 +02:00
7 changed files with 57 additions and 10 deletions

View File

@ -9,7 +9,7 @@
<parent> <parent>
<groupId>dev.kske</groupId> <groupId>dev.kske</groupId>
<artifactId>undo-redo</artifactId> <artifactId>undo-redo</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.1.0</version>
</parent> </parent>
</project> </project>

View File

@ -0,0 +1,47 @@
package dev.kske.undoredo.core;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author Kai S. K. Engelbart
* @since 0.2.0
*/
public final class AggregateChange<C extends Change> implements Change {
private final List<C> changes = new ArrayList<>();
@SafeVarargs
public AggregateChange(C... changes) {
this(Arrays.asList(changes));
}
public AggregateChange(Collection<C> changes) {
changes.addAll(changes);
}
@Override
public void apply() {
changes.forEach(Change::apply);
}
@Override
public Change invert() {
List<Change> invertedChanges =
changes
.parallelStream()
.map(Change::invert)
.collect(Collectors.toList());
Collections.reverse(invertedChanges);
return new AggregateChange<>(invertedChanges);
}
@Override
public boolean isIdentity() {
return changes.stream().allMatch(Change::isIdentity);
}
public List<C> changes() {
return Collections.unmodifiableList(changes);
}
}

View File

@ -1,7 +1,7 @@
package dev.kske.undoredo.core; package dev.kske.undoredo.core;
/** /**
* Base interface for changes to be registered in an undo manager. * Base interface for changes to be registered in a change manager.
* *
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @since 0.0.1 * @since 0.0.1

View File

@ -18,7 +18,7 @@ public final class UnlimitedChangeManager<C extends Change> implements ChangeMan
private int markedIndex = -1; private int markedIndex = -1;
/** /**
* @implNode As this change manager uses a linear history model, all changes behind the last * @implNote As this change manager uses a linear history model, all changes behind the last
* applied change will be discarded and therefore can be garbage collected. * applied change will be discarded and therefore can be garbage collected.
*/ */
@Override @Override

View File

@ -9,14 +9,14 @@
<parent> <parent>
<groupId>dev.kske</groupId> <groupId>dev.kske</groupId>
<artifactId>undo-redo</artifactId> <artifactId>undo-redo</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.1.0</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>dev.kske</groupId> <groupId>dev.kske</groupId>
<artifactId>undo-redo-core</artifactId> <artifactId>undo-redo-core</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.openjfx</groupId> <groupId>org.openjfx</groupId>

View File

@ -28,13 +28,13 @@ public class ChangeManagerWrapper<C extends Change, M extends ChangeManager<C>>
public static final String UNDO_AVAILABLE = "undoAvailable"; public static final String UNDO_AVAILABLE = "undoAvailable";
public static final String REDO_AVAILABLE = "redoAvailable"; public static final String REDO_AVAILABLE = "redoAvailable";
protected ReadOnlyObjectWrapper<C> lastChange = protected final ReadOnlyObjectWrapper<C> lastChange =
new ReadOnlyObjectWrapper<>(this, LAST_CHANGE); new ReadOnlyObjectWrapper<>(this, LAST_CHANGE);
protected ReadOnlyBooleanWrapper atMarkedChange = protected final ReadOnlyBooleanWrapper atMarkedChange =
new ReadOnlyBooleanWrapper(this, AT_MARKED_CHANGE); new ReadOnlyBooleanWrapper(this, AT_MARKED_CHANGE);
protected ReadOnlyBooleanWrapper undoAvailable = protected final ReadOnlyBooleanWrapper undoAvailable =
new ReadOnlyBooleanWrapper(this, UNDO_AVAILABLE); new ReadOnlyBooleanWrapper(this, UNDO_AVAILABLE);
protected ReadOnlyBooleanWrapper redoAvailable = protected final ReadOnlyBooleanWrapper redoAvailable =
new ReadOnlyBooleanWrapper(this, REDO_AVAILABLE); new ReadOnlyBooleanWrapper(this, REDO_AVAILABLE);
protected final M manager; protected final M manager;

View File

@ -5,7 +5,7 @@
<groupId>dev.kske</groupId> <groupId>dev.kske</groupId>
<artifactId>undo-redo</artifactId> <artifactId>undo-redo</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.1.0</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Undo-Redo</name> <name>Undo-Redo</name>