Skip to content

Commit 70b2346

Browse files
committed
CTT Code improvements
1 parent 975ed26 commit 70b2346

File tree

6 files changed

+122
-92
lines changed

6 files changed

+122
-92
lines changed

sdk/consumer-test-tool/src/main/java/esa/mo/nmf/ctt/windows/element/CompositeEntry.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,15 @@ public class CompositeEntry extends Entry {
3131

3232
private final javax.swing.JToggleButton button;
3333

34-
public CompositeEntry(String fieldNameIn, Element obj, boolean editable, boolean objIsNull) {
35-
super(fieldNameIn, obj, editable, objIsNull);
34+
public CompositeEntry(String fieldName, Element obj, boolean editable, boolean objIsNull) {
35+
super(fieldName, obj, editable, objIsNull);
3636

3737
// Make a button and put it in the middle Panel
3838
button = new javax.swing.JToggleButton();
3939
button.addActionListener(this::buttonActionPerformed);
40-
40+
button.setText(editable ? "Edit" : "View"); // Set the text
4141
super.middlePanel.add(button);
4242

43-
// Set the text
44-
if (editable) {
45-
this.button.setText("Edit");
46-
} else {
47-
this.button.setText("View");
48-
}
49-
5043
if (objIsNull) {
5144
super.makeFieldNull();
5245
this.button.setText("Add");
@@ -77,7 +70,5 @@ private void buttonActionPerformed(java.awt.event.ActionEvent evt) {
7770
if (editable) {
7871
this.button.setText("Edit");
7972
}
80-
8173
}
82-
8374
}

sdk/consumer-test-tool/src/main/java/esa/mo/nmf/ctt/windows/element/Entry.form

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121
<Layout>
2222
<DimensionLayout dim="0">
2323
<Group type="103" groupAlignment="0" attributes="0">
24-
<Group type="102" attributes="0">
25-
<EmptySpace max="-2" attributes="0"/>
26-
<Component id="mainPanel" pref="580" max="32767" attributes="0"/>
27-
<EmptySpace max="-2" attributes="0"/>
28-
</Group>
24+
<Component id="mainPanel" alignment="0" pref="593" max="32767" attributes="0"/>
2925
</Group>
3026
</DimensionLayout>
3127
<DimensionLayout dim="1">
@@ -40,8 +36,8 @@
4036
<SubComponents>
4137
<Container class="javax.swing.JPanel" name="mainPanel">
4238
<Properties>
43-
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
44-
<Dimension value="[153, 23]"/>
39+
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
40+
<Dimension value="[2000, 2000]"/>
4541
</Property>
4642
</Properties>
4743
<AuxValues>
@@ -58,6 +54,13 @@
5854
<Properties>
5955
<Property name="horizontalAlignment" type="int" value="4"/>
6056
<Property name="text" type="java.lang.String" value="jLabel1"/>
57+
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
58+
<Dimension value="[1800, 19]"/>
59+
</Property>
60+
<Property name="name" type="java.lang.String" value="" noResource="true"/>
61+
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
62+
<Dimension value="null"/>
63+
</Property>
6164
</Properties>
6265
<AuxValues>
6366
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
@@ -67,6 +70,9 @@
6770
<Properties>
6871
<Property name="horizontalAlignment" type="int" value="2"/>
6972
<Property name="text" type="java.lang.String" value="jLabel1"/>
73+
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
74+
<Dimension value="[800, 19]"/>
75+
</Property>
7076
</Properties>
7177
<AuxValues>
7278
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>

sdk/consumer-test-tool/src/main/java/esa/mo/nmf/ctt/windows/element/Entry.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.lang.reflect.Field;
2424
import java.util.logging.Level;
2525
import java.util.logging.Logger;
26+
import javax.swing.JLabel;
2627
import org.ccsds.moims.mo.mal.helpertools.helpers.HelperAttributes;
2728
import org.ccsds.moims.mo.mal.structures.Union;
2829

@@ -32,8 +33,8 @@
3233
*/
3334
public abstract class Entry extends javax.swing.JPanel {
3435

35-
Object object = null;
36-
boolean editable;
36+
protected Object object = null;
37+
protected boolean editable;
3738

3839
@SuppressWarnings("unchecked")
3940
public Entry(String fieldName, Object obj, boolean editable, boolean objIsNull) {
@@ -63,7 +64,6 @@ public Entry(String fieldName, Object obj, boolean editable, boolean objIsNull)
6364

6465
Integer typeShortForm = (Integer) fieldTypeShortForm.get(obj);
6566
className = HelperAttributes.typeShortForm2attributeName(typeShortForm);
66-
6767
} catch (IllegalArgumentException | SecurityException | NoSuchFieldException | IllegalAccessException ex) {
6868
Logger.getLogger(Entry.class.getName()).log(Level.SEVERE, null, ex);
6969
}
@@ -105,15 +105,19 @@ private void initComponents() {
105105

106106
setPreferredSize(new java.awt.Dimension(600, 35));
107107

108-
mainPanel.setPreferredSize(new java.awt.Dimension(153, 23));
108+
mainPanel.setMaximumSize(new java.awt.Dimension(2000, 2000));
109109
mainPanel.setLayout(new java.awt.GridLayout(1, 1, 15, 0));
110110

111111
fieldName.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
112112
fieldName.setText("jLabel1");
113+
fieldName.setMaximumSize(new java.awt.Dimension(1800, 19));
114+
fieldName.setName(""); // NOI18N
115+
fieldName.setPreferredSize(null);
113116
mainPanel.add(fieldName);
114117

115118
fieldType.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
116119
fieldType.setText("jLabel1");
120+
fieldType.setMaximumSize(new java.awt.Dimension(800, 19));
117121
mainPanel.add(fieldType);
118122

119123
fieldSelectableAttribute.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
@@ -139,10 +143,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
139143
this.setLayout(layout);
140144
layout.setHorizontalGroup(
141145
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
142-
.addGroup(layout.createSequentialGroup()
143-
.addContainerGap()
144-
.addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE)
145-
.addContainerGap())
146+
.addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 593, Short.MAX_VALUE)
146147
);
147148
layout.setVerticalGroup(
148149
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -173,10 +174,14 @@ public final void makeFieldNull() {
173174
this.fieldSelectableAttribute.setEnabled(false);
174175
}
175176

176-
public javax.swing.JLabel getFieldNameLabel() {
177+
public JLabel getFieldName() {
177178
return fieldName;
178179
}
179180

181+
public JLabel getFieldType() {
182+
return fieldType;
183+
}
184+
180185
public String getFieldTypeString() {
181186
return this.fieldType.getText();
182187
}

sdk/consumer-test-tool/src/main/java/esa/mo/nmf/ctt/windows/element/ListEntry.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ public ListEntry(final MOWindow previousWindow, String fieldNameIn,
4545
buttonRemove = new javax.swing.JToggleButton();
4646
buttonRemove.setText("Remove");
4747
final ListEntry temp = this;
48+
4849
java.awt.event.ActionListener actionListenerRemove = evt -> {
4950
JPanel panel = previousWindow.getComponentsPanel();
5051
panel.remove(temp);
5152

5253
// Fix the indexes
5354
for (int i = 0; i < panel.getComponentCount() - 1; i++) {
5455
Entry component = (Entry) panel.getComponent(i);
55-
component.getFieldNameLabel().setText(String.valueOf(i));
56+
component.getFieldName().setText(String.valueOf(i));
5657
}
5758

5859
previousWindow.refreshVerticalSize();
@@ -74,7 +75,6 @@ public ListEntry(final MOWindow previousWindow, String fieldNameIn,
7475
if (!editable) {
7576
this.buttonRemove.setEnabled(false);
7677
}
77-
7878
} else {
7979
// Make a button and put it in the middle Panel
8080
buttonEdit = new javax.swing.JToggleButton();
@@ -90,8 +90,9 @@ public ListEntry(final MOWindow previousWindow, String fieldNameIn,
9090
this.nullCB.setEnabled(false);
9191
}
9292
}
93-
94-
super.middlePanel.add(buttonRemove);
93+
if (editable) {
94+
super.middlePanel.add(buttonRemove);
95+
}
9596

9697
if (objIsNull) {
9798
super.makeFieldNull();

sdk/consumer-test-tool/src/main/java/esa/mo/nmf/ctt/windows/element/MOWindow.form

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<Container class="javax.swing.JPanel" name="topPanel">
3535
<Properties>
3636
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
37-
<Dimension value="[78, 40]"/>
37+
<Dimension value="[500, 40]"/>
3838
</Property>
3939
</Properties>
4040
<Constraints>
@@ -72,11 +72,11 @@
7272
<Container class="javax.swing.JPanel" name="componentsPanel">
7373
<Properties>
7474
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
75-
<Dimension value="[550, 100]"/>
75+
<Dimension value="[500, 100]"/>
7676
</Property>
7777
<Property name="name" type="java.lang.String" value="" noResource="true"/>
7878
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
79-
<Dimension value="[550, 200]"/>
79+
<Dimension value="null"/>
8080
</Property>
8181
</Properties>
8282
<Constraints>
@@ -98,7 +98,7 @@
9898
</Property>
9999
<Property name="name" type="java.lang.String" value="" noResource="true"/>
100100
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
101-
<Dimension value="[452, 40]"/>
101+
<Dimension value="[500, 40]"/>
102102
</Property>
103103
</Properties>
104104
<Constraints>

0 commit comments

Comments
 (0)