1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
13 import java.util.HashMap;
16 import org.eclipse.jface.text.Assert;
17 import org.eclipse.jface.text.templates.TemplateVariable;
22 public class MultiVariable extends TemplateVariable {
23 private final Map fValueMap = new HashMap();
27 private Object fDefaultKey = null;
29 public MultiVariable(String type, String defaultValue, int[] offsets) {
30 super(type, defaultValue, offsets);
31 fValueMap.put(fDefaultKey, new String[] { defaultValue });
32 fSet = getDefaultValue();
36 * Sets the values of this variable under a specific set.
39 * the set identifier for which the values are valid
41 * the possible values of this variable
43 public void setValues(Object set, String[] values) {
44 Assert.isNotNull(set);
45 Assert.isTrue(values.length > 0);
46 fValueMap.put(set, values);
47 if (fDefaultKey == null) {
49 fSet = getDefaultValue();
54 * @see org.eclipse.jface.text.templates.TemplateVariable#setValues(java.lang.String[])
56 public void setValues(String[] values) {
57 if (fValueMap != null) {
58 Assert.isNotNull(values);
59 Assert.isTrue(values.length > 0);
60 fValueMap.put(fDefaultKey, values);
61 fSet = getDefaultValue();
66 * @see org.eclipse.jface.text.templates.TemplateVariable#getValues()
68 public String[] getValues() {
69 return (String[]) fValueMap.get(fDefaultKey);
73 * Returns the choices for the set identified by <code>set</code>.
77 * @return the choices for this variable and the given set, or
78 * <code>null</code> if the set is not defined.
80 public String[] getValues(Object set) {
81 return (String[]) fValueMap.get(set);
87 public Object getSet() {
91 public void setSet(Object set) {