|
1 /* |
|
2 * Copyright (c) 2009 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 "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.s60tools.hticonnection.actions; |
|
19 |
|
20 import org.eclipse.jface.action.IAction; |
|
21 import org.eclipse.jface.window.Window; |
|
22 |
|
23 import com.nokia.carbide.remoteconnections.interfaces.IConnection; |
|
24 import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard; |
|
25 import com.nokia.s60tools.hticonnection.HtiApiActivator; |
|
26 import com.nokia.s60tools.hticonnection.connection.HTIService; |
|
27 import com.nokia.s60tools.hticonnection.core.HtiConnection; |
|
28 import com.nokia.s60tools.hticonnection.core.HtiConnection.ConnectionStatus; |
|
29 import com.nokia.s60tools.hticonnection.resources.Messages; |
|
30 |
|
31 /** |
|
32 * Action for creating new connection or selecting currently used connection. |
|
33 */ |
|
34 @SuppressWarnings("restriction") |
|
35 public class NewConnectionAction extends S60ToolsBaseAction { |
|
36 |
|
37 /** |
|
38 * Constructor. |
|
39 */ |
|
40 public NewConnectionAction() { |
|
41 super(Messages.getString("NewConnectionAction.NewConnection_Action_Text"), //$NON-NLS-1$ |
|
42 Messages.getString("NewConnectionAction.NewConnection_Action_Tooltip"), //$NON-NLS-1$ |
|
43 IAction.AS_PUSH_BUTTON, |
|
44 null); |
|
45 } |
|
46 |
|
47 /* (non-Javadoc) |
|
48 * @see com.nokia.s60tools.hticonnection.actions.S60ToolsBaseAction#run() |
|
49 */ |
|
50 public void run() { |
|
51 // Creating new settings wizard for HTI Connection. |
|
52 SettingsWizard wizard = new SettingsWizard(null, new HTIService()); |
|
53 int result = wizard.open(HtiApiActivator.getCurrentlyActiveWbWindowShell()); |
|
54 if(result == Window.OK) { |
|
55 // Wizard was completed successfully. Starting connection with new connection. |
|
56 IConnection connection = wizard.getConnectionToEdit(); |
|
57 HtiConnection htiConnection = HtiConnection.getInstance(); |
|
58 if(htiConnection.getConnectionStatus() != ConnectionStatus.SHUTDOWN) { |
|
59 htiConnection.stopConnection(); |
|
60 } |
|
61 // Starting new connection. |
|
62 htiConnection.setCurrentConnection(connection, false); |
|
63 htiConnection.startConnection(false); |
|
64 } |
|
65 } |
|
66 } |