Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 418883 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jubula.client.ui.rcp/plugin.xml (-22 / +5 lines)
Lines 144-156 Link Here
144
          properties="isPasteAllowed"
144
          properties="isPasteAllowed"
145
          type="java.util.Collection">
145
          type="java.util.Collection">
146
    </propertyTester>
146
    </propertyTester>
147
    <propertyTester
148
          class="org.eclipse.jubula.client.ui.rcp.propertytester.ImageViewPropertyTester"
149
          id="org.eclipse.jubula.client.ui.rcp.propertytester.ImageViewPropertyTester"
150
          namespace="org.eclipse.jubula.client.ui.rcp.ImageView"
151
          properties="hasImage"
152
          type="org.eclipse.jubula.client.core.model.TestResultNode">
153
    </propertyTester>
154
  </extension>
147
  </extension>
155
  <extension
148
  <extension
156
    id="jbMarker"
149
    id="jbMarker"
Lines 1979-1999 Link Here
1979
      class="org.eclipse.jubula.client.ui.rcp.handlers.SaveImageAsHandler"
1972
      class="org.eclipse.jubula.client.ui.rcp.handlers.SaveImageAsHandler"
1980
      commandId="org.eclipse.jubula.client.ui.commands.SaveImageAs">
1973
      commandId="org.eclipse.jubula.client.ui.commands.SaveImageAs">
1981
     <enabledWhen>
1974
     <enabledWhen>
1982
     <and>
1975
        <with variable="activeContexts">
1983
         <count
1976
            <iterate ifEmpty="false" operator="or">
1984
              value="1">
1977
                <equals value="org.eclipse.jubula.client.ui.contexts.ImageViewDisplaysImage"/>
1985
         </count>
1978
            </iterate>
1986
         <iterate
1979
        </with>     
1987
             ifEmpty="false"
1988
             operator="or">
1989
             <and>
1990
                <instanceof
1991
                      value="org.eclipse.jubula.client.core.model.TestResultNode">
1992
                </instanceof>
1993
                <test property="org.eclipse.jubula.client.ui.rcp.ImageView.hasImage"/>
1994
             </and>
1995
         </iterate>
1996
     </and>
1997
     </enabledWhen>
1980
     </enabledWhen>
1998
  </handler>
1981
  </handler>
1999
    <handler
1982
    <handler
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/SaveImageAsHandler.java (-54 / +27 lines)
Lines 12-34 package org.eclipse.jubula.client.ui.rcp.handlers; Link Here
12
12
13
import org.apache.commons.lang.StringUtils;
13
import org.apache.commons.lang.StringUtils;
14
import org.eclipse.core.commands.ExecutionEvent;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.jface.viewers.IStructuredSelection;
15
import org.eclipse.jubula.client.ui.constants.Constants;
16
import org.eclipse.jubula.client.core.model.TestResultNode;
17
import org.eclipse.jubula.client.ui.handlers.AbstractSelectionBasedHandler;
16
import org.eclipse.jubula.client.ui.handlers.AbstractSelectionBasedHandler;
18
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
17
import org.eclipse.jubula.client.ui.views.imageview.ImageView;
19
import org.eclipse.jubula.tools.messagehandling.MessageIDs;
18
import org.eclipse.jubula.client.ui.views.imageview.ImageViewData;
20
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.graphics.ImageData;
21
import org.eclipse.swt.graphics.ImageLoader;
21
import org.eclipse.swt.widgets.FileDialog;
22
import org.eclipse.swt.widgets.FileDialog;
23
import org.eclipse.ui.IViewPart;
22
import org.eclipse.ui.handlers.HandlerUtil;
24
import org.eclipse.ui.handlers.HandlerUtil;
23
25
24
import java.io.File;
25
import java.io.FileNotFoundException;
26
import java.io.FileOutputStream;
27
import java.io.IOException;
28
import java.io.OutputStream;
29
import java.text.DateFormat;
30
import java.text.SimpleDateFormat;
31
32
/**
26
/**
33
 * @author BREDEX GmbH
27
 * @author BREDEX GmbH
34
 * @created 11.09.2013
28
 * @created 11.09.2013
Lines 36-97 import java.text.SimpleDateFormat; Link Here
36
public class SaveImageAsHandler extends AbstractSelectionBasedHandler {
30
public class SaveImageAsHandler extends AbstractSelectionBasedHandler {
37
31
38
    /**
32
    /**
39
     * suggest only 255 character long file names
40
     */
