Example usage for com.google.gwt.user.client Window addResizeHandler

List of usage examples for com.google.gwt.user.client Window addResizeHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window addResizeHandler.

Prototype

public static HandlerRegistration addResizeHandler(ResizeHandler handler) 

Source Link

Usage

From source file:se.esss.litterbox.linaclego.webapp.client.panels.CsvFilePanel.java

License:Open Source License

public void setCsvFile(CsvFile csvFile) {
    if (getWidgetCount() > 0)
        clear();//w  ww.  ja va2  s.  c  o  m
    this.csvFile = csvFile;
    Anchor sourceFileAnchor = new Anchor("Source File");
    sourceFileAnchor.addClickHandler(new DownLoadClickHandler(sourceFileLink));
    add(sourceFileAnchor);
    numDataRows = csvFile.numOfRows() - numHeaderRows;

    dataGrid = new Grid(numDataRows, csvFile.numOfCols());
    headerGrid = new Grid(numHeaderRows, csvFile.numOfCols());
    dataGridScrollPane = new ScrollPanel();
    dataGridScrollPane.add(dataGrid);
    add(headerGrid);
    add(dataGridScrollPane);

    for (int irow = 0; irow < numHeaderRows; ++irow) {
        for (int icol = 0; icol < csvFile.numOfCols(); ++icol) {
            headerGrid.setText(irow, icol, csvFile.getLine(irow).getCell(icol));
        }
    }
    int numDataRowsOnLoad = numDataRows;
    fileCompletelyLoaded = true;
    if (numDataRowsOnLoad > getMaxNumDataRowsOnLoad()) {
        numDataRowsOnLoad = getMaxNumDataRowsOnLoad();
        fileCompletelyLoaded = false;
        Scheduler.get().scheduleIncremental(new CsvFilePanelIncrementalExtraRowLoader(this));
    }
    for (int irow = 0; irow < numDataRowsOnLoad; ++irow) {
        for (int icol = 0; icol < csvFile.numOfCols(); ++icol) {
            dataGrid.setText(irow, icol, csvFile.getLine(irow + numHeaderRows).getCell(icol));
        }
        if (oddDataRow)
            dataGrid.getRowFormatter().setStyleName(irow, "csvFilePanelOddRow");
        oddDataRow = !oddDataRow;
    }
    lastDataRowLoaded = numDataRowsOnLoad - 1;
    resizeMe(csvFile);
    Window.addResizeHandler(new MyResizeHandler(csvFile));
    for (int ih = 0; ih < numHeaderRows; ++ih)
        headerGrid.getRowFormatter().setStyleName(ih, "csvFilePanelHeader");
    headerGrid.setBorderWidth(0);
    headerGrid.setCellSpacing(0);
    headerGrid.setCellPadding(0);
    dataGrid.setBorderWidth(0);
    dataGrid.setCellSpacing(0);
    dataGrid.setCellPadding(0);
    dataGrid.addClickHandler(new DataGridClickHandler(dataGrid));

    if (fileCompletelyLoaded)
        myTabLayoutScrollPanel.getMyTabLayoutPanel().getLinacLegoWebApp().getStatusTextArea()
                .addStatus("Finished building " + csvFileType + " Spreadsheet.");
    if (!fileCompletelyLoaded)
        myTabLayoutScrollPanel.getMyTabLayoutPanel().getLinacLegoWebApp().getStatusTextArea()
                .addStatus("Still building " + csvFileType + " Spreadsheet.");
}

From source file:se.esss.litterbox.linaclego.webapp.client.panels.PartsFilePanel.java

License:Open Source License

