Skip to content

Commit

Permalink
Fix switching parts layout (#8895)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Zatsarynnyi <azatsary@redhat.com>
  • Loading branch information
azatsarynnyy committed Feb 26, 2018
1 parent 3d4a91f commit 417b8fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,27 @@

import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.web.bindery.event.shared.EventBus;
import javax.inject.Singleton;
import org.eclipse.che.ide.api.mvp.Presenter;
import org.eclipse.che.ide.api.parts.PartPresenter;
import org.eclipse.che.ide.api.parts.PartStack;
import org.eclipse.che.ide.api.parts.PartStackStateChangedEvent;
import org.eclipse.che.ide.api.parts.PartStackType;
import org.eclipse.che.ide.api.parts.Perspective;
import org.eclipse.che.ide.api.parts.PerspectiveManager;
import org.eclipse.che.ide.api.parts.WorkspaceAgent;

/** Presenter to manage Panel selector widget and perspective layout. */
@Singleton
public class PanelSelectorPresenter implements Presenter, PanelSelectorView.ActionDelegate {

private final Provider<WorkspaceAgent> workspaceAgentProvider;
private PanelSelectorView view;
private PerspectiveManager perspectiveManager;

@Inject
public PanelSelectorPresenter(
PanelSelectorView view,
PerspectiveManager perspectiveManager,
EventBus eventBus,
Provider<WorkspaceAgent> workspaceAgentProvider) {
PanelSelectorView view, PerspectiveManager perspectiveManager, EventBus eventBus) {
this.view = view;
this.perspectiveManager = perspectiveManager;
this.workspaceAgentProvider = workspaceAgentProvider;

view.setDelegate(this);

Expand Down Expand Up @@ -109,8 +101,6 @@ private void showPanels(boolean left, boolean bottom, boolean right) {
return;
}

PartPresenter activePart = workspaceAgentProvider.get().getActivePart();

PartStack editorPartStack = perspective.getPartStack(PartStackType.EDITING);
editorPartStack.restore();

Expand Down Expand Up @@ -150,7 +140,8 @@ private void showPanels(boolean left, boolean bottom, boolean right) {

updateButtonState();

workspaceAgentProvider.get().setActivePart(activePart);
// set focus to the active editor if it exists
editorPartStack.openPreviousActivePart();
}

/** Updates icon for panel selector button displaying the current state of panels. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ public void removePartStack(EditorPartStack editorPartStack) {
@Override
public void openPreviousActivePart() {
if (activeEditor != null) {
getPartStackByPart(activeEditor).openPreviousActivePart();
EditorPartStack partStack = getPartStackByPart(activeEditor);
if (partStack != null) {
partStack.openPreviousActivePart();
}
}
}

Expand Down

0 comments on commit 417b8fb

Please sign in to comment.