Example usage for com.google.gwt.user.client.ui HorizontalPanel add

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

Introduction

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

Prototype

@Override
    public void add(Widget w) 

Source Link

Usage

From source file:com.algorithmstudy.visualizer.client.sort.BarChartVisualizer.java

License:Open Source License

public BarChartVisualizer(int[] elements, boolean isSingle) {
    setStyleName(STYLE_BAR_CHART);/*from   w ww.jav a2s.com*/

    HorizontalPanel timePanel = new HorizontalPanel();
    timePanel.setWidth("100%");
    timePanel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);

    movesLabel = new Label();
    movesLabel.setStyleName(STYLE_MOVES_LABEL);
    movesLabel.setText(MOVES_BASE + "0");
    movesLabel.setWidth("8em");
    numberOfMoves = 0;

    timePanel.add(movesLabel);

    this.add(timePanel);

    chart = new Chart(elements, isSingle);
    this.add(chart);
}

From source file:com.algorithmstudy.visualizer.client.sort.SortingDisplayPanel.java

License:Open Source License

private void doReinitForTwo(SortAlgorithmType algorithm1, SortAlgorithmType algorithm2) {
    clearForReuse();//  www  .j av a 2 s . com

    sortControls.doReset();

    setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);

    sortControls.doSetNumElementsCB(VisualizerIndex.Second);
    this.add(sortControls);

    setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    visualizer1 = new BarChartVisualizer(valuesToSort, false);
    alg1 = algorithm1.getInstance();
    alg1.setVisualizer(visualizer1);
    alg1.setListToSort(cloneValuesToSort());
    visualizer1.setAlgorithm(alg1);
    timer.addVisualizer(visualizer1);

    alg1Type = algorithm1;

    visualizer2 = new BarChartVisualizer(valuesToSort, false);
    alg2 = algorithm2.getInstance();
    alg2.setVisualizer(visualizer2);
    alg2.setListToSort(cloneValuesToSort());
    visualizer2.setAlgorithm(alg2);
    timer.addVisualizer(visualizer2);

    alg2Type = algorithm2;

    HorizontalPanel visPanel = new HorizontalPanel();
    visPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);

    visPanel.add(visualizer1);
    visPanel.add(visualizer2);

    this.add(visPanel);
}

From source file:com.allen_sauer.gwt.dnd.demo.client.DragStartSensitivityBehaviorPanel.java

License:Apache License

public DragStartSensitivityBehaviorPanel(final DragController dragController) {
    super("Drag Sensitivity", "getBehaviorDragStartSensitivity() / setBehaviorDragStartSensitivity(int)");
    this.dragController = dragController;

    HorizontalPanel panel = new HorizontalPanel();
    panel.setSpacing(5);/*from   www.  jav a 2s  .  c om*/
    Label label = new Label("Number of Pixels");
    textBox = new TextBox();
    textBox.setWidth("3em");
    panel.add(label);
    panel.add(textBox);
    panel.setTitle("DragController#setBehaviorDragStartSensitivity(int)");
    add(panel);

    textBox.setText("" + dragController.getBehaviorDragStartSensitivity());

    textBox.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            fix();
        }
    });
    textBox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            fix();
            textBox.selectAll();
        }
    });
    textBox.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            fix();
        }
    });
}

From source file:com.allen_sauer.gwt.dnd.demo.client.example.duallist.DualListBox.java

License:Apache License

