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

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

Introduction

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

Prototype

public Anchor(String text, String href, String target) 

Source Link

Document

Creates a source anchor with a frame target.

Usage

From source file:com.edgenius.wiki.gwt.client.page.widgets.RSSFeedButton.java

License:Open Source License

private void buildPanel() {
    this.clear();

    Anchor feedLink = new Anchor("RSS", getRSSURL(), "_blank");
    Image feedImg = new Image(IconBundle.I.get().feed());
    feedImg.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            openFeed();//from w w  w . j  a  va2s .c om
        }

    });
    feedImg.setStyleName(Css.PORTLET_FOOT_IMG);

    this.add(feedImg);
    //this just for surround <div> in Anchor, so it looks like with other button
    FlowPanel con = new FlowPanel();
    con.setStyleName("gwt-Hyperlink");
    con.add(feedLink);
    this.add(con);
}

From source file:com.google.api.explorer.client.FullView.java

License:Apache License

private void showDocumentationLink(String componentName, String href) {
    docsContainer.add(new InlineLabel("Learn more about using " + componentName + " by reading the "));
    docsContainer.add(new Anchor("documentation", href, NEW_TAB_TARGET));
    docsContainer.add(new InlineLabel("."));
}

From source file:com.google.api.explorer.client.history.JsonPrettifier.java

License:Apache License

private static List<Widget> formatString(ApiService service, String rawText,
        PrettifierLinkFactory linkFactory) {

    if (isLink(rawText)) {
        List<Widget> response = Lists.newArrayList();
        response.add(new InlineLabel("\""));

        boolean createdExplorerLink = false;
        try {//from  ww w  . ja  v  a2s . c  om
            ApiMethod method = getMethodForUrl(service, rawText);
            if (method != null) {
                String explorerLink = createExplorerLink(service, rawText, method);
                Widget linkObject = linkFactory.generateAnchor(rawText, explorerLink);
                linkObject.addStyleName(style.jsonStringExplorerLink());
                response.add(linkObject);
                createdExplorerLink = true;
            }
        } catch (IndexOutOfBoundsException e) {
            // Intentionally blank - this will only happen when iterating the method
            // url template in parallel with the url components and you run out of
            // components
        }

        if (!createdExplorerLink) {
            Anchor linkObject = new Anchor(rawText, rawText, OPEN_IN_NEW_WINDOW);
            linkObject.addStyleName(style.jsonStringLink());
            response.add(linkObject);
        }

        response.add(new InlineLabel("\""));
        return response;
    } else {
        JSONString encoded = new JSONString(rawText);
        Widget stringText = new InlineLabel(encoded.toString());
        stringText.addStyleName(style.jsonString());
        return Lists.newArrayList(stringText);
    }
}

From source file:com.google.caliper.cloud.client.BenchmarkDataViewer.java

License:Apache License

private Widget newEnvironmentWidget(RunMeta runMeta) {
    Widget environmentWidget;//w ww  .j  ava  2  s  . co m
    EnvironmentMeta environmentMeta = runMeta.getEnvironmentMeta();
    if (environmentMeta == null) {
        Label noEnvironmentLabel = new Label("none");
        noEnvironmentLabel.setStyleName("placeholder");
        environmentWidget = noEnvironmentLabel;
    } else {
        Anchor environmentAnchor = new Anchor(environmentMeta.getName(), false, "#environments");
        environmentAnchor.setStyleName("subtlelink");
        environmentWidget = environmentAnchor;
    }
    return environmentWidget;
}

From source file:com.google.caliper.cloud.client.BenchmarksDisplay.java

License:Apache License

private void rebuildBenchmarksTable() {
    Grid table = new Grid(benchmarkNames.size() + 1, 2);
    table.setStyleName("data");

    int r = 0;// ww w .j  a  v a 2 s .c  o  m
    table.getRowFormatter().setStyleName(r, "evenRow");
    table.getCellFormatter().setStyleName(r, 0, "parameterKey");
    table.setWidget(r, 0, new Label("package"));
    table.getCellFormatter().setStyleName(r, 1, "parameterKey");
    table.setWidget(r, 1, new Label("benchmark"));
    r++;

    Collections.sort(benchmarkNames);
    for (String benchmarkName : benchmarkNames) {
        table.getRowFormatter().addStyleName(r, r % 2 == 0 ? "evenRow" : "oddRow");

        int lastPeriod = benchmarkName.lastIndexOf('.');
        String packageName;
        String className;
        if (lastPeriod != -1) {
            packageName = benchmarkName.substring(0, lastPeriod);
            className = benchmarkName.substring(lastPeriod + 1);
        } else {
            packageName = "(default package)";
            table.getCellFormatter().setStyleName(r, 0, "placeholder");
            className = benchmarkName;
        }

        table.setWidget(r, 0, new Label(packageName));

        Anchor benchmarkAnchor = new Anchor(className, false, "/run/" + benchmarkOwner + "/" + benchmarkName);
        benchmarkAnchor.addStyleName("strong");
        table.setWidget(r, 1, benchmarkAnchor);
        r++;
    }

    benchmarksDiv.clear();
    benchmarksDiv.add(table);
}

