Example usage for com.google.gwt.user.client.ui FocusPanel FocusPanel

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

Introduction

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

Prototype

public FocusPanel(Widget child) 

Source Link

Usage

From source file:asquare.gwt.tests.focus.client.Demo.java

License:Apache License

private Widget createFocusPanel() {
    Table outer = new Table();

    outer.add(new FocusPanel(new Label("Label in a FocusPanel")));
    outer.add(new Button("Button"));
    outer.add(new CheckBox("CheckBox"));
    outer.add(new TextBox());
    outer.add(new PasswordTextBox());
    outer.add(new TextArea());
    outer.add(new RadioButton("group1", "RadioButton1"));
    outer.add(new RadioButton("group1", "RadioButton2"));
    ListBox listBox1 = new ListBox();
    listBox1.addItem("ListBox1");
    listBox1.addItem("item2");
    listBox1.addItem("item3");
    outer.add(listBox1);//from  ww  w.j  a  v  a  2s  . co  m
    ListBox listBox2 = new ListBox(true);
    listBox2.setVisibleItemCount(3);
    listBox2.addItem("ListBox2");
    listBox2.addItem("item2");
    listBox2.addItem("item3");
    outer.add(listBox2);
    Tree tree = new Tree();
    tree.addItem("Tree");
    tree.addItem("item2");
    tree.addItem("item3");
    outer.add(tree);

    return outer;
}

From source file:asquare.gwt.tests.focusevent.client.Demo.java

License:Apache License

private Widget createDemoPanel() {
    TestPanel outer = new TestPanel();

    outer.add(new Label("GWT onfocus Event Handler"));
    outer.add(new Button("Button"), "Button");
    outer.add(new CheckBox("CheckBox"), "CheckBox");
    outer.add(new RadioButton("group1", "RadioButton1"), "RadioButton1");
    TextBox textBox = new TextBox();
    textBox.setText("TextBox");
    outer.add(textBox, "TextBox");
    PasswordTextBox passwordTextBox = new PasswordTextBox();
    passwordTextBox.setText("PasswordTextBox");
    outer.add(passwordTextBox, "PasswordTextBox");
    TextArea textArea = new TextArea();
    textArea.setText("TextArea");
    outer.add(textArea, "TextArea");
    ListBox listBox = new ListBox();
    listBox.addItem("ListBox");
    listBox.addItem("item2");
    listBox.addItem("item3");
    outer.add(listBox, "ListBox");
    outer.add(new FocusPanel(new Label("Label in a FocusPanel")), "FocusPanel");
    Tree tree = new Tree();
    tree.addItem("item1");
    tree.addItem("item2");
    tree.addItem("item3");
    outer.add(tree, "Tree");

    return outer;
}

From source file:asquare.gwt.tkdemo.client.demos.FocusCycleDemo.java

License:Apache License

private Widget createFocusCycle1() {
    FocusCyclePanel cycle1 = new FocusCyclePanel("div", "block");

    cycle1.add(new Label("Cycle 1"));

    cycle1.add(new FocusStyleDecorator(new Button("Button")));

    Button buttonDisabled = new Button("disabled");
    buttonDisabled.setEnabled(false);//from  w  ww  .  j a  v a 2  s  . com
    cycle1.add(new FocusStyleDecorator(buttonDisabled));

    Button buttonNegativeTabIndex = new Button("tabIndex = -1");
    buttonNegativeTabIndex.setTabIndex(-1);
    cycle1.add(new FocusStyleDecorator(buttonNegativeTabIndex));

    cycle1.add(new FocusStyleDecorator(new CheckBox("CheckBox")));

    cycle1.add(new FocusStyleDecorator(new FocusPanel(new Label("FocusPanel"))));

    ListBox listBox = new ListBox();
    listBox.addItem("ListBox");
    listBox.addItem("Item 1");
    listBox.addItem("Item 2");
    listBox.addItem("Item 3");
    cycle1.add(new FocusStyleDecorator(listBox));

    TextBox textBox = new TextBox();
    textBox.setText("TextBox");
    cycle1.add(new FocusStyleDecorator(textBox));

    PasswordTextBox pwBox = new PasswordTextBox();
    pwBox.setText("PasswordTextBox");
    cycle1.add(new FocusStyleDecorator(pwBox));

    TextArea textArea = new TextArea();
    textArea.setText("TextArea");
    cycle1.add(new FocusStyleDecorator(textArea));

    Tree tree = new Tree();
    TreeItem treeRoot = new TreeItem("Tree");
    for (int branchNum = 1; branchNum < 4; branchNum++) {
        TreeItem branch = new TreeItem("Branch " + branchNum);
        for (int item = 1; item < 4; item++) {
            branch.addItem("Item " + item);
        }
        treeRoot.addItem(branch);
    }
    tree.addItem(treeRoot);
    cycle1.add(new FocusStyleDecorator(tree));

    new WidgetFocusStyleController(cycle1.getFocusModel());

    return cycle1;
}

