Search in sources :

Example 1 with WebLinkInfo

use of com.google.gerrit.client.info.WebLinkInfo in project gerrit by GerritCodeReview.

the class PatchSetSelectBox method setUpPatchSetNav.

void setUpPatchSetNav(JsArray<RevisionInfo> list, int parents, DiffInfo.FileMeta meta, boolean editExists, boolean current, boolean open, boolean binary) {
    InlineHyperlink selectedLink = null;
    if (sideA) {
        if (parents <= 1) {
            InlineHyperlink link = createLink(PatchUtil.C.patchBase(), DiffObject.base());
            linkPanel.add(link);
            selectedLink = link;
        } else {
            for (int i = parents; i > 0; i--) {
                PatchSet.Id id = new PatchSet.Id(changeId, -i);
                InlineHyperlink link = createLink(Util.M.diffBaseParent(i), DiffObject.patchSet(id));
                linkPanel.add(link);
                if (revision != null && id.equals(revision)) {
                    selectedLink = link;
                }
            }
            InlineHyperlink link = createLink(Util.C.autoMerge(), DiffObject.autoMerge());
            linkPanel.add(link);
            if (selectedLink == null) {
                selectedLink = link;
            }
        }
    }
    for (int i = 0; i < list.length(); i++) {
        RevisionInfo r = list.get(i);
        InlineHyperlink link = createLink(r.id(), DiffObject.patchSet(new PatchSet.Id(changeId, r._number())));
        linkPanel.add(link);
        if (revision != null && r.id().equals(revision.getId())) {
            selectedLink = link;
        }
    }
    if (selectedLink != null) {
        selectedLink.setStyleName(style.selected());
    }
    if (meta == null) {
        return;
    }
    if (!Patch.isMagic(path)) {
        linkPanel.add(createDownloadLink());
    }
    if (!binary && open && !idActive.isBaseOrAutoMerge() && Gerrit.isSignedIn()) {
        if ((editExists && idActive.isEdit()) || (!editExists && current)) {
            linkPanel.add(createEditIcon());
        }
    }
    List<WebLinkInfo> webLinks = Natives.asList(meta.webLinks());
    if (webLinks != null) {
        for (WebLinkInfo webLink : webLinks) {
            linkPanel.add(webLink.toAnchor());
        }
    }
}
Also used : InlineHyperlink(com.google.gerrit.client.ui.InlineHyperlink) RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) WebLinkInfo(com.google.gerrit.client.info.WebLinkInfo) PatchSet(com.google.gerrit.reviewdb.client.PatchSet)

Example 2 with WebLinkInfo

use of com.google.gerrit.client.info.WebLinkInfo in project gerrit by GerritCodeReview.

the class ProjectListScreen method onInitUI.

