Skip to content

Commit bfc78f7

Browse files
committed
looking through all MainWindowActions
1 parent 2a0c88b commit bfc78f7

File tree

58 files changed

+222
-567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+222
-567
lines changed

key.core/src/main/java/de/uka/ilkd/key/pp/SequentPrintFilter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ public ImmutableList<SequentPrintFilterEntry> getFilteredSucc() {
8282
* entries.
8383
*/
8484
protected void filterIdentity() {
85+
if(originalSequent==null) {
86+
return;
87+
}
88+
8589
antec = ImmutableSLList.nil();
8690
Iterator<SequentFormula> it = originalSequent.antecedent().iterator();
8791
while (it.hasNext()) {

key.ui/src/main/java/de/uka/ilkd/key/core/KeYMediator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ public void enableWhenProofLoaded(final Action a) {
720720
addKeYSelectionListener(new KeYSelectionListener() {
721721
@Override
722722
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
723-
a.setEnabled(e.getSource().getSelectedProof() != null);
723+
a.setEnabled(e.source().getSelectedProof() != null);
724724
}
725725
});
726726
}
@@ -736,7 +736,7 @@ public void enableWhenProofLoaded(final javax.swing.AbstractButton a) {
736736

737737
@Override
738738
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
739-
a.setEnabled(e.getSource().getSelectedProof() != null);
739+
a.setEnabled(e.source().getSelectedProof() != null);
740740
}
741741
});
742742
}

key.ui/src/main/java/de/uka/ilkd/key/core/KeYSelectionEvent.java

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,20 @@
66