public void setPartsFile(CsvFile csvFile) {
    if (getWidgetCount() > 0)
        clear();/* ww  w. j a va  2  s .c o  m*/
    this.partsFile = csvFile;
    Anchor sourceFileAnchor = new Anchor("Source File");
    sourceFileAnchor.addClickHandler(new DownLoadClickHandler(sourceFileLink));
    add(sourceFileAnchor);
    numDataRows = csvFile.numOfRows() - numHeaderRows;

    dataGrid = new Grid(numDataRows, csvFile.numOfCols());
    headerGrid = new Grid(numHeaderRows, csvFile.numOfCols());
    dataGridScrollPane = new ScrollPanel();
    dataGridScrollPane.add(dataGrid);
    add(headerGrid);
    add(dataGridScrollPane);

    for (int irow = 0; irow < numHeaderRows; ++irow) {
        for (int icol = 0; icol < csvFile.numOfCols(); ++icol) {
            headerGrid.setText(irow, icol, csvFile.getLine(irow).getCell(icol));
        }
    }
    for (int irow = 0; irow < numDataRows; ++irow) {
        for (int icol = 0; icol < csvFile.numOfCols(); ++icol) {
            dataGrid.setText(irow, icol, csvFile.getLine(irow + numHeaderRows).getCell(icol));
        }
        if (oddDataRow)
            dataGrid.getRowFormatter().setStyleName(irow, "csvFilePanelOddRow");
        oddDataRow = !oddDataRow;
    }
    resizeMe(csvFile);
    Window.addResizeHandler(new MyResizeHandler(csvFile));
    for (int ih = 0; ih < numHeaderRows; ++ih)
        headerGrid.getRowFormatter().setStyleName(ih, "partsFilePanelHeader");
    headerGrid.setBorderWidth(0);
    headerGrid.setCellSpacing(0);
    headerGrid.setCellPadding(0);
    dataGrid.setBorderWidth(0);
    dataGrid.setCellSpacing(0);
    dataGrid.setCellPadding(0);
    dataGrid.addClickHandler(new DataGridClickHandler(this));

    getLinacLegoWebApp().getStatusTextArea().addStatus("Finished building " + partsFileType + " Spreadsheet.");
}

From source file:stroom.widget.popup.client.view.Dialog.java

License:Apache License

@Override
public void show() {
    setGlassEnabled(isModal());/* w w w .  j a v  a2 s . co m*/

    if (resizeHandlerRegistration == null) {
        resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {
            @Override
            public void onResize(final ResizeEvent event) {
                windowWidth = event.getWidth();
            }
        });
    }
    super.show();
}

From source file:teropa.globetrotter.client.Demo.java

License:Creative Commons License

public void onModuleLoad() {
    final Map map = new Map("100%", "100%");
    map.setResolutions(OpenStreetMapLayer.SUPPORTED_RESOLUTIONS, 4);

    initBaseLayer(map);//from  w  w w .  ja  v a2s. co  m
    initMarkerLayer(map);
    initControls(map);

    // Tell the map to recalculate its layout when window size changes
    Window.addResizeHandler(new ResizeHandler() {
        public void onResize(ResizeEvent event) {
            map.onResize();
        }
    });

    RootPanel.get("container").add(map);
}

From source file:test.client.application.ApplicationView.java

License:Apache License

