blob: d6ccd98aa596797cc780ee3cabe4010cffb9f346 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* Licensed Materials - Property of IBM,
* WebSphere Studio Workbench
* (c) Copyright IBM Corp 2000, 2001
*/
package org.eclipse.compare.internal;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.compare.*;
import org.eclipse.jface.viewers.Viewer;
/**
* Creates <code>Viewer</code>s from an <code>IConfigurationElement</code>.
*/
public class ViewerDescriptor implements IViewerDescriptor {
private final static String CLASS_ATTRIBUTE= "class";
private final static String EXTENSIONS_ATTRIBUTE= "extensions";
private IConfigurationElement fConfiguration;
private IViewerCreator fViewerCreator;
public ViewerDescriptor(IConfigurationElement config) {
fConfiguration= config;
}
public Viewer createViewer(Viewer currentViewer, Composite parent, CompareConfiguration mp) {
String className= fConfiguration.getAttribute(CLASS_ATTRIBUTE);
if (currentViewer != null && currentViewer.getClass().getName().equals(className)) {
return currentViewer;
}
if (fViewerCreator == null) {
try {
fViewerCreator= (IViewerCreator) fConfiguration.createExecutableExtension(CLASS_ATTRIBUTE);
} catch (CoreException e) {
}
}
if (fViewerCreator != null) {
Viewer viewer= fViewerCreator.createViewer(parent, mp);
//if (viewer != null && currentViewer != null && viewer.getClass() == currentViewer.getClass())
// return currentViewer;
return viewer;
}
return null;
}
public String getExtension() {
return fConfiguration.getAttribute(EXTENSIONS_ATTRIBUTE);
}
}
|