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 179540
Collapse All | Expand All

(-)src/org/eclipse/hyades/test/ui/forms/util/EObjectTreeContentProvider.java (-2 / +2 lines)
Lines 38-45 Link Here
38
 * @author bjiang
38
 * @author bjiang
39
 * @since  4.1
39
 * @since  4.1
40
 */
40
 */
41
public class EObjectTreeContentProvider extends AdapterImpl implements	ITreeContentProvider {
41
public class EObjectTreeContentProvider extends AdapterImpl implements	ITreeContentProvider 
42
	
42
{	
43
	private EStructuralFeature eStructuralFeature;
43
	private EStructuralFeature eStructuralFeature;
44
	private EObject container;
44
	private EObject container;
45
	private Viewer viewer;
45
	private Viewer viewer;
(-)src/org/eclipse/hyades/test/ui/forms/base/LogEventsBlock.java (-2 / +6 lines)
Lines 29-34 Link Here
29
import org.eclipse.hyades.test.ui.forms.extensions.IEventAction;
29
import org.eclipse.hyades.test.ui.forms.extensions.IEventAction;
30
import org.eclipse.hyades.test.ui.forms.util.FormsUtil;
30
import org.eclipse.hyades.test.ui.forms.util.FormsUtil;
31
import org.eclipse.hyades.test.ui.forms.util.TestLogEventsContentProvider;
31
import org.eclipse.hyades.test.ui.forms.util.TestLogEventsContentProvider;
32
import org.eclipse.hyades.test.ui.forms.util.TestLogEventsLazyPathContentProvider;
32
import org.eclipse.hyades.test.ui.forms.util.TestLogVerdictCollection;
33
import org.eclipse.hyades.test.ui.forms.util.TestLogVerdictCollection;
33
import org.eclipse.hyades.test.ui.internal.editor.form.util.EventLabelProvider;
34
import org.eclipse.hyades.test.ui.internal.editor.form.util.EventLabelProvider;
34
import org.eclipse.hyades.test.ui.internal.editor.form.util.ExecutionHistoryExtensionsManager;
35
import org.eclipse.hyades.test.ui.internal.editor.form.util.ExecutionHistoryExtensionsManager;
Lines 119-125 Link Here
119
		layout.makeColumnsEqualWidth = false;
120
		layout.makeColumnsEqualWidth = false;
120
		client.setLayout(layout);
121
		client.setLayout(layout);
121
		
122
		
122
		Tree tree = toolkit.createTree(client, SWT.FULL_SELECTION | SWT.SINGLE);
123
		Tree tree = toolkit.createTree(client, SWT.FULL_SELECTION | SWT.SINGLE | SWT.VIRTUAL);
123
		GridData gd = new GridData(GridData.FILL_BOTH);
124
		GridData gd = new GridData(GridData.FILL_BOTH);
124
		gd.grabExcessVerticalSpace = true;
125
		gd.grabExcessVerticalSpace = true;
125
		gd.widthHint = 100;
126
		gd.widthHint = 100;
Lines 127-134 Link Here
127
		tree.setLayoutData(gd);
128
		tree.setLayoutData(gd);
128
		
129
		
129
		viewer = new TreeViewer(tree);		
130
		viewer = new TreeViewer(tree);		
130
		viewer.setContentProvider(new TestLogEventsContentProvider(Common_TestprofilePackage.eINSTANCE.getTPFExecutionHistory_ExecutionEvents()));
131
		//viewer.setContentProvider(new TestLogEventsContentProvider(Common_TestprofilePackage.eINSTANCE.getTPFExecutionHistory_ExecutionEvents()));
132
		viewer.setContentProvider(new TestLogEventsLazyPathContentProvider(Common_TestprofilePackage.eINSTANCE.getTPFExecutionHistory_ExecutionEvents()));
131
		viewer.setLabelProvider(new EventLabelProvider());
133
		viewer.setLabelProvider(new EventLabelProvider());
134
		viewer.setUseHashlookup(true);
135
		
132
		viewer.addSelectionChangedListener(this);
136
		viewer.addSelectionChangedListener(this);
133
		TPFExecutionResult result = (TPFExecutionResult)((TestLogViewer)formPage.getEditor()).getEditorObject();
137
		TPFExecutionResult result = (TPFExecutionResult)((TestLogViewer)formPage.getEditor()).getEditorObject();
134
		
138
		
(-)src/org/eclipse/hyades/test/ui/forms/util/TestLogEventsLazyPathContentProvider.java (+240 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
 * $Id: TestLogEventsContentProvider.java,v 1.4 2005/10/14 15:26:03 bjiang Exp $
8
 * 
9
 * Contributors:
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
package org.eclipse.hyades.test.ui.forms.util;
13
14
import java.util.Collection;
15
16
import org.eclipse.emf.ecore.EStructuralFeature;
17
import org.eclipse.hyades.models.common.testprofile.TPFExecutionEvent;
18
import org.eclipse.hyades.models.common.testprofile.TPFExecutionHistory;
19
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult;
20
import org.eclipse.hyades.models.common.testprofile.TPFInvocationEvent;
21
import org.eclipse.jface.viewers.ILazyTreePathContentProvider;
22
import org.eclipse.jface.viewers.TreePath;
23
import org.eclipse.jface.viewers.TreeViewer;
24
25
/**
26
 * This is the content provider used by TPTP Test Log Viewer Events tree.
27
 * 
28
 * @author bjiang
29
 * @author marcelop
30
 * @since  4.1
31
 */
32
public class TestLogEventsLazyPathContentProvider extends EObjectTreeContentProvider
33
				implements ILazyTreePathContentProvider
34
{
35
	/*
36
	 * (non-Javadoc)
37
	 * @see org.eclipse.hyades.test.ui.forms.util.EObjectContainerContentProvider#getRegisteredParentChild(java.lang.Object)
38
	 */
39
	protected Object getRegisteredParentChild(Object parent)
40
    {
41
        if(parent instanceof TPFExecutionResult)
42
        {
43
            TPFExecutionResult executionResult = (TPFExecutionResult)parent;
44
            if(executionResult.getExecutionHistory() != null)
45
                return executionResult.getExecutionHistory().getExecutionEvents();
46
            return null;
47
        }
48
        //added to set the parent/child hierarchy for execution events :BGB(12/2/03)
49
        else if (parent instanceof TPFExecutionEvent)
50
        {
51
            if ( parent instanceof TPFInvocationEvent )
52
            {
53
                TPFInvocationEvent invocationEvent  = (TPFInvocationEvent)parent;
54
                return( invocationEvent.getInvokedExecutionResult() );
55
            }
56
            else
57
            {
58
                TPFExecutionEvent   executionEvent  = (TPFExecutionEvent)parent;
59
                if ( ( executionEvent.getChildren() != null ) &&
60
                     ( executionEvent.getChildren().isEmpty() == false ))
61
                    return( executionEvent.getChildren());
62
            }
63
        }
64
        return null;
65
    }
66
	
67
	  
68
	public TestLogEventsLazyPathContentProvider(EStructuralFeature eStructuralFeature)
69
	{
70
		super(eStructuralFeature);
71
	}
72
	
73
	public TreePath[] getParents(Object element)
74
    {
75
		return null;
76
    }
77
    
78
	
79
    /**
80
	 * Called when a previously-blank item becomes visible in the TreeViewer.    
81
     */
82
	public void updateElement(TreePath parentPath, int index)
83
	{
84
		
85
		Object child = null;
86
		Object parent = getElement(parentPath);
87
		
88
		if (parent instanceof TPFExecutionHistory) {
89
			TPFExecutionHistory eventLog = (TPFExecutionHistory) parent;
90
			child = (TPFExecutionEvent) eventLog.getExecutionEvents().get(index);
91
		} 
92
		else if(parent instanceof TPFExecutionResult)
93
        {
94
            TPFExecutionResult executionResult = (TPFExecutionResult)parent;
95
            if(executionResult.getExecutionHistory() != null)
96
                child = executionResult.getExecutionHistory().getExecutionEvents().get(index);
97
        }
98
		
99
		else if (parent instanceof TPFExecutionEvent) {
100
			
101
            if ( parent instanceof TPFInvocationEvent )
102
            {            	
103
            	
104
                TPFInvocationEvent invocationEvent  = (TPFInvocationEvent)parent;
105
                child = invocationEvent.getInvokedExecutionResult();
106
                
107
            }
108
            else
109
            {
110
                TPFExecutionEvent   executionEvent  = (TPFExecutionEvent)parent;
111
                if ( ( executionEvent.getChildren() != null ) &&
112
                     ( executionEvent.getChildren().isEmpty() == false ))
113
                    child = (TPFExecutionEvent)executionEvent.getChildren().get(index);
114
            }
115
			
116
		}
117
	
118
//	System.out.println("update Element " + index + "\n " + parent + "\n	" + child);
119
		
120
		if (child != null) {
121
			
122
			TreeViewer treeViewer = (TreeViewer)getViewer();
123
			
124
			treeViewer.replace(parentPath, index, child);			
125
			
126
			int count = 0;
127
			Object child1 = getRegisteredParentChild(child);
128
			if(child1 != null)
129
			{
130
				if(child1 instanceof Collection)
131
					count = ((Collection)child1).size();
132
				else 
133
					count =1;
134
					
135
			}
136
		
137
		//	System.out.println("update Element child " + child.getClass().getName()  + ", " + count);
138
			
139
			treeViewer.setChildCount(child, count);
140
		}
141
	}
142
    
143
	/**
144
	 * Called when the TreeViewer needs an up-to-date child count for the given tree path
145
	*/
146
	public void updateChildCount(TreePath treePath, int currentChildCount)
147
	{
148
		
149
		Object element = getElement(treePath);
150
				
151
		int count = currentChildCount;
152
//		System.out.println("updateChildCount " + element + ", " + currentChildCount);
153
		
154
			if(element instanceof TPFExecutionHistory)
155
			{
156
				count = ((TPFExecutionHistory)element).getExecutionEvents().size();
157
			}	
158
			else if(element instanceof TPFExecutionResult)
159
	        {
160
	            TPFExecutionResult executionResult = (TPFExecutionResult)element;
161
	            if(executionResult.getExecutionHistory() != null)
162
	            {
163
	                count = executionResult.getExecutionHistory().getExecutionEvents().size();
164
	            }
165
	        }
166
			else if (element instanceof TPFExecutionEvent) {
167
				
168
	            if (!( element instanceof TPFInvocationEvent) )
169
	            {
170
	                TPFExecutionEvent   executionEvent  = (TPFExecutionEvent)element;
171
	                if ( ( executionEvent.getChildren() != null ) &&
172
	                     ( executionEvent.getChildren().isEmpty() == false ))
173
	                    count = executionEvent.getChildren().size();
174
	            }
175
				
176
			}
177
			
178
//			System.out.println("updateChildCount " + element + " : " + currentChildCount + ", " + count);
179
			
180
			if(count != currentChildCount)
181
				((TreeViewer)getViewer()).setChildCount(treePath, count);
182
			
183
		
184
	}
185
    
186
	/**
187
	 * Called when the TreeViewer needs up-to-date information whether the node
188
	 * at the given tree path can be expanded. If the content provider knows the
189
	 * element at the given tree path, it should respond by calling
190
	 * {@link TreeViewer#setHasChildren(Object, boolean)}. The content provider
191
	 * may also choose to call {@link TreeViewer#setChildCount(Object, int)}
192
	 * instead if it knows the number of children.
193
     */	
194
	public void updateHasChildren(TreePath path)
195
	{
196
		Object element = getElement(path);
197
		TreeViewer viewer = (TreeViewer)getViewer();
198
		
199
//		System.out.println("updatehasChildern " + element);
200
			if(element instanceof TPFExecutionHistory)
201
			{
202
				viewer.setChildCount(path, ((TPFExecutionHistory)element).getExecutionEvents().size());
203
			}	
204
			else if(element instanceof TPFExecutionResult)
205
	        {
206
	            TPFExecutionResult executionResult = (TPFExecutionResult)element;
207
	            if(executionResult.getExecutionHistory() != null)
208
	            {
209
					viewer.setChildCount(path, executionResult.getExecutionHistory().getExecutionEvents().size());	            	
210
	            }
211
	        }
212
			else if (element instanceof TPFExecutionEvent) {
213
				
214
	            if ( element instanceof TPFInvocationEvent) 
215
	            {
216
					viewer.setHasChildren(path, false);	            	
217
	            }
218
	            else
219
	            {
220
	                TPFExecutionEvent   executionEvent  = (TPFExecutionEvent)element;
221
					viewer.setHasChildren(path, executionEvent.getChildren() != null && executionEvent.getChildren().size() > 0);
222
	                
223
	            }				
224
			}
225
	}
226
	
227
	/**
228
	 * Returns the element corresponding to the given tree path.
229
	 * 
230
	 * @param path tree path
231
	 * @return model element
232
	 */
233
	protected Object getElement(TreePath path) {
234
		if (path.getSegmentCount() > 0) {
235
			return path.getLastSegment();
236
		}
237
		return getViewer().getInput();
238
	}
239
240
 }

Return to bug 179540