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

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

Introduction

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

Prototype

public HorizontalPanel() 

Source Link

Document

Creates an empty horizontal panel.

Usage

From source file:com.google.gerrit.client.changes.TopicDescriptionBlock.java

License:Apache License

public TopicDescriptionBlock() {
    infoBlock = new TopicInfoBlock();
    messageBlock = new CommitMessageBlock();

    final HorizontalPanel hp = new HorizontalPanel();
    hp.add(infoBlock);//from   w  w w  . ja v  a  2s . c  o  m
    hp.add(messageBlock);
    initWidget(hp);
}

From source file:com.google.gerrit.client.changes.TopicScreen.java

License:Apache License

private void addComments(final TopicDetail detail) {
    comments.clear();// w  w w .jav a 2s  .c om

    final AccountInfoCache accts = detail.getAccounts();
    final List<TopicMessage> msgList = detail.getMessages();

    HorizontalPanel title = new HorizontalPanel();
    title.setWidth("100%");
    // TODO Do we need a new string constant?
    title.add(new Label(Util.C.changeScreenComments()));
    if (msgList.size() > 1) {
        title.add(messagesMenuBar());
    }
    title.setStyleName(Gerrit.RESOURCES.css().blockHeader());
    comments.add(title);

    final long AGE = 7 * 24 * 60 * 60 * 1000L;
    final Timestamp aged = new Timestamp(System.currentTimeMillis() - AGE);

    for (int i = 0; i < msgList.size(); i++) {
        final TopicMessage msg = msgList.get(i);

        final AccountInfo author;
        if (msg.getAuthor() != null) {
            author = accts.get(msg.getAuthor());
        } else {
            final Account gerrit = new Account(null);
            gerrit.setFullName(Util.C.messageNoAuthor());
            author = new AccountInfo(gerrit);
        }

        boolean isRecent;
        if (i == msgList.size() - 1) {
            isRecent = true;
        } else {
            // TODO Instead of opening messages by strict age, do it by "unread"?
            isRecent = msg.getWrittenOn().after(aged);
        }

        final CommentPanel cp = new CommentPanel(author, msg.getWrittenOn(), msg.getMessage());
        cp.setRecent(isRecent);
        cp.addStyleName(Gerrit.RESOURCES.css().commentPanelBorder());
        if (i == msgList.size() - 1) {
            cp.addStyleName(Gerrit.RESOURCES.css().commentPanelLast());
            cp.setOpen(true);
        }
        comments.add(cp);
    }

    comments.setVisible(msgList.size() > 0);
}

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

License:Apache License

public StringListPanel(String title, List<String> fieldNames, FocusWidget w, boolean autoSort) {
    widget = w;//from  ww  w .j  ava 2s . c o m
    if (title != null) {
        titlePanel = new HorizontalPanel();
        SmallHeading titleLabel = new SmallHeading(title);
        titlePanel.add(titleLabel);
        add(titlePanel);
    }

    t = new StringListTable(fieldNames, autoSort);
    add(t);

    buttonPanel = new HorizontalPanel();
    buttonPanel.setStyleName(Gerrit.RESOURCES.css().stringListPanelButtons());
    deleteButton = new Button(Gerrit.C.stringListPanelDelete());
    deleteButton.setEnabled(false);
    deleteButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            widget.setEnabled(true);
            t.deleteChecked();
        }
    });
    buttonPanel.add(deleteButton);
    add(buttonPanel);
}

From source file:com.google.gerrit.client.ui.BranchTopicLink.java

License:Apache License

public BranchTopicLink(String text, Project.NameKey project, Change.Status status, String branch, String topic,
        Id topicId) {/* w  w w. j  a  va 2  s . c  o m*/
    hp = new HorizontalPanel();

    bl = new BranchLink(text, project, status, branch, topic);
    if (topicId != null)
        tl = new TopicLink(" (" + topic + ")", topicId);
    else {
        // TODO Remove this when the server side is ready and simply do not add tl to the HorizontalPanel
        String topicString;
        if (topic == null)
            topicString = "";
        else
            topicString = " (" + topic + ")";

        tl = new TopicLink(topicString, new Change.Id(1));
    }

    hp.add(bl);
    hp.add(tl);
    initWidget(hp);
}