public DualListBox(int visibleItems, String width) {
    HorizontalPanel horizontalPanel = new HorizontalPanel();
    add(horizontalPanel);/*from  w  ww .  j a  va 2  s . c  o m*/
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.addStyleName(CSS_DEMO_DUAL_LIST_EXAMPLE_CENTER);
    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    dragController = new ListBoxDragController(this);
    left = new MouseListBox(dragController, LIST_SIZE);
    right = new MouseListBox(dragController, LIST_SIZE);

    left.setWidth(width);
    right.setWidth(width);

    horizontalPanel.add(left);
    horizontalPanel.add(verticalPanel);
    horizontalPanel.add(right);

    oneRight = new Button(">");
    oneLeft = new Button("<");
    allRight = new Button(">>");
    allLeft = new Button("<<");
    verticalPanel.add(oneRight);
    verticalPanel.add(oneLeft);
    verticalPanel.add(new HTML(" "));
    verticalPanel.add(allRight);
    verticalPanel.add(allLeft);

    allRight.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            moveItems(left, right, false);
        }
    });

    allLeft.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            moveItems(right, left, false);
        }
    });

    oneRight.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            moveItems(left, right, true);
        }
    });

    oneLeft.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            moveItems(right, left, true);
        }
    });

    ListBoxDropController leftDropController = new ListBoxDropController(left);
    ListBoxDropController rightDropController = new ListBoxDropController(right);
    dragController.registerDropController(leftDropController);
    dragController.registerDropController(rightDropController);
}

From source file:com.allen_sauer.gwt.dnd.demo.client.example.insertpanel.InsertPanelExample.java

License:Apache License

public InsertPanelExample(DemoDragHandler demoDragHandler) {
    addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE);
    int count = 0;

    // use the boundary panel as this composite's widget
    AbsolutePanel boundaryPanel = new AbsolutePanel();
    boundaryPanel.setSize("100%", "100%");
    setWidget(boundaryPanel);//from w ww  . j av a2s .c  o  m

    // initialize our column drag controller
    PickupDragController columnDragController = new PickupDragController(boundaryPanel, false);
    columnDragController.setBehaviorMultipleSelection(false);
    columnDragController.addDragHandler(demoDragHandler);

    // initialize our widget drag controller
    PickupDragController widgetDragController = new PickupDragController(boundaryPanel, false);
    widgetDragController.setBehaviorMultipleSelection(false);
    widgetDragController.addDragHandler(demoDragHandler);

    // initialize horizontal panel to hold our columns
    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_CONTAINER);
    horizontalPanel.setSpacing(SPACING);
    boundaryPanel.add(horizontalPanel);

    // initialize our column drop controller
    HorizontalPanelDropController columnDropController = new HorizontalPanelDropController(horizontalPanel);
    columnDragController.registerDropController(columnDropController);

    for (int col = 1; col <= COLUMNS; col++) {
        // initialize a vertical panel to hold the heading and a second vertical
        // panel
        VerticalPanel columnCompositePanel = new VerticalPanel();
        columnCompositePanel.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_COLUMN_COMPOSITE);

        // initialize inner vertical panel to hold individual widgets
        VerticalPanel verticalPanel = new VerticalPanelWithSpacer();
        verticalPanel.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_CONTAINER);
        verticalPanel.setSpacing(SPACING);
        horizontalPanel.add(columnCompositePanel);

        // initialize a widget drop controller for the current column
        VerticalPanelDropController widgetDropController = new VerticalPanelDropController(verticalPanel);
        widgetDragController.registerDropController(widgetDropController);

        // Put together the column pieces
        Label heading = new Label("Column " + col);
        heading.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_HEADING);
        columnCompositePanel.add(heading);
        columnCompositePanel.add(verticalPanel);

        // make the column draggable by its heading
        columnDragController.makeDraggable(columnCompositePanel, heading);

        for (int row = 1; row <= ROWS; row++) {
            // initialize a widget
            HTML widget = new HTML("Draggable&nbsp;#" + ++count);
            widget.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_WIDGET);
            widget.setHeight(Random.nextInt(4) + 2 + "em");
            verticalPanel.add(widget);

            // make the widget draggable
            widgetDragController.makeDraggable(widget);
        }
    }
}

From source file:com.allen_sauer.gwt.log.client.DivLogger.java

License:Apache License

/**
 * @deprecated//from  w ww .  j  a  va 2  s. c  om
 */
