use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.
the class ServerLabelProvider method getImage.
/*
* @see ILabelProvider#getImage(Object)
*/
public Image getImage(Object element) {
try {
if (element instanceof IRuntimeType) {
IRuntimeType runtimeType = (IRuntimeType) element;
return decorate(ImageResource.getImage(runtimeType.getId()), runtimeType);
} else if (element instanceof IRuntime) {
IRuntime runtime = (IRuntime) element;
return decorate(ImageResource.getImage(runtime.getRuntimeType().getId()), runtime);
} else if (element instanceof IServerType) {
IServerType serverType = (IServerType) element;
return decorate(ImageResource.getImage(serverType.getId()), serverType);
} else if (element instanceof IServer) {
IServer server = (IServer) element;
if (server.getServerType() == null)
return null;
return decorate(ImageResource.getImage(server.getServerType().getId()), server);
} else if (element instanceof IModule) {
IModule module = (IModule) element;
IModuleType mt = module.getModuleType();
if (mt == null)
return null;
return decorate(getModuleImage(mt.getId()), module);
} else if (element instanceof IModule[]) {
IModule[] modules = (IModule[]) element;
IModule module = modules[modules.length - 1];
IModuleType mt = module.getModuleType();
if (mt == null)
return null;
return decorate(getModuleImage(mt.getId()), modules);
} else if (element instanceof ModuleServer) {
ModuleServer ms = (ModuleServer) element;
IModule module = ms.module[ms.module.length - 1];
IModuleType mt = module.getModuleType();
if (mt == null)
return null;
return decorate(getModuleImage(mt.getId()), ms);
}
} catch (Exception e) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Could not get image descriptor", e);
}
}
return null;
}
use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.
the class ModuleLabelDecorator method decorateImage.
public Image decorateImage(Image image, 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;
return PlatformUI.getWorkbench().getDecoratorManager().decorateImage(image, 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 ModifyModulesComposite method moveAll.
protected void moveAll(IModule[] mods, boolean add2) {
int size = mods.length;
List<IModule> list = new ArrayList<IModule>();
for (int i = 0; i < size; i++) {
IStatus status = errorMap.get(mods[i]);
if ((status == null || status.getSeverity() != IStatus.ERROR) && !list.contains(mods[i]))
list.add(mods[i]);
}
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
IModule module = (IModule) iterator.next();
ModuleServer ms = new ModuleServer(null, new IModule[] { module });
if (add2) {
modules.remove(module);
deployed.add(module);
availableTreeViewer.remove(ms);
deployedTreeViewer.add(ROOT, ms);
} else {
modules.add(module);
deployed.remove(module);
availableTreeViewer.add(ROOT, ms);
deployedTreeViewer.remove(ms);
}
}
setEnablement();
}
use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.
the class ModifyModulesComposite method setEnablement.
protected void setEnablement() {
wizard.setMessage(null, IMessageProvider.NONE);
int count = 0;
if (requiredModules != null) {
// count how many of requiredModules are deployed
int size = requiredModules.length;
for (int i = 0; i < size; i++) {
if (deployed.contains(requiredModules[i]))
count++;
}
}
// give error if there are more than one possible required modules and none are
// added to the server
isComplete = true;
if (requiredModules != null && requiredModules.length > 1 && count == 0) {
String s = "";
int size = requiredModules.length;
for (int i = 0; i < size; i++) {
if (i > 0)
s += " | ";
s += requiredModules[i].getName();
}
wizard.setMessage(NLS.bind(Messages.wizModuleRequiredModules, s), IMessageProvider.ERROR);
isComplete = false;
}
// selection specific messages
ModuleServer[] ms = getAvailableSelection();
if (ms == null || ms.length == 0) {
add.setEnabled(false);
} else {
boolean enabled = false;
// iterate through selection, if we find at least ONE module that can't be added, exit the loop
for (int i = 0; i < ms.length; i++) {
IModule module = getModule(ms[i]);
if (module != null) {
try {
IStatus status = errorMap.get(module);
if (modules.contains(module)) {
if (status == null)
enabled = true;
else if (status.getSeverity() == IStatus.ERROR) {
// this module can't be added because has errors, exit the loop
enabled = false;
wizard.setMessage(status.getMessage(), IMessageProvider.ERROR);
break;
} else if (status.getSeverity() == IStatus.WARNING) {
enabled = true;
wizard.setMessage(status.getMessage(), IMessageProvider.WARNING);
} else if (status.getSeverity() == IStatus.INFO) {
enabled = true;
wizard.setMessage(status.getMessage(), IMessageProvider.INFORMATION);
}
} else {
// at least ONE module from the selection can't be added, exit the loop
enabled = false;
break;
}
} catch (Exception e) {
if (Trace.INFO) {
Trace.trace(Trace.STRING_INFO, "Unable to handle error map for module:" + module);
}
}
}
}
add.setEnabled(enabled);
}
addAll.setEnabled(modules.size() > 0);
ms = getDeployedSelection();
if (ms == null || ms.length == 0) {
remove.setEnabled(false);
} else {
boolean enabled = false;
// iterate through selection, if we find at least ONE module that can't be removed, exit the loop
for (int i = 0; i < ms.length; i++) {
IModule module = getModule(ms[i]);
if (module != null && deployed.contains(module)) {
// required modules can't be removed
if (requiredModules != null) {
if (requiredModules.length == 1 && requiredModules[0].equals(module)) {
// this is a required module and can't be removed, exit the loop
wizard.setMessage(NLS.bind(Messages.wizModuleRequiredModule, module.getName()), IMessageProvider.ERROR);
enabled = false;
break;
}
enabled = true;
} else if (errorMap.containsKey(module)) {
// this is a required module and can't be removed, exit the loop
wizard.setMessage(errorMap.get(module).getMessage(), IMessageProvider.ERROR);
enabled = false;
break;
} else
enabled = true;
} else {
// this module is not found in the 'deployed' array, the module might be a child
// at least ONE module from the selection can't be removed, exit the loop
enabled = false;
break;
}
}
remove.setEnabled(enabled);
}
if (requiredModules == null)
removeAll.setEnabled(deployed.size() > 0);
else
removeAll.setEnabled(deployed.size() > 1);
}
use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.
the class ModuleLabelDecorator2 method decorate.
public void decorate(Object element, IDecoration decoration) {
try {
IModule module = null;
if (element instanceof IServer) {
decoration.addSuffix(" *");
return;
}
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;
IProject project = module.getProject();
if (project == null)
return;
String text = module.getName();
if (!project.getName().equals(text))
decoration.addSuffix(" (" + project.getName() + ")");
// text = NLS.bind(Messages.moduleDecoratorProject, new String[] {text, project.getName()});
// return PlatformUI.getWorkbench().getDecoratorManager().decorateText(text, project);
} catch (Exception e) {
return;
}
}
Aggregations