From d55dc585ecd9f8bfd800ba7a034ab1e6b6bba2b3 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Thu, 3 Oct 2019 16:48:14 +0200 Subject: [PATCH] MemoryEditor's Amount field defaults to 100 --- .../net/mograsim/plugin/editors/MemoryEditor.java | 8 +++++--- .../tables/memory/MemoryTableContentProvider.java | 13 +++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/MemoryEditor.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/MemoryEditor.java index 028a1b5b..b367f3a4 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/MemoryEditor.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/MemoryEditor.java @@ -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); diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java index 3d67c9dc..a27f31f3 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java @@ -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() -- 2.17.1