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

COVERAGE SUMMARY FOR SOURCE FILE [DockStatusViewer.java]

nameclass, %method, %block, %line, %
DockStatusViewer.java0%   (0/5)0%   (0/24)0%   (0/535)0%   (0/105)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DockStatusViewer0%   (0/1)0%   (0/16)0%   (0/352)0%   (0/73)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/2)
DockStatusViewer (DockModel, Composite, int): void 0%   (0/1)0%   (0/277)0%   (0/54)
access$0 (DockStatusViewer): DockModel 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (DockStatusViewer): Image 0%   (0/1)0%   (0/3)0%   (0/1)
access$10 (): Logger 0%   (0/1)0%   (0/2)0%   (0/1)
access$2 (DockStatusViewer): Image 0%   (0/1)0%   (0/3)0%   (0/1)
access$3 (DockStatusViewer): Image 0%   (0/1)0%   (0/3)0%   (0/1)
access$4 (DockStatusViewer): Label 0%   (0/1)0%   (0/3)0%   (0/1)
access$5 (DockStatusViewer): Label 0%   (0/1)0%   (0/3)0%   (0/1)
access$6 (DockStatusViewer): Label 0%   (0/1)0%   (0/3)0%   (0/1)
access$7 (DockStatusViewer): Label 0%   (0/1)0%   (0/3)0%   (0/1)
access$8 (DockStatusViewer): ProgressBar 0%   (0/1)0%   (0/3)0%   (0/1)
access$9 (DockStatusViewer): Canvas 0%   (0/1)0%   (0/3)0%   (0/1)
checkSubclass (): void 0%   (0/1)0%   (0/1)0%   (0/1)
showSimuDockView (): void 0%   (0/1)0%   (0/7)0%   (0/2)
update (Observable, Object): void 0%   (0/1)0%   (0/31)0%   (0/4)
     
class DockStatusViewer$10%   (0/1)0%   (0/2)0%   (0/47)0%   (0/11)
DockStatusViewer$1 (DockStatusViewer): void 0%   (0/1)0%   (0/6)0%   (0/2)
paintControl (PaintEvent): void 0%   (0/1)0%   (0/41)0%   (0/9)
     
class DockStatusViewer$20%   (0/1)0%   (0/2)0%   (0/14)0%   (0/4)
DockStatusViewer$2 (DockStatusViewer, DockModel): void 0%   (0/1)0%   (0/9)0%   (0/2)
widgetSelected (SelectionEvent): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class DockStatusViewer$30%   (0/1)0%   (0/2)0%   (0/99)0%   (0/16)
DockStatusViewer$3 (DockStatusViewer): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/93)0%   (0/14)
     
class DockStatusViewer$40%   (0/1)0%   (0/2)0%   (0/23)0%   (0/8)
DockStatusViewer$4 (): void 0%   (0/1)0%   (0/3)0%   (0/2)
run (): void 0%   (0/1)0%   (0/20)0%   (0/6)

