public void setDisplayValue() { if (paramClass == null) { setPrompt(null); return; } Record records[] = paramClass.getValueRecords(); setValue(""); if (records == null) { setPrompt(null); return; } String displayFields[] = paramClass.getDisplayFields(); String value = ""; String valuePrompt = "<table cellpadding=\"0\" cellspacing=\"0\" style=\"width: 350px; border: 1px solid #ABABAB;\"><tr>"; for (String displayField : paramClass.getDisplayFieldTitles()) { valuePrompt += "<td style=\"border-top: 1px solid #F0F0F0; font-weight: bold; height: 22px; padding-left: 4px; padding-right: 4px; background-image: url('images/hdr-bg-image.png');\">" + displayField + "</td>"; } valuePrompt += "</tr>"; int i = 0; for (Record record : records) { valuePrompt += "<tr>"; for (String displayField : displayFields) { String itemValue = record.getAttributeAsString(displayField); if (i > 0) { value += ","; } value += itemValue; String borderColor = "#ABABAB"; String bgColor = ""; if (i != 0) { borderColor = "#F0F0F0"; } if (i % 2 != 0) { bgColor = "background-color: #FAFAFA;"; } valuePrompt += "<td style=\"border-top: 1px solid " + borderColor + "; height: 22px; padding-left: 4px; padding-right: 4px; " + bgColor + "\">" + itemValue + "</td>"; } valuePrompt += "</tr>"; i++; } valuePrompt += "</table>"; setPrompt(valuePrompt); setValue(value); }
private void delete(ListGridRecord listGridRecord) { try { com.smartgwt.client.rpc.RPCManager.startQueue(); Record record = new Record(); record.setAttribute( "loggedUserName", CommonSingleton.getInstance().getSessionPerson().getUser_name()); record.setAttribute( "billing_company_id", listGridRecord.getAttributeAsInt("billing_company_id")); DSRequest req = new DSRequest(); req.setAttribute("operationId", "removeBillingComp"); billingCompsGrid.removeData( record, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) {} }, req); com.smartgwt.client.rpc.RPCManager.sendQueue(); } catch (Exception e) { SC.say(e.toString()); } }
private void save() { try { Record records[] = listGrid.getRecords(); Integer mainIdList[] = new Integer[records.length]; int i = 0; for (Record record : records) { mainIdList[i++] = record.getAttributeAsInt("main_id"); } DataSource dataSource = DataSource.get("OrgDS"); com.smartgwt.client.rpc.RPCManager.startQueue(); Record record = new Record(); record.setAttribute("mainIdList", mainIdList); record.setAttribute( "loggedUserName", CommonSingleton.getInstance().getSessionPerson().getUserName()); DSRequest req = new DSRequest(); req.setAttribute("operationId", "updateMainServiceOrders"); dataSource.updateData( record, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { destroy(); tabOrganization.search(); } }, req); com.smartgwt.client.rpc.RPCManager.sendQueue(); } catch (Exception e) { e.printStackTrace(); SC.say(e.toString()); } }
@Override public void saveRecord(AbstractRecord record) { super.saveRecord(record); Record rec = (Record) record; Long gameId = rec.getAttributeAsLong(GameModel.GAMEID_FIELD); if (!gameToGi.containsKey(gameId)) { gameToGi.put(gameId, new HashMap<Long, Record>()); } gameToGi.get(gameId).put(rec.getAttributeAsLong(GeneralItemModel.GENERALITEMID_FIELD), rec); }
@Override public GUIDocument markSelectedAsCheckedOut() { Record record = getSelectedRecord(); if (record == null) return null; record.setAttribute("locked", "page_edit"); record.setAttribute("lockUserId", Session.get().getUser().getId()); record.setAttribute("status", Constants.DOC_CHECKED_OUT); redraw(); return getSelectedDocument(); }
private List<TransitLPActivity> getActivities() { ArrayList<TransitLPActivity> activities = new ArrayList<TransitLPActivity>(); for (Record record : view.getProjectActivities()) { TransitLPActivity transit = (TransitLPActivity) record.getAttributeAsObject("transit"); activities.add(transit); } return activities; }
private RecordList errorsFromExportResult(Record[] exportResults) { RecordList recordList = new RecordList(); for (Record result : exportResults) { Record[] errors = result.getAttributeAsRecordArray(ExportResourceApi.RESULT_ERRORS); if (errors != null && errors.length > 0) { recordList.addList(errors); } } return recordList; }
@Override public void updateDocument(GUIDocument document) { Record record = null; // Find the record the corresponds to the given document Record[] records = getData(); for (Record rec : records) if (Long.parseLong(rec.getAttribute("id")) == document.getId()) record = rec; if (record != null) { GridUtil.updateRecord(document, record); redraw(); } }
/** * Instantiates a new user statistics. * * @param userId the user id * @param model the model * @param dateFrom the date from * @param dateTo the date to * @param segVal the seg val * @param dispatcher */ public UserStatisticsLayout( Record userRec, String model, Date dateFrom, Date dateTo, final String segVal, DispatchAsync dispatcher, LangConstants lang) { this.dispatcher = dispatcher; this.userId = userRec != null ? userRec.getAttributeAsString(Constants.ATTR_ID) : UNIFYING; this.chartsLayout = new HLayout(); this.lang = lang; this.userName = userRec != null ? (userRec.getAttributeAsString(Constants.ATTR_NAME) + " " + userRec.getAttribute(Constants.ATTR_SURNAME)) : lang.unifyingCharts(); HTMLFlow nameFlow = new HTMLFlow(HtmlCode.title(userName, 3)); nameFlow.setHeight(40); addMember(nameFlow); addMember(chartsLayout); setBackgroundColor("white"); htmlPieFlow = new HTMLFlow(html.replace("%s", PIE_CHART_NESTED_DIV_ID + userId)); htmlPieFlow.setWidth("40%"); htmlPieFlow.setHeight(250); htmlPieFlow.setExtraSpace((userRec != null) ? 10 : 50); chartsLayout.addMember(htmlPieFlow); htmlLineFlow = new HTMLFlow(html.replace("%s", LINE_CHART_NESTED_DIV_ID + userId)); htmlLineFlow.setWidth("*"); htmlLineFlow.setHeight(250); chartsLayout.addMember(htmlLineFlow); setShowEdges(true); setEdgeSize(3); setEdgeOpacity(60); setPadding(5); setExtraSpace(5); setHeight(280); final ModalWindow mw = new ModalWindow(chartsLayout); mw.setLoadingIcon("loadingAnimation.gif"); mw.show(true); setdata(model, dateFrom, dateTo, segVal, mw); }
@Override protected void transformResponse(DSResponse dsResponse, DSRequest dsRequest, Object data) { if (RestConfig.isStatusOk(dsResponse)) { Record[] records = dsResponse.getData(); for (Record record : records) { String mid = record.getAttribute(FIELD_ID); String way = record.getAttribute(FIELD_WAY); String pk = mid; if (way != null) { pk = mid + way; } record.setAttribute(PRIMARY_KEY, pk); } } super.transformResponse(dsResponse, dsRequest, data); }
protected void addEdit(Record record) { Object val = null; if (record != null) val = record.getAttributeAsObject("_obj"); int[] hw = getWindowHW(); new CommonDialog(getCommonSavePanel(this, val, record), true, hw[0], hw[1], getWindowTitle()) .show(); }
private DataSource getRecentlyAccessed() { final DataSource datasource = new DataSource(); datasource.setClientOnly(true); datasource.setCacheAllData(true); datasource.setAutoCacheAllData(true); int j = accesshistory.get(selectedCriterion.displaytype).getStack().size(); final Record[] records = new Record[j]; for (final AccessString access : accesshistory.get(selectedCriterion.displaytype).getStack()) { final Record record = new Record(JSONParser.parseStrict(access.asString()).isObject().getJavaScriptObject()); record.setAttribute("row", j); record.setAttribute("lastmodified", record.getAttribute("lastmodified").substring(0, 10)); records[--j] = record; } datasource.setTestData(records); return datasource; }
private void saveNewDigitalObject(String modelId, String pid, String mods) { Record r = new Record(); DigitalObjectDataSource ds = DigitalObjectDataSource.getInstance(); r.setAttribute(DigitalObjectDataSource.FIELD_MODEL, modelId); if (mods != null) { r.setAttribute(DigitalObjectDataSource.FIELD_MODS, mods); } if (pid != null && !pid.isEmpty()) { r.setAttribute(DigitalObjectDataSource.FIELD_PID, pid); } DSRequest dsRequest = new DSRequest(); dsRequest.setWillHandleError(true); ds.addData( r, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (response.getStatus() == RPCResponse.STATUS_VALIDATION_ERROR) { Map errors = response.getErrors(); newDigObject.setValidationErrors(errors); request.setWillHandleError(true); return; } if (response.getHttpResponseCode() >= 400) { // failure SC.warn("Failed to create digital object!"); } else { Record[] data = response.getData(); if (data != null && data.length > 0) { String pid = data[0].getAttribute(DigitalObjectDataSource.FIELD_PID); // here should be updated DigitalObject data stream // caches to prevent server round-trip delays StatusView.getInstance().show(i18n.DigitalObjectCreator_FinishedStep_Done_Msg()); places.goTo(new DigitalObjectEditorPlace(DatastreamEditorType.MODS, pid)); } else { SC.warn("Failed to create digital object!"); } } } }, dsRequest); }
private List<TransitLPActivityUnit> getActivityUnits() { ArrayList<TransitLPActivityUnit> activityUnit = new ArrayList<TransitLPActivityUnit>(); System.out.println("Size : " + view.getUnitChoices().size()); for (List<Record> unitRecord : view.getUnitChoices()) { TransitLPActivityUnit unit = new TransitLPActivityUnit(); unit.setCategory(transitCategory.getId()); for (Record record : unitRecord) { System.out.println( "CHOICe activity to be added : " + ((TransitLPActivity) record.getAttributeAsObject("transit")).getName()); unit.addActivity(((TransitLPActivity) record.getAttributeAsObject("transit")).getId()); } activityUnit.add(unit); } return activityUnit; }
private void askForExportOptions(String[] pids) { if (pids == null || pids.length == 0) { return; } Record export = new Record(); export.setAttribute(ExportResourceApi.CROSSREF_PID_PARAM, pids); // ExportOptionsWidget.showOptions(export, new Callback<Record, Void>() { // // @Override // public void onFailure(Void reason) { // // no-op // } // // @Override // public void onSuccess(Record result) { // exportOrValidate(result); // } // }); exportOrValidate(export); }
/** * Get comments * * @param attributes * @param record */ public void doGet(final HashMap<String, String> attributes, final Record record) { String type = attributes.get(MethodConstants.ATTR_TYPE); if (type.equals(ClassificationConstants.FNC_ID_Comment)) { String posting = record.getAttributeAsString(JaxrConstants.RIM_ID); CommentGridImpl grid = new CommentGridImpl(posting); new CommentsViewer(grid); } }
private void changeStatus(Integer calendar_id, Integer deleted) { try { com.smartgwt.client.rpc.RPCManager.startQueue(); Record record = new Record(); record.setAttribute("deleted", deleted); record.setAttribute("calendar_id", calendar_id); record.setAttribute( "loggedUserName", CommonSingleton.getInstance().getSessionPerson().getUserName()); DSRequest req = new DSRequest(); req.setAttribute("operationId", "updateSecularCalendarStatus"); listGrid.updateData( record, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) {} }, req); com.smartgwt.client.rpc.RPCManager.sendQueue(); } catch (Exception e) { SC.say(e.toString()); } }
@Override protected void editRecord(Record record) { super.editRecord(record); Record[] bundleRecords = record.getAttributeAsRecordArray(BundleGroupsDataSource.FIELD_BUNDLES); ListGridRecord[] bundleListGridRecords = toListGridRecordArray(bundleRecords); this.bundleSelector = new BundleSelector(bundleListGridRecords, canAssign, canUnassign); this.bundleSelector.addAssignedItemsChangedHandler( new AssignedItemsChangedHandler() { public void onSelectionChanged(AssignedItemsChangedEvent event) { BundleGroupEditView.this.onItemChanged(); } }); updateTab(this.bundlesTab, this.bundleSelector); }
@Override public GUIDocument markSelectedAsCheckedIn() { Record record = getSelectedRecord(); if (record == null) return null; record.setAttribute("locked", "blank"); record.setAttribute("status", Constants.DOC_UNLOCKED); record.setAttribute("indexed", Constants.INDEX_TO_INDEX); record.setAttribute("signed", "blank"); record.setAttribute("extResId", (String) null); redraw(); return getSelectedDocument(); }
public void setDataValue(Object val, Record record) { record.setAttribute("_obj", val); setOtherValues(val, record); }
public void copyFromRecord(Record from) { setId(from.getAttributeAsInt("id")); setName(from.getAttributeAsString("name")); setDate(from.getAttributeAsDate("date")); }
/* public static void addGoodsCategoryToListAsRecord(Record record) { AddGoods.setGoodsCategoryAsRecord(record); } */ public static void addGoodsCategoryToListAsRecord(Record record, String action) { goodsCategoryList.addData(record.getAttributeAsRecord("goodsCategory")); goodsCategoryList.saveAllEdits(); AddGoods.setGoodsCategoryAsRecord(record); sendUpdateToAllClient(Constants.SELL_HS_GOODSCATEGORYLIST_ID); }
public void copyToRecord(Record to) { to.setAttribute("id", getId()); to.setAttribute("name", getName()); to.setAttribute("date", getDate()); }
@Override public ResourceGroupComposite copyValues(Record from) { Integer idAttrib = from.getAttributeAsInt("id"); String nameAttrib = from.getAttribute(NAME.propertyName()); String descriptionAttrib = from.getAttribute(DESCRIPTION.propertyName()); String typeNameAttrib = from.getAttribute(TYPE.propertyName()); ResourceGroup rg = new ResourceGroup(nameAttrib); rg.setId(idAttrib); rg.setDescription(descriptionAttrib); if (typeNameAttrib != null) { ResourceType rt = new ResourceType(); rt.setName(typeNameAttrib); String pluginNameAttrib = from.getAttribute(PLUGIN.propertyName()); rt.setPlugin(pluginNameAttrib); rg.setResourceType(rt); } Long explicitCount = Long.valueOf(from.getAttribute("explicitCount")); Long explicitDown = Long.valueOf(from.getAttribute("explicitDown")); Long explicitUnknown = Long.valueOf(from.getAttribute("explicitUnknown")); Long explicitDisabled = Long.valueOf(from.getAttribute("explicitDisabled")); Long implicitCount = Long.valueOf(from.getAttribute("implicitCount")); Long implicitDown = Long.valueOf(from.getAttribute("implicitDown")); Long implicitUnknown = Long.valueOf(from.getAttribute("implicitUnknown")); Long implicitDisabled = Long.valueOf(from.getAttribute("implicitDisabled")); ResourceGroupComposite composite = new ResourceGroupComposite( explicitCount, explicitDown, explicitUnknown, explicitDisabled, implicitCount, implicitDown, implicitUnknown, implicitDisabled, rg); return composite; }
@Override public void init() { Criteria criteria = null; if (parentRecord != null) { criteria = new Criteria(); criteria.setAttribute("Class_id", (Long) parentRecord.getAttributeAsLong("Class_id")); } else { Record rec = this.selectedRecord; criteria = new Criteria(); criteria.setAttribute("Class_id", (Long) rec.getAttributeAsLong("Class_id")); } tabs.setHeight100(); tabs.setWidth100(); final ClassModelMessages ClassMessagesd = (ClassModelMessages) GWT.create(ClassModelMessages.class); // let First tab be the Detail page of the current row, ie. the form thing. Tab tab_details = new Tab(ClassMessagesd.name_single()); tab_details.addTabDeselectedHandler( detailView); // has to respond with a form save, when we select a different tab tab_details.setPane(detailView); tabs.addTab(tab_details); tab_details.addTabSelectedHandler( new TabSelectedHandler() { @Override public void onTabSelected(TabSelectedEvent event) { getBreadcrumbs().removeAfter("Class_single"); } }); if (userDetails.hasAuthority("CAN_READ_TEAM_TAB") || userDetails.hasAuthority("CAN_READ_TAB_TEAM") || userDetails.hasAuthority("CAN_READ_CLASS_TAB_REF")) { Log.debug("Detected rights: CAN_READ_TEAM_TAB, showing tab"); teamsInClass_Team_Widget teamsInClass_Team = new teamsInClass_Team_Widget(criteria, userDetails); this.refs.add(teamsInClass_Team); final TeamModelMessages TeamMessages = (TeamModelMessages) GWT.create(TeamModelMessages.class); Tab tab_teamsInClass_Team_Widget = new Tab(TeamMessages.tab_name_TeamModel()); tab_teamsInClass_Team_Widget.setPane(teamsInClass_Team); modelToTitleMap.put("Team", TeamMessages.tab_name_TeamModel()); tab_teamsInClass_Team_Widget.addTabSelectedHandler( new TabSelectedHandler() { @Override public void onTabSelected(TabSelectedEvent event) { // if the last element's key doesn't end with _single, pop it first if (!getBreadcrumbs().lastCrumbIsSingle()) { getBreadcrumbs().popLast(); } // then add the target's normal crumb getBreadcrumbs().addCrumb("Team", TeamMessages.tab_name_TeamModel()); } }); tabs.addTab(tab_teamsInClass_Team_Widget); } else { Log.debug("No rights: CAN_READ_TEAM_TAB detected, not showing tab"); } attachToCanvas(); }
private void saveCountry() { try { String cityNameGeo = cityNameGeoItem.getValueAsString(); if (cityNameGeo == null || cityNameGeo.trim().equalsIgnoreCase("")) { SC.say("შეიყვანეთ ქართული დასახელება !"); return; } String town_code = cityCodeItem.getValueAsString(); // if (town_code == null || town_code.trim().equalsIgnoreCase("")) { // SC.say("შეიყვანეთ ქალაქის კოდი !"); // return; // } String town_code_new = cityNewCodeItem.getValueAsString(); ListGridRecord country_record = countryItem.getSelectedRecord(); if (country_record == null || country_record.getAttributeAsInt("country_id") == null) { SC.say("გთხოვთ აირჩიოთ ქვეყანა !"); return; } Integer country_id = country_record.getAttributeAsInt("country_id"); if (cityNameGeo.length() > 1005) { SC.say("ქართული დასახელება შედგება მაქსიმუმ 155 სიმბოლოსაგან !"); return; } // if (town_code.length() > 180) { // SC.say("ქალაქის კოდი შედგება მაქსიმუმ 90 სიმბოლოსაგან !"); // return; // } // if (town_code_new != null && town_code_new.length() > 180) { // SC.say("ქალაქის ახალი კოდი შედგება მაქსიმუმ 90 სიმბოლოსაგან !"); // return; // } ListGridRecord city_type_record = townTypeItem.getSelectedRecord(); if (city_type_record == null || city_type_record.getAttributeAsInt("description_id") == null) { SC.say("გთხოვთ აირჩიოთ ქალაქის ტიპი !"); return; } Integer town_type_id = city_type_record.getAttributeAsInt("description_id"); String capital_town_record = isCapitalItem.getValueAsString(); if (capital_town_record == null || capital_town_record.trim().equals("")) { SC.say("გთხოვთ აირჩიოთ ქალაქის სახეობა !"); return; } Integer capital_town = Integer.parseInt(capital_town_record); // try { // Integer.parseInt(town_code); // } catch (NumberFormatException e) { // SC.say("ქალაქის კოდის შედგება მხოლოდ ციფრებისაგან !"); // return; // } // if (town_code_new != null && !town_code_new.equals("")) { // try { // Integer.parseInt(town_code_new); // } catch (NumberFormatException e) { // SC.say("ქალაქის ახალი კოდის შედგება მხოლოდ ციფრებისაგან !"); // return; // } // } String normal_gmt = ofGmtItem.getValueAsString(); if (normal_gmt == null || normal_gmt.trim().equals("")) { SC.say("გთხოვთ შეიყვანოთ დრო !"); return; } try { Integer.parseInt(normal_gmt); } catch (NumberFormatException e) { SC.say("დრო შედგება მხოლოდ ციფრებისაგან !"); return; } String winter_gmt = ofGmtWinterItem.getValueAsString(); if (winter_gmt == null || winter_gmt.trim().equals("")) { SC.say("გთხოვთ შეიყვანოთ ზამთრის დრო !"); return; } try { Integer.parseInt(winter_gmt); } catch (NumberFormatException e) { SC.say("ზამთრის დრო შედგება მხოლოდ ციფრებისაგან !"); return; } com.smartgwt.client.rpc.RPCManager.startQueue(); Record record = new Record(); record.setAttribute("town_name", cityNameGeo); record.setAttribute("town_code", town_code); record.setAttribute("town_new_code", town_code_new); record.setAttribute("country_id", country_id); record.setAttribute("town_type_id", town_type_id); record.setAttribute("capital_town", capital_town); record.setAttribute("normal_gmt", normal_gmt); record.setAttribute("winter_gmt", winter_gmt); if (lCityRecord != null) { record.setAttribute("town_id", lCityRecord.getAttributeAsInt("town_id")); } record.setAttribute( "loggedUserName", CommonSingleton.getInstance().getSessionPerson().getUser_name()); DSRequest req = new DSRequest(); if (lCityRecord == null) { req.setAttribute("operationId", "townAdd"); cityGrid.addData( record, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { destroy(); } }, req); } else { req.setAttribute("operationId", "townUpdate"); cityGrid.updateData( record, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { destroy(); } }, req); } com.smartgwt.client.rpc.RPCManager.sendQueue(); } catch (Exception e) { e.printStackTrace(); SC.say(e.toString()); } }