77
/**
88
* An event that indicates that the users focused node or proof has changed
9+
*
10+
* @param source the source of this event
11+
* @param previousSelection the previously selected item
12+
* @param currentSelection the previously selected item
913
*/
10-
11-
public class KeYSelectionEvent<Sel> {
12-
13-
/** the source of this event */
14-
private final KeYSelectionModel source;
15-
16-
/** the previously selected item */
17-
private final Sel previousSelection;
18-
19-
/**
20-
* creates a new SelectedNodeEvent
21-
*
22-
* @param source the SelectedNodeModel where the event had its origin
23-
* @param previousSelection the previous selected item
24-
*/
25-
public KeYSelectionEvent(KeYSelectionModel source, Sel previousSelection) {
26-
this.source = source;
27-
this.previousSelection = previousSelection;
28-
}
29-
30-
/**
31-
* creates a new SelectedNodeEvent
32-
*
33-
* @param source the SelectedNodeModel where the event had its origin
34-
*/
35-
public KeYSelectionEvent(KeYSelectionModel source) {
36-
this(source, null);
37-
}
38-
39-
14+
public record KeYSelectionEvent<Sel>(
15+
KeYSelectionModel source, Sel previousSelection, Sel currentSelection) {
4016
/**
4117
* returns the KeYSelectionModel that caused this event
4218
*
4319
* @return the KeYSelectionModel that caused this event
4420
*/
45-
public KeYSelectionModel getSource() {
21+
@Override
22+
public KeYSelectionModel source() {
4623
return source;
4724
}
48-
49-
/**
50-
* returns the previous selected item
51-
*
52-
* @return the previous selected item
53-
*/
54-
public Sel getPreviousSelection() {
55-
return previousSelection;
56-
}
5725
}

key.ui/src/main/java/de/uka/ilkd/key/core/KeYSelectionModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public void removeKeYSelectionListener(KeYSelectionListener listener) {
360360
public synchronized void fireSelectedNodeChanged(Node previousNode) {
361361
synchronized (listenerList) {
362362
final KeYSelectionEvent<Node> selectionEvent =
363-
new KeYSelectionEvent<>(this, previousNode);
363+
new KeYSelectionEvent<>(this, previousNode, selectedNode);
364364
for (final KeYSelectionListener listener : listenerList) {
365365
listener.selectedNodeChanged(selectionEvent);
366366
}
@@ -371,7 +371,7 @@ public synchronized void fireSelectedProofChanged(Proof previousProof) {
371371
synchronized (listenerList) {
372372
LOGGER.debug("Selected Proof changed, firing...");
373373
final KeYSelectionEvent<Proof> selectionEvent =
374-
new KeYSelectionEvent<>(this, previousProof);
374+
new KeYSelectionEvent<>(this, previousProof, proof);
375375
for (final KeYSelectionListener listener : listenerList) {
376376
listener.selectedProofChanged(selectionEvent);
377377
}

key.ui/src/main/java/de/uka/ilkd/key/gui/GoalList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ public void selectedNodeChanged(KeYSelectionEvent<Node> e) {
568568
*/
569569
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
570570
LOGGER.debug("GoalList: initialize with new proof");
571-
selectingListModel.setProof(e.getSource().getSelectedProof());
571+
selectingListModel.setProof(e.source().getSelectedProof());
572572
validate();
573573
}
574574
}

key.ui/src/main/java/de/uka/ilkd/key/gui/InfoView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public void selectedNodeChanged(KeYSelectionEvent<Node> e) {
214214
*/
215215
@Override
216216
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
217-
final KeYSelectionModel selectionModel = e.getSource();
217+
final KeYSelectionModel selectionModel = e.source();
218218
Runnable action = () -> {
219219
if (isVisible()) {
220220
if (selectionModel.getSelectedProof() == null) {

key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.awt.event.KeyEvent;
99
import java.beans.PropertyChangeEvent;
1010
import java.beans.PropertyChangeListener;
11+
import java.lang.reflect.Field;
1112
import java.lang.reflect.InvocationTargetException;
1213
import java.lang.reflect.Method;
1314
import java.nio.file.Path;
@@ -1650,7 +1651,7 @@ public synchronized void selectedProofChanged(KeYSelectionEvent<Proof> e) {
16501651
if (proof != null && !proof.isDisposed()) {
16511652
proof.getSettings().getStrategySettings().removePropertyChangeListener(this);
16521653
}
1653-
proof = e.getSource().getSelectedProof();
1654+
proof = e.source().getSelectedProof();
16541655
if (proof != null) {
16551656
proof.getSettings().getStrategySettings().removePropertyChangeListener(this);
16561657
}
@@ -1697,7 +1698,7 @@ private void enable(boolean b) {
16971698

16981699
@Override
16991700
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
1700-
handleProof(e.getSource().getSelectedProof());
1701+
handleProof(e.source().getSelectedProof());
17011702
}
17021703

17031704
private void handleProof(Proof p) {
@@ -1710,7 +1711,7 @@ private void handleProof(Proof p) {
17101711

17111712
@Override
17121713
public void selectedNodeChanged(KeYSelectionEvent<Node> e) {
1713-
handleProof(e.getSource().getSelectedProof());
1714+
handleProof(e.source().getSelectedProof());
17141715
}
17151716

17161717
}

key.ui/src/main/java/de/uka/ilkd/key/gui/ProofMacroMenu.java

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
import javax.swing.*;
88

99
import de.uka.ilkd.key.core.KeYMediator;
10+
import de.uka.ilkd.key.core.KeYSelectionEvent;
11+
import de.uka.ilkd.key.core.KeYSelectionListener;
12+
import de.uka.ilkd.key.core.KeYSelectionModel;
1013
import de.uka.ilkd.key.gui.actions.ProofScriptFromFileAction;
1114
import de.uka.ilkd.key.gui.actions.ProofScriptInputAction;
1215
import de.uka.ilkd.key.gui.actions.useractions.ProofMacroUserAction;
13-
import de.uka.ilkd.key.gui.keyshortcuts.KeyStrokeManager;
1416
import de.uka.ilkd.key.macros.ProofMacro;
1517
import de.uka.ilkd.key.proof.Node;
18+
import de.uka.ilkd.key.proof.Proof;
1619
import de.uka.ilkd.key.settings.FeatureSettings;
1720

1821
import org.key_project.prover.sequent.PosInOccurrence;
@@ -24,8 +27,8 @@
2427
* This class provides the user interface to the macro extensions.
2528
*
2629
* <p>
27-
* It provides a menu with all macros which are applicable in a given context. The check of of
28-
* applicability is done using {@link ProofMacro#canApplyTo}.
30+
* It provides a menu with all macros which are applicable in a given context.
31+
* The check of applicability is done using {@link ProofMacro#canApplyTo}.
2932
*
3033
* <p>
3134
* The menu items bear the name returned by {@link ProofMacro#getName()} and the tooltip is set to
@@ -39,19 +42,14 @@
3942
* register a macro, add its class name to the file
4043
* <tt>resources/META-INF/services/de.uka.ilkd.key.macros.ProofMacro</tt>.
4144
*
45+
* @author mattias ulbrich
4246
* @see ProofMacro
4347
* @see ServiceLoader
44-
*
45-
* @author mattias ulbrich
4648
*/
4749
public class ProofMacroMenu extends JMenu {
48-
49-
50-
private static final long serialVersionUID = -5946657022043894399L;
51-
5250
/**
5351
* The loader used to access the providers for macros.
54-
*
52+
* <p>
5553
* This is used as iteration source in other parts of KeY's ui.
5654
*/
5755
public static final Iterable<ProofMacro> REGISTERED_MACROS =
@@ -73,13 +71,11 @@ public class ProofMacroMenu extends JMenu {
7371
* @param mediator the mediator of the current proof.
7472
* @param posInOcc the pos in occurrence, can be <code>null</code> if not available.
7573
*/
76-
public ProofMacroMenu(KeYMediator mediator,
77-
PosInOccurrence posInOcc) {
74+
public ProofMacroMenu(KeYMediator mediator, PosInOccurrence posInOcc) {
7875
super("Strategy Macros");
7976

8077
// Macros are grouped according to their category.
8178
Map<String, List<JMenuItem>> submenus = new LinkedHashMap<>();
82-
8379
int count = 0;
8480
Node node = mediator.getSelectedNode();
8581
for (ProofMacro macro : REGISTERED_MACROS) {
@@ -127,25 +123,23 @@ public ProofMacroMenu(KeYMediator mediator,
127123
}
128124
});
129125
}
130-
131-
mediator.enableWhenProofLoaded(this);
132126
this.numberOfMacros = count;
127+
128+
setEnabled(mediator.getSelectedProof() != null);
129+
mediator.addKeYSelectionListener(new KeYSelectionListener() {
130+
@Override
131+
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
132+
setEnabled(e.currentSelection() != null);
133+
}
134+
});
133135
}
134136

135-
private static JMenuItem createMenuItem(final ProofMacro macro, final KeYMediator mediator,
137+
private static JMenuItem createMenuItem(final ProofMacro macro,
138+
final KeYMediator mediator,
136139
final PosInOccurrence posInOcc) {
137-
138-
JMenuItem menuItem = new JMenuItem(macro.getName());
139-
menuItem.setToolTipText(macro.getDescription());
140-
final KeyStroke macroKey = KeyStrokeManager.get(macro);
141-
142-
if (macroKey != null && posInOcc == null) { // currently only for global macro applications
143-
menuItem.setAccelerator(macroKey);
144-
}
145-
146-
menuItem.addActionListener(
147-
new ProofMacroUserAction(mediator, macro, posInOcc, mediator.getSelectedProof()));
148-
return menuItem;
140+
var action =
141+
new ProofMacroUserAction(mediator, macro, posInOcc, mediator.getSelectedProof());
142+
return new JMenuItem(action);
149143
}
150144

151145
/**

key.ui/src/main/java/de/uka/ilkd/key/gui/SelectionHistory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ public void navigateForward() {
151151
@Override
152152
public void selectedNodeChanged(KeYSelectionEvent<Node> e) {
153153
if (selectedNodes.isEmpty()) {
154-
selectedNodes.add(new WeakReference<>(e.getSource().getSelectedNode()));
154+
selectedNodes.add(new WeakReference<>(e.source().getSelectedNode()));
155155
fireChangeEvent();
156156
return;
157157
}
158158
Node last = selectedNodes.peekLast().get();
159-
Node now = e.getSource().getSelectedNode();
159+
Node now = e.source().getSelectedNode();
160160
if (last != now) {
161161
selectedNodes.add(new WeakReference<>(now));
162162
fireChangeEvent();
@@ -165,7 +165,7 @@ public void selectedNodeChanged(KeYSelectionEvent<Node> e) {
165165

166166
@Override
167167
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
168-
Proof p = e.getSource().getSelectedProof();
168+
Proof p = e.source().getSelectedProof();
169169
if (p == null || monitoredProofs.contains(p)) {
170170
return;
171171
}

key.ui/src/main/java/de/uka/ilkd/key/gui/StrategySelectionView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public final class StrategySelectionView extends JPanel implements TabPanel {
9898
private final KeYSelectionListener mediatorListener = new KeYSelectionListener() {
9999

100100
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
101-
refresh(e.getSource().getSelectedProof());
101+
refresh(e.source().getSelectedProof());
102102
}
103103
};
104104
private JButton btnGo;

0 commit comments

Comments
 (0)