| /******************************************************************************* |
| * Copyright (c) 2009, 2010 Nokia and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Nokia - Initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.cdt.debug.edc.tcf.extension.services; |
| |
| import java.io.IOException; |
| import java.util.Collection; |
| import java.util.Collections; |
| |
| import org.eclipse.tm.tcf.core.Command; |
| import org.eclipse.tm.tcf.protocol.IChannel; |
| import org.eclipse.tm.tcf.protocol.IService; |
| import org.eclipse.tm.tcf.protocol.IServiceProvider; |
| import org.eclipse.tm.tcf.protocol.IToken; |
| import org.eclipse.tm.tcf.protocol.Protocol; |
| |
| public class SettingsProxy implements ISettings { |
| |
| private final IChannel channel; |
| |
| public SettingsProxy(IChannel channel) { |
| this.channel = channel; |
| |
| } |
| |
| public String getName() { |
| return NAME; |
| } |
| |
| /** |
| * @since 2.0 |
| */ |
| public IToken getIds(final DoneGetSettingIds done) { |
| return new Command(channel, SettingsProxy.this, "getIds", new Object[] {}) { |
| @SuppressWarnings("unchecked") |
| @Override |
| public void done(Exception error, Object[] args) { |
| Collection<String> idStrings; |
| if (args != null && args[1] != null) |
| idStrings = (Collection<String>) args[1]; |
| else |
| idStrings = Collections.emptyList(); |
| done.doneGetSettingIds(token, error, idStrings.toArray(new String[idStrings.size()])); |
| } |
| }.token; |
| } |
| |
| /** |
| * @since 2.0 |
| */ |
| public IToken setValues(String context, String[] ids, Object[] values, final DoneSetSettingValues done) { |
| return new Command(channel, SettingsProxy.this, "set", new Object[] { context, ids, values }) { |
| @Override |
| public void done(Exception error, Object[] args) { |
| if (error == null) { |
| assert args.length == 1; |
| if (args[0] != null) |
| error = toError(args[0]); |
| else |
| error = null; |
| } |
| done.doneSetSettingValues(token, error); |
| } |
| }.token; |
| } |
| } |