CHE-4379 Cannot reduce process panel size (#4829)
* CHE-4379 Cannot reduce process panel size * CHE-4379 Cannot reduce process panel size * CHE-4379 Cannot reduce process panel size6.19.x Docker
parent
b42ccbf59a
commit
261cb400dc
|
|
@ -86,7 +86,6 @@ public class ProjectExplorerStateComponent implements StateComponent {
|
|||
|
||||
@Override
|
||||
public void loadState(@NotNull JsonObject state) {
|
||||
|
||||
if (state.hasKey(SHOW_HIDDEN_FILES)) {
|
||||
projectExplorer.showHiddenFiles(state.getBoolean(SHOW_HIDDEN_FILES));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,4 +174,5 @@ public class WorkspacePresenter implements Presenter, WorkspaceView.ActionDelega
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,13 +321,17 @@ public abstract class AbstractPerspective implements Presenter, Perspective,
|
|||
private JsonObject getPartStackState(PartStack partStack, WorkBenchPartController partController) {
|
||||
JsonObject state = Json.createObject();
|
||||
state.put("SIZE", partController.getSize());
|
||||
state.put("STATE", partStack.getPartStackState().name());
|
||||
|
||||
if (partStack.getParts().isEmpty()) {
|
||||
state.put("HIDDEN", true);
|
||||
} else {
|
||||
if (partStack.getActivePart() != null) {
|
||||
state.put("ACTIVE_PART", partStack.getActivePart().getClass().getName());
|
||||
}
|
||||
|
||||
state.put("HIDDEN", partController.isHidden());
|
||||
|
||||
JsonArray parts = Json.createArray();
|
||||
state.put("PARTS", parts);
|
||||
int i = 0;
|
||||
|
|
@ -343,18 +347,22 @@ public abstract class AbstractPerspective implements Presenter, Perspective,
|
|||
@Override
|
||||
public void loadState(@NotNull JsonObject state) {
|
||||
if (state.hasKey("PART_STACKS")) {
|
||||
JsonObject part_stacks = state.getObject("PART_STACKS");
|
||||
for (String partStackType : part_stacks.keys()) {
|
||||
JsonObject partStack = part_stacks.getObject(partStackType);
|
||||
JsonObject partStacksState = state.getObject("PART_STACKS");
|
||||
|
||||
// Don't restore part dimensions if perspective is maximized.
|
||||
boolean perspectiveMaximized = isPerspectiveMaximized(partStacksState);
|
||||
|
||||
for (String partStackType : partStacksState.keys()) {
|
||||
JsonObject partStackState = partStacksState.getObject(partStackType);
|
||||
switch (PartStackType.valueOf(partStackType)) {
|
||||
case INFORMATION:
|
||||
restorePartController(partStacks.get(INFORMATION), belowPartController, partStack);
|
||||
loadPartStackState(partStacks.get(INFORMATION), belowPartController, partStackState, perspectiveMaximized);
|
||||
break;
|
||||
case NAVIGATION:
|
||||
restorePartController(partStacks.get(NAVIGATION), leftPartController, partStack);
|
||||
loadPartStackState(partStacks.get(NAVIGATION), leftPartController, partStackState, perspectiveMaximized);
|
||||
break;
|
||||
case TOOLING:
|
||||
restorePartController(partStacks.get(TOOLING), rightPartController, partStack);
|
||||
loadPartStackState(partStacks.get(TOOLING), rightPartController, partStackState, perspectiveMaximized);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -370,9 +378,38 @@ public abstract class AbstractPerspective implements Presenter, Perspective,
|
|||
}
|
||||
}
|
||||
|
||||
private void restorePartController(PartStack partStack, WorkBenchPartController controller, JsonObject partStackJSON) {
|
||||
if (partStackJSON.hasKey("PARTS")) {
|
||||
JsonArray parts = partStackJSON.get("PARTS");
|
||||
/**
|
||||
* Determines whether perspective is maximized.
|
||||
*
|
||||
* @param partStacksState part stack state
|
||||
* @return <b>true</b> is perspective has maximized part stack
|
||||
*/
|
||||
private boolean isPerspectiveMaximized(JsonObject partStacksState) {
|
||||
for (String partStackType : partStacksState.keys()) {
|
||||
JsonObject partStackState = partStacksState.getObject(partStackType);
|
||||
if (partStackState.hasKey("STATE") && PartStack.State.MAXIMIZED.name().equals(partStackState.getString("STATE"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set part stack state.
|
||||
*
|
||||
* @param partStack
|
||||
* @param controller
|
||||
* @param partStackState
|
||||
* @param skipRestoreDimensions
|
||||
*/
|
||||
private void loadPartStackState(PartStack partStack,
|
||||
WorkBenchPartController controller,
|
||||
JsonObject partStackState,
|
||||
boolean skipRestoreDimensions) {
|
||||
if (partStackState.hasKey("PARTS")) {
|
||||
JsonArray parts = partStackState.get("PARTS");
|
||||
|
||||
for (int i = 0; i < parts.length(); i++) {
|
||||
JsonObject value = parts.get(i);
|
||||
if (value.hasKey("CLASS")) {
|
||||
|
|
@ -389,8 +426,8 @@ public abstract class AbstractPerspective implements Presenter, Perspective,
|
|||
}
|
||||
|
||||
// restore part stack's active part
|
||||
if (partStackJSON.hasKey("ACTIVE_PART")) {
|
||||
String activePart = partStackJSON.getString("ACTIVE_PART");
|
||||
if (partStackState.hasKey("ACTIVE_PART")) {
|
||||
String activePart = partStackState.getString("ACTIVE_PART");
|
||||
Provider<PartPresenter> provider = dynaProvider.getProvider(activePart);
|
||||
if (provider != null) {
|
||||
partStack.setActivePart(provider.get());
|
||||
|
|
@ -403,13 +440,17 @@ public abstract class AbstractPerspective implements Presenter, Perspective,
|
|||
return;
|
||||
}
|
||||
|
||||
if (partStackJSON.hasKey("HIDDEN") && partStackJSON.getBoolean("HIDDEN")) {
|
||||
if (skipRestoreDimensions) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (partStackState.hasKey("HIDDEN") && partStackState.getBoolean("HIDDEN")) {
|
||||
partStack.minimize();
|
||||
return;
|
||||
}
|
||||
|
||||
if (partStackJSON.hasKey("SIZE")) {
|
||||
double size = partStackJSON.getNumber("SIZE");
|
||||
if (partStackState.hasKey("SIZE")) {
|
||||
double size = partStackState.getNumber("SIZE");
|
||||
|
||||
// Size of the part must not be less 100 pixels.
|
||||
if (size <= MIN_PART_SIZE) {
|
||||
|
|
|
|||
|
|
@ -153,4 +153,5 @@ public class AppStateManagerTest {
|
|||
assertThat(jsonObject.hasKey("key1")).isTrue();
|
||||
assertThat(jsonObject.getString("key1")).isEqualTo("value1");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.eclipse.che.ide.api.constraints.Constraints;
|
|||
import org.eclipse.che.ide.api.editor.AbstractEditorPresenter;
|
||||
import org.eclipse.che.ide.api.event.ActivePartChangedEvent;
|
||||
import org.eclipse.che.ide.api.parts.PartPresenter;
|
||||
import org.eclipse.che.ide.api.parts.PartStack;
|
||||
import org.eclipse.che.ide.api.parts.PartStackView;
|
||||
import org.eclipse.che.ide.part.PartStackPresenter;
|
||||
import org.eclipse.che.ide.workspace.PartStackPresenterFactory;
|
||||
|
|
@ -39,6 +40,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
|
|
@ -110,6 +112,8 @@ public class AbstractPerspectivePersistenceTest {
|
|||
when(view.getInformationPanel()).thenReturn(simpleLayoutPanel);
|
||||
when(view.getToolPanel()).thenReturn(simplePanel);
|
||||
|
||||
when(partStackPresenter.getPartStackState()).thenReturn(PartStack.State.NORMAL);
|
||||
|
||||
when(controllerFactory.createController(Matchers.<SplitLayoutPanel>anyObject(),
|
||||
Matchers.<SimplePanel>anyObject())).thenReturn(workBenchController);
|
||||
|
||||
|
|
@ -224,4 +228,40 @@ public class AbstractPerspectivePersistenceTest {
|
|||
verify(partStackPresenter).addPart(partPresenter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRestoreMaximizedPartStack() throws Exception {
|
||||
JsonObject state = Json.createObject();
|
||||
|
||||
JsonObject parts = Json.createObject();
|
||||
state.put("PART_STACKS", parts);
|
||||
|
||||
JsonObject partStack = Json.createObject();
|
||||
parts.put("INFORMATION", partStack);
|
||||
|
||||
partStack.put("STATE", PartStack.State.MAXIMIZED.name());
|
||||
|
||||
JsonArray partsArray = Json.createArray();
|
||||
partStack.put("PARTS", partsArray);
|
||||
|
||||
JsonObject part = Json.createObject();
|
||||
partsArray.set(0, part);
|
||||
part.put("CLASS", "foo.Bar");
|
||||
|
||||
partStack.put("SIZE", 142);
|
||||
|
||||
// partStackPresenter.getParts() must return non empty list
|
||||
final List<PartPresenter> partPresenters = new ArrayList<>();
|
||||
partPresenters.add(partPresenter);
|
||||
when(partStackPresenter.getParts()).thenAnswer(new Answer<List<? extends PartPresenter>>() {
|
||||
@Override
|
||||
public List<? extends PartPresenter> answer(InvocationOnMock invocationOnMock) throws Throwable {
|
||||
return partPresenters;
|
||||
}
|
||||
});
|
||||
|
||||
perspective.loadState(state);
|
||||
|
||||
verify(workBenchController, never()).setSize(142d);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,4 +106,5 @@ public class WorkspacePresenterPersistenceTest {
|
|||
|
||||
verify(perspective1).loadState(perspective1State);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public class ContributionMixinProvider {
|
|||
});
|
||||
}
|
||||
|
||||
void processCurrentProject() {
|
||||
private void processCurrentProject() {
|
||||
final Project rootProject = appContext.getRootProject();
|
||||
|
||||
if (lastSelected != null && lastSelected.equals(rootProject)) {
|
||||
|
|
@ -124,7 +124,6 @@ public class ContributionMixinProvider {
|
|||
final PartStack toolingPartStack = workspaceAgent.getPartStack(TOOLING);
|
||||
|
||||
if (rootProject == null) {
|
||||
|
||||
if (toolingPartStack.containsPart(contributePart)) {
|
||||
invalidateContext(lastSelected);
|
||||
hidePart();
|
||||
|
|
|
|||
Loading…
Reference in New Issue