Search in sources :

Example 1 with OpenShiftServer

use of org.jboss.tools.openshift.core.server.OpenShiftServer in project jbosstools-openshift by jbosstools.

the class ResourceChangePublisher method getPublishRequiredServers.

private OpenShiftServer[] getPublishRequiredServers(IResourceDelta delta) {
    // The list of servers that will require publish
    final List<OpenShiftServer> servers2 = new ArrayList<>();
    // wrksServers = Workspaces Servers
    final IServer[] wrksServers = ServerCore.getServers();
    for (int i = 0; i < wrksServers.length; i++) {
        OpenShiftServer os = (OpenShiftServer) wrksServers[i].loadAdapter(OpenShiftServer.class, new NullProgressMonitor());
        if (os != null) {
            IProject magic = OpenShiftServerUtils.getDeployProject(wrksServers[i]);
            if (magic != null) {
                // Safe because we've already eliminated non-project deltas
                IProject p = (IProject) delta.getResource();
                if (magic.equals(p)) {
                    servers2.add(os);
                }
            }
        }
    }
    return servers2.toArray(new OpenShiftServer[servers2.size()]);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) OpenShiftServer(org.jboss.tools.openshift.core.server.OpenShiftServer) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject)

Example 2 with OpenShiftServer

use of org.jboss.tools.openshift.core.server.OpenShiftServer in project jbosstools-openshift by jbosstools.

the class ResourceChangePublisher method publishHandleProjectChange.

protected void publishHandleProjectChange(IResourceDelta delta, IResourceChangeEvent event) {
    IProject project = (IProject) delta.getResource();
    if (project == null)
        return;
    List<IResource> changes = getDeltaResourceChanges(delta);
    if (!changes.isEmpty()) {
        OpenShiftServer[] servers2 = getPublishRequiredServers(delta);
        int size2 = servers2.length;
        for (int j = 0; j < size2; j++) {
            handleSpecialProjectChange(servers2[j], delta, changes, event);
        }
    }
}
Also used : OpenShiftServer(org.jboss.tools.openshift.core.server.OpenShiftServer) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource)

Example 3 with OpenShiftServer

use of org.jboss.tools.openshift.core.server.OpenShiftServer in project jbosstools-openshift by jbosstools.

the class OpenShiftServerAdapterFactoryTest method testLoadWebModule.

@Test
public void testLoadWebModule() {
    OpenShiftServerAdapterFactory factory = new OpenShiftServerAdapterFactory();
    IServer server = mock(IServer.class);
    OpenShiftServer realServer = mock(OpenShiftServer.class);
    when(server.loadAdapter(eq(OpenShiftServer.class), isA(IProgressMonitor.class))).thenReturn(realServer);
    IServerModule serverModule = factory.getAdapter(server, IServerModule.class);
    assertNotNull(serverModule);
    IModule[] module = serverModule.getModule();
    assertNotNull(module);
    assertNotNull(module[0].loadAdapter(IWebModule.class, null));
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IModule(org.eclipse.wst.server.core.IModule) OpenShiftServerAdapterFactory(org.jboss.tools.openshift.internal.ui.server.OpenShiftServerAdapterFactory) IServerModule(org.eclipse.wst.server.ui.IServerModule) OpenShiftServer(org.jboss.tools.openshift.core.server.OpenShiftServer) IWebModule(org.eclipse.jst.server.core.IWebModule) Test(org.junit.Test)

Example 4 with OpenShiftServer

use of org.jboss.tools.openshift.core.server.OpenShiftServer in project jbosstools-openshift by jbosstools.

the class OpenShiftServerAdapterFactory method getAdapter.

@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
    if (adaptableObject instanceof IServer && IServerModule.class.equals(adapterType)) {
        IServer server = (IServer) adaptableObject;
        OpenShiftServer oss = (OpenShiftServer) server.loadAdapter(OpenShiftServer.class, new NullProgressMonitor());
        if (oss != null) {
            return (T) new OpenShiftServerModuleAdapter(server);
        }
    }
    return null;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IServerModule(org.eclipse.wst.server.ui.IServerModule) OpenShiftServer(org.jboss.tools.openshift.core.server.OpenShiftServer)

Aggregations

OpenShiftServer (org.jboss.tools.openshift.core.server.OpenShiftServer)4 IServer (org.eclipse.wst.server.core.IServer)3 IProject (org.eclipse.core.resources.IProject)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IServerModule (org.eclipse.wst.server.ui.IServerModule)2 ArrayList (java.util.ArrayList)1 IResource (org.eclipse.core.resources.IResource)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IWebModule (org.eclipse.jst.server.core.IWebModule)1 IModule (org.eclipse.wst.server.core.IModule)1 OpenShiftServerAdapterFactory (org.jboss.tools.openshift.internal.ui.server.OpenShiftServerAdapterFactory)1 Test (org.junit.Test)1