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

(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ExecutionFileProxyNode.java (-22 / +7 lines)
Lines 15-22 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
19
import org.eclipse.ui.IMemento;
22
20
Lines 24-58 Link Here
24
 * @author jgout
22
 * @author jgout
25
 * @since 3.2
23
 * @since 3.2
26
 */
24
 */
27
public class ExecutionFileProxyNode extends EMFResourceProxyNode implements IPersistableProxyNode {
25
public class ExecutionFileProxyNode extends EMFResourceProxyNode {
28
		
26
		
29
	public ExecutionFileProxyNode(IFile file, Resource resource) {
27
	public ExecutionFileProxyNode(IFile file, Resource resource) {
30
		super(file, resource);
28
		super(file, resource);
31
	}
29
	}
32
	
30
	
33
	public ExecutionFileProxyNode(IFile file, String name, IMemento[] childrenState) {
31
	public ExecutionFileProxyNode(IFile file, IMemento memento) {
34
		super(file, name, childrenState);
32
		super(file, memento);
35
	}
33
	}
36
34
37
	public Image getImage() {
35
	public Image getImage() {
38
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_EXECUTION);
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_EXECUTION);
39
	}
37
	}
40
	
38
	
41
	public String getFactoryID() {
39
	protected String getNodeKind() {
42
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
40
    	return TestUIConstants.EXECUTION_FILE_NODE;
43
	}
41
    }
44
	
42
45
	public boolean saveState(IMemento memento) { 
46
		//- data to retrieve the correct object 
47
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.EXECUTION_FILE_NODE);
48
		//- data from EMFResourceProxyNode
49
		memento.putString(TestUIConstants.TAG_NAME, getText());
50
		IProxyNode [] children = getChildren();
51
		for (int i = 0; i < children.length; i++) {
52
			if(!saveChildState(memento, children[i])) {
53
				return false;
54
			}
55
		}
56
		return true;
57
	}
58
}
43
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultExecutionResultProxyNode.java (-35 / +52 lines)
Lines 22-29 Link Here
22
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult;
22
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult;
23
import org.eclipse.hyades.models.common.testprofile.TPFInvocationEvent;
23
import org.eclipse.hyades.models.common.testprofile.TPFInvocationEvent;
24
import org.eclipse.hyades.models.common.testprofile.TPFTest;
24
import org.eclipse.hyades.models.common.testprofile.TPFTest;
25
import org.eclipse.hyades.models.common.testprofile.TPFTestSuite;
26
import org.eclipse.hyades.test.core.util.EMFUtil;
27
import org.eclipse.hyades.test.ui.TestUIConstants;
25
import org.eclipse.hyades.test.ui.TestUIConstants;
28
import org.eclipse.hyades.test.ui.TestUIImages;
26
import org.eclipse.hyades.test.ui.TestUIImages;
29
import org.eclipse.hyades.test.ui.internal.model.EventUtil;
27
import org.eclipse.hyades.test.ui.internal.model.EventUtil;
Lines 39-50 Link Here
39
37
40
/**
38
/**
41
 * @author jgout
39
 * @author jgout
40
 * @author jcanches
42
 * @since 3.2
41
 * @since 3.2
43
 */
42
 */
44
public class DefaultExecutionResultProxyNode extends TypedElementProxyNode implements IExecutionResultProxyNode, IPersistableProxyNode {
43
public class DefaultExecutionResultProxyNode extends TypedElementProxyNode implements IExecutionResultProxyNode, IPersistableProxyNode {
45
	
44
	
45
	private final static String TAG_VERDICT = "verdict"; //$NON-NLS-1$
46
	private final static String TAG_TIMESTAMP = "timestamp"; //$NON-NLS-1$
47
	
46
	private IProxyNode[] children;
48
	private IProxyNode[] children;
47
    private int verdict;
49
    private int verdict;
50
    private long timestamp;
51
    private String cachedName;
48
	
52
	
49
	/**
53
	/**
50
	 * @param er
54
	 * @param er
Lines 53-59 Link Here
53
	public DefaultExecutionResultProxyNode(TPFExecutionResult er, Object parent) {
57
	public DefaultExecutionResultProxyNode(TPFExecutionResult er, Object parent) {
54
		super(er, parent);
58
		super(er, parent);
55
		
59
		
56
		String name;
57
		LinkedList c = new LinkedList();
60
		LinkedList c = new LinkedList();
58
		TPFExecutionHistory history = er.getExecutionHistory();
61
		TPFExecutionHistory history = er.getExecutionHistory();
59
		if (history != null ) {
62
		if (history != null ) {
Lines 64-106 Link Here
64
		}
67
		}
65
		children = (IProxyNode[]) c.toArray(new IProxyNode[c.size()]);
68
		children = (IProxyNode[]) c.toArray(new IProxyNode[c.size()]);
66
		//- save the name of this element
69
		//- save the name of this element
67
		if(er.getName() != null) {
70
		String name = er.getName();
68
			name = er.getName();
71
		String testName = null; 
72
		TPFTest test = er.getTest();
73
		if(test != null) {
74
			testName = test.getName();
75
		}
76
		if (name != null) {
77
			if (testName != null && !testName.equals(name)) {
78
				name += " [" + testName + "]";  //$NON-NLS-1$//$NON-NLS-2$
79
			}
69
		} else {
80
		} else {
70
			name = "unamed"; //$NON-NLS-1$
81
			if (testName != null) {
71
		}
82
				name = testName;
72
        TPFTest test = er.getTest();
83
			}
73
		if((er.getTest() != null) && (((er.getTest()).getName()) != null)) {
74
            if (test instanceof TPFTestSuite) {
75
                if (er.getExecutionHistory().getExecutionEvents()!=null && er.getExecutionHistory().getExecutionEvents().size()>0) {
76
                    long timeStamp = ((TPFExecutionEvent)er.getExecutionHistory().getExecutionEvents().get(0)).getTimestamp();
77
                    String dateStamp = EventUtil.getTime(timeStamp);
78
                    name += " ["+dateStamp+"]";  //$NON-NLS-1$//$NON-NLS-2$
79
                }
80
            } else {
81
                name += " [" + (er.getTest()).getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
82
            }
83
		}
84
		}
84
		setName(name);
85
		setName(name);
86
		if (!(parent instanceof IExecutionResultProxyNode)) {
87
			if (er.getExecutionHistory().getExecutionEvents() != null && er.getExecutionHistory().getExecutionEvents().size()>0) {
88
				timestamp = ((TPFExecutionEvent)er.getExecutionHistory().getExecutionEvents().get(0)).getTimestamp();
89
			}
90
		}
85
        verdict = er.getVerdict().getValue();
91
        verdict = er.getVerdict().getValue();
86
	}
92
	}
87
93
	
88
	public DefaultExecutionResultProxyNode(IMemento memento, Object parent) {
94
	public DefaultExecutionResultProxyNode(IMemento memento, Object parent) {
89
		super(memento, parent);
95
		super(memento, parent);
90
        Integer v = memento.getInteger(TestUIConstants.TAG_VERDICT);
96
        Integer v = memento.getInteger(TAG_VERDICT);
91
        if(v == null) {
97
        String l = memento.getString(TAG_TIMESTAMP);
98
        if(v == null || l == null) {
92
            //- old memento, we need to rebuild the proxy from execution file
99
            //- old memento, we need to rebuild the proxy from execution file
93
            throw new ProxyNeedToBeRebuiltException();
100
            throw new ProxyNeedToBeRebuiltException();
94
        } else {
101
        } else {
95
            verdict = v.intValue();
102
            verdict = v.intValue();
96
        }
103
        }
104
        try {
105
        	timestamp = Long.parseLong(l);
106
        } catch (NumberFormatException e) {
107
        	timestamp = 0L;
108
        }
97
		IMemento [] childrenMemento = memento.getChildren(TestUIConstants.TAG_CHILD);
109
		IMemento [] childrenMemento = memento.getChildren(TestUIConstants.TAG_CHILD);
98
        LinkedList execChildren = new LinkedList();
110
        LinkedList execChildren = new LinkedList();
99
		for (int i = 0; i < childrenMemento.length; i++) {
111
		for (int i = 0; i < childrenMemento.length; i++) {
100
			IMemento mementoChild = childrenMemento[i];
112
			IMemento mementoChild = childrenMemento[i];
101
            //- inherit the TAG_URI_ROOT which is an extra data contained by the parent
113
            //- inherit the TAG_URI_ROOT which is an extra data contained by the parent
102
            mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT));
114
            mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT));
103
			String type = mementoChild.getString(TestUIConstants.TAG_TYPE);
115
			String type = getType();
104
			if(type == null) {
116
			if(type == null) {
105
				throw new ProxyNeedToBeRebuiltException();
117
				throw new ProxyNeedToBeRebuiltException();
106
			}
118
			}
Lines 133-138 Link Here
133
		}
145
		}
134
	}
146
	}
135
147
148
	public String getText() {
149
		if (timestamp != 0L) {
150
			if (cachedName == null) {
151
				String dateStamp = EventUtil.getTime(timestamp);
152
				cachedName = super.getText() + " ["+dateStamp+"]";  //$NON-NLS-1$//$NON-NLS-2$
153
			}
154
			return cachedName;
155
		}
156
		return super.getText();
157
	}
158
	
136
	public Image getImage() {
159
	public Image getImage() {
137
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_EXECUTION);
160
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_EXECUTION);
138
	}
161
	}
Lines 142-148 Link Here
142
	}
165
	}
143
		
166
		
144
	public TPFExecutionResult getExecutionResult() {
167
	public TPFExecutionResult getExecutionResult() {
145
		EObject exec = EMFUtil.getResourceSet().getEObject(getOriginatorURI(), true);
168
		EObject exec = super.getEObject();
146
		if (exec instanceof TPFExecutionResult) {
169
		if (exec instanceof TPFExecutionResult) {
147
			return (TPFExecutionResult) exec;
170
			return (TPFExecutionResult) exec;
148
		} else {
171
		} else {
Lines 154-173 Link Here
154
        return verdict;
177
        return verdict;
155
    }
178
    }
156
179
157
    public String getFactoryID() {
180
    protected String getNodeKind() {
158
        return "EMFResourceProxyFactory"; //$NON-NLS-1$
181
    	return TestUIConstants.EXECUTION_RESULT_NODE;
159
    }
182
    }
160
183
    
161
    public boolean saveState(IMemento memento) {
184
    public boolean saveState(IMemento memento) {
162
        //- data to retrieve the correct object 
185
        //- data to retrieve the correct object 
163
        memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.EXECUTION_RESULT_NODE);
186
        memento.putInteger(TAG_VERDICT, getVerdict());
164
        memento.putInteger(TestUIConstants.TAG_VERDICT, getVerdict());
187
        memento.putString(TAG_TIMESTAMP, Long.toString(timestamp));
165
        //- data from TypedElementProxyNode
166
        memento.putString(TestUIConstants.TAG_TYPE, getType());
167
        //- data from CMNNamedElementProxyNode
168
        memento.putString(TestUIConstants.TAG_NAME, getText());
169
        //- data from EObjectProxyNode
170
        memento.putString(TestUIConstants.TAG_URI_FRAGMENT, getOriginatorURI().fragment());
171
        //- children (testcases)
188
        //- children (testcases)
172
        for (int i = 0; i < children.length; i++) {
189
        for (int i = 0; i < children.length; i++) {
173
            DefaultExecutionResultProxyNode child = (DefaultExecutionResultProxyNode)children[i];
190
            DefaultExecutionResultProxyNode child = (DefaultExecutionResultProxyNode)children[i];
Lines 176-182 Link Here
176
                return false;
193
                return false;
177
            }
194
            }
178
        }
195
        }
179
        return true;
196
        return super.saveState(memento);
180
    }
197
    }
181
    
198
    
182
    
199
    
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EMFResourceProxyNode.java (-3 / +25 lines)
Lines 29-36 Link Here
29
 * @author jgout
29
 * @author jgout
30
 * @since 3.2
30
 * @since 3.2
31
 */
31
 */
32
public class EMFResourceProxyNode extends FileProxyNode {
32
public abstract class EMFResourceProxyNode extends FileProxyNode implements IPersistableProxyNode {
33
33
34
	private static final String TAG_NAME = "name"; //$NON-NLS-1$
35
	
34
	private List children;
36
	private List children;
35
	private String name;
37
	private String name;
36
	
38
	
Lines 55-65 Link Here
55
		name = name.substring(0, name.length()-(file.getFileExtension().length()+1));
57
		name = name.substring(0, name.length()-(file.getFileExtension().length()+1));
56
	}
58
	}
57
59
58
	public EMFResourceProxyNode(IFile file, String name, IMemento [] childrenState) {
60
	public EMFResourceProxyNode(IFile file, IMemento rootMemento) {
59
		super(file);
61
		super(file);
60
		this.name = name;
62
		this.name = rootMemento.getString(TAG_NAME);
61
		children = new LinkedList();
63
		children = new LinkedList();
62
		IProxyNode child = null;
64
		IProxyNode child = null;
65
		IMemento[] childrenState = rootMemento.getChildren(TestUIConstants.TAG_CHILD);
63
		for (int i = 0; i < childrenState.length; i++) {
66
		for (int i = 0; i < childrenState.length; i++) {
64
			IMemento memento = childrenState[i];
67
			IMemento memento = childrenState[i];
65
			child = HyadesProxyNodeFactory.getInstance().recreate(memento, this);
68
			child = HyadesProxyNodeFactory.getInstance().recreate(memento, this);
Lines 96-99 Link Here
96
			return super.getAdapter(adapter);
99
			return super.getAdapter(adapter);
97
		}
100
		}
98
	}
101
	}
102
	
103
	public String getFactoryID() {
104
		return EMFResourceProxyFactory.ID;
105
	}
106
	
107
	public boolean saveState(IMemento memento) {
108
		memento.putString(TestUIConstants.TAG_NODE_KIND, getNodeKind());
109
		memento.putString(TAG_NAME, getText());
110
		IProxyNode [] children = getChildren();
111
		for (int i = 0; i < children.length; i++) {
112
			if(!saveChildState(memento, children[i])) {
113
				return false;
114
			}
115
		}
116
		return true;
117
	}
118
	
119
	protected abstract String getNodeKind();
120
99
}
121
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TypedElementFactoryManager.java (-4 / +5 lines)
Lines 114-133 Link Here
114
		if (value instanceof IConfigurationElement) {
114
		if (value instanceof IConfigurationElement) {
115
			//- if the factory has not yet been loaded
115
			//- if the factory has not yet been loaded
116
			IConfigurationElement element = (IConfigurationElement) value;
116
			IConfigurationElement element = (IConfigurationElement) value;
117
			ITypedElementProxyFactory factory = null;
117
			try {
118
			try {
118
				ITypedElementProxyFactory factory = null;
119
				if("factory".equals(element.getName())) { //$NON-NLS-1$
119
				if("factory".equals(element.getName())) { //$NON-NLS-1$
120
					factory = (ITypedElementProxyFactory)element.createExecutableExtension("class"); //$NON-NLS-1$
120
					factory = (ITypedElementProxyFactory)element.createExecutableExtension("class"); //$NON-NLS-1$
121
				} else {
121
				} else {
122
					//- old extension point
122
					//- old extension point
123
					factory = (ITypedElementProxyFactory)element.createExecutableExtension("factory"); //$NON-NLS-1$
123
					factory = (ITypedElementProxyFactory)element.createExecutableExtension("factory"); //$NON-NLS-1$
124
				}
124
				}
125
				return factory;
126
			} catch (CoreException e) {
125
			} catch (CoreException e) {
127
				UiPlugin.logError(e);
126
				UiPlugin.logError(e);
128
				//- problem building the instance of factory using reflection
127
				//- problem building the instance of factory using reflection
129
				return new DefaultTypedElementProxyFactory();
128
				factory = new DefaultTypedElementProxyFactory();
130
			} 
129
			}
130
			factories.put(factoryID, factory);
131
			return factory;
131
		} else {
132
		} else {
132
			//- the factory has been loaded yet
133
			//- the factory has been loaded yet
133
			if (value instanceof ITypedElementProxyFactory) {
134
			if (value instanceof ITypedElementProxyFactory) {
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultTestCaseProxyNode.java (-17 / +5 lines)
Lines 21-27 Link Here
21
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
21
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
22
import org.eclipse.hyades.test.ui.navigator.ITestCaseProxyNode;
22
import org.eclipse.hyades.test.ui.navigator.ITestCaseProxyNode;
23
import org.eclipse.hyades.test.ui.navigator.TypedElementProxyNode;
23
import org.eclipse.hyades.test.ui.navigator.TypedElementProxyNode;
24
import org.eclipse.hyades.ui.HyadesUIPlugin;
24
import org.eclipse.hyades.ui.extension.IAssociationConstants;
25
import org.eclipse.hyades.ui.extension.IAssociationDescriptor;
25
import org.eclipse.hyades.ui.extension.IAssociationDescriptor;
26
import org.eclipse.hyades.ui.extension.IAssociationMapping;
26
import org.eclipse.hyades.ui.extension.IAssociationMapping;
27
import org.eclipse.hyades.ui.internal.extension.AssociationMappingRegistry;
27
import org.eclipse.hyades.ui.internal.extension.AssociationMappingRegistry;
Lines 42-55 Link Here
42
	public DefaultTestCaseProxyNode(TPFTestCase tc, Object parent) {
42
	public DefaultTestCaseProxyNode(TPFTestCase tc, Object parent) {
43
		super(tc, parent);
43
		super(tc, parent);
44
		AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestCaseMappingRegistry();
44
		AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestCaseMappingRegistry();
45
		IAssociationMapping associationMapping = registry.getAssociationMapping(HyadesUIPlugin.EP_TYPE_DESCRIPTIONS);
45
		IAssociationMapping associationMapping = registry.getAssociationMapping(IAssociationConstants.EP_TYPE_DESCRIPTIONS);
46
		descriptor = associationMapping.getDefaultAssociationDescriptor(tc.getType());
46
		descriptor = associationMapping.getDefaultAssociationDescriptor(tc.getType());
47
	}
47
	}
48
48
49
	public DefaultTestCaseProxyNode(IMemento memento, Object parent) {
49
	public DefaultTestCaseProxyNode(IMemento memento, Object parent) {
50
		super(memento, parent);
50
		super(memento, parent);
51
		AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestCaseMappingRegistry();
51
		AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestCaseMappingRegistry();
52
		IAssociationMapping associationMapping = registry.getAssociationMapping(HyadesUIPlugin.EP_TYPE_DESCRIPTIONS);
52
		IAssociationMapping associationMapping = registry.getAssociationMapping(IAssociationConstants.EP_TYPE_DESCRIPTIONS);
53
		descriptor = associationMapping.getDefaultAssociationDescriptor(getType());		
53
		descriptor = associationMapping.getDefaultAssociationDescriptor(getType());		
54
	}
54
	}
55
	
55
	
Lines 76-94 Link Here
76
		}
76
		}
77
	}
77
	}
78
	
78
	
79
	public String getFactoryID() {
79
	protected String getNodeKind() {
80
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
80
		return TestUIConstants.TESTCASE_NODE;
81
	}
82
	
83
	public boolean saveState(IMemento memento) {
84
		//- data to retrieve the correct object 
85
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTCASE_NODE);
86
		//- data from TypedElementProxyNode
87
		memento.putString(TestUIConstants.TAG_TYPE, getType());
88
		//- data from CMNNamedElementProxyNode
89
		memento.putString(TestUIConstants.TAG_NAME, getText());
90
		//- data from EObjectProxyNode
91
		memento.putString(TestUIConstants.TAG_URI_FRAGMENT, getOriginatorURI().fragment());
92
		return true;
93
	}
81
	}
