use of org.eclipse.wst.server.core.IModuleArtifact in project webtools.servertools by eclipse.
the class ServersViewDropAdapter method doSel.
protected boolean doSel(IServer server, Object data) {
// check if the selection is a project (module) that we can add to the server
IProject project = (IProject) Platform.getAdapterManager().getAdapter(data, IProject.class);
if (project != null) {
IModule[] modules = ServerUtil.getModules(project);
if (modules != null && modules.length == 1) {
try {
IServerWorkingCopy wc = server.createWorkingCopy();
IModule[] parents = wc.getRootModules(modules[0], null);
if (parents == null || parents.length == 0)
return false;
if (ServerUtil.containsModule(server, parents[0], null))
return false;
IModule[] add = new IModule[] { parents[0] };
if (wc.canModifyModules(add, null, null).getSeverity() != IStatus.ERROR) {
wc.modifyModules(modules, null, null);
wc.save(false, null);
return true;
}
} catch (final CoreException ce) {
final Shell shell = getViewer().getControl().getShell();
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
EclipseUtil.openError(shell, ce.getLocalizedMessage());
}
});
return true;
}
}
}
// otherwise, try Run on Server
final IServer finalServer = server;
RunOnServerActionDelegate ros = new RunOnServerActionDelegate() {
public IServer getServer(IModule module, IModuleArtifact moduleArtifact, IProgressMonitor monitor) throws CoreException {
if (!ServerUIPlugin.isCompatibleWithLaunchMode(finalServer, launchMode))
return null;
if (!ServerUtil.containsModule(finalServer, module, monitor)) {
IServerWorkingCopy wc = finalServer.createWorkingCopy();
try {
ServerUtil.modifyModules(wc, new IModule[] { module }, new IModule[0], monitor);
wc.save(false, monitor);
} catch (CoreException ce) {
throw ce;
}
}
return finalServer;
}
};
Action action = new Action() {
};
ros.selectionChanged(action, new StructuredSelection(data));
// if (!action.isEnabled())
// return false;
ros.run(action);
return true;
}
use of org.eclipse.wst.server.core.IModuleArtifact in project webtools.servertools by eclipse.
the class IModuleArtifactTestCase method testCreate.
public void testCreate() {
artifact = new IModuleArtifact() {
public IModule getModule() {
return null;
}
};
artifact.getModule();
}
Aggregations