use of org.eclipse.wst.server.core.IModule in project sling by apache.
the class ImportContentAction method run.
private void run(ISelection currentSelection) {
if (!(currentSelection instanceof IStructuredSelection)) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;
for (Iterator<?> it = structuredSelection.iterator(); it.hasNext(); ) {
Object selected = it.next();
if (selected instanceof IResource) {
IProject project = (IProject) (((IResource) selected).getProject());
if (!ProjectHelper.isContentProject(project)) {
continue;
}
IModule module = ServerUtil.getModule(project);
if (module == null) {
continue;
}
ImportWizard wiz = new ImportWizard();
wiz.init(PlatformUI.getWorkbench(), structuredSelection);
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wiz);
dialog.open();
}
}
}
use of org.eclipse.wst.server.core.IModule in project sling by apache.
the class ServerUtil method getDefaultServer.
private static IServer getDefaultServer(IProject project) {
IModule module = org.eclipse.wst.server.core.ServerUtil.getModule(project);
if (module == null) {
// is what we need to create a RepositoryInfo
return null;
}
IServer server = ServerCore.getDefaultServer(module);
if (server != null) {
return server;
}
// then we cannot create a repository
IServer[] allServers = ServerCore.getServers();
out: for (int i = 0; i < allServers.length; i++) {
IServer aServer = allServers[i];
IModule[] allModules = aServer.getModules();
for (int j = 0; j < allModules.length; j++) {
IModule aMoudle = allModules[j];
if (aMoudle.equals(module)) {
server = aServer;
break out;
}
}
}
return server;
}
use of org.eclipse.wst.server.core.IModule in project sling by apache.
the class AbstractNewSlingApplicationWizard method deployProjectsOnServer.
protected void deployProjectsOnServer(Projects projects, IProgressMonitor monitor) throws CoreException {
IServer server = setupServerWizardPage.getOrCreateServer(monitor);
if (server == null) {
monitor.done();
return;
}
advance(monitor, 1);
IServerWorkingCopy wc = server.createWorkingCopy();
// add the bundle and content projects, ie modules, to the server
List<IModule> modules = new LinkedList<>();
for (IProject project : projects.getBundleProjects()) {
IModule module = ServerUtil.getModule(project);
if (module != null && shouldDeploy(module)) {
modules.add(module);
}
}
for (IProject project : projects.getContentProjects()) {
IModule module = ServerUtil.getModule(project);
if (module != null && shouldDeploy(module)) {
modules.add(module);
}
}
wc.modifyModules(modules.toArray(new IModule[modules.size()]), new IModule[0], monitor);
wc.save(true, monitor);
advance(monitor, 2);
monitor.done();
}
use of org.eclipse.wst.server.core.IModule in project sling by apache.
the class AbstractJcrNodeImportExportContentHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getCurrentSelection(event);
JcrNode node = SelectionUtils.getFirst(sel, JcrNode.class);
if (node == null) {
return null;
}
IProject project = node.getProject();
if (!ProjectHelper.isContentProject(project)) {
return null;
}
IModule module = ServerUtil.getModule(project);
if (module == null) {
return null;
}
IResource resource = node.getResourceForImportExport();
if (resource == null) {
return null;
}
Wizard wiz = createWizard(resource);
WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wiz);
dialog.open();
return null;
}
use of org.eclipse.wst.server.core.IModule in project sling by apache.
the class ServerAdapter method installModule.
public void installModule(final IProject project) throws CoreException, InterruptedException {
// not sure why we need to poll at all here ... there is some async operation that I'm not aware of
IModule bundleModule = new Poller().pollUntil(new Callable<IModule>() {
@Override
public IModule call() throws Exception {
return ServerUtil.getModule(project);
}
}, notNullValue(IModule.class));
IServerWorkingCopy serverWorkingCopy = server.createWorkingCopy();
serverWorkingCopy.modifyModules(new IModule[] { bundleModule }, new IModule[0], new NullProgressMonitor());
serverWorkingCopy.save(false, new NullProgressMonitor());
}
Aggregations