Search in sources :

Example 16 with IRuntimeType

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");
            }
        });
    }
}
Also used : RuntimeTypeWithServerProxy(org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) ArrayList(java.util.ArrayList)

Example 17 with IRuntimeType

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();
}
Also used : IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) ArrayList(java.util.ArrayList)

Example 18 with IRuntimeType

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;
}
Also used : RuntimeTypeWithServerProxy(org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) Image(org.eclipse.swt.graphics.Image) DefaultServerImageDescriptor(org.eclipse.wst.server.ui.internal.DefaultServerImageDescriptor)

Example 19 with IRuntimeType

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());
}
Also used : IRuntimeType(org.eclipse.wst.server.core.IRuntimeType)

Example 20 with IRuntimeType

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;
}
Also used : IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) Image(org.eclipse.swt.graphics.Image) IRuntime(org.eclipse.wst.server.core.IRuntime)

Aggregations

IRuntimeType (org.eclipse.wst.server.core.IRuntimeType)35 IRuntime (org.eclipse.wst.server.core.IRuntime)17 IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)12 IServerType (org.eclipse.wst.server.core.IServerType)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)9 CoreException (org.eclipse.core.runtime.CoreException)8 IPath (org.eclipse.core.runtime.IPath)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Path (org.eclipse.core.runtime.Path)3 GenericServerRuntime (org.eclipse.jst.server.generic.core.internal.GenericServerRuntime)3 Image (org.eclipse.swt.graphics.Image)3 IServer (org.eclipse.wst.server.core.IServer)3 File (java.io.File)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2