Example usage for com.google.gwt.user.client.ui LayoutPanel setWidgetTopHeight

List of usage examples for com.google.gwt.user.client.ui LayoutPanel setWidgetTopHeight

Introduction

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

Prototype

public void setWidgetTopHeight(IsWidget child, double top, Unit topUnit, double height, Unit heightUnit) 

Source Link

Document

Overloaded version for IsWidget.

Usage

From source file:at.ac.fhcampuswien.atom.client.gui.frames.TabLayoutPanelCopy.java

License:Apache License

/**
 * Creates an empty tab panel./*from w  w w . j  a v  a2s.  c  om*/
 *
 * @param barHeight the size of the tab bar
 * @param barUnit the unit in which the tab bar size is specified
 */
public TabLayoutPanelCopy(double barHeight, Unit barUnit) {
    LayoutPanel panel = new LayoutPanel();
    initWidget(panel);

    // Add the tab bar to the panel.
    panel.add(tabBar);
    panel.setWidgetLeftRight(tabBar, 0, Unit.PX, 0, Unit.PX);
    panel.setWidgetTopHeight(tabBar, 0, Unit.PX, barHeight, barUnit);
    panel.setWidgetVerticalPosition(tabBar, Alignment.END);

    // Add the deck panel to the panel.
    // CHANGE4: styles again: deckPanel.addStyleName(CONTENT_CONTAINER_STYLE);
    panel.add(deckPanel);
    panel.setWidgetLeftRight(deckPanel, 0, Unit.PX, 0, Unit.PX);
    panel.setWidgetTopBottom(deckPanel, barHeight, barUnit, 0, Unit.PX);

    // Make the tab bar extremely wide so that tabs themselves never wrap.
    // (Its layout container is overflow:hidden)

    // CHANGE5: Adapt the TabBar Style element to our needs
    Style tabBarStyle = tabBar.getElement().getStyle();
    tabBarStyle.setHeight(barHeight, barUnit);
    tabBarStyle.setWidth(BIG_ENOUGH_TO_NOT_WRAP, Unit.PX);

    // CHANGE6: We don't want the standard GWT styles
    // tabBar.setStyleName("gwt-TabLayoutPanelTabs");
    // setStyleName("gwt-TabLayoutPanel");
}

From source file:cc.kune.initials.AvatarComposite.java

License:GNU Affero Public License

public AvatarComposite(final Builder builder, final int[][] sizes, final int[] fontSizes,
        final List<IsWidget> widgets) {
    final LayoutPanel panel = new LayoutPanel();
    final int fullSize = builder.getSize();
    panel.setSize(fullSize + "px", fullSize + "px");
    for (int i = 0; i < widgets.size(); i++) {
        final int top = sizes[i][0];
        final int height = sizes[i][1];
        final int left = sizes[i][2];
        final int width = sizes[i][3];
        final int finalWidth = width - left;
        final int finalHeight = height - top;
        final IsWidget widget = widgets.get(i);
        IsWidget wrap = widget;/*from w  w  w. j  ava 2  s  . c  om*/
        if (widget instanceof InitialLabel) {
            ((InitialLabel) widget).setStyle(height, fontSizes[i]);
        } else if (widget instanceof Image) {
            // If is an image, we crop/resize in the center of the image
            wrap = ImagesHelper.cropResize((Image) widget, fullSize, finalWidth, finalHeight);
        }
        panel.add(wrap);
        panel.setWidgetTopHeight(wrap, top, PX, height, PX);
        panel.setWidgetLeftWidth(wrap, left, PX, width, PX);
    }
    initWidget(panel);
}

From source file:com.moesol.gwt.maps.client.Driver.java

License:Open Source License

private void doMapPanel(RootPanel mapPanel) {
    mapPanel.setHeight("100%");
    mapPanel.setWidth("100%");

    DOM.setInnerHTML(mapPanel.getElement(), "");

    final DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.PX);
    dockPanel.setHeight("420px");
    dockPanel.setWidth("600px");
    mapPanel.add(dockPanel);//from   w  w w .  java 2  s  .co m

    // loadLayerConfigsFromServer();
    loadLayerConfigsFromClient();

    //VerticalPanel vp = new VerticalPanel();
    MapPanel mapFillPanel = new MapPanel(m_map);
    m_map.setDpi(m_scrnDpi);
    m_map.getController().withHoverDelayMillis(MAP_HOVER_DELAY_MILLIS);

    //new EdgeHoverPanControl(m_map, MAP_EDGE_HOVER_RADIUS_PIXELS,
    //      MAP_EDGE_HOVER_PAN_INTERVAL,
    //      MAP_EDGE_HOVER_MAX_PAN_PER_INTERVAL_PIXELS);
    //      m_map.getController().addHoverHandler(new HoverHandler() {
    //         BubbleControl bc = new BubbleControl(m_map);
    //         
    //         @Override
    //         public void onHover(HoverEvent e) {
    //            ViewCoords m_vc = new ViewCoords(e.getX(), e.getY());
    //            GeodeticCoords gc = m_map.getProjection().viewToGeodetic(m_vc);
    //            bc.getHtml().setHTML("Hover: " + gc.toString());
    //            bc.animateShow(e.getClientX(), e.getClientY());
    //         }
    //      });

    if (isTrue("showSomeIcons", false)) {
        addSomeIcons();
    }

    m_map.updateView();

    //      Button left = new Button("Left", new ClickHandler() {
    //         @Override
    //         public void onClick(ClickEvent event) {
    //            goLeft();
    //         }
    //      });
    //      Button right = new Button("Right", new ClickHandler() {
    //         @Override
    //         public void onClick(ClickEvent event) {
    //            goRight();
    //         }});
    //      Button up = new Button("Up", new ClickHandler() {
    //         @Override
    //         public void onClick(ClickEvent event) {
    //            goUp();
    //         }});
    //      Button down = new Button("Down", new ClickHandler() {
    //         @Override
    //         public void onClick(ClickEvent event) {
    //            goDown();
    //         }});
    //      
    //      Button in = new Button("In", new ClickHandler() {
    //         @Override
    //         public void onClick(ClickEvent event) {
    //            goIn();
    //         }});
    //      Button out = new Button("Out", new ClickHandler() {
    //         @Override
    //         public void onClick(ClickEvent event) {
    //            goOut();
    //         }});
    Button removeIcons = new Button("Remove Icons", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            removeIcons();
        }
    });
    Button moveIcons = new Button("Move Icons", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            moveIcons();
        }
    });
    Button resizeMap = new Button("Fill Viewport", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dockPanel.setHeight("100%");
            dockPanel.setWidth("100%");
        }
    });
    MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
    oracle.add("0");
    oracle.add("01");
    oracle.add("1");
    oracle.add("3");
    m_levelBox = new SuggestBox();

    m_map.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            mapChanged();
        }
    });

    HorizontalPanel bar = new HorizontalPanel();
    //      bar.add(left);
    //      bar.add(right);
    //      bar.add(up);
    //      bar.add(down);
    //      bar.add(in);
    //      bar.add(out);
    bar.add(removeIcons);
    bar.add(moveIcons);
    bar.add(resizeMap);
    //      bar.add(m_centerLabel);
    dockPanel.addNorth(bar, 20);

    //bar.add(m_levelBox);
    //      if (false) {
    //         // Show debug grid
    //         bar.add(m_tiles);
    //      }
    //vp.add(bar);

    LayoutPanel hp = new LayoutPanel();
    dockPanel.add(hp);
    //hp.setHeight("500px");
    //hp.setWidth("500px");
    //vp.add(hp);

    if (isTrue("showLayerPanel", false)) {
        addTileMapServiceView(hp);
        //         eventBus.addHandler(TileMapAddEvent.TYPE, new TileMapAddEvent.Handler() {
        //            @Override
        //            public void onTileMapAdd(TileMapAddEvent event) {
        //               LayerSet layerSet = new LayerSet();
        //               TileMapMetadata tileMapMetadata = event.getTileMapMetadata();
        //               layerSet.setServer(tileMapMetadata.getUrl());
        //               layerSet.setData("");
        //               layerSet.setUrlPattern("{server}/{level}/{x}/{y}." + tileMapMetadata.getTileImageFormat());
        //               m_map.addLayer(layerSet);
        //            }
        //         });
    }

    // The map viewport
    hp.add(mapFillPanel);
    //hp.setWidgetLeftWidth(mapFillPanel,0, Style.Unit.PCT, 100, Style.Unit.PCT);
    // The map controls
    MapPanZoomControl mapControls = new MapPanZoomControl(m_map, 15, 100);
    mapControls.getElement().getStyle().setZIndex(100000);
    hp.add(mapControls);
    hp.setWidgetLeftWidth(mapControls, 0, Style.Unit.PX, 56, Style.Unit.PX);
    hp.setWidgetTopHeight(mapControls, 0, Style.Unit.PX, 121, Style.Unit.PX);
    //The mouse position label;
    PositionControl mousePosLabel = new PositionControl(m_map);
    hp.add(mousePosLabel);
    hp.setWidgetRightWidth(mousePosLabel, 10, Style.Unit.PX, 500, Style.Unit.PX);
    hp.setWidgetTopHeight(mousePosLabel, 10, Style.Unit.PX, 20, Style.Unit.PX);

    // Map dimmer control
    MapDimmerControl dimmer = new MapDimmerControl(m_map, true);
    hp.add(dimmer);
    hp.setWidgetRightWidth(dimmer, 10, Style.Unit.PX, 35, Style.Unit.PX);
    hp.setWidgetBottomHeight(dimmer, 10, Style.Unit.PX, 22, Style.Unit.PX);

    SearchControl flyToControl = new SearchControl();
    hp.add(flyToControl);
    hp.setWidgetRightWidth(flyToControl, 0, Style.Unit.PX, 160, Style.Unit.PX);
    hp.setWidgetTopHeight(flyToControl, 0, Style.Unit.PX, 50, Style.Unit.PX);

    flyToControl.addSearchHandler(new FlyToController(m_map));

    // Layer a transparent dialog...
    if (isTrue("showTestDialog", false)) {
        DialogBox db = new DialogBox();
        db.setHTML("<a href='' onclick='false'>x</a>");
        db.setPopupPosition(100, 10);
        db.setPixelSize(100, 100);
        db.show();
    }
}

From source file:com.moesol.gwt.milmap.client.Driver.java

License:Open Source License

private void doMap(RootPanel mapPanel) {
    //doMap(mapPanel);

    mapPanel.setHeight("100%");
    mapPanel.setWidth("100%");

    DOM.setInnerHTML(mapPanel.getElement(), "");

    final DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.PX);
    dockPanel.setHeight("100%");
    dockPanel.setWidth("100%");
    //dockPanel.setHeight("420px");
    //dockPanel.setWidth("600px");
    mapPanel.add(dockPanel);//from w  w w  .j av a2  s  . c om

    // loadLayerConfigsFromServer();
    m_map = new MapView();
    loadLayerConfigsFromClient();

    MapPanel mapFillPanel = new MapPanel(m_map);
    m_map.setDpi(m_scrnDpi);
    m_map.getController().withHoverDelayMillis(MAP_HOVER_DELAY_MILLIS);
    m_map.setDeclutterLabels(true);
    //new EdgeHoverPanControl(m_map, MAP_EDGE_HOVER_RADIUS_PIXELS,
    //      MAP_EDGE_HOVER_PAN_INTERVAL,
    //      MAP_EDGE_HOVER_MAX_PAN_PER_INTERVAL_PIXELS);
    //      m_map.getController().addHoverHandler(new HoverHandler() {
    //         BubbleControl bc = new BubbleControl(m_map);
    //         
    //         @Override
    //         public void onHover(HoverEvent e) {
    //            ViewCoords m_vc = new ViewCoords(e.getX(), e.getY());
    //            GeodeticCoords gc = m_map.getProjection().viewToGeodetic(m_vc);
    //            bc.getHtml().setHTML("Hover: " + gc.toString());
    //            bc.animateShow(e.getClientX(), e.getClientY());
    //         }
    //      });
    if (isTrue("showSomeIcons", false)) {
        addSomeIcons();
    }

    m_map.updateView();

    //Button removeIcons = new Button("Remove Icons", new ClickHandler() {
    //   @Override
    //   public void onClick(ClickEvent event) {
    //      removeIcons();
    //   }});
    //Button moveIcons = new Button("Move Icons", new ClickHandler() {
    //   @Override
    //   public void onClick(ClickEvent event) {
    //      moveIcons();
    //   }});
    //Button showLeaders = new Button("Show Leaders", new ClickHandler() {
    //   @Override
    //   public void onClick(ClickEvent event) {
    //      showLeaders();
    //   }
    //});
    //Button benchmarks = new Button("Benchmarks", new ClickHandler() {
    //   @Override
    //   public void onClick(ClickEvent event) {
    //      runBenchmarks();
    //   }});
    //Button stats = new Button("Stats", new ClickHandler() {
    //   @Override
    //   public void onClick(ClickEvent event) {
    //      stats();
    //   }});
    //Button memoryTest = new Button("Memory Test", new ClickHandler() {
    //   @Override
    //   public void onClick(ClickEvent event) {
    //      memoryTest();
    //   }});

    //Button declutter = new Button("Declutter", new ClickHandler() {
    //   @Override
    //   public void onClick(ClickEvent event) {
    //      declutterTest();
    //   }});
    MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
    oracle.add("0");
    oracle.add("01");
    oracle.add("1");
    oracle.add("3");
    m_levelBox = new SuggestBox();

    m_map.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            mapChanged();
        }
    });

    // removing button bar for demo purposes
    //HorizontalPanel bar = new HorizontalPanel();
    //      bar.add(removeIcons);
    //      bar.add(moveIcons);
    //      bar.add(showLeaders);
    //      bar.add(declutter);
    //      bar.add(benchmarks);
    //      bar.add(stats);
    //      bar.add(memoryTest);

    //      dockPanel.addNorth(bar, 20);

    LayoutPanel lp = new LayoutPanel();
    dockPanel.add(lp);

    if (isTrue("showLayerPanel", false)) {
        addTileMapServiceView(lp);
    }

    // The map viewport
    lp.add(mapFillPanel);
    //count = hp.getWidgetCount();
    //hp.setWidgetLeftWidth(mapFillPanel,0, Style.Unit.PCT, 100, Style.Unit.PCT);
    // The map controls
    MapPanZoomControl mapControls = new MapPanZoomControl(m_map, 15, 10);
    mapControls.getElement().getStyle().setZIndex(100000);
    lp.add(mapControls);
    lp.setWidgetLeftWidth(mapControls, 0, Style.Unit.PX, 56, Style.Unit.PX);
    lp.setWidgetTopHeight(mapControls, 0, Style.Unit.PX, 121, Style.Unit.PX);

    //The mouse position label;
    PositionControl mousePosLabel = new PositionControl(m_map);
    lp.add(mousePosLabel);
    lp.setWidgetRightWidth(mousePosLabel, 10, Style.Unit.PX, 500, Style.Unit.PX);
    lp.setWidgetTopHeight(mousePosLabel, 10, Style.Unit.PX, 20, Style.Unit.PX);

    //The Text control;
    m_textControl = new TextControl();
    lp.add(m_textControl);
    lp.setWidgetLeftWidth(m_textControl, 10, Style.Unit.PX, 500, Style.Unit.PX);
    lp.setWidgetBottomHeight(m_textControl, 10, Style.Unit.PX, 20, Style.Unit.PX);

    // Map dimmer control
    MapDimmerControl dimmer = new MapDimmerControl(m_map, true);
    lp.add(dimmer);
    lp.setWidgetRightWidth(dimmer, 10, Style.Unit.PX, 60, Style.Unit.PX);
    lp.setWidgetBottomHeight(dimmer, 10, Style.Unit.PX, 34, Style.Unit.PX);

    // Map tag control
    TagControl tag = new TagControl(m_map, true);
    lp.add(tag);
    lp.setWidgetRightWidth(tag, 10, Style.Unit.PX, 35, Style.Unit.PX);
    lp.setWidgetBottomHeight(tag, 60, Style.Unit.PX, 22, Style.Unit.PX);

    SearchControl flyToControl = new SearchControl();
    lp.add(flyToControl);
    lp.setWidgetRightWidth(flyToControl, 10, Style.Unit.PX, 160, Style.Unit.PX);
    lp.setWidgetTopHeight(flyToControl, 10, Style.Unit.PX, 50, Style.Unit.PX);

    flyToControl.addSearchHandler(new FlyToController(m_map));

    // Layer a transparent dialog...
    if (isTrue("showTestDialog", false)) {
        DialogBox db = new DialogBox();
        db.setHTML("<a href='' onclick='false'>x</a>");
        db.setPopupPosition(100, 10);
        db.setPixelSize(100, 100);
        db.show();
    }

}

From source file:com.moesol.mapsample.client.MapSample.java

License:Open Source License

private void doMap(RootPanel mapPanel) {
    //doMap(mapPanel);

    mapPanel.setHeight("100%");
    mapPanel.setWidth("100%");

    DOM.setInnerHTML(mapPanel.getElement(), "");

    final DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.PX);
    dockPanel.setHeight("100%");
    dockPanel.setWidth("100%");
    mapPanel.add(dockPanel);//from   w  w w .j  a v a  2s  .  co m

    // loadLayerConfigsFromServer();
    m_map = new MapView();
    loadLayerConfigsFromClient();

    MapPanel mapFillPanel = new MapPanel(m_map);
    m_map.setDpi(m_scrnDpi);
    m_map.getController().withHoverDelayMillis(MAP_HOVER_DELAY_MILLIS);
    m_map.setDeclutterLabels(true);

    if (isTrue("showSomeIcons", false)) {
        addSomeIcons();
    }

    m_map.updateView();
    MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
    oracle.add("0");
    oracle.add("01");
    oracle.add("1");
    oracle.add("3");
    m_levelBox = new SuggestBox();

    m_map.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            mapChanged();
        }
    });

    LayoutPanel lp = new LayoutPanel();
    dockPanel.add(lp);

    // The map viewport
    lp.add(mapFillPanel);
    //count = hp.getWidgetCount();
    //hp.setWidgetLeftWidth(mapFillPanel,0, Style.Unit.PCT, 100, Style.Unit.PCT);
    // The map controls
    MapPanZoomControl mapControls = new MapPanZoomControl(m_map, 15, 10);
    mapControls.getElement().getStyle().setZIndex(100000);
    lp.add(mapControls);
    lp.setWidgetLeftWidth(mapControls, 0, Style.Unit.PX, 56, Style.Unit.PX);
    lp.setWidgetTopHeight(mapControls, 0, Style.Unit.PX, 121, Style.Unit.PX);

    //The mouse position label;
    PositionControl mousePosLabel = new PositionControl(m_map);
    lp.add(mousePosLabel);
    lp.setWidgetRightWidth(mousePosLabel, 10, Style.Unit.PX, 500, Style.Unit.PX);
    lp.setWidgetTopHeight(mousePosLabel, 10, Style.Unit.PX, 20, Style.Unit.PX);

    //The Text control;
    m_textControl = new TextControl();
    lp.add(m_textControl);
    lp.setWidgetLeftWidth(m_textControl, 10, Style.Unit.PX, 500, Style.Unit.PX);
    lp.setWidgetBottomHeight(m_textControl, 10, Style.Unit.PX, 20, Style.Unit.PX);

    // Map dimmer control
    MapDimmerControl dimmer = new MapDimmerControl(m_map, true);
    lp.add(dimmer);
    lp.setWidgetRightWidth(dimmer, 10, Style.Unit.PX, 60, Style.Unit.PX);
    lp.setWidgetBottomHeight(dimmer, 10, Style.Unit.PX, 34, Style.Unit.PX);

    // Map tag control
    TagControl tag = new TagControl(m_map, true);
    lp.add(tag);
    lp.setWidgetRightWidth(tag, 10, Style.Unit.PX, 35, Style.Unit.PX);
    lp.setWidgetBottomHeight(tag, 60, Style.Unit.PX, 22, Style.Unit.PX);

    SearchControl flyToControl = new SearchControl();
    lp.add(flyToControl);
    lp.setWidgetRightWidth(flyToControl, 10, Style.Unit.PX, 160, Style.Unit.PX);
    lp.setWidgetTopHeight(flyToControl, 10, Style.Unit.PX, 50, Style.Unit.PX);

    flyToControl.addSearchHandler(new FlyToController(m_map));

    // Layer a transparent dialog...
    if (isTrue("showTestDialog", false)) {
        DialogBox db = new DialogBox();
        db.setHTML("<a href='' onclick='false'>x</a>");
        db.setPopupPosition(100, 10);
        db.setPixelSize(100, 100);
        db.show();
    }

}

From source file:com.puzzlebazar.client.ui.AspectRatioLayoutPanel.java

License:Apache License

@Override
public void onResize() {
    LayoutPanel parent = (LayoutPanel) getParent();

    // Compute width and height available for inside area
    int parentWidth = parent.getOffsetWidth();
    int parentHeight = parent.getOffsetHeight();
    int availableWidth = parentWidth - 2 * border;
    int availableHeight = parentHeight - 2 * border;

    if (availableWidth > 0 && availableHeight > 0) {
        float parentRatio = (float) availableWidth / (float) availableHeight;
        if (parentRatio < aspectRatio) {
            // availableWidth/availableHeight < desiredWidth/desiredHeight
            // Set desiredWidth = availableWidth  ==>  availableHeight > desiredHeight (good!)
            // Then desiredHeight = availableWidth / aspectRatio
            int desiredHeight = (int) (availableWidth / aspectRatio);
            parent.setWidgetLeftRight(this, 0, Unit.PX, 0, Unit.PX);
            parent.setWidgetTopHeight(this, (parentHeight - desiredHeight) / 2 - border, Unit.PX,
                    desiredHeight + 2 * border, Unit.PX);
        } else {//from  w  w w  .  jav a 2  s  .c o m
            // availableWidth/availableHeight > desiredWidth/desiredHeight
            // Set desiredHeight = availableHeight  ==>  availableWidth > desiredWidth (good!)
            // Then desiredWidth = availableHeight * aspectRatio
            int desiredWidth = (int) (availableHeight * aspectRatio);
            parent.setWidgetTopBottom(this, 0, Unit.PX, 0, Unit.PX);
            parent.setWidgetLeftWidth(this, (parentWidth - desiredWidth) / 2 - border, Unit.PX,
                    desiredWidth + 2 * border, Unit.PX);
        }
    } else {
        // Not enough room for inside area, border takes up everything.
        if (parentWidth < parentHeight) {
            // parentWidth is smaller, allocate parentWidth x parentWidth
            parent.setWidgetLeftRight(this, 0, Unit.PX, 0, Unit.PX);
            parent.setWidgetTopHeight(this, (parentHeight - parentWidth) / 2, Unit.PX, parentWidth, Unit.PX);
        } else {
            // parentHeight is smaller, allocate parentHeight x parentHeight
            parent.setWidgetTopBottom(this, 0, Unit.PX, 0, Unit.PX);
            parent.setWidgetLeftWidth(this, (parentWidth - parentHeight) / 2, Unit.PX, parentHeight, Unit.PX);
        }
    }
    super.onResize();
}

