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;
17 //import org.eclipse.jface.text.Assert;
18 import org.eclipse.core.runtime.Assert;
19 import org.eclipse.jface.text.templates.TemplateVariable;
24 public class MultiVariable extends TemplateVariable {
25 private final Map fValueMap = new HashMap();
29 private Object fDefaultKey = null;
31 public MultiVariable(String type, String defaultValue, int[] offsets) {
32 super(type, defaultValue, offsets);
33 fValueMap.put(fDefaultKey, new String[] { defaultValue });
34 fSet = getDefaultValue();
38 * Sets the values of this variable under a specific set.
41 * the set identifier for which the values are valid
43 * the possible values of this variable
45 public void setValues(Object set, String[] values) {
46 Assert.isNotNull(set);
47 Assert.isTrue(values.length > 0);
48 fValueMap.put(set, values);
49 if (fDefaultKey == null) {
51 fSet = getDefaultValue();
56 * @see org.eclipse.jface.text.templates.TemplateVariable#setValues(java.lang.String[])
58 public void setValues(String[] values) {
59 if (fValueMap != null) {
60 Assert.isNotNull(values);
61 Assert.isTrue(values.length > 0);
62 fValueMap.put(fDefaultKey, values);
63 fSet = getDefaultValue();
68 * @see org.eclipse.jface.text.templates.TemplateVariable#getValues()
70 public String[] getValues() {
71 return (String[]) fValueMap.get(fDefaultKey);
75 * Returns the choices for the set identified by <code>set</code>.
79 * @return the choices for this variable and the given set, or
80 * <code>null</code> if the set is not defined.
82 public String[] getValues(Object set) {
83 return (String[]) fValueMap.get(set);
89 public Object getSet() {
93 public void setSet(Object set) {