Java Code Examples for com.smartgwt.client.widgets.grid.ListGridRecord#setAttribute()

The following examples show how to use com.smartgwt.client.widgets.grid.ListGridRecord#setAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageDialog.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Add new users in the recipients grid
 */
private void addRecipients(ListGridRecord[] newSelection) {
	if (newSelection == null || newSelection.length < 1)
		return;

	for (int i = 0; i < newSelection.length; i++) {
		ListGridRecord newRec = new ListGridRecord();
		newRec.setAttribute("id", newSelection[i].getAttributeAsString("id"));
		newRec.setAttribute("label", newSelection[i].getAttributeAsString("label"));

		// Iterate over the current recipients avoiding duplicates
		boolean duplicate = false;
		ListGridRecord[] currentRecipients = recipientsGrid.getRecords();
		for (int j = 0; j < currentRecipients.length; j++) {
			ListGridRecord rec = currentRecipients[j];
			if (rec.getAttributeAsString("id").equals(newRec.getAttributeAsString("id"))) {
				duplicate = true;
				break;
			}
		}

		if (!duplicate)
			recipientsGrid.addData(newRec);
	}
}
 
Example 2
Source File: ContactsImportPreview.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void setContacts(GUIContact[] contacts) {
	List<ListGridRecord> records = new ArrayList<ListGridRecord>();
	for (GUIContact contact : contacts) {
		ListGridRecord record = new ListGridRecord();
		record.setAttribute("id", contact.getId());
		record.setAttribute("firstName", contact.getFirstName());
		record.setAttribute("lastName", contact.getLastName());
		record.setAttribute("email", contact.getEmail());
		record.setAttribute("company", contact.getCompany());
		record.setAttribute("address", contact.getAddress());
		record.setAttribute("mobile", contact.getMobile());
		record.setAttribute("phone", contact.getPhone());
		records.add(record);
	}
	list.setRecords(records.toArray(new ListGridRecord[0]));
}
 
Example 3
Source File: BarcodeTemplatesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void updateGrid() {
	if (selectedBarcodeTemplate != null) {
		ArrayList<ListGridRecord> records = new ArrayList<ListGridRecord>();
		if (selectedBarcodeTemplate.getBarcodeSpecs() != null)
			for (GUIBarcodeSpec pat : selectedBarcodeTemplate.getBarcodeSpecs()) {
				ListGridRecord record = new ListGridRecord();
				record.setAttribute("pattern", pat.getPatterns());
				record.setAttribute("include", pat.getInclude());
				record.setAttribute("exclude", pat.getExclude());

				String frmts = pat.getFormats();
				if (frmts == null || frmts.trim().isEmpty())
					record.setAttribute("formats", (String) null);
				else if (!frmts.trim().contains(","))
					record.setAttribute("formats", frmts.trim());
				else
					record.setAttribute("formats", pat.getFormats().replaceAll(" ", "").split(","));
				records.add(record);
			}
		patternsGrid.setRecords(records.toArray(new ListGridRecord[0]));
	}
}
 
Example 4
Source File: TemplatePropertiesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void fillAttributesList() {
	if (attributesList.getRecordList().getLength() > 0)
		attributesList.getRecordList().removeList(attributesList.getRecords());

	if (template == null)
		return;

	GUIAttribute[] attributes = template.getAttributesOrderedByPosition();
	if (attributes == null)
		return;

	for (int i = 0; i < attributes.length; i++) {
		GUIAttribute att = attributes[i];
		ListGridRecord record = new ListGridRecord();
		record.setAttribute("name", att.getName());
		record.setAttribute("label", att.getLabel());
		record.setAttribute("set", att.getSet());
		record.setAttribute("setId", att.getSetId());
		record.setAttribute("type", att.getType());
		record.setAttribute("editor", att.getEditor());
		record.setAttribute("mandatory", att.isMandatory());
		record.setAttribute("hidden", att.isHidden());
		record.setAttribute("multiple", att.isMultiple());
		attributesList.getRecordList().add(record);
	}
}
 
Example 5
Source File: StoragesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void onAddStorage() {
	for (int i = 1; i < 99; i++) {
		Record record = list.getRecordList().find("id", Integer.toString(i));
		if (record == null) {
			ListGridRecord newStore = new ListGridRecord();
			newStore.setAttribute("id", Integer.toString(i));
			newStore.setAttribute("name", "Storage " + i);
			newStore.setAttribute("type", "fs");
			newStore.setAttribute("encrypt", "false");
			newStore.setAttribute("write", "blank");

			list.getDataSource().addData(newStore);
			list.redraw();
			break;
		}
	}
}
 