From source file:com.google.caliper.cloud.client.SnapshotsTableDisplay.java

License:Apache License

public void rebuild(boolean editable, BenchmarkMeta benchmarkMeta, long selectedSnapshotId) {
    container.clear();/*  w w  w .j  av a2 s  .  c  o m*/
    List<BenchmarkSnapshotMeta> snapshots = benchmarkMeta.getSnapshots();
    Benchmark baseBenchmark = benchmarkMeta.getBenchmark();

    // rows for all snapshots, and the base benchmark itself.
    Grid table = new Grid(snapshots.size() + 1, editable ? 3 : 2);
    table.setStyleName("data");
    int row = 0;
    int column = 0;

    // baseBenchmark
    if (selectedSnapshotId == -1) {
        table.getRowFormatter().setStyleName(row, "environmentDifferRow");
    } else {
        table.getRowFormatter().setStyleName(row, row % 2 == 0 ? "evenRow" : "oddRow");
    }
    table.setWidget(row, column++,
            new Anchor("Original", false, "/run/" + baseBenchmark.getOwner() + "/" + baseBenchmark.getName()));
    table.getCellFormatter().addStyleName(row, column, "placeholder");
    row++;

    Collections.sort(snapshots, Collections.reverseOrder(BenchmarkSnapshotMeta.ORDER_BY_DATE));
    for (BenchmarkSnapshotMeta snapshot : snapshots) {
        column = 0;

        if (selectedSnapshotId == snapshot.getId()) {
            table.getRowFormatter().setStyleName(row, "environmentDifferRow");
        } else {
            table.getRowFormatter().setStyleName(row, row % 2 == 0 ? "evenRow" : "oddRow");
        }
        DateTimeFormat format = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss Z");
        String formattedDate = format.format(new Date(snapshot.getCreated()));

        table.setWidget(row, column++, new Anchor("Snapshot", false, "/run/" + snapshot.getBenchmarkOwner()
                + "/" + snapshot.getBenchmarkName() + "/" + snapshot.getId()));
        table.setWidget(row, column++, new Label(formattedDate));
        if (editable) {
            table.setWidget(row, column++, new SnapshotDeletedEditor(snapshot).getWidget());
        }
        row++;
    }

    container.add(table);
}

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

License:Apache License

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

    HorizontalPanel h = new HorizontalPanel();
    add(h);/*from w ww.j  a v  a2s  .c  o  m*/

    VerticalPanel v = new VerticalPanel();
    v.addStyleName(Gerrit.RESOURCES.css().avatarInfoPanel());
    h.add(v);
    avatar = new AvatarImage();
    v.add(avatar);
    changeAvatar = new Anchor(Util.C.changeAvatar(), "", "_blank");
    changeAvatar.setVisible(false);
    v.add(changeAvatar);

    if (LocaleInfo.getCurrentLocale().isRTL()) {
        labelIdx = 1;
        fieldIdx = 0;
    } else {
        labelIdx = 0;
        fieldIdx = 1;
    }

    info = new Grid((Gerrit.getConfig().siteHasUsernames() ? 1 : 0) + 4, 2);
    info.setStyleName(Gerrit.RESOURCES.css().infoBlock());
    info.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
    h.add(info);

    int row = 0;
    if (Gerrit.getConfig().siteHasUsernames()) {
        infoRow(row++, Util.C.userName());
    }
    infoRow(row++, Util.C.fullName());
    infoRow(row++, Util.C.preferredEmail());
    infoRow(row++, Util.C.registeredOn());
    infoRow(row++, Util.C.accountId());

    final CellFormatter fmt = info.getCellFormatter();
    fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
    fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
    fmt.addStyleName(row - 1, 0, Gerrit.RESOURCES.css().bottomheader());
}

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

License:Apache License

