40 import org.eclipse.swt.widgets.FileDialog; |
40 import org.eclipse.swt.widgets.FileDialog; |
41 import org.eclipse.swt.widgets.Table; |
41 import org.eclipse.swt.widgets.Table; |
42 import org.eclipse.swt.widgets.TableColumn; |
42 import org.eclipse.swt.widgets.TableColumn; |
43 |
43 |
44 import com.nokia.carbide.cpp.pi.PiPlugin; |
44 import com.nokia.carbide.cpp.pi.PiPlugin; |
|
45 import com.nokia.carbide.cpp.pi.wizards.WizardsPlugin; |
45 |
46 |
46 /** |
47 /** |
47 * Provides content of the profile data file selection from file system group |
48 * Provides content of the profile data file selection from file system group |
48 */ |
49 */ |
49 public class FileSelectionGroup extends AbstractBaseGroup { |
50 public class FileSelectionGroup extends AbstractBaseGroup { |
50 |
51 |
51 private TableViewer profileDataTable; |
52 private TableViewer profileDataTable; |
|
53 private PluginSelectionGroup pluginSelectionGroup; |
52 |
54 |
53 /** |
55 /** |
54 * Constructor |
56 * Constructor |
55 * |
57 * |
56 * @param parent instance of the parent composite |
58 * @param parent instance of the parent composite |
57 * @param wizardSettings instance of the INewPIWizardSettings |
59 * @param wizardSettings instance of the INewPIWizardSettings |
58 */ |
60 */ |
59 public FileSelectionGroup(Composite parent, |
61 public FileSelectionGroup(Composite parent, |
60 INewPIWizardSettings wizardSettings) { |
62 INewPIWizardSettings wizardSettings) { |
61 super(parent, wizardSettings); |
63 super(parent, wizardSettings, false); |
62 } |
64 } |
63 |
65 |
64 /* |
66 /* |
65 * (non-Javadoc) |
67 * (non-Javadoc) |
66 * @see com.nokia.carbide.cpp.internal.pi.wizards.ui.AbstractBaseGroup#createContent() |
68 * @see com.nokia.carbide.cpp.internal.pi.wizards.ui.AbstractBaseGroup#createContent() |
127 }); |
129 }); |
128 |
130 |
129 profileDataTable.addSelectionChangedListener(new ISelectionChangedListener() { |
131 profileDataTable.addSelectionChangedListener(new ISelectionChangedListener() { |
130 public void selectionChanged(SelectionChangedEvent event) { |
132 public void selectionChanged(SelectionChangedEvent event) { |
131 if(profileDataTable.getTable().getSelectionCount() == 1){ |
133 if(profileDataTable.getTable().getSelectionCount() == 1){ |
|
134 pluginSelectionGroup.updateTraceIds(getSelectedItem()); |
132 wizardSettings.validatePage(); |
135 wizardSettings.validatePage(); |
133 |
136 |
134 } |
137 } |
135 } |
138 } |
136 }); |
139 }); |
198 String path = dialog.open(); |
201 String path = dialog.open(); |
199 if(path != null){ |
202 if(path != null){ |
200 IPath folder = new Path(path).removeLastSegments(1); |
203 IPath folder = new Path(path).removeLastSegments(1); |
201 for(String fileName: dialog.getFileNames()){ |
204 for(String fileName: dialog.getFileNames()){ |
202 try { |
205 try { |
203 addProfileDataFile(folder.append(fileName)); |
206 addProfilerDataFile(folder.append(fileName),0,0); |
204 } catch (IllegalArgumentException iae) { |
207 } catch (IllegalArgumentException iae) { |
205 IStatus status = new Status(Status.ERROR, |
208 IStatus status = new Status(Status.ERROR, |
206 PiPlugin.PLUGIN_ID, iae.getMessage()); |
209 PiPlugin.PLUGIN_ID, iae.getMessage()); |
207 ErrorDialog.openError(getShell(), |
210 ErrorDialog.openError(getShell(), |
208 Messages.getString("FileSelectionGroup.performanceInvestigator"), null, status); //$NON-NLS-1$ |
211 Messages.getString("FileSelectionGroup.performanceInvestigator"), null, status); //$NON-NLS-1$ |
209 } |
212 } |
210 } |
213 } |
211 refreshTable(profileDataTable); |
214 refreshTable(profileDataTable, true); |
212 } |
215 } |
213 } |
216 } |
214 }); |
217 }); |
215 |
218 |
216 // Add folder button |
219 // Add folder button |
228 .setText(Messages.getString("FileSelectionGroup.dialogDirectoryTitle")); //$NON-NLS-1$ |
231 .setText(Messages.getString("FileSelectionGroup.dialogDirectoryTitle")); //$NON-NLS-1$ |
229 String result = dialog.open(); |
232 String result = dialog.open(); |
230 if (result != null) { |
233 if (result != null) { |
231 try { |
234 try { |
232 addDirectory(new Path(result)); |
235 addDirectory(new Path(result)); |
233 refreshTable(profileDataTable); |
236 refreshTable(profileDataTable, true); |
234 |
237 |
235 } catch (IllegalArgumentException iae) { |
238 } catch (IllegalArgumentException iae) { |
236 IStatus status = new Status(Status.ERROR, |
239 IStatus status = new Status(Status.ERROR, |
237 PiPlugin.PLUGIN_ID, iae.getMessage()); |
240 PiPlugin.PLUGIN_ID, iae.getMessage()); |
238 ErrorDialog.openError(getShell(), |
241 ErrorDialog.openError(getShell(), |
248 removeOneButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
251 removeOneButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
249 removeOneButton.setText(Messages.getString("FileSelectionGroup.actionRemove")); //$NON-NLS-1$ |
252 removeOneButton.setText(Messages.getString("FileSelectionGroup.actionRemove")); //$NON-NLS-1$ |
250 removeOneButton.addSelectionListener(new SelectionAdapter() { |
253 removeOneButton.addSelectionListener(new SelectionAdapter() { |
251 public void widgetSelected(SelectionEvent e) { |
254 public void widgetSelected(SelectionEvent e) { |
252 removeSelectedItem(profileDataTable); |
255 removeSelectedItem(profileDataTable); |
253 refreshTable(profileDataTable); |
256 refreshTable(profileDataTable, true); |
254 } |
257 } |
255 |
258 |
256 }); |
259 }); |
257 |
260 |
258 // Remove all files and folders button |
261 // Remove all files and folders button |
261 removeAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
264 removeAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
262 removeAllButton.setText(Messages.getString("FileSelectionGroup.actionRemoveAll")); //$NON-NLS-1$ |
265 removeAllButton.setText(Messages.getString("FileSelectionGroup.actionRemoveAll")); //$NON-NLS-1$ |
263 removeAllButton.addSelectionListener(new SelectionAdapter() { |
266 removeAllButton.addSelectionListener(new SelectionAdapter() { |
264 public void widgetSelected(SelectionEvent e) { |
267 public void widgetSelected(SelectionEvent e) { |
265 removeAll(); |
268 removeAll(); |
266 refreshTable(profileDataTable); |
269 refreshTable(profileDataTable, true); |
267 } |
270 } |
268 |
271 |
269 }); |
272 }); |
|
273 pluginSelectionGroup = new PluginSelectionGroup(this,wizardSettings, false); |
270 } |
274 } |
271 |
275 |
272 /* |
276 /* |
273 * (non-Javadoc) |
277 * (non-Javadoc) |
274 * @see com.nokia.carbide.cpp.internal.pi.wizards.ui.AbstractBaseGroup#getTable() |
278 * @see com.nokia.carbide.cpp.internal.pi.wizards.ui.AbstractBaseGroup#getTable() |
275 */ |
279 */ |
276 @Override |
280 @Override |
277 public Table getTable() { |
281 public Table getTable() { |
278 return profileDataTable.getTable(); |
282 return profileDataTable.getTable(); |
279 } |
283 } |
|
284 |
|
285 |
|
286 @Override |
|
287 public IStatus validateContent(NewPIWizard wizardPage) { |
|
288 IStatus status = Status.OK_STATUS; |
|
289 if(pluginSelectionGroup != null){ |
|
290 pluginSelectionGroup.updateTraceIds(getSelectedItem()); |
|
291 wizardPage.setProfilerDataFiles(getProfilerDataFiles()); |
|
292 } |
|
293 int count = getProfilerDataFiles().size(); |
|
294 if( count > 1){ |
|
295 status = new Status(Status.WARNING, WizardsPlugin.PLUGIN_ID, Messages.getString("NewPIWizardPageInputTask.noteImportMayTakeSeveralMinutes")); //$NON-NLS-1$ |
|
296 }else if(count == 1){ |
|
297 status = new Status(Status.OK, WizardsPlugin.PLUGIN_ID,Messages.getString("NewPIWizardPageSampleFile.description")); //$NON-NLS-1$ |
|
298 }else{ |
|
299 status = new Status(Status.INFO, WizardsPlugin.PLUGIN_ID,Messages.getString("NewPIWizardPageSampleFile.description")); //$NON-NLS-1$ |
|
300 } |
|
301 return status; |
|
302 } |
280 } |
303 } |