Skip to content

Commit 853e4ce

Browse files
committed
start with fixing #3415
1 parent 627d745 commit 853e4ce

20 files changed

+186
-241
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import de.uka.ilkd.key.control.ProofControl;
1717
import de.uka.ilkd.key.gui.GUIListener;
1818
import de.uka.ilkd.key.gui.UserActionListener;
19+
import de.uka.ilkd.key.gui.actions.MainWindowAction;
1920
import de.uka.ilkd.key.gui.actions.useractions.UserAction;
2021
import de.uka.ilkd.key.gui.notification.events.NotificationEvent;
2122
import de.uka.ilkd.key.gui.notification.events.ProofClosedNotificationEvent;
@@ -704,15 +705,21 @@ public void autoModeStopped(ProofEvent e) {
704705
}
705706
}
706707

707-
/*
708-
* Disable certain actions until a proof is loaded.
709-
*/
708+
/// Disable certain actions until a proof is loaded.
709+
///
710+
/// ### DEPRECATION
711+
/// You should rather use the [MainWindowAction] class
712+
/// with the [MainWindowAction#updateEnablednessOnSelectionChange()] method.
713+
///
714+
/// This provides more flexibility, as the enabledness can define in cases of a
715+
/// combination of predicates.
716+
///
717+
@Deprecated(forRemoval = true)
710718
public void enableWhenProofLoaded(final Action a) {
711719
a.setEnabled(getSelectedProof() != null);
712720
addKeYSelectionListener(new KeYSelectionListener() {
713-
714721
@Override
715-
public void selectedProofChanged(KeYSelectionEvent e) {
722+
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
716723
a.setEnabled(e.getSource().getSelectedProof() != null);
717724
}
718725
});
@@ -722,13 +729,13 @@ public void selectedProofChanged(KeYSelectionEvent e) {
722729
* Disable certain actions until a proof is loaded. This is a workaround for a broken proof
723730
* macro menu in the GUI. Remove this method as soon as another solution can be found.
724731
*/
725-
@Deprecated
732+
@Deprecated(forRemoval = true)
726733
public void enableWhenProofLoaded(final javax.swing.AbstractButton a) {
727734
a.setEnabled(getSelectedProof() != null);
728735
addKeYSelectionListener(new KeYSelectionListener() {
729736

730737
@Override
731-
public void selectedProofChanged(KeYSelectionEvent e) {
738+
public void selectedProofChanged(KeYSelectionEvent<Proof> e) {
732739
a.setEnabled(e.getSource().getSelectedProof() != null);
733740
}
734741
});

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

Lines changed: 22 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
import java.awt.*;
77
import java.awt.event.ActionEvent;
88
import java.awt.event.KeyEvent;
9-
import java.awt.event.KeyListener;
10-
import java.awt.event.MouseEvent;
119
import java.beans.PropertyChangeEvent;
1210
import java.beans.PropertyChangeListener;
1311
import java.io.File;
12+
import java.lang.reflect.Field;
1413
import java.lang.reflect.InvocationTargetException;
1514
import java.lang.reflect.Method;
1615
import java.util.*;
@@ -24,7 +23,6 @@
2423
import javax.swing.event.ChangeListener;
2524
import javax.swing.event.MenuEvent;
2625
import javax.swing.event.MenuListener;
27-
import javax.swing.event.MouseInputAdapter;
2826

2927
import de.uka.ilkd.key.control.AutoModeListener;
3028
import de.uka.ilkd.key.control.TermLabelVisibilityManager;
@@ -57,6 +55,7 @@
5755
import de.uka.ilkd.key.logic.Sequent;
5856
import de.uka.ilkd.key.proof.Goal;
5957
import de.uka.ilkd.key.proof.Proof;
58+
import de.uka.ilkd.key.proof.ProofAggregate;
6059
import de.uka.ilkd.key.proof.ProofEvent;
6160
import de.uka.ilkd.key.rule.RuleApp;
6261
import de.uka.ilkd.key.settings.FeatureSettings;
@@ -106,6 +105,8 @@ public final class MainWindow extends JFrame {
106105
"Activates the 'Run All Proofs' action that allows you to run multiple proofs inside the UI.",
107106
false);
108107

108+
public static final String PROPERTY_IN_AUTO_MODE = "inAutoMode";
109+
109110
private static MainWindow instance = null;
110111
/**
111112
* Search bar for Sequent Views.
@@ -167,23 +168,27 @@ public final class MainWindow extends JFrame {
167168
private final ToggleProofTreeTooltipAction toogleProofTreeTooltipAction =
168169
new ToggleProofTreeTooltipAction(this);
169170
private final TermLabelMenu termLabelMenu;
170-
private boolean frozen = false;
171+
171172
/**
172173
*
173174
*/
174175
private final CControl dockControl = new CControl(this);
176+
175177
/**
176178
* the first toolbar
177179
*/
178180
private JToolBar controlToolBar;
181+
179182
/**
180183
* the second toolbar
181184
*/
182185
private JToolBar fileOpToolBar;
186+
183187
/**
184188
* the status line
185189
*/
186190
private MainStatusLine statusLine;
191+
187192
/**
188193
* action for opening a KeY file
189194
*/
@@ -278,6 +283,7 @@ public final class MainWindow extends JFrame {
278283

279284
private final LruCached<HTMLSyntaxHighlighter.Args, String> highlightCache =
280285
new LruCached<>(HTMLSyntaxHighlighter.Args::run);
286+
private boolean inAutoMode;
281287

282288
/*
283289
* This class should only be instantiated once!
@@ -442,7 +448,7 @@ public TermLabelVisibilityManager getVisibleTermLabels() {
442448
*/
443449
private void applyGnomeWorkaround() {
444450
Toolkit xToolkit = Toolkit.getDefaultToolkit();
445-
java.lang.reflect.Field awtAppClassNameField;
451+
Field awtAppClassNameField;
446452
try {
447453
awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName");
448454
awtAppClassNameField.setAccessible(true);
@@ -573,7 +579,7 @@ private void layoutMain() {
573579

574580
getContentPane().add(toolBarPanel, BorderLayout.PAGE_START);
575581

576-
proofListView.setPreferredSize(new java.awt.Dimension(350, 100));
582+
proofListView.setPreferredSize(new Dimension(350, 100));
577583
GuiUtilities.paintEmptyViewComponent(proofListView, "Proofs");
578584

579585
// JSplitPane leftPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, proofListView,
@@ -815,27 +821,6 @@ public void setStatusLine(final String str, final int max) {
815821
ThreadUtilities.invokeOnEventQueue(() -> setStatusLineImmediately(str, max));
816822
}
817823

818-
/**
819-
* Freeze the main window by blocking all input events, except those for the toolbar (i.e.
820-
* the abort button within the toolbar)
821-
*/
822-
public void freezeExceptAutoModeButton() {
823-
if (!frozen) {
824-
frozen = true;
825-
826-
Component glassPane = new BlockingGlassPane(getContentPane());
827-
setGlassPane(glassPane);
828-
glassPane.setVisible(true);
829-
}
830-
}
831-
832-
public void unfreezeExceptAutoModeButton() {
833-
if (frozen) {
834-
getGlassPane().setVisible(false);
835-
frozen = false;
836-
}
837-
}
838-
839824
/**
840825
* Update the sequent view.
841826
*/
@@ -846,7 +831,7 @@ public void makePrettyView() {
846831
SwingUtilities.invokeLater(this::updateSequentView);
847832
}
848833

849-
private void addToProofList(de.uka.ilkd.key.proof.ProofAggregate plist) {
834+
private void addToProofList(ProofAggregate plist) {
850835
proofList.addProof(plist);
851836
// TODO/Check: the code below emulates phantom actions. Check if this can be solved
852837
// differently
@@ -1183,7 +1168,7 @@ public CurrentGoalView getGoalView() {
11831168
return currentGoalView;
11841169
}
11851170

1186-
public void addProblem(final de.uka.ilkd.key.proof.ProofAggregate plist) {
1171+
public void addProblem(final ProofAggregate plist) {
11871172
Runnable guiUpdater = () -> {
11881173
disableCurrentGoalView = true;
11891174
addToProofList(plist);
@@ -1489,146 +1474,14 @@ public CurrentGoalView getCurrentGoalView() {
14891474
return currentGoalView;
14901475
}
14911476

1492-
/**
1493-
* Glass pane that only delivers events for the status line (i.e. the abort button)
1494-
* <p>
1495-
* This has been partly taken from the GlassPaneDemo of the Java Tutorial
1496-
*/
1497-
private static class BlockingGlassPane extends JComponent {
1498-
/**
1499-
*
1500-
*/
1501-
private static final long serialVersionUID = 1218022319090988424L;
1502-
private final GlassPaneListener listener;
1503-
1504-
public BlockingGlassPane(Container contentPane) {
1505-
setCursor(new Cursor(Cursor.WAIT_CURSOR));
1506-
1507-
listener = new GlassPaneListener(this, contentPane);
1508-
addMouseListener(listener);
1509-
addMouseMotionListener(listener);
1510-
addKeyListener(new KeyListener() {
1511-
1512-
@Override
1513-
public void keyPressed(KeyEvent e) {
1514-
e.consume();
1515-
}
1516-
1517-
@Override
1518-
public void keyReleased(KeyEvent e) {
1519-
e.consume();
1520-
1521-
}
1522-
1523-
@Override
1524-
public void keyTyped(KeyEvent e) {
1525-
e.consume();
1526-
}
1527-
1528-
});
1529-
}
1477+
public void setInAutoMode(boolean inAutoMode) {
1478+
var oldValue = this.inAutoMode;
1479+
this.inAutoMode = inAutoMode;
1480+
firePropertyChange(PROPERTY_IN_AUTO_MODE, oldValue, inAutoMode);
15301481
}
15311482

1532-
/**
1533-
* Mouse listener for the glass pane that only delivers events for the status line (i.e. the
1534-
* abort button)
1535-
* <p>
1536-
* This has been partly taken from the GlassPaneDemo of the Java Tutorial
1537-
*/
1538-
private static class GlassPaneListener extends MouseInputAdapter {
1539-
Component currentComponent = null;
1540-
final Component glassPane;
1541-
final Container contentPane;
1542-
1543-
public GlassPaneListener(Component glassPane, Container contentPane) {
1544-
this.glassPane = glassPane;
1545-
this.contentPane = contentPane;
1546-
}
1547-
1548-
@Override
1549-
public void mouseMoved(MouseEvent e) {
1550-
redispatchMouseEvent(e);
1551-
}
1552-
1553-
/*
1554-
* We must forward at least the mouse drags that started with mouse presses over the check
1555-
* box. Otherwise, when the user presses the check box then drags off, the check box isn't
1556-
* disarmed -- it keeps its dark gray background or whatever its L&F uses to indicate that
1557-
* the button is currently being pressed.
1558-
*/
1559-
@Override
1560-
public void mouseDragged(MouseEvent e) {
1561-
redispatchMouseEvent(e);
1562-
}
1563-
1564-
@Override
1565-
public void mouseClicked(MouseEvent e) {
1566-
redispatchMouseEvent(e);
1567-
}
1568-
1569-
@Override
1570-
public void mouseEntered(MouseEvent e) {
1571-
redispatchMouseEvent(e);
1572-
}
1573-
1574-
@Override
1575-
public void mouseExited(MouseEvent e) {
1576-
redispatchMouseEvent(e);
1577-
}
1578-
1579-
@Override
1580-
public void mousePressed(MouseEvent e) {
1581-
redispatchMouseEvent(e);
1582-
}
1583-
1584-
@Override
1585-
public void mouseReleased(MouseEvent e) {
1586-
redispatchMouseEvent(e);
1587-
currentComponent = null;
1588-
}
1589-
1590-
private void redispatchMouseEvent(MouseEvent e) {
1591-
if (currentComponent != null) {
1592-
dispatchForCurrentComponent(e);
1593-
} else {
1594-
int eventID = e.getID();
1595-
Point glassPanePoint = e.getPoint();
1596-
1597-
Point containerPoint =
1598-
SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane);
1599-
Component component = SwingUtilities.getDeepestComponentAt(contentPane,
1600-
containerPoint.x, containerPoint.y);
1601-
1602-
if (eventID == MouseEvent.MOUSE_PRESSED && isLiveComponent(component)) {
1603-
currentComponent = component;
1604-
dispatchForCurrentComponent(e);
1605-
}
1606-
}
1607-
}
1608-
1609-
// FIXME This is not really good.
1610-
private boolean isLiveComponent(Component c) {
1611-
// this is not the most elegant way to identify the right
1612-
// components, but it scales well ;-)
1613-
while (c != null) {
1614-
if ((c instanceof JComponent)
1615-
&& AUTO_MODE_TEXT.equals(((JComponent) c).getToolTipText())) {
1616-
return true;
1617-
}
1618-
c = c.getParent();
1619-
}
1620-
return false;
1621-
}
1622-
1623-
private void dispatchForCurrentComponent(MouseEvent e) {
1624-
Point glassPanePoint = e.getPoint();
1625-
Point componentPoint =
1626-
SwingUtilities.convertPoint(glassPane, glassPanePoint, currentComponent);
1627-
currentComponent.dispatchEvent(new MouseEvent(currentComponent, e.getID(), e.getWhen(),
1628-
// do not use as it freezes the stop button: e.getModifiersEx(),
1629-
e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(),
1630-
e.isPopupTrigger()));
1631-
}
1483+
public boolean isInAutoMode() {
1484+
return inAutoMode;
16321485
}
16331486

16341487
/**
@@ -1776,7 +1629,7 @@ public synchronized void autoModeStarted(ProofEvent e) {
17761629
LOGGER.debug("Automode started");
17771630
disableCurrentGoalView = true;
17781631
getMediator().removeKeYSelectionListener(proofListener);
1779-
freezeExceptAutoModeButton();
1632+
setInAutoMode(true);
17801633
}
17811634

17821635
/**
@@ -1785,9 +1638,9 @@ public synchronized void autoModeStarted(ProofEvent e) {
17851638
@Override
17861639
public synchronized void autoModeStopped(ProofEvent e) {
17871640
LOGGER.debug("Automode stopped");
1788-
unfreezeExceptAutoModeButton();
17891641
disableCurrentGoalView = false;
17901642
getMediator().addKeYSelectionListenerChecked(proofListener);
1643+
setInAutoMode(false);
17911644
}
17921645

17931646
@Override

key.ui/src/main/java/de/uka/ilkd/key/gui/actions/AbandonTaskAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public AbandonTaskAction(MainWindow mainWindow, Proof proof) {
2424
setIcon(IconFactory.abandon(16));
2525
setTooltip("Drop current proof.");
2626

27-
getMediator().enableWhenProofLoaded(this);
27+
enabledOnAnActiveProof();
2828

2929
this.proof = proof;
3030
}

0 commit comments

Comments
 (0)