Search in sources :

Example 86 with Command

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") + "&nbsp;</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;
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Command(com.google.gwt.user.client.Command) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) HTML(com.google.gwt.user.client.ui.HTML)

Example 87 with Command

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());
    }
}
Also used : Command(com.google.gwt.user.client.Command)

Example 88 with Command

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());
        }
    });
}
Also used : ItemReference(org.eclipse.che.api.project.shared.dto.ItemReference) Command(com.google.gwt.user.client.Command) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 89 with Command

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);
}
Also used : SuggestionDisplay(com.google.gwt.user.client.ui.SuggestBox.SuggestionDisplay) Command(com.google.gwt.user.client.Command) Test(org.junit.Test)

Example 90 with Command

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;
        }
    }
}
Also used : Command(com.google.gwt.user.client.Command) Scheduler(com.google.gwt.core.client.Scheduler)

Aggregations

Command (com.google.gwt.user.client.Command)189 AppCommand (org.rstudio.core.client.command.AppCommand)39 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)38 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)21 JsArrayString (com.google.gwt.core.client.JsArrayString)16 Test (org.junit.Test)16 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)15 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)15 ArrayList (java.util.ArrayList)11 ServerError (org.rstudio.studio.client.server.ServerError)11 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)10 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)10 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)9 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)8 MenuItem (com.google.gwt.user.client.ui.MenuItem)8 Handler (org.rstudio.core.client.command.Handler)8 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)8 Widget (com.google.gwt.user.client.ui.Widget)7 Operation (org.rstudio.core.client.widget.Operation)7 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)7