private void addRow(JSONObject object, int row) { String desc = Util.str(object.get("description")); String id = Util.str(object.get("id")); String trust = Util.str(object.get("fond")); String defaultdesc = Util.str(object.get("defaultdesc")); String actionclub = Util.str(object.get("actionclub")); String actiontrust = Util.str(object.get("actionfond")); String debetpost = Util.strSkipNull(object.get("debetpost")); String creditpost = Util.strSkipNull(object.get("creditpost")); table.setText(row, 0, trustActionCache.trustGivesDesc(trust)); table.setText(row, 1, desc); table.setText(row, 2, defaultdesc); table.setText(row, 3, Util.debkred(elements, actionclub)); table.setText(row, 4, Util.debkred(elements, actiontrust)); if (!("".equals(debetpost))) { table.setText(row, 5, posttypeCache.getDescriptionWithType(debetpost)); } if (!("".equals(creditpost))) { table.setText(row, 6, posttypeCache.getDescriptionWithType(creditpost)); } table.getCellFormatter().setStyleName(row, 0, "desc"); table.getCellFormatter().setStyleName(row, 1, "desc"); table.getCellFormatter().setStyleName(row, 2, "desc"); table.getCellFormatter().setStyleName(row, 5, "desc"); table.getCellFormatter().setStyleName(row, 6, "desc"); Image editImage = ImageFactory.editImage("projectEditView_editImage"); editImage.addClickHandler(me); idHolder.add(id, editImage); table.setWidget(row, 7, editImage); String style = (((row + 1) % 6) < 3) ? "line2" : "line1"; table.getRowFormatter().setStyleName(row, style); }
private void doSave() { StringBuffer sb = new StringBuffer(); sb.append("action=save"); Util.addPostParam(sb, "id", currentId); Util.addPostParam(sb, "trust", trustBox.getText()); Util.addPostParam(sb, "description", descBox.getText()); Util.addPostParam(sb, "defaultdesc", defaultDescBox.getText()); Util.addPostParam(sb, "clubaction", Util.getSelected(actionClubBox)); Util.addPostParam(sb, "trustaction", Util.getSelected(actionTrustBox)); Util.addPostParam(sb, "debetpost", accountDebIdBox.getText()); Util.addPostParam(sb, "creditpost", accountCredIdBox.getText()); ServerResponse callback = new ServerResponse() { @Override public void serverResponse(JSONValue value) { JSONObject obj = value.isObject(); String serverResponse = Util.str(obj.get("result")); if ("0".equals(serverResponse)) { mainErrorLabel.setText(messages.save_failed()); Util.timedMessage(mainErrorLabel, "", 5); } else { /* Could probably be more effective, but why bother? */ TrustActionCache.getInstance(constants, messages).flush(me); hide(); } } }; AuthResponder.post(constants, messages, callback, sb, "registers/trustaction.php"); }
public void init(String id) { currentId = id; JSONObject object = trustActionCache.getTrustAction(id); String trust = Util.str(object.get("fond")); String desc = Util.str(object.get("description")); String defaultdesc = Util.str(object.get("defaultdesc")); String actionclub = Util.str(object.get("actionclub")); String actiontrust = Util.str(object.get("actionfond")); String debetpost = Util.strSkipNull(object.get("debetpost")); String creditpost = Util.strSkipNull(object.get("creditpost")); Util.setIndexByValue(trustBox.getListbox(), trust); descBox.setText(desc); defaultDescBox.setText(defaultdesc); accountCredIdBox.setText(creditpost); Util.setIndexByValue(accountCredNameBox, creditpost); accountDebIdBox.setText(debetpost); Util.setIndexByValue(accountDebNameBox, debetpost); Util.setIndexByValue(actionClubBox, actionclub); Util.setIndexByValue(actionTrustBox, actiontrust); }
TrustActionEditFields() { setText(elements.project()); FlexTable edittable = new FlexTable(); edittable.setStyleName("edittable"); edittable.setText(0, 0, elements.trust()); trustBox = new ListBoxWithErrorText("trust"); trustActionCache.fillTrustList(trustBox.getListbox()); edittable.setWidget(0, 1, trustBox); edittable.setText(1, 0, elements.description()); descBox = new TextBoxWithErrorText("description"); descBox.setMaxLength(40); descBox.setVisibleLength(40); edittable.setWidget(1, 1, descBox); edittable.setText(2, 0, elements.trust_default_desc()); defaultDescBox = new TextBoxWithErrorText("trust_default_desc"); defaultDescBox.setMaxLength(50); defaultDescBox.setVisibleLength(50); edittable.setWidget(2, 1, defaultDescBox); edittable.setText(3, 0, elements.trust_actionclub()); actionClubBox = new ListBox(); addDebetKredit(actionClubBox); edittable.setWidget(3, 1, actionClubBox); edittable.setText(4, 0, elements.trust_actiontrust()); actionTrustBox = new ListBox(); addDebetKredit(actionTrustBox); edittable.setWidget(4, 1, actionTrustBox); edittable.setText(5, 0, elements.trust_creditpost()); HorizontalPanel hpcred = new HorizontalPanel(); HTML errorAccountCredHtml = new HTML(); accountCredIdBox = new TextBoxWithErrorText("account", errorAccountCredHtml); accountCredIdBox.setVisibleLength(6); accountCredNameBox = new ListBox(); accountCredNameBox.setVisibleItemCount(1); hpcred.add(accountCredIdBox); hpcred.add(accountCredNameBox); hpcred.add(errorAccountCredHtml); PosttypeCache.getInstance(constants, messages).fillAllPosts(accountCredNameBox); Util.syncListbox(accountCredNameBox, accountCredIdBox.getTextBox()); edittable.setWidget(5, 1, hpcred); edittable.setText(6, 0, elements.trust_debetpost()); HorizontalPanel hpdeb = new HorizontalPanel(); HTML errorAccountDebHtml = new HTML(); accountDebIdBox = new TextBoxWithErrorText("account", errorAccountDebHtml); accountDebIdBox.setVisibleLength(6); accountDebNameBox = new ListBox(); accountDebNameBox.setVisibleItemCount(1); hpdeb.add(accountDebIdBox); hpdeb.add(accountDebNameBox); hpdeb.add(errorAccountDebHtml); PosttypeCache.getInstance(constants, messages).fillAllPosts(accountDebNameBox); Util.syncListbox(accountDebNameBox, accountDebIdBox.getTextBox()); edittable.setWidget(6, 1, hpdeb); DockPanel dp = new DockPanel(); dp.add(edittable, DockPanel.NORTH); saveButton = new NamedButton("projectEditView_saveButton", elements.save()); saveButton.addClickHandler(this); cancelButton = new NamedButton("projectEditView_cancelButton", elements.cancel()); cancelButton.addClickHandler(this); mainErrorLabel = new HTML(); mainErrorLabel.setStyleName("error"); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.add(saveButton); buttonPanel.add(cancelButton); buttonPanel.add(mainErrorLabel); dp.add(buttonPanel, DockPanel.NORTH); setWidget(dp); }
public EditPortalUserPopup( Elements elements, Constants constants, I18NAccount messages, JSONObject object, String id) { this.elements = elements; this.constants = constants; this.messages = messages; this.id = id; setModal(true); String title = "Rediger detaljer for " + Util.str(object.get("firstname")) + " " + Util.str(object.get("lastname")); setText(title); setAnimationEnabled(true); setAutoHideEnabled(true); HorizontalPanel hp = new HorizontalPanel(); delTable = new AccountTable("tableborder"); hp.add(delTable); delTable.setHeader(0, 0, elements.portal_homepage()); delTable.setHeader(1, 0, elements.portal_twitter()); delTable.setHeader(2, 0, elements.portal_facebook()); delTable.setHeader(3, 0, elements.portal_linkedin()); delTable.setHeader(4, 0, elements.portal_access()); delTable.setHTML(5, 0, " "); delTable.setText(0, 1, Util.str(object.get("homepage"))); delTable.setText(1, 1, Util.str(object.get("twitter"))); delTable.setText(2, 1, Util.str(object.get("facebook"))); delTable.setText(3, 1, Util.str(object.get("linkedin"))); boolean isDeactivated = Util.getBoolean(object.get("deactivated")); delTable.setText( 4, 1, isDeactivated ? elements.portal_access_blocked() : elements.portal_access_granted()); delHomepage = ImageFactory.deleteImage("delhomepage"); delTwitter = ImageFactory.deleteImage("deltwitter"); delFacebook = ImageFactory.deleteImage("delfacebook"); delLinkedin = ImageFactory.deleteImage("dellinkedin"); delHomepage.addClickHandler(this); delTwitter.addClickHandler(this); delFacebook.addClickHandler(this); delLinkedin.addClickHandler(this); delTable.setWidget(0, 2, delHomepage); delTable.setWidget(1, 2, delTwitter); delTable.setWidget(2, 2, delFacebook); delTable.setWidget(3, 2, delLinkedin); blockAccessButton = new NamedButton("block_acceess", "Sperr tilgang"); blockAccessButton.addClickHandler(this); grantAccessButton = new NamedButton("grant_acceess", "Gi tilgang"); grantAccessButton.addClickHandler(this); delPortalImage = new NamedButton("delete_portal_image", "Slett profilbilde"); delPortalImage.addClickHandler(this); delTable.setWidget(5, 0, blockAccessButton); delTable.setWidget(5, 1, grantAccessButton); delTable.setWidget(6, 3, delPortalImage); profileImage = new Image( "/RegnskapServer/services/portal/portal_admin.php?action=image&image=" + id + "&foolcache=" + System.currentTimeMillis()); delTable.setWidget(0, 3, profileImage); delTable.getFlexCellFormatter().setRowSpan(0, 3, 6); blockAccessButton.setEnabled(!isDeactivated); grantAccessButton.setEnabled(isDeactivated); add(hp); }