Merge lp:~tapaal-contributor/tapaal/fix-product-display-1971421 into lp:~tapaal-contributor/tapaal/cpn-gui-dev

Proposed by Lena Ernstsen
Status: Merged
Approved by: Jiri Srba
Approved revision: 1641
Merged at revision: 1642
Proposed branch: lp:~tapaal-contributor/tapaal/fix-product-display-1971421
Merge into: lp:~tapaal-contributor/tapaal/cpn-gui-dev
Diff against target: 130 lines (+29/-16)
4 files modified
src/main/java/dk/aau/cs/approximation/ApproximationWorker.java (+0/-2)
src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanEqExpression.java (+1/-1)
src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanExpression.java (+1/-1)
src/main/java/net/tapaal/gui/petrinet/editor/ColoredTransitionGuardPanel.java (+27/-12)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/fix-product-display-1971421
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+422811@code.launchpad.net

This proposal supersedes a proposal from 2022-05-18.

Commit message

Product colours are updated correctly when using product colours in guard expressions.

Description of the change

Also, fixed null exception when trying to switch between color types while currently selecting a > or >= expression.

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) wrote :

fixes the issue

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/java/dk/aau/cs/approximation/ApproximationWorker.java'
2--- src/main/java/dk/aau/cs/approximation/ApproximationWorker.java 2022-02-20 15:02:33 +0000
3+++ src/main/java/dk/aau/cs/approximation/ApproximationWorker.java 2022-05-18 07:39:20 +0000
4@@ -106,8 +106,6 @@
5 false,
6 approxResult.getUnfoldedModel());
7 toReturn.setNameMapping(nameMapping);
8-
9-
10
11 OverApproximation overaprx = new OverApproximation();
12
13
14=== modified file 'src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanEqExpression.java'
15--- src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanEqExpression.java 2021-06-24 10:15:01 +0000
16+++ src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanEqExpression.java 2022-05-18 07:39:20 +0000
17@@ -77,7 +77,7 @@
18
19 @Override
20 public GuardExpression copy() {
21- return null;
22+ return new GreaterThanEqExpression(left, right);
23 }
24
25 @Override
26
27=== modified file 'src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanExpression.java'
28--- src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanExpression.java 2021-06-24 10:15:01 +0000
29+++ src/main/java/dk/aau/cs/model/CPN/Expressions/GreaterThanExpression.java 2022-05-18 07:39:20 +0000
30@@ -84,7 +84,7 @@
31
32 @Override
33 public GuardExpression copy() {
34- return null;
35+ return new GreaterThanExpression(left, right);
36 }
37
38 @Override
39
40=== modified file 'src/main/java/net/tapaal/gui/petrinet/editor/ColoredTransitionGuardPanel.java'
41--- src/main/java/net/tapaal/gui/petrinet/editor/ColoredTransitionGuardPanel.java 2022-03-23 16:24:25 +0000
42+++ src/main/java/net/tapaal/gui/petrinet/editor/ColoredTransitionGuardPanel.java 2022-05-18 07:39:20 +0000
43@@ -1,6 +1,5 @@
44 package net.tapaal.gui.petrinet.editor;
45
46-import dk.aau.cs.util.Tuple;
47 import net.tapaal.gui.petrinet.Context;
48 import net.tapaal.gui.petrinet.undo.Colored.SetTransitionExpressionCommand;
49 import net.tapaal.gui.petrinet.undo.Command;
50@@ -374,7 +373,7 @@
51 private Pair<ColorExpression, ColorExpression> getLeftRightExpression(Expression currentSelection) {
52 if (currentSelection instanceof PlaceHolderGuardExpression) {
53 if (colorTypeCombobox.getItemAt(colorTypeCombobox.getSelectedIndex()) instanceof ProductType) {
54- int size = colorCombobox.getColorType().size();
55+ int size = ((ProductType) colorTypeCombobox.getItemAt(colorTypeCombobox.getSelectedIndex())).size();
56 Vector<ColorExpression> tempVec1 = createPlaceholderVectors(size);
57 Vector<ColorExpression> tempVec2 = createPlaceholderVectors(size);
58 return new Pair<>(new TupleExpression(tempVec1), new TupleExpression(tempVec2));
59@@ -666,10 +665,14 @@
60 greaterThanEqButton.setEnabled(true);
61 lessThanEqButton.setEnabled(true);
62 lessThanButton.setEnabled(true);
63- colorTypeCombobox.setEnabled(true);
64 succButton.setEnabled(false);
65 predButton.setEnabled(false);
66 colorCombobox.setEnabled(false);
67+ if (currentSelection.getObject() instanceof PlaceHolderGuardExpression) {
68+ colorTypeCombobox.setEnabled(false);
69+ } else {
70+ colorTypeCombobox.setEnabled(true);
71+ }
72 }
73 if (colorTypeCombobox.getItemAt(colorTypeCombobox.getSelectedIndex()) instanceof ProductType) {
74 greaterThanButton.setEnabled(false);
75@@ -720,7 +723,12 @@
76 if (currentSelection.getObject() instanceof ColorExpression) {
77 ColorType ct = colorTypeCombobox.getItemAt(colorTypeCombobox.getSelectedIndex());
78 if (ct instanceof ProductType && !(currentSelection.getObject() instanceof TupleExpression)) {
79- ColorType newColorType = ((ProductType) ct).getConstituents().get(((ColorExpression) currentSelection.getObject()).getIndex());
80+ int currentIndex = ((ColorExpression) currentSelection.getObject()).getIndex();
81+ ColorType newColorType;
82+ if (currentIndex == -1)
83+ newColorType = ((ProductType) ct).getConstituents().firstElement();
84+ else
85+ newColorType = ((ProductType) ct).getConstituents().get(((ColorExpression) currentSelection.getObject()).getIndex());
86 colorCombobox.updateColorType(newColorType, context, true);
87 }
88 ColorExpression exprToCheck = ((ColorExpression) currentSelection.getObject()).getBottomColorExpression();
89@@ -876,11 +884,22 @@
90
91 private void updateExpression() {
92 ColorType ct = colorTypeCombobox.getItemAt(colorTypeCombobox.getSelectedIndex());
93- ExprStringPosition[] children = newProperty.getChildren();
94- GuardExpression oldProperty = newProperty.copy();
95+ ExprStringPosition[] children = currentSelection.getObject().getChildren();
96+ Expression oldProperty = currentSelection.getObject().copy();
97
98 if (ct == getColorType(newProperty)) return;
99
100+ updateChildren(ct, currentSelection.getObject(), children);
101+
102+ if (doColorTypeUndo) {
103+ replaceAndAddToUndo(oldProperty, newProperty);
104+ } else {
105+ newProperty = newProperty.replace(oldProperty, newProperty);
106+ updateSelection(newProperty);
107+ }
108+ }
109+
110+ private void updateChildren(ColorType ct, Expression parent, ExprStringPosition[] children) {
111 for (ExprStringPosition child : children) {
112 if (child.getObject() instanceof ColorExpression) {
113 Expression expr;
114@@ -890,14 +909,10 @@
115 expr = new PlaceHolderColorExpression();
116 }
117 newProperty = newProperty.replace(child.getObject(), expr);
118+ } else if (parent instanceof NotExpression && child.getObject() instanceof LeftRightGuardExpression) {
119+ updateChildren(ct, child.getObject(), child.getObject().getChildren());
120 }
121 }
122- if (doColorTypeUndo) {
123- replaceAndAddToUndo(oldProperty, newProperty);
124- } else {
125- newProperty = newProperty.replace(oldProperty, newProperty);
126- updateSelection(newProperty);
127- }
128 }
129
130 // /////////////////////////////////////////////////////////////////////

Subscribers

People subscribed via source and target branches

to all changes: