From 97a3a4f07cdc8437f73f4270b237e85c7739a6be Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 27 May 2008 17:23:45 +0000 Subject: client and server variables are now separate in the editor. --- sources/prefs/editors/VSAbstractEditor.java | 44 +++++++++++++++++++---------- sources/prefs/editors/VSProcessEditor.java | 17 +++++++++-- 2 files changed, 43 insertions(+), 18 deletions(-) (limited to 'sources/prefs/editors') diff --git a/sources/prefs/editors/VSAbstractEditor.java b/sources/prefs/editors/VSAbstractEditor.java index 9ae98be..1b6351c 100644 --- a/sources/prefs/editors/VSAbstractEditor.java +++ b/sources/prefs/editors/VSAbstractEditor.java @@ -634,33 +634,47 @@ public abstract class VSAbstractEditor implements ActionListener { editTable.fireTableDataChanged(); } + private ArrayList filterOut(Set set, ArrayList filter, String prefix) { + ArrayList ret = new ArrayList(); + + for (String key : set) { + String fullKey = prefix + key; + if (filter.contains(fullKey)) + ret.add(fullKey); + } + + return ret; + } + /** * Adds the to editor. * * @param label the label * @param prefsKey the prefs key * @param prefsToAdd the prefs to add + * @param addOnlyThisVariables only add variables which are in this list */ - protected void addToEditor(String label, String prefsKey, VSPrefs prefsToAdd) { + protected void addToEditor(String label, String prefsKey, VSPrefs prefsToAdd, ArrayList addOnlyThisVariables) { addSeparator(label); prefsKey = "(" + prefsKey + ")"; ArrayList fullKeys = new ArrayList(); - Set integerKeys = prefsToAdd.getIntegerKeySet(); - Set vectorKeys = prefsToAdd.getVectorKeySet(); - Set floatKeys = prefsToAdd.getFloatKeySet(); - Set longKeys = prefsToAdd.getLongKeySet(); - Set booleanKeys = prefsToAdd.getBooleanKeySet(); - Set stringKeys = prefsToAdd.getStringKeySet(); - - for (String key : integerKeys) fullKeys.add(VSPrefs.INTEGER_PREFIX + key); - for (String key : vectorKeys) fullKeys.add(VSPrefs.VECTOR_PREFIX + key); - for (String key : floatKeys) fullKeys.add(VSPrefs.FLOAT_PREFIX + key); - for (String key : longKeys) fullKeys.add(VSPrefs.LONG_PREFIX + key); - for (String key : booleanKeys) fullKeys.add(VSPrefs.BOOLEAN_PREFIX + key); - for (String key : stringKeys) fullKeys.add(VSPrefs.STRING_PREFIX + key); - + fullKeys.addAll(filterOut(prefsToAdd.getIntegerKeySet(), addOnlyThisVariables, VSPrefs.INTEGER_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getVectorKeySet(), addOnlyThisVariables, VSPrefs.VECTOR_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getFloatKeySet(), addOnlyThisVariables, VSPrefs.FLOAT_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getLongKeySet(), addOnlyThisVariables, VSPrefs.LONG_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getBooleanKeySet(), addOnlyThisVariables, VSPrefs.BOOLEAN_PREFIX)); + fullKeys.addAll(filterOut(prefsToAdd.getStringKeySet(), addOnlyThisVariables, VSPrefs.STRING_PREFIX)); + + /* + for (String key : integerKeys) fullKeys.add(VSPrefs.INTEGER_PREFIX + key); + for (String key : vectorKeys) fullKeys.add(VSPrefs.VECTOR_PREFIX + key); + for (String key : floatKeys) fullKeys.add(VSPrefs.FLOAT_PREFIX + key); + for (String key : longKeys) fullKeys.add(VSPrefs.LONG_PREFIX + key); + for (String key : booleanKeys) fullKeys.add(VSPrefs.BOOLEAN_PREFIX + key); + for (String key : stringKeys) fullKeys.add(VSPrefs.STRING_PREFIX + key); + */ Collections.sort(fullKeys); for (String fullKey : fullKeys) { diff --git a/sources/prefs/editors/VSProcessEditor.java b/sources/prefs/editors/VSProcessEditor.java index 8666fbe..1992d6c 100644 --- a/sources/prefs/editors/VSProcessEditor.java +++ b/sources/prefs/editors/VSProcessEditor.java @@ -13,7 +13,6 @@ import protocols.*; import events.*; import prefs.VSPrefs; -// TODO: Auto-generated Javadoc /** * The Class VSProcessEditor. */ @@ -57,11 +56,23 @@ public class VSProcessEditor extends VSAbstractBetterEditor { ArrayList editableProtocolsClassnames = VSRegisteredEvents.getEditableProtocolsClassnames(); - String protocolString = " " + prefs.getString("lang.protocol"); + //String protocolString = " " + prefs.getString("lang.protocol"); + String clientString = " " + prefs.getString("lang.client"); + String serverString = " " + prefs.getString("lang.server"); + for (String protocolClassname : editableProtocolsClassnames) { String protocolShortname = VSRegisteredEvents.getShortname(protocolClassname); VSAbstractProtocol protocol = process.getProtocolObject(protocolClassname); - addToEditor(protocolShortname + protocolString, protocolShortname, protocol); + protocol.onClientInit(); + protocol.onServerInit(); + + ArrayList clientVariables = VSRegisteredEvents.getProtocolClientVariables(protocolClassname); + if (clientVariables != null) + addToEditor(protocolShortname + clientString, protocolShortname, protocol, clientVariables); + + ArrayList serverVariables = VSRegisteredEvents.getProtocolServerVariables(protocolClassname); + if (serverVariables != null) + addToEditor(protocolShortname + serverString, protocolShortname, protocol, serverVariables); } } -- cgit v1.2.3