94
}
82
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMarkerPersister.java (-2 / +3 lines)
Lines 45-50 Link Here
45
45
46
public class FileProxyMarkerPersister implements IFileProxyPersister {
46
public class FileProxyMarkerPersister implements IFileProxyPersister {
47
47
48
	private static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
48
    private static final String TAG_PROXY_STATE = "proxyState"; //$NON-NLS-1$
49
    private static final String TAG_PROXY_STATE = "proxyState"; //$NON-NLS-1$
49
    private static final String TAG_LAST_SAVE_STAMP = "lastSaveStamp"; //$NON-NLS-1$
50
    private static final String TAG_LAST_SAVE_STAMP = "lastSaveStamp"; //$NON-NLS-1$
50
    private static final String MARKER_PROXYSTATE = "org.eclipse.hyades.test.ui.proxyStateMarker"; //$NON-NLS-1$
51
    private static final String MARKER_PROXYSTATE = "org.eclipse.hyades.test.ui.proxyStateMarker"; //$NON-NLS-1$
Lines 65-71 Link Here
65
                //- if this file has changed since last save do not read the saved state
66
                //- if this file has changed since last save do not read the saved state
66
                if(currentModStamp != lastSaveStamp) return null;
67
                if(currentModStamp != lastSaveStamp) return null;
67
                //- marker exists so retrieve factory id and proxy state
68
                //- marker exists so retrieve factory id and proxy state
68
                String factoryID = markers[0].getAttribute(TestUIConstants.TAG_FACTORY_ID, null);
69
                String factoryID = markers[0].getAttribute(TAG_FACTORY_ID, null);
69
                if (FileProxyNodeCache.NullProxy.FACTORY_ID.equals(factoryID)) return FileProxyNodeCache.nullProxy;
70
                if (FileProxyNodeCache.NullProxy.FACTORY_ID.equals(factoryID)) return FileProxyNodeCache.nullProxy;
70
                String proxyState = markers[0].getAttribute(TAG_PROXY_STATE, null);
71
                String proxyState = markers[0].getAttribute(TAG_PROXY_STATE, null);
71
                if (proxyState == null) {
72
                if (proxyState == null) {
Lines 232-238 Link Here
232
                    //- create a file marker to store the proxy state
233
                    //- create a file marker to store the proxy state
233
                    IMarker marker = _file.createMarker(MARKER_PROXYSTATE);
234
                    IMarker marker = _file.createMarker(MARKER_PROXYSTATE);
234
                    marker.setAttribute(TAG_LAST_SAVE_STAMP, Long.toString(lastSaveStamp));
235
                    marker.setAttribute(TAG_LAST_SAVE_STAMP, Long.toString(lastSaveStamp));
235
                    marker.setAttribute(TestUIConstants.TAG_FACTORY_ID, factoryId);
236
                    marker.setAttribute(TAG_FACTORY_ID, factoryId);
236
                    if (state != null) {
237
                    if (state != null) {
237
                    	marker.setAttribute(TAG_PROXY_STATE, state);
238
                    	marker.setAttribute(TAG_PROXY_STATE, state);
238
                    }
239
                    }
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolFileProxyNode.java (-21 / +5 lines)
Lines 15-22 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
19
import org.eclipse.ui.IMemento;
22
20
Lines 24-58 Link Here
24
 * @author jgout
22
 * @author jgout
25
 * @since 3.2
23
 * @since 3.2
26
 */
24
 */
27
public class DatapoolFileProxyNode extends EMFResourceProxyNode implements IPersistableProxyNode {
25
public class DatapoolFileProxyNode extends EMFResourceProxyNode {
28
		
26
		
29
	public DatapoolFileProxyNode(IFile file, Resource resource) {
27
	public DatapoolFileProxyNode(IFile file, Resource resource) {
30
		super(file, resource);
28
		super(file, resource);
31
	}
29
	}
32
	
30
	
33
	public DatapoolFileProxyNode(IFile file, String name, IMemento [] children) {
31
	public DatapoolFileProxyNode(IFile file, IMemento memento) {
34
		super(file, name, children);
32
		super(file, memento);
35
	}
33
	}
36
	
34
	
37
	public Image getImage() {
35
	public Image getImage() {
38
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DATAPOOL);
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DATAPOOL);
39
	}
37
	}
40
	
38
	
41
	public String getFactoryID() {
39
	protected String getNodeKind() {
42
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
40
		return TestUIConstants.DATAPOOL_FILE_NODE;
43
	}
44
	
45
	public boolean saveState(IMemento memento) {
46
		//- data to retrieve the correct object 
47
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DATAPOOL_FILE_NODE);
48
		//- data from EMFResourceProxyNode
49
		memento.putString(TestUIConstants.TAG_NAME, getText());
50
		IProxyNode [] children = getChildren();
51
		for (int i = 0; i < children.length; i++) {
52
			if(!saveChildState(memento, children[i])) {
53
				return false;
54
			}
55
		}
56
		return true;
57
	}
41
	}
58
}
42
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactProxyNode.java (-15 / +3 lines)
Lines 15-21 Link Here
15
import org.eclipse.hyades.test.ui.TestUIConstants;
15
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIImages;
16
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
Lines 24-32 Link Here
24
 * @author jgout
23
 * @author jgout
25
 * @since 3.2
24
 * @since 3.2
26
 */
25
 */
27
public class ArtifactProxyNode extends CMNNamedElementProxyNode implements IPersistableProxyNode  {
26
public class ArtifactProxyNode extends CMNNamedElementProxyNode {
28
	
27
	
29
30
	/**
28
	/**
31
	 * @param memento
29
	 * @param memento
32
	 * @param parent
30
	 * @param parent
Lines 52-69 Link Here
52
		return new IProxyNode[0];
50
		return new IProxyNode[0];
53
	}
51
	}
54
	
52
	
55
	public String getFactoryID() {
53
	protected String getNodeKind() {
56
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
54
		return TestUIConstants.ARTIFACT_NODE;
57
	}
58
	
59
	public boolean saveState(IMemento memento) { 
60
		//- data to retrieve the correct object
61
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.ARTIFACT_NODE);
62
		//- data from CMNNamedElementProxyNode
63
		memento.putString(TestUIConstants.TAG_NAME, getText());
64
		//- data from EObjectProxyNode
65
		memento.putString(TestUIConstants.TAG_URI_FRAGMENT, getOriginatorURI().fragment());
66
		return true;
67
	}
55
	}
68
	
56
	
69
}
57
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DefaultTestComponentlProxyNode.java (+6 lines)
Lines 14-19 Link Here
14
import org.eclipse.emf.ecore.EObject;
14
import org.eclipse.emf.ecore.EObject;
15
import org.eclipse.hyades.models.common.testprofile.TPFTestComponent;
15
import org.eclipse.hyades.models.common.testprofile.TPFTestComponent;
16
import org.eclipse.hyades.test.core.util.EMFUtil;
16
import org.eclipse.hyades.test.core.util.EMFUtil;
17
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.ITestComponentProxyNode;
20
import org.eclipse.hyades.test.ui.navigator.ITestComponentProxyNode;
Lines 55-58 Link Here
55
			return null;
56
			return null;
56
		}
57
		}
57
	}
58
	}
59
60
	protected String getNodeKind() {
61
		return TestUIConstants.TESTCOMPONENT_NODE;
62
	}
63
58
}
64
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestSuiteFileProxyNode.java (-22 / +7 lines)
Lines 15-22 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
19
import org.eclipse.ui.IMemento;
22
20
Lines 24-58 Link Here
24
 * @author jgout
22
 * @author jgout
25
 * @since 3.2
23
 * @since 3.2
26
 */
24
 */
27
public class TestSuiteFileProxyNode extends EMFResourceProxyNode implements IPersistableProxyNode {
25
public class TestSuiteFileProxyNode extends EMFResourceProxyNode {
28
	
26
	
29
	public TestSuiteFileProxyNode(IFile file, Resource res) {
27
	public TestSuiteFileProxyNode(IFile file, Resource res) {
30
		super(file, res);
28
		super(file, res);
31
	}
29
	}
32
	
30
	
33
	public TestSuiteFileProxyNode(IFile file, String name, IMemento[] childrenState) {
31
	public TestSuiteFileProxyNode(IFile file, IMemento memento) {
34
		super(file, name, childrenState);
32
		super(file, memento);
35
	}
33
	}
36
34
37
	public Image getImage() {
35
	public Image getImage() {
38
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_SUITE);
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_SUITE);
39
	}
37
	}
40
	
38
	
41
	public String getFactoryID() {
39
	protected String getNodeKind() {
42
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
40
    	return TestUIConstants.TESTSUITE_FILE_NODE;
43
	}
41
    }
44
	
42
45
	public boolean saveState(IMemento memento) {
46
		//- data to retrieve the correct object 
47
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTSUITE_FILE_NODE);
48
		//- data from EMFResourceProxyNode
49
		memento.putString(TestUIConstants.TAG_NAME, getText());
50
		IProxyNode [] children = getChildren();
51
		for (int i = 0; i < children.length; i++) {
52
			if(!saveChildState(memento, children[i])) {
53
				return false;
54
			}
55
		}
56
		return true;
57
	}
58
}
43
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentFileProxyNode.java (-21 / +5 lines)
Lines 15-22 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
19
import org.eclipse.ui.IMemento;
22
20
Lines 24-58 Link Here
24
 * @author jgout
22
 * @author jgout
25
 * @since 3.2
23
 * @since 3.2
26
 */
24
 */
27
public class DeploymentFileProxyNode extends EMFResourceProxyNode implements IPersistableProxyNode {
25
public class DeploymentFileProxyNode extends EMFResourceProxyNode {
28
		
26
		
29
	public DeploymentFileProxyNode(IFile file, Resource resource) {
27
	public DeploymentFileProxyNode(IFile file, Resource resource) {
30
		super(file, resource);
28
		super(file, resource);
31
	}
29
	}
32
	
30
	
33
	public DeploymentFileProxyNode(IFile file, String name, IMemento[] childrenState) {
31
	public DeploymentFileProxyNode(IFile file, IMemento memento) {
34
		super(file, name, childrenState);
32
		super(file, memento);
35
	}
33
	}
36
34
37
	public Image getImage() {
35
	public Image getImage() {
38
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DEPLOYMENT);
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_DEPLOYMENT);
39
	}
37
	}
40
38
41
	public String getFactoryID() {
39
	protected String getNodeKind() {
42
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
40
		return TestUIConstants.DEPLOY_FILE_NODE;
43
	}
44
	
45
	public boolean saveState(IMemento memento) {
46
		//- data to retrieve the correct object 
47
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DEPLOY_FILE_NODE);
48
		//- data from EMFResourceProxyNode
49
		memento.putString(TestUIConstants.TAG_NAME, getText());
50
		IProxyNode [] children = getChildren();
51
		for (int i = 0; i < children.length; i++) {
52
			if(!saveChildState(memento, children[i])) {
53
				return false;
54
			}
55
		}
56
		return true;
57
	}
41
	}
58
}
42
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationFileProxyNode.java (-22 / +7 lines)
Lines 15-22 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
19
import org.eclipse.ui.IMemento;
22
20
Lines 24-57 Link Here
24
 * @author jgout