From source file:ch.unifr.pai.twice.layout.client.eclipseLayout.MiceLayoutTabPanel.java

License:Apache License

/**
 * The constructor creates the panel and adds the necessary drop handlers.
 * //from  w  w w . j a  v a2 s  . c  o  m
 * @param barHeight
 *            - the height of the tab bar in pixels
 */
public MiceLayoutTabPanel(double barHeight) {
    super(barHeight, Unit.PX);
    RESOURCES.miceLayoutStyle().ensureInjected();
    hoverGhost.addStyleName(RESOURCES.miceLayoutStyle().hoverGhostTab());
    panel = (LayoutPanel) getWidget();
    tabBar = (FlowPanel) panel.getWidget(0);
    deckPanel = (DeckLayoutPanel) panel.getWidget(1);
    tabBarFocus = new FocusPanel(tabBar);
    panel.add(tabBarFocus);
    panel.setWidgetTopHeight(tabBarFocus, 0, Unit.PX, barHeight + 10, Unit.PX);
    panel.setWidgetTopBottom(deckPanel, barHeight + 10, Unit.PX, 0, Unit.PX);

    final FocusPanel southArea = new FocusPanel();
    panel.insert(southArea, 0);
    panel.setWidgetBottomHeight(southArea, 0, Unit.PX, 2, Unit.PX);
    DragNDrop.setDropHandler(southArea, new NewAreaDropHandler(Direction.SOUTH, southArea, this), true);

    final FocusPanel westArea = new FocusPanel();
    panel.insert(westArea, 0);
    panel.setWidgetLeftWidth(westArea, 0, Unit.PX, 2, Unit.PX);
    DragNDrop.setDropHandler(westArea, new NewAreaDropHandler(Direction.WEST, westArea, this), true);

    final FocusPanel eastArea = new FocusPanel();
    panel.insert(eastArea, 0);
    panel.setWidgetRightWidth(eastArea, 0, Unit.PX, 2, Unit.PX);
    DragNDrop.setDropHandler(eastArea, new NewAreaDropHandler(Direction.EAST, eastArea, this), true);

    final FocusPanel northArea = new FocusPanel();
    panel.insert(northArea, 0);
    panel.setWidgetTopHeight(northArea, 0, Unit.PX, 2, Unit.PX);
    DragNDrop.setDropHandler(northArea, new NewAreaDropHandler(Direction.NORTH, northArea, this), true);

    DragNDrop.setDropHandler(tabBarFocus, new DropTargetHandler() {

        /**
         * Handles the drop of a dragged {@link MiceTabLabel} hovering the tab bar
         * 
         * @see ch.unifr.pai.twice.dragndrop.client.intf.DropTargetHandler#onDrop(java.lang.String, com.google.gwt.user.client.ui.Widget,
         *      com.google.gwt.dom.client.Element, com.google.gwt.user.client.Event, java.lang.Double, java.lang.Double)
         */
        @Override
        public boolean onDrop(String deviceId, Widget widget, Element dragProxy, Event event,
                Double intersectionPercentage, Double intersectionPercentageWithTarget) {
            if (widget instanceof MiceTabLabel && !labels.contains(widget)) {
                final MiceTabLabel tab = (MiceTabLabel) widget;
                if (MiceLayoutTabPanel.this != tab.getCurrentParent()) {
                    MiceLayoutTabPanel originalParent = tab.getCurrentParent();
                    add((MiceTabLabel) widget);
                    originalParent.remove(tab);
                }
            }
            return false;
        }

        /**
         * Shows the "ghost" of the dragged {@link MiceTabLabel} when hovering the tab bar
         * 
         * @see ch.unifr.pai.twice.dragndrop.client.intf.DropTargetHandler#onHover(java.lang.String, com.google.gwt.user.client.ui.Widget,
         *      com.google.gwt.dom.client.Element, com.google.gwt.user.client.Event, java.lang.Double, java.lang.Double)
         */
        @Override
        public void onHover(String deviceId, Widget widget, Element dragProxy, Event event,
                Double intersectionPercentage, Double intersectionPercentageWithTarget) {
            if (widget instanceof MiceTabLabel && !labels.contains(widget))
                showHoverGhost(dragProxy);
        }

        /**
         * Hides the "ghost" of the dragged {@link MiceTabLabel} when leaving the area of the tab bar
         * 
         * @see ch.unifr.pai.twice.dragndrop.client.intf.DropTargetHandler#onHoverEnd(java.lang.String, com.google.gwt.user.client.ui.Widget,
         *      com.google.gwt.dom.client.Element, com.google.gwt.user.client.Event)
         */
        @Override
        public void onHoverEnd(String deviceId, Widget widget, Element dragProxy, Event event) {
            if (widget instanceof MiceTabLabel && !labels.contains(widget))
                hideHoverGhost(dragProxy);
        }

        @Override
        public Priority getPriority() {
            return Priority.NORMAL;
        }
    }, true);

    showFullscreenButton = new Image(RESOURCES.fullscreenButton());
    showFullscreenButton.setTitle("show fullscreen");
    showFullscreenButton.setStyleName(RESOURCES.miceLayoutStyle().tabPanelButton());
    showFullscreenButton.addClickHandler(new ClickHandler() {

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

    hideFullscreenButton = new Image(RESOURCES.nofullscreenButton());
    hideFullscreenButton.setTitle("hide fullscreen");
    hideFullscreenButton.setStyleName(RESOURCES.miceLayoutStyle().tabPanelButton());
    hideFullscreenButton.addClickHandler(new ClickHandler() {

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

    Widget tabPanelButtonBar = createTabButtonBar();
    panel.insert(tabPanelButtonBar, 0);
    panel.setWidgetTopHeight(tabPanelButtonBar, 7, Unit.PX, 16, Unit.PX);
    panel.setWidgetRightWidth(tabPanelButtonBar, 5, Unit.PX, 40, Unit.PX);

    addSelectionHandler(new SelectionHandler<Integer>() {

        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            for (int i = 0; i < getWidgetCount(); i++) {
                MiceTabLabel w = (MiceTabLabel) getTabWidget(i);
                if (event.getSelectedItem().equals(i)) {
                    if (!w.isSelected())
                        w.setSelected(true);
                } else {
                    if (w.isSelected())
                        w.setSelected(false);
                }
            }
        }
    });

}

From source file:com.flatown.client.FavoritesPanel.java

License:Apache License

private FavoritesPanel() {
    _favorites = new VerticalPanel();
    _favorites.setStyleName("favorites");

    _listenerPanel = new FocusPanel(_favorites);
    _listenerPanel.addMouseListener(new MouseListenerAdapter() {
        public void onMouseLeave(Widget sender) {
            _clicked = null;// w w w. jav  a 2 s .  c o m
        }

        public void onMouseUp(Widget sender, int x, int y) {
            _clicked = null;
        }
    });

    setWidget(_listenerPanel);
    setStyleName("favoritesPanel");
    DOM.setStyleAttribute(getElement(), "maxHeight", Window.getClientHeight() - 50 + "px");

    _dragListener = new MouseListenerAdapter() {
        public void onMouseEnter(Widget sender) {
            if (sender instanceof DragBar) {
                DragBar bar = (DragBar) sender;
                if (isClicked() && _clicked != bar) {
                    int newPos = _favorites.getWidgetIndex(bar.getDragWidget());
                    _favorites.remove(_clicked.getDragWidget());
                    _favorites.insert(_clicked.getDragWidget(), newPos);
                }
            }
        }

        public void onMouseDown(Widget sender, int x, int y) {
            if (sender instanceof DragBar)
                _clicked = (DragBar) sender;
        }

        public void onMouseUp(Widget sender, int x, int y) {
            if (isClicked())
                GBox.Prefs.saveFavorites();
        }
    };
}

From source file:com.fullmetalgalaxy.client.AppMain.java

License:Open Source License

/**
 * /*from ww  w .  j  a  v a 2  s  .com*/
 */
public AppMain() {
    super();
    s_instance = this;
    loadAccountInfoFromPage();

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.takeOff32()));
    hPanel.add(new Label(MAppBoard.s_messages.unconnected()));
    m_pnlChannelDisconnected = new FocusPanel(hPanel);

    // disconnect if leaving this page
    Window.addWindowClosingHandler(this);
}

From source file:com.fullmetalgalaxy.client.game.context.WgtContextAction.java

License:Open Source License

/**
 * //w  w  w  .  j a v  a 2 s . c  o  m
 */
public WgtContextAction() {
    m_btnOk.addClickHandler(this);
    m_btnOk.setTitle(MAppBoard.s_messages.validAction());
    m_btnOk.setStyleName("fmp-PushButton32");
    m_btnCancel.addClickHandler(this);
    m_btnCancel.setTitle(MAppBoard.s_messages.cancelAction());
    m_btnCancel.setStyleName("fmp-PushButton32");
    m_btnRepairTurret.addClickHandler(this);
    m_btnRepairTurret.setTitle(MAppBoard.s_messages.repairTurret());
    m_btnRepairTurret.setStyleName("fmp-PushButton32");
    m_btnTakeOff.addClickHandler(this);
    m_btnTakeOff.setTitle(MAppBoard.s_messages.takeOff());
    m_btnTakeOff.setStyleName("fmp-PushButton32");
    m_btnFire.addClickHandler(this);
    m_btnFire.setTitle(MAppBoard.s_messages.fire());
    m_btnFire.setStyleName("fmp-PushButton32");
    m_btnControl.addClickHandler(this);
    m_btnControl.setTitle(MAppBoard.s_messages.control());
    m_btnControl.setStyleName("fmp-PushButton32");
    m_btnFireCoverOn.addClickHandler(this);
    m_btnFireCoverOn.setTitle(MAppBoard.s_messages.displayFireCover());
    m_btnFireCoverOn.setStyleName("fmp-PushButton32");
    m_btnFireCoverOff.addClickHandler(this);
    m_btnFireCoverOff.setTitle(MAppBoard.s_messages.hideFireCover());
    m_btnFireCoverOff.setStyleName("fmp-PushButton32");
    m_btnEndTurn.addClickHandler(this);
    m_btnEndTurn.setTitle(MAppBoard.s_messages.endTurn());
    m_btnEndTurn.setStyleName("fmp-PushButton32");
    m_btnZoomIn.addClickHandler(this);
    m_btnZoomIn.setTitle(MAppBoard.s_messages.tacticalZoom());
    m_btnZoomIn.setStyleName("fmp-PushButton32");
    m_btnZoomOut.addClickHandler(this);
    m_btnZoomOut.setTitle(MAppBoard.s_messages.strategyZoom());
    m_btnZoomOut.setStyleName("fmp-PushButton32");
    m_btnGridOn.addClickHandler(this);
    m_btnGridOn.setTitle(MAppBoard.s_messages.displayGrid());
    m_btnGridOn.setStyleName("fmp-PushButton32");
    m_btnGridOff.addClickHandler(this);
    m_btnGridOff.setTitle(MAppBoard.s_messages.hideGrid());
    m_btnGridOff.setStyleName("fmp-PushButton32");
    m_btnRegister.addClickHandler(this);
    m_btnRegister.setTitle(MAppBoard.s_messages.joinGame());
    m_btnRegister.setStyleName("fmp-PushButton32");
    m_btnPractice.addClickHandler(this);
    m_btnPractice.setTitle(MAppBoard.s_messages.trainningMode());
    m_btnPractice.setStyleName("fmp-PushButton32");
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.register32()));
    hPanel.add(new Label(MAppBoard.s_messages.joinThisGame()));
    m_pnlRegister = new FocusPanel(hPanel);
    m_pnlRegister.addClickHandler(this);
    hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.pause32()));
    hPanel.add(new Label(MAppBoard.s_messages.waitGameStarting()));
    m_pnlWait = new FocusPanel(hPanel);
    hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.takeOff32()));
    hPanel.add(new Label(MAppBoard.s_messages.mustLandFreighter()));
    m_pnlLand = new FocusPanel(hPanel);
    m_pnlLand.addClickHandler(this);
    hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.takeOff32()));
    hPanel.add(new Label(MAppBoard.s_messages.mustDeployUnits()));
    m_pnlDeploy = new FocusPanel(hPanel);
    m_pnlDeploy.addClickHandler(this);
    hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.pause32()));
    hPanel.add(new Label(MAppBoard.s_messages.pauseGameAllowNewPlayer()));
    m_pnlPause = new FocusPanel(hPanel);
    hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.endTurn32()));
    hPanel.add(new Label(MAppBoard.s_messages.mustEndYourTurn()));
    m_pnlEndTurn = new FocusPanel(hPanel);
    m_pnlEndTurn.addClickHandler(this);
    hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.takeOff32()));
    hPanel.add(new Label(MAppBoard.s_messages.SelectFreighterToTakeOff()));
    m_pnlTakeOff = new FocusPanel(hPanel);
    m_pnlTakeOff.addClickHandler(this);
    hPanel = new HorizontalPanel();
    hPanel.add(new Image(Icons.s_instance.practice32()));
    hPanel.add(new Label(MAppBoard.s_messages.trainningMode()));
    hPanel.add(m_btnPracticeCancel);
    m_btnPracticeCancel.addClickHandler(this);
    hPanel.add(m_btnPracticeOk);
    m_btnPracticeOk.addClickHandler(this);
    m_pnlPractice = new FocusPanel(hPanel);

    m_iconAction.setTitle(MAppBoard.s_messages.costInPA());
    m_lblAction.setStyleName("fmp-status-text");

    // subscribe all needed models update event
    AppRoot.getEventBus().addHandler(ModelUpdateEvent.TYPE, this);

    m_panel.setSize("100%", "100%");
    m_panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    m_panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    initWidget(m_panel);
}

