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

COVERAGE SUMMARY FOR SOURCE FILE [MarkovResultEditor.java]

nameclass, %method, %block, %line, %
MarkovResultEditor.java0%   (0/1)0%   (0/9)0%   (0/114)0%   (0/40)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MarkovResultEditor0%   (0/1)0%   (0/9)0%   (0/114)0%   (0/40)
MarkovResultEditor (): void 0%   (0/1)0%   (0/3)0%   (0/1)
createPartControl (Composite): void 0%   (0/1)0%   (0/43)0%   (0/14)
doSave (IProgressMonitor): void 0%   (0/1)0%   (0/1)0%   (0/1)
doSaveAs (): void 0%   (0/1)0%   (0/1)0%   (0/1)
getFileContent (IEditorInput): String 0%   (0/1)0%   (0/54)0%   (0/17)
init (IEditorSite, IEditorInput): void 0%   (0/1)0%   (0/7)0%   (0/3)
isDirty (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
isSaveAsAllowed (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
setFocus (): void 0%   (0/1)0%   (0/1)0%   (0/1)

1package de.uka.ipd.sdq.reliability.solver.visualisation;
2 
3import java.io.BufferedReader;
4import java.io.FileNotFoundException;
5import java.io.FileReader;
6import java.io.IOException;
7 
8import org.eclipse.core.runtime.IProgressMonitor;
9import org.eclipse.swt.SWT;
10import org.eclipse.swt.browser.Browser;
11import org.eclipse.swt.widgets.Composite;
12import org.eclipse.ui.IEditorInput;
13import org.eclipse.ui.IEditorSite;
14import org.eclipse.ui.PartInitException;
15import org.eclipse.ui.part.EditorPart;
16import org.eclipse.ui.part.FileEditorInput;
17 
18public class MarkovResultEditor extends EditorPart {
19 
20        @Override
21        public void createPartControl(Composite parent) {
22                IEditorInput input = getEditorInput();
23                Browser browser = new Browser(parent, SWT.BORDER);
24                browser.setJavascriptEnabled(true);
25                if (input != null) {
26                        if (input instanceof MarkovResultEditorInput) {
27                                // display HTML code in browser
28                                browser
29                                                .setText(((MarkovResultEditorInput) input)
30                                                                .getHtmlCode());
31                        } else {
32                                // see if we can extract HTML code from the given input
33                                String fileContent = getFileContent(input);
34                                if (fileContent.trim().startsWith("<html>")) {
35                                        // assume we have an HTML file and try to display it
36                                        browser.setText(fileContent);
37                                } else {
38                                        browser
39                                                        .setText("<html><head><title>Markov Results</title></head>"
40                                                                        + "<body><font color=\"red\">Error:"
41                                                                        + " The given editor input could not be handled.</font>"
42                                                                        + "</body></html>");
43                                }
44                        }
45                }
46        }
47 
48        @Override
49        public void doSave(IProgressMonitor monitor) {
50                // TODO Auto-generated method stub
51 
52        }
53 
54        @Override
55        public void doSaveAs() {
56                // TODO Auto-generated method stub
57 
58        }
59 
60        private String getFileContent(IEditorInput input) {
61                StringBuilder fileContent = null;
62                if (input instanceof FileEditorInput) {
63                        FileEditorInput fileEditorInput = (FileEditorInput) input;
64                        try {
65                                FileReader fileReader = new FileReader(fileEditorInput
66                                                .getPath().toOSString());
67                                BufferedReader in = new BufferedReader(fileReader);
68                                String line = null;
69                                fileContent = new StringBuilder();
70                                String newLine = System.getProperty("line.separator");
71                                try {
72                                        while ((line = in.readLine()) != null) {
73                                                fileContent.append(line);
74                                                fileContent.append(newLine);
75                                        }
76                                } catch (IOException e) {
77                                        e.printStackTrace();
78                                }
79                        } catch (FileNotFoundException e) {
80                                e.printStackTrace();
81                        }
82                }
83                return fileContent.toString();
84        }
85 
86        @Override
87        public void init(IEditorSite site, IEditorInput input)
88                        throws PartInitException {
89                setSite(site);
90                setInput(input);
91        }
92 
93        @Override
94        public boolean isDirty() {
95                // TODO Auto-generated method stub
96                return false;
97        }
98 
99        @Override
100        public boolean isSaveAsAllowed() {
101                // TODO Auto-generated method stub
102                return false;
103        }
104 
105        @Override
106        public void setFocus() {
107                // TODO Auto-generated method stub
108 
109        }
110 
111}

[all classes][de.uka.ipd.sdq.reliability.solver.visualisation]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov