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()]);
}
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);
}
}
}
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));
}
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;
}
Aggregations