Search in sources :

Example 1 with IRuntimeType

use of org.eclipse.wst.server.core.IRuntimeType in project sling by apache.

the class SlingWstServer method before.

@Override
protected void before() throws Throwable {
    IRuntimeType launchpadRuntime = null;
    for (IRuntimeType type : ServerCore.getRuntimeTypes()) {
        if ("org.apache.sling.ide.launchpadRuntimeType".equals(type.getId())) {
            launchpadRuntime = type;
            break;
        }
    }
    if (launchpadRuntime == null) {
        throw new IllegalArgumentException("No runtime of type 'org.apache.sling.ide.launchpadRuntimeType' found");
    }
    IRuntimeWorkingCopy rtwc = launchpadRuntime.createRuntime("temp.sling.launchpad.rt.id", new NullProgressMonitor());
    rtwc.save(true, new NullProgressMonitor());
    IServerType serverType = null;
    for (IServerType type : ServerCore.getServerTypes()) {
        if ("org.apache.sling.ide.launchpadServer".equals(type.getId())) {
            serverType = type;
            break;
        }
    }
    if (serverType == null) {
        throw new IllegalArgumentException("No server type of type 'org.apache.sling.ide.launchpadServer' found");
    }
    IServerWorkingCopy wc = serverType.createServer("temp.sling.launchpad.server.id", null, new NullProgressMonitor());
    wc.setHost(config.getHostname());
    wc.setAttribute(ISlingLaunchpadServer.PROP_PORT, config.getPort());
    wc.setAttribute(ISlingLaunchpadServer.PROP_CONTEXT_PATH, config.getContextPath());
    wc.setAttribute(ISlingLaunchpadServer.PROP_USERNAME, config.getUsername());
    wc.setAttribute(ISlingLaunchpadServer.PROP_PASSWORD, config.getPassword());
    wc.setAttribute("auto-publish-time", 0);
    server = wc.save(true, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServerType(org.eclipse.wst.server.core.IServerType) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 2 with IRuntimeType

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

the class TomcatRuntimeLocator method getRuntimeFromDir.

protected static IRuntimeWorkingCopy getRuntimeFromDir(File dir, IProgressMonitor monitor) {
    for (int i = 0; i < runtimeTypes.length; i++) {
        try {
            IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypes[i]);
            String absolutePath = dir.getAbsolutePath();
            String id = absolutePath.replace(File.separatorChar, '_').replace(':', '-');
            IRuntimeWorkingCopy runtime = runtimeType.createRuntime(id, monitor);
            runtime.setName(dir.getName());
            runtime.setLocation(new Path(absolutePath));
            ITomcatRuntimeWorkingCopy wc = (ITomcatRuntimeWorkingCopy) runtime.loadAdapter(ITomcatRuntimeWorkingCopy.class, null);
            wc.setVMInstall(JavaRuntime.getDefaultVMInstall());
            IStatus status = runtime.validate(monitor);
            if (status == null || status.getSeverity() != IStatus.ERROR)
                return runtime;
            Trace.trace(Trace.FINER, "False runtime found at " + dir.getAbsolutePath() + ": " + status.getMessage());
        } catch (Exception e) {
            Trace.trace(Trace.SEVERE, "Could not find runtime", e);
        }
    }
    return null;
}
Also used : IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Example 3 with IRuntimeType

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

the class GenericServerRuntimeWizardFragment method createName.

private String createName() {
    RuntimeDelegate dl = getRuntimeDelegate();
    IRuntimeType runtimeType = dl.getRuntime().getRuntimeType();
    String name = NLS.bind(GenericServerUIMessages.runtimeName, runtimeType.getName());
    IRuntime[] list = ServerCore.getRuntimes();
    int suffix = 1;
    String suffixName = name;
    for (int i = 0; i < list.length; i++) {
        if ((list[i].getName().equals(name) || list[i].getName().equals(suffixName)) && !list[i].equals(dl.getRuntime()))
            suffix++;
        suffixName = name + ' ' + suffix;
    }
    if (suffix > 1)
        return suffixName;
    return name;
}
Also used : IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) RuntimeDelegate(org.eclipse.wst.server.core.model.RuntimeDelegate) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 4 with IRuntimeType

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

the class RuntimeBridge method getExportedRuntimeNames.

public Set<String> getExportedRuntimeNames() throws CoreException {
    IRuntime[] runtimes = ServerCore.getRuntimes();
    Set<String> result = new HashSet<String>(runtimes.length);
    for (int i = 0; i < runtimes.length; i++) {
        IRuntime runtime = runtimes[i];
        IRuntimeType runtimeType = runtime.getRuntimeType();
        if (runtimeType != null && mappings.containsKey(runtimeType.getId())) {
            result.add(runtime.getId());
        }
    }
    return result;
}
Also used : IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 5 with IRuntimeType

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

the class RuntimeTreeLabelProvider method getImageImpl.

/**
 */
protected Image getImageImpl(Object element) {
    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