Search in sources :

Example 1 with ActivePartChangedEvent

use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.

the class TestSelectionAgent method shouldFireEventWhenSelectionInActivePartChanged.

/**
     * If selection chang in active part, Selection Agent should fire
     * an Event
     */
@Test
public void shouldFireEventWhenSelectionInActivePartChanged() {
    AbstractPartPresenter part = new AbstractPartPresenter() {

        @Override
        public void go(AcceptsOneWidget container) {
        }

        @Override
        public String getTitleToolTip() {
            return null;
        }

        @Override
        public SVGResource getTitleImage() {
            return null;
        }

        @Override
        public String getTitle() {
            return null;
        }

        @Override
        public IsWidget getView() {
            return null;
        }
    };
    // fire event, for agent to get information about active part
    eventBus.fireEvent(new ActivePartChangedEvent(part));
    SelectionChangedHandler handler = mock(SelectionChangedHandler.class);
    eventBus.addHandler(SelectionChangedEvent.TYPE, handler);
    part.setSelection(mock(Selection.class));
    verify(handler).onSelectionChanged((SelectionChangedEvent) any());
}
Also used : AbstractPartPresenter(org.eclipse.che.ide.api.parts.AbstractPartPresenter) ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) Selection(org.eclipse.che.ide.api.selection.Selection) SelectionChangedHandler(org.eclipse.che.ide.api.event.SelectionChangedHandler) AcceptsOneWidget(com.google.gwt.user.client.ui.AcceptsOneWidget) Test(org.junit.Test)

Example 2 with ActivePartChangedEvent

use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.

the class TestSelectionAgent method shouldNOTFireEventWhenSelectionInNONActivePartChanged.

/**
     * If selection chang in non-active part, no events should be fired by
     * Selection Agent
     */
@Test
public void shouldNOTFireEventWhenSelectionInNONActivePartChanged() {
    AbstractPartPresenter firstPart = new AbstractPartPresenter() {

        @Override
        public void go(AcceptsOneWidget container) {
        }

        @Override
        public String getTitleToolTip() {
            return null;
        }

        @Override
        public SVGResource getTitleImage() {
            return null;
        }

        @Override
        public String getTitle() {
            return null;
        }

        @Override
        public IsWidget getView() {
            return null;
        }
    };
    // fire event, for agent to get information about active part
    eventBus.fireEvent(new ActivePartChangedEvent(firstPart));
    // change part
    eventBus.fireEvent(new ActivePartChangedEvent(mock(PartPresenter.class)));
    SelectionChangedHandler handler = mock(SelectionChangedHandler.class);
    eventBus.addHandler(SelectionChangedEvent.TYPE, handler);
    // call setSelection on the first Part.
    firstPart.setSelection(mock(Selection.class));
    verifyZeroInteractions(handler);
}
Also used : AbstractPartPresenter(org.eclipse.che.ide.api.parts.AbstractPartPresenter) ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) Selection(org.eclipse.che.ide.api.selection.Selection) SelectionChangedHandler(org.eclipse.che.ide.api.event.SelectionChangedHandler) AcceptsOneWidget(com.google.gwt.user.client.ui.AcceptsOneWidget) Test(org.junit.Test)

Example 3 with ActivePartChangedEvent

use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.

the class TestSelectionAgent method shouldChangeSelectionAfterPartGetsActivated.

/** Check proper Selection returned when part changed */
@Test
public void shouldChangeSelectionAfterPartGetsActivated() {
    when(part.getSelection()).thenReturn(selection);
    // fire event, for agent to get information about active part
    eventBus.fireEvent(new ActivePartChangedEvent(part));
    assertEquals("Agent should return proper Selection", selection, agent.getSelection());
}
Also used : ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) Test(org.junit.Test)

Example 4 with ActivePartChangedEvent

use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.

the class TestSelectionAgent method shouldFireEventWhenPartChanged.

/** Event should be fired, when active part changed */
@Test
public void shouldFireEventWhenPartChanged() {
    when(part.getSelection()).thenReturn(selection);
    SelectionChangedHandler handler = mock(SelectionChangedHandler.class);
    eventBus.addHandler(SelectionChangedEvent.TYPE, handler);
    // fire event, for agent to get information about active part
    eventBus.fireEvent(new ActivePartChangedEvent(part));
    verify(handler).onSelectionChanged((SelectionChangedEvent) any());
}
Also used : ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) SelectionChangedHandler(org.eclipse.che.ide.api.event.SelectionChangedHandler) Test(org.junit.Test)

Example 5 with ActivePartChangedEvent

use of org.eclipse.che.ide.api.event.ActivePartChangedEvent in project che by eclipse.

the class AbstractPerspectiveTest method perspectiveStateShouldBeStored.

@Test
public void perspectiveStateShouldBeStored() {
    perspective.onActivePartChanged(new ActivePartChangedEvent(editorPart));
    perspective.storeState();
    verify(editorPart).storeState();
}
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