use of org.eclipse.wst.server.core.IServer 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;
}
use of org.eclipse.wst.server.core.IServer in project webtools.servertools by eclipse.
the class OptionalClientWizardFragment method updateClients.
protected void updateClients() {
if (getTaskModel() == null)
return;
try {
IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
if (server == null) {
getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, null);
getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, null);
getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null);
getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false));
return;
}
// if (lastServer == null)
// return;
// get the launchable adapter and module object
Object launchable = null;
try {
Object[] obj = ServerUIPlugin.getLaunchableAdapter(server, moduleArtifact);
getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, obj[0]);
getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, obj[1]);
launchable = obj[1];
} catch (CoreException ce) {
getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, null);
getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, null);
getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null);
getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false));
EclipseUtil.openError(null, ce.getStatus());
return;
}
// stop here if the server and launchable haven't changed
if (lastServer != null && lastServer.equals(server)) {
if (lastLaunchable == null && launchable == null)
return;
if (lastLaunchable != null && lastLaunchable.equals(launchable)) {
return;
}
}
lastServer = server;
lastLaunchable = launchable;
String launchMode = (String) getTaskModel().getObject(TaskModel.TASK_LAUNCH_MODE);
clients = ServerUIPlugin.getClients(server, launchable, launchMode);
getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null);
getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false));
if (clients != null) {
if (clients.length > 1) {
getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, clients);
getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(true));
} else
getTaskModel().putObject(WizardTaskUtil.TASK_CLIENT, clients[0]);
}
updateChildFragments();
} catch (Exception e) {
// ignore
}
}
use of org.eclipse.wst.server.core.IServer in project webtools.servertools by eclipse.
the class ServerPerformanceTestCase method getFirstServer.
protected IServer getFirstServer(String serverTypeId) {
IServer[] servers = ServerCore.getServers();
assertTrue(servers.length > 0);
IServer server = servers[0];
assertNotNull(server);
assertTrue(server.getServerType().getId().equals(serverTypeId));
return server;
}
use of org.eclipse.wst.server.core.IServer in project webtools.servertools by eclipse.
the class AbstractOpenEditorTestCase method testOpenEditor.
public void testOpenEditor() throws Exception {
IServer server = getServer();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = page.openEditor(new ServerEditorInput(server.getId()), SERVER_EDITOR_ID, true);
page.closeEditor(editor, false);
releaseServer(server);
}
use of org.eclipse.wst.server.core.IServer in project webtools.servertools by eclipse.
the class AbstractOpenEditorTestCase method testOpenEditor.
public void testOpenEditor() throws Exception {
startMeasuring();
IServer server = getFirstServer(getServerTypeId());
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = page.openEditor(new ServerEditorInput(server.getId()), SERVER_EDITOR_ID, true);
stopMeasuring();
commitMeasurements();
assertPerformance();
page.closeEditor(editor, false);
}
Aggregations