Java Code Examples for com.google.gwt.user.client.ui.Anchor

The following are top voted examples for showing how to use com.google.gwt.user.client.ui.Anchor. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: unitimes   File: UniTimeDialogBox.java   Source Code and License 7 votes vote down vote up
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);
  }
 
Example 2
Project: errai-spring-boot-sample   File: App.java   Source Code and License 6 votes vote down vote up
@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();
}
 
Example 3
Project: sig-seguimiento-vehiculos   File: AnchorBuilder.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Project: sig-seguimiento-vehiculos   File: AnchorBuilder.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 5
Project: appinventor-extensions   File: ProfilePage.java   Source Code and License 6 votes vote down vote up
/**
 * 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");
    }
  }
}
 
Example 6
Project: x-cure-chat   File: PageIndexWidget.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 7
Project: ontobrowser   File: EditSynonymPopup.java   Source Code and License 6 votes vote down vote up
@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());
	
}
 
Example 8
Project: sandbox-frame   File: FilterPanel.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 9
Project: aggregate   File: NavLinkBar.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 10
Project: mgwt-traffic-flow   File: AboutViewGwtImpl.java   Source Code and License 6 votes vote down vote up
public AboutViewGwtImpl() {
    String appVersion = Consts.APP_VERSION;
    String mailTo = "mailto:[email protected]?subject=Traffic Flow ";
    email = new Anchor();

	initWidget(uiBinder.createAndBindUi(this));

       if (MGWT.getOsDetection().isAndroid()) {
           leftFlexSpacer.setVisible(false);
           scrollPanel.setBounce(false);
           email.setHref(mailTo + "Android App v" + appVersion);
       } else if (MGWT.getOsDetection().isIOs()) {
           email.setHref(mailTo + "iPhone App v" + appVersion);
       } else {
           email.setHref(mailTo + "Mobile App v" + appVersion);
       }

}
 
Example 11
Project: riscoss-corporate   File: EntitiesListBox.java   Source Code and License 6 votes vote down vote up
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());
	}
}
 
Example 12
Project: riscoss-corporate   File: RiskAnalysisResults.java   Source Code and License 6 votes vote down vote up
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));
	}
}
 
Example 13
Project: riscoss-corporate   File: RiskAnalysisWizard.java   Source Code and License 6 votes vote down vote up
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());
	}
}
 
Example 14
Project: geowe-core   File: AnchorBuilder.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 15
Project: geowe-core   File: AnchorBuilder.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 16
Project: OpenTripPlanner-client-gwt   File: AlertStackWidget.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 17
Project: gerrit   File: DashboardsTable.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 18
Project: gerrit   File: ProjectAccessEditor.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 19
Project: gerrit   File: PatchSetSelectBox.java   Source Code and License 6 votes vote down vote up
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);
  }
}
 
Example 20
Project: gerrit   File: SkipBar.java   Source Code and License 6 votes vote down vote up
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());
}
 
Example 21
Project: gerrit   File: MyAgreementsScreen.java   Source Code and License 6 votes vote down vote up
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());
  }
}
 
Example 22
Project: gerrit   File: Gerrit.java   Source Code and License 6 votes vote down vote up
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);
  }
}
 
Example 23
Project: gerrit   File: WebLinkInfo.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 24
Project: unitime   File: UniTimeDialogBox.java   Source Code and License 6 votes vote down vote up
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);
  }
 
Example 25
Project: dhcalc   File: MainPanel.java   Source Code and License 6 votes vote down vote up
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");
		}

	}
 
Example 26
Project: dhcalc   File: GearPanel.java   Source Code and License 6 votes vote down vote up
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");
		}
	}
}
 
Example 27
Project: dhcalc   File: SkillsPanel.java   Source Code and License 6 votes vote down vote up
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);
	}
 
Example 28
Project: dhcalc   File: SkillsPanel.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 29
Project: dhcalc   File: SkillsPanel.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 30
Project: mvp4g-examples   File: ProductListView.java   Source Code and License 6 votes vote down vote up
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 );
}
 
Example 31
Project: yaph   File: TagsWidget.java   Source Code and License 6 votes vote down vote up
@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);
		}
	});
	
}
 
Example 32
Project: gwthtml5apps   File: TransparentIt.java   Source Code and License 6 votes vote down vote up
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
}
 
Example 33
Project: gwthtml5apps   File: SimpleLogo.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 34
Project: rtgov-ui   File: SituationWatcherEvent.java   Source Code and License 6 votes vote down vote up
/**
 * @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);
}
 
Example 35
Project: rtgov-ui   File: SituationTable.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 36
Project: test-analytics-ng   File: CapabilityDetailsViewImpl.java   Source Code and License 6 votes vote down vote up
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);
  }
}
 
Example 37
Project: test-analytics-ng   File: CodeChurnRiskProvider.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 38
Project: swcv   File: WordCloudApp.java   Source Code and License 6 votes vote down vote up
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");
                }
            });

        }
    });
}
 
Example 39
Project: swcv   File: WordCloudApp.java   Source Code and License 6 votes vote down vote up
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");
                }
            });

        }
    });
}
 
Example 40
Project: swcv   File: WordCloudApp.java   Source Code and License 6 votes vote down vote up
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");
                }
            });

        }
    });
}