22
 * @author jgout
25
 * @since 3.2
23
 * @since 3.2
26
 */
24
 */
27
public class LocationFileProxyNode extends EMFResourceProxyNode implements IPersistableProxyNode {
25
public class LocationFileProxyNode extends EMFResourceProxyNode {
28
		
26
		
29
	public LocationFileProxyNode(IFile file, Resource resource) {
27
	public LocationFileProxyNode(IFile file, Resource resource) {
30
		super(file, resource);
28
		super(file, resource);
31
	}
29
	}
32
	
30
	
33
	public LocationFileProxyNode(IFile file, String name, IMemento[] childrenState) {
31
	public LocationFileProxyNode(IFile file, IMemento memento) {
34
		super(file, name, childrenState);
32
		super(file, memento);
35
	}
33
	}
36
	public Image getImage() {
34
	public Image getImage() {
37
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_LOCATION);
35
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_LOCATION);
38
	}
36
	}
39
	
37
	
40
	public String getFactoryID() {
38
	protected String getNodeKind() {
41
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
39
    	return TestUIConstants.LOCATION_FILE_NODE;
42
	}
40
    }
43
	
41
44
	public boolean saveState(IMemento memento) {
45
		//- data to retrieve the correct object 
46
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.LOCATION_FILE_NODE);
47
		//- data from EMFResourceProxyNode
48
		memento.putString(TestUIConstants.TAG_NAME, getText());
49
		IProxyNode [] children = getChildren();
50
		for (int i = 0; i < children.length; i++) {
51
			if(!saveChildState(memento, children[i])) {
52
				return false;
53
			}
54
		}
55
		return true;
56
	}	
57
}
42
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/FileProxyMetadataPersister.java (-6 / +9 lines)
Lines 4-10 Link Here
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: FileProxyMetadataPersister.java,v 1.1 2006/09/28 15:14:48 jcanches Exp $
7
 * $Id: $
8
 * 
8
 * 
9
 * Contributors:
9
 * Contributors:
10
 *     IBM Corporation - initial API and implementation
10
 *     IBM Corporation - initial API and implementation
Lines 12-17 Link Here
12
12
13
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
13
package org.eclipse.hyades.test.ui.internal.navigator.proxy;
14
14
15
import java.io.BufferedInputStream;
16
import java.io.BufferedOutputStream;
15
import java.io.File;
17
import java.io.File;
16
import java.io.FileInputStream;
18
import java.io.FileInputStream;
17
import java.io.FileNotFoundException;
19
import java.io.FileNotFoundException;
Lines 44-50 Link Here
44
46
45
public class FileProxyMetadataPersister implements IFileProxyPersister {
47
public class FileProxyMetadataPersister implements IFileProxyPersister {
46
48
47
    private static final String TAG_PROXY_STATE = "proxyState"; //$NON-NLS-1$
49
	private static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
50
	private static final String TAG_PROXY_STATE = "proxyState"; //$NON-NLS-1$
48
    private static final String TAG_LAST_SAVE_STAMP = "lastSaveStamp"; //$NON-NLS-1$
51
    private static final String TAG_LAST_SAVE_STAMP = "lastSaveStamp"; //$NON-NLS-1$
49
52
50
    private IPath storageArea;
53
    private IPath storageArea;
Lines 65-71 Link Here
65
	protected Writer createWriter(IFile file) throws IOException {
68
	protected Writer createWriter(IFile file) throws IOException {
66
		IPath path = getStoragePath(file);
69
		IPath path = getStoragePath(file);
67
		File storageFile = createFile(path);
70
		File storageFile = createFile(path);
68
		GZIPOutputStream stream = new GZIPOutputStream(new FileOutputStream(storageFile));
71
		GZIPOutputStream stream = new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(storageFile)));
69
		return new OutputStreamWriter(stream);
72
		return new OutputStreamWriter(stream);
70
	}
73
	}
71
	
74
	
Lines 74-80 Link Here
74
		File storageFile = new File(path.toOSString());
77
		File storageFile = new File(path.toOSString());
