Merge lp:~tapaal-contributor/tapaal/cut-names-1923011 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Merged
Approved by: Jiri Srba
Approved revision: 1129
Merged at revision: 1128
Proposed branch: lp:~tapaal-contributor/tapaal/cut-names-1923011
Merge into: lp:tapaal
Diff against target: 321 lines (+44/-36)
11 files modified
src/dk/aau/cs/gui/SharedPlaceNamePanel.java (+2/-2)
src/dk/aau/cs/gui/SharedTransitionNamePanel.java (+2/-2)
src/dk/aau/cs/gui/TemplateExplorer.java (+6/-6)
src/net/tapaal/swinghelpers/CustomJSpinner.java (+1/-3)
src/net/tapaal/swinghelpers/SwingHelper.java (+8/-0)
src/pipe/gui/GuiFrame.java (+3/-4)
src/pipe/gui/widgets/ConstantsDialogPanel.java (+3/-3)
src/pipe/gui/widgets/GuardDialogue.java (+11/-10)
src/pipe/gui/widgets/NewTAPNPanel.java (+2/-2)
src/pipe/gui/widgets/PlaceEditorPanel.java (+3/-2)
src/pipe/gui/widgets/TAPNTransitionEditor.java (+3/-2)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/cut-names-1923011
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Kenneth Yrke Jørgensen code Approve
Review via email: mp+400775@code.launchpad.net

Commit message

Let java control height of text fields so that it works for all distributions.

To post a comment you must log in.
Revision history for this message
Kenneth Yrke Jørgensen (yrke) wrote :

Before merging, could you make a search for something like "new Dimension(" to see if you can find other places where this could be an issue.

review: Approve (code)
Revision history for this message
Peter Haahr Taankvist (ptaank) wrote :

It happens several places, but now it only happens for buttons and panels. Should this also be changed?

Revision history for this message
Kenneth Yrke Jørgensen (yrke) wrote :

For now just focus on button and panels :)