From source file:com.google.gerrit.client.ui.MenuScreen.java

License:Apache License

@Override
protected void onInitUI() {
    super.onInitUI();

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(menu);//w w w.  jav  a  2  s.  c  om
    hp.add(body);
    super.add(hp);
}

From source file:com.google.gerrit.client.ui.ProjectListPopup.java

License:Apache License

private void createWidgets(final String popupText, final String currentPageLink) {
    filterPanel = new HorizontalPanel();
    filterPanel.setStyleName(Gerrit.RESOURCES.css().projectFilterPanel());
    final Label filterLabel = new Label(com.google.gerrit.client.admin.Util.C.projectFilter());
    filterLabel.setStyleName(Gerrit.RESOURCES.css().projectFilterLabel());
    filterPanel.add(filterLabel);/*from   ww w. ja  v  a 2  s  .c  o m*/
    filterTxt = new NpTextBox();
    filterTxt.setValue(subname);
    filterTxt.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            subname = filterTxt.getValue();
            populateProjects();
        }
    });
    filterPanel.add(filterTxt);

    projectsTab = new HighlightingProjectsTable() {
        @Override
        protected void movePointerTo(final int row, final boolean scroll) {
            super.movePointerTo(row, scroll);
            onMovePointerTo(getRowItem(row).name());
        }

        @Override
        protected void onOpenRow(final int row) {
            super.onOpenRow(row);
            openRow(getRowItem(row).name());
        }
    };
    projectsTab.setSavePointerId(currentPageLink);

    close = new Button(Util.C.projectsClose());
    close.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            closePopup();
        }
    });

    popup = new PluginSafeDialogBox();
    popup.setModal(false);
    popup.setText(popupText);
}

From source file:com.google.gwt.demos.gwtcanvas.client.GWTCanvasDemo.java

License:Apache License

public void onModuleLoad() {

    layout = new HorizontalPanel();

    // Each demo will set their own dimensions, so it doesn't matter
    // what we initialize the canvas to.
    canvas = new GWTCanvas(400, 400);

    canvas.addStyleName("gwt-canvas");

    // Create demos
    demos.add(new StaticDemo(canvas));
    demos.add(new LogoDemo(canvas));
    demos.add(new ParticleDemo(canvas));
    demos.add(new GradientDemo(canvas));
    demos.add(new SuiteDemo(canvas));

    // Add them to the selection list box
    ListBox lb = new ListBox();
    lb.setStyleName("listBox");

    for (int i = 0; i < demos.size(); i++) {
        lb.addItem(((SimpleCanvasDemo) demos.get(i)).getName());
    }/*from w ww .  j  a  v  a 2 s.  com*/

    lb.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            int choice = ((ListBox) event.getSource()).getSelectedIndex();
            swapDemo(demos.get(choice));
        }
    });

    // start off with the first demo
    currentDemo = demos.get(0);

    // Add widgets to layout and RootPanel
    VerticalPanel vp = new VerticalPanel();
    vp.add(lb);
    vp.add(canvas);
    layout.add(vp);
    if (currentDemo.getControls() != null) {
        layout.add(currentDemo.getControls());
    }
    RootPanel.get().add(layout);
    currentDemo.drawDemo();
}

From source file:com.google.gwt.examples.ImageExample.java

License:Apache License

public void onModuleLoad() {
    // Create an image, not yet referencing a URL. We make it final so that we
    // can manipulate the image object within the ClickHandlers for the buttons.
    final Image image = new Image();

    // Hook up an error handler, so that we can be informed if the image fails
    // to load.//from www  . java2 s  . c o  m
    image.addErrorHandler(new ErrorHandler() {
        public void onError(ErrorEvent event) {
            lbl.setText("An error occurred while loading.");
        }
    });

    // Point the image at a real URL.
    image.setUrl("http://www.google.com/images/logo.gif");

    // When the user clicks this button, we want to clip the image.
    btn.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            image.setVisibleRect(70, 0, 47, 110);
        }
    });
    btn.setWidth("120px");

    // When the user clicks this button, we want to restore the image to its
    // unclipped state.
    btn2.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            image.setUrl("http://www.google.com/images/logo.gif");
        }
    });
    btn2.setWidth("120px");

    // Add the image, label, and clip/restore buttons to the root panel.
    VerticalPanel panel = new VerticalPanel();
    panel.add(lbl);
    panel.add(image);

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.add(btn);
    buttonPanel.add(btn2);

    panel.add(buttonPanel);

    RootPanel.get().add(panel);
}

