in gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Preferences.groovy [179:254]
private static installPropertyListeners() {
org.codehaus.groovy.tools.shell.util.Preferences.addChangeListener(new PreferenceChangeListener() {
@Override
void preferenceChange(PreferenceChangeEvent evt) {
if (evt.key == PREFERENCE_ITERATION_MAX && null != evt.newValue) {
try {
maxIteration = Integer.parseInt(evt.newValue)
} catch (NumberFormatException e) {
println(Colorizer.render(errorColor,"Unable to convert '${evt.newValue}' to integer. Using default ${DEFAULT_ITERATION_MAX}"))
maxIteration = DEFAULT_ITERATION_MAX
}
} else if (evt.key == PREFERENCE_ITERATION_MAX){
maxIteration = DEFAULT_ITERATION_MAX
}
}
})
org.codehaus.groovy.tools.shell.util.Preferences.addChangeListener(new PreferenceChangeListener() {
@Override
void preferenceChange(PreferenceChangeEvent evt) {
if (evt.key == PREF_GREMLIN_COLOR) {
gremlinColor = getValidColor(PREF_GREMLIN_COLOR, evt.newValue, PREF_GREMLIN_COLOR_DEFAULT)
} else if (evt.key == PREF_VERTEX_COLOR) {
vertexColor = getValidColor(PREF_VERTEX_COLOR, evt.newValue, PREF_VERTEX_COLOR_DEFAULT)
} else if (evt.key == PREF_EDGE_COLOR) {
edgeColor = getValidColor(PREF_EDGE_COLOR, evt.newValue, PREF_EDGE_COLOR_DEFAULT)
} else if (evt.key == PREF_ERROR_COLOR) {
errorColor = getValidColor(PREF_ERROR_COLOR, evt.newValue, PREF_ERROR_COLOR_DEFAULT)
} else if (evt.key == PREF_INFO_COLOR) {
infoColor = getValidColor(PREF_INFO_COLOR, evt.newValue, PREF_INFO_COLOR_DEFAULT)
} else if (evt.key == PREF_STRING_COLOR) {
stringColor = getValidColor(PREF_STRING_COLOR, evt.newValue, PREF_STRING_COLOR_DEFAULT)
} else if (evt.key == PREF_NUMBER_COLOR) {
numberColor = getValidColor(PREF_NUMBER_COLOR, evt.newValue, PREF_NUMBER_COLOR_DEFAULT)
} else if (evt.key == PREF_T_COLOR) {
tColor = getValidColor(PREF_T_COLOR, evt.newValue, PREF_T_COLOR_DEFAULT)
} else if (evt.key == PREF_INPUT_PROMPT_COLOR) {
inputPromptColor = getValidColor(PREF_INPUT_PROMPT_COLOR, evt.newValue, PREF_INPUT_PROMPT_COLOR_DEFAULT)
} else if (evt.key == PREF_RESULT_PROMPT_COLOR) {
resultPromptColor = getValidColor(PREF_RESULT_PROMPT_COLOR, evt.newValue, PREF_RESULT_PROMPT_COLOR_DEFAULT)
} else if (evt.key == PREF_RESULT_IND_NULL) {
if (null == evt.newValue) {
emptyResult = STORE.get(PREF_RESULT_IND_NULL, PREF_RESULT_IND_NULL_DEFAULT)
} else {
emptyResult = evt.newValue
}
} else if (evt.key == PREF_INPUT_PROMPT) {
if (null == evt.newValue) {
inputPrompt = STORE.get(PREF_INPUT_PROMPT, PREF_INPUT_PROMPT_DEFAULT)
} else {
inputPrompt = evt.newValue
}
} else if (evt.key == PREF_RESULT_PROMPT) {
if (null == evt.newValue) {
resultPrompt = STORE.get(PREF_RESULT_PROMPT, PREF_RESULT_PROMPT_DEFAULT)
} else {
resultPrompt = evt.newValue
}
} else if (evt.key == PREF_COLORS) {
if (null == evt.newValue) {
colors = Boolean.valueOf(STORE.get(PREF_COLORS, PREF_COLORS_DEFAULT.toString()))
} else {
colors = Boolean.valueOf(evt.newValue)
}
} else if (evt.key == PREF_WARNINGS) {
if (null == evt.newValue) {
warnings = Boolean.valueOf(STORE.get(PREF_WARNINGS, PREF_WARNINGS_DEFAULT.toString()))
} else {
warnings = Boolean.valueOf(evt.newValue)
}
}
}
})
}