KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > memory > renderings > ErrorRendering


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 IBM Corporation and others.
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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.views.memory.renderings;
12
13 import org.eclipse.debug.internal.ui.DebugUIMessages;
14 import org.eclipse.debug.ui.DebugUITools;
15 import org.eclipse.debug.ui.memory.AbstractMemoryRendering;
16 import org.eclipse.jface.text.Document;
17 import org.eclipse.jface.text.TextViewer;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.custom.StyledText;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.swt.widgets.Control;
22
23 /**
24  * A dummy rendering for displaying an error message in a view tab.
25  * @since 3.1
26  */

27 /**
28  * @author chanskw
29  *
30  */

31 public class ErrorRendering extends AbstractMemoryRendering {
32
33     private TextViewer fTextViewer;
34     private String JavaDoc fRenderingId;
35     private Throwable JavaDoc fException;
36     
37     /**
38      * @param renderingId - id of rendering that the memory view has failed
39      * to create.
40      */

41     public ErrorRendering(String JavaDoc renderingId, Throwable JavaDoc exception)
42     {
43         super("org.eclipse.debug.internal.ui.views.memory.errorrendering"); //$NON-NLS-1$
44
fRenderingId = renderingId;
45         fException = exception;
46     }
47     
48     /* (non-Javadoc)
49      * @see org.eclipse.debug.ui.memory.IMemoryRendering#createControl(org.eclipse.swt.widgets.Composite)
50      */

51     public Control createControl(Composite parent) {
52         fTextViewer = new TextViewer(parent, SWT.READ_ONLY);
53         fTextViewer.setDocument(new Document());
54         StyledText styleText = fTextViewer.getTextWidget();
55         
56         styleText.setText("\r\n\r\n" + DebugUIMessages.EmptyViewTab_Unable_to_create + "\n" + getRenderingName() + "\n\n" + DebugUIMessages.ErrorRendering_0 + fException.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
57

58         
59         return fTextViewer.getControl();
60     }
61     
62
63     /**
64      *
65      */

66     private String JavaDoc getRenderingName() {
67         
68         if (DebugUITools.getMemoryRenderingManager().getRenderingType(fRenderingId)!= null)
69         {
70             String JavaDoc name =
71                 DebugUITools.getMemoryRenderingManager()
72                 .getRenderingType(fRenderingId)
73                 .getLabel();
74             
75             return name;
76         }
77         return "Unknown"; //$NON-NLS-1$
78
}
79
80     /* (non-Javadoc)
81      * @see org.eclipse.debug.internal.ui.memory.AbstractMemoryRendering#getControl()
82      */

83     public Control getControl() {
84         return fTextViewer.getControl();
85     }
86
87     public void refresh() {
88     }
89
90 }
91
Popular Tags