Package com.google.gwt.event.shared

Examples of com.google.gwt.event.shared.HandlerRegistration


      btnLayout.setStyleName(STYLE_SEARCH_ROW);

      IButton btnAddRow = new IButton();
      btnAddRow.setWidth(26);
      btnAddRow.setIcon("[ISOMORPHIC]/geomajas/silk/add.png");
      HandlerRegistration addReg = btnAddRow.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
          IButton btnAddRow2 = (IButton) event.getSource();
          for (int i = 0; i < buttonPanes.size(); i++) {
            IButton button = (IButton) buttonPanes.get(i).getMember(0);
            if (btnAddRow2.equals(button)) {
              addEmptyRow(i + 1);
              break;
            }
          }
          buttonPanes.get(0).getMember(1).setDisabled(false);
        }
      });

      IButton btnRemoveRow = new IButton();
      btnRemoveRow.setWidth(26);
      btnRemoveRow.setIcon("[ISOMORPHIC]/geomajas/silk/remove.png");
      HandlerRegistration removeReg = btnRemoveRow.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
          IButton sourceBtn = (IButton) event.getSource();
          for (int i = 0; i < buttonPanes.size(); i++) {
            IButton button = (IButton) buttonPanes.get(i).getMember(1);
            if (sourceBtn.equals(button)) {
View Full Code Here


    btnLayout.setStyleName(STYLE_SEARCH_ROW);

    IButton btnAddRow = new IButton();
    btnAddRow.setWidth(26);
    btnAddRow.setIcon("[ISOMORPHIC]/geomajas/silk/add.png");
    HandlerRegistration addReg = btnAddRow.addClickHandler(new ClickHandler() {

      public void onClick(ClickEvent event) {
        IButton btnAddRow2 = (IButton) event.getSource();
        for (int i = 0; i < buttonPanes.size(); i++) {
          IButton button = (IButton) buttonPanes.get(i).getMember(0);
          if (btnAddRow2.equals(button)) {
            addEmptyRow(i + 1);
            break;
          }
        }
        buttonPanes.get(0).getMember(1).setDisabled(false);
      }
    });

    IButton btnRemoveRow = new IButton();
    btnRemoveRow.setWidth(26);
    btnRemoveRow.setIcon("[ISOMORPHIC]/geomajas/silk/remove.png");
    HandlerRegistration removeReg = btnRemoveRow.addClickHandler(new ClickHandler() {

      public void onClick(ClickEvent event) {
        IButton sourceBtn = (IButton) event.getSource();
        for (int i = 0; i < buttonPanes.size(); i++) {
          IButton button = (IButton) buttonPanes.get(i).getMember(1);
View Full Code Here

    // no scale limitations
    mapView.setMaximumScale(Double.MAX_VALUE);
    mapView.setMaxBounds(new Bbox(-1E20, -1E20, 2E20, 2E20));
   
    CaptureHandler handler = new CaptureHandler();
    HandlerRegistration registration = mapView.addMapViewChangedHandler(handler);
    // force 1.0
    mapView.setCurrentScale(1.0, MapView.ZoomOption.LEVEL_CLOSEST);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, true);
    // force 2.0
    mapView.setCurrentScale(2.0, MapView.ZoomOption.LEVEL_CLOSEST);
    // zooms in to 2.0
    handler.expect(new Bbox(450, 175, 100, 50), 2.0, false);
    // force 0.01
    mapView.setCurrentScale(0.01, MapView.ZoomOption.LEVEL_CLOSEST);
    // zooms in to 0.01
    handler.expect(new Bbox(-9500, -4800, 20000, 10000), 0.01, false);
    // fitting
    // force 1.0
    mapView.setCurrentScale(1.0, MapView.ZoomOption.LEVEL_FIT);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, false);
    // force 2.0
    mapView.setCurrentScale(2.0, MapView.ZoomOption.LEVEL_FIT);
    // zooms in to 2.0
    handler.expect(new Bbox(450, 175, 100, 50), 2.0, false);
    // force 0.01
    mapView.setCurrentScale(0.01, MapView.ZoomOption.LEVEL_FIT);
    // zooms in to 0.01
    handler.expect(new Bbox(-9500, -4800, 20000, 10000), 0.01, false);
    handler.validate();
    registration.removeHandler();
   
    // test for 1 resolution
    resolutions = new ArrayList<Double>();
    resolutions.add(1 / 1.0);
    mapView.setResolutions(resolutions);
View Full Code Here

    Layer<?> layer2 = layersModel.getLayer(LAYER2);

    selectId = null;
    deselectId = null;

    HandlerRegistration reg = eventBus.addHandler(LayerSelectionHandler.TYPE, new LayerSelectionHandler() {

      public void onSelectLayer(LayerSelectedEvent event) {
        selectId = event.getLayer().getId();
      }

      public void onDeselectLayer(LayerDeselectedEvent event) {
        deselectId = event.getLayer().getId();
      }
    });

    layer1.setSelected(true);
    Assert.assertEquals(LAYER1, selectId);
    Assert.assertNull(deselectId);

    layer2.setSelected(true);
    Assert.assertEquals(LAYER1, deselectId);
    Assert.assertEquals(LAYER2, selectId);

    layer2.setSelected(false);
    Assert.assertEquals(LAYER2, deselectId);
    Assert.assertEquals(LAYER2, selectId);

    reg.removeHandler();
  }
View Full Code Here

    Layer<?> layer3 = layersModel.getLayer(LAYER3);

    fromIndex = 342;
    toIndex = 342;

    HandlerRegistration reg = eventBus.addHandler(LayerOrderChangedHandler.TYPE, new LayerOrderChangedHandler() {

      public void onLayerOrderChanged(LayerOrderChangedEvent event) {
        fromIndex = event.getFromIndex();
        toIndex = event.getToIndex();
      }
    });

    layersModel.moveLayerDown(layer1); // Expect no changes, and so no event.
    Assert.assertEquals(342, fromIndex);
    Assert.assertEquals(342, toIndex);

    layersModel.moveLayerDown(layer3);
    Assert.assertEquals(2, fromIndex);
    Assert.assertEquals(1, toIndex);

    reg.removeHandler();
  }
View Full Code Here

    Layer<?> layer3 = layersModel.getLayer(LAYER3);

    fromIndex = 342;
    toIndex = 342;

    HandlerRegistration reg = eventBus.addHandler(LayerOrderChangedHandler.TYPE, new LayerOrderChangedHandler() {

      public void onLayerOrderChanged(LayerOrderChangedEvent event) {
        fromIndex = event.getFromIndex();
        toIndex = event.getToIndex();
      }
    });

    layersModel.moveLayerUp(layer3); // Expect no changes, and so no event.
    Assert.assertEquals(342, fromIndex);
    Assert.assertEquals(342, toIndex);

    layersModel.moveLayerUp(layer1);
    Assert.assertEquals(0, fromIndex);
    Assert.assertEquals(1, toIndex);

    reg.removeHandler();
  }
View Full Code Here

    Layer<?> layer3 = layersModel.getLayer(LAYER3);

    fromIndex = 342;
    toIndex = 342;

    HandlerRegistration reg = eventBus.addHandler(LayerOrderChangedHandler.TYPE, new LayerOrderChangedHandler() {

      public void onLayerOrderChanged(LayerOrderChangedEvent event) {
        fromIndex = event.getFromIndex();
        toIndex = event.getToIndex();
      }
    });

    layersModel.moveLayer(layer1, -1); // Expect no changes, and so no event.
    Assert.assertEquals(342, fromIndex);
    Assert.assertEquals(342, toIndex);

    layersModel.moveLayer(layer2, -1);
    Assert.assertEquals(1, fromIndex);
    Assert.assertEquals(0, toIndex);

    layersModel.moveLayer(layer2, 2);
    Assert.assertEquals(0, fromIndex);
    Assert.assertEquals(2, toIndex);

    layersModel.moveLayer(layer2, 200); // Expect no changes.
    Assert.assertEquals(0, fromIndex);
    Assert.assertEquals(2, toIndex);

    layersModel.moveLayer(layer3, 0);
    Assert.assertEquals(1, fromIndex);
    Assert.assertEquals(0, toIndex);

    fromIndex = 342;
    toIndex = 342;

    // Corner case - move to same position. We don't expect an event.
    layersModel.moveLayer(layer3, 0);
    Assert.assertEquals(342, fromIndex);
    Assert.assertEquals(342, toIndex);

    reg.removeHandler();
  }
