MemoryEditor's Amount field defaults to 100
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 3 Oct 2019 14:48:14 +0000 (16:48 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 3 Oct 2019 14:48:14 +0000 (16:48 +0200)
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/MemoryEditor.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java

index 028a1b5..b367f3a 100644 (file)
@@ -111,19 +111,21 @@ public class MemoryEditor extends EditorPart
                Text amountText = new Text(parent, SWT.BORDER);
                amountText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
                amountText.addVerifyListener(vl);
-               amountText.setText("0");
                amountText.addModifyListener(e ->
                {
                        try
                        {
-                               provider.setAmount(AsmNumberUtil.valueOf(amountText.getText()).intValue());
-                               viewer.refresh();
+                               if (provider != null)
+                                       provider.setAmount(AsmNumberUtil.valueOf(amountText.getText()).intValue());
+                               if (viewer != null)
+                                       viewer.refresh();
                        }
                        catch (NumberFormatException x)
                        {
                                // Nothing to do here
                        }
                });
+               amountText.setText("100");// do this after registering the ModifyListener
                new RadixSelector(parent, displaySettings);
 
                addActivationButton(parent);
index 3d67c9d..a27f31f 100644 (file)
@@ -27,12 +27,13 @@ public class MemoryTableContentProvider implements ILazyContentProvider, MemoryC
 
        public void updateItemCount()
        {
-               if (memory != null)
-               {
-                       long size = memory.getDefinition().getMaximalAddress() - lower;
-                       viewer.setItemCount(size > amount ? amount : (int) size);
-               } else
-                       viewer.setItemCount(0);
+               if (viewer != null)
+                       if (memory != null)
+                       {
+                               long size = memory.getDefinition().getMaximalAddress() - lower;
+                               viewer.setItemCount(size > amount ? amount : (int) size);
+                       } else
+                               viewer.setItemCount(0);
        }
 
        public long getLowerBound()