Search in sources :

Example 1 with ProjectInfo

use of com.google.gerrit.client.projects.ProjectInfo in project gerrit by GerritCodeReview.

the class CreateProjectScreen method initSuggestedParents.

private void initSuggestedParents() {
    suggestedParentsTab = new ProjectsTable() {

        {
            table.setText(0, 1, AdminConstants.I.parentSuggestions());
        }

        @Override
        protected void populate(final int row, final ProjectInfo k) {
            final Anchor projectLink = new Anchor(k.name());
            projectLink.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    parent.setText(getRowItem(row).name());
                }
            });
            table.setWidget(row, 2, projectLink);
            table.setText(row, 3, k.description());
            setRowItem(row, k);
        }
    };
    suggestedParentsTab.setVisible(false);
    ProjectMap.parentCandidates(new GerritCallback<ProjectMap>() {

        @Override
        public void onSuccess(ProjectMap list) {
            if (!list.isEmpty()) {
                suggestedParentsTab.setVisible(true);
                suggestedParentsTab.display(list);
                suggestedParentsTab.finishDisplay();
            }
        }
    });
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ProjectsTable(com.google.gerrit.client.ui.ProjectsTable) ProjectMap(com.google.gerrit.client.projects.ProjectMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ProjectInfo(com.google.gerrit.client.projects.ProjectInfo)

Example 2 with ProjectInfo

use of com.google.gerrit.client.projects.ProjectInfo in project gerrit by GerritCodeReview.

the class ProjectsTable method displaySubset.

public void displaySubset(ProjectMap projects, int fromIndex, int toIndex) {
    while (1 < table.getRowCount()) {
        table.removeRow(table.getRowCount() - 1);
    }
    List<ProjectInfo> list = Natives.asList(projects.values());
    Collections.sort(list, new Comparator<ProjectInfo>() {

        @Override
        public int compare(ProjectInfo a, ProjectInfo b) {
            return a.name().compareTo(b.name());
        }
    });
    for (ProjectInfo p : list.subList(fromIndex, toIndex)) {
        insert(table.getRowCount(), p);
    }
    finishDisplay();
}
Also used : ProjectInfo(com.google.gerrit.client.projects.ProjectInfo)

Example 3 with ProjectInfo

use of com.google.gerrit.client.projects.ProjectInfo 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)

Aggregations

ProjectInfo (com.google.gerrit.client.projects.ProjectInfo)3 ProjectsTable (com.google.gerrit.client.ui.ProjectsTable)2 WebLinkInfo (com.google.gerrit.client.info.WebLinkInfo)1 ProjectMap (com.google.gerrit.client.projects.ProjectMap)1 HighlightingInlineHyperlink (com.google.gerrit.client.ui.HighlightingInlineHyperlink)1 ProjectSearchLink (com.google.gerrit.client.ui.ProjectSearchLink)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 Anchor (com.google.gwt.user.client.ui.Anchor)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 List (java.util.List)1