public UniTimeDialogBox(boolean autoHide, boolean modal) { super(autoHide, modal); setAnimationEnabled(true); setGlassEnabled(true); iContainer = new FlowPanel(); iContainer.addStyleName("dialogContainer"); iClose = new Anchor(); iClose.setTitle(MESSAGES.hintCloseDialog()); iClose.setStyleName("close"); iClose.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { onCloseClick(event); } }); iClose.setVisible(autoHide); iControls = new FlowPanel(); iControls.setStyleName("dialogControls"); iControls.add(iClose); }
@AfterInitialization public void afterInitialization() { authenticationServiceCaller.call(new RemoteCallback<User>() { @Override public void callback(User user) { Label userLabel = new Label( "User logged in: username=" + user.getIdentifier() + ", roles=" + user.getRoles()); RootPanel.get().add(userLabel); SimplePanel panel = new SimplePanel(); Anchor logoutLink = new Anchor("Spring Security Logout URL", GWT.getHostPageBaseURL() + "logout"); panel.add(logoutLink); RootPanel.get().add(panel); initBtns(); } }).getUser(); }
/** * Build the Anchor with target="_blank" * * @return Anchor */ public Anchor build() { final Anchor anchor = new Anchor(); if (image != null) { anchor.getElement().appendChild(image.getElement()); } if (text != null) { anchor.setText(text); } if (title != null) { anchor.setTitle(title); } if (bottomBorderOnMouseOver) { anchor.addMouseOverHandler(getMouseOverhandler(anchor)); anchor.addMouseOutHandler(getMouseOutHandler(anchor)); } anchor.setHref(href); anchor.setTarget("_blank"); return anchor; }
public Anchor buildClick() { Anchor anchor = new Anchor(); if (image != null) { anchor.getElement().appendChild(image.getElement()); } if (text != null) { anchor.setText(text); } if (title != null) { anchor.setTitle(title); } if (clickHandler != null) { anchor.addClickHandler(clickHandler); } return anchor; }
/** * Helper method to validify a hyperlink * @param link the GWT anchor object to validify * @param linktext the actual http link that the anchor should point to */ private void makeValidLink(Anchor link, String linktext) { if (linktext == null) { link.setText("N/A"); } else { if (linktext.isEmpty()) { link.setText("N/A"); } else { linktext = linktext.toLowerCase(); // Validate link format, fill in http part if (!linktext.startsWith("http")) { linktext = "http://" + linktext; } link.setText(linktext); link.setHref(linktext); link.setTarget("_blank"); } } }
/** * THe basic constructor * @param searchData the original search object with the pageIndex field indicating he currently selected page * @param pageIndex the page index is the index for which this page-index widget is created * @param isEnabled true to create the widget in the enabled mode, false in the disabled * @param siteSectionPrefix the history token site section prefix */ public PageIndexWidget( final ForumSearchData searchData, final int pageIndex, final boolean isEnabled, final String siteSectionPrefix ) { this.isCurrentPage = (searchData.pageIndex == pageIndex ); //Create a copy in order to be able to set the proper search object index and not spoil the original search object final ForumSearchData localSearchData = searchData.clone(); localSearchData.pageIndex = pageIndex; hyperLink = new Anchor("" + pageIndex, CommonResourcesContainer.URI_HASH_SYMBOL + siteSectionPrefix + localSearchData.serialize(encoder)); if( isCurrentPage ) { hyperLink.addStyleName( CommonResourcesContainer.CURRENT_PAGE_INDEX_STYLE ); //the current page index widget is always disabled setEnabled( false ); } else { //Set the link as enabled/disabled setEnabled( isEnabled ); } initWidget(hyperLink); }
@Override public void setEntity(Synonym synonym) { this.synonym = synonym; Term term = synonym.getTerm(); int row = 0; grid.setText(row++, 1, term.getOntology().getName()); if(UrlValidator.validate(term.getUrl())) { Anchor a = new Anchor(term.getName(), term.getUrl().trim()); a.setTarget("TermUrl"); grid.setWidget(row++, 1, a); } else { grid.setText(row++, 1, term.getName()); } grid.setText(row++, 1, synonym.getSynonym()); typeDropBox.setSelectedIndex(synonym.getType().ordinal()); }
FilterItem(E filterEntity, ImageResource imageRes, String bgClass, String text) { this.filterEntity = filterEntity; anchor = new Anchor(); add(anchor); Element span = DOM.createElement("span"); span.setInnerText(text); DOM.insertChild(anchor.getElement(), span, 0); span = DOM.createElement("span"); DOM.insertChild(anchor.getElement(), span, 0); span.addClassName(Utils.sandboxStyle.icon()); span.addClassName(Utils.sandboxStyle.fa()); if (bgClass != null) { Element b = DOM.createElement("b"); b.addClassName(bgClass); DOM.insertChild(span, b, 0); } if (imageRes != null) { Image image = new Image(imageRes); image.setTitle(text); DOM.insertChild(span, image.getElement(), 0); } }
public NavLinkBar() { getElement().setId("nav_bar_help_login"); loginLogoutLink = new Anchor(); loginLogoutLink.getElement().setId("nav_bar_help_login_item"); helpPanelToggleButton = new HelpSlidePanelToggleButton(); helpPanelToggleButton.getElement().setId("nav_bar_help_login_item"); helpBookButton = new HelpBookToggleButton(); helpBookButton.getElement().setId("nav_bar_help_login_item"); helpBalloonsToggleButton = new HelpDialogsToggleButton(); helpBalloonsToggleButton.getElement().setId("nav_bar_help_login_item"); FlexTable layout = new FlexTable(); layout.setWidget(0, 0, loginLogoutLink); layout.setWidget(0, 1, helpPanelToggleButton); layout.setWidget(0, 2, helpBookButton); layout.setWidget(0, 3, helpBalloonsToggleButton); layout.setWidget(0, 4, new HTML(HtmlConsts.TAB)); add(layout); }
private void appendChilds(TreeWidget rootEnt, JSONArray children) { for (int i = 0; i < children.size(); ++i) { nextEntityName = children.get(i).isString().stringValue(); Anchor a = new Anchor(nextEntityName + " (" + entities.get(nextEntityName).getLeft() + ")"); a.setWidth("100%"); a.setStyleName("font"); a.addClickHandler(new ClickHandler() { String name = nextEntityName; @Override public void onClick(ClickEvent event) { module.setSelectedEntity(name); } }); HorizontalPanel cPanel = new HorizontalPanel(); cPanel.setStyleName("tree"); cPanel.setWidth("100%"); cPanel.add(a); TreeWidget c = new TreeWidget(cPanel); rootEnt.addChild(c); if (children.size() > 0) appendChilds(c, entities.get(nextEntityName).getRight()); } }
private void generateTree(TreeWidget c, JSONValue entity) { nextEntityName = entity.isObject().get("entity").isString().stringValue(); Anchor a = new Anchor(nextEntityName); a.setWidth("100%"); a.setStyleName("font"); a.addClickHandler(new ClickHandler() { String name = nextEntityName; @Override public void onClick(ClickEvent event) { setSelectedEntity(name); } }); HorizontalPanel cPanel = new HorizontalPanel(); cPanel.setStyleName("tree"); cPanel.setWidth("100%"); cPanel.add(a); TreeWidget cc = new TreeWidget(cPanel); c.addChild(cc); results.put(nextEntityName, entity.isObject().get("results").isArray()); entities.add(nextEntityName); for (int i = 0; i < entity.isObject().get("children").isArray().size(); ++i) { generateTree(cc, entity.isObject().get("children").isArray().get(i)); } }
private void appendChilds(TreeWidget rootEnt, JSONArray children) { for (int i = 0; i < children.size(); ++i) { nextEntityName = children.get(i).isString().stringValue(); Anchor a = new Anchor(nextEntityName + " (" + entities.get(nextEntityName).getLeft() + ")"); a.setWidth("100%"); a.setStyleName("font"); a.addClickHandler(new ClickHandler() { String name = nextEntityName; @Override public void onClick(ClickEvent event) { setSelectedEntity(name); } }); HorizontalPanel cPanel = new HorizontalPanel(); cPanel.setStyleName("tree"); cPanel.setWidth("100%"); cPanel.add(a); TreeWidget c = new TreeWidget(cPanel); rootEnt.addChild(c); if (children.size() > 0) appendChilds(c, entities.get(nextEntityName).getRight()); } }
public AlertStackWidget() { alertWidgets = new ArrayList<AlertWidget>(); VerticalPanel rootPanel = new VerticalPanel(); rootPanel.setWidth("100%"); alertsPanel = new VerticalPanel(); alertsPanel.setWidth("100%"); rootPanel.add(alertsPanel); showHideAnchor = new Anchor( I18nUtils.tr(visible ? "hide.alerts" : "show.alerts")); showHideAnchor.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { visible = !visible; alertsPanel.setVisible(visible); showHideAnchor.setText( I18nUtils.tr(visible ? "hide.alerts" : "show.alerts")); } }); showHideAnchor.addStyleName("alert-showhide-link"); showHideAnchor.setVisible(false); rootPanel.add(showHideAnchor); initWidget(rootPanel); }
protected void populate(int row, DashboardInfo k) { if (k.isDefault()) { table.setWidget(row, 1, new Image(Gerrit.RESOURCES.greenCheck())); final FlexCellFormatter fmt = table.getFlexCellFormatter(); fmt.getElement(row, 1).setTitle(Util.C.dashboardDefaultToolTip()); } table.setWidget( row, 2, new Anchor( k.path(), "#" + PageLinks.toProjectDashboard(new Project.NameKey(k.project()), k.id()))); table.setText(row, 3, k.title() != null ? k.title() : k.path()); table.setText(row, 4, k.description()); if (k.definingProject() != null && !k.definingProject().equals(k.project())) { table.setWidget( row, 5, new Anchor( k.definingProject(), "#" + PageLinks.toProjectDashboards(new Project.NameKey(k.definingProject())))); } setRowItem(row, k); }
private static Anchor toAnchor(WebLinkInfoCommon info) { Anchor a = new Anchor(); a.setHref(info.url); if (info.target != null && !info.target.isEmpty()) { a.setTarget(info.target); } if (info.imageUrl != null && !info.imageUrl.isEmpty()) { Image img = new Image(); img.setAltText(info.name); img.setUrl(info.imageUrl); img.setTitle(info.name); a.getElement().appendChild(img.getElement()); } else { a.setText("(" + info.name + ")"); } return a; }
void setUpBlame(final CodeMirror cm, boolean isBase, PatchSet.Id rev, String path) { if (!Patch.isMagic(path) && Gerrit.isSignedIn() && Gerrit.info().change().allowBlame()) { Anchor blameIcon = createBlameIcon(); blameIcon.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { if (cm.extras().getBlameInfo() != null) { cm.extras().toggleAnnotation(); } else { ChangeApi.blame(Project.NameKey.asStringOrNull(project), rev, path, isBase) .get( new GerritCallback<JsArray<BlameInfo>>() { @Override public void onSuccess(JsArray<BlameInfo> lines) { cm.extras().toggleAnnotation(lines); } }); } } }); linkPanel.add(blameIcon); } }
SkipBar(SkipManager manager, CodeMirror cm) { this.manager = manager; this.cm = cm; skipNum = new Anchor(true); upArrow = new Anchor(true); downArrow = new Anchor(true); initWidget(uiBinder.createAndBindUi(this)); addDomHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { cm.focus(); } }, ClickEvent.getType()); }
void addOne(AgreementInfo info) { int row = table.getRowCount(); table.insertRow(row); applyDataRowStyle(row); String url = info.url(); if (url != null && url.length() > 0) { Anchor a = new Anchor(info.name(), url); a.setTarget("_blank"); table.setWidget(row, 1, a); } else { table.setText(row, 1, info.name()); } table.setText(row, 2, info.description()); FlexCellFormatter fmt = table.getFlexCellFormatter(); for (int c = 1; c < 3; c++) { fmt.addStyleName(row, c, Gerrit.RESOURCES.css().dataCell()); } }
private static void addExtensionLink(LinkMenuBar m, TopMenuItem item) { if (item.getUrl().startsWith("#") && (item.getTarget() == null || item.getTarget().isEmpty())) { LinkMenuItem a = new LinkMenuItem(item.getName(), item.getUrl().substring(1)); if (item.getId() != null) { a.getElement().setAttribute("id", item.getId()); } m.addItem(a); } else { Anchor atag = anchor( item.getName(), isAbsolute(item.getUrl()) ? item.getUrl() : selfRedirect(item.getUrl())); if (item.getTarget() != null && !item.getTarget().isEmpty()) { atag.setTarget(item.getTarget()); } if (item.getId() != null) { atag.getElement().setAttribute("id", item.getId()); } m.add(atag); } }
public final Anchor toAnchor() { Anchor a = new Anchor(); a.setHref(url()); if (target() != null && !target().isEmpty()) { a.setTarget(target()); } if (imageUrl() != null && !imageUrl().isEmpty()) { Image img = new Image(); img.setAltText(name()); img.setUrl(imageUrl()); img.setTitle(name()); a.getElement().appendChild(img.getElement()); } else { a.setText("(" + name() + ")"); } return a; }
protected void updateRuneLabel(Anchor label, ListBox skills, ListBox runes) { ActiveSkill skill = ActiveSkill.SENTRY; if (skills != null) skill = this.getSkill(skills); if (skill != null) { Rune rune = getRune(runes); label.setTarget("_blank"); if ((rune != null) && (rune != Rune.None)) label.setHref(skill.getUrl() + "#" + rune.getSlug() + "+"); else label.setHref(skill.getUrl()); } else { label.setHref("javascript:void(0)"); label.setTarget("_self"); } }
public void updateLabels() { for (Slot s : Slot.values()) if (!s.isCube()) { final Anchor label = labels.get(s); ItemHolder item = items.get(s); if (item != null) { String url = "http://us.battle.net/d3/en/itemData/" + item.getTooltip(); label.setHref(url); item.getInfo(new DefaultCallback<ItemInformation>(){ @Override protected void doOnSuccess(ItemInformation result) { label.setText(result.name); } }); } else { label.setHref("javascript:void(0)"); label.setText("Empty"); } } }
private void setRunes(Anchor anchor2, ListBox list2, ActiveSkill skill) { list2.clear(); if (skill != null) { for (Rune r : skill.getRunes()) { list2.addItem(r.getLongName(), r.name()); } } else { list2.addItem("None", Rune.None.name()); } list2.setSelectedIndex(0); setRuneAnchor(skill, anchor2, Rune.None); }
private void selectRune(ActiveSkill skill, Anchor anchor2, ListBox list2, Rune rune) { if (rune == null) { list2.setSelectedIndex(0); } else { int n = list2.getItemCount(); for (int i = 0; i < n; i++) { String value = list2.getValue(i); if (value.equals(rune.name())) { list2.setSelectedIndex(i); break; } } } this.setRuneAnchor(skill, anchor2, rune); }
private void selectSkill(Anchor anchor, ListBox list, ActiveSkill skill, Anchor anchor2, ListBox list2) { if (skill == null) { list.setSelectedIndex(0); } else { int n = list.getItemCount(); for (int i = 0; i < n; i++) { String value = list.getValue(i); if (value.equals(skill.name())) { list.setSelectedIndex(i); break; } } } this.setSkillAnchor(anchor, skill); this.setRunes(anchor2, list2, skill); }
public void createView() { table = new FlexTable(); createButton = new Image( "images/add.png" ); companyButton = new Anchor( "Go to company" ); infoButton = new Anchor( "Info" ); passiveInfoButton = new Anchor( "Passive Info" ); VerticalPanel mainPanel = new VerticalPanel(); mainPanel.add( table ); mainPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_RIGHT ); mainPanel.add( createButton ); mainPanel.add( companyButton ); mainPanel.add( infoButton ); mainPanel.add( passiveInfoButton ); setWidget( mainPanel ); }
@Override public void onClick(ClickEvent event) { Anchor tag = (Anchor)event.getSource(); tags.remove(tag); container.remove(tag); valueTags.remove(tag.getText()); saisiTag.setFocus(true); fireEvent(new TagEvent(tag.getText()) { @Override protected void dispatch(TagEventHandler handler) { handler.onRemove(this); } }); }
private void createDownloadImage(boolean withBg) { if(selection==null){ return; } downloadArea.clear(); updateCanvas(withBg);//anway bg blob=Blob.createBase64Blob(canvas.toDataUrl(),"image/png");//for IE keep blob Anchor a=null; if(GWTUtils.isIE()){ a=HTML5Download.get().generateDownloadLink(blob, "image/png","gridPaint.png", textConstants.RightClickAndSaveAs(),false); //a.setTitle("to download right mouse button to show contextmenu and select save as by yourself"); }else{ //TODO support ios a=HTML5Download.get().generateDownloadLink(blob, "image/png","transparent.png", textConstants.Download_Image(),true); } a.setStylePrimaryName("bt"); downloadArea.add(a); updateCanvas(false);//clear invalid }
protected void generateImage() { int clipSX=(canvasWidth-imageWidth)/2; int clipSY=(canvasHeight-imageHeight)/2; int clipEX=clipSX+imageWidth; int clipEY=clipSY+imageHeight; ImageData data=canvas.getContext2d().getImageData(clipSX, clipSY, clipEX-clipSX, clipEY-clipSY); CanvasUtils.createCanvas(drawCanvas, data); String type=typeBox.getValue(); String dataUrl=drawCanvas.toDataUrl("image/"+type); String extension=type.equals("jpeg")?"jpg":type; String name=titleBox.getText().isEmpty()?"logo":titleBox.getText(); Anchor anchor=HTML5Download.get().generateBase64DownloadLink(dataUrl, "image/"+type, name+"."+extension, textConstants.Download(), true); anchor.setStylePrimaryName("bt"); downloadArea.clear(); downloadArea.add(anchor); }
/** * @see com.google.gwt.user.client.ui.HasValue#setValue(java.lang.Object, boolean) * * <div class="sitwatch-event"> * <div class="icon icon-severity-critical"></div> * <a class="title" href="#">Rate Limit Exceeded</a> * <span class="timestamp">9:16 AM</span> * <span class="subject">{urn:namespace}ImportantService|VeryImportantOperation</span> * </div> */ @Override public void setValue(SituationEventBean value, boolean fireEvents) { clear(); FlowPanel icon = new FlowPanel(); icon.setStyleName("icon"); //$NON-NLS-1$ icon.addStyleName("icon-severity-" + value.getSeverity()); //$NON-NLS-1$ Anchor type = toDetailsPageLinkFactory.get("id", value.getSituationId()); //$NON-NLS-1$ type.setText(value.getType()); type.setStyleName("title"); //$NON-NLS-1$ InlineLabel timestamp = new InlineLabel(ClientMessages.getTimeFormat().format(value.getTimestamp())); timestamp.setStyleName("timestamp"); //$NON-NLS-1$ InlineLabel subject = new InlineLabel(value.getSubject()); subject.setStyleName("subject"); //$NON-NLS-1$ add(icon); add(type); add(timestamp); add(subject); }
/** * Adds a single row to the table. * @param situationSummaryBean */ public void addRow(final SituationSummaryBean situationSummaryBean) { int rowIdx = this.rowElements.size(); DateTimeFormat format = DateTimeFormat.getFormat(i18n.format("dateTime-format")); //$NON-NLS-1$ FlowPanel icon = new FlowPanel(); icon.getElement().setClassName("icon"); //$NON-NLS-1$ icon.getElement().addClassName("icon-severity-" + situationSummaryBean.getSeverity()); //$NON-NLS-1$ Anchor type = toDetailsPageLinkFactory.get("id", situationSummaryBean.getSituationId()); //$NON-NLS-1$ type.setText(situationSummaryBean.getType()); InlineLabel resolutionState = new InlineLabel(situationSummaryBean.getResolutionState()); InlineLabel subject = new InlineLabel(situationSummaryBean.getSubject()); InlineLabel description = new InlineLabel(situationSummaryBean.getDescription()); InlineLabel timestamp = new InlineLabel(format.format(situationSummaryBean.getTimestamp())); Widget infoIcons = createInfoPanel(situationSummaryBean); add(rowIdx, 0, icon); add(rowIdx, 1, type); add(rowIdx, 2, resolutionState); add(rowIdx, 3, subject); add(rowIdx, 4, timestamp); add(rowIdx, 5, description); add(rowIdx, 6, infoIcons); }
private void updateBugSection() { bugGrid.resize(capabilityBugs.size() + 1, 1); bugGrid.setTitle("Bugs (" + capabilityBugs.size() + " total)"); bugGrid.setWidget(0, 0, buildBugHeaderWidget("Bugs (" + capabilityBugs.size() + " total)", "add bug")); for (int i = 0; i < capabilityBugs.size(); i++) { Bug bug = capabilityBugs.get(i); HorizontalPanel panel = new HorizontalPanel(); panel.add(getBugStateImage(bug.getState())); Anchor anchor = new Anchor(bug.getLinkText(), bug.getLinkUrl()); anchor.setTarget("_blank"); panel.add(anchor); Label statusLabel = new Label(); statusLabel.setText(" - filed " + getDateText(bug.getStateDate())); panel.add(statusLabel); bugGrid.setWidget(i + 1, 0, panel); } }
@Override public Widget onClick(CapabilityIntersectionData targetCell) { VerticalPanel checkinsPanel = new VerticalPanel(); Set<Checkin> relevantCheckins = getCheckinsRealtedToRiskCell(targetCell); if (relevantCheckins.size() == 0) { checkinsPanel.add(new Label("No checkins are associated with this cell.")); } else { for (Checkin checkin : relevantCheckins) { String linkText = Long.toString(checkin.getExternalId()) + ": " + checkin.getSummary(); // Display only 100 characters of a checkin summary. if (linkText.length() > 100) { linkText = linkText.substring(0, 97) + "..."; } checkinsPanel.add(new Anchor(linkText, checkin.getChangeUrl())); } } return checkinsPanel; }
private void createLuckyTwitterButton() { Anchor rndWikiButton = Anchor.wrap(Document.get().getElementById("btn_rnd_twitter")); final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text")); rndWikiButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { wcService.getRandomTwitterUrl(new AsyncCallback<String>() { public void onSuccess(String result) { textArea.setText(result); } public void onFailure(Throwable caught) { textArea.setText("twitter: hot trend"); } }); } }); }
private void createLuckyYoutubeButton() { Anchor rndWikiButton = Anchor.wrap(Document.get().getElementById("btn_rnd_youtube")); final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text")); rndWikiButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { wcService.getRandomYoutubeUrl(new AsyncCallback<String>() { public void onSuccess(String result) { textArea.setText(result); } public void onFailure(Throwable caught) { textArea.setText("https://www.youtube.com"); } }); } }); }
private void createLuckyGoogleButton() { Anchor rndGoogleButton = Anchor.wrap(Document.get().getElementById("btn_rnd_google")); final TextArea textArea = TextArea.wrap(Document.get().getElementById("input_text")); rndGoogleButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { wcService.getRandomGoogleUrl(new AsyncCallback<String>() { public void onSuccess(String result) { textArea.setText(result); } public void onFailure(Throwable caught) { textArea.setText("google: hot trend"); } }); } }); }