@Override
protected void onInitUI() {
    super.onInitUI();
    setPageTitle(Util.C.projectListTitle());
    initPageHeader();//from w w w. j  a  v a  2 s.com

    projects = new ProjectsTable() {
        @Override
        protected void initColumnHeaders() {
            super.initColumnHeaders();
            if (Gerrit.getGitwebLink() != null) {
                table.setText(0, 3, Util.C.projectRepoBrowser());
                table.getFlexCellFormatter().addStyleName(0, 3, 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);
            if (Gerrit.getGitwebLink() != null) {
                table.getFlexCellFormatter().addStyleName(row, 3, Gerrit.RESOURCES.css().dataCell());
            }
        }

        @Override
        protected void populate(final int row, final ProjectInfo k) {
            FlowPanel fp = new FlowPanel();
            fp.add(new ProjectSearchLink(k.name_key()));
            fp.add(new HighlightingInlineHyperlink(k.name(), link(k), subname));
            table.setWidget(row, 1, fp);
            table.setText(row, 2, k.description());
            GitwebLink l = Gerrit.getGitwebLink();
            if (l != null) {
                table.setWidget(row, 3, new Anchor(l.getLinkName(), false, l.toProject(k.name_key())));
            }

            setRowItem(row, k);
        }
    };
    projects.setSavePointerId(PageLinks.ADMIN_PROJECTS);

    add(projects);
}

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

License:Apache License

/**
 * Creates a closed complex disclosure panel for a patch set.
 * The patch set details are loaded when the complex disclosure panel is opened.
 *///w w w . j a va2s . com
public PatchSetComplexDisclosurePanel(final PatchSet ps, boolean isOpen, boolean hasDraftComments) {
    super(Util.M.patchSetHeader(ps.getPatchSetId()), isOpen);
    detailCache = ChangeCache.get(ps.getId().getParentKey()).getChangeDetailCache();
    changeDetail = detailCache.get();
    patchSet = ps;

    body = new FlowPanel();
    setContent(body);

    if (hasDraftComments) {
        final Image draftComments = new Image(Gerrit.RESOURCES.draftComments());
        draftComments.setTitle(Util.C.patchSetWithDraftCommentsToolTip());
        getHeader().add(draftComments);
    }

    final GitwebLink gw = Gerrit.getGitwebLink();
    final InlineLabel revtxt = new InlineLabel(ps.getRevision().get() + " ");
    revtxt.addStyleName(Gerrit.RESOURCES.css().patchSetRevision());
    getHeader().add(revtxt);
    if (gw != null && gw.canLink(ps)) {
        final Anchor revlink = new Anchor(gw.getLinkName(), false,
                gw.toRevision(changeDetail.getChange().getProject(), ps));
        revlink.addStyleName(Gerrit.RESOURCES.css().patchSetLink());
        getHeader().add(revlink);
    }

    if (ps.isDraft()) {
        final InlineLabel draftLabel = new InlineLabel(Util.C.draftPatchSetLabel());
        draftLabel.addStyleName(Gerrit.RESOURCES.css().patchSetRevision());
        getHeader().add(draftLabel);
    }

    if (isOpen) {
        ensureLoaded(changeDetail.getCurrentPatchSetDetail());
    } else {
        addOpenHandler(this);
    }

}

From source file:com.retech.reader.web.client.labs.Labs.java

License:Apache License

@Inject
Labs(final CellList.Resources resource, final PlaceController placeController, final Provider<BasePlace> base) {
    this.setWaveContent(binder.createAndBindUi(this));

    setColor.setChangeElm(simplePanel.getElement());

    minimize.setIconElement(//from   w w  w  .j ava2s . c  om
            AbstractImagePrototype.create(WaveTitleResources.image().waveTitleMinimize()).createElement());

    // add Data
    List<LabsIconDecorator> list = listDataProvider.getList();
    LabsIconDecorator touch = new LabsIconDecorator(bunder.laboratory(), "", WaveTest.class);
    list.add(touch);

    LabsIconDecorator flip = new LabsIconDecorator(bunder.laboratory(), "3D", BookFlip.class);
    list.add(flip);

    LabsIconDecorator contact = new LabsIconDecorator(bunder.laboratory(), "??",
            ContactPanel.class);
    list.add(contact);

    LabsIconDecorator treeTest = new LabsIconDecorator(bunder.laboratory(), "TreeTest", TreeTest.class);
    list.add(treeTest);

    LabsIconDecorator search = new LabsIconDecorator(bunder.laboratory(), "?", SearchPanel.class);
    list.add(search);

    LabsIconDecorator blipTest = new LabsIconDecorator(bunder.laboratory(), "BlipTest", BlipTest.class);
    list.add(blipTest);

    LabsIconDecorator blipTree = new LabsIconDecorator(bunder.laboratory(), "NestedBlipTest",
            NestedBlipTest.class);
    list.add(blipTree);

    LabsIconDecorator settingsView = new LabsIconDecorator(bunder.laboratory(), "", SettingsView.class);
    list.add(settingsView);

    LabsIconDecorator contactPanel = new LabsIconDecorator(bunder.laboratory(), "", ContactPanel.class);
    list.add(contactPanel);

    server.add(
            new Anchor("Android", "https://build.phonegap.com/apps/95095/download/android", "_blank"));
    server.add(
            new Anchor("iOS", "https://build.phonegap.com/apps/95095/download/ios", "_blank"));
    server.add(new Anchor("Google Play?",
            "https://play.google.com/store/apps/details?id=com.goodow.web.mobile", "_blank"));
    server.add(new Anchor("SCM - Subversion", SERVER_URL + "/svn/retech", "_blank"));
    server.add(new Anchor("Files", SERVER_URL + "/files", "_blank"));
    server.add(new Anchor("Document", SERVER_URL + "/svn/retech/document", "_blank"));
    server.add(new Anchor("CI - Hudson", SERVER_URL + ":8080", "_blank"));
    server.add(new Anchor("Repository - Nexus", SERVER_URL + ":8081/nexus", "_blank"));

    // add cell
    List<HasCell<LabsIconDecorator, ?>> hasCells = new ArrayList<HasCell<LabsIconDecorator, ?>>();
    hasCells.add(new HasCell<LabsIconDecorator, LabsIconDecorator>() {

        LabsIconDecoratorCell cell = new LabsIconDecoratorCell(
                new LabsIconDecoratorCell.Delegate<LabsIconDecorator>() {

                    @Override
                    public void execute(final LabsIconDecorator object) {
                        placeController.goTo(base.get().setPath(object.getClassName().getName()));
                    }
                });

        @Override
        public Cell<LabsIconDecorator> getCell() {
            return cell;
        }

        @Override
        public FieldUpdater<LabsIconDecorator, LabsIconDecorator> getFieldUpdater() {
            return null;
        }

        @Override
        public LabsIconDecorator getValue(final LabsIconDecorator object) {
            return object;
        }
    });

    hasCells.add(new HasCell<LabsIconDecorator, LabsIconDecorator>() {

        private TrangleButtonCell<LabsIconDecorator> tbc = new TrangleButtonCell<LabsIconDecorator>();

        @Override
        public Cell<LabsIconDecorator> getCell() {
            return tbc;
        }

        @Override
        public FieldUpdater<LabsIconDecorator, LabsIconDecorator> getFieldUpdater() {
            return null;
        }

        @Override
        public LabsIconDecorator getValue(final LabsIconDecorator object) {
            return object;
        }
    });

    compositeCell = new CompositeCell<LabsIconDecorator>(hasCells) {

        @Override
        public void render(final com.google.gwt.cell.client.Cell.Context context, final LabsIconDecorator value,
                final SafeHtmlBuilder sb) {
            super.render(context, value, sb);
        }

        @Override
        protected Element getContainerElement(final Element parent) {
            return parent;
        }

        @Override
        protected <X> void render(final com.google.gwt.cell.client.Cell.Context context,
                final LabsIconDecorator value, final SafeHtmlBuilder sb,
                final HasCell<LabsIconDecorator, X> hasCell) {
            Cell<X> cell = hasCell.getCell();
            cell.render(context, hasCell.getValue(value), sb);
        }
    };

    // add cellList
    cellList = new CellList<LabsIconDecorator>(compositeCell, resource);

    // add cellPreviewHanler
    cellList.addCellPreviewHandler(new CellPreviewEvent.Handler<LabsIconDecorator>() {

        @Override
        public void onCellPreview(final CellPreviewEvent<LabsIconDecorator> event) {
            NativeEvent nativeEvent = event.getNativeEvent();
            boolean isClick = nativeEvent.getType().equals(BrowserEvents.CLICK);
            if (isClick) {
                Element clickelm = cellList.getRowElement(event.getIndex());
                Element eventTarget = Element.as(nativeEvent.getEventTarget());
                if (clickelm.getFirstChildElement() == eventTarget) {
                    if (Labs.this.lastElm == null) {
                        Labs.this.lastElm = clickelm;
                    }
                    if (Labs.this.lastElm != clickelm) {
                        Labs.this.lastElm.removeClassName(LabsResources.css().cellListSelectionItem());
                        clickelm.addClassName(LabsResources.css().cellListSelectionItem());
                        Labs.this.lastElm = clickelm;
                    } else if (Labs.this.lastElm == clickelm) {
                        clickelm.addClassName(LabsResources.css().cellListSelectionItem());
                    }
                }
            }
        }
    });
    simplePanel.add(cellList);
}