Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
[Layout editor] Areas around the editor (title and Messages) are drag…
Browse files Browse the repository at this point in the history
…gable and generate error.
  • Loading branch information
ederign committed Apr 19, 2017
1 parent fae06bb commit 20ce868
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
Expand Up @@ -18,6 +18,7 @@

import java.util.Iterator;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
import org.gwtbootstrap3.client.ui.Button;
Expand All @@ -33,8 +34,8 @@
*/
public class ListDropdown extends DropDown {

protected Button button = new Button();
protected DropDownMenu dropDownMenu = new DropDownMenu();
protected Button button = GWT.create(Button.class);
protected DropDownMenu dropDownMenu = GWT.create(DropDownMenu.class);
protected boolean hideOnSingleElement = true;

public ListDropdown() {
Expand Down
Expand Up @@ -130,8 +130,10 @@ public void selectPart(final PartDefinition part) {
entry.getValue().removeStyleName("uf-part-list-dropdown-selected");
}
}
makeDraggable(title,
partView.get(part));
if (dndEnabled) {
makeDraggable(title,
partView.get(part));
}
}

public void changeTitle(final PartDefinition part,
Expand Down Expand Up @@ -226,8 +228,8 @@ public void enableDragAndDrop() {
}
}

private void makeDraggable(final Widget title,
final WorkbenchPartPresenter.View view) {
void makeDraggable(final Widget title,
final WorkbenchPartPresenter.View view) {
if (this.dndManager == null || this.dndEnabled == false) {
return;
}
Expand Down
@@ -0,0 +1,53 @@
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.uberfire.client.views.pfly.listbar;

import com.google.gwtmockito.GwtMockitoTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Spy;
import org.uberfire.workbench.model.PartDefinition;

import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

@RunWith(GwtMockitoTestRunner.class)
public class PartListDropdownTest {

@Spy
@InjectMocks
PartListDropdown dropdown;

@Test
public void selectPartShouldMakeItDraggableOnlyIfDnDIsEnable(){
assertTrue(dropdown.isDndEnabled());
dropdown.selectPart(mock(PartDefinition.class));
verify(dropdown).makeDraggable(any(),any());
}

@Test
public void selectPartShouldNeverMakeItDraggableIfDnDIsDisable(){
dropdown.disableDragAndDrop();
assertTrue(!dropdown.isDndEnabled());
dropdown.selectPart(mock(PartDefinition.class));
verify(dropdown, never()).makeDraggable(any(),any());
}

}
Expand Up @@ -39,6 +39,7 @@ public class MultiListWorkbenchPanelView

@Override
protected MultiPartWidget setupWidget() {
listBar.disableDnd();
addOnFocusHandler(listBar);
addSelectionHandler(listBar);

Expand Down
Expand Up @@ -82,6 +82,7 @@ public void setupWidget() {

verify(listBar).addSelectionHandler(any(SelectionHandler.class));
verify(listBar).addOnFocusHandler(any(Command.class));
verify(listBar).disableDnd();

verify(maximizeButton).setVisible(true);
verify(maximizeButton).setMaximizeCommand(any(Command.class));
Expand Down

0 comments on commit 20ce868

Please sign in to comment.