Search in sources :

Example 56 with IServer

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

the class ServerLabelProvider method getImage.

public Image getImage(Object element) {
    Image image = null;
    if (element instanceof ModuleServer) {
        ModuleServer ms = (ModuleServer) element;
        ILabelProvider labelProvider = ServerUICore.getLabelProvider();
        image = labelProvider.getImage(ms.module[ms.module.length - 1]);
        labelProvider.dispose();
    } else if (element instanceof IServer) {
        IServer server = (IServer) element;
        if (server.getServerType() != null) {
            // Ideally we won't be doing the overlay of the state here, but rather in a decorator so that
            // users can turn it off and on. This works for now until we have more time to work and reorganize
            // the code
            Image serverTypeImg = ImageResource.getImage(server.getServerType().getId());
            Image serverStatusImg = ServerDecorator.getServerStateImageOverlay(server);
            // Images returned via the CompositeServerImageDescriptor#createImage() need to be cached since this API
            // will always create a new Image and it is impossible to know when to dispose them except when the
            // label provider is disposed.
            final String key = this.getCacheKey(server, serverTypeImg, serverStatusImg);
            image = this.providerImageCache.get(key);
            if (image == null) {
                CompositeServerImageDescriptor dsid = new CompositeServerImageDescriptor(serverTypeImg, serverStatusImg);
                image = dsid.createImage();
                this.providerImageCache.put(key, image);
            }
        }
    }
    return image;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) Image(org.eclipse.swt.graphics.Image)

Example 57 with IServer

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

the class OptionalClientWizardFragment method updateClients.

protected void updateClients() {
    if (getTaskModel() == null)
        return;
    try {
        IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
        if (server == null) {
            getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, null);
            getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, null);
            getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null);
            getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false));
            return;
        }
        // if (lastServer == null)
        // return;
        // get the launchable adapter and module object
        Object launchable = null;
        try {
            Object[] obj = ServerUIPlugin.getLaunchableAdapter(server, moduleArtifact);
            getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, obj[0]);
            getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, obj[1]);
            launchable = obj[1];
        } catch (CoreException ce) {
            getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, null);
            getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, null);
            getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null);
            getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false));
            EclipseUtil.openError(null, ce.getStatus());
            return;
        }
        // stop here if the server and launchable haven't changed
        if (lastServer != null && lastServer.equals(server)) {
            if (lastLaunchable == null && launchable == null)
                return;
            if (lastLaunchable != null && lastLaunchable.equals(launchable)) {
                return;
            }
        }
        lastServer = server;
        lastLaunchable = launchable;
        String launchMode = (String) getTaskModel().getObject(TaskModel.TASK_LAUNCH_MODE);
        clients = ServerUIPlugin.getClients(server, launchable, launchMode);
        getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null);
        getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false));
        if (clients != null) {
            if (clients.length > 1) {
                getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, clients);
                getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(true));
            } else
                getTaskModel().putObject(WizardTaskUtil.TASK_CLIENT, clients[0]);
        }
        updateChildFragments();
    } catch (Exception e) {
    // ignore
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) CoreException(org.eclipse.core.runtime.CoreException) CoreException(org.eclipse.core.runtime.CoreException)

Example 58 with IServer

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

the class ServerPerformanceTestCase method getFirstServer.

protected IServer getFirstServer(String serverTypeId) {
    IServer[] servers = ServerCore.getServers();
    assertTrue(servers.length > 0);
    IServer server = servers[0];
    assertNotNull(server);
    assertTrue(server.getServerType().getId().equals(serverTypeId));
    return server;
}
Also used : IServer(org.eclipse.wst.server.core.IServer)

Example 59 with IServer

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

the class AbstractOpenEditorTestCase method testOpenEditor.

public void testOpenEditor() throws Exception {
    IServer server = getServer();
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart editor = page.openEditor(new ServerEditorInput(server.getId()), SERVER_EDITOR_ID, true);
    page.closeEditor(editor, false);
    releaseServer(server);
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ServerEditorInput(org.eclipse.wst.server.ui.internal.editor.ServerEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 60 with IServer

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

the class AbstractOpenEditorTestCase method testOpenEditor.

public void testOpenEditor() throws Exception {
    startMeasuring();
    IServer server = getFirstServer(getServerTypeId());
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart editor = page.openEditor(new ServerEditorInput(server.getId()), SERVER_EDITOR_ID, true);
    stopMeasuring();
    commitMeasurements();
    assertPerformance();
    page.closeEditor(editor, false);
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ServerEditorInput(org.eclipse.wst.server.ui.internal.editor.ServerEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

IServer (org.eclipse.wst.server.core.IServer)183 CoreException (org.eclipse.core.runtime.CoreException)39 IModule (org.eclipse.wst.server.core.IModule)32 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)30 Test (org.junit.Test)30 IProject (org.eclipse.core.resources.IProject)25 IStatus (org.eclipse.core.runtime.IStatus)25 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)23 ArrayList (java.util.ArrayList)20 File (java.io.File)17 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 Status (org.eclipse.core.runtime.Status)12 Iterator (java.util.Iterator)11 IPath (org.eclipse.core.runtime.IPath)11 IServerType (org.eclipse.wst.server.core.IServerType)11 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)11 IOException (java.io.IOException)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 Server (org.eclipse.wst.server.core.internal.Server)10 IFolder (org.eclipse.core.resources.IFolder)8