75
		if (storageFile.canRead()) {
78
		if (storageFile.canRead()) {
76
			try {
79
			try {
77
				return new InputStreamReader(new GZIPInputStream(new FileInputStream(storageFile)));
80
				return new InputStreamReader(new GZIPInputStream(new BufferedInputStream(new FileInputStream(storageFile))));
78
			} catch (FileNotFoundException e) {
81
			} catch (FileNotFoundException e) {
79
				UiPlugin.logError(e);
82
				UiPlugin.logError(e);
80
			} catch (IOException e) {
83
			} catch (IOException e) {
Lines 101-107 Link Here
101
            long lastSaveStamp = stamp != null ? Long.parseLong(stamp) : 0;
104
            long lastSaveStamp = stamp != null ? Long.parseLong(stamp) : 0;
102
            //- if this file has changed since last save do not read the saved state
105
            //- if this file has changed since last save do not read the saved state
103
            if(currentModStamp != lastSaveStamp) return null;
106
            if(currentModStamp != lastSaveStamp) return null;
104
			String factoryId = memento.getString(TestUIConstants.TAG_FACTORY_ID);
107
			String factoryId = memento.getString(TAG_FACTORY_ID);
105
			if (FileProxyNodeCache.NullProxy.FACTORY_ID.equals(factoryId)) return FileProxyNodeCache.nullProxy;
108
			if (FileProxyNodeCache.NullProxy.FACTORY_ID.equals(factoryId)) return FileProxyNodeCache.nullProxy;
106
			IMemento proxyState = memento.getChild(TAG_PROXY_STATE);
109
			IMemento proxyState = memento.getChild(TAG_PROXY_STATE);
107
            if (proxyState == null) return null;
110
            if (proxyState == null) return null;
Lines 169-175 Link Here
169
			try {
172
			try {
170
				XMLMemento memento = XMLMemento.createWriteRoot("proxyStateMemento");  //$NON-NLS-1$
173
				XMLMemento memento = XMLMemento.createWriteRoot("proxyStateMemento");  //$NON-NLS-1$
171
				memento.putString(TAG_LAST_SAVE_STAMP, Long.toString(file.getModificationStamp()));
174
				memento.putString(TAG_LAST_SAVE_STAMP, Long.toString(file.getModificationStamp()));
172
	            memento.putString(TestUIConstants.TAG_FACTORY_ID, proxy.getFactoryID());
175
	            memento.putString(TAG_FACTORY_ID, proxy.getFactoryID());
173
	            IMemento state = memento.createChild(TAG_PROXY_STATE);
176
	            IMemento state = memento.createChild(TAG_PROXY_STATE);
174
				proxy.saveState(state);
177
				proxy.saveState(state);
175
				memento.save(writer);
178
				memento.save(writer);
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/EMFResourceProxyFactory.java (-7 / +12 lines)
Lines 37-42 Link Here
37
 */
37
 */
38
public class EMFResourceProxyFactory implements IFileProxyFactory, IPersistableFileProxyFactory {
38
public class EMFResourceProxyFactory implements IFileProxyFactory, IPersistableFileProxyFactory {
39
	
39
	
40
	/**
41
	 * Factory id.
42
	 */
43
	public final static String ID = "EMFResourceProxyFactory"; //$NON-NLS-1$
44
	
40
	/** This method is called to build a node that contains multiple EMF objects as children.
45
	/** This method is called to build a node that contains multiple EMF objects as children.
41
	 *  The object created depends of the extension of the file (.datapool -> DatapoolFileProxyNode)
46
	 *  The object created depends of the extension of the file (.datapool -> DatapoolFileProxyNode)
42
	 *  using as name the name of the file since if there are multiple objects inside, we can't
47
	 *  using as name the name of the file since if there are multiple objects inside, we can't
Lines 130-148 Link Here
130
                mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT));               
135
                mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT));               
131
            }
136
            }
132
            if(nodeKind.equals(TestUIConstants.ARTIFACT_FILE_NODE)) {
137
            if(nodeKind.equals(TestUIConstants.ARTIFACT_FILE_NODE)) {
133
				return new ArtifactFileProxyNode(file, memento.getString(TestUIConstants.TAG_NAME), mementoChildren);
138
				return new ArtifactFileProxyNode(file, memento);
134
			} else if(nodeKind.equals(TestUIConstants.DATAPOOL_FILE_NODE)) {
139
			} else if(nodeKind.equals(TestUIConstants.DATAPOOL_FILE_NODE)) {
135
				return new DatapoolFileProxyNode(file, memento.getString(TestUIConstants.TAG_NAME), mementoChildren);
140
				return new DatapoolFileProxyNode(file, memento);
136
			} else if(nodeKind.equals(TestUIConstants.DEPLOY_FILE_NODE)) {
141
			} else if(nodeKind.equals(TestUIConstants.DEPLOY_FILE_NODE)) {
137
				return new DeploymentFileProxyNode(file, memento.getString(TestUIConstants.TAG_NAME), mementoChildren);
142
				return new DeploymentFileProxyNode(file, memento);
138
			} else if(nodeKind.equals(TestUIConstants.EXECUTION_FILE_NODE)) {
143
			} else if(nodeKind.equals(TestUIConstants.EXECUTION_FILE_NODE)) {
139
				return new ExecutionFileProxyNode(file, memento.getString(TestUIConstants.TAG_NAME), mementoChildren);
144
				return new ExecutionFileProxyNode(file, memento);
140
			} else if(nodeKind.equals(TestUIConstants.LOCATION_FILE_NODE)) {
145
			} else if(nodeKind.equals(TestUIConstants.LOCATION_FILE_NODE)) {
141
				return new LocationFileProxyNode(file, memento.getString(TestUIConstants.TAG_NAME), mementoChildren);
146
				return new LocationFileProxyNode(file, memento);
142
			} else if(nodeKind.equals(TestUIConstants.TESTCOMPONENT_FILE_NODE)) {
147
			} else if(nodeKind.equals(TestUIConstants.TESTCOMPONENT_FILE_NODE)) {
143
				return new TestComponentFileProxyNode(file, memento.getString(TestUIConstants.TAG_NAME), mementoChildren);
148
				return new TestComponentFileProxyNode(file, memento);
144
			} else if(nodeKind.equals(TestUIConstants.TESTSUITE_FILE_NODE)) {
149
			} else if(nodeKind.equals(TestUIConstants.TESTSUITE_FILE_NODE)) {
145
				return new TestSuiteFileProxyNode(file, memento.getString(TestUIConstants.TAG_NAME), mementoChildren);
150
				return new TestSuiteFileProxyNode(file, memento);
146
			}
151
			}
147
		} else {
152
		} else {
148
			return proxy;
153
			return proxy;
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/TestComponentFileProxyNode.java (-21 / +7 lines)
Lines 15-22 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
19
import org.eclipse.ui.IMemento;
22
20
Lines 24-57 Link Here
24
 * @author jgout
22
 * @author jgout
25
 * @since 3.2
23
 * @since 3.2
26
 */
24
 */
27
public class TestComponentFileProxyNode extends EMFResourceProxyNode implements IPersistableProxyNode {
25
public class TestComponentFileProxyNode extends EMFResourceProxyNode {
28
		
26
		
29
	public TestComponentFileProxyNode(IFile file, Resource resource) {
27
	public TestComponentFileProxyNode(IFile file, Resource resource) {
30
		super(file, resource);
28
		super(file, resource);
31
	}
29
	}
32
	
30
	
33
	public TestComponentFileProxyNode(IFile file, String name, IMemento[] childrenState) {
31
	public TestComponentFileProxyNode(IFile file, IMemento memento) {
34
		super(file, name, childrenState);
32
		super(file, memento);
35
	}
33
	}
36
34
37
	public Image getImage() {
35
	public Image getImage() {
38
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_COMPONENT);
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_TEST_COMPONENT);
39
	}
37
	}
40
	
38
	
41
	public String getFactoryID() {
39
	protected String getNodeKind() {
42
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
40
    	return TestUIConstants.TESTCOMPONENT_FILE_NODE;
43
	}
41
    }
44
	
42
45
	public boolean saveState(IMemento memento) {
46
		//- data to retrieve the correct object 
47
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTCOMPONENT_FILE_NODE);
48
		//- data from EMFResourceProxyNode
49
		memento.putString(TestUIConstants.TAG_NAME, getText());
50
		IProxyNode [] children = getChildren();
51
		for (int i = 0; i < children.length; i++) {
52
			if(!saveChildState(memento, children[i]))
53
				return false;
54
		}
55
		return true;
56
	}
57
}
43
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/ArtifactFileProxyNode.java (-21 / +5 lines)
Lines 15-22 Link Here
15
import org.eclipse.emf.ecore.resource.Resource;
15
import org.eclipse.emf.ecore.resource.Resource;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIConstants;
17
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.TestUIImages;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
19
import org.eclipse.ui.IMemento;
22
20
Lines 24-58 Link Here
24
 * @author jgout
22
 * @author jgout
25
 * @since 3.2
23
 * @since 3.2
26
 */
24
 */
27
public class ArtifactFileProxyNode extends EMFResourceProxyNode implements IPersistableProxyNode {
25
public class ArtifactFileProxyNode extends EMFResourceProxyNode {
28
	
26
	
29
	public ArtifactFileProxyNode(IFile file, Resource res) {
27
	public ArtifactFileProxyNode(IFile file, Resource res) {
30
		super(file, res);
28
		super(file, res);
31
	}
29
	}
32
	
30
	
33
	public ArtifactFileProxyNode(IFile file, String name, IMemento [] children) {
31
	public ArtifactFileProxyNode(IFile file, IMemento memento) {
34
		super(file, name, children);
32
		super(file, memento);
35
	}
33
	}
36
	
34
	
37
	public Image getImage() {
35
	public Image getImage() {
38
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_ARTIFACT);
36
		return TestUIImages.INSTANCE.getImage(TestUIImages.IMG_ARTIFACT);
39
	}
37
	}
40
38
41
	public String getFactoryID() {
39
	public String getNodeKind() {
42
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
40
		return TestUIConstants.ARTIFACT_FILE_NODE;
43
	}
44
	
45
	public boolean saveState(IMemento memento) {
46
		//- data to retrieve the correct object 
47
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.ARTIFACT_FILE_NODE);
48
		//- data from EMFResourceProxyNode
49
		memento.putString(TestUIConstants.TAG_NAME, getText());
50
		IProxyNode [] children = getChildren();
51
		for (int i = 0; i < children.length; i++) {
52
			if(!saveChildState(memento, children[i])) {
53
				return false;
54
			}
55
		}
56
		return true;
57
	}
41
	}
58
}
42
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DatapoolProxyNode.java (-14 / +3 lines)
Lines 15-21 Link Here
15
import org.eclipse.hyades.test.ui.TestUIConstants;
15
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIImages;
16
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
Lines 24-30 Link Here
24
 * @author jgout
23
 * @author jgout
25
 * @since 3.2
24
 * @since 3.2
26
 */
25
 */
27
public class DatapoolProxyNode extends CMNNamedElementProxyNode implements IPersistableProxyNode {
26
public class DatapoolProxyNode extends CMNNamedElementProxyNode {
28
	/**
27
	/**
29
	 * @param dp
28
	 * @param dp
30
	 * @param parent
29
	 * @param parent
Lines 50-66 Link Here
50
		return new IProxyNode[0];
49
		return new IProxyNode[0];
51
	}
50
	}
52
	
51
	
53
	public String getFactoryID() {
52
	protected String getNodeKind() {
54
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
53
		return TestUIConstants.DATAPOOL_NODE;
55
	}
56
	
57
	public boolean saveState(IMemento memento) {
58
		//- data to retrieve the correct object 
59
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DATAPOOL_NODE);
60
		//- data from CMNNamedElementProxyNode
61
		memento.putString(TestUIConstants.TAG_NAME, getText());
62
		//- data from EObjectProxyNode
63
		memento.putString(TestUIConstants.TAG_URI_FRAGMENT, getOriginatorURI().fragment());
64
		return true;
65
	}
54
	}
66
}
55
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/DeploymentProxyNode.java (-15 / +4 lines)
Lines 15-21 Link Here
15
import org.eclipse.hyades.test.ui.TestUIConstants;
15
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIImages;
16
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
Lines 24-30 Link Here
24
 * @author jgout
23
 * @author jgout
25
 * @since 3.2
24
 * @since 3.2
26
 */
25
 */
27
public class DeploymentProxyNode extends CMNNamedElementProxyNode implements IPersistableProxyNode {
26
public class DeploymentProxyNode extends CMNNamedElementProxyNode {
28
	/**
27
	/**
29
	 * @param deploy
28
	 * @param deploy
30
	 * @param parent
29
	 * @param parent
Lines 50-66 Link Here
50
		return new IProxyNode[0];
49
		return new IProxyNode[0];
51
	}
50
	}
52
	
51
	
53
	public String getFactoryID() {
52
	protected String getNodeKind() {
54
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
53
    	return TestUIConstants.DEPLOY_NODE;
55
	}
54
    }
56
	
57
	public boolean saveState(IMemento memento) {
58
		//- data to retrieve the correct object 
59
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.DEPLOY_NODE);
60
		//- data from CMNNamedElementProxyNode
61
		memento.putString(TestUIConstants.TAG_NAME, getText());
62
		//- data from EObjectProxyNode
63
		memento.putString(TestUIConstants.TAG_URI_FRAGMENT, getOriginatorURI().fragment());
64
		return true;
65
	}
66
}
55
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/proxy/LocationProxyNode.java (-15 / +5 lines)
Lines 15-21 Link Here
15
import org.eclipse.hyades.test.ui.TestUIConstants;
15
import org.eclipse.hyades.test.ui.TestUIConstants;
16
import org.eclipse.hyades.test.ui.TestUIImages;
16
import org.eclipse.hyades.test.ui.TestUIImages;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.IMemento;
Lines 24-30 Link Here
24
 * @author jgout
23
 * @author jgout
25
 * @since 3.2
24
 * @since 3.2
26
 */
25
 */
27
public class LocationProxyNode extends CMNNamedElementProxyNode implements IPersistableProxyNode {
26
public class LocationProxyNode extends CMNNamedElementProxyNode {
28
	/**
27
	/**
29
	 * @param loc
28
	 * @param loc
30
	 * @param parent
29
	 * @param parent
Lines 50-66 Link Here
50
		return new IProxyNode[0];
49
		return new IProxyNode[0];
51
	}
50
	}
52
	
51
	
53
	public String getFactoryID() {
52
	protected String getNodeKind() {
54
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
53
    	return TestUIConstants.LOCATION_NODE;
55
	}
54
    }
56
	
55
57
	public boolean saveState(IMemento memento) {
58
		//- data to retrieve the correct object 
59
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.LOCATION_NODE);
60
		//- data from CMNNamedElementProxyNode
61
		memento.putString(TestUIConstants.TAG_NAME, getText());
62
		//- data from EObjectProxyNode
63
		memento.putString(TestUIConstants.TAG_URI_FRAGMENT, getOriginatorURI().fragment());
64
		return true;
65
	}
66
}
56
}
(-)src/org/eclipse/hyades/test/ui/navigator/CMNNamedElementProxyNode.java (-9 / +28 lines)
Lines 14-30 Link Here
14
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.runtime.Platform;
16
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.emf.common.util.URI;
18
import org.eclipse.emf.ecore.EObject;
17
import org.eclipse.emf.ecore.EObject;
19
import org.eclipse.emf.ecore.resource.Resource;
18
import org.eclipse.emf.ecore.resource.Resource;
20
import org.eclipse.hyades.models.common.common.CMNNamedElement;
19
import org.eclipse.hyades.models.common.common.CMNNamedElement;
21
import org.eclipse.hyades.test.core.util.EMFUtil;
20
import org.eclipse.hyades.test.core.util.EMFUtil;
22
import org.eclipse.hyades.test.ui.TestUIConstants;
23
import org.eclipse.hyades.test.ui.UiPlugin;
21
import org.eclipse.hyades.test.ui.UiPlugin;
24
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer;
22
import org.eclipse.hyades.test.ui.navigator.actions.IProxyNodeRenamer;
25
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIInlineEditor;
23
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIInlineEditor;
26
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIStatus;
24
import org.eclipse.hyades.test.ui.navigator.actions.RenamerUIStatus;
27
import org.eclipse.hyades.ui.editor.IHyadesEditorPart;
28
import org.eclipse.ui.IEditorInput;
25
import org.eclipse.ui.IEditorInput;
29
import org.eclipse.ui.IEditorPart;
26
import org.eclipse.ui.IEditorPart;
30
import org.eclipse.ui.IEditorReference;
27
import org.eclipse.ui.IEditorReference;
Lines 38-49 Link Here
38
 * Proxy node for <code>CMNNamedElement</code> element.
35
 * Proxy node for <code>CMNNamedElement</code> element.
39
 * @author jgout
36
 * @author jgout
40
 */
37
 */
41
/**
42
 * @author jgout
43
 * @since 
44
 */
45
public abstract class CMNNamedElementProxyNode extends EObjectProxyNode implements IProxyNodeRenamer  {
38
public abstract class CMNNamedElementProxyNode extends EObjectProxyNode implements IProxyNodeRenamer  {
39
	
40
	private final static String TAG_NAME = "name"; //$NON-NLS-1$
41
	private final static String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
42
	
46
	private String name;
43
	private String name;
44
	private String description;
47
45
48
    /**
46
    /**
49
     * Constructor used to load an already built proxy.
47
     * Constructor used to load an already built proxy.
Lines 52-61 Link Here
52
     */
50
     */
53
	public CMNNamedElementProxyNode(IMemento memento, Object parent) {
51
	public CMNNamedElementProxyNode(IMemento memento, Object parent) {
54
		super(memento, parent);
52
		super(memento, parent);
55
		this.name = memento.getString(TestUIConstants.TAG_NAME);
53
		this.name = memento.getString(TAG_NAME);
56
		if(this.name == null) {
54
		if(this.name == null) {
57
			throw new IllegalArgumentException("Malformed saved proxy state: unable to retrieve name field"); //$NON-NLS-1$
55
			throw new IllegalArgumentException("Malformed saved proxy state: unable to retrieve name field"); //$NON-NLS-1$
58
		}
56
		}
57
		this.description = memento.getString(TAG_DESCRIPTION);
59
	}
58
	}
60
	
59
	
61
	/** 
60
	/** 
Lines 66-72 Link Here
66
	public CMNNamedElementProxyNode(EObject eObject, Object parent) {
65
	public CMNNamedElementProxyNode(EObject eObject, Object parent) {
67
		super(eObject, parent);
66
		super(eObject, parent);
68
		if(eObject instanceof CMNNamedElement) {
67
		if(eObject instanceof CMNNamedElement) {
69
			this.name = ((CMNNamedElement)eObject).getName();
68
			CMNNamedElement namedElement = (CMNNamedElement)eObject;
69
			this.name = namedElement.getName();
70
			this.description = namedElement.getDescription();
70
		} else {
71
		} else {
71
			throw new IllegalArgumentException("CMNNamedElementProxyNode can only be built upon CMNNamedElement"); //$NON-NLS-1$
72
			throw new IllegalArgumentException("CMNNamedElementProxyNode can only be built upon CMNNamedElement"); //$NON-NLS-1$
72
		}
73
		}
Lines 90-95 Link Here
90
		this.name = name;
91
		this.name = name;
91
	}
92
	}
92
	
93
	
94
	public String getName() {
95
		return this.description;
96
	}
97
	
98
	/**
99
	 * Returns the description of the named element.
100
	 * @return
101
	 */
102
	public String getDescription() {
103
		return this.description;
104
	}
105
	
93
 	/**
106
 	/**
94
 	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
107
 	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
95
 	 */
108
 	 */
Lines 171-174 Link Here
171
	public RenamerUIStatus performUserInteraction(String oldName) {
184
	public RenamerUIStatus performUserInteraction(String oldName) {
172
		return new RenamerUIInlineEditor();
185
		return new RenamerUIInlineEditor();
173
	}
186
	}
187
	
188
	public boolean saveState(IMemento memento) { 
189
		memento.putString(TAG_NAME, getName());
190
		return super.saveState(memento);
191
	}
192
	
174
}
193
}
(-)src/org/eclipse/hyades/test/ui/navigator/DefaultTestSuiteProxyNode.java (-18 / +6 lines)
Lines 22-28 Link Here
22
import org.eclipse.hyades.test.ui.TestUIExtension;
22
import org.eclipse.hyades.test.ui.TestUIExtension;
23
import org.eclipse.hyades.test.ui.TestUIImages;
23
import org.eclipse.hyades.test.ui.TestUIImages;
24
import org.eclipse.hyades.test.ui.internal.navigator.proxy.TypedElementFactoryManager;
24
import org.eclipse.hyades.test.ui.internal.navigator.proxy.TypedElementFactoryManager;
25
import org.eclipse.hyades.ui.HyadesUIPlugin;
25
import org.eclipse.hyades.ui.extension.IAssociationConstants;
26
import org.eclipse.hyades.ui.extension.IAssociationDescriptor;
26
import org.eclipse.hyades.ui.extension.IAssociationDescriptor;
27
import org.eclipse.hyades.ui.extension.IAssociationMapping;
27
import org.eclipse.hyades.ui.extension.IAssociationMapping;
28
import org.eclipse.hyades.ui.internal.extension.AssociationMappingRegistry;
28
import org.eclipse.hyades.ui.internal.extension.AssociationMappingRegistry;
Lines 53-59 Link Here
53
	public DefaultTestSuiteProxyNode(TPFTestSuite ts, Object parent) {
53
	public DefaultTestSuiteProxyNode(TPFTestSuite ts, Object parent) {
54
		super(ts, parent);
54
		super(ts, parent);
55
		AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestSuiteMappingRegistry();
55
		AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestSuiteMappingRegistry();
56
		IAssociationMapping associationMapping = registry.getAssociationMapping(HyadesUIPlugin.EP_TYPE_DESCRIPTIONS);
56
		IAssociationMapping associationMapping = registry.getAssociationMapping(IAssociationConstants.EP_TYPE_DESCRIPTIONS);
57
		descriptor = associationMapping.getDefaultAssociationDescriptor(ts.getType());
57
		descriptor = associationMapping.getDefaultAssociationDescriptor(ts.getType());
58
		LinkedList tcProxies = new LinkedList();
58
		LinkedList tcProxies = new LinkedList();
59
		EList testcases = ts.getTestCases();
59
		EList testcases = ts.getTestCases();
Lines 76-82 Link Here
76
		super(memento, parent);
76
		super(memento, parent);
77
		//- set the descriptor according to the saved type. This is used in getImage() 
77
		//- set the descriptor according to the saved type. This is used in getImage() 
78
		AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestSuiteMappingRegistry();
78
		AssociationMappingRegistry registry = (AssociationMappingRegistry)TestUIExtension.getTestSuiteMappingRegistry();
79
		IAssociationMapping associationMapping = registry.getAssociationMapping(HyadesUIPlugin.EP_TYPE_DESCRIPTIONS);
79
		IAssociationMapping associationMapping = registry.getAssociationMapping(IAssociationConstants.EP_TYPE_DESCRIPTIONS);
80
		descriptor = associationMapping.getDefaultAssociationDescriptor(getType());
80
		descriptor = associationMapping.getDefaultAssociationDescriptor(getType());
81
81
82
		IMemento [] tcStates = memento.getChildren(TestUIConstants.TAG_CHILD);
82
		IMemento [] tcStates = memento.getChildren(TestUIConstants.TAG_CHILD);
Lines 86-92 Link Here
86
			IMemento mementoChild = tcStates[i];
86
			IMemento mementoChild = tcStates[i];
87
            //- inherit the TAG_URI_ROOT which is an extra data contained by the parent
87
            //- inherit the TAG_URI_ROOT which is an extra data contained by the parent
88
            mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT));
88
            mementoChild.putString(TestUIConstants.TAG_URI_ROOT, memento.getString(TestUIConstants.TAG_URI_ROOT));
89
			String type = mementoChild.getString(TestUIConstants.TAG_TYPE);
89
			String type = getType();
90
			if(type == null) {
90
			if(type == null) {
91
				throw new IllegalArgumentException("Malformed saved proxy state: unable to retrieve type field"); //$NON-NLS-1$
91
				throw new IllegalArgumentException("Malformed saved proxy state: unable to retrieve type field"); //$NON-NLS-1$
92
			}
92
			}
Lines 136-147 Link Here
136
		}
136
		}
137
	}
137
	}
138
	
138
	
139
    /**
139
	protected String getNodeKind() {
140
     * Returns the ID of the factory that is used to recreate this proxy node.
140
		return TestUIConstants.TESTSUITE_NODE;
141
     * @return the ID of the factory that is used to recreate this proxy node.
142
     */
143
	public String getFactoryID() {
144
		return "EMFResourceProxyFactory"; //$NON-NLS-1$
145
	}
141
	}
146
	
142
	
147
    /**
143
    /**
Lines 151-164 Link Here
151
     * @return the returned value is no longer significant.
147
     * @return the returned value is no longer significant.
152
     */
148
     */
153
	public boolean saveState(IMemento memento) {
149
	public boolean saveState(IMemento memento) {
154
		//- data to retrieve the correct object 
155
		memento.putString(TestUIConstants.TAG_NODE_KIND, TestUIConstants.TESTSUITE_NODE);
156
		//- data from TypedElementProxyNode
157
		memento.putString(TestUIConstants.TAG_TYPE, getType());
158
		//- data from CMNNamedElementProxyNode
159
		memento.putString(TestUIConstants.TAG_NAME, getText());
160
		//- data from EObjectProxyNode
161
		memento.putString(TestUIConstants.TAG_URI_FRAGMENT, getOriginatorURI().fragment());
162
		//- children (testcases)
150
		//- children (testcases)
163
		for (int i = 0; i < testCases.length; i++) {
151
		for (int i = 0; i < testCases.length; i++) {
164
			CMNNamedElementProxyNode tcProxy = testCases[i];
152
			CMNNamedElementProxyNode tcProxy = testCases[i];
(-)src/org/eclipse/hyades/test/ui/navigator/EObjectProxyNode.java (-2 / +18 lines)
Lines 21-26 Link Here
21
import org.eclipse.emf.ecore.util.EcoreUtil;
21
import org.eclipse.emf.ecore.util.EcoreUtil;
22
import org.eclipse.hyades.test.core.util.EMFUtil;
22
import org.eclipse.hyades.test.core.util.EMFUtil;
23
import org.eclipse.hyades.test.ui.TestUIConstants;
23
import org.eclipse.hyades.test.ui.TestUIConstants;
24
import org.eclipse.hyades.test.ui.internal.navigator.proxy.EMFResourceProxyFactory;
24
import org.eclipse.ui.IMemento;
25
import org.eclipse.ui.IMemento;
25
26
26
/** EMF object proxy element for the test navigator.
27
/** EMF object proxy element for the test navigator.
Lines 28-34 Link Here
28
 * EMF objects wrapped by subclasses will be stored in the test navigator resource set
29
 * EMF objects wrapped by subclasses will be stored in the test navigator resource set
29
 * @author jgout
30
 * @author jgout
30
 */
31
 */
31
public abstract class EObjectProxyNode implements IProxyNode {
32
public abstract class EObjectProxyNode implements IProxyNode, IPersistableProxyNode {
33
	
34
	private static final String TAG_URI_FRAGMENT = "uriFragment"; //$NON-NLS-1$
35
	
32
	private URI originatorURI;
36
	private URI originatorURI;
33
	private Object parent;
37
	private Object parent;
34
	
38
	
Lines 46-52 Link Here
46
            //- get the fragment part from the whole uri
50
            //- get the fragment part from the whole uri
47
            uriFragmentName = oldURI.fragment();
51
            uriFragmentName = oldURI.fragment();
48
        } else {
52
        } else {
49
            uriFragmentName = memento.getString(TestUIConstants.TAG_URI_FRAGMENT);
53
            uriFragmentName = memento.getString(TAG_URI_FRAGMENT);
50
        }
54
        }
51
		//- this data is not persisted but added by the proxy node loader (FileProxyManager#buildProxy)
55
		//- this data is not persisted but added by the proxy node loader (FileProxyManager#buildProxy)
52
        String uriRootName = memento.getString(TestUIConstants.TAG_URI_ROOT);
56
        String uriRootName = memento.getString(TestUIConstants.TAG_URI_ROOT);
Lines 141-144 Link Here
141
		return Platform.getAdapterManager().getAdapter(this, adapter);
145
		return Platform.getAdapterManager().getAdapter(this, adapter);
142
	}
146
	}
143
147
148
	public String getFactoryID() {
149
		return EMFResourceProxyFactory.ID;
150
	}
151
	
152
	public boolean saveState(IMemento memento) {
153
		memento.putString(TestUIConstants.TAG_NODE_KIND, getNodeKind());
154
		memento.putString(TAG_URI_FRAGMENT, getOriginatorURI().fragment());
155
		return true;
156
	}
157
	
158
	protected abstract String getNodeKind();
159
144
}
160
}
(-)src/org/eclipse/hyades/test/ui/navigator/TypedElementProxyNode.java (-2 / +9 lines)
Lines 14-20 Link Here
14
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult;
14
import org.eclipse.hyades.models.common.testprofile.TPFExecutionResult;
15
import org.eclipse.hyades.models.common.testprofile.TPFTest;
15
import org.eclipse.hyades.models.common.testprofile.TPFTest;
16
import org.eclipse.hyades.models.common.testprofile.TPFTestComponent;
16
import org.eclipse.hyades.models.common.testprofile.TPFTestComponent;
17
import org.eclipse.hyades.test.ui.TestUIConstants;
18
import org.eclipse.ui.IMemento;
17
import org.eclipse.ui.IMemento;
19
18
20
/** General proxy for typed element. 
19
/** General proxy for typed element. 
Lines 22-27 Link Here
22
 * @author jgout
21
 * @author jgout
23
 */
22
 */
24
public abstract class TypedElementProxyNode extends CMNNamedElementProxyNode implements ITypedElementProxyNode {
23
public abstract class TypedElementProxyNode extends CMNNamedElementProxyNode implements ITypedElementProxyNode {
24
	
25
	private static final String TAG_TYPE = "type"; //$NON-NLS-1$
26
	
25
	private String type; 
27
	private String type; 
26
	
28
	
27
    /**
29
    /**
Lines 61-67 Link Here
61
	 */
63
	 */
62
	public TypedElementProxyNode(IMemento memento, Object parent) {
64
	public TypedElementProxyNode(IMemento memento, Object parent) {
63
		super(memento, parent);
65
		super(memento, parent);
64
		this.type = memento.getString(TestUIConstants.TAG_TYPE);
66
		this.type = memento.getString(TAG_TYPE);
65
		if (this.type == null) {
67
		if (this.type == null) {
66
			throw new IllegalArgumentException("Malformed saved proxy state: unable to retrieve type field"); //$NON-NLS-1$
68
			throw new IllegalArgumentException("Malformed saved proxy state: unable to retrieve type field"); //$NON-NLS-1$
67
		}
69
		}
Lines 74-77 Link Here
74
		return type;
76
		return type;
75
	}
77
	}
76
	
78
	
79
    public boolean saveState(IMemento memento) {
80
        memento.putString(TAG_TYPE, getType());
81
        return super.saveState(memento);
82
    }
83
    
77
}
84
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/messages.properties (+4 lines)
Lines 13-20 Link Here
13
# NLS_MESSAGEFORMAT_VAR
13
# NLS_MESSAGEFORMAT_VAR
14
# NLS_ENCODING=UTF-8
14
# NLS_ENCODING=UTF-8
15
15
16
# Followings are used as labels of tree items in test navigator
16
TEST_NAVIGATOR_UNNAMED_ELEMENT=unnamed
17
TEST_NAVIGATOR_UNNAMED_ELEMENT=unnamed
17
PROXY_LOADING_ERROR=loading error
18
PROXY_LOADING_ERROR=loading error
19
18
OpenWithActionGroup_ActionLabel=Open Wit&h
20
OpenWithActionGroup_ActionLabel=Open Wit&h
19
FileFolderInContainerPaste_NameTwoArg=Copy ({0}) of {1}
21
FileFolderInContainerPaste_NameTwoArg=Copy ({0}) of {1}
20
FileFolderInContainerPaste_NameOneArg=Copy of {0}
22
FileFolderInContainerPaste_NameOneArg=Copy of {0}
Lines 24-26 Link Here
24
FileFolderInContainerPaste_MessageLabel=Enter a new name for ''{0}''
26
FileFolderInContainerPaste_MessageLabel=Enter a new name for ''{0}''
25
TestNavigatorActionGroup_ToggleAction_Text=Link with Editor
27
TestNavigatorActionGroup_ToggleAction_Text=Link with Editor
26
RenameAction_ActionName=Rena&me
28
RenameAction_ActionName=Rena&me
29
# The following is used as a range, e.g. "[1 - 100]", or "[901 - 1000]".
30
CHILD_GROUP=[{0} - {1}]
(-)src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigator.java (-32 / +43 lines)
Lines 12-17 Link Here
12
package org.eclipse.hyades.test.ui.internal.navigator;
12
package org.eclipse.hyades.test.ui.internal.navigator;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Collections;
15
import java.util.HashMap;
16
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.Iterator;
17
import java.util.List;
18
import java.util.List;
Lines 28-39 Link Here
28
import org.eclipse.emf.ecore.resource.Resource;
29
import org.eclipse.emf.ecore.resource.Resource;
29
import org.eclipse.emf.ecore.util.EcoreUtil;
30
import org.eclipse.emf.ecore.util.EcoreUtil;
30
import org.eclipse.hyades.models.common.common.CMNNamedElement;
31
import org.eclipse.hyades.models.common.common.CMNNamedElement;
31
import org.eclipse.hyades.models.common.testprofile.TPFTest;
32
import org.eclipse.hyades.test.core.util.EMFUtil;
32
import org.eclipse.hyades.test.core.util.EMFUtil;
33
import org.eclipse.hyades.test.ui.TestUIExtension;
33
import org.eclipse.hyades.test.ui.TestUIExtension;
34
import org.eclipse.hyades.test.ui.UiPlugin;
34
import org.eclipse.hyades.test.ui.UiPlugin;
35
import org.eclipse.hyades.test.ui.internal.editor.BaseEditorPart;
35
import org.eclipse.hyades.test.ui.internal.editor.BaseEditorPart;
36
import org.eclipse.hyades.test.ui.internal.model.ResourceUtil.ResourceAdaptable;
36
import org.eclipse.hyades.test.ui.internal.model.ResourceUtil.ResourceAdaptable;
37
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigatorProvider.IProxyGroup;
37
import org.eclipse.hyades.test.ui.internal.navigator.action.TestNavigatorActionGroup;
38
import org.eclipse.hyades.test.ui.internal.navigator.action.TestNavigatorActionGroup;
38
import org.eclipse.hyades.test.ui.internal.navigator.action.ToggleViewAction;
39
import org.eclipse.hyades.test.ui.internal.navigator.action.ToggleViewAction;
39
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileFactoryManager;
40
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileFactoryManager;
Lines 51-56 Link Here
51
import org.eclipse.hyades.test.ui.navigator.IProxyNodeListener;
52
import org.eclipse.hyades.test.ui.navigator.IProxyNodeListener;
52
import org.eclipse.hyades.test.ui.navigator.ITestNavigator;
53
import org.eclipse.hyades.test.ui.navigator.ITestNavigator;
53
import org.eclipse.hyades.test.ui.navigator.ITypeProviderContext;
54
import org.eclipse.hyades.test.ui.navigator.ITypeProviderContext;
55
import org.eclipse.hyades.test.ui.navigator.ITypedElementProxyNode;
54
import org.eclipse.hyades.ui.extension.IAssociationConstants;
56
import org.eclipse.hyades.ui.extension.IAssociationConstants;
55
import org.eclipse.hyades.ui.extension.IAssociationDescriptor;
57
import org.eclipse.hyades.ui.extension.IAssociationDescriptor;
56
import org.eclipse.hyades.ui.extension.IAssociationMapping;
58
import org.eclipse.hyades.ui.extension.IAssociationMapping;
Lines 462-486 Link Here
462
        } catch (NumberFormatException e) {
464
        } catch (NumberFormatException e) {
463
        }
465
        }
464
        NavigatorViewerSorter viewerSorter = new NavigatorViewerSorter(this, criteria) {
466
        NavigatorViewerSorter viewerSorter = new NavigatorViewerSorter(this, criteria) {
465
            protected String getValue(Viewer viewer, Object e) {
467
        	
466
                String value = super.getValue(viewer, e);
468
            protected int compareCategories(Object e1, Object e2) {
467
                if (e instanceof EObject) {
469
            	if (e1 instanceof IProxyGroup) {
468
                    EObject eObject = (EObject) e;
470
            		if (e2 instanceof IProxyGroup) {
469
                    if (eObject.eContainer() != null)
471
            			return ((IProxyGroup)e1).getOrder() - ((IProxyGroup)e2).getOrder();
470
                        return ""; //$NON-NLS-1$
472
            		}
473
            		return -1;
474
            	}
475
            	if (e2 instanceof IProxyGroup) {
476
            		return 1;
477
            	}
478
				return super.compareCategories(e1, e2);
479
			}
480
481
			public int category(Object element) {
482
            	if (element instanceof IResource) return super.category(element);
483
				if (element instanceof IAdaptable) {
484
					IResource res = (IResource)((IAdaptable)element).getAdapter(IResource.class);
485
					if (res != null) {
486
						return super.category(res);
487
					}
488
				}
489
				return super.category(element);
490
			}
471
491
492
			protected String getValue(Viewer viewer, Object e) {
493
                String value = super.getValue(viewer, e);
494
                if (e instanceof ITypedElementProxyNode) {
495
                	ITypedElementProxyNode proxy = (ITypedElementProxyNode) e;
472
                    if (getCriteria() == NavigatorViewerSorter.TYPE) {
496
                    if (getCriteria() == NavigatorViewerSorter.TYPE) {
473
                        if (eObject instanceof TPFTest) {
497
                        String type = proxy.getType();
474
                            String type = ((TPFTest) eObject).getType();
498
                        if (type != null)
475
                            if (type != null)
499
                            value = type + value;
476
                                value = type + value;
500
                        else
477
                            else
501
                            value = "zZz" + type; //$NON-NLS-1$
478
                                value = "zZz" + type; //$NON-NLS-1$
479
                        }
480
                        value = eObject.eClass().getName() + value;
481
                    }
502
                    }
482
                }
503
                }
483
484
                return value;
504
                return value;
485
            }
505
            }
486
        };
506
        };
Lines 524-544 Link Here
524
        if (input instanceof IFileEditorInput) {
544
        if (input instanceof IFileEditorInput) {
525
            IFileEditorInput fileInput = (IFileEditorInput) input;
545
            IFileEditorInput fileInput = (IFileEditorInput) input;
526
            IFile file = fileInput.getFile();
546
            IFile file = fileInput.getFile();
527
547
            selectReveal(new StructuredSelection(file));
528
            Resource resource = EMFUtil.getResource(null, file);
548
            return true;
529
            if ((resource != null) && (!resource.getContents().isEmpty())) {
530
                IStructuredSelection structuredSelection = getStructuredSelection();
531
                if (structuredSelection.size() == 1) {
532
                    Object currentSelection = structuredSelection.getFirstElement();
533
                    if (currentSelection instanceof EObject) {
534
                        if (((EObject) currentSelection).eResource() == resource)
535
                            return true;
536
                    }
537
                }
538
539
                selectReveal(new StructuredSelection(resource.getContents().get(0)));
540
                return true;
541
            }
542
        }
549
        }
543
550
544
        return false;
551
        return false;
Lines 970-976 Link Here
970
     * @return
977
     * @return
971
     */
978
     */
972
    public static Iterator getAllInstancesIterator() {
979
    public static Iterator getAllInstancesIterator() {
973
        return testNavigatorByWorkbenchWindow.values().iterator();
980
    	if (testNavigatorByWorkbenchWindow == null) {
981
    		return Collections.EMPTY_LIST.iterator();
982
    	} else {
983
    		return testNavigatorByWorkbenchWindow.values().iterator();
984
    	}
974
    }
985
    }
975
    
986
    
976
    /* (non-Javadoc)
987
    /* (non-Javadoc)
(-)src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorProvider.java (-1 / +104 lines)
Lines 19-30 Link Here
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
20
import org.eclipse.jface.viewers.ITreeContentProvider;
20
import org.eclipse.jface.viewers.ITreeContentProvider;
21
import org.eclipse.jface.viewers.Viewer;
21
import org.eclipse.jface.viewers.Viewer;
22
import org.eclipse.osgi.util.NLS;
23
import org.eclipse.swt.graphics.Image;
22
24
23
/**
25
/**
24
 * @author jgout
26
 * @author jgout
25
 */
27
 */
26
public abstract class TestNavigatorProvider extends TestNavigatorLabelProvider implements ITreeContentProvider {
28
public abstract class TestNavigatorProvider extends TestNavigatorLabelProvider implements ITreeContentProvider {
27
29
30
	private final static int MAX_PROXY_NODE_CHILDREN = 100;
31
28
	public Object getParent(Object element) {
32
	public Object getParent(Object element) {
29
		if (element instanceof IProxyNode) {
33
		if (element instanceof IProxyNode) {
30
            Object parent = ((IProxyNode) element).getParent();
34
            Object parent = ((IProxyNode) element).getParent();
Lines 42-58 Link Here
42
			IProxyNode proxy = (IProxyNode) parentElement;
46
			IProxyNode proxy = (IProxyNode) parentElement;
43
			return proxy.getChildren().length > 0;
47
			return proxy.getChildren().length > 0;
44
		}
48
		}
49
		if (parentElement instanceof IProxyGroup) {
50
			return true;
51
		}
45
		return false;
52
		return false;
46
	}
53
	}
47
54
48
	public Object[] getChildren(Object parentElement) {
55
	public Object[] getChildren(Object parentElement) {
49
		if (parentElement instanceof IProxyNode) {
56
		if (parentElement instanceof IProxyNode) {
50
			IProxyNode proxy = (IProxyNode) parentElement;
57
			IProxyNode proxy = (IProxyNode) parentElement;
51
			return proxy.getChildren();
58
			return foldProxyNodes(proxy);
59
		}
60
		if (parentElement instanceof IProxyGroup) {
61
			return ((IProxyGroup)parentElement).getChildren();
52
		}
62
		}
53
		return new Object[0];
63
		return new Object[0];
54
	}
64
	}
55
	
65
	
66
	public String getText(Object element) {
67
		if (element instanceof IProxyGroup) {
68
			return ((IProxyGroup)element).getText();
69
		}
70
		return super.getText(element);
71
	}
72
	
73
	public Image getImage(Object element) {
74
		if (element instanceof IProxyGroup) {
75
			return ((IProxyGroup)element).getImage();
76
		}
77
		return super.getImage(element);
78
	}
79
	
56
80
57
	public Object[] getElements(Object inputElement) {
81
	public Object[] getElements(Object inputElement) {
58
		if (inputElement instanceof IWorkspaceRoot) {
82
		if (inputElement instanceof IWorkspaceRoot) {
Lines 70-74 Link Here
70
    
94
    
71
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
95
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
72
	}
96
	}
97
	
98
	public static interface IProxyGroup {
99
		IProxyNode[] getChildren();
100
		String getText();
101
		Image getImage();
102
		int getOrder();
103
	}
104
	
105
	private static class ProxyGroup implements IProxyGroup {
106
		private IProxyNode parent;
107
		private int sequence;
108
		public ProxyGroup(IProxyNode node, int sequence) {
109
			this.parent = node;
110
			this.sequence = sequence;
111
		}
112
		public IProxyNode[] getChildren() {
113
			int start = sequence * MAX_PROXY_NODE_CHILDREN;
114
			IProxyNode[] completeChildren = parent.getChildren();
115
			IProxyNode[] children = new IProxyNode[MAX_PROXY_NODE_CHILDREN];
116
			System.arraycopy(completeChildren, start, children, 0, MAX_PROXY_NODE_CHILDREN);
117
			return children;
118
		}
119
		public String getText() {
120
			int start = sequence * MAX_PROXY_NODE_CHILDREN + 1;
121
			int end = (sequence + 1) * MAX_PROXY_NODE_CHILDREN;
122
			return NLS.bind(TestNavigatorMessages.CHILD_GROUP, new String[] { Integer.toString(start), Integer.toString(end) });
123
		}
124
		public Image getImage() {
125
			return parent.getImage();
126
		}
127
		public int getOrder() {
128
			return sequence;
129
		}
130
	}
131
	
132
	private static class RemainingProxyGroup implements IProxyGroup {
133
		private IProxyNode parent;
134
		public RemainingProxyGroup(IProxyNode parent) {
135
			this.parent = parent;
136
		}
137
		public IProxyNode[] getChildren() {
138
			IProxyNode[] completeChildren = parent.getChildren();
139
			int completeLength = completeChildren.length;
140
			int length = completeLength % MAX_PROXY_NODE_CHILDREN;
141
			IProxyNode[] children = new IProxyNode[length];
142
			System.arraycopy(completeChildren, completeLength - length, children, 0, length);
143
			return children;
144
		}
145
		public String getText() {
146
			IProxyNode[] completeChildren = parent.getChildren();
147
			int end = completeChildren.length;
148
			int length = end % MAX_PROXY_NODE_CHILDREN;
149
			int start = end - length + 1;
150
			return NLS.bind(TestNavigatorMessages.CHILD_GROUP, new String[] { Integer.toString(start), Integer.toString(end) });
151
		}
152
		public Image getImage() {
153
			return parent.getImage();
154
		}
155
		public int getOrder() {
156
			return Integer.MAX_VALUE;
157
		}
158
	}
159
	
160
	protected Object[] foldProxyNodes(IProxyNode parent) {
161
		IProxyNode[] children = parent.getChildren();
162
		int length = children.length;
163
		if (length <= MAX_PROXY_NODE_CHILDREN) return children;
164
		int size = length / MAX_PROXY_NODE_CHILDREN;
165
		int remaining = length % MAX_PROXY_NODE_CHILDREN;
166
		int totalSize = size + (remaining > 0 ? 1 : 0);
167
		Object[] groups = new IProxyGroup[totalSize];
168
		for (int i = 0; i < size; i++) {
169
			groups[i] = new ProxyGroup(parent, i);
170
		}
171
		if (remaining > 0) {
172
			groups[size] = new RemainingProxyGroup(parent);
173
		}
174
		return groups;
175
	}
73
176
74
}
177
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/TestDecoratingLabelProvider.java (-43 / +17 lines)
Lines 13-23 Link Here
13
package org.eclipse.hyades.test.ui.internal.navigator;
13
package org.eclipse.hyades.test.ui.internal.navigator;
14
14
15
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import java.util.LinkedList;
18
16
19
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFile;
20
import org.eclipse.hyades.test.ui.navigator.ITestNavigator;
18
import org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache;
19
import org.eclipse.hyades.test.ui.navigator.IProxyNode;
21
import org.eclipse.jface.viewers.DecoratingLabelProvider;
20
import org.eclipse.jface.viewers.DecoratingLabelProvider;
22
import org.eclipse.jface.viewers.IBaseLabelProvider;
21
import org.eclipse.jface.viewers.IBaseLabelProvider;
23
import org.eclipse.jface.viewers.ILabelDecorator;
22
import org.eclipse.jface.viewers.ILabelDecorator;
Lines 30-75 Link Here
30
 */
29
 */
31
public class TestDecoratingLabelProvider extends DecoratingLabelProvider implements ILabelProviderListener{
30
public class TestDecoratingLabelProvider extends DecoratingLabelProvider implements ILabelProviderListener{
32
31
33
	private LinkedList listeners;
32
	private final TestNavigator testNavigator;
34
	private final ITestNavigator testNavigator;
33
	
35
	/**
34
	/**
36
	 * @param provider
35
	 * @param provider
37
	 * @param decorator
36
	 * @param decorator
38
	 * @param testNavigator
37
	 * @param testNavigator
39
	 */
38
	 */
40
	public TestDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator, ITestNavigator testNavigator) {
39
	public TestDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator, TestNavigator testNavigator) {
41
		super(provider, decorator);
40
		super(provider, decorator);
42
		this.testNavigator = testNavigator;
41
		this.testNavigator = testNavigator;
43
		listeners = new LinkedList();
44
	}
45
	
46
	public void addListener(ILabelProviderListener listener) {
47
		ILabelDecorator decorator = getLabelDecorator();
48
		if(decorator != null) {
42
		if(decorator != null) {
49
			decorator.addListener(this);
43
			decorator.addListener(this);
50
		}
44
		}
51
		//- avoid multiple listener registration
52
		if(!listeners.contains(listener)) {
53
			ILabelProvider labelProvider = getLabelProvider();
54
			if(labelProvider != null) {
55
				labelProvider.addListener(listener);
56
			}
57
			listeners.add(listener);
58
		}
59
	}
45
	}
60
	
46
	
61
	public void removeListener(ILabelProviderListener listener) {
47
	public void dispose() {
62
		ILabelDecorator decorator = getLabelDecorator();
48
		ILabelDecorator decorator = getLabelDecorator();
63
		if(decorator != null) {
49
		if(decorator != null) {
64
			decorator.removeListener(this);
50
			decorator.removeListener(this);
65
		}
51
		}
66
		if(listeners.contains(listener)) {
52
		super.dispose();
67
			ILabelProvider labelProvider = getLabelProvider();
68
			if(labelProvider != null) {
69
				labelProvider.removeListener(listener);
70
			}
71
			listeners.remove(listener);
72
		}
73
	}
53
	}
74
54
75
	/* (non-Javadoc)
55
	/* (non-Javadoc)
Lines 86-110 Link Here
86
                    //- need to check is there is not a proxy define for this file
66
                    //- need to check is there is not a proxy define for this file
87
                    IFile file = (IFile) elem;
67
                    IFile file = (IFile) elem;
88
                    if (file.exists()) {
68
                    if (file.exists()) {
89
                        Object convertedObject = TestNavigator.getFileProxyManager().getProxy((IFile) elem, null);
69
                    	IProxyNode converted = FileProxyNodeCache.getInstance().getCachedProxy(file);
90
                        if (convertedObject != null) {
70
                    	if (converted != null) {
91
                            others.add(convertedObject);
71
                    		if (TestNavigator.getFileProxyManager().getParent(converted) != null) {
92
                        } else {
72
                    			others.add(converted);
93
                            others.add(elem);
73
                    		}
94
                        }
74
                    	}
95
                    } else {
96
                        others.add(elem);
97
                    }
75
                    }
98
                } else {
99
                    others.add(elem);
100
                }
76
                }
101
            }
77
            }
102
            event = new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
78
            if (others.size() > 0) {
79
	            event = new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
80
	            fireLabelProviderChanged(event);
81
            }
103
        }
82
        }
104
		//- delegate to all registered listeners with the new event content
105
		for (Iterator it = listeners.iterator(); it.hasNext();) {
106
			ILabelProviderListener l = (ILabelProviderListener) it.next();
107
			l.labelProviderChanged(event);
108
		}
109
	}
83
	}
110
}
84
}
(-)src/org/eclipse/hyades/test/ui/internal/navigator/TestNavigatorMessages.java (+1 lines)
Lines 35-38 Link Here
35
    public static String FileFolderInContainerPaste_MessageLabel;
35
    public static String FileFolderInContainerPaste_MessageLabel;
36
    public static String TestNavigatorActionGroup_ToggleAction_Text;
36
    public static String TestNavigatorActionGroup_ToggleAction_Text;
37
    public static String RenameAction_ActionName;
37
    public static String RenameAction_ActionName;
38
    public static String CHILD_GROUP;
38
}
39
}
(-)src/org/eclipse/hyades/test/ui/internal/model/CMNNamedElementUtil.java (+45 lines)
Lines 21-26 Link Here
21
import org.eclipse.hyades.models.common.common.CMNNamedElement;
21
import org.eclipse.hyades.models.common.common.CMNNamedElement;
22
import org.eclipse.hyades.models.common.common.CommonPackage;
22
import org.eclipse.hyades.models.common.common.CommonPackage;
23
import org.eclipse.hyades.test.core.util.EMFUtil;
23
import org.eclipse.hyades.test.core.util.EMFUtil;
24
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
24
import org.eclipse.hyades.ui.util.IDisposable;
25
import org.eclipse.hyades.ui.util.IDisposable;
25
import org.eclipse.hyades.ui.util.INamedElement;
26
import org.eclipse.hyades.ui.util.INamedElement;
26
import org.eclipse.ui.IElementFactory;
27
import org.eclipse.ui.IElementFactory;
Lines 181-186 Link Here
181
		}
182
		}
182
	}
183
	}
183
	
184
	
185
	public static class UIProxyNamedElement implements INamedElement, IDisposable {
186
187
		private CMNNamedElementProxyNode proxy;
188
		private CMNNamedElement loadedObject;
189
		
190
		public UIProxyNamedElement(CMNNamedElementProxyNode proxy) {
191
			this.proxy = proxy;
192
		}
193
		
194
		private CMNNamedElement loadNamedElement() {
195
			if (loadedObject == null) {
196
				loadedObject = (CMNNamedElement) proxy.getEObject();
197
			}
198
			return loadedObject;
199
		}
200
		
201
		public String getDescription() {
202
			return proxy.getDescription();
203
		}
204
205
		public String getName() {
206
			return proxy.getText();
207
		}
208
209
		public void setDescription(String description) {
210
			throw new UnsupportedOperationException();
211
		}
212
213
		public void setName(String name) {
214
			throw new UnsupportedOperationException();
215
		}
216
217
		public Object getAdapter(Class adapter) {
218
			if(INamedElement.class == adapter)
219
				return this;
220
			return proxy.getAdapter(adapter);
221
		}
222
223
		public void dispose() {
224
			loadedObject = null;
225
		}
226
		
227
	}
228
	
184
	public static interface NameChangeObserver
229
	public static interface NameChangeObserver
185
	{
230
	{
186
		public void update(CMNNamedElement namedElement, String oldName);
231
		public void update(CMNNamedElement namedElement, String oldName);
(-)src/org/eclipse/hyades/test/ui/adapter/CMNNamedElementPropertySource.java (-2 / +7 lines)
Lines 13-26 Link Here
13
13
14
import org.eclipse.hyades.models.common.common.CMNNamedElement;
14
import org.eclipse.hyades.models.common.common.CMNNamedElement;
15
import org.eclipse.hyades.test.ui.internal.model.CMNNamedElementUtil.UINamedElement;
15
import org.eclipse.hyades.test.ui.internal.model.CMNNamedElementUtil.UINamedElement;
16
import org.eclipse.hyades.test.ui.internal.model.CMNNamedElementUtil.UIProxyNamedElement;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
16
import org.eclipse.hyades.ui.adapter.NamedElementPropertySource;
18
import org.eclipse.hyades.ui.adapter.NamedElementPropertySource;
17
19
18
20
19
public class CMNNamedElementPropertySource
21
public class CMNNamedElementPropertySource
20
extends NamedElementPropertySource
22
extends NamedElementPropertySource
21
{
23
{
22
	public CMNNamedElementPropertySource(CMNNamedElement namedElement)
24
	public CMNNamedElementPropertySource(CMNNamedElement namedElement) {
23
	{
24
		super(new UINamedElement(namedElement));		
25
		super(new UINamedElement(namedElement));		
25
	}
26
	}
27
	
28
	public CMNNamedElementPropertySource(CMNNamedElementProxyNode proxy) {
29
		super(new UIProxyNamedElement(proxy));
30
	}
26
}
31
}
(-)src/org/eclipse/hyades/test/ui/TestUIConstants.java (-1 / +20 lines)
Lines 11-33 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.hyades.test.ui;
12
package org.eclipse.hyades.test.ui;
13
13
14
/** Constants storage interface
14
/**
15
 * Constants storage interface
15
 * @author jgout
16
 * @author jgout
16
 */
17
 */
17
public interface TestUIConstants {
18
public interface TestUIConstants {
18
	
19
	
20
    /**
21
     * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path
22
     */
19
	public static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
23
	public static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$
20
	public static final String TAG_NODE_KIND = "nodeKind"; //$NON-NLS-1$
24
	public static final String TAG_NODE_KIND = "nodeKind"; //$NON-NLS-1$
25
    /**
26
     * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path
27
     */
21
	public static final String TAG_NAME = "name"; //$NON-NLS-1$
28
	public static final String TAG_NAME = "name"; //$NON-NLS-1$
22
	public static final String TAG_TYPE = "type"; //$NON-NLS-1$
29
	public static final String TAG_TYPE = "type"; //$NON-NLS-1$
23
    /**
30
    /**
24
     * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path
31
     * @deprecated use TAG_FRAGMENT instead. We no longer should persiste the full URI because it contains file path
25
     */
32
     */
26
    public static final String TAG_URI = "uri"; //$NON-NLS-1$
33
    public static final String TAG_URI = "uri"; //$NON-NLS-1$
34
    /**
35
     * @deprecated This constant was mistakenly published.
36
     */
27
	public static final String TAG_URI_FRAGMENT = "uriFragment"; //$NON-NLS-1$
37
	public static final String TAG_URI_FRAGMENT = "uriFragment"; //$NON-NLS-1$
28
    public static final String TAG_URI_ROOT = "uriRoot"; //$NON-NLS-1$
38
    public static final String TAG_URI_ROOT = "uriRoot"; //$NON-NLS-1$
39
    /**
40
     * @deprecated This constant was mistakenly published.
41
     */
29
	public static final String TAG_IDENTIFIER = "identifier"; //$NON-NLS-1$
42
	public static final String TAG_IDENTIFIER = "identifier"; //$NON-NLS-1$
43
    /**
44
     * @deprecated This constant was mistakenly published.
45
     */
30
	public static final String TAG_UNDERLYING_RESOURCE = "underlyingResource"; //$NON-NLS-1$
46
	public static final String TAG_UNDERLYING_RESOURCE = "underlyingResource"; //$NON-NLS-1$
47
    /**
48
     * @deprecated This constant was mistakenly published.
49
     */
31
	public static final String TAG_VERDICT = "verdict"; //$NON-NLS-1$
50
	public static final String TAG_VERDICT = "verdict"; //$NON-NLS-1$
32
	
51
	
33
	//- hyades default value of tag TAG_NODE_KIND 
52
	//- hyades default value of tag TAG_NODE_KIND 
(-)src/org/eclipse/hyades/test/tools/ui/java/internal/junit/navigator/JUnitTestSuiteProxyNode.java (-6 lines)
Lines 39-48 Link Here
39
        return "org.eclipse.hyades.test.tools.ui.JUnitTestSuiteFactory"; //$NON-NLS-1$
39
        return "org.eclipse.hyades.test.tools.ui.JUnitTestSuiteFactory"; //$NON-NLS-1$
40
    }
40
    }
41
    
41
    
42
    /* (non-Javadoc)
43
     * @see org.eclipse.hyades.test.ui.navigator.IPersistableProxyNode#saveState(org.eclipse.ui.IMemento)
44
     */
45
    public boolean saveState(IMemento memento) {
46
        return super.saveState(memento);
47
    }
48
}
42
}
(-)src/org/eclipse/hyades/test/tools/ui/java/internal/TestJavaPropertySource.java (-4 / +13 lines)
Lines 14-19 Link Here
14
import org.eclipse.hyades.models.common.common.CMNNamedElement;
14
import org.eclipse.hyades.models.common.common.CMNNamedElement;
15
import org.eclipse.hyades.test.ui.adapter.CMNNamedElementPropertySource;
15
import org.eclipse.hyades.test.ui.adapter.CMNNamedElementPropertySource;
16
import org.eclipse.hyades.test.ui.adapter.INamedElementPropertySource;
16
import org.eclipse.hyades.test.ui.adapter.INamedElementPropertySource;
17
import org.eclipse.hyades.test.ui.navigator.CMNNamedElementProxyNode;
17
import org.eclipse.hyades.test.ui.navigator.IExecutionResultProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.IExecutionResultProxyNode;
18
import org.eclipse.hyades.test.ui.navigator.ITestCaseProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.ITestCaseProxyNode;
19
import org.eclipse.hyades.test.ui.navigator.ITestComponentProxyNode;
20
import org.eclipse.hyades.test.ui.navigator.ITestComponentProxyNode;
Lines 26-41 Link Here
26
public class TestJavaPropertySource implements INamedElementPropertySource {
27
public class TestJavaPropertySource implements INamedElementPropertySource {
27
28
28
	public IPropertySource getPropertySource(Object adaptableObject) {
29
	public IPropertySource getPropertySource(Object adaptableObject) {
30
		if (adaptableObject instanceof CMNNamedElementProxyNode) {
31
			return new CMNNamedElementPropertySource((CMNNamedElementProxyNode)adaptableObject);
32
		}
29
		if(adaptableObject instanceof ITestSuiteProxyNode) {
33
		if(adaptableObject instanceof ITestSuiteProxyNode) {
30
			return new CMNNamedElementPropertySource(((ITestSuiteProxyNode)adaptableObject).getTestSuite());
34
			return new CMNNamedElementPropertySource(((ITestSuiteProxyNode)adaptableObject).getTestSuite());
31
		} else if(adaptableObject instanceof ITestCaseProxyNode) {
35
		}
36
		if(adaptableObject instanceof ITestCaseProxyNode) {
32
			return new CMNNamedElementPropertySource(((ITestCaseProxyNode)adaptableObject).getTestCase());
37
			return new CMNNamedElementPropertySource(((ITestCaseProxyNode)adaptableObject).getTestCase());
33
		} else if(adaptableObject instanceof ITestComponentProxyNode) {
38
		}
39
		if(adaptableObject instanceof ITestComponentProxyNode) {
34
			return new CMNNamedElementPropertySource(((ITestComponentProxyNode)adaptableObject).getTestComponent());
40
			return new CMNNamedElementPropertySource(((ITestComponentProxyNode)adaptableObject).getTestComponent());
35
		} else if(adaptableObject instanceof IExecutionResultProxyNode) {
41
		}
42
		if(adaptableObject instanceof IExecutionResultProxyNode) {
36
			return new CMNNamedElementPropertySource(((IExecutionResultProxyNode)adaptableObject).getExecutionResult());
43
			return new CMNNamedElementPropertySource(((IExecutionResultProxyNode)adaptableObject).getExecutionResult());
37
		} else {
44
		}
45
		if (adaptableObject instanceof CMNNamedElement){
38
			return new CMNNamedElementPropertySource((CMNNamedElement)adaptableObject);
46
			return new CMNNamedElementPropertySource((CMNNamedElement)adaptableObject);
39
		}
47
		}
48
		return null;
40
	}
49
	}
41
}
50
}

Return to bug 160221