Revision history for this message
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dk/aau/cs/gui/SharedPlaceNamePanel.java'
2--- src/dk/aau/cs/gui/SharedPlaceNamePanel.java 2020-07-13 13:58:47 +0000
3+++ src/dk/aau/cs/gui/SharedPlaceNamePanel.java 2021-04-08 08:40:30 +0000
4@@ -15,6 +15,7 @@
5 import javax.swing.JRootPane;
6 import javax.swing.JTextField;
7
8+import net.tapaal.swinghelpers.SwingHelper;
9 import pipe.dataLayer.TAPNQuery;
10 import dk.aau.cs.TCTL.visitors.RenameSharedPlaceVisitor;
11 import dk.aau.cs.gui.SharedPlacesAndTransitionsPanel.SharedPlacesListModel;
12@@ -80,8 +81,7 @@
13
14 String initialText = (placeToEdit == null) ? "" : placeToEdit.name();
15 nameField = new JTextField(initialText);
16- nameField.setMinimumSize(new Dimension(330, 25));
17- nameField.setPreferredSize(new Dimension(330, 25));
18+ SwingHelper.setPreferredWidth(nameField,330);
19 nameField.addActionListener(e -> {
20 okButton.requestFocusInWindow();
21 okButton.doClick();
22
23=== modified file 'src/dk/aau/cs/gui/SharedTransitionNamePanel.java'
24--- src/dk/aau/cs/gui/SharedTransitionNamePanel.java 2020-07-13 13:58:47 +0000
25+++ src/dk/aau/cs/gui/SharedTransitionNamePanel.java 2021-04-08 08:40:30 +0000
26@@ -15,6 +15,7 @@
27 import javax.swing.JRootPane;
28 import javax.swing.JTextField;
29
30+import net.tapaal.swinghelpers.SwingHelper;
31 import pipe.gui.undo.UndoManager;
32 import pipe.dataLayer.TAPNQuery;
33 import dk.aau.cs.TCTL.visitors.RenameSharedTransitionVisitor;
34@@ -86,8 +87,7 @@
35
36 String initialText = (transitionToEdit == null) ? "" : transitionToEdit.name();
37 nameField = new JTextField(initialText);
38- nameField.setMinimumSize(new Dimension(330, 25));
39- nameField.setPreferredSize(new Dimension(330, 25));
40+ SwingHelper.setPreferredWidth(nameField,330);
41 nameField.addActionListener(e -> {
42 okButton.requestFocusInWindow();
43 okButton.doClick();
44
45=== modified file 'src/dk/aau/cs/gui/TemplateExplorer.java'
46--- src/dk/aau/cs/gui/TemplateExplorer.java 2020-08-04 08:53:19 +0000
47+++ src/dk/aau/cs/gui/TemplateExplorer.java 2021-04-08 08:40:30 +0000
48@@ -39,6 +39,7 @@
49 import dk.aau.cs.gui.undo.MoveElementDownCommand;
50 import dk.aau.cs.gui.undo.MoveElementUpCommand;
51 import net.tapaal.resourcemanager.ResourceManager;
52+import net.tapaal.swinghelpers.SwingHelper;
53 import pipe.dataLayer.DataLayer;
54 import pipe.dataLayer.TAPNQuery;
55 import pipe.dataLayer.Template;
56@@ -551,9 +552,9 @@
57 nameContainer.setLayout(new GridBagLayout());
58 size = new Dimension(330, 25);
59
60- nameTextField = new javax.swing.JTextField();
61- nameTextField.setPreferredSize(size);
62- nameTextField.setText(nameToShow);
63+ nameTextField = new javax.swing.JTextField();
64+ SwingHelper.setPreferredWidth(nameTextField,330);
65+ nameTextField.setText(nameToShow);
66 nameTextField.addAncestorListener(new RequestFocusListener());
67 nameTextField.addActionListener(e -> {
68 okButton.requestFocusInWindow();
69@@ -659,10 +660,9 @@
70 container.setLayout(new GridBagLayout());
71 nameContainer = new JPanel();
72 nameContainer.setLayout(new GridBagLayout());
73- size = new Dimension(330, 25);
74
75- nameTextField = new javax.swing.JTextField();
76- nameTextField.setPreferredSize(size);
77+ nameTextField = new javax.swing.JTextField();
78+ SwingHelper.setPreferredWidth(nameTextField,330);
79 nameTextField.setText(oldname);
80 nameTextField.addAncestorListener(new RequestFocusListener());
81 nameTextField.addActionListener(e -> {
82
83=== modified file 'src/net/tapaal/swinghelpers/CustomJSpinner.java'
84--- src/net/tapaal/swinghelpers/CustomJSpinner.java 2020-04-18 12:30:50 +0000
85+++ src/net/tapaal/swinghelpers/CustomJSpinner.java 2021-04-08 08:40:30 +0000
86@@ -104,9 +104,7 @@
87 ((JSpinner)e.getSource()).setValue(maximumValue);
88 }
89 });
90- this.setPreferredSize(new Dimension(100, 25));
91- this.setMaximumSize(new Dimension(100, 25));
92- this.setMinimumSize(new Dimension(100, 25));
93+ SwingHelper.setPreferredWidth(this, 100);
94
95 final JSpinner spinner = this;
96
97
98=== added file 'src/net/tapaal/swinghelpers/SwingHelper.java'
99--- src/net/tapaal/swinghelpers/SwingHelper.java 1970-01-01 00:00:00 +0000
100+++ src/net/tapaal/swinghelpers/SwingHelper.java 2021-04-08 08:40:30 +0000
101@@ -0,0 +1,8 @@
102+package net.tapaal.swinghelpers;
103+import java.awt.*;
104+public class SwingHelper {
105+ public static void setPreferredWidth(Component c, int width) {
106+ var pSize = c.getPreferredSize();
107+ c.setPreferredSize(new Dimension(width, pSize.height));
108+ }
109+}
110\ No newline at end of file
111
112=== modified file 'src/pipe/gui/GuiFrame.java'
113--- src/pipe/gui/GuiFrame.java 2020-12-16 08:38:28 +0000
114+++ src/pipe/gui/GuiFrame.java 2021-04-08 08:40:30 +0000
115@@ -27,6 +27,7 @@
116 import net.tapaal.helpers.Reference.MutableReference;
117 import net.tapaal.helpers.Reference.Reference;
118 import net.tapaal.swinghelpers.ExtendedJTabbedPane;
119+import net.tapaal.swinghelpers.SwingHelper;
120 import net.tapaal.swinghelpers.ToggleButtonWithoutText;
121 import org.jetbrains.annotations.NotNull;
122 import pipe.dataLayer.TAPNQuery;
123@@ -866,7 +867,7 @@
124 * for generic addition of comboboxes
125 */
126 private void addZoomComboBox(JToolBar toolBar, Action action) {
127- Dimension zoomComboBoxDimension = new Dimension(75, 28);
128+ Dimension zoomComboBoxDimension = new Dimension(100, 28);
129
130 String[] zoomExamplesStrings = new String[zoomLevels.length];
131 int i;
132@@ -878,9 +879,7 @@
133 zoomComboBox.setEditable(true);
134 zoomComboBox.setSelectedItem("100%");
135 zoomComboBox.setMaximumRowCount(zoomLevels.length);
136- zoomComboBox.setMaximumSize(zoomComboBoxDimension);
137- zoomComboBox.setMinimumSize(zoomComboBoxDimension);
138- zoomComboBox.setPreferredSize(zoomComboBoxDimension);
139+ SwingHelper.setPreferredWidth(zoomComboBox,zoomComboBoxDimension.width);
140 zoomComboBox.setAction(action);
141 zoomComboBox.setFocusable(false);
142 toolBar.add(zoomComboBox);
143
144=== modified file 'src/pipe/gui/widgets/ConstantsDialogPanel.java'
145--- src/pipe/gui/widgets/ConstantsDialogPanel.java 2020-07-20 09:36:10 +0000
146+++ src/pipe/gui/widgets/ConstantsDialogPanel.java 2021-04-08 08:40:30 +0000
147@@ -17,6 +17,7 @@
148
149 import net.tapaal.swinghelpers.CustomJSpinner;
150 import net.tapaal.swinghelpers.RequestFocusListener;
151+import net.tapaal.swinghelpers.SwingHelper;
152 import pipe.gui.CreateGui;
153 import dk.aau.cs.gui.undo.Command;
154 import dk.aau.cs.model.tapn.Constant;
155@@ -75,9 +76,8 @@
156 private void initComponents() {
157 container = new JPanel();
158 container.setLayout(new GridBagLayout());
159- size = new Dimension(330, 25);
160- nameTextField = new javax.swing.JTextField();
161- nameTextField.setPreferredSize(size);
162+ nameTextField = new javax.swing.JTextField();
163+ SwingHelper.setPreferredWidth(nameTextField,330);
164 nameTextField.addAncestorListener(new RequestFocusListener());
165 nameTextField.addActionListener(e -> {
166 okButton.requestFocusInWindow();
167
168=== modified file 'src/pipe/gui/widgets/GuardDialogue.java'
169--- src/pipe/gui/widgets/GuardDialogue.java 2020-09-24 15:33:08 +0000
170+++ src/pipe/gui/widgets/GuardDialogue.java 2021-04-08 08:40:30 +0000
171@@ -29,6 +29,7 @@
172
173 import dk.aau.cs.gui.TabContent;
174 import dk.aau.cs.model.tapn.*;
175+import net.tapaal.swinghelpers.SwingHelper;
176 import net.tapaal.swinghelpers.WidthAdjustingComboBox;
177 import pipe.gui.CreateGui;
178 import pipe.gui.graphicElements.PetriNetObject;
179@@ -233,11 +234,11 @@
180 gridBagConstraints.anchor = GridBagConstraints.WEST;
181 gridBagConstraints.insets = new Insets(3, 3, 3, 3);
182 weightEditPanel.add(label, gridBagConstraints);
183-
184+
185 Dimension intervalBoxDims = new Dimension(190, 25);
186
187 weightNumber = new JSpinner();
188- weightNumber.setPreferredSize(intervalBoxDims);
189+ SwingHelper.setPreferredWidth(weightNumber,intervalBoxDims.width);
190 weightNumber.addChangeListener(e -> {
191 if((Integer) weightNumber.getValue() < 1){
192 weightNumber.setValue(1);
193@@ -271,8 +272,8 @@
194 weightConstantsComboBox.setModel(new DefaultComboBoxModel<>(constantArray));
195 weightConstantsComboBox.setMaximumRowCount(20);
196 weightConstantsComboBox.setVisible(false);
197- weightConstantsComboBox.setPreferredSize(intervalBoxDims);
198-
199+ SwingHelper.setPreferredWidth(weightConstantsComboBox,intervalBoxDims.width);
200+
201 gridBagConstraints = new GridBagConstraints();
202 gridBagConstraints.gridx = 1;
203 gridBagConstraints.gridy = 1;
204@@ -379,7 +380,7 @@
205 firstIntervalNumber = new JSpinner();
206 // firstIntervalNumber.setMaximumSize(intervalBoxDims);
207 // firstIntervalNumber.setMinimumSize(intervalBoxDims);
208- firstIntervalNumber.setPreferredSize(intervalBoxDims);
209+ SwingHelper.setPreferredWidth(firstIntervalNumber,intervalBoxDims.width);
210 firstIntervalNumber.addChangeListener(this::firstSpinnerStateChanged);
211 GridBagConstraints gridBagConstraints = new GridBagConstraints();
212 gridBagConstraints.gridx = 2;
213@@ -393,9 +394,8 @@
214 guardEditPanel.add(new JLabel(" , "), gridBagConstraints);
215
216 secondIntervalNumber = new JSpinner();
217- secondIntervalNumber.setMaximumSize(intervalBoxDims);
218- secondIntervalNumber.setMinimumSize(intervalBoxDims);
219- secondIntervalNumber.setPreferredSize(intervalBoxDims);
220+
221+ SwingHelper.setPreferredWidth(secondIntervalNumber,intervalBoxDims.width);
222 secondIntervalNumber.addChangeListener(this::secondSpinnerStateChanged);
223
224 gridBagConstraints.gridx = 4;
225@@ -430,7 +430,8 @@
226 leftConstantsComboBox.setVisible(false);
227 // leftConstantsComboBox.setMaximumSize(intervalBoxDims);
228 // leftConstantsComboBox.setMinimumSize(intervalBoxDims);
229- leftConstantsComboBox.setPreferredSize(intervalBoxDims);
230+ SwingHelper.setPreferredWidth(leftConstantsComboBox,intervalBoxDims.width);
231+ //leftConstantsComboBox.setPreferredSize(intervalBoxDims);
232 leftConstantsComboBox.addItemListener(e -> {
233 if (e.getStateChange() == ItemEvent.SELECTED) {
234 updateRightConstantComboBox();
235@@ -462,7 +463,7 @@
236 rightConstantsComboBox.setVisible(false);
237 // rightConstantsComboBox.setMaximumSize(intervalBoxDims);
238 // rightConstantsComboBox.setMinimumSize(intervalBoxDims);
239- rightConstantsComboBox.setPreferredSize(intervalBoxDims);
240+ SwingHelper.setPreferredWidth(rightConstantsComboBox,intervalBoxDims.width);
241 gridBagConstraints = new GridBagConstraints();
242 rightConstantsComboBox.addItemListener(e -> {
243 if (e.getStateChange() == ItemEvent.SELECTED) {
244
245=== modified file 'src/pipe/gui/widgets/NewTAPNPanel.java'
246--- src/pipe/gui/widgets/NewTAPNPanel.java 2020-08-04 08:53:19 +0000
247+++ src/pipe/gui/widgets/NewTAPNPanel.java 2021-04-08 08:40:30 +0000
248@@ -11,6 +11,7 @@
249 import javax.swing.*;
250
251 import dk.aau.cs.gui.TabContent;
252+import net.tapaal.swinghelpers.SwingHelper;
253 import pipe.gui.CreateGui;
254 import pipe.gui.Grid;
255 import pipe.gui.GuiFrame;
256@@ -127,8 +128,7 @@
257 String defaultName = String.format("New Petri net %1$d", frame
258 .getNameCounter());
259 nameTextBox = new JTextField(defaultName);
260- Dimension size = new Dimension(330, 25);
261- nameTextBox.setPreferredSize(size);
262+ SwingHelper.setPreferredWidth(nameTextBox,330);
263 gbc = new GridBagConstraints();
264 gbc.gridx = 1;
265 gbc.gridy = 0;
266
267=== modified file 'src/pipe/gui/widgets/PlaceEditorPanel.java'
268--- src/pipe/gui/widgets/PlaceEditorPanel.java 2020-08-10 09:34:06 +0000
269+++ src/pipe/gui/widgets/PlaceEditorPanel.java 2021-04-08 08:40:30 +0000
270@@ -25,6 +25,7 @@
271 import dk.aau.cs.gui.TabContent;
272 import net.tapaal.swinghelpers.CustomJSpinner;
273 import net.tapaal.swinghelpers.GridBagHelper;
274+import net.tapaal.swinghelpers.SwingHelper;
275 import net.tapaal.swinghelpers.WidthAdjustingComboBox;
276 import pipe.dataLayer.Template;
277 import pipe.gui.CreateGui;
278@@ -251,11 +252,11 @@
279 basicPropertiesPanel.add(nameLabel, gridBagConstraints);
280
281 nameTextField = new javax.swing.JTextField();
282- nameTextField.setPreferredSize(new Dimension(290,27));
283+ SwingHelper.setPreferredWidth(nameTextField,290);
284
285 sharedPlacesComboBox = new WidthAdjustingComboBox(maxNumberOfPlacesToShowAtOnce);
286
287- sharedPlacesComboBox.setPreferredSize(new Dimension(290,27));
288+ SwingHelper.setPreferredWidth(sharedPlacesComboBox,290);
289
290 sharedPlacesComboBox.addItemListener(e -> {
291 SharedPlace place = (SharedPlace)e.getItem();
292
293=== modified file 'src/pipe/gui/widgets/TAPNTransitionEditor.java'
294--- src/pipe/gui/widgets/TAPNTransitionEditor.java 2020-08-10 09:34:06 +0000
295+++ src/pipe/gui/widgets/TAPNTransitionEditor.java 2021-04-08 08:40:30 +0000
296@@ -18,6 +18,7 @@
297 import javax.swing.event.CaretListener;
298 import net.tapaal.swinghelpers.GridBagHelper;
299 import dk.aau.cs.gui.undo.*;
300+import net.tapaal.swinghelpers.SwingHelper;
301 import net.tapaal.swinghelpers.WidthAdjustingComboBox;
302 import pipe.gui.CreateGui;
303 import pipe.gui.graphicElements.tapn.TimedTransitionComponent;
304@@ -66,7 +67,7 @@
305 transitionEditorPanel = new JPanel();
306 nameLabel = new JLabel();
307 nameTextField = new JTextField();
308- nameTextField.setPreferredSize(new Dimension(290,27));
309+ SwingHelper.setPreferredWidth(nameTextField, 290);
310 rotationLabel = new JLabel();
311 rotationComboBox = new JComboBox<>();
312 buttonPanel = new JPanel();
313@@ -80,7 +81,7 @@
314
315
316 sharedTransitionsComboBox = new WidthAdjustingComboBox<>(maxNumberOfTransitionsToShowAtOnce);
317- sharedTransitionsComboBox.setPreferredSize(new Dimension(290,27));
318+ SwingHelper.setPreferredWidth(sharedTransitionsComboBox,290);
319 sharedTransitionsComboBox.addActionListener(e -> {
320 if(((SharedTransition)sharedTransitionsComboBox.getSelectedItem()).transitions().isEmpty()){
321 ((SharedTransition)sharedTransitionsComboBox.getSelectedItem()).setUrgent(urgentCheckBox.isSelected());

Subscribers

People subscribed via source and target branches