id="eu.etaxonomy.taxeditor.uuidParameterType"
type="java.util.UUID">
</commandParameterType>
+ <commandParameterType
+ converter="eu.etaxonomy.taxeditor.handler.UuidsParameterTypeConverter"
+ id="eu.etaxonomy.taxeditor.uuidsParameterType"
+ type="java.util.List">
+ </commandParameterType>
</extension>
<extension
point="org.eclipse.ui.importWizards">
package eu.etaxonomy.taxeditor.handler;
+import java.util.ArrayList;
+import java.util.List;
import java.util.UUID;
import org.eclipse.core.commands.AbstractParameterValueConverter;
import org.eclipse.core.commands.ParameterValueConversionException;
/**
- * Converts {@link UUID}s to a string representation
+ * Converts either a single {@link UUID} or a list of UUIDSs to a string representation
* and vica versa.
*
* @author pplitzner
*/
public class UuidsParameterTypeConverter extends AbstractParameterValueConverter {
+ private static final String SEPARATOR = ",";
+
public UuidsParameterTypeConverter() {
}
@Override
public Object convertToObject(String parameterValue) throws ParameterValueConversionException {
- return UUID.fromString(parameterValue);
+ if(parameterValue.endsWith(SEPARATOR)){
+ List<UUID> uuids = new ArrayList<UUID>();
+ String[] split = parameterValue.split(SEPARATOR);
+ for (String string : split) {
+ uuids.add(UUID.fromString(string));
+ }
+ return uuids;
+ }
+ else{
+ return UUID.fromString(parameterValue);
+ }
}
@Override
public String convertToString(Object parameterValue) throws ParameterValueConversionException {
- return parameterValue.toString();
+ if(parameterValue instanceof List){
+ List list = (List)parameterValue;
+ String stringList = "";
+ for (Object object : list) {
+ stringList += parameterValue.toString()+SEPARATOR;
+ }
+ }
+ else if(parameterValue instanceof UUID){
+ return parameterValue.toString();
+ }
+ else{
+ throw new ParameterValueConversionException("Parameter is of wrong type: "+parameterValue.getClass().toString());
+ }
+ return null;
}
}
\ No newline at end of file