Example usage for com.google.gwt.user.client.ui AbsolutePanel remove

List of usage examples for com.google.gwt.user.client.ui AbsolutePanel remove

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui AbsolutePanel remove.

Prototype

@Override
public boolean remove(Widget w) 

Source Link

Document

Overrides ComplexPanel#remove(Widget) to change the removed Widget's element back to static positioning.This is done so that any positioning changes to the widget that were done by the panel are undone when the widget is disowned from the panel.

Usage

From source file:cl.uai.client.marks.RubricMark.java

License:Open Source License

public void removeCollaborativeButtons() {
    if (collaborativeMarks == null)
        return;/* w  w w .  ja va2  s. c o  m*/

    AbsolutePanel abspanel = (AbsolutePanel) this.getParent();
    abspanel.remove(collaborativeMarks);
}

From source file:com.ait.toolkit.clientio.uploader.client.Uploader.java

License:Apache License

private FileUpload createFileUpload() {
    fileUpload = new FileUpload();
    fileUpload.getElement().getStyle().setDisplay(Style.Display.NONE);

    if (fileTypes != null) {
        // Convert the format that the SWFUpload/Flash parameter expects to the W3C DOM standard
        // See: http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#attr-input-accept
        fileUpload.getElement().setAttribute("accept",
                this.fileTypes.replaceAll("\\;", ",").replaceAll("\\*\\.", "."));

        // TODO: Need to consider validation of this in the file queued handler as well, as the browsers don't
        // appear to consistently support the "accept" attribute
    }//from w  w w  . j  av  a2 s . co m

    final AbsolutePanel panel = this;

    fileUpload.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {

            JsArray selectedFiles = nativeGetSelectedFiles(fileUpload.getElement());

            // Every time a file is selected replace the FileUpload component running in the DOM so that
            // the user can continue to attempt uploading the same file multiple times (otherwise the
            // "ChangeHandler" never fires)
            panel.remove(fileUpload);
            panel.add(createFileUpload());

            addFilesToQueue(selectedFiles);

        }
    });
    return fileUpload;
}

From source file:de.eckhartarnold.client.TouchControls.java

License:Apache License

private void hideAllOtherWidgets(Image except) {
    AbsolutePanel panel = imagePanel.getPanel();
    for (int i = FIRST; i <= LAST; i++) {
        if (symbol[i] != except && panel.getWidgetIndex(symbol[i]) >= 0) {
            Fade.setOpacity(symbol[i], 0.0);
            panel.remove(symbol[i]);
        }//from ww  w. j a v  a  2 s .  c o  m
    }
}

From source file:org.gwtopenmaps.demo.openlayers.client.examples.gwtwidget.GwtWidgetExample.java

License:Apache License

@Override
public void buildPanel() {
    //create some MapOptions
    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setNumZoomLevels(16);

    //Create a MapWidget and add 2 OSM layers
    final MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions);
    OSM osm_1 = OSM.Mapnik("Mapnik");
    OSM osm_2 = OSM.CycleMap("CycleMap");
    osm_1.setIsBaseLayer(true);/*from   w  w w  .j  a  v  a  2  s .  c  o m*/
    osm_2.setIsBaseLayer(true);
    final Map map = mapWidget.getMap();
    map.addLayer(osm_1);
    map.addLayer(osm_2);

    //Lets add some default controls to the map
    map.addControl(new LayerSwitcher()); //+ sign in the upperright corner to display the layer switcher
    map.addControl(new OverviewMap()); //+ sign in the lowerright to display the overviewmap
    map.addControl(new ScaleLine()); //Display the scaleline

    //Center and zoom to a location
    final LonLat lonLat = new LonLat(6.95, 50.94);
    lonLat.transform(DEFAULT_PROJECTION.getProjectionCode(), map.getProjection()); //transform lonlat to OSM coordinate system
    map.setCenter(lonLat, 5);

    //And now where the real code starts
    final AbsolutePanel panel = new AbsolutePanel(); //use a GWT AbsolutePanel
    panel.setSize("500px", "500px"); //give it the same size as the MapWidget
    panel.add(mapWidget, 0, 0); //add the MapWidget to the AbsolutePanel

    final List<TextBox> ltb = new ArrayList<TextBox>();
    final List<LonLat> lll = new ArrayList<LonLat>();

    for (int i = 0; i < 20; i++) {
        for (int j = 40; j < 60; j++) {
            final TextBox tbGwt = new TextBox(); //we will add a TextBox to on top of the map
            tbGwt.setText("I am a GWT TextBox " + i + ";" + j);
            tbGwt.getElement().getStyle().setProperty("pointerEvents", "none"); //events will go through to the map
            ltb.add(tbGwt);

            final LonLat ll = new LonLat(i, j);
            ll.transform(DEFAULT_PROJECTION.getProjectionCode(), map.getProjection()); //transform lonlat to OSM coordinate system
            lll.add(ll);
        }
    }

    int count = 0;
    for (int i = 0; i < 20; i++) {
        for (int j = 40; j < 60; j++) {
            final LonLat ll = lll.get(count);

            Pixel pxLonLat = map.getPixelFromLonLat(ll); //calculate px coordinates from lonLat
            int x = pxLonLat.x();
            int y = pxLonLat.y();

            if ((x > 0) && (y > 0) && (x < 500) && (y < 500)) {
                panel.add(ltb.get(count), pxLonLat.x(), pxLonLat.y()); //add TextBox add these px coordinates
            }
            count++;
        }
    }

    map.addMapMoveListener(new MapMoveListener() {

        public void onMapMove(MapMoveEvent eventObject) {

            if (panel.getWidgetCount() > 1) {
                int count2 = 0;
                for (int i = 0; i < 20; i++) {
                    for (int j = 40; j < 60; j++) {
                        panel.remove(ltb.get(count2));
                        count2++;
                    }
                }
            }

            int count3 = 0;
            for (int i = 0; i < 20; i++) {
                for (int j = 40; j < 60; j++) {
                    final LonLat ll = lll.get(count3);

                    Pixel pxLonLat = map.getPixelFromLonLat(ll); //calculate px coordinates from lonLat
                    int x = pxLonLat.x();
                    int y = pxLonLat.y();

                    if ((x > 0) && (y > 0) && (x < 500) && (y < 500)) {
                        panel.add(ltb.get(count3), pxLonLat.x(), pxLonLat.y()); //add TextBox add these px coordinates
                    }
                    count3++;
                }
            }

        }
    });

    contentPanel
            .add(new HTML("<p>This example shows how to add a GWT widget to the map, at a certain location.</p>"
                    + "<p>In this example we add a TextBox at LonLat(6.95, 50.94). The upperleft point of the widget will be placed at this point."));
    contentPanel.add(panel);

    initWidget(contentPanel);

    mapWidget.getElement().getFirstChildElement().getStyle().setZIndex(0); //force the map to fall behind popups
}

