use of com.google.gwt.event.dom.client.KeyPressHandler in project drools-wb by kiegroup.
the class VerifyRulesFiredWidget method render.
private FlexTable render(final FixtureList rfl, final Scenario sc) {
FlexTable data = new FlexTable();
for (int i = 0; i < rfl.size(); i++) {
final VerifyRuleFired v = (VerifyRuleFired) rfl.get(i);
if (showResults && v.getSuccessResult() != null) {
if (!v.getSuccessResult().booleanValue()) {
data.setWidget(i, 0, new Image(CommonImages.INSTANCE.warning()));
data.setWidget(i, 4, new HTML(TestScenarioConstants.INSTANCE.ActualResult(v.getActualResult().toString())));
data.getCellFormatter().addStyleName(i, 4, // NON-NLS
"testErrorValue");
} else {
data.setWidget(i, 0, new Image(TestScenarioImages.INSTANCE.testPassed()));
}
}
data.setWidget(i, 1, new SmallLabel(v.getRuleName() + ":"));
data.getFlexCellFormatter().setAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
final ListBox b = new ListBox();
b.addItem(TestScenarioConstants.INSTANCE.firedAtLeastOnce(), "y");
b.addItem(TestScenarioConstants.INSTANCE.didNotFire(), "n");
b.addItem(TestScenarioConstants.INSTANCE.firedThisManyTimes(), "e");
final TextBox num = new TextBox();
((InputElement) num.getElement().cast()).setSize(5);
if (v.getExpectedFire() != null) {
b.setSelectedIndex((v.getExpectedFire().booleanValue()) ? 0 : 1);
num.setVisible(false);
} else {
b.setSelectedIndex(2);
String xc = (v.getExpectedCount() != null) ? "" + v.getExpectedCount().intValue() : "0";
num.setText(xc);
}
b.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String s = b.getValue(b.getSelectedIndex());
if (s.equals("y") || s.equals("n")) {
num.setVisible(false);
v.setExpectedFire((s.equals("y")) ? Boolean.TRUE : Boolean.FALSE);
v.setExpectedCount(null);
} else {
num.setVisible(true);
v.setExpectedFire(null);
num.setText("1");
v.setExpectedCount(Integer.valueOf(1));
}
}
});
b.addItem(TestScenarioConstants.INSTANCE.ChooseDotDotDot());
num.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
v.setExpectedCount(Integer.valueOf(num.getText()));
}
});
HorizontalPanel h = new HorizontalPanel();
h.add(b);
h.add(num);
data.setWidget(i, 2, h);
Button del = new Button();
del.setIcon(IconType.TRASH);
del.setTitle(TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation());
del.addClickHandler(clickEvent -> {
if (Window.confirm(TestScenarioConstants.INSTANCE.AreYouSureYouWantToRemoveThisRuleExpectation())) {
rfl.remove(v);
sc.removeFixture(v);
outer.setWidget(1, 0, render(rfl, sc));
}
});
data.setWidget(i, 3, del);
// we only want numbers here...
num.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (Character.isLetter(event.getCharCode())) {
((TextBox) event.getSource()).cancelKey();
}
}
});
}
ScenarioUtils.addBottomAndRightPaddingToTableCells(data);
return data;
}
use of com.google.gwt.event.dom.client.KeyPressHandler in project rstudio by rstudio.
the class DomUtils method addKeyHandlers.
public static void addKeyHandlers(HasAllKeyHandlers widget, final NativeEventHandler handler) {
widget.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(final KeyDownEvent event) {
handler.onNativeEvent(event.getNativeEvent());
}
});
widget.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(final KeyPressEvent event) {
handler.onNativeEvent(event.getNativeEvent());
}
});
widget.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(final KeyUpEvent event) {
handler.onNativeEvent(event.getNativeEvent());
}
});
}
use of com.google.gwt.event.dom.client.KeyPressHandler in project rstudio by rstudio.
the class ChooseFolderDialog method createMainWidget.
@Override
public Widget createMainWidget() {
Widget mainWidget = super.createMainWidget();
browser_.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
maybeInvalidateSelection();
}
});
browser_.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
maybeInvalidateSelection();
}
});
return mainWidget;
}
use of com.google.gwt.event.dom.client.KeyPressHandler in project gerrit by GerritCodeReview.
the class CopyableLabel method showTextBox.
private void showTextBox() {
if (textBox == null) {
textBox = new TextBox();
textBox.setText(getText());
textBox.setVisibleLength(visibleLen);
textBox.setReadOnly(true);
textBox.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(final KeyPressEvent event) {
if (event.isControlKeyDown() || event.isMetaKeyDown()) {
switch(event.getCharCode()) {
case 'c':
case 'x':
textBox.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(final KeyUpEvent event) {
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
hideTextBox();
}
});
}
});
break;
}
}
}
});
textBox.addBlurHandler(new BlurHandler() {
@Override
public void onBlur(final BlurEvent event) {
hideTextBox();
}
});
content.insert(textBox, 1);
}
textLabel.setVisible(false);
textBox.setVisible(true);
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
textBox.selectAll();
textBox.setFocus(true);
}
});
}
use of com.google.gwt.event.dom.client.KeyPressHandler in project gerrit by GerritCodeReview.
the class ProjectBranchesScreen method onInitUI.
@Override
protected void onInitUI() {
super.onInitUI();
initPageHeader();
prev = PagingHyperlink.createPrev();
prev.setVisible(false);
next = PagingHyperlink.createNext();
next.setVisible(false);
addPanel = new FlowPanel();
final Grid addGrid = new Grid(2, 2);
addGrid.setStyleName(Gerrit.RESOURCES.css().addBranch());
final int texBoxLength = 50;
nameTxtBox = new HintTextBox();
nameTxtBox.setVisibleLength(texBoxLength);
nameTxtBox.setHintText(AdminConstants.I.defaultBranchName());
nameTxtBox.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
doAddNewBranch();
}
}
});
addGrid.setText(0, 0, AdminConstants.I.columnBranchName() + ":");
addGrid.setWidget(0, 1, nameTxtBox);
irevTxtBox = new HintTextBox();
irevTxtBox.setVisibleLength(texBoxLength);
irevTxtBox.setHintText(AdminConstants.I.defaultRevisionSpec());
irevTxtBox.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
doAddNewBranch();
}
}
});
addGrid.setText(1, 0, AdminConstants.I.initialRevision() + ":");
addGrid.setWidget(1, 1, irevTxtBox);
addBranch = new Button(AdminConstants.I.buttonAddBranch());
addBranch.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
doAddNewBranch();
}
});
addPanel.add(addGrid);
addPanel.add(addBranch);
branchTable = new BranchesTable();
delBranch = new Button(AdminConstants.I.buttonDeleteBranch());
delBranch.setStyleName(Gerrit.RESOURCES.css().branchTableDeleteButton());
delBranch.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
branchTable.deleteChecked();
}
});
HorizontalPanel buttons = new HorizontalPanel();
buttons.setStyleName(Gerrit.RESOURCES.css().branchTablePrevNextLinks());
buttons.add(delBranch);
buttons.add(prev);
buttons.add(next);
add(branchTable);
add(buttons);
add(addPanel);
}
Aggregations