@Inject
ApplicationView(Binder uiBinder, final Resources resources) {
    this.resources = resources;
    resources.screenCss().ensureInjected();
    initWidget(uiBinder.createAndBindUi(this));

    scrollPanel.addAttachHandler(new AttachEvent.Handler() {

        @Override/* w  w  w  .  j  a v  a2 s  . co  m*/
        public void onAttachOrDetach(AttachEvent event) {
            if (event.isAttached()) {
                updateCanvasSize();
            }
        }
    });

    Window.addResizeHandler(new ResizeHandler() {

        @Override
        public void onResize(ResizeEvent event) {
            updateCanvasSize();
        }
    });

    // create drag controller
    //      dragController = new PickupDragController(canvas, true);
    dragController = new PickupDragController(viewport, true); // original
    dragController.addDragHandler(new DragHandler() {

        @Override
        public void onPreviewDragStart(DragStartEvent event) throws VetoDragException {
            GWT.log("drag preview start");
        }

        @Override
        public void onPreviewDragEnd(DragEndEvent event) throws VetoDragException {
            GWT.log("drag preview end");
        }

        @Override
        public void onDragStart(DragStartEvent event) {
            GWT.log("drag start");
        }

        @Override
        public void onDragEnd(DragEndEvent event) {
            GWT.log("drag end");
        }
    });
    dragController.setBehaviorDragStartSensitivity(resources.screenCss().dragSensitivity());
    dragController.setBehaviorBoundaryPanelDrop(false);

    // instantiate our drop controller
    dropController = new AbsolutePositionDropController(canvas) { // original
        //      dropController = new AbsolutePositionDropController(viewport) {
        @Override
        public void onDrop(DragContext context) {
            super.onDrop(context);
            GWT.log("onDrop");
        }

    };
    dragController.registerDropController(dropController);

    //      test1.addStyleName(resources.screenCss().note());

    FocusPanel focusPanel = new FocusPanel();
    focusPanel.addStyleName(resources.screenCss().noteFocusPanel());
    //      test1.add(focusPanel);

    //      canvas.add(test1, 10, 10);

    // test
    //      dragController.makeDraggable(test1, focusPanel);

    // drag and drop map notes enabled

    FlowPanel notePanel = new FlowPanel();
    notePanel.addStyleName(resources.screenCss().note());

    // note drag and drop
    FocusPanel noteFocusPanel = new FocusPanel();
    noteFocusPanel.addStyleName(resources.screenCss().noteFocusPanel());
    notePanel.add(noteFocusPanel);

    // don't pass click events to the canvas
    noteFocusPanel.addClickHandler(clickStopPropagationHandler);

    // flow panel for all note elements
    Panel noteFlowPanel = new FlowPanel();
    noteFocusPanel.add(noteFlowPanel);

    // note body label
    HTML bodyLabel = new HTML();
    bodyLabel.setText("hello");
    noteFlowPanel.add(bodyLabel);

    // add note to canvas
    //canvas.add(notePanel, 100, 100);

    // drag and drop notes enabled
    dragController.makeDraggable(notePanel, noteFocusPanel);

    //      dragController.makeDraggable(canvas);
}

From source file:test.client.ResizableMapLayout.java

License:Open Source License

/**
 * Create a resizable map layout for the given map. The map will be added to this layout.
 * /*ww w. j av  a  2  s .  co  m*/
 * @param mapPresenter
 *            The map to add.
 */
public ResizableMapLayout(final MapPresenter mapPresenter) {
    this.mapPresenter = mapPresenter;
    mapPresenter.getEventBus().addHandler(MapInitializationHandler.TYPE, new RedrawMapInitializationHandler());

    layout = new ResizeLayoutPanel();
    layout.setSize("100%", "100%");
    layout.add(mapPresenter.asWidget());

    // Add an automatic resize handler to set the correct size when the window resizes:
    Window.addResizeHandler(new ResizeHandler() {

        public void onResize(ResizeEvent event) {
            applySize();
        }
    });

    // Calculate the correct size on load:
    layout.addAttachHandler(new AttachEvent.Handler() {

        public void onAttachOrDetach(AttachEvent event) {
            Timer timer = new Timer() {

                @Override
                public void run() {
                    if (!applySize()) {
                        schedule(50);
                    }
                }
            };
            timer.run();
        }
    });
}

From source file:thothbot.parallax.site.client.Site.java

License:Open Source License

@Override
public void onSceneLoading(SceneLoadingEvent event) {
    if (event.isLoaded()) {
        infoText.setText("Your browser supports WebGL!");
        Window.addResizeHandler(this);
    } else {// www . j a v  a 2 s .  com
        infoText.setText("Loading scene...");
    }
}

From source file:tv.dyndns.kishibe.qmaclone.client.creation.DialogBoxPolygonCreation.java

License:Open Source License

protected void onLoad() {
    super.onLoad();
    Window.addResizeHandler(resizeHandler);
}

From source file:tv.dyndns.kishibe.qmaclone.client.creation.DialogBoxPolygonCreation.java

License:Open Source License

protected void onUnload() {
    Window.addResizeHandler(resizeHandler);
    super.onUnload();
}

From source file:uk.ac.ncl.openlab.intake24.client.survey.NavigationPanel.java

License:Apache License

public NavigationPanel(Survey initialState) {
    mealsPanel = new FlowPanel();
    mealsPanel.getElement().setId("intake24-meals-panel");
    initWidget(mealsPanel);//from  w  w  w. j a  v  a 2s . c  o  m

    Window.addResizeHandler(new ResizeHandler() {
        public void onResize(ResizeEvent resizeEvent) {
            onWindowResize();
        }
    });

    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        public void execute() {
            onWindowResize();
        }
    });

    stateChanged(initialState);
}