From source file:edu.ycp.cs.netcoder.client.DevelopmentView.java

License:Open Source License

public DevelopmentView(Session session) {
    super(session);

    addSessionObject(new ChangeList());
    addSessionObject(new AffectEvent());

    // Observe ChangeList state.
    // We do this so that we know when the local editor contents are
    // up to date with the text on the server.
    session.get(ChangeList.class).subscribe(ChangeList.State.CLEAN, this, getSubscriptionRegistrar());

    // User won't be allowed to edit until the problem (and previous editor contents, if any)
    // are loaded.
    mode = Mode.LOADING;/*from w  w w.  j  a  v  a  2  s . c  om*/
    textLoaded = false;

    // The overall UI is build in a LayoutPanel (which the parent class creates)
    LayoutPanel layoutPanel = getLayoutPanel();

    // Add problem description widget
    problemDescription = new ProblemDescriptionWidget(session, getSubscriptionRegistrar());
    layoutPanel.add(problemDescription);
    layoutPanel.setWidgetTopHeight(problemDescription, LayoutConstants.TOP_BAR_HEIGHT_PX, Unit.PX,
            LayoutConstants.DEV_PROBLEM_DESC_HEIGHT_PX, Unit.PX);

    // Add AceEditor widget
    editor = new AceEditor();
    editor.setStyleName("NetCoderEditor");
    layoutPanel.add(editor);
    layoutPanel.setWidgetTopHeight(editor,
            LayoutConstants.TOP_BAR_HEIGHT_PX + LayoutConstants.DEV_PROBLEM_DESC_HEIGHT_PX, Unit.PX, 200,
            Unit.PX);

    // Add the status and button bar widget
    StatusAndButtonBarWidget statusAndButtonBarWidget = new StatusAndButtonBarWidget(getSession(),
            getSubscriptionRegistrar());
    statusAndButtonBarWidget.addToLeftPanel(new StatusMessageWidget(getSession(), getSubscriptionRegistrar()));
    statusAndButtonBarWidget.addToRightPanel(
            new EditorStatusWidget(getSession().get(ChangeList.class), getSubscriptionRegistrar()));
    Button submitButton = new Button("Submit");
    submitButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            submitCode();
        }
    });
    statusAndButtonBarWidget.addToRightPanel(submitButton);

    layoutPanel.add(statusAndButtonBarWidget);
    layoutPanel.setWidgetBottomHeight(statusAndButtonBarWidget, LayoutConstants.DEV_RESULTS_PANEL_HEIGHT_PX,
            Unit.PX, LayoutConstants.DEV_STATUS_AND_BUTTON_BAR_HEIGHT_PX, Unit.PX);

    // Tab panel for test results and other information
    resultsTabPanel = new TabLayoutPanel(LayoutConstants.DEV_RESULTS_TAB_BAR_HEIGHT_PX, Unit.PX);

    // Test results widget
    resultWidget = new ResultWidget(getSession(), getSubscriptionRegistrar());
    resultWidget.setWidth("100%");
    resultWidget.setHeight("100%");
    resultsTabPanel.add(resultWidget, "Test results");

    layoutPanel.add(resultsTabPanel);
    layoutPanel.setWidgetBottomHeight(resultsTabPanel, 0, Unit.PX, LayoutConstants.DEV_RESULTS_PANEL_HEIGHT_PX,
            Unit.PX);

    // UI is now complete
    initWidget(layoutPanel);

    // Subscribe to window ResizeEvents
    getSession().get(WindowResizeNotifier.class).subscribe(WindowResizeNotifier.WINDOW_RESIZED, this,
            getSubscriptionRegistrar());

    // Initiate loading of the problem and current editor text.
    loadProblemAndCurrentText();

    // Create timer to flush unsent change events periodically.
    this.flushPendingChangeEventsTimer = new Timer() {
        @Override
        public void run() {
            final ChangeList changeList = getSession().get(ChangeList.class);

            if (changeList == null) {
                // paranoia
                return;
            }

            if (changeList.getState() == ChangeList.State.UNSENT) {
                Change[] changeBatch = changeList.beginTransmit();

                AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        changeList.endTransmit(false);
                        GWT.log("Failed to send change batch to server");

                        getSession().add(new StatusMessage(StatusMessage.Category.ERROR,
                                "Could not save code to server!"));
                    }

                    @Override
                    public void onSuccess(Boolean result) {
                        changeList.endTransmit(true);
                    }
                };

                logCodeChangeService.logChange(changeBatch, callback);
            }
        }
    };
    flushPendingChangeEventsTimer.scheduleRepeating(FLUSH_CHANGES_INTERVAL_MS);
}