View Full Code Here

      public void onLayerRemoved(LayerRemovedEvent event) {
        layerCount--;
      }
    };
    HandlerRegistration reg = eventBus.addHandler(MapCompositionHandler.TYPE, layerCounter);

    layersModel.removeLayer(LAYER1);
    Assert.assertEquals(2, layerCount);
    layersModel.removeLayer(LAYER3);
    Assert.assertEquals(1, layerCount);
    layersModel.removeLayer(LAYER2);
    Assert.assertEquals(0, layerCount);

    // Corner cases:
    Assert.assertFalse(layersModel.removeLayer("this-layer-does-not-exist"));
    try {
      layersModel.removeLayer(null);
      Assert.fail();
    } catch (NullPointerException npe) {
      // Test passed.
    }

    reg.removeHandler();
  }
View Full Code Here

  @Test
  public void testApplyPosition() {
    Assert.assertEquals(4.0, viewPort.getScale());
    Assert.assertNull(event);

    HandlerRegistration reg = eventBus.addHandler(ViewPortChangedHandler.TYPE, new AllowTranslationHandler());

    viewPort.applyPosition(new Coordinate(342, 342));
    Assert.assertEquals(4.0, viewPort.getScale());
    Assert.assertNotNull(event);
    Assert.assertTrue(event instanceof ViewPortTranslatedEvent);

    reg.removeHandler();
  }
View Full Code Here

  @Test
  public void testApplyScale() {
    Assert.assertEquals(4.0, viewPort.getScale());
    Assert.assertNull(event);

    HandlerRegistration reg = eventBus.addHandler(ViewPortChangedHandler.TYPE, new AllowScalingHandler());

    viewPort.applyScale(2.0);
    Assert.assertEquals(2.0, viewPort.getScale());
    Assert.assertNotNull(event);
    Assert.assertTrue(event instanceof ViewPortScaledEvent);

    reg.removeHandler();
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.event.shared.HandlerRegistration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.