/
ProofManagementDialog.java
673 lines (602 loc) · 26.9 KB
/
ProofManagementDialog.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
package de.uka.ilkd.key.gui;
import de.uka.ilkd.key.core.KeYMediator;
import de.uka.ilkd.key.gui.fonticons.IconFactory;
import de.uka.ilkd.key.gui.utilities.GuiUtilities;
import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.java.abstraction.KeYJavaType;
import de.uka.ilkd.key.java.declaration.InterfaceDeclaration;
import de.uka.ilkd.key.java.declaration.TypeDeclaration;
import de.uka.ilkd.key.logic.Name;
import de.uka.ilkd.key.logic.ProgramElementName;
import de.uka.ilkd.key.logic.op.IObserverFunction;
import de.uka.ilkd.key.logic.op.IProgramMethod;
import de.uka.ilkd.key.proof.Proof;
import de.uka.ilkd.key.proof.ProofAggregate;
import de.uka.ilkd.key.proof.init.InitConfig;
import de.uka.ilkd.key.proof.init.ProblemInitializer;
import de.uka.ilkd.key.proof.init.ProofInputException;
import de.uka.ilkd.key.proof.init.ProofOblInput;
import de.uka.ilkd.key.proof.mgt.ProofEnvironment;
import de.uka.ilkd.key.proof.mgt.ProofStatus;
import de.uka.ilkd.key.proof.mgt.SpecificationRepository;
import de.uka.ilkd.key.speclang.Contract;
import de.uka.ilkd.key.ui.AbstractMediatorUserInterfaceControl;
import de.uka.ilkd.key.util.Pair;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.key_project.util.collection.DefaultImmutableSet;
import org.key_project.util.collection.ImmutableSet;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public final class ProofManagementDialog extends JDialog {
private static final long serialVersionUID = 3543411893273433386L;
/**
* The contracts are stored by name of the {@link KeYJavaType}, method name, and contract name
* to avoid keeping environments in the memory.
*/
@Nullable
private static ContractId previouslySelectedContracts;
private static final ImageIcon keyIcon = IconFactory.keyHole(20, 20);
private static final ImageIcon keyAlmostClosedIcon = IconFactory.keyHoleAlmostClosed(20, 20);
private static final Icon keyClosedIcon = IconFactory.keyHoleClosed(20);
private boolean startedProof;
private JTabbedPane tabbedPane;
private Map<Pair<KeYJavaType, IObserverFunction>, Icon> targetIcons;
private ClassTree classTree;
private JList<ProofWrapper> proofList;
private ContractSelectionPanel contractPanelByMethod;
private ContractSelectionPanel contractPanelByProof;
private JButton startButton;
private JButton cancelButton;
private KeYMediator mediator;
private final InitConfig initConfig;
private ProofEnvironment env;
// -------------------------------------------------------------------------
// constructors
// -------------------------------------------------------------------------
private ProofManagementDialog(MainWindow mainWindow, final InitConfig initConfig) {
super(mainWindow, "Proof Management", true);
this.mediator = mainWindow.getMediator();
this.initConfig = initConfig;
// create class tree
targetIcons = new LinkedHashMap<Pair<KeYJavaType, IObserverFunction>, Icon>();
classTree = new ClassTree(true, true, initConfig.getServices(), targetIcons);
classTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// Check that it is a double click on an item, not a folder or the background
if (e.getClickCount() != 2) {
return;
}
// row is -1 when the user does not click on an entry but on the background
int row = classTree.getRowForLocation(e.getX(), e.getY());
if (row == -1) {
return;
}
final ClassTree.Entry entry = classTree.getSelectedEntry();
if (entry.kjt != null && entry.target != null) {
final ImmutableSet<Contract> contracts = initConfig.getServices()
.getSpecificationRepository().getContracts(entry.kjt, entry.target);
final Contract c = contracts.iterator().next();
if (contracts.size() == 1 && c == contractPanelByMethod.getContract()) {
startButton.doClick();
}
}
}
});
classTree.addTreeSelectionListener(e -> updateContractPanel());
// create proof list
proofList = new JList<>();
proofList.setCellRenderer(new DefaultListCellRenderer() {
private static final long serialVersionUID = -7810888250050777877L;
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
Component result = super.getListCellRendererComponent(list, value, index,
isSelected, cellHasFocus);
if (result instanceof JLabel) {
ProofStatus ps = ((ProofWrapper) value).proof.mgt().getStatus();
JLabel label = (JLabel) result;
if (ps.getProofClosed()) {
label.setIcon(keyClosedIcon);
} else if (ps.getProofClosedButLemmasLeft()) {
label.setIcon(keyAlmostClosedIcon);
} else {
assert ps.getProofOpen();
label.setIcon(keyIcon);
}
}
return result;
}
});
proofList.addListSelectionListener(e -> updateContractPanel());
// create method list panel, scroll pane
JPanel listPanelByMethod = new JPanel();
listPanelByMethod.setLayout(new BoxLayout(listPanelByMethod, BoxLayout.X_AXIS));
JScrollPane classScrollPane = new JScrollPane(classTree);
classScrollPane.setBorder(new TitledBorder("Contract Targets"));
Dimension classScrollPaneDim = new Dimension(250, 400);
classScrollPane.setPreferredSize(classScrollPaneDim);
classScrollPane.setMinimumSize(classScrollPaneDim);
listPanelByMethod.add(classScrollPane);
// create proof list panel, scroll pane
JPanel listPanelByProof = new JPanel();
listPanelByProof.setLayout(new BoxLayout(listPanelByProof, BoxLayout.X_AXIS));
JScrollPane proofScrollPane = new JScrollPane(proofList);
proofScrollPane.setBorder(new TitledBorder("Proofs"));
proofScrollPane.setPreferredSize(classScrollPaneDim);
proofScrollPane.setMinimumSize(classScrollPaneDim);
listPanelByProof.add(proofScrollPane);
// create contract panel by method
contractPanelByMethod = new ContractSelectionPanel(initConfig.getServices(), false);
contractPanelByMethod.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
startButton.doClick();
}
}
});
contractPanelByMethod.addListSelectionListener(e -> updateStartButton());
listPanelByMethod.add(contractPanelByMethod);
// create contract panel by proof
contractPanelByProof = new ContractSelectionPanel(initConfig.getServices(), false);
contractPanelByProof.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
updateStartButton();
if (e.getClickCount() == 2) {
startButton.doClick();
}
}
});
contractPanelByProof.addListSelectionListener(e -> updateStartButton());
listPanelByProof.add(contractPanelByProof);
// create tabbed pane
tabbedPane = new JTabbedPane();
tabbedPane.addTab("By Target", listPanelByMethod);
tabbedPane.addTab("By Proof", listPanelByProof);
tabbedPane.addChangeListener(e -> {
updateStartButton();
if (proofList.getSelectedIndex() == -1 && proofList.getModel().getSize() > 0) {
proofList.setSelectedIndex(0);
}
});
getContentPane().add(tabbedPane);
// create button panel
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
Dimension buttonDim = new Dimension(140, 27);
buttonPanel
.setMaximumSize(new Dimension(Integer.MAX_VALUE, (int) buttonDim.getHeight() + 10));
getContentPane().add(buttonPanel);
// create "start proof" button
startButton = new JButton("Start Proof");
startButton.setPreferredSize(buttonDim);
startButton.setMinimumSize(buttonDim);
startButton.setEnabled(false);
startButton.addActionListener(e -> {
Contract contract = getSelectedContract();
if (contract != null) {
setVisible(false);
findOrStartProof(contract);
}
});
buttonPanel.add(startButton);
getRootPane().setDefaultButton(startButton);
// create "cancel" button
cancelButton = new JButton("Cancel");
cancelButton.setPreferredSize(buttonDim);
cancelButton.setMinimumSize(buttonDim);
cancelButton.addActionListener(e -> setVisible(false));
buttonPanel.add(cancelButton);
GuiUtilities.attachClickOnEscListener(cancelButton);
// show
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
pack();
}
@Override
public void dispose() {
super.dispose();
// ============================================
// cumbersome but necessary code providing a workaround for a memory leak
// in Java, see: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6497929
tabbedPane = null;
proofList = null;
targetIcons = null;
classTree = null;
contractPanelByMethod = null;
contractPanelByProof = null;
startButton = null;
cancelButton = null;
// ============================================
}
/**
* Selects the first contract of the first {@link TypeDeclaration} (sorted by name).
*/
private void selectKJTandTarget() {
Services servicesLocal = initConfig.getServices();
List<KeYJavaType> allJavaTypes = servicesLocal.getJavaInfo().getAllKeYJavaTypes().stream()
// sort by name
.sorted(Comparator.comparing(KeYJavaType::getFullName))
// filter out library classes
.filter(kjtTmp -> !(kjtTmp.getJavaType() instanceof TypeDeclaration
&& ((TypeDeclaration) kjtTmp.getJavaType()).isLibraryClass()))
.collect(Collectors.toList());
// compare: IProgramMethods by program name, otherwise prefer NOT IProgramMethod
final Comparator<IObserverFunction> compareFunction = (o1, o2) -> {
if (o1 instanceof IProgramMethod && !(o2 instanceof IProgramMethod)) {
return -1;
} else if (!(o1 instanceof IProgramMethod) && o2 instanceof IProgramMethod) {
return 1;
} else {
String s1 = o1.name() instanceof ProgramElementName
? ((ProgramElementName) o1.name()).getProgramName()
: o1.name().toString();
String s2 = o2.name() instanceof ProgramElementName
? ((ProgramElementName) o2.name()).getProgramName()
: o2.name().toString();
return s1.compareTo(s2);
}
};
for (KeYJavaType javaType : allJavaTypes) {
Stream<IObserverFunction> targets = servicesLocal.getSpecificationRepository()
.getContractTargets(javaType).stream().sorted(compareFunction)
// has contract
.filter(targetTmp -> !servicesLocal.getSpecificationRepository()
.getContracts(javaType, targetTmp).isEmpty());
Optional<IObserverFunction> t = targets.findFirst();
if (t.isPresent()) {
select(javaType, t.get());
break;
}
}
}
/**
* Shows the dialog and selects the passed proof.
*/
public static void showInstance(InitConfig initConfig, Proof selectedProof) {
showInstance(initConfig, null, null, selectedProof);
}
/**
* <p>
* Shows the dialog and selects the passed {@link KeYJavaType} and its
* {@link IObserverFunction}.
* </p>
* <p>
* <b>This method is required, because the Eclipse integration of KeY needs this functionality
* to start a new proof for a selected method.</b>
* </p>
*
* @param initConfig the initial prover configuration
* @param selectedKJT the selected {@link KeYJavaType}
* @param selectedTarget the selected target
*/
public static void showInstance(InitConfig initConfig, KeYJavaType selectedKJT,
IObserverFunction selectedTarget) {
showInstance(initConfig, selectedKJT, selectedTarget, null);
}
/**
* Shows the dialog.
*/
public static boolean showInstance(InitConfig initConfig) {
return showInstance(initConfig, null, null, null);
}
private static boolean showInstance(InitConfig initConfig, KeYJavaType selectedKJT,
IObserverFunction selectedTarget, Proof selectedProof) {
MainWindow mainWindow = MainWindow.getInstance();
ProofManagementDialog dialog = new ProofManagementDialog(mainWindow, initConfig);
// determine own defaults if not given
dialog.selectKJTandTarget();
// if (previouslySelectedContracts.containsKey(selectedProof)) {
if (previouslySelectedContracts != null) {
dialog.select(previouslySelectedContracts);
}
dialog.updateGlobalStatus();
// The selected elements have to be select before the dialog is made visible!
if (selectedKJT != null && selectedTarget != null) {
dialog.select(selectedKJT, selectedTarget);
}
if (selectedProof != null) {
dialog.select(selectedProof);
dialog.env = selectedProof.getEnv();
}
dialog.setLocationRelativeTo(mainWindow);
dialog.setVisible(true);
if (dialog.getSelectedContract() != null) {
Contract c = dialog.getSelectedContract();
String kjtName = c.getKJT().getFullName();
String contractName = c.getName();
String methodName = c.getTarget().name().toString();
previouslySelectedContracts = new ContractId(kjtName, methodName, contractName);
}
return dialog.startedProof;
}
/**
* Selects the contract by the given {@link ContractId}
*/
private void select(@Nonnull ContractId cid) {
Services servicesLocal = initConfig.getServices();
String keyJavaTypeName = cid.keyJavaTypeName;
Optional<KeYJavaType> allJavaTypes =
servicesLocal.getJavaInfo().getAllKeYJavaTypes().stream()
// filter out library classes
.filter(kjtTmp -> !(kjtTmp.getJavaType() instanceof TypeDeclaration
&& ((TypeDeclaration) kjtTmp.getJavaType()).isLibraryClass()))
.filter(it -> it.getFullName().equals(keyJavaTypeName)).findAny();
if (!allJavaTypes.isPresent()) {
return;
}
KeYJavaType javaType = allJavaTypes.get();
Name methodName = new Name(cid.methodName);
Optional<IObserverFunction> target =
servicesLocal.getSpecificationRepository().getContractTargets(javaType).stream()
.filter(targetTmp -> !servicesLocal.getSpecificationRepository()
.getContracts(javaType, targetTmp).isEmpty())
.filter(it -> it.name().equals(methodName)).findAny();
if (!target.isPresent()) {
return;
}
final IObserverFunction method = target.get();
select(javaType, method);
if (!isInstanceMethodOfAbstractClass(javaType, method)) {
Optional<Contract> contract =
initConfig.getServices().getSpecificationRepository().getContracts(javaType, method)
.stream().filter(it -> it.getName().equals(cid.contractName)).findAny();
contract.ifPresent(value -> contractPanelByMethod.selectContract(value));
}
}
private ContractSelectionPanel getActiveContractPanel() {
return tabbedPane.getSelectedIndex() == 0 ? contractPanelByMethod : contractPanelByProof;
}
private void select(KeYJavaType kjt, IObserverFunction target) {
tabbedPane.setSelectedIndex(0);
if (classTree != null)
classTree.select(kjt, target);
}
private void select(Proof p) {
for (int i = 0, n = proofList.getModel().getSize(); i < n; i++) {
if (proofList.getModel().getElementAt(i).proof.equals(p)) {
tabbedPane.setSelectedIndex(1);
proofList.setSelectedIndex(i);
break;
}
}
}
private Contract getSelectedContract() {
return getActiveContractPanel().getContract();
}
/**
* Finds a proof for the given contract. Preferring a already closed proof, laking that a proof
* that just misses lemmas.
*
* @param contract the contract for which to find a proof
* @return a proof for the contract, preferring closed proofs then closed proofs needing some
* lemmas and then just any proof or {@code null} if there is no proof for the contract
*/
@Nullable
private Proof findPreferablyClosedProof(@Nonnull Contract contract) {
// will the contracts here always be atomic?
// it seems that way, but not completely sure
ImmutableSet<Proof> proofs =
initConfig.getServices().getSpecificationRepository().getProofs(contract);
// no proofs?
if (proofs.isEmpty()) {
return null;
}
// try to find closed proof
Proof fallback = null;
for (Proof proof : proofs) {
final ProofStatus status = proof.mgt().getStatus();
if (status.getProofClosed()) {
return proof;
} else if (fallback == null || status.getProofClosedButLemmasLeft()) {
fallback = proof;
}
}
return fallback;
}
private void findOrStartProof(@Nonnull Contract contract) {
Proof proof = findPreferablyClosedProof(contract);
if (proof == null) {
AbstractMediatorUserInterfaceControl ui = mediator.getUI();
ProblemInitializer pi = new ProblemInitializer(ui, initConfig.getServices(), ui);
// enables to access the FileRepo created in AbstractProblemLoader
pi.setFileRepo(initConfig.getFileRepo());
try {
final ProofOblInput po =
contract.createProofObl(initConfig.copyWithServices(initConfig.getServices()));
final ProofAggregate pl = pi.startProver(initConfig, po);
if (env == null) {
env = ui.createProofEnvironmentAndRegisterProof(po, pl, initConfig);
} else {
env.registerProof(po, pl);
}
} catch (ProofInputException exc) {
IssueDialog.showExceptionDialog(MainWindow.getInstance(), exc);
}
} else {
mediator.setProof(proof);
}
startedProof = true;
}
private void updateStartButton() {
final Contract contract = getSelectedContract();
if (contract == null) {
startButton.setText("No Contract");
startButton.setIcon(null);
startButton.setEnabled(false);
} else {
final Proof proof = findPreferablyClosedProof(contract);
if (proof == null) {
startButton.setText("Start Proof");
startButton.setIcon(null);
} else {
final ProofStatus status = proof.mgt().getStatus();
startButton.setText("Go to Proof");
if (status.getProofOpen()) {
startButton.setIcon(keyIcon);
} else if (status.getProofClosedButLemmasLeft()) {
startButton.setIcon(keyAlmostClosedIcon);
} else {
assert status.getProofClosed();
startButton.setIcon(keyClosedIcon);
}
}
startButton.setEnabled(true);
}
validate();
}
private boolean isInstanceMethodOfAbstractClass(KeYJavaType p_class, IObserverFunction obs) {
return p_class.getJavaType() instanceof InterfaceDeclaration
|| (p_class.getSort().isAbstract() && !obs.isStatic());
}
private void updateContractPanel() {
ContractSelectionPanel pan = getActiveContractPanel();
if (pan == contractPanelByMethod) {
final ClassTree.Entry entry = classTree.getSelectedEntry();
if (entry != null && entry.target != null
&& !isInstanceMethodOfAbstractClass(entry.kjt, entry.target)) {
final ImmutableSet<Contract> contracts = initConfig.getServices()
.getSpecificationRepository().getContracts(entry.kjt, entry.target);
pan.setContracts(contracts, "Contracts");
pan.setGrayOutAuxiliaryContracts(Objects.equals(
targetIcons.get(new Pair<>(entry.kjt, entry.target)), keyClosedIcon));
} else {
pan.setContracts(DefaultImmutableSet.<Contract>nil(), "Contracts");
}
} else if (pan == contractPanelByProof) {
if (proofList.getSelectedValue() != null) {
final Proof p = ((ProofWrapper) proofList.getSelectedValue()).proof;
final ImmutableSet<Contract> usedContracts = p.mgt().getUsedContracts();
pan.setContracts(usedContracts, "Contracts used in proof \"" + p.name() + "\"");
} else {
pan.setContracts(DefaultImmutableSet.<Contract>nil(), "Contracts");
}
}
updateStartButton();
}
private void updateGlobalStatus() {
// target icons
Services services = initConfig.getServices();
SpecificationRepository specRepos = services.getSpecificationRepository();
Set<KeYJavaType> kjts = services.getJavaInfo().getAllKeYJavaTypes();
for (KeYJavaType kjt : kjts) {
// skip library classes, the user isn't shown contracts for them
if (kjt.getJavaType() instanceof TypeDeclaration
&& ((TypeDeclaration) kjt.getJavaType()).isLibraryClass()) {
continue;
}
ImmutableSet<IObserverFunction> targets = specRepos.getContractTargets(kjt);
for (IObserverFunction target : targets) {
if (!isInstanceMethodOfAbstractClass(kjt, target)) {
ImmutableSet<Contract> contracts = specRepos.getContracts(kjt, target);
boolean startedProving = false;
boolean allClosed = true;
boolean lemmasLeft = false;
for (Contract contract : contracts) {
// Skip auxiliary contracts (like block/loop contracts).
if (contract.isAuxiliary()) {
continue;
}
final Proof proof = findPreferablyClosedProof(contract);
if (proof == null) {
allClosed = false;
} else {
startedProving = true;
ProofStatus status = proof.mgt().getStatus();
if (status.getProofOpen()) {
allClosed = false;
} else if (status.getProofClosedButLemmasLeft()) {
lemmasLeft = true;
}
}
}
targetIcons.put(new Pair<>(kjt, target),
startedProving
? (allClosed ? (lemmasLeft ? keyAlmostClosedIcon : keyClosedIcon)
: keyIcon)
: null);
}
}
}
classTree.updateUI();
// proof list
DefaultListModel<ProofWrapper> model = new DefaultListModel<>();
for (Proof p : specRepos.getAllProofs()) {
model.add(0, new ProofWrapper(p));
}
boolean changed;
if (model.size() != proofList.getModel().getSize()) {
changed = true;
} else {
changed = false;
for (int i = 0, n = model.size(); i < n; i++) {
if (!model.get(i).equals(proofList.getModel().getElementAt(i))) {
changed = true;
break;
}
}
}
if (changed) {
proofList.setModel(model);
proofList.updateUI();
}
// others
updateContractPanel();
updateStartButton();
}
// -------------------------------------------------------------------------
// inner classes
// -------------------------------------------------------------------------
private static final class ProofWrapper {
public final Proof proof;
public ProofWrapper(Proof proof) {
this.proof = proof;
}
@Override
public String toString() {
return proof.name().toString();
}
@Override
public boolean equals(Object o) {
return o instanceof ProofWrapper && proof.equals(((ProofWrapper) o).proof);
}
@Override
public int hashCode() {
return proof.hashCode();
}
}
/**
* Stores the identification of a {@link Contract}, i.e. type, method, contract name.
*/
private static final class ContractId {
/** The key java type name. */
@Nullable
public final String keyJavaTypeName;
/** The method name. */
@Nullable
public final String methodName;
/** The contract name. */
@Nullable
public final String contractName;
private ContractId(@Nullable String keyJavaTypeName, @Nullable String methodName,
@Nullable String contractName) {
this.keyJavaTypeName = keyJavaTypeName;
this.methodName = methodName;
this.contractName = contractName;
}
}
}