use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.
the class MachinePanelPresenterTest method shouldShowMachinesWhenMachinesPartIsActive.
@Test
public void shouldShowMachinesWhenMachinesPartIsActive() throws Exception {
when(workspaceRuntime.getMachines()).thenReturn(Collections.singletonList(machineDtoFromAPI1));
ActivePartChangedEvent event = mock(ActivePartChangedEvent.class);
when(event.getActivePart()).thenReturn(presenter);
presenter.onActivePartChanged(event);
verify(event).getActivePart();
verify(appContext).getWorkspace();
verify(usersWorkspace).getRuntime();
verify(entityFactory).createMachineNode(isNull(MachineTreeNode.class), eq("root"), Matchers.<List<MachineTreeNode>>anyObject());
verify(entityFactory).createMachineNode(eq(rootNode), eq(machine1), eq(null));
verify(view).setData(Matchers.<MachineTreeNode>anyObject());
verify(view).selectNode(machineNode1);
}
use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.
the class RecipePartPresenterTest method panelShouldBeShowedWhenPartIsActivated.
@Test
public void panelShouldBeShowedWhenPartIsActivated() throws Exception {
ActivePartChangedEvent event = mock(ActivePartChangedEvent.class);
when(event.getActivePart()).thenReturn(recipePartPresenter);
when(recipesContainerPresenter.getEditorPanel(Matchers.<RecipeWidget>any())).thenReturn(recipeEditorPanel);
recipePartPresenter.onActivePartChanged(event);
verify(recipeEditorPanel).setDelegate(recipePartPresenter);
}
use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.
the class AbstractPerspectivePersistenceTest method setUp.
@Before
public void setUp() throws Exception {
when(view.getLeftPanel()).thenReturn(panel);
when(view.getRightPanel()).thenReturn(panel);
when(view.getBottomPanel()).thenReturn(panel);
when(view.getSplitPanel()).thenReturn(layoutPanel);
when(view.getNavigationPanel()).thenReturn(simplePanel);
when(view.getInformationPanel()).thenReturn(simpleLayoutPanel);
when(view.getToolPanel()).thenReturn(simplePanel);
when(controllerFactory.createController(Matchers.<SplitLayoutPanel>anyObject(), Matchers.<SimplePanel>anyObject())).thenReturn(workBenchController);
when(partStackViewFactory.create(Matchers.<PartStackView.TabPosition>anyObject(), Matchers.<FlowPanel>anyObject())).thenReturn(partStackView);
when(stackPresenterFactory.create(Matchers.<PartStackView>anyObject(), Matchers.<WorkBenchPartController>anyObject())).thenReturn(partStackPresenter);
perspective = new AbstractPerspectiveTest.DummyPerspective(view, stackPresenterFactory, partStackViewFactory, controllerFactory, eventBus, null, partStackPresenter, dynaProvider);
perspective.onActivePartChanged(new ActivePartChangedEvent(activePart));
}
use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.
the class OpenFileAction method promise.
@Override
public Promise<Void> promise(final ActionEvent actionEvent) {
if (actionEvent.getParameters() == null) {
return Promises.reject(JsPromiseError.create(localization.canNotOpenFileWithoutParams()));
}
final String pathToOpen = actionEvent.getParameters().get(FILE_PARAM_ID);
if (pathToOpen == null) {
return Promises.reject(JsPromiseError.create(localization.fileToOpenIsNotSpecified()));
}
final Call<Void, Throwable> call = new Call<Void, Throwable>() {
HandlerRegistration handlerRegistration;
@Override
public void makeCall(final Callback<Void, Throwable> callback) {
actionCompletedCallback = callback;
handlerRegistration = eventBus.addHandler(ActivePartChangedEvent.TYPE, new ActivePartChangedHandler() {
@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
if (event.getActivePart() instanceof EditorPartPresenter) {
EditorPartPresenter editor = (EditorPartPresenter) event.getActivePart();
handlerRegistration.removeHandler();
if (Path.valueOf(pathToOpen).equals(editor.getEditorInput().getFile().getLocation())) {
callback.onSuccess(null);
}
}
}
});
actionPerformed(actionEvent);
}
};
return createFromCallback(call);
}
use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.
the class AbstractPerspectiveTest method perspectiveStateShouldBeRestored.
@Test
public void perspectiveStateShouldBeRestored() {
perspective.onActivePartChanged(new ActivePartChangedEvent(editorPart));
perspective.storeState();
perspective.restoreState();
verify(editorPart).restoreState();
}
Aggregations