Search in sources :

Example 1 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project liferay-ide by liferay.

the class LiferayServerModuleLabelDecorator method decorateImage.

@Override
public Image decorateImage(Image image, Object element) {
    try {
        IModule module = null;
        Image bundleImage = image;
        if (element instanceof IModule) {
            module = (IModule) element;
        } else if (element instanceof ModuleServer) {
            IModule[] modules = ((ModuleServer) element).module;
            module = modules[modules.length - 1];
            ModuleServer portalServer = (ModuleServer) element;
            IServer server = portalServer.getServer();
            IServerType serverType = server.getServerType();
            if (serverType.getRuntimeType().getId().equals("com.liferay.ide.server.portal.runtime")) {
                bundleImage = getBundleModuleImage();
            }
        }
        if (module == null) {
            return null;
        }
        IProject project = module.getProject();
        if (project == null) {
            return null;
        }
        IMarker[] markers = project.findMarkers(LiferayServerCore.BUNDLE_OUTPUT_ERROR_MARKER_TYPE, false, 0);
        if (ListUtil.isNotEmpty(markers)) {
            bundleImage = BundlesImages.IMG_BUNDLE_ERROR;
        }
        return PlatformUI.getWorkbench().getDecoratorManager().decorateImage(bundleImage, project);
    } catch (Exception e) {
        return null;
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) IServerType(org.eclipse.wst.server.core.IServerType) IMarker(org.eclipse.core.resources.IMarker) Image(org.eclipse.swt.graphics.Image) IProject(org.eclipse.core.resources.IProject)

Example 2 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project liferay-ide by liferay.

the class OpenDeployedFolderHandler method getDeployFolderPath.

private IPath getDeployFolderPath(Object selected) {
    IPath retval = null;
    ModuleServer moduleServer = null;
    if (selected != null) {
        if (selected instanceof ModuleServer) {
            moduleServer = (ModuleServer) selected;
            moduleServer.getModule()[0].getProject();
            final ILiferayServerBehavior liferayServerBehavior = (ILiferayServerBehavior) moduleServer.getServer().loadAdapter(ILiferayServerBehavior.class, null);
            if (liferayServerBehavior != null) {
                retval = liferayServerBehavior.getDeployedPath(moduleServer.getModule());
            }
        }
    }
    return retval;
}
Also used : ILiferayServerBehavior(com.liferay.ide.server.core.ILiferayServerBehavior) IPath(org.eclipse.core.runtime.IPath) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer)

Example 3 with ModuleServer

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

the class ServerContentProvider method hasChildren.

public boolean hasChildren(Object element) {
    if (element instanceof ModuleServer) {
        // Check if the module server has child modules.
        ModuleServer curModuleServer = (ModuleServer) element;
        IServer curServer = curModuleServer.server;
        IModule[] curModule = curModuleServer.module;
        if (curServer != null && curModule != null) {
            IModule[] curChildModule = curServer.getChildModules(curModule, null);
            if (curChildModule != null && curChildModule.length > 0)
                return true;
            return false;
        }
        return false;
    }
    if (element instanceof IServer) {
        return ((IServer) element).getModules().length > 0;
    }
    return false;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer)

Example 4 with ModuleServer

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

the class ServerContentProvider method getChildren.

public Object[] getChildren(Object element) {
    if (element instanceof ModuleServer) {
        ModuleServer ms = (ModuleServer) element;
        try {
            IModule[] children = ms.server.getChildModules(ms.module, null);
            int size = children.length;
            ModuleServer[] ms2 = new ModuleServer[size];
            for (int i = 0; i < size; i++) {
                int size2 = ms.module.length;
                IModule[] module = new IModule[size2 + 1];
                System.arraycopy(ms.module, 0, module, 0, size2);
                module[size2] = children[i];
                ms2[i] = new ModuleServer(ms.server, module);
            }
            return ms2;
        } catch (Exception e) {
            return null;
        }
    }
    IServer server = (IServer) element;
    IModule[] modules = server.getModules();
    int size = modules.length;
    ModuleServer[] ms = new ModuleServer[size];
    for (int i = 0; i < size; i++) {
        ms[i] = new ModuleServer(server, new IModule[] { modules[i] });
    }
    return ms;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer)

Example 5 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer 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)

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