Skip to content

Commit

Permalink
Merge branch 'main' into viewpalette
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelnjri authored Dec 8, 2021
2 parents 8e270eb + fd695b9 commit cf45f4a
Show file tree
Hide file tree
Showing 31 changed files with 1,078 additions and 422 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ jobs:
# Runs a command (running tests) using the runners shell
- name: Run tests
working-directory: ./JHotDraw

run: mvn test

2 changes: 2 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ jobs:
- name: Testing project
working-directory: ./JHotDraw
run: mvn test


31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@

/JHotDraw/target/

# Netbeans
nbactions.xml
nb-configuration.xml
build/
dist/

# IntelliJ
.idea/
*.iml
*.iws

# Eclipse
.classpath
.project
.settings/
bin/

# Mac
.DS_Store

# Maven
target/
runner/
FeatureTraces/
nbactions.xml
nb-configuration.xml
/JHotDraw/nbproject/

JHotDraw/src/main/java/org/jhotdraw/app/DefaultSDIApplication.java
16 changes: 11 additions & 5 deletions JHotDraw/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
<artifactId>featuretracer</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.6</version>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand All @@ -47,5 +42,16 @@
<version>1.0.0-RC6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.jhotdraw.app.action;

import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.beans.*;
import java.util.*;
import org.jhotdraw.util.*;
import org.jhotdraw.app.Application;
import org.jhotdraw.app.JHotDrawFeatures;
import org.jhotdraw.app.View;

/**
*
* @author Mustafa
*/
public abstract class AbstractRedoUndoAction extends AbstractViewAction {
public static String ID;


private PropertyChangeListener redoActionPropertyListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
String name = evt.getPropertyName();
if (name == AbstractAction.NAME) {
putValue(AbstractAction.NAME, evt.getNewValue());
} else if (name == "enabled") {
updateEnabledState();
}
}
};

/** Creates a new instance. */
public AbstractRedoUndoAction(Application app) {
super(app);
}

protected void updateEnabledState() {
boolean isEnabled = false;
Action realAction = getRealAction();
if (realAction != null) {
isEnabled = realAction.isEnabled();
}
setEnabled(isEnabled);
}

@Override protected void updateView(View oldValue, View newValue) {
super.updateView(oldValue, newValue);
if (newValue != null && newValue.getAction(ID) != null) {
putValue(AbstractAction.NAME, newValue.getAction(ID).
getValue(AbstractAction.NAME));
updateEnabledState();
}
}
/**
* Installs listeners on the view object.
*/
@Override protected void installViewListeners(View p) {
super.installViewListeners(p);
if (p.getAction(ID) != null) {
p.getAction(ID).addPropertyChangeListener(redoActionPropertyListener);
}
}
/**
* Installs listeners on the view object.
*/
@Override protected void uninstallViewListeners(View p) {
super.uninstallViewListeners(p);
if (p.getAction(ID) != null) {
p.getAction(ID).removePropertyChangeListener(redoActionPropertyListener);
}
}

@FeatureEntryPoint(JHotDrawFeatures.UNDO_REDO)
public void actionPerformed(ActionEvent e) {
Action realAction = getRealAction();
if (realAction != null) {
realAction.actionPerformed(e);
}
}

public abstract Action getRealAction();


}

60 changes: 3 additions & 57 deletions JHotDraw/src/main/java/org/jhotdraw/app/action/RedoAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,72 +34,18 @@
* @version 2.0 2006-06-15 Reworked.
* <br>1.0 October 9, 2005 Created.
*/
public class RedoAction extends AbstractViewAction {
public class RedoAction extends AbstractRedoUndoAction {
public final static String ID = "edit.redo";
private ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.app.Labels");

private PropertyChangeListener redoActionPropertyListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
String name = evt.getPropertyName();
if (name == AbstractAction.NAME) {
putValue(AbstractAction.NAME, evt.getNewValue());
} else if (name == "enabled") {
updateEnabledState();
}
}
};

/** Creates a new instance. */
public RedoAction(Application app) {
super(app);
labels.configureAction(this, ID);
}

protected void updateEnabledState() {
boolean isEnabled = false;
Action realRedoAction = getRealRedoAction();
if (realRedoAction != null) {
isEnabled = realRedoAction.isEnabled();
}
setEnabled(isEnabled);
}