@Override
protected void onInitUI() {
    super.onInitUI();
    setPageTitle(AdminConstants.I.projectListTitle());
    initPageHeader();
    prev = PagingHyperlink.createPrev();
    prev.setVisible(false);
    next = PagingHyperlink.createNext();
    next.setVisible(false);
    projects = new ProjectsTable() {

        @Override
        protected void initColumnHeaders() {
            super.initColumnHeaders();
            table.setText(0, ProjectsTable.C_REPO_BROWSER, AdminConstants.I.projectRepoBrowser());
            table.getFlexCellFormatter().addStyleName(0, ProjectsTable.C_REPO_BROWSER, Gerrit.RESOURCES.css().dataHeader());
        }

        @Override
        protected void onOpenRow(final int row) {
            History.newItem(link(getRowItem(row)));
        }

        private String link(final ProjectInfo item) {
            return Dispatcher.toProject(item.name_key());
        }

        @Override
        protected void insert(int row, ProjectInfo k) {
            super.insert(row, k);
            table.getFlexCellFormatter().addStyleName(row, ProjectsTable.C_REPO_BROWSER, Gerrit.RESOURCES.css().dataCell());
        }

        @Override
        protected void populate(final int row, final ProjectInfo k) {
            Image state = new Image();
            switch(k.state()) {
                case HIDDEN:
                    state.setResource(Gerrit.RESOURCES.redNot());
                    state.setTitle(Util.toLongString(k.state()));
                    table.setWidget(row, ProjectsTable.C_STATE, state);
                    break;
                case READ_ONLY:
                    state.setResource(Gerrit.RESOURCES.readOnly());
                    state.setTitle(Util.toLongString(k.state()));
                    table.setWidget(row, ProjectsTable.C_STATE, state);
                    break;
                case ACTIVE:
                default:
                    // Intentionally left blank, do not show an icon when active.
                    break;
            }
            FlowPanel fp = new FlowPanel();
            fp.add(new ProjectSearchLink(k.name_key()));
            fp.add(new HighlightingInlineHyperlink(k.name(), link(k), match));
            table.setWidget(row, ProjectsTable.C_NAME, fp);
            table.setText(row, ProjectsTable.C_DESCRIPTION, k.description());
            addWebLinks(row, k);
            setRowItem(row, k);
        }

        private void addWebLinks(int row, ProjectInfo k) {
            List<WebLinkInfo> webLinks = Natives.asList(k.webLinks());
            if (webLinks != null && !webLinks.isEmpty()) {
                FlowPanel p = new FlowPanel();
                table.setWidget(row, ProjectsTable.C_REPO_BROWSER, p);
                for (WebLinkInfo weblink : webLinks) {
                    p.add(weblink.toAnchor());
                }
            }
        }
    };
    projects.setSavePointerId(PageLinks.ADMIN_PROJECTS);
    add(projects);
    final HorizontalPanel buttons = new HorizontalPanel();
    buttons.setStyleName(Gerrit.RESOURCES.css().changeTablePrevNextLinks());
    buttons.add(prev);
    buttons.add(next);
    add(buttons);
}
Also used : WebLinkInfo(com.google.gerrit.client.info.WebLinkInfo) ProjectsTable(com.google.gerrit.client.ui.ProjectsTable) ProjectSearchLink(com.google.gerrit.client.ui.ProjectSearchLink) ProjectInfo(com.google.gerrit.client.projects.ProjectInfo) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) List(java.util.List) Image(com.google.gwt.user.client.ui.Image) HighlightingInlineHyperlink(com.google.gerrit.client.ui.HighlightingInlineHyperlink)

Example 3 with WebLinkInfo

use of com.google.gerrit.client.info.WebLinkInfo in project gerrit by GerritCodeReview.

the class Header method init.

void init(PreferencesAction pa, List<InlineHyperlink> links, List<WebLinkInfo> webLinks) {
    prefsAction = pa;
    prefsAction.setPartner(preferences);
    for (InlineHyperlink link : links) {
        linkPanel.add(link);
    }
    for (WebLinkInfo webLink : webLinks) {
        linkPanel.add(webLink.toAnchor());
    }
}
Also used : InlineHyperlink(com.google.gerrit.client.ui.InlineHyperlink) WebLinkInfo(com.google.gerrit.client.info.WebLinkInfo)

Example 4 with WebLinkInfo

use of com.google.gerrit.client.info.WebLinkInfo in project gerrit by GerritCodeReview.

the class DiffInfo method filterWebLinks.

private List<WebLinkInfo> filterWebLinks(DiffView diffView) {
    List<WebLinkInfo> filteredDiffWebLinks = new ArrayList<>();
    List<DiffWebLinkInfo> allDiffWebLinks = Natives.asList(webLinks());
    if (allDiffWebLinks != null) {
        for (DiffWebLinkInfo webLink : allDiffWebLinks) {
            if (diffView == DiffView.SIDE_BY_SIDE && webLink.showOnSideBySideDiffView()) {
                filteredDiffWebLinks.add(webLink);
            }
            if (diffView == DiffView.UNIFIED_DIFF && webLink.showOnUnifiedDiffView()) {
                filteredDiffWebLinks.add(webLink);
            }
        }
    }
    return filteredDiffWebLinks;
}
Also used : DiffWebLinkInfo(com.google.gerrit.client.DiffWebLinkInfo) DiffWebLinkInfo(com.google.gerrit.client.DiffWebLinkInfo) WebLinkInfo(com.google.gerrit.client.info.WebLinkInfo) ArrayList(java.util.ArrayList)

Aggregations

WebLinkInfo (com.google.gerrit.client.info.WebLinkInfo)4 InlineHyperlink (com.google.gerrit.client.ui.InlineHyperlink)2 DiffWebLinkInfo (com.google.gerrit.client.DiffWebLinkInfo)1 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)1 ProjectInfo (com.google.gerrit.client.projects.ProjectInfo)1 HighlightingInlineHyperlink (com.google.gerrit.client.ui.HighlightingInlineHyperlink)1 ProjectSearchLink (com.google.gerrit.client.ui.ProjectSearchLink)1 ProjectsTable (com.google.gerrit.client.ui.ProjectsTable)1 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 Image (com.google.gwt.user.client.ui.Image)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1