Example 6
Source File: DashletsPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void refreshGrid() {
	ListGridRecord[] records = new ListGridRecord[dashlets.size()];
	int i = 0;
	for (GUIDashlet dashlet : dashlets) {
		ListGridRecord record = new ListGridRecord();
		record.setAttribute("id", dashlet.getId());
		record.setAttribute("name", dashlet.getName());
		record.setAttribute("type", dashlet.getType());
		record.setAttribute("title", dashlet.getTitle());
		record.setAttribute("max", dashlet.getMax());
		record.setAttribute("query", dashlet.getQuery());
		record.setAttribute("content", dashlet.getContent());
		records[i++] = record;
	}
	grid.setData(records);
}
 
Example 7
Source File: SubscriptionListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
protected ChangedHandler createActivateChangedHandler(final ListGridRecord ruleRecord) {
    return new ChangedHandler() {
        @Override
        public void onChanged(ChangedEvent event) {
            CheckboxItem checkbox = (CheckboxItem) event.getSource();
            boolean checked = checkbox.getValueAsBoolean().booleanValue();
            String uuid = ruleRecord.getAttribute(UUID);
            String medium = ruleRecord.getAttribute(MEDIUM);
            String format = ruleRecord.getAttribute(FORMAT);
            ruleRecord.setAttribute(SUBSCRIBED, checked);
            if(checked) {
                getMainEventBus().fireEvent(new SubscribeEvent(currentSession(), uuid, medium, format));
            } else {
                getMainEventBus().fireEvent(new UnsubscribeEvent(currentSession(), uuid, medium, format));
            }
        }
    };
}
 
Example 8
Source File: CalendarEventDialog.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addParticipant(final ListGrid list, String id, String username, String name) {
	// Check if the selected user is already present in the list
	ListGridRecord[] records = list.getRecords();
	for (ListGridRecord test : records) {
		if (test.getAttribute("id").equals(id))
			return;
	}

	// Update the table
	ListGridRecord record = new ListGridRecord();

	record.setAttribute("id", id);
	record.setAttribute("name", name);
	record.setAttribute("username", username);
	list.addData(record);
	
	if (id.startsWith("g-")) {
		GUIGroup group = new GUIGroup();
		group.setId(Long.parseLong(id.substring(2)));
		group.setName(username);
		group.setDescription(name);
		CalendarEventDialog.this.calendarEvent.addParticipant(group);
	} else {
		GUIUser user = new GUIUser();
		user.setId(Long.parseLong(id));
		user.setUsername(username);
		user.setFirstName(name);
		CalendarEventDialog.this.calendarEvent.addParticipant(user);
	}
}
 
Example 9
Source File: SavedSearchesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void addEntry(String name, String description, String type) {
	// Incredible!!! Without this line we have a duplicated save search
	// entry when the user saves the first search.
	System.out.println("");
	ListGridRecord record = new ListGridRecord();
	record.setAttribute("name", name);
	record.setAttribute("description", description);
	record.setAttribute("type", type);
	list.addData(record);
}
 
Example 10
Source File: AttributeSetPropertiesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void fillAttributesList() {
	if (attributeSet != null && attributeSet.getAttributes() != null) {
		for (GUIAttribute att : attributeSet.getAttributesOrderedByPosition()) {
			ListGridRecord record = new ListGridRecord();
			record.setAttribute("name", att.getName());
			record.setAttribute("label", att.getLabel());
			attributesList.addData(record);
		}
	}
}
 
Example 11
Source File: AttributeSetPropertiesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addAttribute(GUIAttribute att) {
	ListGridRecord record = new ListGridRecord();
	record.setAttribute("name", att.getName());
	record.setAttribute("label", att.getLabel());
	attributesList.getDataAsRecordList().add(record);
	attributeSet.appendAttribute(att);
	detailsPanel.enableSave();
	;
	form2.clearValues();
	attributesList.deselectRecord(record);
}
 
Example 12
Source File: AttributeSetPropertiesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void updateAttribute(GUIAttribute att, String oldAttrName) {
	attributesList.removeSelectedData();

	ListGridRecord record = new ListGridRecord();
	record.setAttribute("name", att.getName());
	record.setAttribute("label", att.getLabel());
	attributesList.getDataAsRecordList().addAt(record, att.getPosition());

	detailsPanel.enableSave();
	;
	form2.clearValues();
	attributesList.deselectRecord(record);
}
 
Example 13
Source File: EventsWindow.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void addEvent(GUIEvent event) {
	ListGridRecord record = new ListGridRecord();
	record.setAttribute("date", event.getDate());
	record.setAttribute("detail", event.getDetail());
	record.setAttribute("severity", event.getSeverity());
	record.setAttribute("severityLabel", I18N.message(event.getSeverity()));
	grid.addData(record);
	grid.sort("date", SortDirection.DESCENDING);
}
 
Example 14
Source File: ImportArchivesList.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void updateRecord(GUIArchive result) {
	ListGridRecord record = list.getSelectedRecord();
	record.setAttribute("description", result.getDescription());
	list.refreshRow(list.getRecordIndex(record));
}