1 | package de.uka.ipd.sdq.sensorframework.dialogs.dataset; |
2 | |
3 | |
4 | import org.eclipse.jface.wizard.WizardDialog; |
5 | import org.eclipse.swt.events.SelectionAdapter; |
6 | import org.eclipse.swt.events.SelectionEvent; |
7 | import org.eclipse.swt.widgets.Shell; |
8 | |
9 | import de.uka.ipd.sdq.sensorframework.SensorFrameworkDataset; |
10 | import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory; |
11 | |
12 | /** @author Roman Andrej */ |
13 | public class ConfigureDatasourceDialog extends DatasourceDialog { |
14 | |
15 | public static String OPEN_WISARD_TITLE = "Load a source storage for the sensor framework."; |
16 | public static String ADD_WIZARD_TITLE = "Select/create a storage for the sensor framework."; |
17 | |
18 | public ConfigureDatasourceDialog(Shell parentShell, String dialogTitel, boolean makeValidation) { |
19 | super(parentShell, dialogTitel, SensorFrameworkDataset |
20 | .singleton().getDataSources(), makeValidation); |
21 | create(); |
22 | setRemoveButtonAction(new SelectionAdapter() { |
23 | |
24 | /* (non-Javadoc) |
25 | * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
26 | */ |
27 | @Override |
28 | public void widgetSelected(SelectionEvent e) { |
29 | IDAOFactory selectedSource = (IDAOFactory) getResult(); |
30 | SensorFrameworkDataset.singleton().removeDataSource( |
31 | selectedSource); |
32 | refresh(); |
33 | } |
34 | }); |
35 | |
36 | setAddButtonAction(new SelectionAdapter(){ |
37 | |
38 | /* (non-Javadoc) |
39 | * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
40 | */ |
41 | @Override |
42 | public void widgetSelected(SelectionEvent e) { |
43 | AddNewDatasourceWizard w = new AddNewDatasourceWizard(); |
44 | //w.init(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getWorkbench(), |
45 | // null); |
46 | // Instantiates the wizard container with the wizard and opens it |
47 | WizardDialog dialog = new WizardDialog(e.display.getActiveShell(), w); |
48 | dialog.create(); |
49 | dialog.setTitle(ADD_WIZARD_TITLE); |
50 | dialog.open(); |
51 | refresh(); |
52 | } |
53 | |
54 | }); |
55 | |
56 | setOpenButtonAction(new SelectionAdapter(){ |
57 | |
58 | /* (non-Javadoc) |
59 | * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
60 | */ |
61 | @Override |
62 | public void widgetSelected(SelectionEvent e) { |
63 | |
64 | OpenDatasourceWizard w = new OpenDatasourceWizard(); |
65 | |
66 | // Instantiates the wizard container with the wizard and opens it |
67 | WizardDialog dialog = new WizardDialog(e.display |
68 | .getActiveShell(), w); |
69 | dialog.create(); |
70 | dialog.setTitle(OPEN_WISARD_TITLE); |
71 | dialog.open(); |
72 | refresh(); |
73 | } |
74 | }); |
75 | } |
76 | } |