@Override protected void updateView(View oldValue, View newValue) {
super.updateView(oldValue, newValue);
if (newValue != null && newValue.getAction(ID) != null) {
putValue(AbstractAction.NAME, newValue.getAction(ID).
getValue(AbstractAction.NAME));
updateEnabledState();
}
}
/**
* Installs listeners on the view object.
*/
@Override protected void installViewListeners(View p) {
super.installViewListeners(p);
if (p.getAction(ID) != null) {
p.getAction(ID).addPropertyChangeListener(redoActionPropertyListener);
}
}
/**
* Installs listeners on the view object.
*/
@Override protected void uninstallViewListeners(View p) {
super.uninstallViewListeners(p);
if (p.getAction(ID) != null) {
p.getAction(ID).removePropertyChangeListener(redoActionPropertyListener);
}
}

@FeatureEntryPoint(JHotDrawFeatures.UNDO_REDO)
public void actionPerformed(ActionEvent e) {
Action realRedoAction = getRealRedoAction();
if (realRedoAction != null) {
realRedoAction.actionPerformed(e);
}
}

private Action getRealRedoAction() {
@Override
public Action getRealAction() {
return (getActiveView() == null) ? null : getActiveView().getAction(ID);
}

Expand Down
59 changes: 4 additions & 55 deletions JHotDraw/src/main/java/org/jhotdraw/app/action/UndoAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.jhotdraw.app.Application;
import org.jhotdraw.app.JHotDrawFeatures;
import org.jhotdraw.app.View;
import static org.jhotdraw.app.action.RedoAction.ID;
/**
* Undoes the last user action.
* In order to work, this action requires that the View returns a view-specific
Expand All @@ -31,72 +32,20 @@
* @version 2.0 2006-06-15 Reworked.
* <br>1.0 October 9, 2005 Created.
*/
public class UndoAction extends AbstractViewAction {
public class UndoAction extends AbstractRedoUndoAction {
public final static String ID = "edit.undo";
private ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.app.Labels");

private PropertyChangeListener redoActionPropertyListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
String name = evt.getPropertyName();
if (name == AbstractAction.NAME) {
putValue(AbstractAction.NAME, evt.getNewValue());
} else if (name == "enabled") {
updateEnabledState();
}
}
};

/** Creates a new instance. */
public UndoAction(Application app) {
super(app);
labels.configureAction(this, ID);
}

protected void updateEnabledState() {
boolean isEnabled = false;
Action realRedoAction = getRealRedoAction();
if (realRedoAction != null) {
isEnabled = realRedoAction.isEnabled();
}
setEnabled(isEnabled);
}

@Override protected void updateView(View oldValue, View newValue) {
super.updateView(oldValue, newValue);
if (newValue != null && newValue.getAction(ID) != null) {
putValue(AbstractAction.NAME, newValue.getAction(ID).
getValue(AbstractAction.NAME));
updateEnabledState();
}
}
/**
* Installs listeners on the view object.
*/
@Override protected void installViewListeners(View p) {
super.installViewListeners(p);
if (p.getAction(ID) != null) {
p.getAction(ID).addPropertyChangeListener(redoActionPropertyListener);
}
}
/**
* Installs listeners on the view object.
*/
@Override protected void uninstallViewListeners(View p) {
super.uninstallViewListeners(p);
if (p.getAction(ID) != null) {
p.getAction(ID).removePropertyChangeListener(redoActionPropertyListener);
}
}

@FeatureEntryPoint(JHotDrawFeatures.UNDO_REDO)
public void actionPerformed(ActionEvent e) {
Action realRedoAction = getRealRedoAction();
if (realRedoAction != null) {
realRedoAction.actionPerformed(e);
}
}

private Action getRealRedoAction() {
@Override
public Action getRealAction() {
return (getActiveView() == null) ? null : getActiveView().getAction(ID);
}

Expand Down
47 changes: 0 additions & 47 deletions JHotDraw/src/main/java/org/jhotdraw/draw/GroupFigure.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
*/
package org.jhotdraw.draw.action;

import dk.sdu.mmmi.featuretracer.lib.FeatureEntryPoint;
import java.util.Collection;
import java.util.LinkedList;
import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;
import javax.swing.undo.UndoableEdit;
import org.jhotdraw.app.JHotDrawFeatures;
import org.jhotdraw.draw.CompositeFigure;
import org.jhotdraw.draw.DrawingEditor;
import org.jhotdraw.draw.DrawingView;
Expand Down Expand Up @@ -73,6 +75,7 @@ boolean canPerformAction() {
return getView() != null && getView().getSelectionCount() > 1;
}

@FeatureEntryPoint(JHotDrawFeatures.GROUPING)
@Override
void perform() {
final DrawingView view = getView();
Expand Down
Loading

0 comments on commit cf45f4a

Please sign in to comment.