public VoteListGrid() { super(); // initialize the List Grid fields ListGridField iconField = new ListGridField(ICON, ICON_DISPLAY_NAME, ICON_COLUMN_LENGTH); iconField.setImageSize(16); iconField.setAlign(Alignment.CENTER); iconField.setType(ListGridFieldType.IMAGE); iconField.setImageURLPrefix(URL_PREFIX); iconField.setImageURLSuffix(URL_SUFFIX); ListGridField voteCodeField = new ListGridField(VOTE_CODE, VOTE_CODE_DISPLAY); voteCodeField.setWidth("20%"); ListGridField voteNameField = new ListGridField(VOTE_NAME, VOTE_NAME_DISPLAY); voteNameField.setWidth("20%"); ListGridField voteIDField = new ListGridField(VOTE_ID, VOTE_ID_DISPLAY); voteIDField.setHidden(true); ListGridField createdByField = new ListGridField(CREATED_BY, CREATED_BY_DISPLAY); createdByField.setWidth("20%"); ListGridField changedByField = new ListGridField(CHANGED_BY, CHANGED_BY_DISPLAY); changedByField.setWidth("20%"); ListGridField emptyField = new ListGridField(EMPTY_FIELD, EMPTY_FIELD_DISPLAY_NAME); this.setCanPickFields(false); this.setShowRowNumbers(true); this.setFields(voteIDField, voteNameField, voteCodeField, createdByField, changedByField); }
private ListGridField createIconField() { ListGridField iconField = new ListGridField("icon", " ", 28); iconField.setShowDefaultContextMenu(false); iconField.setCanSort(false); iconField.setAlign(Alignment.CENTER); iconField.setType(ListGridFieldType.IMAGE); iconField.setImageURLSuffix("_16.png"); iconField.setImageWidth(16); iconField.setImageHeight(16); return iconField; }
public SearchValueSetItemsListGrid() { super(); i_valueSetItemSearchXmlDS = ValueSetItemSearchXmlDS.getInstance(); setWidth100(); setHeight100(); setShowAllRecords(true); setWrapCells(false); setDataSource(i_valueSetItemSearchXmlDS); setEmptyMessage(EMPTY_MESSAGE); ListGridField addField = new ListGridField("add", "Add"); addField.setType(ListGridFieldType.BOOLEAN); addField.setShowHover(false); addField.setDefaultValue(false); addField.setCanEdit(true); addField.addChangedHandler( new ChangedHandler() { @Override public void onChanged(ChangedEvent changedEvent) { if ((Boolean) changedEvent.getValue()) { ListGridRecord selected = getSelectedRecord(); String uri = selected.getAttribute("uri"); String code = selected.getAttribute("name"); String description = selected.getAttribute("designation"); String codeSystem = selected.getAttribute("namespace"); String codeSystemVersion = selected.getAttribute("codeSystemVersion"); Cts2Editor.EVENT_BUS.fireEvent( new AddEntitySelectedEvent( uri, code, description, codeSystem, codeSystemVersion)); } else { ListGridRecord selected = getSelectedRecord(); String href = selected.getAttribute("uri"); Cts2Editor.EVENT_BUS.fireEvent(new AddEntityDeselectedEvent(href)); } } }); ListGridField nameField = new ListGridField(ID_NAME, TITLE_NAME); nameField.setWrap(false); nameField.setWidth("25%"); nameField.setShowHover(false); nameField.setCanEdit(false); nameField.setCellFormatter( new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value != null) { return addCellHighlights(value.toString()); } else { return null; } } }); ListGridField designationField = new ListGridField(ID_DESIGNATION, TITLE_DESIGNATION); designationField.setWrap(false); designationField.setWidth("*"); designationField.setCanEdit(false); designationField.setCellFormatter( new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value != null) { return addCellHighlights(value.toString()); } else { return null; } } }); setFields(addField, nameField, designationField); setSelectOnEdit(true); setSelectionAppearance(SelectionAppearance.ROW_STYLE); setSelectionType(SelectionStyle.SINGLE); // Set edit and edit event to get the download checkbox to work // correctly. setCanEdit(true); setAutoFetchData(false); setCanHover(true); setShowHover(true); setShowHoverComponents(true); // set the initial sort SortSpecifier[] sortspec = new SortSpecifier[1]; sortspec[0] = new SortSpecifier(ID_NAME, SortDirection.ASCENDING); setInitialSort(sortspec); // addEventHandlers(); }
public Canvas getViewPanel() { VLayout layout = new VLayout(15); layout.setWidth(650); layout.setAutoHeight(); final ListGrid countryGrid = new ListGrid(); countryGrid.setLeaveScrollbarGap(true); countryGrid.setCanFreezeFields(false); countryGrid.setCanGroupBy(false); countryGrid.setWidth100(); countryGrid.setHeight(224); countryGrid.setDataSource(CountryXmlDS.getInstance()); countryGrid.setAutoFetchData(true); // allow users to add formula and summary fields // accessible in the grid header context menu countryGrid.setCanAddFormulaFields(true); countryGrid.setCanAddSummaryFields(true); ListGridField countryCodeField = new ListGridField("countryCode", "Flag", 50); countryCodeField.setAlign(Alignment.CENTER); countryCodeField.setType(ListGridFieldType.IMAGE); countryCodeField.setImageURLPrefix("flags/16/"); countryCodeField.setImageURLSuffix(".png"); countryCodeField.setCanSort(false); ListGridField nameField = new ListGridField("countryName", "Country"); ListGridField capitalField = new ListGridField("capital", "Capital"); ListGridField populationField = new ListGridField("population", "Population"); populationField.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value == null) return null; try { NumberFormat nf = NumberFormat.getFormat("0,000"); return nf.format(((Number) value).longValue()); } catch (Exception e) { return value.toString(); } } }); ListGridField areaField = new ListGridField("area", "Area (km²)"); areaField.setType(ListGridFieldType.INTEGER); areaField.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value == null) return null; String val = null; try { NumberFormat nf = NumberFormat.getFormat("0,000"); val = nf.format(((Number) value).longValue()); } catch (Exception e) { return value.toString(); } return val + "km²"; } }); countryGrid.setFields(countryCodeField, nameField, capitalField, populationField, areaField); ToolStripButton formulaButton = new ToolStripButton("Formula Builder", "crystal/oo/sc_insertformula.png"); formulaButton.setAutoFit(true); formulaButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { countryGrid.addFormulaField(); } }); ToolStripButton summaryBuilder = new ToolStripButton("Summary Builder", "crystal/16/apps/tooloptions.png"); summaryBuilder.setAutoFit(true); summaryBuilder.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { countryGrid.addSummaryField(); } }); ToolStripButton savePreference = new ToolStripButton("Persist State", "silk/database_gear.png"); savePreference.setAutoFit(true); savePreference.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { String viewState = countryGrid.getViewState(); Offline.put("exampleState", viewState); SC.say("Preferences persisted."); } }); // toolstrip to attach to the country grid ToolStrip countryGridToolStrip = new ToolStrip(); countryGridToolStrip.setWidth100(); countryGridToolStrip.addFill(); countryGridToolStrip.addButton(formulaButton); countryGridToolStrip.addButton(summaryBuilder); countryGridToolStrip.addSeparator(); countryGridToolStrip.addButton(savePreference); VLayout countryGridLayout = new VLayout(0); countryGridLayout.setWidth(650); countryGridLayout.addMember(countryGridToolStrip); countryGridLayout.addMember(countryGrid); layout.addMember(countryGridLayout); final String previouslySavedState = (String) Offline.get("exampleState"); if (previouslySavedState != null) { countryGrid.addDrawHandler( new DrawHandler() { @Override public void onDraw(DrawEvent event) { // restore any previously saved view state for this grid countryGrid.setViewState(previouslySavedState); } }); } return layout; }
public teamsInClass_Team_Widget( final Criteria criteria, final UserDetailsReceivedEvent userDetails) { this.userDetails = userDetails; final TeamModelMessages targetMessages = (TeamModelMessages) GWT.create(TeamModelMessages.class); BoatTypeModelMessages boatTypeMessages = (BoatTypeModelMessages) GWT.create(BoatTypeModelMessages.class); setPadding(10); setIsGroup(true); setGroupTitle( classMessages.richFormView_teamsInClass_coupling_with_Team( targetMessages.tab_name_TeamModel())); // all elements from the target reference, to be picked from to make a connection setWidth100(); setHeight100(); this.grid.setWidth100(); // grid.setHeight(150); //automatically ought to use all the space // grid.setHeight("*"); this.grid.setAlternateRecordStyles(false); this.grid.setCellHeight(32); this.grid.setDataSource(dataSource); this.grid.setAutoFetchData(false); this.grid.setCanEdit(true); this.grid.setModalEditing(true); this.grid.setShowFilterEditor(true); this.grid.setDoubleClickDelay(100); this.grid.setEditEvent(ListGridEditEvent.DOUBLECLICK); this.grid.setListEndEditAction(RowEndEditAction.DONE); this.grid.setCanRemoveRecords(true); this.grid.setAutoSaveEdits(true); this.grid.setCanSelectText(true); this.grid.setAllowFilterExpressions(true); this.grid.setCanDragSelectText(true); this.grid.setCanRemoveRecords( false); // we have our own delete button, with extra functionality /* */ ListGridField idField = new ListGridField("Team_id", "Team id"); ListGridField sailNumberField = new ListGridField("sailNumber", targetMessages.sailNumber()); sailNumberField.setAlign(Alignment.LEFT); sailNumberField = TeamRichTableView.setFormatterForsailNumber(sailNumberField); ListGridField teamNameField = new ListGridField("teamName", targetMessages.teamName()); teamNameField.setAlign(Alignment.LEFT); teamNameField = TeamRichTableView.setFormatterForteamName(teamNameField); ListGridField nameCaptainField = new ListGridField("nameCaptain", targetMessages.nameCaptain()); nameCaptainField.setAlign(Alignment.LEFT); nameCaptainField = TeamRichTableView.setFormatterFornameCaptain(nameCaptainField); ListGridField streetField = new ListGridField("street", targetMessages.street()); streetField.setAlign(Alignment.LEFT); streetField = TeamRichTableView.setFormatterForstreet(streetField); ListGridField zipcodeField = new ListGridField("zipcode", targetMessages.zipcode()); zipcodeField.setAlign(Alignment.LEFT); zipcodeField = TeamRichTableView.setFormatterForzipcode(zipcodeField); ListGridField cityField = new ListGridField("city", targetMessages.city()); cityField.setAlign(Alignment.LEFT); cityField = TeamRichTableView.setFormatterForcity(cityField); ListGridField emailField = new ListGridField("email", targetMessages.email()); emailField.setAlign(Alignment.LEFT); emailField = TeamRichTableView.setFormatterForemail(emailField); ListGridField phoneField = new ListGridField("phone", targetMessages.phone()); phoneField.setAlign(Alignment.LEFT); phoneField = TeamRichTableView.setFormatterForphone(phoneField); ListGridField numPersonsField = new ListGridField("numPersons", targetMessages.numPersons()); numPersonsField.setAlign(Alignment.LEFT); numPersonsField = TeamRichTableView.setFormatterFornumPersons(numPersonsField); ListGridField toerField = new ListGridField("toer", targetMessages.toer()); toerField = TeamRichTableView.setFormatterFortoer(toerField); ListGridField spinField = new ListGridField("spin", targetMessages.spin()); spinField = TeamRichTableView.setFormatterForspin(spinField); ListGridField waitinglistField = new ListGridField("waitinglist", targetMessages.waitinglist()); waitinglistField = TeamRichTableView.setFormatterForwaitinglist(waitinglistField); ListGridField femaleTeamField = new ListGridField("femaleTeam", targetMessages.femaleTeam()); femaleTeamField = TeamRichTableView.setFormatterForfemaleTeam(femaleTeamField); ListGridField remark_Field = new ListGridField("remark_", targetMessages.remark_()); remark_Field.setAlign(Alignment.LEFT); remark_Field = TeamRichTableView.setFormatterForremark_(remark_Field); ListGridField teamStartTimeField = new ListGridField("teamStartTime", targetMessages.teamStartTime()); teamStartTimeField.setAlign(Alignment.LEFT); teamStartTimeField = TeamRichTableView.setFormatterForteamStartTime(teamStartTimeField); teamStartTimeField.setTimeFormatter(TimeDisplayFormat.TOSHORTPADDED24HOURTIME); // call to a custom field, this class should be created customly teamStartTimeField = nl.sytematic.projects.BrioRaceSystem.client.custom.TeamTeamStartTimeCustomFieldFactory .getCustomField(grid, teamStartTimeField, userDetails); ListGridField endTimeField = new ListGridField("endTime", targetMessages.endTime()); endTimeField.setAlign(Alignment.LEFT); endTimeField = TeamRichTableView.setFormatterForendTime(endTimeField); endTimeField.setTimeFormatter(TimeDisplayFormat.TOSHORTPADDED24HOURTIME); ListGridField sailingTimeField = new ListGridField("sailingTime", targetMessages.sailingTime()); sailingTimeField.setAlign(Alignment.LEFT); sailingTimeField = TeamRichTableView.setFormatterForsailingTime(sailingTimeField); sailingTimeField.setTimeFormatter(TimeDisplayFormat.TOSHORTPADDED24HOURTIME); // call to a custom field, this class should be created customly sailingTimeField = nl.sytematic.projects.BrioRaceSystem.client.custom.TeamSailingTimeCustomFieldFactory .getCustomField(grid, sailingTimeField, userDetails); ListGridField swTimeField = new ListGridField("swTime", targetMessages.swTime()); swTimeField.setAlign(Alignment.LEFT); swTimeField = TeamRichTableView.setFormatterForswTime(swTimeField); swTimeField.setTimeFormatter(TimeDisplayFormat.TOSHORTPADDED24HOURTIME); // call to a custom field, this class should be created customly swTimeField = nl.sytematic.projects.BrioRaceSystem.client.custom.TeamSwTimeCustomFieldFactory .getCustomField(grid, swTimeField, userDetails); ListGridField registrationDateTimeField = new ListGridField("registrationDateTime", targetMessages.registrationDateTime()); registrationDateTimeField.setAlign(Alignment.LEFT); registrationDateTimeField = TeamRichTableView.setFormatterForregistrationDateTime(registrationDateTimeField); // registrationDateTimeField.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATETIME); DateTimeItem registrationDateTimeEditor = new DateTimeItem(); registrationDateTimeEditor.setUseTextField(true); registrationDateTimeEditor.setUseMask(true); // registrationDateTimeEditor.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATETIME); registrationDateTimeField.setEditorType(registrationDateTimeEditor); // registrationDateTimeField.setFilterEditorType(registrationDateTimeEditor); // call to a custom field, this class should be created customly registrationDateTimeField = nl.sytematic.projects.BrioRaceSystem.client.custom .TeamRegistrationDateTimeCustomFieldFactory.getCustomField( grid, registrationDateTimeField, userDetails); ListGridField payDateField = new ListGridField("payDate", targetMessages.payDate()); payDateField.setAlign(Alignment.LEFT); payDateField = TeamRichTableView.setFormatterForpayDate(payDateField); // payDateField.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE); DateItem payDateEditor = new DateItem(); payDateEditor.setUseTextField(true); payDateEditor.setUseMask(true); // payDateEditor.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE); payDateField.setEditorType(payDateEditor); // payDateField.setFilterEditorType(payDateEditor); ListGridField payOrderField = new ListGridField("payOrder", targetMessages.payOrder()); payOrderField.setAlign(Alignment.LEFT); payOrderField = TeamRichTableView.setFormatterForpayOrder(payOrderField); ListGridField payIdField = new ListGridField("payId", targetMessages.payId()); payIdField.setAlign(Alignment.LEFT); payIdField = TeamRichTableView.setFormatterForpayId(payIdField); ListGridField acceptedField = new ListGridField("accepted", targetMessages.accepted()); acceptedField = TeamRichTableView.setFormatterForaccepted(acceptedField); ListGridField payStatusField = new ListGridField("payStatus", targetMessages.payStatus()); payStatusField.setAlign(Alignment.LEFT); payStatusField = TeamRichTableView.setFormatterForpayStatus(payStatusField); ListGridField BoatTypeField = new ListGridField("BoatType_id", boatTypeMessages.name_single()); ListGridField ClassField = new ListGridField("Class_id", classMessages.name_single()); final SelectItem BoatTypeSelectItem = new SelectItem("BoatType_id", boatTypeMessages.name_single()); BoatTypeSelectItem.setOptionDataSource(DataSource.get("BoatType")); BoatTypeSelectItem.setValueField("BoatType_id"); BoatTypeSelectItem.setAlign(Alignment.LEFT); BoatTypeSelectItem.setTextAlign(Alignment.LEFT); BoatTypeSelectItem.setTitleAlign(Alignment.LEFT); ListGrid BoatTypeListGrid = new ListGrid(); BoatTypeListGrid.setShowFilterEditor(true); BoatTypeListGrid.setFilterOnKeypress(true); SortSpecifier BoatTypeSort = new SortSpecifier("typeName", SortDirection.ASCENDING); SortSpecifier[] BoatTypeSorts = new SortSpecifier[] {BoatTypeSort}; BoatTypeListGrid.setInitialSort(BoatTypeSorts); BoatTypeSelectItem.setDisplayField("typeName"); BoatTypeSelectItem.setAllowEmptyValue(true); BoatTypeSelectItem.setPickListWidth(800); BoatTypeSelectItem.setPickListFields( new ListGridField("typeName", boatTypeMessages.typeName()), new ListGridField("SW_value", boatTypeMessages.SW_value())); BoatTypeSelectItem.setPickListProperties(BoatTypeListGrid); BoatTypeField.setAlign(Alignment.LEFT); BoatTypeField.setEditorType(BoatTypeSelectItem); BoatTypeField.setOptionDataSource(DataSource.get("BoatType")); BoatTypeField.setDisplayField("typeName"); BoatTypeField.setFilterEditorType(BoatTypeSelectItem); // reusing this is okay appareantly ButtonItem newBoatType = new ButtonItem("newBoatType", boatTypeMessages.new_window()); newBoatType.addClickHandler( new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { BoatTypeNewEntryWindow w = new BoatTypeNewEntryWindow( null, new DSCallback() { @Override public void execute( DSResponse response, Object rawData, DSRequest request) { RecordList rl = response.getDataAsRecordList(); if (rl.getLength() > 0) { Record r = rl.get(0); Log.debug("Record found in callback"); Integer id = r.getAttributeAsInt("BoatType_id"); Log.debug("ID is " + id); BoatTypeSelectItem.setValue(id); // select the just added value } } }); w.show(); w.bringToFront(); } }); final SelectItem ClassSelectItem = new SelectItem("Class_id", classMessages.name_single()); ClassSelectItem.setOptionDataSource(DataSource.get("Class")); ClassSelectItem.setValueField("Class_id"); ClassSelectItem.setAlign(Alignment.LEFT); ClassSelectItem.setTextAlign(Alignment.LEFT); ClassSelectItem.setTitleAlign(Alignment.LEFT); ListGrid ClassListGrid = new ListGrid(); ClassListGrid.setShowFilterEditor(true); ClassListGrid.setFilterOnKeypress(true); SortSpecifier ClassSort = new SortSpecifier("className", SortDirection.ASCENDING); SortSpecifier[] ClassSorts = new SortSpecifier[] {ClassSort}; ClassListGrid.setInitialSort(ClassSorts); ClassSelectItem.setDisplayField("className"); ClassSelectItem.setAllowEmptyValue(true); ClassSelectItem.setPickListWidth(800); ClassSelectItem.setPickListFields( new ListGridField("className", classMessages.className()), new ListGridField("startTime", classMessages.startTime())); ClassSelectItem.setPickListProperties(ClassListGrid); ClassField.setAlign(Alignment.LEFT); ClassField.setEditorType(ClassSelectItem); ClassField.setOptionDataSource(DataSource.get("Class")); ClassField.setDisplayField("className"); ClassField.setFilterEditorType(ClassSelectItem); // reusing this is okay appareantly ButtonItem newClass = new ButtonItem("newClass", classMessages.new_window()); newClass.addClickHandler( new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { ClassNewEntryWindow w = new ClassNewEntryWindow( null, new DSCallback() { @Override public void execute( DSResponse response, Object rawData, DSRequest request) { RecordList rl = response.getDataAsRecordList(); if (rl.getLength() > 0) { Record r = rl.get(0); Log.debug("Record found in callback"); Integer id = r.getAttributeAsInt("Class_id"); Log.debug("ID is " + id); ClassSelectItem.setValue(id); // select the just added value } } }); w.show(); w.bringToFront(); } }); ListGridField deleteField = new ListGridField("deleteField", "-"); deleteField.setShouldPrint(false); deleteField.setCellIcon( GWT.getHostPageBaseURL() + "images/icons/32/woofunction/remove_32.png"); deleteField.setType(ListGridFieldType.ICON); deleteField.setTitle(""); deleteField.setWidth(32); deleteField.setIconSize(24); deleteField.setCanDragResize(false); deleteField.setCanSort(false); deleteField.setCanEdit(false); deleteField.setCanGroupBy(false); deleteField.setCanFreeze(false); deleteField.setCanFilter(false); deleteField.setCanHide(false); deleteField.setCanReorder(false); this.grid.addRecordClickHandler( new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { ListGridField clicked = event.getField(); final Record r = event.getRecord(); if ("deleteField".equals(clicked.getName())) { SC.confirm( radosMessages.delete_confirm_coupling(), new BooleanCallback() { public void execute(Boolean confirmed) { if (confirmed != null && confirmed) { grid.removeData(r); } else { // Cancel } } }); } } }); ArrayList<ListGridField> fields = new ArrayList<ListGridField>(); fields.add(idField); fields.add(sailNumberField); fields.add(teamNameField); fields.add(nameCaptainField); fields.add(streetField); fields.add(zipcodeField); fields.add(cityField); fields.add(emailField); fields.add(phoneField); fields.add(numPersonsField); fields.add(toerField); fields.add(spinField); fields.add(waitinglistField); fields.add(femaleTeamField); fields.add(remark_Field); fields.add(teamStartTimeField); fields.add(endTimeField); fields.add(sailingTimeField); fields.add(swTimeField); fields.add(registrationDateTimeField); fields.add(payDateField); fields.add(payOrderField); fields.add(payIdField); fields.add(acceptedField); fields.add(payStatusField); fields.add(BoatTypeField); if (userDetails.hasAuthority("CAN_DELETE_TEAM")) { fields.add(deleteField); } ListGridField[] fieldsArr = fields.toArray(new ListGridField[fields.size()]); this.grid.setFields(fieldsArr); this.grid.fetchData(criteria); buttonPanel.setMargin(2); grid.hideField("Team_id"); // newButton.setSize(32); newButton.setIcon(GWT.getHostPageBaseURL() + "images/icons/32/woofunction/add_32.png"); newButton.setIconOrientation("right"); newButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { Map<String, Object> defaultValues = new HashMap<String, Object>(); defaultValues.put("Class_id", criteria.getAttribute("Class_id")); grid.startEditingNew(defaultValues); } }); buttonPanel.addMember(newButton); /*IButton printButton = new IButton(radosMessages.richTableView_print_button());*/ IButton printButton = new IButton(radosMessages.richTableView_print_button()); printButton.setShowRollOver(false); printButton.setIcon(GWT.getHostPageBaseURL() + "images/icons/32/woofunction/printer_32.png"); printButton.setIconOrientation("right"); // Img printButton = new // Img(GWT.getHostPageBaseURL()+"images/icons/32/woofunction/printer_32.png"); // printButton.setSize(32); // printButton.setAltText(radosMessages.richTableView_print_button()); printButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { Canvas.showPrintPreview(grid); } }); buttonPanel.addMember(printButton); EmailGridButtonWidget email = new EmailGridButtonWidget(new Canvas[] {grid}); email.setDefaultMessage(targetMessages.name_single() + "overzicht"); email.setDefaultSubject(targetMessages.name_single() + "overzicht"); email.setDefaultFrom(BrioRaceSystemApplicationPanel.getUserdetails().getEmail()); buttonPanel.addMember(email); ExportButtonWidget exportButton = new ExportButtonWidget(grid, dataSource); buttonPanel.addMember(exportButton); buttonPanel.setHeight(30); this.addMember(buttonPanel); this.addMember(grid); handleRights(); }
FlashUploadComponentImpl(final UploadComponentOptions options) { filesGrid.setHeight(100); filesGrid.setWidth100(); if (options.isAllowMultiple()) { filesGrid.setEmptyMessage("No files selected."); } else { filesGrid.setEmptyMessage("File not selected."); } final ListGridField nameField = new ListGridField("name", "File Name"); nameField.setType(ListGridFieldType.TEXT); nameField.setWidth("*"); filesGrid.setFields(nameField); final UploadBuilder builder = new UploadBuilder(); // Configure which file types may be selected if (options.getTypes() != null) { builder.setFileTypes(options.getTypes()); } if (options.getTypesDescription() != null) { builder.setFileTypesDescription(options.getTypesDescription()); } if (options.getTypesDescription() != null) { builder.setFileTypesDescription(options.getTypesDescription()); } clientId = getUniqueId(); final HTMLPane pane = new HTMLPane(); pane.setHeight(22); builder.setButtonPlaceholderID(clientId); builder.setButtonHeight(22); builder.setButtonWidth(100); pane.setWidth(100); if (options.isAllowMultiple()) { builder.setButtonImageURL(GWT.getHostPageBaseURL() + "images/uploadImageAddFiles.jpg"); } else { builder.setButtonImageURL(GWT.getHostPageBaseURL() + "images/uploadImageChooseFile.jpg"); } // Use ButtonAction.SELECT_FILE to only allow selection of a single file builder.setButtonAction( options.isAllowMultiple() ? ButtonAction.SELECT_FILES : ButtonAction.SELECT_FILE); builder.setFileQueuedHandler( new FileQueuedHandler() { public void onFileQueued(final FileQueuedEvent queuedEvent) { if (!options.isAllowMultiple()) { SmartUtils.removeAllRecords(filesGrid); } final ListGridRecord record = new ListGridRecord(); record.setAttribute("id", queuedEvent.getFile().getId()); record.setAttribute("name", queuedEvent.getFile().getName()); filesGrid.addData(record); } }); builder.setUploadSuccessHandler( new UploadSuccessHandler() { public void onUploadSuccess(final UploadSuccessEvent uploadEvent) { try { filesUploaded++; bytesUploaded += uploadEvent.getFile().getSize(); final String serverResponse = uploadEvent.getServerData(); fileSources.addAll(toFileSources(serverResponse)); updateUrl(); if (upload.getStats().getFilesQueued() > 0) { upload.startUpload(); } else { options.getCompletionCallback().onSuccess(fileSources); } } catch (final Exception e) { options.getCompletionCallback().onFailure(e); } } }); builder.setUploadErrorHandler( new UploadErrorHandler() { public void onUploadError(final UploadErrorEvent e) { options .getCompletionCallback() .onFailure(new Exception("Upload failed " + e.getMessage())); } }); // The button to start the transfer final Layout parent = getParentCanvas(options); setWidget(parent); // pane.setMargin(5); pane.setContents("<span id=\"" + clientId + "\" />"); reg = get() .addDrawHandler( new DrawHandler() { public void onDraw(final DrawEvent event) { upload = builder.build(); reg.removeHandler(); } }); final Button removeButton = SmartUtils.getButton("Remove File", Resources.CROSS); removeButton.addClickHandler( new ClickHandler() { public void onClick(final ClickEvent event) { final ListGridRecord record = filesGrid.getSelectedRecord(); final String id = record.getAttribute("id"); filesGrid.removeData(record); upload.cancelUpload(id, false); } }); SmartUtils.enabledWhenHasSelection(removeButton, filesGrid); removeButton.setDisabled(true); if (!options.isAllowMultiple()) { removeButton.hide(); } final CanvasWithOpsLayout<ClientListGrid> layout = new CanvasWithOpsLayout<ClientListGrid>(filesGrid, pane, removeButton); if (debug) { layout.setBorder("1px solid red"); parent.setBorder("1px solid orange"); } parent.addMember(layout); }
public ListaVentas(final Sgc_capa_web mainWindow) { String PATH_IMG = "/sgc_capa_web/images/"; VLayout layout = new VLayout(10); layout.setBackgroundColor("#006633"); final ListGrid facturaGrid = new ListGrid(); facturaGrid.setWidth(500); facturaGrid.setHeight(224); facturaGrid.setShowAllRecords(true); facturaGrid.setAlternateRecordStyles(true); facturaGrid.setShowEdges(true); facturaGrid.setBorder("0px"); facturaGrid.setBodyStyleName("normal"); facturaGrid.setLeaveScrollbarGap(false); facturaGrid.setBackgroundColor("#99ffcc"); /*-Buscar ------------------------------*/ DynamicForm buscarFields = new DynamicForm(); // buscarFields.setBackgroundColor("#99ffcc"); buscarFields.setItemLayout(FormLayoutType.ABSOLUTE); final TextItem codigoText = new TextItem("codigo"); codigoText.setWrapTitle(false); codigoText.setLeft(10); codigoText.setWidth(43); codigoText.addKeyPressHandler( new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if ("Enter".equals(event.getKeyName())) { /* buscar por el campo correspondiente */ if (codigoText.getValue() != null) { Factura factura = new Factura(); factura.setId(Integer.parseInt(codigoText.getValue().toString())); listar(facturaGrid, factura, "codigo"); } } } }); ButtonItem buscarButton = new ButtonItem("find", ""); buscarButton.setIcon("view.png"); buscarButton.setWidth(50); buscarButton.setLeft(443); buscarButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { /* buscar por el campo correspondiente */ Factura factura = new Factura(); if (codigoText.getValue() != null) factura.setId(Integer.parseInt(codigoText.getValue().toString())); /*if(nombreusuarioText.getValue() != null) cliente.setNombreusuario(nombreusuarioText.getValue().toString());*/ listar(facturaGrid, factura, "nombre"); } }); buscarFields.setFields(codigoText, buscarButton); /*--------------------------------------*/ ListGridField codigoField = new ListGridField("codigo", "Codigo"); ListGridField fechaField = new ListGridField("fecha", "Fecha"); ListGridField numeroField = new ListGridField("numero", "Numero"); ListGridField pendienteField = new ListGridField("pendiente", "Pendiente"); ListGridField saldoField = new ListGridField("saldo", "Saldo"); ListGridField editarField = new ListGridField("edit", "Editar"); ListGridField borrarField = new ListGridField("remove", "Borrar"); codigoField.setAlign(Alignment.CENTER); editarField.setAlign(Alignment.CENTER); borrarField.setAlign(Alignment.CENTER); editarField.setType(ListGridFieldType.IMAGE); borrarField.setType(ListGridFieldType.IMAGE); editarField.setImageURLPrefix(PATH_IMG); borrarField.setImageURLPrefix(PATH_IMG); editarField.setImageURLSuffix(".png"); borrarField.setImageURLSuffix(".png"); facturaGrid.addCellClickHandler( new CellClickHandler() { @Override public void onCellClick(CellClickEvent event) { ListGridRecord record = event.getRecord(); int col = event.getColNum(); if (col > 4) { Factura factura = new Factura(); factura.setId(record.getAttributeAsInt("codigo")); factura.setFecha(record.getAttributeAsDate("fecha")); factura.setNumero(Integer.parseInt(record.getAttribute("numero"))); factura.setPendiente(record.getAttribute("pendiente")); factura.setSaldo(Double.parseDouble(record.getAttribute("saldo"))); if (col == 5) { /* Editar */ new VentaDetalle(factura, mainWindow); } else { /* Borrar */ FacturaServiceAsync service = GWT.create(FacturaService.class); ServiceDefTarget serviceDef = (ServiceDefTarget) service; serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL() + "facturaService"); try { service.eliminar( record.getAttributeAsInt("codigo"), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { Window.alert( "Ocurrio un error y no se puedo eliminar (objeto referenciado)"); // " // + // caught.getClass().getName() + " " + caught.getMessage()) ; } @Override public void onSuccess(Void result) { new ListaVentas(mainWindow); } }); } catch (NumberFormatException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } } }); codigoField.setWidth(50); fechaField.setWidth(180); numeroField.setWidth(50); pendienteField.setWidth(50); saldoField.setWidth(50); facturaGrid.setFields( codigoField, fechaField, numeroField, pendienteField, saldoField, editarField, borrarField); facturaGrid.setCanResizeFields(true); ButtonItem button = new ButtonItem("add", "Agregar"); button.setStartRow(false); button.setWidth(80); button.setIcon("add.png"); button.setAlign(Alignment.CENTER); button.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { new VentaDetalle(mainWindow); } }); listar(facturaGrid, new Factura(), "nombre"); Label label = new Label(); label.setBackgroundColor("#99ffcc"); label.setHeight(30); label.setWidth(500); label.setPadding(10); label.setAlign(Alignment.CENTER); label.setValign(VerticalAlignment.CENTER); label.setWrap(false); label.setShowEdges(true); label.setContents("<div style='color:black;font-size:15'><b>Lista de Ventas</b></div>"); layout.addMember(label); layout.addMember(buscarFields); layout.addMember(facturaGrid); DynamicForm form = new DynamicForm(); // form.setBackgroundColor("#99ffcc"); form.setWidth(300); form.setItems(button); layout.addMember(form); mainWindow.showDialog(layout); }
@Override protected void configureTable() { getListGrid().setEmptyMessage(MSG.view_messageCenter_noRecentMessages()); updateTitleCanvas( MSG.view_messageCenter_lastNMessages( String.valueOf(CoreGUI.getMessageCenter().getMaxMessages()))); ListGridField severityField = new ListGridField(FIELD_SEVERITY); severityField.setType(ListGridFieldType.ICON); severityField.setAlign(Alignment.CENTER); severityField.setShowValueIconOnly(true); HashMap<String, String> severityIcons = new HashMap<String, String>(5); severityIcons.put(Severity.Blank.name(), getSeverityIcon(Severity.Blank)); severityIcons.put(Severity.Info.name(), getSeverityIcon(Severity.Info)); severityIcons.put(Severity.Warning.name(), getSeverityIcon(Severity.Warning)); severityIcons.put(Severity.Error.name(), getSeverityIcon(Severity.Error)); severityIcons.put(Severity.Fatal.name(), getSeverityIcon(Severity.Fatal)); severityField.setValueIcons(severityIcons); severityField.setShowHover(true); severityField.setHoverCustomizer( new HoverCustomizer() { @Override public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { try { Severity severity = ((Message) record.getAttributeAsObject(FIELD_OBJECT)).getSeverity(); switch (severity) { case Info: return MSG.common_severity_info(); case Warning: return MSG.common_severity_warn(); case Error: return MSG.common_severity_error(); case Fatal: return MSG.common_severity_fatal(); } } catch (Throwable e) { Log.error("Cannot get severity hover", e); } return null; } }); severityField.setSortNormalizer( new SortNormalizer() { @Override public Object normalize(ListGridRecord record, String fieldName) { try { Severity severity = ((Message) record.getAttributeAsObject(FIELD_OBJECT)).getSeverity(); return Integer.valueOf(severity.ordinal()); } catch (Throwable e) { Log.error("Cannot get sort nomalizer", e); } return Integer.valueOf(0); } }); ListGridField timeField = new ListGridField(FIELD_TIME, MSG.view_messageCenter_messageTime()); timeField.setType(ListGridFieldType.TIME); timeField.setAttribute("displayFormat", TimeFormatter.TOPADDEDTIME); timeField.setAlign(Alignment.LEFT); timeField.setShowHover(true); timeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(FIELD_TIME)); ListGridField messageField = new ListGridField(FIELD_CONCISEMESSAGE, MSG.common_title_message()); severityField.setWidth(25); timeField.setWidth("15%"); messageField.setWidth("*"); getListGrid().setFields(severityField, timeField, messageField); setListGridDoubleClickHandler( new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { try { ListGrid listGrid = (ListGrid) event.getSource(); ListGridRecord[] selectedRows = listGrid.getSelection(); if (selectedRows != null && selectedRows.length > 0) { Message message = (Message) selectedRows[0].getAttributeAsObject( FIELD_OBJECT); // show the first selected showDetails(message); } } catch (Throwable e) { Log.error("Cannot show details for message", e); } } }); addTableAction( extendLocatorId("delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(), new AbstractTableAction(TableActionEnablement.ANY) { @Override public void executeAction(ListGridRecord[] selection, Object actionValue) { try { for (ListGridRecord record : selection) { Object doomed = record.getAttributeAsObject(FIELD_OBJECT); CoreGUI.getMessageCenter().getMessages().remove(doomed); } refresh(); } catch (Throwable e) { Log.error("Cannot delete messages", e); } } }); addTableAction( extendLocatorId("deleteAll"), MSG.common_button_delete_all(), MSG.common_msg_areYouSure(), new AbstractTableAction(TableActionEnablement.ALWAYS) { @Override public void executeAction(ListGridRecord[] selection, Object actionValue) { try { CoreGUI.getMessageCenter().getMessages().clear(); refresh(); } catch (Throwable e) { Log.error("Cannot delete all messages", e); } } }); LinkedHashMap<String, Integer> maxMessagesMap = new LinkedHashMap<String, Integer>(); maxMessagesMap.put("10", Integer.valueOf("10")); maxMessagesMap.put("25", Integer.valueOf("25")); maxMessagesMap.put("50", Integer.valueOf("50")); maxMessagesMap.put("100", Integer.valueOf("100")); maxMessagesMap.put("200", Integer.valueOf("200")); addTableAction( extendLocatorId("maxMessageMenu"), MSG.view_messageCenter_maxMessages(), null, maxMessagesMap, new AbstractTableAction(TableActionEnablement.ALWAYS) { @Override public void executeAction(ListGridRecord[] selection, Object actionValue) { try { Integer maxSize = (Integer) actionValue; CoreGUI.getMessageCenter().setMaxMessages(maxSize.intValue()); updateTitleCanvas(MSG.view_messageCenter_lastNMessages(maxSize.toString())); refresh(); } catch (Throwable e) { Log.error("Cannot set max messages", e); } } }); /* // TODO only for testing, remove this when done testing addTableAction(extendLocatorId("test"), "TEST MSG", null, new AbstractTableAction(TableActionEnablement.ALWAYS) { @Override public void executeAction(ListGridRecord[] selection, Object actionValue) { for (Severity severity : java.util.EnumSet.allOf(Severity.class)) { Message m = new Message(severity.name() + ':' + System.currentTimeMillis(), severity); CoreGUI.getMessageCenter().notify(m); } } }); */ // initial population of the list with current messages try { refresh(); } catch (Throwable e) { Log.error("Cannot perform initial refresh", e); } }
private void initColumns(List<String> currencyGroupList) { if (currencyGroupList.size() > 0) { List<ListGridField> currencyFieldList = new LinkedList<ListGridField>(); ListGridField dateField = new ListGridField("dt", constants.date()); dateField.setAlign(Alignment.CENTER); dateField.setCellFormatter( new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value instanceof Date) { DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd.MM.yyyy"); Date date = (Date) value; String format = dateFormatter.format(date); return format; } else if (value != null) return value.toString(); else return null; } }); currencyFieldList.add(dateField); CustomValidator customValidator = new CustomValidator() { protected boolean condition(Object value) { try { if (value instanceof Float) { return (Float) value > 0.0; } else if (value instanceof Integer) { return ((Integer) value).floatValue() > 0.0; } else { Float result = Float.parseFloat((String) value); return result > 0.0; } } catch (Exception ex) { } return false; } }; FloatItem floatItem = new FloatItem(); floatItem.setEditorValueFormatter( new FormItemValueFormatter() { @Override public String formatValue( Object value, Record record, DynamicForm form, FormItem item) { if (value == null) return ""; String formattedValue = String.valueOf(value); formattedValue = formattedValue.replace('.', ','); return formattedValue; } }); floatItem.setEditorValueParser( new FormItemValueParser() { @Override public Object parseValue(String value, DynamicForm form, FormItem item) { try { if (value != null) { String newValue = value.replace(',', '.'); Float result = Float.parseFloat(newValue); return result; } } catch (Exception ex) { } return null; } }); for (int index = 0; index < currencyGroupList.size(); index++) { String currencyName = currencyGroupList.get(index); if (currencyName != null && !baseCurrencyPrefix.equals(currencyName) && !docCurrencyPrefix.equals(currencyName)) { ListGridField currencyField = new ListGridField(CurrencyRecord.IDENTITY_CURRENCY + currencyName, currencyName); currencyField.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value == null) { return null; } else { NumberFormat nf = NumberFormat.getFormat("0.###"); try { return nf.format((Number) value); } catch (Exception e) { return value.toString(); } } } }); currencyField.setAlign(Alignment.CENTER); currencyField.setRequired(true); currencyField.setValidators(customValidator); currencyField.setEditorType(floatItem); currencyFieldList.add(currencyField); } } // -------------------------------------------------------------------- // Remove Row column // -------------------------------------------------------------------- ListGridField removeField = new ListGridField("remove", constants.remove()); removeField.setAlign(Alignment.CENTER); removeField.setType(ListGridFieldType.IMAGE); removeField.setCanEdit(false); removeField.setCanFilter(false); removeField.setCellFormatter( new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return Canvas.imgHTML("[SKIN]/actions/remove.png"); } }); removeField.setWidth(60); currencyFieldList.add(removeField); ListGridField[] currencyFieldArray = new ListGridField[currencyFieldList.size()]; currencyFieldList.toArray(currencyFieldArray); currencyGrid.setFields(currencyFieldArray); } }
private ListGridField createAuthorizedField( String name, String title, final String nameField, final ListGrid grid, boolean readOnlyColumn) { final ListGridField authorizedField = new ListGridField(name, title, 65); // Show images rather than true/false. authorizedField.setType(ListGridFieldType.IMAGE); authorizedField.setImageSize(11); LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(2); // set the proper images different for read-only column if (readOnlyColumn) { valueMap.put(Boolean.TRUE.toString(), "global/permission_checked_disabled_11.png"); valueMap.put(Boolean.FALSE.toString(), "global/permission_disabled_11.png"); } else { valueMap.put(Boolean.TRUE.toString(), "global/permission_enabled_11.png"); valueMap.put(Boolean.FALSE.toString(), "global/permission_disabled_11.png"); } authorizedField.setValueMap(valueMap); authorizedField.setCanEdit(true); CheckboxItem editor = new CheckboxItem(); authorizedField.setEditorType(editor); if (!this.isReadOnly) { grid.setEditEvent(ListGridEditEvent.CLICK); final Record[] recordBeingEdited = {null}; authorizedField.addRecordClickHandler( new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { recordBeingEdited[0] = event.getRecord(); } }); authorizedField.addChangedHandler( new ChangedHandler() { public void onChanged(ChangedEvent event) { Boolean authorized = (Boolean) event.getValue(); int recordNum = event.getRowNum(); ListGridRecord record = grid.getRecord(recordNum); String permissionName = record.getAttribute(nameField); Permission permission = Permission.valueOf(permissionName); String permissionDisplayName = record.getAttribute("displayName"); if (permission == Permission.VIEW_RESOURCE) { String messageString = MSG.view_adminRoles_permissions_readAccessImplied(permissionDisplayName); handleIllegalPermissionSelection(event, messageString); } else if (!authorized && selectedPermissions.contains(Permission.MANAGE_SECURITY) && permission != Permission.MANAGE_SECURITY) { String messageString = MSG.view_adminRoles_permissions_illegalDeselectionDueToManageSecuritySelection( permissionDisplayName); handleIllegalPermissionSelection(event, messageString); } else if (!authorized && selectedPermissions.contains(Permission.MANAGE_INVENTORY) && permission.getTarget() == Permission.Target.RESOURCE) { String messageString = MSG.view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection( permissionDisplayName); handleIllegalPermissionSelection(event, messageString); } else if (!authorized && selectedPermissions.contains(Permission.CONFIGURE_WRITE) && permission == Permission.CONFIGURE_READ) { String messageString = MSG .view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection( permissionDisplayName); handleIllegalPermissionSelection(event, messageString); } else { updatePermissions(authorized, permission); // Let our parent role editor know the permissions have been changed, so it can // update the // enablement of its Save and Reset buttons. PermissionsEditor.this.roleEditView.onItemChanged(); } } }); } return authorizedField; }
public Canvas getViewPanel() { Canvas canvas = new Canvas(); final ListGrid countryGrid = new ListGrid(); countryGrid.setWidth(550); countryGrid.setHeight(224); countryGrid.setShowAllRecords(true); countryGrid.setCellHeight(22); countryGrid.setDataSource(CountryXmlDS.getInstance()); ListGridField countryCodeField = new ListGridField("countryCode", "Flag", 40); countryCodeField.setAlign(Alignment.CENTER); countryCodeField.setType(ListGridFieldType.IMAGE); countryCodeField.setImageURLPrefix("flags/16/"); countryCodeField.setImageURLSuffix(".png"); countryCodeField.setCanEdit(false); ListGridField nameField = new ListGridField("countryName", "Country"); ListGridField continentField = new ListGridField("continent", "Continent"); ListGridField memberG8Field = new ListGridField("member_g8", "Member G8"); ListGridField populationField = new ListGridField("population", "Population"); populationField.setType(ListGridFieldType.INTEGER); populationField.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value != null) { NumberFormat nf = NumberFormat.getFormat("0,000"); try { return nf.format(((Number) value).longValue()); } catch (Exception e) { return value.toString(); } } else { return null; } } }); ListGridField independenceField = new ListGridField("independence", "Independence"); countryGrid.setFields( countryCodeField, nameField, continentField, memberG8Field, populationField, independenceField); countryGrid.setAutoFetchData(true); countryGrid.setCanEdit(true); countryGrid.setEditEvent(ListGridEditEvent.CLICK); countryGrid.setListEndEditAction(RowEndEditAction.NEXT); canvas.addChild(countryGrid); IButton button = new IButton("Edit New"); button.setTop(250); button.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { countryGrid.startEditingNew(); } }); canvas.addChild(button); return canvas; }
/** * Create a single field definition from a attribute definition. * * @param attributeInfo attribute info * @return field for grid */ private ListGridField createAttributeGridField(final AttributeInfo attributeInfo) { ListGridField gridField = new ListGridField(attributeInfo.getName(), attributeInfo.getLabel()); gridField.setAlign(Alignment.LEFT); gridField.setCanEdit(false); gridField.setShowIfCondition( new IdentifyingListGridFieldIfFunction(attributeInfo.isIdentifying())); if (attributeInfo instanceof PrimitiveAttributeInfo) { PrimitiveAttributeInfo info = (PrimitiveAttributeInfo) attributeInfo; if (info.getType().equals(PrimitiveType.BOOLEAN)) { gridField.setType(ListGridFieldType.BOOLEAN); } else if (info.getType().equals(PrimitiveType.STRING)) { gridField.setType(ListGridFieldType.TEXT); } else if (info.getType().equals(PrimitiveType.DATE)) { gridField.setType(ListGridFieldType.DATE); } else if (info.getType().equals(PrimitiveType.SHORT)) { gridField.setType(ListGridFieldType.INTEGER); } else if (info.getType().equals(PrimitiveType.INTEGER)) { gridField.setType(ListGridFieldType.INTEGER); } else if (info.getType().equals(PrimitiveType.LONG)) { gridField.setType(ListGridFieldType.INTEGER); } else if (info.getType().equals(PrimitiveType.FLOAT)) { gridField.setType(ListGridFieldType.FLOAT); } else if (info.getType().equals(PrimitiveType.DOUBLE)) { gridField.setType(ListGridFieldType.FLOAT); } else if (info.getType().equals(PrimitiveType.IMGURL)) { gridField.setType(ListGridFieldType.IMAGE); if (showImageAttributeOnHover) { addCellOverHandler(new ImageCellHandler(attributeInfo)); } } else if (info.getType().equals(PrimitiveType.CURRENCY)) { gridField.setType(ListGridFieldType.TEXT); } else if (info.getType().equals(PrimitiveType.URL)) { gridField.setType(ListGridFieldType.TEXT); gridField.setAttribute("text-decoration", "underline"); addCellClickHandler(new UrlCellHandler(attributeInfo)); } } else if (attributeInfo instanceof AssociationAttributeInfo) { gridField.setType(ListGridFieldType.TEXT); } return gridField; }
public Tasks() { super(); SectionStack sectionStack = new SectionStack(); sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE); sectionStack.setWidth100(); sectionStack.setHeight100(); sections = new SectionStackSection[3]; for (int i = 0; i < 2; i++) { sections[i] = new SectionStackSection(i == 0 ? "My Tasks" : "Available Tasks"); sections[i].setExpanded(true); sections[i].setResizeable(false); ListGridField complete = new ListGridField("complete", " "); complete.setType(ListGridFieldType.BOOLEAN); complete.setCanEdit(true); complete.setCanToggle(true); if (i == 0) { final MyTasksListGrid taskgrid = new MyTasksListGrid(); taskgrid.setWidth100(); taskgrid.setHeight100(); taskgrid.setCanExpandRecords(true); taskgrid.setCanExpandMultipleRecords(false); taskgrid.setExpansionMode(ExpansionMode.DETAILS); taskgrid.setShowAllRecords(true); taskgrid.setExpansionCanEdit(true); taskgrid.addCellDoubleClickHandler( new CellDoubleClickHandler() { public void onCellDoubleClick(CellDoubleClickEvent event) { taskgrid.expandRecord(taskgrid.getRecord(event.getRowNum())); } }); ListGridField processIntanceID = new ListGridField("$#processInstanceId", "Workflow"); processIntanceID.setBaseStyle("linkLabel"); processIntanceID.addRecordClickHandler( new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { Object[] args = {event.getValue(), true}; PageManager.getInstance().setPageHistory(Pages.VIEWWORKFLOW, args); } }); taskgrid.setFields( complete, new ListGridField("taskname", "Name"), new ListGridField("$#createTime", "Time"), new ListGridField("$#priority", "Priority"), new ListGridField("$#assignee", "Assignee"), new ListGridField("$#activityName", "ActivityName"), processIntanceID); sections[i].addItem(taskgrid); } else { CustomListGrid grid = new CustomListGrid(); grid.setWidth100(); grid.setHeight100(); grid.setCanExpandRecords(true); grid.setCanExpandMultipleRecords(false); grid.setExpansionMode(ExpansionMode.DETAILS); grid.setShowAllRecords(true); complete.addRecordClickHandler(getRecordClickHandler(grid, i == 1)); grid.setShowRecordComponents(true); grid.setShowRecordComponentsByCell(true); ListGridField assign = new ListGridField("Assign", "Assign"); assign.setAlign(Alignment.CENTER); grid.setFields( complete, new ListGridField("taskname", "Name"), new ListGridField("$#createTime", "Time"), new ListGridField("$#priority", "Priority"), assign); sections[i].addItem(grid); } } sections[2] = new SectionStackSection("Event Log"); sections[2].setExpanded(true); sections[2].setResizeable(false); ListGrid grid = new ListGrid(); grid.setWidth100(); grid.setHeight100(); grid.setCanExpandRecords(false); grid.setShowAllRecords(true); grid.setCanEdit(false); grid.setFields( new ListGridField("$#endTime", "Time"), new ListGridField("$#id", "Task"), new ListGridField("$#assignee", "User"), new ListGridField("$#state", "Action"), new ListGridField("outcome", "Outcome"), new ListGridField("$#processInstanceId", "Workflow")); sections[2].addItem(grid); sectionStack.addSection(sections[0]); sectionStack.addSection(sections[1]); sectionStack.addSection(sections[2]); BpmServiceMain.sendGet( "/processInstances/tasks?assignee=" + BpmServiceMain.getUser(), new AsyncCallback<String>() { public void onFailure(Throwable arg0) {} public void onSuccess(String arg0) { ArrayList<Task> tasks = Parse.parseProcessTasks(arg0); records1 = new ListGridRecord[MAX_TASKS]; int i = 0; for (Task t : tasks) { records1[i++] = createLGR(false, t); } ((MyTasksListGrid) sections[0].getItems()[0]).setData(records1); } }); BpmServiceMain.sendGet( "/processInstances/tasks?candidate=" + BpmServiceMain.getUser(), new AsyncCallback<String>() { public void onFailure(Throwable arg0) {} public void onSuccess(String arg0) { ArrayList<Task> tasks = Parse.parseProcessTasks(arg0); records2 = new ListGridRecord[MAX_TASKS]; int i = 0; for (Task t : tasks) { records2[i++] = createLGR(false, t); } ((CustomListGrid) sections[1].getItems()[0]).setData(records2); } }); int dayLength = 24 * 60 * 60 * 1000; Date d = new Date(); d.setTime(d.getTime() + dayLength); String end = (1900 + d.getYear()) + "-" + (d.getMonth() < 9 ? "0" : "") + (d.getMonth() + 1) + "-" + (d.getDate() < 9 ? "0" : "") + d.getDate(); d = new Date(); d.setTime(d.getTime() - dayLength * 3); String start = (1900 + d.getYear()) + "-" + (d.getMonth() < 9 ? "0" : "") + (d.getMonth() + 1) + "-" + (d.getDate() < 9 ? "0" : "") + d.getDate(); BpmServiceMain.sendGet( "/tasks/history?assignee=" + BpmServiceMain.getUser() + "&start=" + start + "&end=" + end, new AsyncCallback<String>() { public void onFailure(Throwable arg0) {} public void onSuccess(String arg0) { ArrayList<Task> tasks = Parse.parseTasks(arg0); records3 = new ListGridRecord[MAX_TASKS]; int i = 0; for (Task t : tasks) { records3[i++] = createLGR(true, t); } ((ListGrid) sections[2].getItems()[0]).setData(records3); ((ListGrid) sections[2].getItems()[0]).sort(0, SortDirection.DESCENDING); } }); createPage(sectionStack, PageWidget.PAGE_TASKS); timer = new Timer() { public void run() { updateTasks(); } }; timer.scheduleRepeating(BpmServiceMain.getPollingRate()); }