Search in sources :

Example 1 with Property

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);
}
Also used : StringTokenizer(java.util.StringTokenizer) HashMap(java.util.HashMap) ServerRuntime(org.eclipse.jst.server.generic.servertype.definition.ServerRuntime) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.eclipse.jst.server.generic.servertype.definition.Property)

Example 2 with Property

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;
}
Also used : HashMap(java.util.HashMap) Iterator(java.util.Iterator) Property(org.eclipse.jst.server.generic.servertype.definition.Property)

Example 3 with Property

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;
}
Also used : Iterator(java.util.Iterator) Property(org.eclipse.jst.server.generic.servertype.definition.Property)

Example 4 with Property

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;
}
Also used : HashMap(java.util.HashMap) Button(org.eclipse.swt.widgets.Button) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.eclipse.jst.server.generic.servertype.definition.Property)

Example 5 with Property

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);
            }
        }
    }
}
Also used : Button(org.eclipse.swt.widgets.Button) Iterator(java.util.Iterator) List(java.util.List) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) Property(org.eclipse.jst.server.generic.servertype.definition.Property)

Aggregations

Property (org.eclipse.jst.server.generic.servertype.definition.Property)12 Iterator (java.util.Iterator)9 List (java.util.List)6 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Button (org.eclipse.swt.widgets.Button)2 Combo (org.eclipse.swt.widgets.Combo)2 Text (org.eclipse.swt.widgets.Text)2 StringTokenizer (java.util.StringTokenizer)1 Classpath (org.eclipse.jst.server.generic.servertype.definition.Classpath)1 ServerRuntime (org.eclipse.jst.server.generic.servertype.definition.ServerRuntime)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)1 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)1 Section (org.eclipse.ui.forms.widgets.Section)1 ServerEditorSection (org.eclipse.wst.server.ui.editor.ServerEditorSection)1