@Deprecated
private FocusPanel makeHeader() {
    FocusPanel header;
    header = new FocusPanel();
    HorizontalPanel masterPanel = new HorizontalPanel();
    masterPanel.setWidth("100%");
    header.add(masterPanel);

    final Label titleLabel = new Label("gwt-log", false);
    titleLabel.setStylePrimaryName(LogClientBundle.INSTANCE.css().logTitle());

    HorizontalPanel buttonPanel = new HorizontalPanel();
    levelButtons = new Button[levels.length];
    for (int i = 0; i < levels.length; i++) {
        final int level = levels[i];
        levelButtons[i] = new Button(LogUtil.levelToString(level));
        buttonPanel.add(levelButtons[i]);
        levelButtons[i].addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                ((Button) event.getSource()).setFocus(false);
                Log.setCurrentLogLevel(level);
            }
        });
    }

    Button clearButton = new Button("Clear");
    clearButton.addStyleName(LogClientBundle.INSTANCE.css().logClearButton());
    DOM.setStyleAttribute(clearButton.getElement(), "color", "#00c");
    clearButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ((Button) event.getSource()).setFocus(false);
            Log.clear();
        }
    });
    buttonPanel.add(clearButton);

    Button aboutButton = new Button("About");
    aboutButton.addStyleName(LogClientBundle.INSTANCE.css().logClearAbout());
    aboutButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ((Button) event.getSource()).setFocus(false);

            Log.diagnostic("\n" //
                    + "gwt-log-" + Log.getVersion() //
                    + " - Runtime logging for your Google Web Toolkit projects\n" + //
            "Copyright 2007 Fred Sauer\n" + //
            "The original software is available from:\n" + //
            "\u00a0\u00a0\u00a0\u00a0http://allen-sauer.com/gwt/\n", null);
        }
    });

    Button closeButton = new Button("X");
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            logDockPanel.removeFromParent();
        }
    });

    masterPanel.add(titleLabel);
    masterPanel.add(buttonPanel);
    masterPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    masterPanel.add(aboutButton);
    masterPanel.add(closeButton);

    masterPanel.setCellHeight(titleLabel, "100%");
    masterPanel.setCellWidth(titleLabel, "50%");
    masterPanel.setCellWidth(aboutButton, "50%");

    new MouseDragHandler(titleLabel);

    return header;
}

From source file:com.allen_sauer.gwt.voices.demo.client.DemoSoundPanel.java

License:Apache License

public DemoSoundPanel(final ThirdPartySound thirdPartySound) {
    // use a horizontal panel to hold our content
    HorizontalPanel horizontalPanel = new HorizontalPanel();
    initWidget(horizontalPanel);//  w  w  w.  ja  va  2 s . co  m

    // add a (temporarily disabled) play button
    final Button playButton = new Button("wait...");
    playButton.setEnabled(false);
    playButton.addStyleName("voices-button");
    horizontalPanel.add(playButton);

    final Button stopButton = new Button("wait...");
    stopButton.setEnabled(false);
    stopButton.addStyleName("voices-button");
    horizontalPanel.add(stopButton);

    // display a description of the sound next to the button
    horizontalPanel.add(new HTML("&nbsp;" + thirdPartySound.toHTMLString()));

    // display a load state status
    final HTML loadStateHTML = new HTML();
    horizontalPanel.add(loadStateHTML);

    // enable the play button once the sound has loaded
    thirdPartySound.getSound().addEventHandler(new SoundHandler() {
        @Override
        public void onPlaybackComplete(PlaybackCompleteEvent event) {
        }

        @Override
        public void onSoundLoadStateChange(final SoundLoadStateChangeEvent event) {
            // simulate a slight variable delay for local development
            new Timer() {
                @Override
                public void run() {
                    loadStateHTML.setHTML("&nbsp; (<code>" + event.getLoadState().name() + "</code>)");
                    switch (event.getLoadState()) {
                    case LOAD_STATE_SUPPORTED_AND_READY:
                    case LOAD_STATE_SUPPORTED_NOT_READY:
                    case LOAD_STATE_SUPPORTED_MAYBE_READY:
                        playButton.setEnabled(true);
                        playButton.setText("play");
                        stopButton.setEnabled(true);
                        stopButton.setText("stop");
                        break;
                    case LOAD_STATE_NOT_SUPPORTED:
                        playButton.setText("(sound or plugin unavailable)");
                        break;
                    case LOAD_STATE_SUPPORT_NOT_KNOWN:
                        playButton.setEnabled(true);
                        playButton.setText("play (may not work)");
                        stopButton.setEnabled(true);
                        stopButton.setText("stop");
                        break;
                    case LOAD_STATE_UNINITIALIZED:
                    default:
                        throw new IllegalArgumentException("Unhandled state " + event.getLoadState());
                    }
                }
            }.schedule(Random.nextInt(500) + 200);
        }
    });

    // play the sound when button is clicked
    playButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            thirdPartySound.getSound().play();
        }
    });

    stopButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            thirdPartySound.getSound().stop();
        }
    });
}

