List of usage examples for com.google.gwt.user.client.ui Image addMouseListener
@Deprecated public void addMouseListener(MouseListener listener)
From source file:com.xpn.xwiki.watch.client.ui.articles.ArticleListWidget.java
License:Open Source License
protected Widget getTagElementPanel(final FeedArticle article, final String tag, final FlowPanel tagsContainer, final HTML tagStatus) { FlowPanel p = new FlowPanel(); p.setStyleName(watch.getStyleName("article", "tag")); HorizontalPanel tagPanel = new HorizontalPanel(); Label tagName = new Label(tag); tagName.setStyleName(watch.getStyleName("article", "tag-name")); Image deleteAction = new Image(watch.getSkinFile((Constants.IMAGE_DELETE))); deleteAction.addMouseListener(new MouseListenerAdapter() { public void onMouseEnter(Widget sender) { ((Image) sender).setUrl(watch.getSkinFile(Constants.IMAGE_DELETE_ACTIVE)); }/*www . j a v a 2 s . c o m*/ public void onMouseLeave(Widget sender) { ((Image) sender).setUrl(watch.getSkinFile(Constants.IMAGE_DELETE)); } }); Image loadingImage = new Image(watch.getSkinFile(Constants.IMAGE_LOADING_SPINNER)); deleteAction.setTitle(watch.getTranslation("article.tag.remove.caption")); final LoadingWidget deleteTagWidget = new DefaultLoadingWidget(watch, deleteAction, loadingImage); deleteTagWidget.addStyleName(watch.getStyleName("article-tag-remove")); deleteAction.addClickListener(new ClickListener() { public void onClick(Widget w) { watch.getDataManager().removeTag(article, tag, new LoadingAsyncCallback(deleteTagWidget) { public void onSuccess(Object o) { super.onSuccess(o); // success - We need to refreshData the number of tags // Remove the tag from the list article.getTags().remove(tag); tagStatus.setHTML(getTagsStatusTitle(article)); refreshTagsContainer(tagsContainer, article, tagStatus); watch.refreshTagCloud(); } public void onFailure(Throwable t) { super.onFailure(t); } }); } }); tagPanel.add(tagName); tagPanel.add(deleteTagWidget); p.add(tagPanel); return p; }
From source file:gwtBlocks.client.views.WidgetFactory.java
License:Apache License
public static Image newIconButton(final String imageName, String tip, ClickListener listener) { Image.prefetch("gwtBlocks/images/iconButtonHoverBkg.jpg"); Image.prefetch("gwtBlocks/images/iconButtonDownBkg.jpg"); String simpleName = imageName.substring(imageName.lastIndexOf('/') + 1, imageName.lastIndexOf('.')); final Image icon = new Image(imageName); icon.setSize("20px", "20px"); icon.setStylePrimaryName("gbk-iconButton"); icon.addStyleDependentName(simpleName); icon.setTitle(tip);//from w w w . j a v a 2s.c o m if (listener != null) icon.addClickListener(listener); icon.addMouseListener(getIconMouseListener(simpleName)); return icon; }
From source file:gwtBlocks.client.views.WidgetFactory.java
License:Apache License
public static void enableIconButton(Image icon) { icon.removeMouseListener(getIconMouseListener(null)); // This is to avoid duplicate listners. icon.addMouseListener(getIconMouseListener(null)); icon.removeStyleName("disable"); int end = icon.getUrl().lastIndexOf("Off.gif"); if (end > -1) icon.setUrl(icon.getUrl().substring(0, end) + ".gif"); }
From source file:org.curriki.gwt.client.widgets.metadata.MetadataEdit.java
License:Open Source License
private void addCRS(Document doc, Panel panel, boolean isPrivate) { String role = Main.getProperty("role"); XObject crsObj = doc.getObject(Constants.CURRIKI_REVIEW_STATUS_CLASS); Integer reviewpending = (crsObj == null) ? null : (Integer) crsObj.get(Constants.CURRIKI_REVIEW_STATUS_REVIEWPENDING); String status = (crsObj == null) ? null : (String) crsObj.get(Constants.CURRIKI_REVIEW_STATUS_STATUS); currentCRSStatus = status;//w w w.j av a 2 s . com String lastReviewDate = (crsObj == null) ? "" : crsObj.getViewProperty(Constants.CURRIKI_REVIEW_STATUS_LASTTREVIEWDATE); FlowPanel crsPanel = new FlowPanel(); crsPanel.setStyleName("crs_review"); HTMLPanel crsPanelTitle = new HTMLPanel(Main.getTranslation("curriki.crs.currikireview")); crsPanelTitle.setStyleName("crs_reviewtitle"); crsPanel.add(crsPanelTitle); String txt = Main.getTranslation("curriki.crs.review.tooltip"); Image image = new Image(Constants.ICON_PATH + "exclamation.png"); PopupPanel popup = new PopupPanel(true); popup.setStyleName("metadata-tooltip-popup"); // popup.setWidth("300px"); popup.add(new HTML(txt)); image.addMouseListener(new TooltipMouseListener(popup)); crsPanel.add(image); FlowPanel crsRatingPanel = new FlowPanel(); crsRatingPanel.setStyleName("crs_reviewrating"); if ((status == null) || (status.equals("100")) || (status.equals(""))) { crsRatingPanel.setStyleName("crs_reviewnorating"); HTMLPanel crsRatingTextPanel = new HTMLPanel(Main.getTranslation("curriki.crs.unrated")); crsRatingTextPanel.setStyleName("crs_reviewratingtext"); crsRatingPanel.add(crsRatingTextPanel); } else { HTMLPanel crsRatingTextPanel = new HTMLPanel(Main.getTranslation("curriki.crs.rating" + status)); crsRatingTextPanel.setStyleName("crs_reviewratingtext"); crsRatingPanel.add(crsRatingTextPanel); if ((lastReviewDate != null) && (!lastReviewDate.equals(""))) { String sreviewDate = (lastReviewDate.length() >= 8) ? lastReviewDate.substring(0, 8) : lastReviewDate; HTMLPanel crsRatingDatePanel = new HTMLPanel( Main.getTranslation("curriki.crs.asof") + " " + sreviewDate); crsRatingDatePanel.setStyleName("crs_reviewratingdate"); crsRatingPanel.add(crsRatingDatePanel); } Image crsRatingImage = new Image(Constants.SKIN_PATH + "crs" + status + ".gif"); crsRatingImage.addClickListener(new ClickListener() { public void onClick(Widget widget) { ComponentsPage.getSingleton().switchPage("comment"); } }); crsRatingImage.setStyleName("crs_reviewratingtext"); crsRatingPanel.add(crsRatingImage); } crsPanel.add(crsRatingPanel); if (!"200".equals(status) && !isPrivate) { if ((reviewpending != null) && reviewpending.intValue() == 1) { HTMLPanel crsReviewPendingPanel = new HTMLPanel(Main.getTranslation("curriki.crs.reviewpending")); crsReviewPendingPanel.setStyleName("crs_reviewpending"); crsPanel.add(crsReviewPendingPanel); } else { Hyperlink crsReviewNominateLink = new Hyperlink(); crsReviewNominateLink.setHTML(Main.getTranslation("curriki.crs.reviewnominate")); crsReviewNominateLink.setStyleName("crs_reviewnominate"); crsReviewNominateLink.addClickListener(new ClickListener() { public void onClick(Widget widget) { Document currentAsset = Main.getSingleton().getEditor().getCurrentAsset(); new NominateDialog(currentAsset, new AsyncCallback() { public void onFailure(Throwable throwable) { // nothing to do this was a cancel } public void onSuccess(Object object) { // Refresh the page Editor editor = Main.getSingleton().getEditor(); editor.setCurrentAssetInvalid(true); editor.refreshState(); } }); // String url = Main.getTranslation("params.crs.nominateurl") + "?fromgwt=1&page=" + currentAsset.getFullName(); // Window.open(url, "_blank", ""); } }); crsPanel.add(crsReviewNominateLink); } // if the reviewer mode is set to one then we show the review link if (("reviewer".equals(role)) || ("admin".equals(role))) { Hyperlink crsReviewReviewLink = new Hyperlink(); crsReviewReviewLink.setHTML(Main.getTranslation("curriki.crs.review")); crsReviewReviewLink.setStyleName("crs_reviewreview"); crsReviewReviewLink.addClickListener(new ClickListener() { public void onClick(Widget widget) { Document currentAsset = Main.getSingleton().getEditor().getCurrentAsset(); String url = Main.getTranslation("params.crs.reviewurl") + "?page=" + currentAsset.getFullName(); Window.open(url, "_blank", ""); } }); crsPanel.add(crsReviewReviewLink); } } /* // We are not putting the set to partner button anymore in the CB // see CURRIKI-2781 if ("admin".equals(role)) { final CheckBox setToPCheckBox = new CheckBox(Main.getTranslation("curriki.crs.settopartner")); setToPCheckBox.setChecked("200".equals(currentCRSStatus)); setToPCheckBox.addClickListener(new ClickListener() { public void onClick(Widget widget) { String questionText; String titleText; if ("200".equals(currentCRSStatus)) { questionText = Main.getTranslation("curriki.crs.confirmunsettopartner"); titleText = "curriki.crs.unsettopartner"; } else { questionText = Main.getTranslation("curriki.crs.confirmsettopartner"); titleText = "curriki.crs.settopartner"; } ncDialog = new NextCancelDialog(titleText, questionText, "crsconfirmsettopartner", new AsyncCallback() { public void onFailure(Throwable throwable) { setToPCheckBox.setChecked("200".equals(currentCRSStatus)); ncDialog.hide(); } public void onSuccess(Object object) { Document currentAsset = Main.getSingleton().getEditor().getCurrentAsset(); final String newCRSStatus = "200".equals(currentCRSStatus) ? "100" : "200"; ncDialog.hide(); CurrikiService.App.getInstance().updateProperty(currentAsset.getFullName(), Constants.CURRIKI_REVIEW_STATUS_CLASS, "status", newCRSStatus, new CurrikiAsyncCallback() { public void onFailure(Throwable caught) { super.onFailure(caught); setToPCheckBox.setChecked("200".equals(currentCRSStatus)); } public void onSuccess(Object result) { super.onSuccess(result); setToPCheckBox.setChecked("200".equals(newCRSStatus)); currentCRSStatus = newCRSStatus; } }); } }); } }); crsPanel.add(setToPCheckBox); } */ panel.add(crsPanel); }
From source file:org.curriki.gwt.client.widgets.metadata.MetadataEdit.java
License:Open Source License
private Widget getTooltip(String name) { String txt = Main.getTranslation("metadata." + name + "_tooltip"); Image image = new Image(Constants.ICON_PATH + "exclamation.png"); PopupPanel popup = new PopupPanel(true); popup.setStyleName("metadata-tooltip-popup"); // popup.setWidth("300px"); popup.add(new HTML(txt)); image.addMouseListener(new TooltipMouseListener(popup)); return image; }
From source file:org.imb.client.RateItWidget.java
License:Open Source License
protected void setup() { final int colCount = grid.getColumnCount(); boolean ratingImages10 = ratingImages != null && ratingImages.length == 10; Image ratingImage = (ratingImages != null && ratingImages.length > 0) ? ratingImages[0] : normalImage; for (int i = 0; i < colCount; i++) { Image img; if (i == 0) { img = normalZeroImage;//from w ww . ja v a 2 s. co m } else if (i <= rating) { img = ratingImage; } else if (ratingImages10 && i < rating + 1) { int f = (int) ((rating - i + 1) * 10); if (f > 0) { img = ratingImages[f]; } else { img = normalImage; } } else { img = normalImage; } img.addMouseListener(new TooltipListener("your text", 5000, "yourcssclass")); final RatePanel panel = new RatePanel(i, img); panel.addMouseListener(cellMouseListener); panel.addClickListener(cellClickListener); grid.setWidget(0, i, panel); } }
From source file:org.pentaho.gwt.widgets.client.filechooser.FileChooser.java
License:Open Source License
public void initUI() { if (mode == FileChooserMode.OPEN_READ_ONLY) { fileNameTextBox.setReadOnly(true); }//from w ww. ja va 2 s . c om // We are here because we are initiating a fresh UI for a new directory // Since there is no file selected currently, we are setting file selected to false. setFileSelected(false); String path = this.selectedPath; // find the selected item from the list List<String> pathSegments = new ArrayList<String>(); if (path != null) { int index = path.indexOf("/", 0); //$NON-NLS-1$ while (index >= 0) { int oldIndex = index; index = path.indexOf("/", oldIndex + 1); //$NON-NLS-1$ if (index >= 0) { pathSegments.add(path.substring(oldIndex + 1, index)); } } pathSegments.add(path.substring(path.lastIndexOf("/") + 1)); //$NON-NLS-1$ } selectedTreeItem = getTreeItem(pathSegments); navigationListBox = new ListBox(); navigationListBox.getElement().setId("navigationListBox"); //$NON-NLS-1$ navigationListBox.setWidth("350px"); //$NON-NLS-1$ // now we can find the tree nodes who match the path segments navigationListBox.addItem("/", "/"); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < pathSegments.size(); i++) { String segment = pathSegments.get(i); String fullPath = ""; //$NON-NLS-1$ for (int j = 0; j <= i; j++) { String segmentPath = pathSegments.get(j); if (segmentPath != null && segmentPath.length() > 0) { fullPath += "/" + segmentPath; //$NON-NLS-1$ } } if (!fullPath.equals("/")) { //$NON-NLS-1$ navigationListBox.addItem(fullPath, segment); } } navigationListBox.setSelectedIndex(navigationListBox.getItemCount() - 1); navigationListBox.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { changeToPath(navigationListBox.getItemText(navigationListBox.getSelectedIndex())); } }); clear(); VerticalPanel locationBar = new VerticalPanel(); locationBar.add(new Label(FileChooserEntryPoint.messages.getString("location"))); //$NON-NLS-1$ HorizontalPanel navigationBar = new HorizontalPanel(); final Image upDirImage = new Image(); upDirImage.setUrl(GWT.getModuleBaseURL() + "images/spacer.gif"); //$NON-NLS-1$ upDirImage.addStyleName("pentaho-filechooseupbutton"); //$NON-NLS-1$ upDirImage.setTitle(FileChooserEntryPoint.messages.getString("upOneLevel")); //$NON-NLS-1$ upDirImage.addMouseListener(new MouseListener() { public void onMouseDown(Widget sender, int x, int y) { } public void onMouseEnter(Widget sender) { } public void onMouseLeave(Widget sender) { } public void onMouseMove(Widget sender, int x, int y) { } public void onMouseUp(Widget sender, int x, int y) { } }); upDirImage.addClickListener(new ClickListener() { public void onClick(Widget sender) { // go up a dir TreeItem tmpItem = selectedTreeItem; List<String> parentSegments = new ArrayList<String>(); while (tmpItem != null) { RepositoryFileTree tree = (RepositoryFileTree) tmpItem.getUserObject(); if (tree.getFile() != null && tree.getFile().getName() != null) { parentSegments.add(tree.getFile().getName()); } tmpItem = tmpItem.getParentItem(); } Collections.reverse(parentSegments); String myPath = ""; //$NON-NLS-1$ // If we have a file selected then we need to go one lesser level deep final int loopCount = isFileSelected() ? parentSegments.size() - 2 : parentSegments.size() - 1; for (int i = 0; i < loopCount; i++) { String pathSegment = parentSegments.get(i); if (pathSegment != null && pathSegment.length() > 0) { myPath += "/" + pathSegment; //$NON-NLS-1$ } } if (myPath.equals("")) { //$NON-NLS-1$ myPath = "/"; //$NON-NLS-1$ } selectedTreeItem = selectedTreeItem.getParentItem(); if (selectedTreeItem == null) { selectedTreeItem = repositoryTree.getItem(0); } changeToPath(myPath); } }); navigationBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); navigationBar.add(navigationListBox); navigationBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); navigationBar.add(upDirImage); navigationBar.setCellWidth(upDirImage, "100%"); //$NON-NLS-1$ DOM.setStyleAttribute(upDirImage.getElement(), "marginLeft", "4px"); navigationBar.setWidth("100%"); //$NON-NLS-1$ locationBar.add(navigationBar); locationBar.setWidth("100%"); //$NON-NLS-1$ Label filenameLabel = new Label(FileChooserEntryPoint.messages.getString("filename")); //$NON-NLS-1$ filenameLabel.setWidth("550px"); //$NON-NLS-1$ add(filenameLabel); fileNameTextBox.setWidth("300px"); //$NON-NLS-1$ add(fileNameTextBox); add(locationBar); add(buildFilesList(selectedTreeItem)); }