Search in sources :

Example 11 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.

the class ServerLabelProvider method getForeground.

public Color getForeground(Object element) {
    if (element instanceof ModuleServer) {
        ModuleServer ms = (ModuleServer) element;
        IModule module = ms.module[0];
        if (module.isExternal()) {
            Color c = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
            return c;
        }
    }
    return null;
}
Also used : ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) Color(org.eclipse.swt.graphics.Color)

Example 12 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.

the class ServerLabelProvider method getText.

/*
	 * @see ILabelProvider#getText(Object)
	 */
public String getText(Object element) {
    if (element == null)
        return "";
    if (element instanceof IRuntime) {
        IRuntime runtime = (IRuntime) element;
        return decorate(getString((runtime).getName()), runtime);
    } else if (element instanceof IServer) {
        IServer server = (IServer) element;
        return decorate(getString((server).getName()), server);
    } else if (element instanceof IRuntimeType) {
        IRuntimeType rt = (IRuntimeType) element;
        return decorate(rt.getName(), rt);
    } else if (element instanceof IServerType) {
        IServerType st = (IServerType) element;
        return decorate(st.getName(), st);
    } else if (element instanceof IClient) {
        IClient client = (IClient) element;
        return decorate(client.getName(), client);
    } else if (element instanceof IModule) {
        IModule module = (IModule) element;
        return decorate(module.getName(), module);
    } else if (element instanceof IModule[]) {
        IModule[] modules = (IModule[]) element;
        IModule module = modules[modules.length - 1];
        return decorate(module.getName(), modules);
    } else if (element instanceof ModuleServer) {
        ModuleServer ms = (ModuleServer) element;
        return decorate(ms.getModuleDisplayName(), ms);
    } else if (element instanceof IWorkbenchAdapter) {
        return ((IWorkbenchAdapter) element).getLabel(null);
    }
    return "";
}
Also used : ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) IClient(org.eclipse.wst.server.core.internal.IClient)

Example 13 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.

the class ModuleLabelDecorator method decorateText.

public String decorateText(String text, Object element) {
    try {
        IModule module = null;
        if (element instanceof IModule) {
            module = (IModule) element;
        } else if (element instanceof ModuleServer) {
            IModule[] modules = ((ModuleServer) element).module;
            module = modules[modules.length - 1];
        }
        if (module == null)
            return null;
        IProject project = module.getProject();
        if (project == null)
            return null;
        if (!project.getName().equals(text))
            text = NLS.bind(Messages.moduleDecoratorProject, new String[] { text, project.getName() });
        return PlatformUI.getWorkbench().getDecoratorManager().decorateText(text, project);
    } catch (Exception e) {
        return null;
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) IProject(org.eclipse.core.resources.IProject)

Example 14 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.

the class ServerPropertyTester method checkProperty.

protected static boolean checkProperty(Object target, String property, String value) {
    if ("isRunnable".equals(property)) {
        // check if project has a module associated with it
        if (target instanceof IProject) {
            IModule m = ServerUtil.getModule((IProject) target);
            if (m == null)
                return false;
        }
        // check for runnable object
        boolean b = ServerPlugin.hasModuleArtifact(target);
        if (b)
            return true;
        if (target instanceof IFileEditorInput) {
            IFileEditorInput fei = (IFileEditorInput) target;
            IFile file = fei.getFile();
            b = ServerPlugin.hasModuleArtifact(file);
            if (b)
                return true;
        }
        return false;
    } else if ("serverType".equals(property)) {
        IServer server = null;
        if (target instanceof IServer) {
            server = (IServer) target;
        } else if (target instanceof ModuleServer) {
            ModuleServer ms = (ModuleServer) target;
            server = ms.server;
        }
        if (server == null || server.getServerType() == null)
            return false;
        String[] typeIds = ServerPlugin.tokenize(value, ",");
        return matches(server.getServerType().getId(), typeIds);
    } else if ("moduleType".equals(property)) {
        IModule[] module = null;
        if (target instanceof IModule[]) {
            module = (IModule[]) target;
        } else if (target instanceof IModule) {
            module = new IModule[] { (IModule) target };
        } else if (target instanceof ModuleServer) {
            ModuleServer ms = (ModuleServer) target;
            module = ms.module;
        }
        if (module == null)
            return false;
        if (module.length == 0)
            return false;
        String[] values = ServerPlugin.tokenize(value, ",");
        IModule m = module[module.length - 1];
        return matches(m.getModuleType().getId(), values);
    } else if ("moduleVersion".equals(property)) {
        IModule[] module = null;
        if (target instanceof IModule[]) {
            module = (IModule[]) target;
        } else if (target instanceof IModule) {
            module = new IModule[] { (IModule) target };
        } else if (target instanceof ModuleServer) {
            ModuleServer ms = (ModuleServer) target;
            module = ms.module;
        }
        if (module == null)
            return false;
        if (module.length == 0)
            return false;
        String[] values = ServerPlugin.tokenize(value, ",");
        IModule m = module[module.length - 1];
        return matches(m.getModuleType().getVersion(), values);
    }
    return false;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer) IFile(org.eclipse.core.resources.IFile) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IProject(org.eclipse.core.resources.IProject)

Example 15 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.

the class ServerDecorator method decorate.

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IServer) {
        IServer server = (IServer) element;
        String state = getServerStateLabel(server);
        String status = getServerStatusLabel(server);
        decoration.addSuffix(combine(state, status));
    } else if (element instanceof ModuleServer) {
        ModuleServer module = (ModuleServer) element;
        String state = getModuleStateText(module);
        String status = getModuleStatusText(module);
        decoration.addSuffix(combine(state, status));
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer)

Aggregations

ModuleServer (org.eclipse.wst.server.ui.internal.view.servers.ModuleServer)21 IModule (org.eclipse.wst.server.core.IModule)8 IServer (org.eclipse.wst.server.core.IServer)7 IProject (org.eclipse.core.resources.IProject)5 ILiferayServerBehavior (com.liferay.ide.server.core.ILiferayServerBehavior)3 ArrayList (java.util.ArrayList)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Image (org.eclipse.swt.graphics.Image)2 Iterator (java.util.Iterator)1 List (java.util.List)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 IMarker (org.eclipse.core.resources.IMarker)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 ISelection (org.eclipse.jface.viewers.ISelection)1