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.account.MyWatchedProjectsScreen.java

License:Apache License

@Override
protected void onInitUI() {
    super.onInitUI();
    createWidgets();/*w ww  . j  a  v  a2s . c  om*/

    /* top table */
    grid = new Grid(2, 2);
    grid.setStyleName(Gerrit.RESOURCES.css().infoBlock());
    grid.setText(0, 0, Util.C.watchedProjectName());
    final HorizontalPanel hp = new HorizontalPanel();
    hp.add(nameTxt);
    hp.add(browse);
    grid.setWidget(0, 1, hp);

    grid.setText(1, 0, Util.C.watchedProjectFilter());
    grid.setWidget(1, 1, filterTxt);

    final CellFormatter fmt = grid.getCellFormatter();
    fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
    fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
    fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().header());
    fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().header());
    fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().bottomheader());

    final FlowPanel fp = new FlowPanel();
    fp.setStyleName(Gerrit.RESOURCES.css().addWatchPanel());
    fp.add(grid);
    fp.add(addNew);
    add(fp);

    /* bottom table */
    add(watchesTab);
    add(delSel);

    /* popup */
    projectsPopup = new ProjectListPopup() {
        @Override
        protected void onMovePointerTo(String projectName) {
            // prevent user input from being overwritten by simply poping up
            if (!projectsPopup.isPoppingUp() || "".equals(nameBox.getText())) {
                nameBox.setText(projectName);
            }
        }

        @Override
        protected void openRow(String projectName) {
            nameBox.setText(projectName);
            doAddNew();
        }
    };
    projectsPopup.initPopup(Util.C.projects(), PageLinks.SETTINGS_PROJECTS);
}

From source file:com.google.gerrit.client.account.SshPanel.java

License:Apache License

SshPanel() {
    final FlowPanel body = new FlowPanel();

    showAddKeyBlock = new Button(Util.C.buttonShowAddSshKey());
    showAddKeyBlock.addClickHandler(new ClickHandler() {
        @Override//  w w w.j  a v a2s .  c o m
        public void onClick(final ClickEvent event) {
            showAddKeyBlock(true);
        }
    });

    keys = new SshKeyTable();
    body.add(keys);
    {
        final FlowPanel fp = new FlowPanel();
        deleteKey = new Button(Util.C.buttonDeleteSshKey());
        deleteKey.setEnabled(false);
        deleteKey.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(final ClickEvent event) {
                keys.deleteChecked();
            }
        });
        fp.add(deleteKey);
        fp.add(showAddKeyBlock);
        body.add(fp);
    }

    addKeyBlock = new VerticalPanel();
    addKeyBlock.setVisible(false);
    addKeyBlock.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel());
    addKeyBlock.add(new SmallHeading(Util.C.addSshKeyPanelHeader()));

    final ComplexDisclosurePanel addSshKeyHelp = new ComplexDisclosurePanel(Util.C.addSshKeyHelpTitle(), false);
    addSshKeyHelp.setContent(new HTML(Util.C.addSshKeyHelp()));
    addKeyBlock.add(addSshKeyHelp);

    addTxt = new NpTextArea();
    addTxt.setVisibleLines(12);
    addTxt.setCharacterWidth(80);
    addTxt.setSpellCheck(false);
    addKeyBlock.add(addTxt);

    final HorizontalPanel buttons = new HorizontalPanel();
    addKeyBlock.add(buttons);

    clearNew = new Button(Util.C.buttonClearSshKeyInput());
    clearNew.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            addTxt.setText("");
            addTxt.setFocus(true);
        }
    });
    buttons.add(clearNew);

    addNew = new Button(Util.C.buttonAddSshKey());
    addNew.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            doAddNew();
        }
    });
    buttons.add(addNew);

    closeAddKeyBlock = new Button(Util.C.buttonCloseAddSshKey());
    closeAddKeyBlock.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            showAddKeyBlock(false);
        }
    });
    buttons.add(closeAddKeyBlock);
    buttons.setCellWidth(closeAddKeyBlock, "100%");
    buttons.setCellHorizontalAlignment(closeAddKeyBlock, HasHorizontalAlignment.ALIGN_RIGHT);

    body.add(addKeyBlock);

    serverKeys = new FlowPanel();
    body.add(serverKeys);

    initWidget(body);
}

From source file:com.google.gerrit.client.admin.GroupListScreen.java

License:Apache License

