Search in sources :

Example 1 with IModule

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();
        }
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) ImportWizard(org.apache.sling.ide.eclipse.ui.wizards.ImportWizard) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 2 with IModule

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;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer)

Example 3 with IModule

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();
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) LinkedList(java.util.LinkedList) IProject(org.eclipse.core.resources.IProject)

Example 4 with IModule

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;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) ISelection(org.eclipse.jface.viewers.ISelection) Wizard(org.eclipse.jface.wizard.Wizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource)

Example 5 with IModule

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());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IModule(org.eclipse.wst.server.core.IModule) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

IModule (org.eclipse.wst.server.core.IModule)12 IProject (org.eclipse.core.resources.IProject)6 IServer (org.eclipse.wst.server.core.IServer)6 ArrayList (java.util.ArrayList)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 SlingContentModuleFactory (org.apache.sling.ide.eclipse.core.internal.SlingContentModuleFactory)2 JcrNode (org.apache.sling.ide.eclipse.ui.nav.model.JcrNode)2 ProjectAdapter (org.apache.sling.ide.test.impl.helpers.ProjectAdapter)2 IResource (org.eclipse.core.resources.IResource)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ISelection (org.eclipse.jface.viewers.ISelection)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)2 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)2 ModuleDelegate (org.eclipse.wst.server.core.model.ModuleDelegate)2 Test (org.junit.Test)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1