41
    private static final int MAX_FILE_NAME_LENGTH = 255;
42
43
    /**
44
     * {@inheritDoc}
33
     * {@inheritDoc}
45
     */
34
     */
46
    protected Object executeImpl(ExecutionEvent event) {
35
    protected Object executeImpl(ExecutionEvent event) {
47
        IStructuredSelection structuredSelection = getSelection();
36
        IViewPart view = HandlerUtil.getActiveSite(event).
48
        Object selectedObject = structuredSelection.getFirstElement();
37
                getPage().findView(Constants.IMAGEVIEW_ID);
49
        if (selectedObject instanceof TestResultNode) {
38
        
50
            TestResultNode result = (TestResultNode) selectedObject;
39
        if (view != null && view instanceof ImageView) {            
51
40
            ImageView imageView = (ImageView)view;
52
            // necessary to get test suite name
41
            int maxFileNameLength = 255;
53
            TestResultNode parent = result;
42
            
54
            while (parent.getParent() != null) {
43
            ImageViewData imageViewData = imageView.getImageViewData();
55
                parent = parent.getParent();
44
            String imageName = imageViewData.getImageName();
56
            }
45
            String imageDate = imageViewData.getImageDate();
57
46
                        
58
            // get the date of test from time stamp
59
            DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
60
            String date = format.format(result.getTimeStamp());
61
62
            FileDialog saveDialog = new FileDialog(HandlerUtil
47
            FileDialog saveDialog = new FileDialog(HandlerUtil
63
                    .getActiveWorkbenchWindow(event).getShell(), SWT.SAVE);
48
                    .getActiveWorkbenchWindow(event).getShell(), SWT.SAVE);
64
            String fileName = "ErrorInTest_" + parent.getName() + "_" //$NON-NLS-1$ //$NON-NLS-2$
49
            String fileEnding = "_" + imageDate + ".png"; //$NON-NLS-1$ //$NON-NLS-2$
65
                                + result.getNode().getName();
50
            String fileName = StringUtils.substring(imageName, 0,
66
            // eliminate whitespaces and characters which are illegal in a file name
51
                    maxFileNameLength
67
            fileName = fileName.replaceAll("[\\s\\?\\\\/:|<>\\*\"]", ""); //$NON-NLS-1$ //$NON-NLS-2$
68
69
            String fileEnding = "_" + date + ".png"; //$NON-NLS-1$ //$NON-NLS-2$
70
            fileName = StringUtils.substring(fileName, 0,
71
                    MAX_FILE_NAME_LENGTH
72
                    - fileEnding.length()
52
                    - fileEnding.length()
73
                    - saveDialog.getFilterPath().length());
53
                    - saveDialog.getFilterPath().length());
74
            fileName = fileName + fileEnding;
54
            fileName = fileName + fileEnding;
55
            
75
            saveDialog.setFileName(fileName);
56
            saveDialog.setFileName(fileName);
76
            saveDialog.setFilterExtensions(new String[] { "*.png" }); //$NON-NLS-1$
57
            saveDialog.setFilterExtensions(new String[] { "*.png" }); //$NON-NLS-1$
77
            saveDialog.setOverwrite(true);
58
            saveDialog.setOverwrite(true);
78
            String path = saveDialog.open();
59
            String path = saveDialog.open();
79
60
61
            ImageData imageData = imageViewData.getImage().getImageData();
62
            
80
            if (path != null) {
63
            if (path != null) {
81
                if (result.getScreenshot() != null) {
64
                if (imageData != null) {
82
                    try {
65
                    ImageLoader loader = new ImageLoader();
83
                        File file = new File(path);
66
                    loader.data = new ImageData[] { imageData };
84
                        OutputStream out = new FileOutputStream(file);
67
                    loader.save(path, SWT.IMAGE_PNG);
85
                        out.write(result.getScreenshot());
86
                        out.flush();
87
                        out.close();
88
                    } catch (FileNotFoundException e) {
89
                        ErrorHandlingUtil.createMessageDialog(MessageIDs.
90
                                E_FILE_NO_PERMISSION);
91
                    } catch (IOException e) {
92
                        ErrorHandlingUtil.createMessageDialog(MessageIDs.
93
                                E_IO_EXCEPTION);
94
                    }
95
                }
68
                }
96
            }
69
            }
97
        }
70
        }
(-)a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/propertytester/ImageViewPropertyTester.java (-53 lines)
Lines 1-53 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2013 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.rcp.propertytester;
12
13
import org.eclipse.jubula.client.core.model.TestResultNode;
14
import org.eclipse.jubula.client.core.propertytester.AbstractBooleanPropertyTester;
15
16
/**
17
 * PropertyTester for TestResultSummary.
18
 *
19
 * @author BREDEX GmbH
20
 * @created Sep 13, 2013
21
 */
22
public class ImageViewPropertyTester
23
    extends AbstractBooleanPropertyTester {
24
    /** the id of the "hasMonitoringData" property */
25
    private static final String HAS_IMAGE = "hasImage"; //$NON-NLS-1$
26
27
    /**
28
     * <code>PROPERTIES</code>
29
     */
30
    private static final String[] PROPERTIES = new String[] {
31
        HAS_IMAGE };
32
33
    /** {@inheritDoc} */
34
    public boolean testImpl(Object receiver, String property, Object[] args) {
35
        if (property.equals(HAS_IMAGE)) {
36
            TestResultNode node = (TestResultNode) receiver;
37
            if (node.getScreenshot() != null) {
38
                return true;
39
            }
40
        }
41
        return false;
42
    }
43
44
    /** {@inheritDoc} */
45
    public Class<? extends Object> getType() {
46
        return TestResultNode.class;
47
    }
48
49
    /** {@inheritDoc} */
50
    public String[] getProperties() {
51
        return PROPERTIES;
52
    }
53
}
(-)a/org.eclipse.jubula.client.ui/META-INF/MANIFEST.MF (+1 lines)
Lines 46-50 Export-Package: org.eclipse.jubula.client.ui.adapter, Link Here
46
 org.eclipse.jubula.client.ui.utils,
46
 org.eclipse.jubula.client.ui.utils,
47
 org.eclipse.jubula.client.ui.validator.cell,
47
 org.eclipse.jubula.client.ui.validator.cell,
48
 org.eclipse.jubula.client.ui.views,
48
 org.eclipse.jubula.client.ui.views,
49
 org.eclipse.jubula.client.ui.views.imageview,
49
 org.eclipse.jubula.client.ui.widgets
50
 org.eclipse.jubula.client.ui.widgets
50
Bundle-Activator: org.eclipse.jubula.client.ui.Plugin
51
Bundle-Activator: org.eclipse.jubula.client.ui.Plugin
(-)a/org.eclipse.jubula.client.ui/plugin.xml (+8 lines)
Lines 351-354 Link Here
351
           <adapter type="org.eclipse.ui.views.properties.IPropertySource" />
351
           <adapter type="org.eclipse.ui.views.properties.IPropertySource" />
352
        </factory>
352
        </factory>
353
	</extension>
353
	</extension>
354
    <extension
355
          point="org.eclipse.ui.contexts">
356
       <context
357
             id="org.eclipse.jubula.client.ui.contexts.ImageViewDisplaysImage"
358
             name="org.eclipse.jubula.client.ui.contexts.ImageViewDisplaysImage"
359
             parentId="org.eclipse.ui.contexts.dialogAndWindow">
360
       </context>
361
    </extension>
354
</plugin>
362
</plugin>
(-)a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/constants/Constants.java (+7 lines)
Lines 129-134 public interface Constants { Link Here
129
        "org.eclipse.jubula.client.ui.rcp.views.RunningAuts"; //$NON-NLS-1$
129
        "org.eclipse.jubula.client.ui.rcp.views.RunningAuts"; //$NON-NLS-1$
130
    
130
    
131
    //  -------------------------------------------------------------
131
    //  -------------------------------------------------------------
132
    //  Keys for Contexts
133
    //  -------------------------------------------------------------
134
    /** if there is an image displayed in the image view */
135
    public static final String IMAGEVIEW_DISPLAYS_IMAGE = 
136
        "org.eclipse.jubula.client.ui.contexts.ImageViewDisplaysImage"; //$NON-NLS-1$
137
    
138
    //  -------------------------------------------------------------
132
    //  decorator ids
139
    //  decorator ids
133
    //  -------------------------------------------------------------
140
    //  -------------------------------------------------------------
134
    /** ID of the completeness check decorator */
141
    /** ID of the completeness check decorator */
(-)a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/imageview/ImageProvider.java (-2 / +1 lines)
Lines 11-17 Link Here
11
package org.eclipse.jubula.client.ui.views.imageview;
11
package org.eclipse.jubula.client.ui.views.imageview;
12
12
13
import org.eclipse.swt.graphics.Device;
13
import org.eclipse.swt.graphics.Device;
14
import org.eclipse.swt.graphics.Image;
15
14
16
/**
15
/**
17
 * @author BREDEX GmbH
16
 * @author BREDEX GmbH
Lines 28-32 public interface ImageProvider { Link Here
28
     * 
27
     * 
29
     * @return {@link Image}
28
     * @return {@link Image}
30
     */
29
     */
31
    Image getImage(Device target);
30
    ImageViewData getImageViewData(Device target);
32
}
31
}
(-)a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/imageview/ImageView.java (-13 / +43 lines)
Lines 17-26 import org.eclipse.core.runtime.IStatus; Link Here
17
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.core.runtime.Status;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.jobs.Job;
19
import org.eclipse.core.runtime.jobs.Job;
20
import org.eclipse.jface.action.MenuManager;
20
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.ISelectionChangedListener;
22
import org.eclipse.jface.viewers.ISelectionChangedListener;
22
import org.eclipse.jface.viewers.ISelectionProvider;
23
import org.eclipse.jface.viewers.ISelectionProvider;
23
import org.eclipse.jface.viewers.IStructuredSelection;
24
import org.eclipse.jface.viewers.IStructuredSelection;
25
import org.eclipse.jubula.client.ui.constants.Constants;
24
import org.eclipse.jubula.client.ui.i18n.Messages;
26
import org.eclipse.jubula.client.ui.i18n.Messages;
25
import org.eclipse.jubula.client.ui.utils.JobUtils;
27
import org.eclipse.jubula.client.ui.utils.JobUtils;
26
import org.eclipse.jubula.client.ui.views.IJBPart;
28
import org.eclipse.jubula.client.ui.views.IJBPart;
Lines 41-49 import org.eclipse.swt.widgets.Menu; Link Here
41
import org.eclipse.ui.ISelectionListener;
43
import org.eclipse.ui.ISelectionListener;
42
import org.eclipse.ui.ISelectionService;
44
import org.eclipse.ui.ISelectionService;
43
import org.eclipse.ui.IWorkbenchPart;
45
import org.eclipse.ui.IWorkbenchPart;
46
import org.eclipse.ui.contexts.IContextActivation;
47
import org.eclipse.ui.contexts.IContextService;
44
import org.eclipse.ui.part.ViewPart;
48
import org.eclipse.ui.part.ViewPart;
45
import org.eclipse.ui.views.properties.IPropertySheetPage;
49
import org.eclipse.ui.views.properties.IPropertySheetPage;
46
import org.eclipse.jface.action.MenuManager;
47
50
48
51
49
/**
52
/**
Lines 59-66 public class ImageView extends ViewPart implements IJBPart, ISelectionProvider { Link Here
59
    /**
62
    /**
60
     * the image
63
     * the image
61
     */
64
     */
62
    private Image m_img;
65
    private ImageViewData m_imgData;
63
    
66
   
64
    /**
67
    /**
65
     * <code>m_oldSelection</code>
68
     * <code>m_oldSelection</code>
66
     */
69
     */
Lines 77-82 public class ImageView extends ViewPart implements IJBPart, ISelectionProvider { Link Here
77
    private Composite m_child;
80
    private Composite m_child;
78
    
81
    
79
    /**
82
    /**
83
     * context activation
84
     */
85
    private IContextActivation m_contextActivation;
86
    
87
    /**
80
     * The selectionListener listens for changes in the workbench's selection
88
     * The selectionListener listens for changes in the workbench's selection
81
     * service.
89
     * service.
82
     */
90
     */
Lines 212-228 public class ImageView extends ViewPart implements IJBPart, ISelectionProvider { Link Here
212
    protected void setImage(final ImageProvider provider) {
220
    protected void setImage(final ImageProvider provider) {
213
        m_scrollComposite.getDisplay().syncExec(new Runnable() {
221
        m_scrollComposite.getDisplay().syncExec(new Runnable() {
214
222
223
215
            public void run() {
224
            public void run() {
216
                clearImage();
225
                clearImage();
217
                m_img = provider.getImage(m_scrollComposite.getDisplay());
226
                m_imgData = provider.getImageViewData(
218
                m_imgWidget.setImage(m_img);
227
                        m_scrollComposite.getDisplay());
219
                if (m_img != null) {
228
                if (m_imgData != null) {
220
                    m_imgWidget.setSize(
229
                    Image img = m_imgData.getImage();
221
                            m_img.getBounds().width,
230
                    m_imgWidget.setImage(img);
222
                            m_img.getBounds().height);
231
                    if (img != null) {
232
                        m_imgWidget.setSize(
233
                                img.getBounds().width,
234
                                img.getBounds().height);
235
                        IContextService cs = (IContextService) getSite().
236
                                getWorkbenchWindow().
237
                                getService(IContextService.class);  
238
                        m_contextActivation = cs.activateContext(
239
                                Constants.IMAGEVIEW_DISPLAYS_IMAGE);
240
                    }
241
                    m_scrollComposite.setMinSize(m_child.computeSize(
242
                            SWT.DEFAULT, SWT.DEFAULT));
223
                }
243
                }
224
                m_scrollComposite.setMinSize(m_child.computeSize(SWT.DEFAULT,
225
                        SWT.DEFAULT));
226
            }
244
            }
227
        });
245
        });
228
    }
246
    }
Lines 236-241 public class ImageView extends ViewPart implements IJBPart, ISelectionProvider { Link Here
236
        if (oldImage != null) {
254
        if (oldImage != null) {
237
            oldImage.dispose();
255
            oldImage.dispose();
238
        }
256
        }
257
        
258
        IContextService cs = (IContextService) getSite().
259
                getService(IContextService.class);  
260
        cs.deactivateContext(m_contextActivation);
239
    }
261
    }
240
    
262
    
241
    /**
263
    /**
Lines 243-250 public class ImageView extends ViewPart implements IJBPart, ISelectionProvider { Link Here
243
     */
265
     */
244
    public void dispose() {
266
    public void dispose() {
245
        getSelectionService().removeSelectionListener(m_selectionListener);
267
        getSelectionService().removeSelectionListener(m_selectionListener);
246
        if (m_img != null) {
268
        if (m_imgData != null) {
247
            m_img.dispose();
269
            m_imgData.dispose();
248
        }
270
        }
249
        super.dispose();
271
        super.dispose();
250
    }
272
    }
Lines 300-303 public class ImageView extends ViewPart implements IJBPart, ISelectionProvider { Link Here
300
        }
322
        }
301
        return super.getAdapter(key);
323
        return super.getAdapter(key);
302
    }
