List of usage examples for com.google.gwt.user.client Window alert
public static void alert(String msg)
From source file:com.edgenius.wiki.gwt.client.login.LoginSignupDeck.java
License:Open Source License
private void showSignup() { if (!AbstractEntryPoint.isAllowPublicSignup()) { Window.alert(ErrorCode.getMessageText(ErrorCode.USER_SIGNUP_DISABLED, null)); return;/* w w w . j av a 2 s .c o m*/ } deck.showWidget(LoginDialog.SINGUP); if (dialog != null) { dialog.setText(Msg.consts.signup()); dialog.setIcon(signupIcon); cancelBtn.setVisible(true); } signupBtn.setVisible(true); sendBtn.setVisible(false); loginBtn.setVisible(false); gotoLoginBtn.setVisible(true); gotoSignupBtn.setVisible(false); forgetPassLink.setVisible(false); }
From source file:com.edgenius.wiki.gwt.client.model.UserListModel.java
License:Open Source License
/** * @param item/*from www . j a v a 2 s . c o m*/ * @return */ public boolean remove(UserModel item) { for (Iterator<UserModel> iter = userList.iterator(); iter.hasNext();) { UserModel model = iter.next(); if (model.equals(item)) { Window.alert("remove" + model.getLoginname()); iter.remove(); //show current page return true; } } return false; }
From source file:com.edgenius.wiki.gwt.client.page.HistoryPanel.java
License:Open Source License
public void onClick(ClickEvent event) { Object sender = event.getSource(); if (sender == compareButton) { PageItemModel left = null, right = null; boolean over = false; for (PageItemModel history : historyList) { if (history.checked) { if (left == null) left = history;//from ww w . ja va 2 s.co m else if (right == null) right = history; else { over = true; break; } } } if (over || left == null || right == null) { Window.alert(Msg.consts.choose_two()); } else { //do compare left and right PageControllerAsync action = ControllerFactory.getPageController(); action.diff(right.isCurrent ? SharedConstants.CURRENT : right.uid, left.isCurrent ? SharedConstants.CURRENT : left.uid, main.viewPanel.versionAsync); // String token = GwtUtils.buildToken(PageMain.TOKEN_DIFF,String.valueOf(right.isCurrent?-1:right.uid), String.valueOf(left.isCurrent?-1:left.uid)); // History.newItem(token); //go to page top GwtClientUtils.gotoAnchor(PageMain.PAGE_TOP_ANCHOR_NAME); } } }
From source file:com.edgenius.wiki.gwt.client.page.PageMain.java
License:Open Source License
public boolean executeKeyShortcut(boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey, int keyCode) { //KeyCaptureListener.globalCapture means some textbox is getting input focus so far, so all shortcut won't work if (!KeyCaptureListener.globalCapture) return true; int idx = deck.getVisibleWidget(); //DEBUG key: Shift_Alt_F12 if (KeyMap.isKey(KeyMap.DEBUG, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { String str = " pageUuid= " + PageMain.getPageUuid() + " \n" + " version= " + this.getPageVersion() + " \n" + " pageAttribute= " + this.getPageAttribute() + " \n" + " parentPageUuid= " + getParentPageUuid() + " \n" + " pageTitle= " + PageMain.getCurrentPageTitle() + " \n" + " spaceUname= " + getSpaceUname() + " \n" + " previewReady= " + this.isPreviewReady() + " \n" + " newPageType(New, home or common page)= " + this.getNewPageType() + " \n" + " fromPanelIdx= " + this.getFromPanelIndex() + " \n" + " editingDirty= " + this.editPanel.isDirty() + " \n"; Window.alert(str); }// w ww . j a v a 2s.c o m if (idx == VIEW_PANEL) { //shift-E to edit page, shift-N to create new page if (KeyMap.isKey(KeyMap.VIEW_CREATE, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { viewPanel.functionBtnBar.createPage(); return false; } else if (KeyMap.isKey(KeyMap.VIEW_EDIT, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { viewPanel.functionBtnBar.editPage(); return false; } else if (KeyMap.isKey(KeyMap.VIEW_NEW_TAG, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { viewPanel.tags.editTag(); return false; } else if (KeyMap.isKey(KeyMap.VIEW_NEW_COMMENT, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { viewPanel.tabPanel.newComment(); GwtClientUtils.gotoAnchor(PageTabPanel.TABS_ANCHOR_NAME); return false; } else if (KeyMap.isKey(KeyMap.VIEW_TOGGLE_COMMENT, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { viewPanel.tabPanel.toggleComment(); GwtClientUtils.gotoAnchor(PageTabPanel.TABS_ANCHOR_NAME); return false; } else if (KeyMap.isKey(KeyMap.VIEW_TOGGLE_ATTACHMENT, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { viewPanel.toggleAttachmnet(); GwtClientUtils.gotoAnchor(PageMain.PAGE_TOP_ANCHOR_NAME); return false; } else if (KeyMap.isKey(KeyMap.VIEW_NEW_ATTACHMENT, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { viewPanel.viewAttachment(); GwtClientUtils.gotoAnchor(PageMain.PAGE_TOP_ANCHOR_NAME); return false; } else if (KeyMap.isKey(KeyMap.VIEW_TOGGLE_HISTORY, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { viewPanel.tabPanel.toggleHistory(); GwtClientUtils.gotoAnchor(PageTabPanel.TABS_ANCHOR_NAME); return false; } else if (KeyMap.isKey(KeyMap.VIEW_CLOSE_PIN_PANEL, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { viewPanel.tabPanel.close(); return false; } else if (KeyMap.isKey(KeyMap.VIEW_TOGGLE_TREE, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { if (toggleSideMenu(ClientConstants.LEFT)) { GwtClientUtils.gotoAnchor(PageMain.PAGE_TOP_ANCHOR_NAME); location.refresh(getSpaceUname(), getPageUuid()); } return false; } } else if (idx == EDIT_SIDEBAR_PANEL) { } else if (idx == EDIT_TEMPLATE_PANEL) { } else if (idx == EDIT_PANEL) { //ctrl-S/shift-alt-s to save-page-exit, shift-S to save-draft-exit, shift-c to Cancel, shift-p to preview if (KeyMap.isKey(KeyMap.EDIT_PUBLISH, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { editPanel.functionBtnBar.savePage(); return false; } else if (KeyMap.isKey(KeyMap.EDIT_SAVE, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { //false: don't exit to view page editPanel.functionBtnBar.saveDraftPage(false); return false; } else if (KeyMap.isKey(KeyMap.EDIT_CANCEL, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { editPanel.functionBtnBar.cancelPage(); return false; } else if (KeyMap.isKey(KeyMap.EDIT_PREVIEW, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { editPanel.functionBtnBar.previewPage(); return false; } else if (KeyMap.isKey(KeyMap.EDIT_FORCE_SAVE, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { editPanel.functionBtnBar.forceSave(); return false; } } else if (idx == PREVIEW_PANEL) { //shift-r resume from preview if (KeyMap.isKey(KeyMap.EDIT_PUBLISH, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { previewPanel.functionBtnBar.savePage(); return false; } else if (KeyMap.isKey(KeyMap.EDIT_SAVE, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { previewPanel.functionBtnBar.saveDraftPage(false); return false; } else if (KeyMap.isKey(KeyMap.PREVIEW_RESUME, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { previewPanel.functionBtnBar.resumePreviewPage(); return false; } else if (KeyMap.isKey(KeyMap.EDIT_FORCE_SAVE, ctrlKey, altKey, shiftKey, metaKey, keyCode)) { previewPanel.functionBtnBar.forceSave(); return false; } } return true; }
From source file:com.edgenius.wiki.gwt.client.page.widgets.AttachmentPanel.java
License:Open Source License
private List<AttachmentModel> parseAttachmentJSON(String results) { List<AttachmentModel> modelList = new ArrayList<AttachmentModel>(); try {/*from w w w . j a v a 2 s .c om*/ JSONValue jsonValue = JSONParser.parseStrict(results); JSONArray attachmentArray; if ((attachmentArray = jsonValue.isArray()) != null) { //AttachmentList int size = attachmentArray.size(); for (int idx = 0; idx < size; ++idx) { //attachment JSONObject attachObj = attachmentArray.get(idx).isObject(); AttachmentModel model = retrieve(attachObj); modelList.add(model); } } } catch (JSONException e) { Window.alert(Msg.consts.error_request()); } return modelList; }
From source file:com.edgenius.wiki.gwt.client.page.widgets.CaptchaDialog.java
License:Open Source License
/** * @return//from w w w . j a v a 2 s .c om */ private String validCaptcha() { String captchaResponse = captcha.getCaptchaInput(); if (captchaResponse == null || captchaResponse.trim().length() == 0) { Window.alert(Msg.consts.captcha_required()); enableSubmit(); return null; } return captchaResponse; }
From source file:com.edgenius.wiki.gwt.client.page.widgets.RSSFeedButton.java
License:Open Source License
private void openFeed() { if (this.spaceUname == null || this.spaceUname.trim().length() == 0) { Window.alert(Msg.consts.error_request()); return;/* w w w.ja v a 2 s. com*/ } //TODO: user spaceUid? it also not good as it stick to database record, which may change after backup/restore // if(GwtUtils.isSupportInURL(spaceUname)){ Window.open(getRSSURL(), SharedConstants.APP_NAME + "RSSFeed", ""); // }else{ // Window.open(GwtUtils.getBaseUrl()+"feed.do?suid="+spaceUid,SharedConstants.APP_NAME+"RSSFeed",""); // } }
From source file:com.edgenius.wiki.gwt.client.page.widgets.SpacePagesDialog.java
License:Open Source License
public void onClick(ClickEvent event) { Object widget = event.getSource(); if (widget == okButton) { okButton.setEnabled(false);/*from ww w . j a va 2s . co m*/ //it is better get from LoationTree rather than treePanel.getSpace(), this ensure consistent with selected page in PageTree String spaceUname = treePanel.locationTree.getSpaceUname(); if (spaceUname == null || spaceUname.trim().length() == 0) { Window.alert(Msg.consts.choose_space_first()); return; } String targetParentPageUuid = treePanel.getChosenPageUuid(); PageControllerAsync action = ControllerFactory.getPageController(); boolean withChildren = withChildrenButton.getValue(); if (type == MOVE) { action.move(main.getSpaceUname(), main.getPageUuid(), spaceUname, targetParentPageUuid, withChildren, this); } else if (type == COPY) { action.copy(main.getSpaceUname(), main.getPageUuid(), spaceUname, targetParentPageUuid, withChildren, this); } } else if (widget == cancelButton) { this.hidebox(); } }
From source file:com.edgenius.wiki.gwt.client.render.PageRender.java
License:Open Source License
/** * @param spaceUname /*from w w w . j ava2s .c o m*/ * @param panel * @param model * @param pieces: could be pageContent, or side bar content * @param isPreivew: if this render is for preview window */ public void renderContent(final String spaceUname, PageModel page, List<RenderPiece> pieces, boolean isPreivew) { //most stuff only need renderPiece, except PageAuthorPanel at moment widgetRenderContent = new StringBuffer(); widgetCounter.clear(); widgetContainer.clear(); panel.clear(); if (pieces != null) { int size = pieces.size(); for (int idx = 0; idx < size; idx++) { Object piece = pieces.get(idx); if (piece instanceof LinkModel) { LinkModel ln = (LinkModel) piece; if (listeners != null) { fireRenderEvent(ln.getView()); } final String anchorTxt = StringUtil.isBlank(ln.getAnchor()) ? "" : (EscapeUtil.escapeToken(ln.getAnchor().trim())); if (anchorTxt.length() != 0 && StringUtil.isBlank(ln.getLink())) { //[view>#anchor] style: will only redirect to anchor in same page ClickLink link = new ClickLink(ln.getView(), true); link.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { GwtClientUtils.gotoAnchor(anchorTxt); } }); panel.add(link); } else if (ln.getType() == LinkModel.LINK_TO_CLIENT_CLICK_LINK) { final String[] token = LinkUtil.parseCLinkParamters(ln.getLink()); if (token != null && token.length > 0) { //If it has anchor field, it will be treated as hyper link.Otherwise, ClickLink if (!StringUtil.isEmpty(ln.getAnchor())) { //now it only support user popup - so need to consolidate if want to more functions EventfulHyperLink link = new EventfulHyperLink(ln.getView(), ln.getAnchor()); String method = token[0]; String[] params = null; if (token.length > 1) { params = new String[token.length - 1]; for (int idx1 = 1; idx1 < token.length; idx1++) { params[idx1 - 1] = token[idx1]; } } JavascriptExposer.run(method, params, link); panel.add(link); } else { //click link ClickLink link = new ClickLink(ln.getView(), true); link.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String method = token[0]; String[] params = null; if (token.length > 1) { params = new String[token.length - 1]; for (int idx = 1; idx < token.length; idx++) { params[idx - 1] = token[idx]; } } JavascriptExposer.run(method, params, (Widget) event.getSource()); } }); panel.add(link); } } else { panel.add(new HTML(ln.getView())); Log.error("Unable pasre link with type 'client click link':" + ln.getLink()); } } else if (ln.getType() == LinkModel.LINK_TO_SERVER_CLICK_LINK) { } else { if (isPreivew) { ClickLink link = new ClickLink(ln.getView(), true); link.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.alert(Msg.consts.preview_disable_link()); } }); panel.add(link); } else { String tokenName = ln.getLink(); String linkSpaceUname = ln.getSpaceUname(); //extspace or current space, if null(failure tolerance) use current spaceUname as value linkSpaceUname = (linkSpaceUname == null || linkSpaceUname.trim().length() == 0) ? spaceUname : linkSpaceUname; if (ln.getType() == LinkModel.LINK_TO_CREATE_FLAG) { //$CREATE ,for link to non-exist page, or for "PAGE_NOT_FOUND" case tokenName = GwtUtils.buildToken(PageMain.TOKEN_CREATE, linkSpaceUname, tokenName); } else if (ln.getType() == LinkModel.LINK_TO_CREATE_HOME_FLAG) { tokenName = GwtUtils.buildToken(PageMain.TOKEN_CREATE_HOME, linkSpaceUname, tokenName); } else if (ln.getType() == LinkModel.LINK_TO_OPEN_NEW_WIN) { //no use so far tokenName = GwtUtils.buildToken(PageMain.TOKEN_OPEN_NEW_WINDOW, linkSpaceUname, tokenName); } else if (ln.getType() == LinkModel.LINK_TO_HYPER_TOKEN) { //keep token unchanged - nothing to do here. } else tokenName = GwtUtils.getSpacePageToken(linkSpaceUname, tokenName); tokenName += (anchorTxt == "" ? "" : "#" + anchorTxt); Hyperlink link = new Hyperlink(ln.getView(), true, tokenName); panel.add(link); } } } else if (piece instanceof MacroModel) { MacroModel rs = (MacroModel) piece; if (rs != null) { if (rs.macroName.equalsIgnoreCase(SharedConstants.MACRO_SPACE_ADMIN)) { SpaceAdminRenderWidget adminPanel = new SpaceAdminRenderWidget(spaceUname); panel.add(adminPanel); widgetContainer.add(adminPanel); adminPanel.onLoad(HTMLPanel.createUniqueId(), currentUser, this); } else if (rs.macroName.equalsIgnoreCase(SharedConstants.MACRO_NOTIFY_SYSADMIN)) { SendingNotifyRenderWidget adminPanel = new SendingNotifyRenderWidget(); panel.add(adminPanel); widgetContainer.add(adminPanel); adminPanel.onLoad(HTMLPanel.createUniqueId(), currentUser, this); } else if (rs.macroName.equals(SharedConstants.MACRO_TAG_CLOUD)) { TagCloudRenderWidget macroPanel = new TagCloudRenderWidget(spaceUname); panel.add(macroPanel); widgetContainer.add(macroPanel); macroPanel.onLoad(HTMLPanel.createUniqueId(), currentUser, this); } else if (rs.macroName.equals(SharedConstants.MACRO_TEMPLATE_LIST)) { TemplateListRenderWidget macroPanel = new TemplateListRenderWidget(spaceUname); panel.add(macroPanel); widgetContainer.add(macroPanel); macroPanel.onLoad(HTMLPanel.createUniqueId(), currentUser, this); } else if (rs.macroName.equals(SharedConstants.MACRO_SEARCH)) { String keyword = (String) rs.values.get(NameConstants.KEYWORD); SearchRenderWidget macroPanel = new SearchRenderWidget(keyword); panel.add(macroPanel); widgetContainer.add(macroPanel); macroPanel.onLoad(HTMLPanel.createUniqueId(), currentUser, this); } else if (rs.macroName.equals(SharedConstants.MACRO_USER_PROFILE)) { String username = rs.values.get(NameConstants.USERNAME); UserProfileRenderWidget macroPanel = new UserProfileRenderWidget(username); panel.add(macroPanel); widgetContainer.add(macroPanel); macroPanel.onLoad(HTMLPanel.createUniqueId(), currentUser, this); } else if (rs.macroName.equals(SharedConstants.MACRO_INCLUDE)) { String src = rs.values.get(NameConstants.SRC); LinkModel link = LinkUtil.parseMarkup(src); if (StringUtil.isBlank(link.getSpaceUname())) { //if @space is blank, treat as current space link.setSpaceUname(spaceUname); } IncludeRenderWidget includePanel = new IncludeRenderWidget(link); panel.add(includePanel); widgetContainer.add(includePanel); includePanel.onLoad(HTMLPanel.createUniqueId(), currentUser, this); } else if (rs.macroName.equals(SharedConstants.MACRO_COMMENT)) { String title = (String) rs.values.get(NameConstants.TITLE); ClickLink comment = new ClickLink(title); comment.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (BaseEntryPoint.I != null && BaseEntryPoint.I instanceof PageMain) { PageMain main = ((PageMain) BaseEntryPoint.I); if (main.getVisiblePanelIndex() == PageMain.VIEW_PANEL) { main.viewPanel.tabPanel.newComment(); return; } } Window.alert(Msg.consts.not_available_mode()); } }); widgetRenderContent.append(title); panel.add(comment); } else if (rs.macroName.equals(SharedConstants.MACRO_PORTAL)) { boolean show = BooleanUtil.toBooleanTrue(rs.values.get(NameConstants.SHOWLOGO)); int column = NumberUtil.toInt(rs.values.get(NameConstants.COLUMNS), -1); if (column == -1) { //this is just for makes this macro can tolerance spell error - colunm or columns column = NumberUtil.toInt(rs.values.get(NameConstants.COLUMN), -1); } if (column == -1) { column = SharedConstants.DEFAULT_PORTAL_COLUMNS; } if (visitor == null) { //default portal visitor - don't use InstancePortalVisitor as it is dangerous to change default dashboard visitor = new HomePortalVisitor(); } Portal portal = new Portal(visitor, column, show); panel.add(portal); widgetContainer.add(portal); portal.onLoad(HTMLPanel.createUniqueId(), currentUser, this); } else if (rs.macroName.equals(SharedConstants.MACRO_FEEDBACK)) { String imgOn = rs.values.get(NameConstants.IMAGE); HasClickHandlers btn; if (StringUtil.isBlank(imgOn)) { //text base link String title = (String) rs.values.get(NameConstants.TITLE); btn = new ClickLink(title); } else { btn = new Image(imgOn); } btn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { FeedbackDialog dialog = new FeedbackDialog(); dialog.showbox(); } }); //for hide welcome message widgetRenderContent.append("feedback");//NON-I18N panel.add((Widget) btn); } else if (rs.macroName.equals(SharedConstants.MACRO_SIGNUP)) { String imgOn = rs.values.get(NameConstants.IMAGE); HasClickHandlers btn; if (StringUtil.isBlank(imgOn)) { //text base link String title = (String) rs.values.get(NameConstants.TITLE); btn = new ClickLink(title); } else { btn = new Image(imgOn); } btn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { LoginDialog dialogue = new LoginDialog(LoginDialog.SINGUP); dialogue.showbox(); } }); //for hide welcome message widgetRenderContent.append("signup");//NON-I18N panel.add((Widget) btn); } } } else if (piece instanceof TextModel) { String text = ((TextModel) piece).toString(); panel.add(text); if (listeners != null) { fireRenderEvent(text); } } } } panel.submit(); if (listeners != null) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { attemptFireRenderEnd(); } }); } }
From source file:com.edgenius.wiki.gwt.client.widgets.ListDialogue.java
License:Open Source License
public ListDialogue(String title, final int type) { listPanel = new ListPanel(type); VerticalPanel panel = new VerticalPanel(); ButtonBar btnBar = this.getButtonBar(); Button okButton = new Button(Msg.consts.ok(), ButtonIconBundle.tickImage()); okButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { List values = listPanel.getCandidates(); if (values == null || values.size() == 0) { if (type == ListDialogue.GROUP) { Window.alert(Msg.params.no_role_user_select(Msg.consts.group())); } else { Window.alert(Msg.params.no_role_user_select(Msg.consts.user())); }/*from w w w. jav a2 s . c o m*/ return; } else { for (ListDialogueListener lis : listeners) { lis.dialogClosed(ListDialogue.this, values); } } hidebox(); } }); Button cancelButton = new Button(Msg.consts.cancel(), ButtonIconBundle.crossImage()); cancelButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { ListDialogue.this.hidebox(); } }); btnBar.add(cancelButton); btnBar.add(okButton); panel.add(loadingInd); panel.add(listPanel); panel.setSize("100%", "100%"); loading(false); this.setText(title); this.setWidget(panel); }