com.google.gwt.event.dom.client.KeyDownHandler Java Examples

The following examples show how to use com.google.gwt.event.dom.client.KeyDownHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WordCloudApp.java    From swcv with MIT License 6 votes vote down vote up
private TextArea createTextArea()
{
    TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text"));
    textArea.addKeyDownHandler(new KeyDownHandler()
    {
        public void onKeyDown(KeyDownEvent event)
        {
            event.preventDefault();
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
            {
                createWordCloud();
            }
        }
    });

    return textArea;
}
 
Example #2
Source File: FilterBox.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void fixHandlers(final FilterBox box, Widget w) {
	if (w instanceof HasBlurHandlers)
		((HasBlurHandlers)w).addBlurHandler(box.iBlurHandler);
	if (w instanceof HasFocusHandlers)
		((HasFocusHandlers)w).addFocusHandler(box.iFocusHandler);
	if (w instanceof HasKeyDownHandlers)
		((HasKeyDownHandlers)w).addKeyDownHandler(new KeyDownHandler() {
			@Override
			public void onKeyDown(KeyDownEvent event) {
				if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE)
					if (box.isFilterPopupShowing()) box.hideFilterPopup();
			}
		});
}
 
Example #3
Source File: RemixedYoungAndroidProjectWizard.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new YoungAndroid project wizard.
 */
public RemixedYoungAndroidProjectWizard(final GalleryApp app, final Button actionButton) {
  super(MESSAGES.remixedYoungAndroidProjectWizardCaption());

  this.actionButton = actionButton;
  gallery = GalleryClient.getInstance();
  // Initialize the UI
  setStylePrimaryName("ode-DialogBox");

  projectNameTextBox = new LabeledTextBox(MESSAGES.projectNameLabel());
  projectNameTextBox.setText(replaceNonTextChar(app.getTitle()));
  projectNameTextBox.getTextBox().addKeyDownHandler(new KeyDownHandler() {
    @Override
    public void onKeyDown(KeyDownEvent event) {
      int keyCode = event.getNativeKeyCode();
      if (keyCode == KeyCodes.KEY_ENTER) {
        handleOkClick();
      } else if (keyCode == KeyCodes.KEY_ESCAPE) {
        handleCancelClick();
      }
    }
  });

  VerticalPanel page = new VerticalPanel();
  page.add(projectNameTextBox);
  addPage(page);
  // Create finish command (create a new Young Android project)
  initFinishCommand(new Command() {
    @Override
    public void execute() {
      String projectName = projectNameTextBox.getText();
      final PopupPanel popup = new PopupPanel(true);
      final FlowPanel content = new FlowPanel();
      popup.setWidget(content);
      Label loading = new Label();
      loading.setText(MESSAGES.loadingAppIndicatorText());
      // loading indicator will be hided or forced to be hided in gallery.loadSourceFile
      content.add(loading);
      popup.center();
      boolean success = gallery.loadSourceFile(app, projectNameTextBox.getText(), popup);
      if(success){
        gallery.appWasDownloaded(app.getGalleryAppId(), app.getDeveloperId());
      }
      else {
        show();
        center();
        return;
      }
    }
  });
}
 
Example #4
Source File: ComponentRenameWizard.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
protected ComponentRenameWizard(final String defaultTypeName, long projectId, final List<ProjectNode> compNodes) {
    super(MESSAGES.componentRenameWizardCaption(), true, false);

    this.defaultTypeName = defaultTypeName;
    this.defaultName = getDefaultName(defaultTypeName);
    this.destinationProjectId = projectId;
    this.nodes = compNodes;

    setStylePrimaryName("ode-DialogBox");

    renameTextBox = new LabeledTextBox(MESSAGES.componentNameLabel());
    renameTextBox.getTextBox().addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            int keyCode = event.getNativeKeyCode();
            if (keyCode == KeyCodes.KEY_ENTER) {
                handleOkClick();
            } else if (keyCode == KeyCodes.KEY_ESCAPE) {
                handleCancelClick();
            }
        }
    });

    renameTextBox.setText(defaultName);

    VerticalPanel page = new VerticalPanel();

    page.add(renameTextBox);
    addPage(page);

    // Create finish command (rename Extension)
    initFinishCommand(new Command() {
        @Override
        public void execute() {
            String newName = renameTextBox.getText();

            if (TextValidators.checkNewComponentName(newName)) {
                ode.getComponentService().renameImportedComponent(defaultTypeName, newName, destinationProjectId, new RenameComponentCallback());

            } else {
                show();
                center();
                renameTextBox.setFocus(true);
                renameTextBox.selectAll();
                return;
            }
        }
    });
    // Create cancel command (delete component files)
    initCancelCommand(new Command() {
        @Override
        public void execute() {
            ode.getComponentService().deleteImportedComponent(defaultTypeName, destinationProjectId, new AsyncCallback<Void>() {
                @Override
                public void onFailure(Throwable throwable) {

                }

                @Override
                public void onSuccess(Void aVoid) {

                }
            });
        }
    });
}
 
