|
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.cdt.internal.debug.launch.newwizard; |
|
19 |
|
20 import java.text.MessageFormat; |
|
21 |
|
22 import org.eclipse.core.runtime.Status; |
|
23 import org.eclipse.swt.widgets.Composite; |
|
24 import org.eclipse.swt.widgets.Shell; |
|
25 |
|
26 import com.nokia.cdt.internal.debug.launch.newwizard.LaunchOptionsData.EExeSelection; |
|
27 import com.nokia.cpp.internal.api.utils.core.PathUtils; |
|
28 |
|
29 /** |
|
30 * |
|
31 */ |
|
32 public class DebugRunProcessSection extends AbstractLaunchWizardSection { |
|
33 |
|
34 public DebugRunProcessSection(LaunchOptionsData data) { |
|
35 super(data, MessageFormat.format("{0} process", data.getModeLabel())); |
|
36 } |
|
37 |
|
38 /* (non-Javadoc) |
|
39 * @see com.nokia.cdt.internal.debug.launch.wizard2.IWizardSection#createComposite(org.eclipse.swt.widgets.Composite) |
|
40 */ |
|
41 @Override |
|
42 public void createControl(Composite parent) { |
|
43 createSection(parent, 1); |
|
44 } |
|
45 |
|
46 /* (non-Javadoc) |
|
47 * @see com.nokia.cdt.internal.debug.launch.wizard2.AbstractLaunchWizardSection#dispose() |
|
48 */ |
|
49 @Override |
|
50 protected void dispose() { |
|
51 |
|
52 } |
|
53 |
|
54 @Override |
|
55 public void initializeSettings() { |
|
56 data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); |
|
57 if (data.getExes().size() > 0) |
|
58 data.setExeSelectionPath(data.getExes().get(0)); |
|
59 else if (data.getDefaultExecutable() != null) |
|
60 data.setExeSelectionPath(data.getDefaultExecutable()); |
|
61 } |
|
62 |
|
63 /* (non-Javadoc) |
|
64 * @see com.nokia.cdt.internal.debug.launch.wizard2.AbstractLaunchWizardSection#createChangeSettingsDialog(org.eclipse.swt.widgets.Shell, com.nokia.cdt.internal.debug.launch.wizard2.LaunchOptionsData) |
|
65 */ |
|
66 @Override |
|
67 protected AbstractLaunchSettingsDialog createChangeSettingsDialog( |
|
68 Shell shell, LaunchOptionsData dialogData) { |
|
69 return new DebugRunProcessDialog(shell, dialogData); |
|
70 } |
|
71 |
|
72 /* (non-Javadoc) |
|
73 * @see com.nokia.cdt.internal.debug.launch.wizard2.AbstractLaunchWizardSection#refresh() |
|
74 */ |
|
75 @Override |
|
76 protected void refresh() { |
|
77 updateUI(); |
|
78 } |
|
79 |
|
80 /* (non-Javadoc) |
|
81 * @see com.nokia.cdt.internal.debug.launch.wizard2.AbstractLaunchWizardSection#validate() |
|
82 */ |
|
83 @Override |
|
84 protected void validate() { |
|
85 |
|
86 status = Status.OK_STATUS; |
|
87 |
|
88 switch (data.getExeSelection()) { |
|
89 case USE_PROJECT_EXECUTABLE: |
|
90 if (data.getExeSelectionPath() == null) |
|
91 status = error("This project does not build any executables.", |
|
92 data.getModeLabel().toLowerCase()); |
|
93 break; |
|
94 case USE_REMOTE_EXECUTABLE: |
|
95 if (data.getExeSelectionPath() == null) |
|
96 status = error("No remote executable is selected.", |
|
97 data.getModeLabel().toLowerCase()); |
|
98 break; |
|
99 case ATTACH_TO_PROCESS: |
|
100 break; |
|
101 } |
|
102 |
|
103 // TODO: package |
|
104 } |
|
105 |
|
106 @Override |
|
107 protected void updateUI() { |
|
108 |
|
109 validate(); |
|
110 |
|
111 if (status.isOK()) { |
|
112 String mainFormat = "Carbide will {0} and {1}."; |
|
113 String copyOrInstallMsg = ""; |
|
114 String runOrLaunchMsg = ""; |
|
115 |
|
116 switch (data.getExeSelection()) { |
|
117 case USE_PROJECT_EXECUTABLE: |
|
118 runOrLaunchMsg = "launch '" + data.getExeSelectionPath().lastSegment() + "'"; |
|
119 break; |
|
120 case USE_REMOTE_EXECUTABLE: |
|
121 runOrLaunchMsg = "launch '" + PathUtils.convertPathToWindows(data.getExeSelectionPath()) + "'"; |
|
122 break; |
|
123 case ATTACH_TO_PROCESS: |
|
124 runOrLaunchMsg = "attach to a process selected at launch time"; |
|
125 break; |
|
126 } |
|
127 |
|
128 copyOrInstallMsg = "copy files to the device"; |
|
129 |
|
130 String runOrDebugProcessMessage = MessageFormat.format(mainFormat, copyOrInstallMsg, runOrLaunchMsg); |
|
131 descriptionLabel.setText(runOrDebugProcessMessage); |
|
132 } else { |
|
133 descriptionLabel.setText(status.getMessage() + "\n\n" + |
|
134 MessageFormat.format("Click the 'Change...' button to select another {0} method.", |
|
135 data.getModeLabel().toLowerCase())); |
|
136 } |
|
137 } |
|
138 |
|
139 } |