From source file:org.moxieapps.gwt.uploader.client.Uploader.java

License:Apache License

private FileUpload createFileUpload() {
    fileUpload = new FileUpload();
    fileUpload.getElement().getStyle().setDisplay(Style.Display.NONE);

    if (fileTypes != null) {
        // Convert the format that the SWFUpload/Flash parameter expects to the W3C DOM standard
        // See: http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#attr-input-accept
        //      fileUpload.getElement().setAttribute("accept", this.fileTypes.replaceAll("\\;", ",").replaceAll("\\*\\.", "."));
        //   fileUpload.getElement().setAttribute("type", "file");
        fileUpload.getElement().setAttribute("accept", "image/*");
        fileUpload.getElement().setAttribute("capture", "camera");

        // TODO: Need to consider validation of this in the file queued handler as well, as the browsers don't
        // appear to consistently support the "accept" attribute
    }//from   w  w w.  j  a  v a2 s.  c om

    final AbsolutePanel panel = this;

    fileUpload.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {

            JsArray selectedFiles = nativeGetSelectedFiles(fileUpload.getElement());

            // Every time a file is selected replace the FileUpload component running in the DOM so that
            // the user can continue to attempt uploading the same file multiple times (otherwise the
            // "ChangeHandler" never fires)
            panel.remove(fileUpload);
            panel.add(createFileUpload());

            addFilesToQueue(selectedFiles);

        }
    });
    return fileUpload;
}

From source file:org.openxdata.designer.client.view.DesignSurfaceView.java

/**
 * Fills bindings for loaded widgets in a given panel.
 * /*from  ww w  . java  2s.  c  o m*/
 * @param panel the panel.
 * @param bindings the map of bindings. Made a map instead of list for only easy of search with key.
 */
private void fillBindings(AbsolutePanel panel, HashMap<String, String> bindings) {
    if (panel.getWidgetIndex(rubberBand) > -1)
        panel.remove(rubberBand);

    for (int index = 0; index < panel.getWidgetCount(); index++) {
        DesignWidgetWrapper widget = (DesignWidgetWrapper) panel.getWidget(index);

        //When a widget is deleted, it is reloaded on refresh even if its label still exists.
        if (widget.getWrappedWidget() instanceof Label)
            continue;

        String binding = widget.getParentBinding();
        if (binding == null)
            binding = widget.getBinding();
        bindings.put(binding, binding); //Could possibly put widget as value.

        if (widget.getWrappedWidget() instanceof DesignGroupWidget)
            fillBindings(((DesignGroupWidget) widget.getWrappedWidget()).getPanel(), bindings);
    }
}

From source file:org.wisepersist.gwt.uploader.client.Uploader.java

License:Apache License

private FileUpload createFileUpload() {
    fileUpload = new FileUpload();
    fileUpload.getElement().getStyle().setDisplay(Style.Display.NONE);

    if (fileTypes != null) {
        // Convert the format that the SWFUpload/Flash parameter expects to the W3C DOM standard
        // See: http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#attr-input-accept
        fileUpload.getElement().setAttribute("accept",
                this.fileTypes.replaceAll("\\;", ",").replaceAll("\\*\\.", "."));

        // TODO(jake): Need to consider validation of this in the file queued handler as well,
        // as the browsers don't appear to consistently support the "accept" attribute
    }//from   w w w .  j  ava 2  s.  co m

    final AbsolutePanel panel = this;

    fileUpload.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {

            JsArray<?> selectedFiles = nativeGetSelectedFiles(fileUpload.getElement());

            // Every time a file is selected replace the FileUpload component running in the DOM so that
            // the user can continue to attempt uploading the same file multiple times (otherwise the
            // "ChangeHandler" never fires)
            panel.remove(fileUpload);
            panel.add(createFileUpload());

            addFilesToQueue(selectedFiles);

        }
    });
    return fileUpload;
}