com.google.gwt.event.logical.shared.AttachEvent Java Examples

The following examples show how to use com.google.gwt.event.logical.shared.AttachEvent. 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: MockMap.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
public MockMap(SimpleEditor editor) {
  super(editor, TYPE, images.map(), new MockMapLayout());
  initToolbarItems();

  rootPanel.setHeight("100%");

  mapWidget = new AbsolutePanel();
  mapWidget.setStylePrimaryName("ode-SimpleMockContainer");
  mapWidget.add(rootPanel);

  initComponent(mapWidget);
  mapWidget.addAttachHandler(new AttachEvent.Handler() {
    @Override
    public void onAttachOrDetach(AttachEvent arg0) {
      if (arg0.isAttached()) {
        initPanel();
        invalidateMap();
        for (MockComponent child : children) {
          ((MockMapFeature) child).addToMap(MockMap.this);
        }
      }
    }
  });
}
 
Example #2
Source File: MaterialWidget.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
/**
 * Add an {@code AttachHandler} for attachment events.
 *
 * @param handler Attach event handler.
 * @param oneTime Only execute this handler once, then detach handler.
 * @return The events handler registration.
 */
public HandlerRegistration addAttachHandler(final AttachEvent.Handler handler, boolean oneTime) {
    if (!oneTime) {
        return addAttachHandler(handler);
    } else {
        final HandlerRegistration[] registration = {null};
        registration[0] = addAttachHandler(event -> {
            handler.onAttachOrDetach(event);

            if (registration[0] != null) {
                registration[0].removeHandler();
            }
        });
        return registration[0];
    }
}
 
Example #3
Source File: EventHelper.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
public static void onAttachOnce(HasAttachHandlers has, AttachEvent.Handler handler) {
    HandlerRegistration[] reg = new HandlerRegistration[1];

    if (has.isAttached()) {
        handler.onAttachOrDetach(null);
    } else {
        reg[0] = has.addAttachHandler(event -> {
            if (event.isAttached()) {
                handler.onAttachOrDetach(event);

                if (reg[0] != null) {
                    reg[0].removeHandler();
                }
            }
        });
    }
}
 
Example #4
Source File: MaterialTooltip.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public void setAttribute(String attr, String value) {
    if (widget != null) {
        AttachEvent.Handler handler = event -> {
            widget.getElement().setAttribute(attr, value);
        };
        if (widget.isAttached()) {
            handler.onAttachOrDetach(null);
        } else {
            EventHelper.onAttachOnce(widget, handler);
        }
    } else {
        GWT.log("Please initialize the Target widget.", new IllegalStateException());
    }
}
 
Example #5
Source File: Text.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
protected void onAttach() {
    if (isAttached()) {
        throw new IllegalStateException("Text is already attached!");
    }
    isAttached = true;
    onLoad();
    AttachEvent.fire(this, isAttached);
}
 
Example #6
Source File: Text.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDetach() {
    if (!isAttached()) {
        throw new IllegalStateException("Text is not attached!");
    }
    isAttached = false;
    AttachEvent.fire(this, false);
}
 
Example #7
Source File: ToggleButton.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
public void setActive(boolean active) {
    AttachEvent.Handler handler = event -> getActiveMixin().setActive(active);
    if (!isAttached()) {
        EventHelper.onAttachOnce(this, handler);
    } else {
        handler.onAttachOrDetach(null);
    }
}
 
Example #8
Source File: ContextFieldSet.java    From bitcoin-transaction-explorer with MIT License 5 votes vote down vote up
@Override
public void onAttachOrDetach(final AttachEvent event) {
  if (!event.isAttached()) {
    popupPanel.hide();
    if (attachRegistration != null) {
      attachRegistration.removeHandler();
    }
  }
}
 
Example #9
Source File: DocumentTitle.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onAttachOrDetach(AttachEvent event) {
	Document doc = Document.get();
	if (event.isAttached()) {
		fromTitle = doc.getTitle();
		doc.setTitle(title);
	} else {
		doc.setTitle(fromTitle);
	}
}
 
Example #10
Source File: FinderColumn.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public HandlerRegistration addAttachHandler(AttachEvent.Handler handler) {
    return layout.addAttachHandler(handler);
}
 
Example #11
Source File: ColumnManager.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ColumnManager(SplitLayoutPanel delegate, FinderColumn.FinderId finderId) {
    this.splitlayout = delegate;
    this.finderId = finderId;
    this.eventBus = Console.MODULES.getPlaceManager();

    this.initialized = false;

    // default state
    if(null==totalColumnsVisible.get(finderId))
        totalColumnsVisible.put(finderId, 0);

    this.splitlayout.addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if(!event.isAttached())
            {
                //System.out.println("Detach finder");
                decreaseTotalVisibleBy(ColumnManager.this.visibleColumns.size());

                assertVisibleColumns();
            }
            else
            {

                // skip the first attach event

                if(initialized) {

                   // System.out.println("Attach finder");

                    if (visibleColumns.size() > 0) {
                        increaseTotalVisibleBy(ColumnManager.this.visibleColumns.size());

                        assertVisibleColumns();
                    }
                }
                else
                {
                    initialized = true;
                }

                scrollIfNecessary();

            }
        }
    });


    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent resizeEvent) {
            Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                @Override
                public void execute() {
                    scrollIfNecessary();
                }
            });
        }
    });
}