From source file:com.anzsoft.client.ui.UserIndicator.java

License:Open Source License

public UserIndicator(final String nick) {
    createStatusMenu();/*from ww  w. j a  v  a  2s  . c o m*/
    setWidth("100%");
    setCellPadding(0);
    setCellSpacing(0);
    setStyleName("indicator");
    FlexCellFormatter formatter = getFlexCellFormatter();

    // Setup the links cell
    /*
    linksPanel = new HorizontalPanel();
    setWidget(0, 0, linksPanel);
    formatter.setStyleName(0, 0, "indicator-links");
    formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    formatter.setColSpan(0, 0, 2);
    */

    // Setup the title cell
    setTitleWidget(null);
    formatter.setStyleName(0, 0, "indicator-title");

    getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP);
    getRowFormatter().setVerticalAlign(1, HasVerticalAlignment.ALIGN_TOP);

    final ChatIcons icons = ChatIcons.App.getInstance();
    statusImg = new Image();
    statusImg.setWidth("16px");
    statusImg.setHeight("16px");
    icons.online().applyTo(statusImg);

    avatarImg = new Image("images/default_avatar.png");
    avatarImg.setWidth("32px");
    avatarImg.setHeight("32px");
    avatarImg.setStyleName("handler");
    avatarImg.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            JabberApp.instance().showInfoSelf();
        }

    });

    nickName = new Label(nick);
    nickName.setDirection(Direction.LTR);
    nickName.setWidth("100%");

    statusLabel = new Label();
    statusLabel.setStyleName("status_label");
    statusLabel.setWidth("100%");

    statusEditor = new TextBox();
    statusEditor.setVisible(false);
    statusEditor.setWidth("100%");

    statusButton = new Button();
    statusButton.setMenu(statusMenu);
    statusButton.setStyleName("Status-Menu-Button");

    //statusMenuLabel = new Label();
    //statusMenuLabel.setStyleName("status_menu_label");

    //addLink(new HTML("<a href=\"http://samespace.anzsoft.com\">SameSpace</a>"));
    // Add the title and some images to the title bar
    HorizontalPanel titlePanel = new HorizontalPanel();
    titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    titlePanel.setWidth("100%");
    titlePanel.setSpacing(3);

    VerticalPanel statusPanel = new VerticalPanel();
    statusPanel.setWidth("100%");
    statusPanel.add(nickName);

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setWidth("100%");
    hPanel.setSpacing(2);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hPanel.add(statusLabel);
    hPanel.add(statusEditor);
    hPanel.add(statusButton);

    statusPanel.add(hPanel);

    titlePanel.add(statusImg);
    titlePanel.add(statusPanel);
    titlePanel.add(avatarImg);

    titlePanel.setCellWidth(statusImg, "20px");
    titlePanel.setCellWidth(statusPanel, "100%");
    titlePanel.setCellWidth(avatarImg, "32px");
    setTitleWidget(titlePanel);

    JabberApp.instance().getSession().getUser().addUserListener(new XmppUserListener() {
        public void onPresenceChanged(XmppPresence presence) {
            String show = new String("");
            PresenceShow presenceShow = presence.getShow();
            if (presenceShow != null)
                show = presenceShow.toString();
            String statusString = presence.getStatus();
            int priority = presence.getPriority();
            boolean avaiable = true;
            String type = presence.getType();
            if (type != null && !type.isEmpty()) {
                if (type.equalsIgnoreCase("unavailable"))
                    avaiable = false;
            }
            status = new XmppContactStatus(show, statusString, priority, avaiable);
            statusLabel.setText(status.status());
            iconFromStatus(status).applyTo(statusImg);
        }
    });

    statusLabel.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            statusLabel.setVisible(false);
            statusEditor.setVisible(true);
            statusEditor.setText(statusLabel.getText());
        }

    });

    statusEditor.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {

        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {

        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == 13)
                doneChangeStatusString();
        }

    });

    statusEditor.addFocusListener(new FocusListener() {
        public void onFocus(Widget sender) {
        }

        public void onLostFocus(Widget sender) {
            doneChangeStatusString();
        }

    });

    XmppVCardFactory.instance().addVCardListener(new VCardListener() {
        public void onVCard(XmppID jid, XmppVCard vcard) {
            if (jid.toStringNoResource().equalsIgnoreCase(JabberApp.instance().getJid().toStringNoResource())) {
                if (!vcard.nickName().isEmpty())
                    nickName.setText(vcard.fullName());
                else if (!vcard.fullName().isEmpty())
                    nickName.setText(vcard.fullName());
                String photoData = vcard.photo();
                if (!photoData.isEmpty() && !GXT.isIE) {
                    ImageElement imgEl = avatarImg.getElement().cast();
                    imgEl.removeAttribute("src");
                    imgEl.setSrc("data:image;base64," + photoData);
                }

            }
        }

    });
}