private void initPageHeader() {
    final HorizontalPanel hp = new HorizontalPanel();
    hp.setStyleName(Gerrit.RESOURCES.css().projectFilterPanel());
    final Label filterLabel = new Label(Util.C.projectFilter());
    filterLabel.setStyleName(Gerrit.RESOURCES.css().projectFilterLabel());
    hp.add(filterLabel);/* w ww . 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();
            refresh();
        }
    });
    hp.add(filterTxt);
    add(hp);
}

From source file:com.google.gerrit.client.admin.ProjectTagsScreen.java

License:Apache License

@Override
protected void onInitUI() {
    super.onInitUI();
    initPageHeader();/*  ww w  . j a  va  2s .  co m*/

    prev = PagingHyperlink.createPrev();
    prev.setVisible(false);

    next = PagingHyperlink.createNext();
    next.setVisible(false);

    addPanel = new FlowPanel();

    Grid addGrid = new Grid(2, 2);
    addGrid.setStyleName(Gerrit.RESOURCES.css().addBranch());
    int texBoxLength = 50;

    nameTxtBox = new HintTextBox();
    nameTxtBox.setVisibleLength(texBoxLength);
    nameTxtBox.setHintText(AdminConstants.I.defaultTagName());
    nameTxtBox.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                doAddNewTag();
            }
        }
    });
    addGrid.setText(0, 0, AdminConstants.I.columnTagName() + ":");
    addGrid.setWidget(0, 1, nameTxtBox);

    irevTxtBox = new HintTextBox();
    irevTxtBox.setVisibleLength(texBoxLength);
    irevTxtBox.setHintText(AdminConstants.I.defaultRevisionSpec());
    irevTxtBox.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                doAddNewTag();
            }
        }
    });
    addGrid.setText(1, 0, AdminConstants.I.initialRevision() + ":");
    addGrid.setWidget(1, 1, irevTxtBox);

    addTag = new Button(AdminConstants.I.buttonAddTag());
    addTag.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            doAddNewTag();
        }
    });
    addPanel.add(addGrid);
    addPanel.add(addTag);

    tagTable = new TagsTable();

    delTag = new Button(AdminConstants.I.buttonDeleteTag());
    delTag.setStyleName(Gerrit.RESOURCES.css().branchTableDeleteButton());
    delTag.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            tagTable.deleteChecked();
        }
    });

    HorizontalPanel buttons = new HorizontalPanel();
    buttons.setStyleName(Gerrit.RESOURCES.css().branchTablePrevNextLinks());
    buttons.add(delTag);
    buttons.add(prev);
    buttons.add(next);
    add(tagTable);
    add(buttons);
    add(addPanel);
}

From source file:com.google.gerrit.client.admin.ProjectTagsScreen.java

License:Apache License

private void initPageHeader() {
    parseToken();//from   www .jav  a 2  s.co  m
    HorizontalPanel hp = new HorizontalPanel();
    hp.setStyleName(Gerrit.RESOURCES.css().projectFilterPanel());
    Label filterLabel = new Label(AdminConstants.I.projectFilter());
    filterLabel.setStyleName(Gerrit.RESOURCES.css().projectFilterLabel());
    hp.add(filterLabel);
    filterTxt = new NpTextBox();
    filterTxt.setValue(match);
    filterTxt.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            Query q = new Query(filterTxt.getValue());
            if (match.equals(q.qMatch)) {
                q.start(start);
            } else {
                if (query == null) {
                    q.run();
                }
                query = q;
            }
        }
    });
    hp.add(filterTxt);
    add(hp);
}

From source file:com.google.gerrit.client.change.DownloadBox.java

License:Apache License

private void insertPatch() {
    String id = revision.substring(0, 7);
    Anchor patchBase64 = new Anchor(id + ".diff.base64");
    patchBase64.setHref(new RestApi("/changes/").id(psId.getParentKey().get()).view("revisions").id(revision)
            .view("patch").addParameterTrue("download").url());

    Anchor patchZip = new Anchor(id + ".diff.zip");
    patchZip.setHref(new RestApi("/changes/").id(psId.getParentKey().get()).view("revisions").id(revision)
            .view("patch").addParameterTrue("zip").url());

    HorizontalPanel p = new HorizontalPanel();
    p.add(patchBase64);//w  w w  .java  2s .  c o m
    InlineLabel spacer = new InlineLabel("|");
    spacer.setStyleName(Gerrit.RESOURCES.css().downloadBoxSpacer());
    p.add(spacer);
    p.add(patchZip);
    insertCommand("Patch-File", p);
}

