EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.sensorframework.dialogs.dataset]

COVERAGE SUMMARY FOR SOURCE FILE [AddNewDatasourceWizard.java]

nameclass, %method, %block, %line, %
AddNewDatasourceWizard.java0%   (0/2)0%   (0/8)0%   (0/185)0%   (0/51)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AddNewDatasourceWizard0%   (0/1)0%   (0/6)0%   (0/165)0%   (0/44)
AddNewDatasourceWizard (): void 0%   (0/1)0%   (0/6)0%   (0/3)
addPages (): void 0%   (0/1)0%   (0/42)0%   (0/11)
canFinish (): boolean 0%   (0/1)0%   (0/30)0%   (0/7)
getNextPage (IWizardPage): IWizardPage 0%   (0/1)0%   (0/24)0%   (0/7)
getResult (): String 0%   (0/1)0%   (0/3)0%   (0/1)
performFinish (): boolean 0%   (0/1)0%   (0/60)0%   (0/15)
     
class AddNewDatasourceWizard$ErrorDisplayRunner0%   (0/1)0%   (0/2)0%   (0/20)0%   (0/7)
AddNewDatasourceWizard$ErrorDisplayRunner (AddNewDatasourceWizard, Throwable)... 0%   (0/1)0%   (0/9)0%   (0/4)
run (): void 0%   (0/1)0%   (0/11)0%   (0/3)

1package de.uka.ipd.sdq.sensorframework.dialogs.dataset;
2 
3import org.eclipse.core.resources.ResourcesPlugin;
4import org.eclipse.core.runtime.IPath;
5import org.eclipse.core.runtime.IStatus;
6import org.eclipse.jface.dialogs.MessageDialog;
7import org.eclipse.jface.viewers.TreeSelection;
8import org.eclipse.jface.wizard.IWizardPage;
9import org.eclipse.jface.wizard.Wizard;
10import org.eclipse.ui.PlatformUI;
11import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
12import org.eclipse.ui.dialogs.WizardNewFolderMainPage;
13 
14import de.uka.ipd.sdq.dialogs.error.ErrorDisplayDialog;
15import de.uka.ipd.sdq.sensorframework.SensorFrameworkDataset;
16import de.uka.ipd.sdq.sensorframework.dao.file.FileDAOFactory;
17import de.uka.ipd.sdq.sensorframework.dao.memory.MemoryDAOFactory;
18import de.uka.ipd.sdq.sensorframework.dialogs.SensorFrameworkDialogPlugin;
19import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory;
20 
21public class AddNewDatasourceWizard extends Wizard {
22 
23        private WizardNewFolderMainPage newFolderPage;
24        private WizardNewFileCreationPage newDBpage;
25        private String result;
26        private WizardSelectDatasourcePage selectTypePage;
27 
28        public AddNewDatasourceWizard() {
29                super();
30                this.setWindowTitle("Select/create datastore...");
31        }
32 
33        
34        /* (non-Javadoc)
35         * @see org.eclipse.jface.wizard.Wizard#addPages()
36         */
37        @Override
38        public void addPages() {
39                super.addPages();
40 
41                selectTypePage = new WizardSelectDatasourcePage(
42                                "Select Type of Datasource to create", true, true, true);
43                this.addPage(selectTypePage);
44 
45                newDBpage = new WizardNewFileCreationPage("Create new database",
46                                new TreeSelection());
47                this.addPage(newDBpage);
48 
49                newFolderPage = new WizardNewFolderMainPage(
50                                "Create new data directory", new TreeSelection());
51                this.addPage(newFolderPage);
52        }
53 
54        
55        /* (non-Javadoc)
56         * @see org.eclipse.jface.wizard.Wizard#performFinish()
57         */
58        @Override
59        public boolean performFinish() {
60                
61                if (selectTypePage.getResult().equals("Memory Datasource")) {
62                        
63                        SensorFrameworkDataset.singleton().addDataSource(
64                                        new MemoryDAOFactory(""));
65                        
66                } else if (selectTypePage.getResult().equals("File Datasource")) {
67                        
68                        IPath selectedWorkspacePath = newFolderPage.createNewFolder().getFullPath();
69                        IPath targetDirectory = ResourcesPlugin.getWorkspace().getRoot().getFile(selectedWorkspacePath).getLocation();
70                        try {
71                                IDAOFactory fileFactory = new FileDAOFactory(targetDirectory.toOSString()); 
72                                SensorFrameworkDataset.singleton().addDataSource(
73                                                fileFactory);
74                        } catch (Exception ex) {
75                                MessageDialog.openError(getShell(), "File DAO factory error.",
76                                                ex.getMessage());
77                                SensorFrameworkDialogPlugin.log(IStatus.ERROR, ex.getMessage() == null ? "" : ex.getMessage());
78                                return false;
79                        }
80                }
81                return true;
82        }
83 
84        
85        /* (non-Javadoc)
86         * @see org.eclipse.jface.wizard.Wizard#canFinish()
87         */
88        @Override
89        public boolean canFinish() {
90                if (selectTypePage.getResult().equals("Memory Datasource")) {
91                        return true;
92                } else if (selectTypePage.getResult().equals("DB4O Datasource")) {
93                        return newDBpage.isPageComplete();
94                } else if (selectTypePage.getResult().equals("File Datasource")) {
95                        return newFolderPage.isPageComplete();
96                }
97                return false;
98        }
99        
100        
101        /* (non-Javadoc)
102         * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage)
103         */
104        @Override
105        public IWizardPage getNextPage(IWizardPage page) {
106                if (page instanceof WizardSelectDatasourcePage) {
107                        
108                        WizardSelectDatasourcePage data_type_page = (WizardSelectDatasourcePage) page;
109                        
110                        if (data_type_page.getResult().equals("DB4O Datasource")) {
111                                return newDBpage;
112                        } else if (data_type_page.getResult().equals("File Datasource")) {
113                                return newFolderPage;
114                        }
115                }
116                return null;
117        }
118 
119        public String getResult() {
120                return result;
121        }
122        
123        private class ErrorDisplayRunner implements Runnable {
124                private Throwable e;
125 
126                /**
127                 * @param e the throwable to display in the error
128                 * display dialog
129                 */
130                public ErrorDisplayRunner(Throwable e) {
131                        super();
132                        this.e = e;
133                }
134 
135                public void run() {
136                        new ErrorDisplayDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
137                                        .getShell(), e).open();
138                }
139        }
140        
141}
142 

[all classes][de.uka.ipd.sdq.sensorframework.dialogs.dataset]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov