connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ToggleDiscoveryAgentAction.java
equal
deleted
inserted
replaced
|
1 /** |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.remoteconnections.internal; |
|
19 |
|
20 import org.eclipse.core.runtime.CoreException; |
|
21 import org.eclipse.jface.action.Action; |
|
22 import org.eclipse.jface.action.IAction; |
|
23 |
|
24 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
|
25 import com.nokia.carbide.remoteconnections.internal.api.IDeviceDiscoveryAgent; |
|
26 |
|
27 public class ToggleDiscoveryAgentAction extends Action { |
|
28 |
|
29 private final IDeviceDiscoveryAgent agent; |
|
30 |
|
31 public ToggleDiscoveryAgentAction(IDeviceDiscoveryAgent agent) { |
|
32 this.agent = agent; |
|
33 setChecked(agent.isRunning()); |
|
34 } |
|
35 |
|
36 @Override |
|
37 public void run() { |
|
38 try { |
|
39 if (agent.isRunning()) |
|
40 agent.stop(); |
|
41 else |
|
42 agent.start(); |
|
43 setChecked(agent.isRunning()); |
|
44 } catch (CoreException e) { |
|
45 RemoteConnectionsActivator.logError(e); |
|
46 } |
|
47 } |
|
48 |
|
49 @Override |
|
50 public int getStyle() { |
|
51 return IAction.AS_CHECK_BOX; |
|
52 } |
|
53 |
|
54 @Override |
|
55 public String getText() { |
|
56 return agent.getDisplayName(); |
|
57 } |
|
58 } |
|
59 |