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