From source file:com.appspot.hommkmessage.client.view.Hommk_message.java

License:Open Source License

private SearchHandler initSearch(final ListView listView) {
    final Button searchButton = new Button("Suche");
    final TextBox searchTextField = new TextBox();
    searchTextField.setText("");
    searchTextField.setFocus(true);/*from ww  w.  j a  va 2 s. c  om*/
    searchButton.addStyleName("sendButton");
    HorizontalPanel searchPanel = new HorizontalPanel();
    searchPanel.add(searchTextField);
    searchPanel.add(searchButton);
    RootPanel.get("searchLineContainer").add(searchPanel);

    SearchHandler handler = new SearchHandler(listView, searchTextField);
    searchButton.addClickHandler(handler);
    searchTextField.addKeyUpHandler(handler);
    return handler;
}

From source file:com.appspot.hommkmessage.client.view.ListView.java

License:Open Source License

private void createListEntry(final int index, final MessageMetadata messageMetadata) {
    final HorizontalPanel entryLinePanel = new HorizontalPanel();
    final DisclosurePanel entryPanel = new DisclosurePanel();
    entryPanel.addStyleName("messageListEntryPanel");
    setEntryHeader(messageMetadata, entryPanel, true);
    entryLinePanel.add(entryPanel);
    addDeleteLink(messageMetadata, entryLinePanel);
    add(entryLinePanel);/*  ww w .j  a  v a  2  s  .c om*/

    entryPanel.addOpenHandler(new OpenHandler<DisclosurePanel>() {

        @Override
        public void onOpen(OpenEvent<DisclosurePanel> event) {
            entryPanel.clear();
            final MessageFrame messageFrame = new MessageFrame("messageFrame" + index);
            messageFrame.addStyleName("messageInListView");
            entryPanel.add(messageFrame);
            messageFrame.showMessage(messageMetadata.getId());
            localStorage.markAsRead(messageMetadata.getId());

            setEntryHeader(messageMetadata, entryPanel, false);
        }

    });
    entryPanel.addCloseHandler(new CloseHandler<DisclosurePanel>() {

        @Override
        public void onClose(CloseEvent<DisclosurePanel> event) {
            setEntryHeader(messageMetadata, entryPanel, true);
        }
    });
}