use of com.google.gwt.user.client.Command in project drools-wb by kiegroup.
the class FromCompositeFactPatternWidget method getCompositeLabel.
protected Widget getCompositeLabel() {
ClickHandler click = new ClickHandler() {
public void onClick(ClickEvent event) {
showFactTypeSelector();
}
};
String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from") + " </div>";
FlexTable panel = new FlexTable();
int r = 0;
if (pattern.getFactPattern() == null) {
panel.setWidget(r, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", click, !this.readOnly));
r++;
}
panel.setWidget(r, 0, new HTML(lbl));
ExpressionBuilder expressionBuilder = new ExpressionBuilder(this.getModeller(), this.getEventBus(), this.pattern.getExpression(), this.readOnly);
expressionBuilder.addOnModifiedCommand(new Command() {
public void execute() {
setModified(true);
}
});
panel.setWidget(r, 1, expressionBuilder);
return panel;
}
use of com.google.gwt.user.client.Command in project drools-wb by kiegroup.
the class FromCompositeFactPatternWidget method createFactPatternWidget.
private Widget createFactPatternWidget(FactPattern fact) {
FactPatternWidget factPatternWidget;
if (this.readOnly) {
// creates a new read-only FactPatternWidget
factPatternWidget = new FactPatternWidget(this.getModeller(), this.getEventBus(), fact, false, true);
// this.layout.setWidget( 0, 0, factPatternWidget );
return factPatternWidget;
} else {
factPatternWidget = new FactPatternWidget(this.getModeller(), this.getEventBus(), fact, true, false);
factPatternWidget.addOnModifiedCommand(new Command() {
public void execute() {
setModified(true);
}
});
// this.layout.setWidget( 0, 0, addRemoveButton( factPatternWidget, createClickHandlerForAddRemoveButton() ) );
return addRemoveButton(factPatternWidget, createClickHandlerForAddRemoveButton());
}
}
use of com.google.gwt.user.client.Command in project che by eclipse.
the class NavigateToFileViewImpl method handleKeyDown.
@UiHandler("fileName")
void handleKeyDown(KeyDownEvent event) {
switch(event.getNativeKeyCode()) {
case KeyCodes.KEY_UP:
event.stopPropagation();
event.preventDefault();
if (list != null) {
list.getSelectionModel().selectPrevious();
}
return;
case KeyCodes.KEY_DOWN:
event.stopPropagation();
event.preventDefault();
if (list != null) {
list.getSelectionModel().selectNext();
}
return;
case KeyCodes.KEY_PAGEUP:
event.stopPropagation();
event.preventDefault();
if (list != null) {
list.getSelectionModel().selectPreviousPage();
}
return;
case KeyCodes.KEY_PAGEDOWN:
event.stopPropagation();
event.preventDefault();
if (list != null) {
list.getSelectionModel().selectNextPage();
}
return;
case KeyCodes.KEY_ENTER:
event.stopPropagation();
event.preventDefault();
ItemReference selectedItem = list.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
delegate.onFileSelected(Path.valueOf(selectedItem.getPath()));
;
}
return;
case KeyCodes.KEY_ESCAPE:
event.stopPropagation();
event.preventDefault();
hidePopup();
return;
}
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
delegate.onFileNameChanged(fileName.getText());
}
});
}
use of com.google.gwt.user.client.Command in project gwt-test-utils by gwt-test-utils.
the class WidgetUtilsTest method suggestBoxItems.
@Test
public void suggestBoxItems() {
// Given
SuggestBox box = new SuggestBox();
SuggestionDisplay display = GwtReflectionUtils.getPrivateFieldValue(box, "display");
MenuBar bar = GwtReflectionUtils.getPrivateFieldValue(display, "suggestionMenu");
Command cmd = new Command() {
public void execute() {
}
};
MenuItem item0 = bar.addItem("item0", cmd);
MenuItem item1 = bar.addItem("item1", cmd);
// When
List<MenuItem> items = WidgetUtils.getMenuItems(box);
// Then
assertThat(items).hasSize(2);
assertThat(items.get(0)).isEqualTo(item0);
assertThat(items.get(1)).isEqualTo(item1);
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class MenuBar method doItemAction.
/*
* Performs the action associated with the given menu item. If the item has a
* popup associated with it, the popup will be shown. If it has a command
* associated with it, and 'fireCommand' is true, then the command will be
* fired. Popups associated with other items will be hidden.
*
* @param item the item whose popup is to be shown. @param fireCommand
* <code>true</code> if the item's command should be fired, <code>false</code>
* otherwise.
*/
void doItemAction(final MenuItem item, boolean fireCommand, boolean focus) {
// Should not perform any action if the item is disabled
if (!item.isEnabled()) {
return;
}
// Ensure that the item is selected.
selectItem(item);
if (item != null) {
// if the command should be fired and the item has one, fire it
if (fireCommand && item.getCommand() != null) {
// Close this menu and all of its parents.
closeAllParents();
// Fire the item's command. The command must be fired in the same event
// loop or popup blockers will prevent popups from opening.
final Command cmd = item.getCommand();
Scheduler.get().scheduleFinally(new Scheduler.ScheduledCommand() {
public void execute() {
cmd.execute();
}
});
// hide any open submenus of this item
if (shownChildMenu != null) {
shownChildMenu.onHide(focus);
popup.hide();
shownChildMenu = null;
selectItem(null);
}
} else if (item.getSubMenu() != null) {
if (shownChildMenu == null) {
// open this submenu
openPopup(item);
} else if (item.getSubMenu() != shownChildMenu) {
// close the other submenu and open this one
shownChildMenu.onHide(focus);
popup.hide();
openPopup(item);
} else if (fireCommand && !autoOpen) {
// close this submenu
shownChildMenu.onHide(focus);
popup.hide();
shownChildMenu = null;
selectItem(item);
}
} else if (autoOpen && shownChildMenu != null) {
// close submenu
shownChildMenu.onHide(focus);
popup.hide();
shownChildMenu = null;
}
}
}
Aggregations