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

Commit

Permalink
GUVNOR-2685: Guided Decision Table Editor: Keyboard navigation should…
Browse files Browse the repository at this point in the history
… not be attached to RootPanel (#512)
  • Loading branch information
manstis authored and csadilek committed Sep 16, 2016
1 parent 4d28433 commit ffadd2b
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 27 deletions.
Expand Up @@ -219,7 +219,8 @@ private GridWidget makeGridWidget1() {

//Add a floating column
final GridColumn.HeaderMetaData grid1ColumnFloatingHeaderMetaData = new BaseHeaderMetaData( "Floating" );
final TextBoxSingletonDOMElementFactory grid1ColumnFloatingFactory = new TextBoxSingletonDOMElementFactory( view.getGridLayer(),
final TextBoxSingletonDOMElementFactory grid1ColumnFloatingFactory = new TextBoxSingletonDOMElementFactory( view.getGridPanel(),
view.getGridLayer(),
gridWidget1 );
final BaseGridColumn<String> grid1ColumnFloating = new StringDOMElementSingletonColumn( grid1ColumnFloatingHeaderMetaData,
grid1ColumnFloatingFactory,
Expand Down Expand Up @@ -326,7 +327,8 @@ public double getHeaderRowHeight() {
final String grid3ColumnGroup1 = "grid3ColumnGroup1";
final GridColumn.HeaderMetaData grid3Column2HeaderMetaData = new BaseHeaderMetaData( "G3-G1-C2",
grid3ColumnGroup1 );
final TextBoxSingletonDOMElementFactory grid3Column2Factory = new TextBoxSingletonDOMElementFactory( view.getGridLayer(),
final TextBoxSingletonDOMElementFactory grid3Column2Factory = new TextBoxSingletonDOMElementFactory( view.getGridPanel(),
view.getGridLayer(),
gridWidget3 );
final BaseGridColumn<String> grid3Column2 = new StringDOMElementSingletonColumn( grid3Column2HeaderMetaData,
grid3Column2Factory,
Expand Down Expand Up @@ -357,7 +359,8 @@ public double getHeaderRowHeight() {
//Add DOM Column - ListBox
final GridColumn.HeaderMetaData grid3Column4HeaderMetaData = new BaseHeaderMetaData( "G3-G1-C4",
grid3ColumnGroup1 );
final ListBoxSingletonDOMElementFactory grid3Column4Factory = new ListBoxSingletonDOMElementFactory( view.getGridLayer(),
final ListBoxSingletonDOMElementFactory grid3Column4Factory = new ListBoxSingletonDOMElementFactory( view.getGridPanel(),
view.getGridLayer(),
gridWidget3 );
final BaseGridColumn<String> grid3Column4 = new ListBoxDOMElementSingletonColumn( grid3Column4HeaderMetaData,
grid3Column4Factory,
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.themes.GridRendererTheme;
import org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer;
import org.uberfire.ext.wires.core.grids.client.widget.layer.GridSelectionManager;
import org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLienzoPanel;

/**
* View and Presenter definition for WiresGridDemo
Expand Down Expand Up @@ -62,6 +63,12 @@ interface Presenter extends GridSelectionManager {
*/
GridLayer getGridLayer();

/**
* Gets the underlying GridLienzoPanel associated with the View.
* @return The associated GridLienzoPanel.
*/
GridLienzoPanel getGridPanel();

/**
* Adds a handler for when the Zoom level in the View is changed.
* @param handler
Expand Down
Expand Up @@ -49,12 +49,17 @@
margin-bottom: 10px;
}

.nofocus {
border-style: none;
outline: none;
}

.buttons {
}
</style>

<div class="canvas">
<div id="gridPanel"></div>
<div id="gridPanel" class="nofocus"></div>
</div>
<div class="controls">
<div class="zoom">
Expand Down
Expand Up @@ -177,10 +177,15 @@ public GridLayer getGridLayer() {
return gridLayer;
}

@Override
public GridLienzoPanel getGridPanel() {
return gridPanel;
}

@Override
public HandlerRegistration addKeyDownHandler( final KeyDownHandler handler ) {
return RootPanel.get().addDomHandler( handler,
KeyDownEvent.getType() );
return gridPanel.addDomHandler( handler,
KeyDownEvent.getType() );
}

@Override
Expand Down
Expand Up @@ -23,26 +23,33 @@
import org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget;
import org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer;
import org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLayerRedrawManager;
import org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLienzoPanel;

/**
* Base Factory for single-instance DOMElements, i.e. there can only be one instance "on screen" at any given time,
* for example to handle "in cell" editing; when a DOMElement is required to "edit" the cell but not when the cell
* is rendered ordinarily. This implementation keeps a single DOMElement that is detached from the GWT container
* when not needed.
* @param <T> The data-type of the cell
* @param <W> The Widget to be wrapped by the DOMElement.
* @param <E> The DOMElement type that this Factory generates.
* @param <T>
* The data-type of the cell
* @param <W>
* The Widget to be wrapped by the DOMElement.
* @param <E>
* The DOMElement type that this Factory generates.
*/
public abstract class BaseSingletonDOMElementFactory<T, W extends Widget, E extends BaseDOMElement<T, W>> implements SingletonDOMElementFactory<W, E> {

protected final GridLienzoPanel gridPanel;
protected final GridLayer gridLayer;
protected final GridWidget gridWidget;

protected W widget;
protected E e;

public BaseSingletonDOMElementFactory( final GridLayer gridLayer,
public BaseSingletonDOMElementFactory( final GridLienzoPanel gridPanel,
final GridLayer gridLayer,
final GridWidget gridWidget ) {
this.gridPanel = gridPanel;
this.gridLayer = gridLayer;
this.gridWidget = gridWidget;
}
Expand Down
Expand Up @@ -22,21 +22,27 @@
import org.uberfire.ext.wires.core.grids.client.widget.dom.impl.ListBoxDOMElement;
import org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget;
import org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer;
import org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLienzoPanel;

/**
* A DOMElement Factory for single-instance ListBoxes.
*/
public class ListBoxSingletonDOMElementFactory extends BaseSingletonDOMElementFactory<String, ListBox, ListBoxDOMElement> {

public ListBoxSingletonDOMElementFactory( final GridLayer gridLayer,
public ListBoxSingletonDOMElementFactory( final GridLienzoPanel gridPanel,
final GridLayer gridLayer,
final GridWidget gridWidget ) {
super( gridLayer,
super( gridPanel,
gridLayer,
gridWidget );
}

@Override
public ListBox createWidget() {
return new ListBox();
return new ListBox() {{
addKeyDownHandler( ( e ) -> e.stopPropagation() );
addMouseDownHandler( ( e ) -> e.stopPropagation() );
}};
}

@Override
Expand All @@ -52,6 +58,7 @@ public ListBoxDOMElement createDomElement( final GridLayer gridLayer,
public void onBlur( final BlurEvent event ) {
destroyResources();
gridLayer.batch();
gridPanel.setFocus( true );
}
} );
return e;
Expand Down
Expand Up @@ -22,21 +22,27 @@
import org.uberfire.ext.wires.core.grids.client.widget.dom.impl.TextBoxDOMElement;
import org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget;
import org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer;
import org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLienzoPanel;

/**
* A DOMElement Factory for single-instance TextBoxes.
*/
public class TextBoxSingletonDOMElementFactory extends BaseSingletonDOMElementFactory<String, TextBox, TextBoxDOMElement> {

public TextBoxSingletonDOMElementFactory( final GridLayer gridLayer,
public TextBoxSingletonDOMElementFactory( final GridLienzoPanel gridPanel,
final GridLayer gridLayer,
final GridWidget gridWidget ) {
super( gridLayer,
super( gridPanel,
gridLayer,
gridWidget );
}

@Override
public TextBox createWidget() {
return new TextBox();
return new TextBox() {{
addKeyDownHandler( ( e ) -> e.stopPropagation() );
addMouseDownHandler( ( e ) -> e.stopPropagation() );
}};
}

@Override
Expand All @@ -52,6 +58,7 @@ public TextBoxDOMElement createDomElement( final GridLayer gridLayer,
public void onBlur( final BlurEvent event ) {
destroyResources();
gridLayer.batch();
gridPanel.setFocus( true );
}
} );
return e;
Expand Down
Expand Up @@ -20,8 +20,6 @@
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import org.gwtbootstrap3.client.shared.event.ModalShowEvent;
import org.gwtbootstrap3.client.shared.event.ModalShowHandler;
import org.gwtbootstrap3.client.ui.Button;
import org.gwtbootstrap3.client.ui.Modal;
import org.gwtbootstrap3.client.ui.ModalBody;
Expand Down Expand Up @@ -82,19 +80,15 @@ public void onClick( final ClickEvent event ) {
footer.add( cancelButton );
add( footer );

addShowHandler( new ModalShowHandler() {
@Override
public void onShow( final ModalShowEvent evt ) {
textBox.setFocus( true );
}
} );

addShownHandler( ( e ) -> textBox.setFocus( true ) );
}

/**
* Show the popup
* @param value The value to show in the editor.
* @param callback Callback to invoke when the popup is "OK'ed".
* @param value
* The value to show in the editor.
* @param callback
* Callback to invoke when the popup is "OK'ed".
*/
public void edit( final GridCellValue<String> value,
final Callback<GridCellValue<String>> callback ) {
Expand Down
Expand Up @@ -94,6 +94,7 @@ public void onAttachOrDetach( final AttachEvent event ) {
}
}
} );
addMouseDownHandler( ( e ) -> setFocus( true ) );
}

@Override
Expand Down

0 comments on commit ffadd2b

Please sign in to comment.