+
+ private void addDashesGroup(Composite parent)
+ {
+ Composite dashesGroupParent = new Composite(parent, SWT.NONE);
+ dashesGroupParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ GridLayout dashesGroupParentLayout = new GridLayout();
+ dashesGroupParentLayout.marginWidth = 0;
+ dashesGroupParentLayout.marginHeight = 0;
+ dashesGroupParent.setLayout(dashesGroupParentLayout);
+
+ Group dashesGroup = new Group(dashesGroupParent, SWT.NONE);
+ dashesGroup.setText("Line dashes");
+ dashesGroup.setLayout(new GridLayout());
+ dashesGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ Composite content = new Composite(dashesGroup, SWT.NONE);
+ content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ GridLayout contentLayout = new GridLayout(2, false);
+ contentLayout.marginWidth = 0;
+ contentLayout.marginHeight = 0;
+ content.setLayout(contentLayout);
+
+ Label dashesDescription = new Label(content, SWT.WRAP);
+ dashesDescription.setText("Line dashes for single-bit wires displaying the respective value.\n"
+ + "Format: A comma-separated list of doubles. The first value is the width of the first segment,\n"
+ + "the second is the spacing between the first and second segments,\n"
+ + "the third is the width of the second segment and so on.");
+ dashesDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
+ addString(BIT_ZERO_DASH, "0", content);
+ addString(BIT_Z_DASH, "Z", content);
+ addString(BIT_X_DASH, "X", content);
+ addString(BIT_U_DASH, "U", content);
+ addString(BIT_ONE_DASH, "1", content);
+ }
+
+ private void addBoolean(String name, String label, Composite parent)
+ {
+ defaultsPreferenceStore(name).getBoolean(name);
+ addField(new BooleanFieldEditor(name, label, parent));
+ }
+
+ private void addInt(String name, String label, Composite parent)
+ {
+ defaultsPreferenceStore(name).getInt(name);
+ addField(new IntegerFieldEditor(name, label, parent));
+ }
+
+ private void addDouble(String name, String label, Composite parent)
+ {
+ defaultsPreferenceStore(name).getDouble(name);
+ addField(new DoubleFieldEditor(name, label, parent));
+ }
+
+ private void addIntCombo(String name, String label, String[][] entryNamesAndValues, Composite parent)
+ {
+ addCombo(name, label, entryNamesAndValues, parent, defaultsPreferenceStore(name)::getInt);
+ }
+
+ private void addCombo(String name, String label, String[][] entryNamesAndValues, Composite parent, Consumer<String> initializeDefault)
+ {
+ initializeDefault.accept(name);
+ addField(new ComboFieldEditor(name, label, entryNamesAndValues, parent));
+ }
+
+ private void addString(String name, String label, Composite parent)
+ {
+ defaultsPreferenceStore(name).getString(name);
+ addField(new StringFieldEditor(name, label, parent));
+ }
+
+ private static void insertSeparator(Composite parent)
+ {
+ new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ }
+
+ private static Preferences defaultsPreferenceStore(String name)
+ {
+ // TODO is it a good idea to list all preference systems here?
+ // Maybe rather split the page into one per preference system
+ MograsimActivator mograsim = MograsimActivator.instance();
+ if (name.startsWith(RenderPreferences.PREFIX))
+ return mograsim.getRenderPrefs();
+ else if (name.startsWith(PluginPreferences.PREFIX))
+ return mograsim.getPluginPrefs();
+ else
+ throw new IllegalArgumentException("The preference system containing " + name + " is not known");
+ }