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;
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations