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

COVERAGE SUMMARY FOR SOURCE FILE [LQNResultEditor.java]

nameclass, %method, %block, %line, %
LQNResultEditor.java0%   (0/1)0%   (0/9)0%   (0/114)0%   (0/36)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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