From source file:edu.ycp.cs.netcoder.client.LoginView.java

License:Open Source License

public LoginView(Session session) {
    super(session);

    LayoutPanel loginViewPanel = getLayoutPanel();

    FlowPanel panel = new FlowPanel();
    panel.add(new Label("Username:"));
    userNameTextBox = new TextBox();
    userNameTextBox.setWidth("20em");
    panel.add(userNameTextBox);/*from   w  ww  .j a  v  a2 s .c  o m*/
    panel.add(new Label("Password:"));
    passwordTextBox = new PasswordTextBox();
    passwordTextBox.setWidth("20em");
    panel.add(passwordTextBox);

    userNameTextBox.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                passwordTextBox.setFocus(true);
            }
        }
    });
    passwordTextBox.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                attemptLogin();
            }
        }
    });

    FlowPanel panel2 = new FlowPanel();
    Button loginButton = new Button("Log in");

    loginButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            attemptLogin();
        }
    });

    panel2.add(loginButton);
    FlowPanel loginBox = new FlowPanel();
    loginBox.setStyleName("NetCoderRoundBox");
    loginBox.add(panel);
    loginBox.add(panel2);

    loginStatusLabel = new Label("");
    loginStatusLabel.setStyleName("NetCoderLoginStatus");
    loginBox.add(loginStatusLabel);

    loginViewPanel.add(loginBox);
    loginViewPanel.setWidgetRightWidth(loginBox, 2, Unit.EM, 23, Unit.EM);
    loginViewPanel.setWidgetTopHeight(loginBox, LayoutConstants.TOP_BAR_HEIGHT_PX + 10, Unit.PX, 13, Unit.EM);

    initWidget(loginViewPanel);
}