From source file:com.google.gwt.gadgets.sample.gadgetrpc.client.GadgetRPC.java

License:Apache License

@Override
protected void init(GadgetRPC.Preferences preferences) {

    gadgetService = GWT.create(GadgetService.class);
    ServiceDefTarget serviceDef = (ServiceDefTarget) gadgetService;
    String rpcUrl = serviceDef.getServiceEntryPoint();

    // Uses Gadgets container as proxy for GWT RPC requests
    GadgetsGwtRpc.redirectThroughProxy(serviceDef);

    // Build the user interface.
    VerticalPanel vp = new VerticalPanel();
    vp.setWidth("100%");

    vp.add(new Label("RPC to: " + rpcUrl));

    HorizontalPanel startedHp = new HorizontalPanel();
    startedHp.add(new Label("Server Start Time: "));
    startedHp.add(serverStartedText);// www.ja va2 s  .c  o m
    vp.add(startedHp);

    HorizontalPanel currentHp = new HorizontalPanel();
    currentHp.add(new Label("Server Current Time: "));
    currentHp.add(serverCurrentText);
    vp.add(currentHp);

    Button doRPCButton = new Button("Call RPC Method");
    vp.add(doRPCButton);

    vp.add(exceptionInfo);

    RootPanel.get().add(vp);

    // Setup a button listener to invoke the RPC.
    doRPCButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            gadgetService.getServerInfo(rpcCallback);
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.HelloGData.java

License:Apache License

/**
 * Invoked when GData has loaded. Build the UI and display the default demo.
 *//*from w  ww .  ja  v a  2  s.  c  o  m*/
public void onGDataLoad() {
    if (User.getStatus() == AuthSubStatus.LOGGING_IN) {
        /*
         * AuthSub causes a refresh of the browser, so if status is LOGGING_IN
         * don't render anything. An empty page refresh is friendlier.
         */
        return;
    }

    DecoratorPanel decorator = new DecoratorPanel();
    decorator.add(outerPanel);

    RootPanel.get().setStylePrimaryName("hm-body");
    RootPanel.get().add(new HTML("<img src='logo-small.png' alt='gwt logo' "
            + "align='absmiddle'><span class='hm-title'>Google GData API Library " + "for GWT Demo</span>"));
    RootPanel.get().add(decorator);

    innerPanel.setStylePrimaryName("hm-innerpanel");
    innerPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    innerPanel.setSpacing(10);

    outerPanel.setStylePrimaryName("hm-outerpanel");
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);

    outerPanel.addCell(0);
    outerPanel.addCell(1);
    outerPanel.addCell(2);
    outerPanel.addCell(3);

    outerPanel.setWidget(0, 0,
            new HTML("This GData-enabled application was built using the GData " + "API Library for GWT, "
                    + "<a href=\"http://code.google.com/p/gwt-gdata/\">"
                    + "http://code.google.com/p/gwt-gdata/</a>. "
                    + "The drop down list below allows you to select a scenario that "
                    + "demonstrates a particular capability of the GData support."));

    outerPanel.setWidget(1, 0, innerPanel);

    HorizontalPanel horizPanel = new HorizontalPanel();
    list.setStylePrimaryName("hm-demolistbox");
    list.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            GDataDemoInfo info = list.getGDataDemoSelection();
            if (info == null) {
                showInfo();
            } else {
                show(info);
            }
        }
    });
    description.setStylePrimaryName("hm-description");
    innerPanel.clear();
    innerPanel.add(horizPanel);
    innerPanel.add(description);
    horizPanel.add(new Label("Select Demo: "));
    horizPanel.add(list);
    loadGDataDemos();
    showInfo();
}