324
    }
325
    
326
    /**
327
     * returns the data of the displayed image
328
     * @return the image data
329
     */
330
    public ImageViewData getImageViewData() {
331
        return m_imgData;
332
    }
303
}
333
}
(-)a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/imageview/ImageViewData.java (+78 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2013 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.views.imageview;
12
13
import org.eclipse.swt.graphics.Image;
14
15
/**
16
 * Class representing an image from the image view and its data 
17
 * @author BREDEX GmbH
18
 * @created Nov 08, 2013
19
 */
20
public class ImageViewData {
21
    /**
22
     * the image
23
     */
24
    private Image m_img;
25
    
26
    /**
27
     * the name of the image
28
     */
29
    private String m_imgName;
30
    
31
    /**
32
     * the date of the image
33
     */
34
    private String m_imgDate;
35
    
36
    /**
37
     * constructor
38
     * @param img the image 
39
     * @param name the name of the image
40
     * @param date the date of the image
41
     */
42
    public ImageViewData(Image img, String name, String date) {
43
        m_img = img;
44
        m_imgName = name;
45
        m_imgDate = date;
46
    }
47
    
48
    /**
49
     * returns the image
50
     * @return the image
51
     */
52
    public Image getImage() {
53
        return m_img;
54
    }
55
    
56
    /**
57
     * returns the name of the image
58
     * @return the name of the image
59
     */
60
    public String getImageName() {
61
        return m_imgName;
62
    }
63
64
    /**
65
     * returns the date of the image
66
     * @return the date of the image
67
     */
68
    public String getImageDate() {
69
        return m_imgDate;
70
    }
71
72
    /**
73
     * Disposes the image.
74
     */
75
    public void dispose() {
76
        m_img.dispose();
77
    }
78
}
(-)a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/imageview/TestResultNodeImageProvider.java (-6 / +38 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jubula.client.ui.views.imageview;
11
package org.eclipse.jubula.client.ui.views.imageview;
12
12
13
import java.text.DateFormat;
14
import java.text.SimpleDateFormat;
15
13
import org.eclipse.jubula.client.core.model.TestResultNode;
16
import org.eclipse.jubula.client.core.model.TestResultNode;
14
import org.eclipse.jubula.client.ui.utils.ImageUtils;
17
import org.eclipse.jubula.client.ui.utils.ImageUtils;
15
import org.eclipse.swt.graphics.Device;
18
import org.eclipse.swt.graphics.Device;
Lines 33-47 public class TestResultNodeImageProvider implements ImageProvider { Link Here
33
    public TestResultNodeImageProvider(TestResultNode testresultnode) {
36
    public TestResultNodeImageProvider(TestResultNode testresultnode) {
34
        m_testResultNode = testresultnode;
37
        m_testResultNode = testresultnode;
35
    }
38
    }
36
39
    
37
    /**
40
    /**
38
     * {@inheritDoc}
41
     * {@inheritDoc}
39
     */
42
     */
40
    public Image getImage(Device target) {
43
    public ImageViewData getImageViewData(Device target) {
41
        if (m_testResultNode.getScreenshot() != null) {
44
        byte[] screenshot = m_testResultNode.getScreenshot();
42
            return new Image(target, ImageUtils.getImageData(m_testResultNode
45
        if (screenshot != null) {
43
                    .getScreenshot()));
46
            Image img = new Image(target, ImageUtils.getImageData(screenshot));
47
            return new ImageViewData(img, generateImageName(), 
48
                    generateImageDate());
44
        }
49
        }
45
        return null;
50
        return null;
46
    }
51
    }
52
    
53
    /**
54
     * generates the name of the image
55
     * @return the name of the image
56
     */
57
    private String generateImageName() {
58
        TestResultNode parent = m_testResultNode;
59
        while (parent.getParent() != null) {
60
            parent = parent.getParent();
61
        }
62
        
63
        String imgName = "ErrorInTest_" + parent.getName() + "_" //$NON-NLS-1$ //$NON-NLS-2$
64
                              + m_testResultNode.getNode().getName();
65
        // eliminate whitespaces and characters which are illegal in a file name
66
        imgName = imgName.replaceAll("[\\s\\?\\\\/:|<>\\*\"]", ""); //$NON-NLS-1$ //$NON-NLS-2$
67
        return imgName;
68
    }
69
    
70
    /**
71
     * generates the date of the image
72
     * @return the date of the image
73
     */
74
    private String generateImageDate() {
75
        // get the date of test from time stamp
76
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss-SSS"); //$NON-NLS-1$
77
        String date = format.format(m_testResultNode.getTimeStamp());
78
        return date;
79
    }
47
}
80
}
48
- 

Return to bug 418883