From source file:com.google.gerrit.client.Gerrit.java

License:Apache License

private static void whoAmI(boolean canLogOut) {
    AccountInfo account = getUserAccountInfo();
    final UserPopupPanel userPopup = new UserPopupPanel(account, canLogOut, true);
    final FlowPanel userSummaryPanel = new FlowPanel();
    class PopupHandler implements KeyDownHandler, ClickHandler {
        private void showHidePopup() {
            if (userPopup.isShowing() && userPopup.isVisible()) {
                userPopup.hide();//from w w w . ja  v  a  2 s  . c  om
            } else {
                userPopup.showRelativeTo(userSummaryPanel);
            }
        }

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

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                showHidePopup();
                event.preventDefault();
            }
        }
    }
    final PopupHandler popupHandler = new PopupHandler();
    final InlineLabel l = new InlineLabel(FormatUtil.name(account));
    l.setStyleName(RESOURCES.css().menuBarUserName());
    final AvatarImage avatar = new AvatarImage(account, 26, false);
    avatar.setStyleName(RESOURCES.css().menuBarUserNameAvatar());
    userSummaryPanel.setStyleName(RESOURCES.css().menuBarUserNamePanel());
    userSummaryPanel.add(l);
    userSummaryPanel.add(avatar);
    userSummaryPanel.add(new InlineLabel(" "));
    userPopup.addAutoHidePartner(userSummaryPanel.getElement());
    FocusPanel fp = new FocusPanel(userSummaryPanel);
    fp.setStyleName(RESOURCES.css().menuBarUserNameFocusPanel());
    fp.addKeyDownHandler(popupHandler);
    fp.addClickHandler(popupHandler);
    menuRight.add(fp);
}

From source file:com.google.gwt.gadgets.sample.traveler.client.PersonBrowser.java

License:Apache License

private Panel createPersonPanel(final Person p) {
    VerticalPanel panel = new VerticalPanel();
    panel.setPixelSize(cellSize, cellSize);
    panel.setStylePrimaryName("friend-cell");
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    String imgUrl = p.getThumbnailUrl();
    panel.add(new Image(imgUrl == null ? noPhotoUrl : imgUrl));
    panel.add(new Label(p.getDisplayName()));

    FocusPanel fPanel = new FocusPanel(panel);
    if (clickHandler != null) {
        fPanel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                clickHandler.handle(p.getId());
            }/*from  w w w  .j ava2 s  .  com*/
        });
    }
    return fPanel;
}

From source file:com.google.livingstories.client.contentitemlist.ClickableContentItemListElement.java

License:Apache License

public ClickableContentItemListElement(ContentItemListElement child, final ContentItemClickHandler handler) {
    this.element = child;
    focusPanel = new FocusPanel(element);
    focusPanel.addClickHandler(new ClickHandler() {
        @Override/* w  w w  .  j a va2  s. c o m*/
        public void onClick(ClickEvent event) {
            handler.onClick(element.getContentItem());
        }
    });
}