Search in sources :

Example 1 with RuntimeTypeWithServerProxy

use of org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy in project webtools.servertools by eclipse.

the class NewRuntimeWizardFragment method createChildFragments.

protected void createChildFragments(List<WizardFragment> list) {
    if (getTaskModel() == null)
        return;
    Object runtime = getTaskModel().getObject(TaskModel.TASK_RUNTIME);
    if (runtime == null)
        return;
    WizardFragment sub = null;
    if (runtime instanceof IRuntimeWorkingCopy)
        sub = getWizardFragment(((RuntimeWorkingCopy) runtime).getRuntimeType().getId());
    else if (runtime instanceof RuntimeTypeWithServerProxy)
        sub = getWizardFragment(((RuntimeTypeWithServerProxy) runtime).getId());
    if (sub != null)
        list.add(sub);
    Object serverObj = getTaskModel().getObject(TaskModel.TASK_SERVER);
    if (serverObj != null && serverObj instanceof IServerWorkingCopy) {
        IServerWorkingCopy server = (IServerWorkingCopy) serverObj;
        if (server.getServerType().hasServerConfiguration() && server instanceof ServerWorkingCopy) {
            ServerWorkingCopy swc = (ServerWorkingCopy) server;
            try {
                if (runtime instanceof IRuntimeWorkingCopy) {
                    RuntimeWorkingCopy runtimeWorkingCopy = (RuntimeWorkingCopy) runtime;
                    if (runtimeWorkingCopy.getLocation() != null && !runtimeWorkingCopy.getLocation().isEmpty())
                        swc.importRuntimeConfiguration(runtimeWorkingCopy, null);
                }
            } catch (CoreException ce) {
            // ignore
            }
        }
        list.add(new WizardFragment() {

            public void enter() {
                IRuntimeWorkingCopy runtime2 = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
                IServerWorkingCopy server2 = (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER);
                server2.setRuntime(runtime2);
            }
        });
        sub = getWizardFragment(server.getServerType().getId());
        if (sub != null)
            list.add(sub);
        list.add(WizardTaskUtil.SaveServerFragment);
    }
}
Also used : RuntimeTypeWithServerProxy(org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy) ServerWorkingCopy(org.eclipse.wst.server.core.internal.ServerWorkingCopy) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) CoreException(org.eclipse.core.runtime.CoreException) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) RuntimeWorkingCopy(org.eclipse.wst.server.core.internal.RuntimeWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 2 with RuntimeTypeWithServerProxy

use of org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy 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 3 with RuntimeTypeWithServerProxy

use of org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy 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)

Aggregations

RuntimeTypeWithServerProxy (org.eclipse.wst.server.core.internal.RuntimeTypeWithServerProxy)3 IRuntimeType (org.eclipse.wst.server.core.IRuntimeType)2 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 Image (org.eclipse.swt.graphics.Image)1 IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)1 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)1 RuntimeWorkingCopy (org.eclipse.wst.server.core.internal.RuntimeWorkingCopy)1 ServerWorkingCopy (org.eclipse.wst.server.core.internal.ServerWorkingCopy)1 DefaultServerImageDescriptor (org.eclipse.wst.server.ui.internal.DefaultServerImageDescriptor)1 WizardFragment (org.eclipse.wst.server.ui.wizard.WizardFragment)1