Search in sources :

Example 6 with ActivePartChangedEvent

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);
}
Also used : ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) Test(org.junit.Test)

Example 7 with ActivePartChangedEvent

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);
}
Also used : ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) Test(org.junit.Test)

Example 8 with ActivePartChangedEvent

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));
}
Also used : ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) PartStackView(org.eclipse.che.ide.api.parts.PartStackView) Before(org.junit.Before)

Example 9 with ActivePartChangedEvent

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);
}
Also used : HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) ActivePartChangedHandler(org.eclipse.che.ide.api.event.ActivePartChangedHandler) Call(org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.Call) CallbackPromiseHelper.createFromCallback(org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.createFromCallback) Callback(com.google.gwt.core.client.Callback) ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 10 with ActivePartChangedEvent

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();
}
Also used : ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) Test(org.junit.Test)

Aggregations

ActivePartChangedEvent (org.eclipse.che.ide.api.event.ActivePartChangedEvent)11 Test (org.junit.Test)8 SelectionChangedHandler (org.eclipse.che.ide.api.event.SelectionChangedHandler)3 AcceptsOneWidget (com.google.gwt.user.client.ui.AcceptsOneWidget)2 ActivePartChangedHandler (org.eclipse.che.ide.api.event.ActivePartChangedHandler)2 AbstractPartPresenter (org.eclipse.che.ide.api.parts.AbstractPartPresenter)2 Selection (org.eclipse.che.ide.api.selection.Selection)2 Optional (com.google.common.base.Optional)1 Callback (com.google.gwt.core.client.Callback)1 Inject (com.google.inject.Inject)1 HandlerRegistration (com.google.web.bindery.event.shared.HandlerRegistration)1 Call (org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.Call)1 CallbackPromiseHelper.createFromCallback (org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.createFromCallback)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 PartStackView (org.eclipse.che.ide.api.parts.PartStackView)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)1 Before (org.junit.Before)1