List of usage examples for com.google.gwt.user.client.ui Label addClickHandler
public HandlerRegistration addClickHandler(ClickHandler handler)
From source file:org.eurekastreams.web.client.ui.pages.discover.DiscoverListItemPanel.java
License:Apache License
/** * Constructor./*from w ww . j a v a 2s. c o m*/ * * @param inStreamDTO * the streamDTO to represent * @param inListItemType * list item type * @param showBlockSuggestion * show block suggestion controls. */ public DiscoverListItemPanel(final StreamDTO inStreamDTO, final ListItemType inListItemType, final boolean showBlockSuggestion) { coreCss = StaticResourceBundle.INSTANCE.coreCss(); HTMLPanel main = (HTMLPanel) binder.createAndBindUi(this); initWidget(main); // set text and link for name; assume group if not person Page linkPage = (inStreamDTO.getEntityType() == EntityType.PERSON) ? Page.PEOPLE : Page.GROUPS; String nameUrl = Session.getInstance().generateUrl(// new CreateUrlRequest(linkPage, inStreamDTO.getUniqueId())); streamNameLink.setTargetHistoryToken(nameUrl); streamNameLink.setText(inStreamDTO.getDisplayName()); streamNameLink.setTitle(inStreamDTO.getDisplayName()); // set info text switch (inListItemType) { case MUTUAL_FOLLOWERS: if (inStreamDTO.getFollowersCount() == 1) { streamInfoText.setInnerText("1 Mutual Follower"); } else { streamInfoText .setInnerText(Integer.toString(inStreamDTO.getFollowersCount()) + " Mutual Followers"); } break; case DAILY_VIEWERS: if (inStreamDTO.getFollowersCount() == 1) { streamInfoText.setInnerText("1 Daily Viewer"); } else { streamInfoText.setInnerText(Integer.toString(inStreamDTO.getFollowersCount()) + " Daily Viewers"); } break; case FOLLOWERS: if (inStreamDTO.getFollowersCount() == 1) { streamInfoText.setInnerText("1 Follower"); } else { streamInfoText.setInnerText(Integer.toString(inStreamDTO.getFollowersCount()) + " Followers"); } break; case TIME_AGO: DateFormatter dateFormatter = new DateFormatter(new Date()); streamInfoText.setInnerText(dateFormatter.timeAgo(inStreamDTO.getDateAdded(), true)); break; default: break; } // add following controls if not the current person if (inStreamDTO.getEntityType() != EntityType.PERSON || inStreamDTO.getEntityId() != Session.getInstance().getCurrentPerson().getEntityId()) { final FollowPanel followPanel; ClickHandler clickHandler = null; if (showBlockSuggestion) { // NOTE: this is a hack - this doesn't have anything to do with blocking suggestions, it just happens // that the only list that removes streams after joining them happens to be the one that allows streams // to be blocked clickHandler = new ClickHandler() { public void onClick(final ClickEvent event) { removeFromParent(); } }; } // it's not the current user - see if it's a private group, and if we're not admin if (inStreamDTO.getEntityType() == EntityType.GROUP && inStreamDTO instanceof DomainGroupModelView && ((DomainGroupModelView) inStreamDTO).isPublic() != null && !((DomainGroupModelView) inStreamDTO).isPublic() && !Session.getInstance().getCurrentPerson().getRoles().contains(Role.SYSTEM_ADMIN)) { // this is a private group and we're not an admin, so we gotta request access // note: no click handler since you can't join this group - just show it as pending followPanel = new FollowPanel(inStreamDTO, style.requestButton(), style.unfollowButton(), coreCss.buttonLabel(), true, style.pendingButton()); } else { // either not a private group, or we're admin and it doesn't matter - just show join/unjoin followPanel = new FollowPanel(inStreamDTO, style.followButton(), style.unfollowButton(), coreCss.buttonLabel(), true, clickHandler, null); } if (!showBlockSuggestion) { followPanel.addStyleName(style.followControlsPanel()); main.add(followPanel); } else { Panel panel = new FlowPanel(); panel.addStyleName(style.followControlsPanel()); panel.addStyleName(style.multi()); panel.add(followPanel); final Label block = new Label(); block.addStyleName(style.blockButton()); block.setTitle("Block this suggestion"); block.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { if (jsniFacade.confirm("Are you sure you want to block this suggestion?")) { BlockedSuggestionModel.getInstance().insert(inStreamDTO.getStreamScopeId()); removeFromParent(); } } }); panel.add(block); main.add(panel); } } }
From source file:org.eurekastreams.web.client.ui.pages.profile.settings.EducationListPanel.java
License:Apache License
/** * default constructor./* w w w. j a v a 2 s . co m*/ * * @param inPageHistoryToken * the page history token. */ public EducationListPanel(final String inPageHistoryToken) { pageHistoryToken = inPageHistoryToken; final Label addNewSchool = new Label("Add school"); addNewSchool.addStyleName(StaticResourceBundle.INSTANCE.coreCss().linkedLabel()); addSchool.add(addNewSchool); addSchool.addStyleName(StaticResourceBundle.INSTANCE.coreCss().addNewBackground()); Session.getInstance().getEventBus().addObserver(GotPersonalEducationResponseEvent.class, new Observer<GotPersonalEducationResponseEvent>() { public void update(final GotPersonalEducationResponseEvent event) { panel.clear(); panel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().personalSettingsBackground()); Label title = new Label("Education"); title.addStyleName(StaticResourceBundle.INSTANCE.coreCss().title()); panel.add(title); for (Enrollment enrollment : event.getResponse()) { panel.add(new EducationPanel(enrollment, pageHistoryToken)); } addSchool.setVisible(true); panel.add(addSchool); createEducationPanel = new CreateOrUpdateEducationPanel(null, pageHistoryToken); createEducationPanel.setVisible(false); panel.add(createEducationPanel); addNewSchool.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { createEducationPanel.setVisible(true); createEducationPanel.clearData(); addSchool.setVisible(false); } }); } }); Session.getInstance().getEventBus().addObserver(InsertedPersonalEducationResponseEvent.class, new Observer<InsertedPersonalEducationResponseEvent>() { public void update(final InsertedPersonalEducationResponseEvent arg1) { Session.getInstance().getEventBus().notifyObservers( new ShowNotificationEvent(new Notification("Your School has been created"))); createEducationPanel.setVisible(false); addSchool.setVisible(true); PersonalEducationModel.getInstance().fetch(Session.getInstance().getCurrentPerson().getId(), true); } }); Session.getInstance().getEventBus().addObserver(UpdatedPersonalEducationResponseEvent.class, new Observer<UpdatedPersonalEducationResponseEvent>() { public void update(final UpdatedPersonalEducationResponseEvent arg1) { Session.getInstance().getEventBus().notifyObservers( new ShowNotificationEvent(new Notification("Your School has been saved"))); PersonalEducationModel.getInstance().fetch(Session.getInstance().getCurrentPerson().getId(), true); } }); Session.getInstance().getEventBus().addObserver(DeletedPersonalEducationResponseEvent.class, new Observer<DeletedPersonalEducationResponseEvent>() { public void update(final DeletedPersonalEducationResponseEvent arg1) { Session.getInstance().getEventBus().notifyObservers( new ShowNotificationEvent(new Notification("Your School has been deleted"))); PersonalEducationModel.getInstance().fetch(Session.getInstance().getCurrentPerson().getId(), true); } }); Session.getInstance().getEventBus().addObserver(BackgroundEducationAddCanceledEvent.class, new Observer<BackgroundEducationAddCanceledEvent>() { public void update(final BackgroundEducationAddCanceledEvent arg1) { createEducationPanel.setVisible(false); addSchool.setVisible(true); } }); this.add(panel); PersonalEducationModel.getInstance().fetch(Session.getInstance().getCurrentPerson().getId(), true); }
From source file:org.eurekastreams.web.client.ui.pages.profile.settings.EmploymentListPanel.java
License:Apache License
/** * default constructor./*from w ww. j a v a 2 s . co m*/ * * @param inPageHistoryToken * The page history token. */ public EmploymentListPanel(final String inPageHistoryToken) { pageHistoryToken = inPageHistoryToken; final Label addNewPosition = new Label("Add position"); addNewPosition.addStyleName(StaticResourceBundle.INSTANCE.coreCss().linkedLabel()); addPosition.add(addNewPosition); addPosition.addStyleName(StaticResourceBundle.INSTANCE.coreCss().addNewBackground()); Session.getInstance().getEventBus().addObserver(GotPersonalEmploymentResponseEvent.class, new Observer<GotPersonalEmploymentResponseEvent>() { public void update(final GotPersonalEmploymentResponseEvent event) { panel.clear(); panel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().personalSettingsBackground()); Label title = new Label("Work History"); title.addStyleName(StaticResourceBundle.INSTANCE.coreCss().title()); panel.add(title); for (Job job : event.getResponse()) { panel.add(new EmploymentPanel(job, pageHistoryToken)); } addPosition.setVisible(true); panel.add(addPosition); createEmploymentPanel = new CreateOrUpdateEmploymentPanel(null, pageHistoryToken); createEmploymentPanel.setVisible(false); panel.add(createEmploymentPanel); addNewPosition.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { createEmploymentPanel.setVisible(true); createEmploymentPanel.clearData(); addPosition.setVisible(false); } }); } }); Session.getInstance().getEventBus().addObserver(InsertedPersonalEmploymentResponseEvent.class, new Observer<InsertedPersonalEmploymentResponseEvent>() { public void update(final InsertedPersonalEmploymentResponseEvent arg1) { Session.getInstance().getEventBus().notifyObservers( new ShowNotificationEvent(new Notification("Your Position has been created"))); createEmploymentPanel.setVisible(false); addPosition.setVisible(true); PersonalEmploymentModel.getInstance() .fetch(Session.getInstance().getCurrentPerson().getId(), true); } }); Session.getInstance().getEventBus().addObserver(UpdatedPersonalEmploymentResponseEvent.class, new Observer<UpdatedPersonalEmploymentResponseEvent>() { public void update(final UpdatedPersonalEmploymentResponseEvent arg1) { Session.getInstance().getEventBus().notifyObservers( new ShowNotificationEvent(new Notification("Your Position has been saved"))); PersonalEmploymentModel.getInstance() .fetch(Session.getInstance().getCurrentPerson().getId(), true); } }); Session.getInstance().getEventBus().addObserver(DeletedPersonalEmploymentResponseEvent.class, new Observer<DeletedPersonalEmploymentResponseEvent>() { public void update(final DeletedPersonalEmploymentResponseEvent arg1) { Session.getInstance().getEventBus().notifyObservers( new ShowNotificationEvent(new Notification("Your Position has been deleted"))); PersonalEmploymentModel.getInstance() .fetch(Session.getInstance().getCurrentPerson().getId(), true); } }); Session.getInstance().getEventBus().addObserver(BackgroundEmploymentAddCanceledEvent.class, new Observer<BackgroundEmploymentAddCanceledEvent>() { public void update(final BackgroundEmploymentAddCanceledEvent arg1) { createEmploymentPanel.setVisible(false); addPosition.setVisible(true); } }); this.add(panel); PersonalEmploymentModel.getInstance().fetch(Session.getInstance().getCurrentPerson().getId(), true); }
From source file:org.eurekastreams.web.client.ui.pages.profile.settings.stream.StreamPluginsSettingsTabContent.java
License:Apache License
/** * Renders the plugins.//from w w w. ja va 2 s .com */ public void renderPlugins() { availablePluginsContainer.clear(); Label availablePluginsHeader = new Label("Available Plugins"); availablePluginsHeader.addStyleName(StaticResourceBundle.INSTANCE.coreCss().header()); availablePluginsContainer.add(availablePluginsHeader); if (availablePlugins.size() > 0) { availablePluginsMetaData.clear(); for (PluginDefinition availablePlugin : availablePlugins) { availablePluginsMetaData.add(getMetaDataForPlugin(availablePlugin)); } sortPluginsMetaData(); for (final GadgetMetaDataDTO metaDataItem : availablePluginsMetaData) { FlowPanel filterPanel = new FlowPanel(); filterPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().filter()); FlowPanel listItemPanel = new FlowPanel(); listItemPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().streamListItem()); FlowPanel labelContainer = new FlowPanel(); labelContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().filterLabel()); Label pluginTitle = new Label(metaDataItem.getTitle()); pluginTitle.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { // clear the notification in case there was one left over from adding a prior plugin Session.getInstance().getEventBus().notifyObservers(new HideNotificationEvent()); selectPlugin(metaDataItem); } }); labelContainer.add(pluginTitle); listItemPanel.add(new Image(metaDataItem.getThumbnail())); listItemPanel.add(labelContainer); filterPanel.add(listItemPanel); availablePluginsContainer.add(filterPanel); availablePluginsById.put(metaDataItem.getGadgetDefinition().getId(), filterPanel); } } else { availablePluginsContainer.add(new Label("No plugins available")); } }
From source file:org.eurekastreams.web.client.ui.pages.settings.GroupSubscriptionDialogContent.java
License:Apache License
/** * Builds the content from the two lists. *//* ww w . j av a2s. co m*/ private void populate() { Session.getInstance().getEventBus().addObserver(StreamActivitySubscriptionChangedEvent.class, new Observer<StreamActivitySubscriptionChangedEvent>() { public void update(final StreamActivitySubscriptionChangedEvent ev) { if (EntityType.GROUP == ev.getResponse().getEntityType()) { String groupName = ev.getResponse().getStreamEntityUniqueId(); boolean subscribed = ev.getResponse().getReceiveNewActivityNotifications(); Widget button; button = subscribeButtons.get(groupName); if (button != null) { button.setVisible(!subscribed); } button = unsubscribeButtons.get(groupName); if (button != null) { button.setVisible(subscribed); } } } }); // remove spinner listPanel.clear(); // display message if no groups if (groups.getPagedSet().isEmpty()) { Label label = new Label("You are not a member of any groups."); label.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionItemEmpty()); listPanel.add(label); return; } // sort groups by name TreeSet<DomainGroupModelView> orderedGroups = new TreeSet<DomainGroupModelView>( new Comparator<DomainGroupModelView>() { public int compare(final DomainGroupModelView inO1, final DomainGroupModelView inO2) { return inO1.getName().compareToIgnoreCase(inO2.getName()); } }); orderedGroups.addAll(groups.getPagedSet()); // display groups for (final DomainGroupModelView group : orderedGroups) { GroupPanel groupWidget = new GroupPanel(group, false, true, false); final Label subscribeButton = new Label(); subscribeButtons.put(group.getUniqueId(), subscribeButton); final Label unsubscribeButton = new Label(); unsubscribeButtons.put(group.getUniqueId(), unsubscribeButton); subscribeButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().groupNotifSubscribeButton()); unsubscribeButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().groupNotifUnsubscribeButton()); subscribeButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent inArg0) { GroupActivitySubscriptionModel.getInstance().insert(group.getUniqueId()); } }); unsubscribeButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent inArg0) { GroupActivitySubscriptionModel.getInstance().delete(group.getUniqueId()); } }); boolean subscribed = subscribedGroupIds.contains(group.getUniqueId()); subscribeButton.setVisible(!subscribed); unsubscribeButton.setVisible(subscribed); groupWidget.insert(subscribeButton, 0); groupWidget.insert(unsubscribeButton, 1); listPanel.add(groupWidget); } }
From source file:org.eurekastreams.web.client.ui.pages.settings.SystemSettingsPanelComposite.java
License:Apache License
/** * Setup for refresh button.//w w w . j a va2 s . c o m * * @return newly configured label/button. */ private Label initializeRefreshButton() { Label button = new Label(); button.addStyleName(StaticResourceBundle.INSTANCE.coreCss().accessListRefreshButton()); button.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { processor.makeRequest("updateMembershipTaskHandler", null, new AsyncCallback<String>() { public void onFailure(final Throwable caught) { Session.getInstance().getEventBus().notifyObservers(new ShowNotificationEvent( new Notification("An error occurred refreshing Access List"))); History.newItem(History.getToken()); } public void onSuccess(final String value) { } }); Session.getInstance().getEventBus().notifyObservers( new ShowNotificationEvent(new Notification("Access List Refresh is now processing"))); History.newItem(History.getToken()); } }); return button; }
From source file:org.freemedsoftware.gwt.client.widget.RemittReportsWidget.java
License:Open Source License
public void loadMonthsInfo() { allReportTable = new FlexTable(); allReportTable.setWidth("80%"); reportsPanel.clear();/*from ww w . java2s . c o m*/ reportsPanel.add(allReportTable); Util.callModuleMethod("RemittBillingTransport", "getMonthsInfo", (Integer) null, new CustomRequestCallback() { @Override public void onError() { } @SuppressWarnings("unchecked") @Override public void jsonifiedData(Object data) { if (data != null) { final HashMap<String, String>[] result = (HashMap[]) data; for (int i = 0; i < result.length; i++) { int row = i / 2; int col = i % 2; VerticalPanel reportPanel = new VerticalPanel(); reportPanel.setSpacing(10); reportPanel.setWidth("70%"); HorizontalPanel hpanel = new HorizontalPanel(); hpanel.setSpacing(5); final Label expandLb = new Label("+"); final CustomTable reportsInfoTable = new CustomTable(); reportsInfoTable.setAllowSelection(false); reportsInfoTable.setWidth("100%"); reportsInfoTable.addColumn(_("Report"), "filename"); reportsInfoTable.addColumn(_("Size"), "filesize"); reportsInfoTable.addColumn(_("Date Sent"), "inserted"); reportsInfoTable.addColumn(_("Action"), "action"); reportsInfoTable .setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() { @Override public Widget setColumn(String columnName, final HashMap<String, String> data) { if (columnName.compareTo("action") == 0) { HorizontalPanel actionPanel = new HorizontalPanel(); actionPanel.setSpacing(5); HTML htmlLedger = new HTML("<a href=\"javascript:undefined;\">" + _("View") + "</a>"); htmlLedger.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { String[] params = { "output", data.get("filename"), "html" }; Window.open(URL.encode(Util.getJsonRequest( "org.freemedsoftware.api.Remitt.GetFile", params)), data.get("filename"), ""); } }); HTML htmlReSend = null; if (data.get("originalId") != null) { htmlReSend = new HTML("<a href=\"javascript:undefined;\">" + _("Re-Send") + "</a>"); htmlReSend.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { CustomRequestCallback cb = new CustomRequestCallback() { @Override public void onError() { } @Override public void jsonifiedData(Object data) { rebillPanel.setVisible(false); reportsPanel.setVisible(true); loadMonthsInfo(); } }; reportsPanel.setVisible(false); rebillPanel.clear(); HashSet<String> hs = new HashSet<String>(); hs.add(data.get("originalId")); RemittBillingWidget billClaimsWidget = new RemittBillingWidget( hs, cb, BillingType.REBILL); rebillPanel.add(billClaimsWidget); rebillPanel.setVisible(true); } }); } else { htmlReSend = new HTML( "<a href=\"javascript:undefined;\" style=\"cursor:default;color: blue;\">" + _("Re-Send") + "</a>"); } actionPanel.add(htmlLedger); actionPanel.add(htmlReSend); return actionPanel; } else if (columnName.compareTo("inserted") == 0) { Label lb = new Label(data.get("inserted").substring(0, 10)); return lb; } else { return (Widget) null; } } }); reportsInfoTable.setVisible(false); expandLb.getElement().getStyle().setCursor(Cursor.POINTER); final int index = i; expandLb.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { if (expandLb.getText().trim().equals("+")) { expandLb.setText("-"); reportsInfoTable.setVisible(true); loadReportsDetails(result[index].get("month"), reportsInfoTable); } else { expandLb.setText("+"); reportsInfoTable.setVisible(false); } } }); hpanel.setWidth("100%"); hpanel.setStyleName(AppConstants.STYLE_TABLE_HEADER); Label infoLb = new Label(result[i].get("month")); hpanel.add(expandLb); hpanel.add(infoLb); hpanel.setCellWidth(expandLb, "5px"); reportPanel.add(hpanel); reportPanel.add(reportsInfoTable); allReportTable.setWidget(row, col, reportPanel); allReportTable.getFlexCellFormatter().setVerticalAlignment(row, col, HasVerticalAlignment.ALIGN_TOP); // panel.add(); // panel.add(reportsInfoTable); } } } }, "HashMap<String,String>[]"); }
From source file:org.freemedsoftware.gwt.client.widget.TaskbarIcon.java
License:Open Source License
public TaskbarIcon(String labelText, Image image, ClickHandler l) { final VerticalPanel verticalPanel = new VerticalPanel(); initWidget(verticalPanel);//from www .j ava 2 s . c o m verticalPanel.add(image); verticalPanel.setCellVerticalAlignment(image, HasVerticalAlignment.ALIGN_BOTTOM); verticalPanel.setCellHorizontalAlignment(image, HasHorizontalAlignment.ALIGN_CENTER); final Label label = new Label(labelText); verticalPanel.add(label); verticalPanel.setCellHorizontalAlignment(label, HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setCellVerticalAlignment(label, HasVerticalAlignment.ALIGN_TOP); // Style this from CSS verticalPanel.setStylePrimaryName("taskbarIcon"); // Push click listeners for both internal objects image.addClickHandler(l); label.addClickHandler(l); MouseOverHandler mlOver = new MouseOverHandler() { @Override public void onMouseOver(MouseOverEvent event) { getParent().setStylePrimaryName("taskbarIcon-hover"); } }; MouseOutHandler mlOut = new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { getParent().setStylePrimaryName("taskbarIcon"); } }; image.addMouseOverHandler(mlOver); image.addMouseOutHandler(mlOut); label.addMouseOverHandler(mlOver); label.addMouseOutHandler(mlOut); }
From source file:org.geomajas.gwt2.plugin.corewidget.example.client.sample.feature.tooltip.ToolTip.java
License:Open Source License
/** * Add content to the tooltip and show it with the given parameters. * * @param content a list of Labels//ww w.j a va 2 s . c o m * @param left the left position of the tooltip * @param top the top position of the tooltip */ public void addContentAndShow(List<Label> content, int left, int top, boolean showCloseButton) { // Add a closeButton when showCloseButton is true. if (showCloseButton) { Label closeButtonLabel = new Label(" X "); closeButtonLabel.addStyleName(ToolTipResource.INSTANCE.css().toolTipCloseButton()); contentPanel.add(closeButtonLabel); closeButtonLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); } // Add the content to the panel. for (Label l : content) { l.addStyleName(ToolTipResource.INSTANCE.css().toolTipLine()); contentPanel.add(l); } // Finally set position of the tooltip and show it. toolTip.setPopupPosition(left, top); toolTip.show(); }
From source file:org.geomajas.gwt2.plugin.geocoder.client.widget.GeocoderWidgetAlternativesViewImpl.java
License:Open Source License
@Override public void setAlternatives(List<GetLocationForStringAlternative> alternatives) { alternativesPanel.clear();//from w ww . j a v a 2 s. c om for (GetLocationForStringAlternative alternative : alternatives) { final String altText = alternative.getCanonicalLocation(); Label altLabel = new Label(altText); altLabel.setStyleName(resource.css().geocoderGadgetAltLabel()); altLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { alternativesPresenter.findLocation(altText); } }); alternativesPanel.add(altLabel); } }