use of org.eclipse.jst.server.generic.servertype.definition.Property in project webtools.servertools by eclipse.
the class GenericServer method setDefaults.
@SuppressWarnings("unchecked")
public void setDefaults(IProgressMonitor monitor) {
ServerRuntime serverRuntime = this.getServerDefinition();
// the runtime is not created yet and serverdef can not be determined.
if (serverRuntime == null) {
return;
}
List props = this.getServerDefinition().getProperty();
Map instancePropsMap = new HashMap();
for (Iterator iter = props.iterator(); iter.hasNext(); ) {
Property element = (Property) iter.next();
if (Property.CONTEXT_SERVER.equalsIgnoreCase(element.getContext())) {
// if the property type is this is a combo, parse the value and use the first token as the default
if (Property.TYPE_SELECT.equals(element.getType()) || Property.TYPE_SELECT_EDIT.equals(element.getType())) {
// $NON-NLS-1$
StringTokenizer tokenizer = new StringTokenizer(element.getDefault(), ",");
if (tokenizer.hasMoreTokens()) {
String firstToken = tokenizer.nextToken();
instancePropsMap.put(element.getId(), firstToken);
}
} else {
// not a combo, so just pass through the default value
instancePropsMap.put(element.getId(), element.getDefault());
}
}
}
setServerInstanceProperties(instancePropsMap);
}
use of org.eclipse.jst.server.generic.servertype.definition.Property in project webtools.servertools by eclipse.
the class Resolver method resolveProperties.
/**
* Returns a resolved string.
*
* @param proppedString
* @return resolved string
*/
public String resolveProperties(String proppedString) {
HashMap<String, String> cache = new HashMap<String, String>(getProperties().size());
Iterator itr = getProperties().iterator();
while (itr.hasNext()) {
Property element = (Property) itr.next();
String value = element.getDefault();
if (fPropertyValues != null && fPropertyValues.containsKey(element.getId()))
value = (String) fPropertyValues.get(element.getId());
if (Property.TYPE_DIRECTORY.equals(element.getType()) || Property.TYPE_FILE.equals(element.getType()))
value = value.replace('\\', '/');
cache.put(element.getId(), value);
}
// $NON-NLS-1$
cache.put("pathChar", File.pathSeparator);
String str = resolvePropertiesFromCache(proppedString, cache);
str = fixPassthroughProperties(str);
return str;
}
use of org.eclipse.jst.server.generic.servertype.definition.Property in project webtools.servertools by eclipse.
the class ServerRuntimeMergeUtil method containsProperty.
private static boolean containsProperty(List properties, String id) {
boolean found = false;
Iterator iter = properties.iterator();
while (iter.hasNext()) {
Property prop = (Property) iter.next();
if (prop.getId().equals(id)) {
found = true;
break;
}
}
return found;
}
use of org.eclipse.jst.server.generic.servertype.definition.Property in project webtools.servertools by eclipse.
the class ServerTypeDefinitionDecorator method getValues.
/**
* Returns the property name/value pairs.
* @return Map containing the values collected from the user
*/
public Map getValues() {
Map propertyMap = new HashMap();
for (int i = 0; i < fPropertyControls.size(); i++) {
Property prop = (Property) ((Control) fPropertyControls.get(i)).getData();
if (fPropertyControls.get(i) instanceof Button) {
Button button = (Button) fPropertyControls.get(i);
propertyMap.put(prop.getId(), Boolean.toString(button.getSelection()));
} else if (fPropertyControls.get(i) instanceof Combo) {
Combo combo = (Combo) fPropertyControls.get(i);
int index = combo.getSelectionIndex();
if (index > 0) {
// is there a selection?
propertyMap.put(prop.getId(), combo.getItem(index));
} else {
propertyMap.put(prop.getId(), combo.getText());
}
} else {
Text text = (Text) fPropertyControls.get(i);
propertyMap.put(prop.getId(), text.getText());
}
}
return propertyMap;
}
use of org.eclipse.jst.server.generic.servertype.definition.Property in project webtools.servertools by eclipse.
the class ServerPropertiesEditorSection method updateControls.
protected void updateControls() {
List props = fServer.getServerDefinition().getProperty();
for (Iterator iter = props.iterator(); iter.hasNext(); ) {
Property property = (Property) iter.next();
if (property.getContext().equals(Property.CONTEXT_SERVER)) {
if (Property.TYPE_BOOLEAN.equals(property.getType())) {
Button b = (Button) fControls.get(property.getId());
// $NON-NLS-1$
b.setSelection("true".equals(getPropertyValue(property)));
} else if (Property.TYPE_SELECT.equals(property.getType()) || Property.TYPE_SELECT_EDIT.equals(property.getType())) {
Combo c = (Combo) fControls.get(property.getId());
// $NON-NLS-1$
String value = getPropertyValue(property) == null ? "" : getPropertyValue(property);
// c.setText( getPropertyValue( property ) );
// responding to "value not used" msg, I'm assuming value
// should be used as in following block.
c.setText(value);
} else {
Text t = (Text) fControls.get(property.getId());
// $NON-NLS-1$
String value = getPropertyValue(property) == null ? "" : getPropertyValue(property);
t.setText(value);
}
}
}
}
Aggregations