From source file:com.google.gerrit.client.change.DownloadBox.java

License:Apache License

private void insertArchive() {
    List<String> activated = Gerrit.info().download().archives();
    if (activated.isEmpty()) {
        return;/*from ww w .j  a  va2  s .c  o m*/
    }

    List<Anchor> anchors = new ArrayList<>(activated.size());
    for (String f : activated) {
        Anchor archive = new Anchor(f);
        archive.setHref(new RestApi("/changes/").id(psId.getParentKey().get()).view("revisions").id(revision)
                .view("archive").addParameter("format", f).url());
        anchors.add(archive);
    }

    HorizontalPanel p = new HorizontalPanel();
    Iterator<Anchor> it = anchors.iterator();
    while (it.hasNext()) {
        Anchor a = it.next();
        p.add(a);
        if (it.hasNext()) {
            InlineLabel spacer = new InlineLabel("|");
            spacer.setStyleName(Gerrit.RESOURCES.css().downloadBoxSpacer());
            p.add(spacer);
        }
    }
    insertCommand("Archive", p);
}

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

License:Apache License

public ChangeDescriptionBlock(KeyCommandSet keysAction) {
    infoBlock = new ChangeInfoBlock();
    messageBlock = new CommitMessageBlock(keysAction);

    final HorizontalPanel hp = new HorizontalPanel();
    hp.add(infoBlock);//from   www  . j a  va2s  .c o  m
    hp.add(messageBlock);
    initWidget(hp);
}

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

License:Apache License

private void addComments(final ChangeDetail detail) {
    comments.clear();/*from   w w w .  ja va  2 s.c  o  m*/

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

    HorizontalPanel title = new HorizontalPanel();
    title.setWidth("100%");
    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);

    CommentVisibilityStrategy commentVisibilityStrategy = CommentVisibilityStrategy.EXPAND_RECENT;
    if (Gerrit.isSignedIn()) {
        commentVisibilityStrategy = Gerrit.getUserAccount().getGeneralPreferences()
                .getCommentVisibilityStrategy();
    }

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

        AccountInfo author;
        if (msg.getAuthor() != null) {
            author = FormatUtil.asInfo(accts.get(msg.getAuthor()));
        } else {
            author = AccountInfo.create(0, Util.C.messageNoAuthor(), null);
        }

        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(),
                commentLinkProcessor);
        cp.setRecent(isRecent);
        cp.addStyleName(Gerrit.RESOURCES.css().commentPanelBorder());
        if (i == msgList.size() - 1) {
            cp.addStyleName(Gerrit.RESOURCES.css().commentPanelLast());
        }
        boolean isOpen = false;
        switch (commentVisibilityStrategy) {
        case COLLAPSE_ALL:
            break;
        case EXPAND_ALL:
            isOpen = true;
            break;
        case EXPAND_MOST_RECENT:
            isOpen = i == msgList.size() - 1;
            break;
        case EXPAND_RECENT:
        default:
            isOpen = isRecent;
            break;
        }
        cp.setOpen(isOpen);
        comments.add(cp);
    }

    final Button b = new Button(Util.C.changeScreenAddComment());
    b.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            PatchSet.Id currentPatchSetId = patchSetsBlock.getCurrentPatchSet().getId();
            Gerrit.display(Dispatcher.toPublish(currentPatchSetId));
        }
    });
    comments.add(b);
    comments.setVisible(msgList.size() > 0);
}

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

License:Apache License

@Override
protected void onInitUI() {
    super.onInitUI();
    prev = new Hyperlink(Util.C.pagedChangeListPrev(), true, "");
    prev.setVisible(false);/*from  ww w. j  av a2 s  .  c  o  m*/

    next = new Hyperlink(Util.C.pagedChangeListNext(), true, "");
    next.setVisible(false);

    table = new ChangeTable2() {
        {
            keysNavigation.add(new DoLinkCommand(0, 'p', Util.C.changeTablePagePrev(), prev));
            keysNavigation.add(new DoLinkCommand(0, 'n', Util.C.changeTablePageNext(), next));
        }
    };
    section = new ChangeTable2.Section();
    table.addSection(section);
    table.setSavePointerId(anchorPrefix);
    add(table);

    final HorizontalPanel buttons = new HorizontalPanel();
    buttons.setStyleName(Gerrit.RESOURCES.css().changeTablePrevNextLinks());
    buttons.add(prev);
    buttons.add(next);
    add(buttons);
}