From source file:es.upm.fi.dia.oeg.map4rdf.client.widget.Header.java

License:Open Source License

private Widget createUi(BrowserResources resources) {
    LayoutPanel panel = new LayoutPanel();
    logo = new Image(GWT.getHostPageBaseURL() + "logo.png");
    Image betaBadge = new Image(resources.betaBadge());

    // Add the logo to the root panel
    RootPanel.get().add(logo);/*  w w w  . j  a v  a2  s.c om*/
    RootPanel.get().setWidgetPosition(logo, 4, 0);
    logo.getElement().getStyle().setZIndex(3);

    panel.add(betaBadge);
    panel.setWidgetRightWidth(betaBadge, 2, Unit.EM, 48, Unit.PX);
    panel.setWidgetTopHeight(betaBadge, 2, Unit.EM, 48, Unit.PX);

    return panel;
}

From source file:hu.mapro.gwt.client.widget.MyTabLayoutPanel.java

License:Apache License

/**
 * Creates an empty tab panel.//w  ww .j a  v  a2 s . c o m
 * 
 * @param barHeight the size of the tab bar
 * @param barUnit the unit in which the tab bar size is specified
 * @param resource the ClientBundle to use for some internal images.
 */
public MyTabLayoutPanel(double barHeight, Unit barUnit, Resources resource) {
    LayoutPanel panel = new LayoutPanel();
    initWidget(panel);

    // Add the tab bar to the panel.
    Panel navPanel = getTabNavPanel();
    navPanel.add(tabBarAnimator);
    tabBarAnimator.add(tabBar);
    navPanel.add(previousButtonPanel);
    navPanel.add(nextButtonPanel);
    navPanel.getElement().getStyle().setHeight(barHeight, barUnit);
    setTabAnimiationDuration(0);

    panel.add(navPanel);

    panel.setWidgetLeftRight(navPanel, 0, Unit.PX, 0, Unit.PX);
    panel.setWidgetTopHeight(navPanel, 0, Unit.PX, barHeight, barUnit);
    panel.setWidgetVerticalPosition(navPanel, Alignment.END);

    // Add the deck panel to the panel.
    deckPanel.addStyleName(CONTENT_CONTAINER_STYLE);
    panel.add(deckPanel);
    panel.setWidgetLeftRight(deckPanel, 0, Unit.PX, 0, Unit.PX);
    panel.setWidgetTopBottom(deckPanel, barHeight, barUnit, 0, Unit.PX);

    // Make the tab bar extremely wide so that tabs themselves never wrap.
    // (Its layout container is overflow:hidden)
    tabBar.getElement().getStyle().setWidth(BIG_ENOUGH_TO_NOT_WRAP, Unit.PX);

    tabBar.setStyleName("gwt-TabLayoutPanelTabs");
    setStyleName("gwt-TabLayoutPanel");
    setTabNavOffset(0);

    previous = new Image(resource.previousTab());
    previous.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            selectPreviousTab();
        }
    });

    next = new Image(resource.nextTab());
    next.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            selectNextTab();
        }
    });
    next.getElement().getStyle().setCursor(Cursor.POINTER);
    previous.getElement().getStyle().setCursor(Cursor.POINTER);

    previousDisabled = new Image(resource.previousTabDisabled());
    nextDisabled = new Image(resource.nextTabDisabled());

    previousButtonPanel.add(previous);
    nextButtonPanel.add(next);
    setNavButtonsVisible(false);
}