Example #5
Source File: GeocodingPanelWidget.java    From geowe-core with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Widget asWidget() {

	if (panel == null) {
		panel = new ContentPanel();
		panel.setBorders(true);
		panel.setPixelSize(490, 47);
		panel.setHeaderVisible(false);
		panel.setPosition(300, 0);
		panel.getElement().getStyle().setPosition(Position.ABSOLUTE);

		StyleInjector.inject(".statusBarStyle { " + "position: absolute; " + "bottom: 35 px;"
				+ "background: #E0ECF8;" + "border-radius: 5px 10px;" + "opacity: 0.8}");
		panel.setStyleName("geocodingPanelStyle");

		final HorizontalPanel horizontalGroup = new HorizontalPanel();
		horizontalGroup.getElement().getStyle().setVerticalAlign(VerticalAlign.MIDDLE);
		horizontalGroup.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
		horizontalGroup.setSpacing(5);
		horizontalGroup.getElement().getStyle().setBackgroundColor("#E0ECF8");

		addressTextField.setWidth("320px");
		addressTextField.setEmptyText(UIMessages.INSTANCE.gcAddressTextField());
		addressTextField.getElement().setId("autocompletar");

		addressTextField.addKeyDownHandler(new KeyDownHandler() {
			@Override
			public void onKeyDown(final KeyDownEvent event) {
				if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
					searchGeocoding(addressTextField.getText());
				}
			}
		});

		horizontalGroup.add(addressTextField);
		horizontalGroup.add(getSearchButton());
		horizontalGroup.add(getW3WLocationButton());
		horizontalGroup.add(getLocationMenuButton());
		panel.setWidget(horizontalGroup);
		panel.setVisible(false);
	}
	return panel;
}
 
Example #6
Source File: TimeSelector.java    From unitime with Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
	return iText.addKeyDownHandler(handler);
}
 
Example #7
Source File: FilterBox.java    From unitime with Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
	return iFilter.addKeyDownHandler(handler);
}
 
Example #8
Source File: UniTimeFilterBox.java    From unitime with Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
	return iFilter.getWidget().addKeyDownHandler(handler);
}
 
Example #9
Source File: Toolbar.java    From djvu-html5 with GNU General Public License v2.0 4 votes vote down vote up
public Toolbar() {
	setStyleName("toolbar");

	zoomPanel = new SelectionPanel("buttonZoomOut", "buttonZoomIn") {

		@Override
		protected void valueTypedIn() {
			zoomTypedIn();
		}

		@Override
		protected void valueSelected() {
			zoomSelectionChanged();
		}

		@Override
		protected void changeValueClicked(int direction) {
			zoomChangeClicked(direction);
		}

		@Override
		protected boolean isButtonEnabled(int direction) {
			if (direction == -1) {
				return pageLayout != null && pageLayout.getZoom() > zoomOptions.get(zoomOptions.size() - 1);
			} else {
				return pageLayout != null && pageLayout.getZoom() < zoomOptions.get(0);
			}
		}
	};
	add(zoomPanel);
	setZoomOptions(zoomOptions);

	pagePanel = new SelectionPanel("buttonPagePrev", "buttonPageNext") {

		@Override
		protected void valueTypedIn() {
			pageTypedIn();
		}

		@Override
		protected void valueSelected() {
			pageSelectionChanged();
		}

		@Override
		protected void changeValueClicked(int direction) {
			pageChangeClicked(direction);
		}
	};
	add(pagePanel);

	addDomHandler(new KeyDownHandler() {
		@Override
		public void onKeyDown(KeyDownEvent event) {
			final int KEY_PLUS = 187, KEY_MINUS = 189;
			int key = event.getNativeKeyCode();
			if (event.isControlKeyDown() && (key == KEY_PLUS || key == KEY_MINUS)) {
				zoomChangeClicked(key == KEY_PLUS ? 1 : -1);
				event.preventDefault();
			}
		}
	}, KeyDownEvent.getType());
}
 
Example #10
Source File: AbstractInput.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public com.google.gwt.event.shared.HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
	return this.addDomHandler(handler, KeyDownEvent.getType());
}
 
Example #11
Source File: ListItem.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
	return this.addDomHandler(handler, KeyDownEvent.getType());
}
 
Example #12
Source File: Anchor.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
	return this.addDomHandler(handler, KeyDownEvent.getType());
}
 
Example #13
Source File: CodeInputImpl.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
	return this.textArea.addKeyDownHandler(handler);
}
 
Example #14
Source File: HandlerPanel.java    From appinventor-extensions with Apache License 2.0 3 votes vote down vote up
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
  return addDomHandler(handler, KeyDownEvent.getType());
}