From a5f595a1a87506b4c131738e48a2e38a2c65ef11 Mon Sep 17 00:00:00 2001
From: Mattias Ulbrich
+ * The first action in the list is the default and will be triggered by the {@code Ctrl+Space}
+ * keyboard shortcut. Actions are displayed in the dropdown menu in the order they are added.
+ *
+ * To add new automation modes, simply add them to this list. No configuration file or service
+ * loader is needed. For macro-based automations, use {@link MacroAutomationAction}. For custom
+ * behaviors, extend {@link MainWindowAction}.
+ *
+ * Example:
+ *
+ *
+ * {@code
+ * actions.add(new MacroAutomationAction(this,
+ * new YourCustomMacro(),
+ * "Your Automation Name",
+ * IconFactory.yourIcon(TOOLBAR_ICON_SIZE)));
+ * }
+ *
+ *
+ * This is a reusable wrapper for macro-based automation actions. Instead of creating separate + * action classes for each macro, this generic wrapper can be used to expose any {@link ProofMacro} + * as an automation option in the dropdown menu. + *
+ *+ * Example usage: + * + *
+ * {@code
+ * actions.add(new MacroAutomationAction(mainWindow,
+ * new FullAutoPilotProofMacro(),
+ * "Full Auto Pilot",
+ * IconFactory.automationFullPilotLogo(16)));
+ * }
+ *
+ *
+ *
+ * @see ProofMacro
+ * @see MainWindow#createAutomationActions()
+ */
+public class MacroAutomationAction extends MainWindowAction {
+
+ private static final long serialVersionUID = 1L;
+
+ /** The proof macro to execute when this action is triggered. */
+ private final ProofMacro macro;
+
+ /**
+ * Creates a new macro automation action.
+ *
+ * @param mainWindow the main window this action belongs to
+ * @param macro the proof macro to execute
+ * @param name the display name shown in the dropdown menu
+ * @param icon the icon displayed on the action button
+ */
+ public MacroAutomationAction(MainWindow mainWindow, ProofMacro macro, String name, Icon icon) {
+ super(mainWindow);
+ this.macro = macro;
+ putValue(NAME, name);
+ putValue(SHORT_DESCRIPTION, macro.getDescription());
+ putValue(SMALL_ICON, icon);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (!getMediator().isInAutoMode()) {
+ Proof proof = getMediator().getSelectedProof();
+ if (proof != null && !proof.closed()) {
+ getMediator().getUI().getProofControl()
+ .runMacro(getMediator().getSelectedNode(), macro, null);
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return (String) getValue(NAME);
+ }
+}
diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/fonticons/IconFactory.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/fonticons/IconFactory.java
index 9c149e44ccf..90f9c797c0e 100644
--- a/key.ui/src/main/java/de/uka/ilkd/key/gui/fonticons/IconFactory.java
+++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/fonticons/IconFactory.java
@@ -4,6 +4,7 @@
package de.uka.ilkd.key.gui.fonticons;
import java.awt.*;
+import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -366,6 +367,102 @@ public static Icon autoModeStopLogo(int size) {
return AUTO_MODE_STOP.load(size);
}
+ /**
+ * Creates an icon with a play button and a letter overlay.
+ * + * Used for automation actions to distinguish different modes visually. The base icon is the + * standard green play button ({@link #autoModeStartLogo(int)}), with a bold italic letter + * overlaid in the bottom-right corner. + *
+ * + * @param size the size of the icon in pixels + * @param letter the letter to overlay (e.g., "R" for Run, "F" for Full, "P" for Prepare), or + * {@code null} for just the play button + * @return the composite icon with letter overlay + * @see #automationRunLogo(int) + * @see #automationFullPilotLogo(int) + * @see #automationPrepareLogo(int) + */ + public static Icon automationWithOverlay(int size, String letter) { + Icon baseIcon = autoModeStartLogo(size); + + BufferedImage image = new BufferedImage(size + 5, size, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = image.createGraphics(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); + + // Draw base icon + baseIcon.paintIcon(null, g2d, 0, 0); + + if (letter == null) { + return new ImageIcon(image); + } + + // Draw letter overlay + g2d.setColor(Color.BLACK); + Font font = new Font(Font.SANS_SERIF, Font.BOLD | Font.ITALIC, (int) (size * 0.9f)); + g2d.setFont(font); + + FontMetrics fm = g2d.getFontMetrics(); + int textWidth = fm.stringWidth(letter); + int textHeight = fm.getAscent() - fm.getDescent(); + + // Position letter in bottom-right corner + int x = size - textWidth; + + g2d.drawString(letter, x + 5, size); + g2d.dispose(); + + return new ImageIcon(image); + } + + /** + * Creates an icon for the "Run Automation" action. + *+ * This is the legacy default automation mode that starts/stops automated proof search. + * The icon shows a green play button with an "R" overlay. + *
+ * + * @param size the size of the icon in pixels + * @return the automation run icon + */ + public static Icon automationRunLogo(int size) { + return automationWithOverlay(size, "R"); + } + + /** + * Creates an icon for the "Full Auto Pilot" action. + *+ * This automation mode performs: finish symbolic execution, separate proof obligations, expand + * invariant definitions, and try to close all proof obligations. + * The icon shows a green play button with an "F" overlay. + *
+ * + * @param size the size of the icon in pixels + * @return the full auto pilot icon + * @see de.uka.ilkd.key.macros.FullAutoPilotProofMacro + */ + public static Icon automationFullPilotLogo(int size) { + return automationWithOverlay(size, "F"); + } + + /** + * Creates an icon for the "Prepare-only Autopilot" action. + *+ * This automation mode performs: finish symbolic execution, separate proof obligations, and + * expand invariant definitions (without trying to close goals). + * The icon shows a green play button with a "P" overlay. + *
+ * + * @param size the size of the icon in pixels + * @return the prepare-only autopilot icon + * @see de.uka.ilkd.key.macros.AutoPilotPrepareProofMacro + */ + public static Icon automationPrepareLogo(int size) { + return automationWithOverlay(size, "P"); + } + public static Icon selectDecProcArrow(int size) { // return scaleIcon(decisionProcedureConfigArrow, size / 2, size); return CONFIGURE_MENU.load(size); From 1b09b1d0fe5333eb8f30b3a378c916260d16d62e Mon Sep 17 00:00:00 2001 From: Mattias Ulbrich- * Example usage: - * - *
- * {@code
- * actions.add(new MacroAutomationAction(mainWindow,
- * new FullAutoPilotProofMacro(),
- * "Full Auto Pilot",
- * IconFactory.automationFullPilotLogo(16)));
- * }
- *
- *
*
* @see ProofMacro
- * @see MainWindow#createAutomationActions()
*/
-public class MacroAutomationAction extends MainWindowAction {
+public class MacroAutomationAction extends AutoModeAction {
private static final long serialVersionUID = 1L;
@@ -45,25 +36,22 @@ public class MacroAutomationAction extends MainWindowAction {
*
* @param mainWindow the main window this action belongs to
* @param macro the proof macro to execute
- * @param name the display name shown in the dropdown menu
* @param icon the icon displayed on the action button
*/
- public MacroAutomationAction(MainWindow mainWindow, ProofMacro macro, String name, Icon icon) {
- super(mainWindow);
+ public MacroAutomationAction(MainWindow mainWindow, ProofMacro macro, Icon icon) {
+ super(mainWindow, icon);
this.macro = macro;
- putValue(NAME, name);
- putValue(SHORT_DESCRIPTION, macro.getDescription());
- putValue(SMALL_ICON, icon);
+ setName(macro.getName());
+ setTooltip(macro.getDescription());
}
@Override
public void actionPerformed(ActionEvent e) {
- if (!getMediator().isInAutoMode()) {
- Proof proof = getMediator().getSelectedProof();
- if (proof != null && !proof.closed()) {
- getMediator().getUI().getProofControl()
- .runMacro(getMediator().getSelectedNode(), macro, null);
- }
+ KeYMediator mediator = getMediator();
+ if (mediator.isInAutoMode()) {
+ getMediator().getUI().getProofControl().stopAutoMode();
+ } else {
+ mediator.getUI().getProofControl().runMacro(mediator.getSelectedNode(), macro, null);
}
}
From 1c298498b6e3d490c7e430c13ef8c3f9f874c713 Mon Sep 17 00:00:00 2001
From: Mattias Ulbrich - * This is the legacy default automation mode that starts/stops automated proof search. - * The icon shows a green play button with an "R" overlay. - *
- * - * @param size the size of the icon in pixels - * @return the automation run icon - */ - public static Icon automationRunLogo(int size) { - return automationWithOverlay(size, "R"); - } - /** * Creates an icon for the "Full Auto Pilot" action. *
From a4943615e680a66f1f83fa32e3ae45c30b5b6774 Mon Sep 17 00:00:00 2001
From: Mattias Ulbrich
";
+ return "This configures the automation such that it preserves
" +
+ "the program structure and makes it easier to comprehend the
" +
+ "resulting proof. It produces proof goals without program
" +
+ "references, but does not try to close these goals.
" +
+ "The steps are:
";
}
@Override
diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/DefaultAutoMacro.java b/key.core/src/main/java/de/uka/ilkd/key/macros/DefaultAutoMacro.java
index a11686ed825..e8efea54c3e 100644
--- a/key.core/src/main/java/de/uka/ilkd/key/macros/DefaultAutoMacro.java
+++ b/key.core/src/main/java/de/uka/ilkd/key/macros/DefaultAutoMacro.java
@@ -31,7 +31,7 @@ public class DefaultAutoMacro extends AbstractProofMacro {
@Override
public String getName() {
- return "Apply Strategy";
+ return "Full Automation";
}
@Override
@@ -46,7 +46,8 @@ public String getScriptCommandName() {
@Override
public String getDescription() {
- return "Runs the active proof strategy on the selected subtree (same as Auto button)";
+ return "Runs the full proof strategy on the selected subtree.
" +
+ "The strategy can be configured in 'Proof Search Strategy' tab.";
}
@Override
diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/FullAutoPilotProofMacro.java b/key.core/src/main/java/de/uka/ilkd/key/macros/FullAutoPilotProofMacro.java
index c0b3c098957..1291127fdc8 100644
--- a/key.core/src/main/java/de/uka/ilkd/key/macros/FullAutoPilotProofMacro.java
+++ b/key.core/src/main/java/de/uka/ilkd/key/macros/FullAutoPilotProofMacro.java
@@ -29,7 +29,7 @@ public class FullAutoPilotProofMacro extends SequentialProofMacro {
@Override
public String getName() {
- return "Full Auto Pilot";
+ return "Structured Automation";
}
@Override
@@ -44,8 +44,14 @@ public String getScriptCommandName() {
@Override
public String getDescription() {
- return "
";
+ return "This configures the automation such that it preserves
" +
+ "the program structure and makes it easier to comprehend the
" +
+ "resulting proof.
" +
+ "The steps are:" +
+ "
";
}
@Override
diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java
index b6557736556..cd1add14165 100644
--- a/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java
+++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/MainWindow.java
@@ -55,6 +55,7 @@
import de.uka.ilkd.key.gui.smt.DropdownSelectionButton;
import de.uka.ilkd.key.gui.sourceview.SourceViewFrame;
import de.uka.ilkd.key.gui.utilities.LruCached;
+import de.uka.ilkd.key.macros.DefaultAutoMacro;
import de.uka.ilkd.key.proof.*;
import de.uka.ilkd.key.proof.init.Profile;
import de.uka.ilkd.key.proof.io.ProblemLoader;
@@ -801,7 +802,10 @@ private DropdownSelectionButton createSMTComponent() {
*/
// @formatter:on
private List