1package de.uka.ipd.sdq.codegen.simucontroller.gui;
2 
3import java.text.DecimalFormat;
4import java.util.Observable;
5import java.util.Observer;
6 
7import org.apache.log4j.Logger;
8import org.eclipse.swt.SWT;
9import org.eclipse.swt.events.PaintEvent;
10import org.eclipse.swt.events.PaintListener;
11import org.eclipse.swt.events.SelectionAdapter;
12import org.eclipse.swt.events.SelectionEvent;
13import org.eclipse.swt.graphics.Image;
14import org.eclipse.swt.layout.FillLayout;
15import org.eclipse.swt.layout.GridData;
16import org.eclipse.swt.layout.GridLayout;
17import org.eclipse.swt.widgets.Button;
18import org.eclipse.swt.widgets.Canvas;
19import org.eclipse.swt.widgets.Composite;
20import org.eclipse.swt.widgets.Group;
21import org.eclipse.swt.widgets.Label;
22import org.eclipse.swt.widgets.ProgressBar;
23import org.eclipse.ui.IViewPart;
24import org.eclipse.ui.PartInitException;
25import org.eclipse.ui.PlatformUI;
26 
27import swing2swt.layout.BorderLayout;
28import de.uka.ipd.sdq.codegen.simucontroller.SimuControllerImages;
29import de.uka.ipd.sdq.codegen.simucontroller.dockmodel.DockModel;
30 
31public class DockStatusViewer extends Composite implements Observer {
32        /** Logger for this class. */
33        private static final Logger logger = Logger.getLogger(DockStatusViewer.class);
34 
35        private Image idle_image;
36        private DockModel model;
37        private Label simTimeLabel;
38        private Label measurementsLabel;
39        private ProgressBar progressBar;
40        private Label remoteLocationLabel;
41        private Label dockIdLabel;
42        private Image running_image;
43        private Image pause_image;
44        private Canvas iconCanvas;
45        private int lastUIUpdate = -1;
46 
47        /**
48         * Create the composite
49         * @param parent
50         * @param style
51         */
52        public DockStatusViewer(final DockModel model, Composite parent, int style) {
53                super(parent, style);
54                this.model = model;
55                model.addObserver(this);
56 
57                setLayout(new BorderLayout(0, 0));
58 
59                final Composite composite = new Composite(this, SWT.NONE);
60                composite.setLayout(new FillLayout());
61 
62                iconCanvas = new Canvas(composite, SWT.NONE);
63 
64                final Composite composite_1 = new Composite(this, SWT.NONE);
65                composite_1.setLayoutData(BorderLayout.SOUTH);
66                composite_1.setLayout(new FillLayout());
67 
68                final Group statusGroup = new Group(composite_1, SWT.NONE);
69                final GridLayout gridLayout = new GridLayout();
70                gridLayout.marginRight = 100;
71                gridLayout.numColumns = 4;
72                statusGroup.setLayout(gridLayout);
73                statusGroup.setText("Status");
74 
75                final Label idLabel = new Label(statusGroup, SWT.NONE);
76                idLabel.setText("ID:");
77 
78                dockIdLabel = new Label(statusGroup, SWT.NONE);
79                final GridData gd_dockIdLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
80                dockIdLabel.setLayoutData(gd_dockIdLabel);
81                dockIdLabel.setText("Label");
82 
83                final Label locationLabel = new Label(statusGroup, SWT.NONE);
84                locationLabel.setLayoutData(new GridData());
85                locationLabel.setText("Location:");
86 
87                remoteLocationLabel = new Label(statusGroup, SWT.NONE);
88                remoteLocationLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
89                remoteLocationLabel.setText("Label");
90 
91                final Label simulationTimeLabel = new Label(statusGroup, SWT.NONE);
92                simulationTimeLabel.setText("Simulation Time:");
93 
94                simTimeLabel = new Label(statusGroup, SWT.NONE);
95                simTimeLabel.setLayoutData(new GridData(83, SWT.DEFAULT));
96                simTimeLabel.setText("Label");
97 
98                final Label measurementsLabelLabel = new Label(statusGroup, SWT.NONE);
99                measurementsLabelLabel.setLayoutData(new GridData());
100                measurementsLabelLabel.setText("Measurements:");
101 
102                measurementsLabel = new Label(statusGroup, SWT.NONE);
103                final GridData gd_measurementsLabel = new GridData(SWT.LEFT, SWT.CENTER, true, false);
104                gd_measurementsLabel.widthHint = 93;
105                measurementsLabel.setLayoutData(gd_measurementsLabel);
106                measurementsLabel.setText("Label");
107 
108                progressBar = new ProgressBar(statusGroup, SWT.NONE);
109                final GridData gd_progressBar = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
110                progressBar.setLayoutData(gd_progressBar);
111                //
112 
113                idle_image = SimuControllerImages.imageRegistry.get(SimuControllerImages.MASCHINE);
114                running_image = SimuControllerImages.imageRegistry.get(SimuControllerImages.MASCHINE_BUSY);
115                pause_image = SimuControllerImages.imageRegistry.get(SimuControllerImages.MASCHINE_PAUSE);
116                iconCanvas.addPaintListener(new PaintListener(){
117 
118                        public void paintControl(PaintEvent e) {
119                                Image image = null;
120 
121                                if (DockStatusViewer.this.model.isIdle())
122                                        image = idle_image;
123                                else if (DockStatusViewer.this.model.isSuspended() && !DockStatusViewer.this.model.isStepping())
124                                        image = pause_image;
125                                else
126                                        image = running_image;
127                                if (!image.isDisposed())
128                                        e.gc.drawImage(image, 0, 0);
129                        }
130 
131                });
132 
133                final Button stopButton = new Button(composite, SWT.NONE);
134                stopButton.addSelectionListener(new SelectionAdapter() {
135                        public void widgetSelected(final SelectionEvent e) {
136                                model.getService().stopSimulation();
137                        }
138                });
139                stopButton.setText("Stop!");
140 
141                update(model,null);
142        }
143 
144        @Override
145        protected void checkSubclass() {
146                // Disable the check that prevents subclassing of SWT components
147        }
148 
149        public void update(Observable o, Object arg) {
150                if (model.getPercentDone() != lastUIUpdate  || model.isStepping() || model.isSuspended() || model.isIdle()) {
151                        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable(){
152 
153                                public void run() {
154                                        showSimuDockView();
155                                        if (!dockIdLabel.isDisposed())
156                                                dockIdLabel.setText(model.getID());
157                                        if (!remoteLocationLabel.isDisposed())
158                                                remoteLocationLabel.setText(model.getRemoteMaschineURI() == null ? "<local>" : model.getRemoteMaschineURI());
159                                        if (!measurementsLabel.isDisposed())
160                                                measurementsLabel.setText(model.getMeasurementCount()+"");
161                                        if (!simTimeLabel.isDisposed())
162                                                simTimeLabel.setText(new DecimalFormat("0.#").format(model.getSimTime()));
163                                        if (!progressBar.isDisposed())
164                                                progressBar.setSelection(model.getPercentDone());
165                                        if (!iconCanvas.isDisposed())
166                                                iconCanvas.redraw();
167 
168                                }
169 
170                        });
171                }
172                lastUIUpdate = model.getPercentDone();
173        }
174 
175        public static void showSimuDockView() {
176                PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){
177 
178                        public void run() {
179                                IViewPart viewer;
180                                try {
181                                        viewer = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockStatusViewPart.ID);
182                                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(viewer);
183                                        viewer.setFocus();
184                                } catch (PartInitException e) {
185                                        logger.warn("Could not show SimuDockView and set focus to it.", e);
186                                }
187                        }
188 
189                });
190        }
191 
192}

[all classes][de.uka.ipd.sdq.codegen.simucontroller.gui]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov