use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.
the class ComparePresenter method showCompareBetweenRevisions.
/**
*
* @param file
* path of the file
* @param status
* status of the file
* @param revisionA
* hash of the first revision or branch.
* If it is set to {@code null}, compare with empty repository state will be performed
* @param revisionB
* hash of the second revision or branch.
* If it is set to {@code null}, compare with latest repository state will be performed
*/
public void showCompareBetweenRevisions(final Path file, final Status status, @Nullable final String revisionA, @Nullable final String revisionB) {
this.compareWithLatest = false;
final DevMachine devMachine = appContext.getDevMachine();
final Path projectLocation = appContext.getRootProject().getLocation();
view.setTitle(file.toString());
if (status == Status.ADDED) {
service.showFileContent(devMachine, projectLocation, file, revisionB).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(ShowFileContentResponse response) throws OperationException {
view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA == null ? "" : revisionA + locale.compareReadOnlyTitle());
view.show("", response.getContent(), file.toString(), true);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
}
});
} else if (status == Status.DELETED) {
service.showFileContent(devMachine, projectLocation, file, revisionA).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(ShowFileContentResponse response) throws OperationException {
view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA + locale.compareReadOnlyTitle());
view.show(response.getContent(), "", file.toString(), true);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
}
});
} else {
service.showFileContent(devMachine, projectLocation, file, revisionA).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(final ShowFileContentResponse contentAResponse) throws OperationException {
service.showFileContent(devMachine, projectLocation, file, revisionB).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(ShowFileContentResponse contentBResponse) throws OperationException {
view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA + locale.compareReadOnlyTitle());
view.show(contentAResponse.getContent(), contentBResponse.getContent(), file.toString(), true);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
}
});
}
});
}
}
use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.
the class AbstractServerMacro method registerProviders.
/**
* Register macro providers which returns the implementation.
*
* @see AbstractServerMacro#getMacros(DevMachine)
* @since 4.7.0
*/
private void registerProviders() {
final DevMachine devMachine = appContext.getDevMachine();
if (devMachine == null) {
return;
}
final Set<Macro> providers = getMacros(devMachine);
checkNotNull(providers);
if (providers.isEmpty()) {
return;
}
providerRegistry.register(providers);
}
use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.
the class ProcessesPanelPresenterTest method setUp.
@Before
public void setUp() {
DevMachine devMachine = mock(DevMachine.class);
when(devMachine.getId()).thenReturn(WORKSPACE_ID);
when(appContext.getDevMachine()).thenReturn(devMachine);
when(appContext.getWorkspace()).thenReturn(workspace);
when(workspace.getRuntime()).thenReturn(workspaceRuntime);
when(processesPromise.then(Matchers.<Operation<List<MachineProcessDto>>>anyObject())).thenReturn(processesPromise);
when(commandConsoleFactory.create(anyString())).thenReturn(mock(OutputConsole.class));
when(appContext.getWorkspaceId()).thenReturn(WORKSPACE_ID);
when(workspaceAgent.getPartStack(eq(PartStackType.INFORMATION))).thenReturn(partStack);
when(execAgentCommandManager.getProcesses(anyString(), anyBoolean())).thenReturn(promise);
when(promise.then(any(Operation.class))).thenReturn(promise);
presenter = new ProcessesPanelPresenter(view, localizationConstant, resources, eventBus, workspaceAgent, appContext, notificationManager, entityFactory, terminalFactory, commandConsoleFactory, dialogFactory, consoleTreeContextMenuFactory, commandTypeRegistry, sshService, execAgentCommandManager, macroProcessor, dtoFactory);
}
use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.
the class StopWorkspaceActionTest method actionShouldBePerformed.
@Test
public void actionShouldBePerformed() throws Exception {
when(workspaceService.stop(anyString())).thenReturn(voidPromise);
DevMachine devMachine = mock(DevMachine.class);
when(devMachine.getId()).thenReturn("id");
when(appContext.getWorkspace()).thenReturn(workspace);
when(workspace.getId()).thenReturn("id");
action.actionPerformed(actionEvent);
verify(workspaceService).stop("id");
}
use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.
the class BootstrapController method startWsAgentComponents.
@Inject
private void startWsAgentComponents(EventBus eventBus, final Map<String, Provider<WsAgentComponent>> components) {
eventBus.addHandler(WorkspaceStartedEvent.TYPE, new WorkspaceStartedEvent.Handler() {
@Override
public void onWorkspaceStarted(WorkspaceStartedEvent event) {
workspaceService.getWorkspace(event.getWorkspace().getId()).then(new Operation<WorkspaceDto>() {
@Override
public void apply(WorkspaceDto ws) throws OperationException {
MachineDto devMachineDto = ws.getRuntime().getDevMachine();
DevMachine devMachine = new DevMachine(devMachineDto);
if (appContext instanceof AppContextImpl) {
((AppContextImpl) appContext).setProjectsRoot(Path.valueOf(devMachineDto.getRuntime().projectsRoot()));
}
wsAgentStateControllerProvider.get().initialize(devMachine);
wsAgentURLModifier.initialize(devMachine);
SortedMap<String, Provider<WsAgentComponent>> sortedComponents = new TreeMap<>();
sortedComponents.putAll(components);
startWsAgentComponents(sortedComponents.values().iterator());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError err) throws OperationException {
Log.error(getClass(), err.getCause());
initializationFailed(err.getMessage());
}
});
}
});
}
Aggregations