use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.
the class RuntimeTypeTreeContentProvider method deferredAdapterInitialize.
protected void deferredAdapterInitialize(final TreeViewer treeViewer, IProgressMonitor monitor) {
List<TreeElement> list = new ArrayList<TreeElement>();
IRuntimeType[] runtimeTypes = ServerCore.getDownloadableRuntimeTypes(monitor);
if (runtimeTypes != null) {
int size = runtimeTypes.length;
for (int i = 0; i < size; i++) {
IRuntimeType runtimeType = runtimeTypes[i];
try {
if (!((RuntimeType) runtimeType).supportsManualCreation()) {
// Hide this runtime type from the list.
continue;
}
} catch (Exception e) {
// Do nothing since all IRuntimeType should be instance of RuntimeType.
}
TreeElement ele = getOrCreate(list, runtimeType.getVendor());
if (compareRuntimes(ele.contents, (RuntimeTypeWithServerProxy) runtimeType))
continue;
if (!compareRuntimes(runtimeInstalledList, (RuntimeTypeWithServerProxy) runtimeType)) {
// Sometime vendor name is different so need to search the entire list
ele.contents.add(runtimeType);
elementToParentMap.put(runtimeType, ele);
} else {
// Remove the empty node
if (ele.contents.isEmpty()) {
list.remove(ele);
elementToParentMap.remove(ele);
}
}
}
}
if (list.size() > 0) {
List<Object> newList = new ArrayList<Object>();
newList.addAll(Arrays.asList(elements));
newList.addAll(list);
elements = newList.toArray();
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (!treeViewer.getTree().isDisposed())
treeViewer.refresh("root");
}
});
}
}
use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.
the class RuntimeTypeTreeContentProvider method fillTree.
public void fillTree() {
clean();
runtimeInstalledList = new ArrayList<IRuntimeType>();
List<TreeElement> list = new ArrayList<TreeElement>();
IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version, runtimeTypeId);
if (runtimeTypes != null) {
int size = runtimeTypes.length;
for (int i = 0; i < size; i++) {
IRuntimeType runtimeType = runtimeTypes[i];
if (!creation || runtimeType.canCreate()) {
try {
if (!((RuntimeType) runtimeType).supportsManualCreation()) {
// Hide this runtime type from the list.
continue;
}
} catch (Exception e) {
// Do nothing since all IRuntimeType should be instance of RuntimeType.
}
TreeElement ele = getOrCreate(list, runtimeType.getVendor());
ele.contents.add(runtimeType);
elementToParentMap.put(runtimeType, ele);
runtimeInstalledList.add(runtimeType);
}
}
}
elements = list.toArray();
}
use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.
the class RuntimeTypeTreeLabelProvider method getImageImpl.
/**
*/
protected Image getImageImpl(Object element) {
IRuntimeType runtimeType = (IRuntimeType) element;
Image image = ImageResource.getImage(runtimeType.getId());
DefaultServerImageDescriptor dsid = null;
if (element instanceof RuntimeTypeWithServerProxy) {
Image image1 = ImageResource.getImage(ImageResource.IMG_DOWN_ARROW);
dsid = new DefaultServerImageDescriptor(image, image1);
dsid.setFlags(DefaultServerImageDescriptor.BOTTOM_RIGHT);
image = dsid.createImage();
}
return image;
}
use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.
the class DefaultViewerSorter method compareServerTypes.
/**
* Sort two server types.
*
* @param s1 the first server type
* @param s2 the second server type
* @return a negative number if the first element is less than the
* second element; the value <code>0</code> if the first element is
* equal to the second element; and a positive number if the first
* element is greater than the second element
*/
protected static int compareServerTypes(IServerType s1, IServerType s2) {
IRuntimeType r1 = s1.getRuntimeType();
IRuntimeType r2 = s2.getRuntimeType();
if (r1 != null && r2 != null) {
if (isSameFamily(s1.getName(), r1.getVersion(), s2.getName(), r2.getVersion()))
return compareVersions(r1.getVersion(), r2.getVersion());
}
return alphanum.compare(s1.getName(), s2.getName());
}
use of org.eclipse.wst.server.core.IRuntimeType in project webtools.servertools by eclipse.
the class RuntimeTableLabelProvider method getColumnImage.
/**
* @see ITableLabelProvider#getColumnImage(Object, int)
*/
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex == 0) {
IRuntime runtime = (IRuntime) element;
IRuntimeType runtimeType = runtime.getRuntimeType();
if (runtimeType != null) {
Image image = ImageResource.getImage(runtimeType.getId());
if (decorator != null) {
Image dec = decorator.decorateImage(image, element);
if (dec != null)
return dec;
}
return image;
}
}
return null;
}
Aggregations