Java Code Examples for com.smartgwt.client.widgets.grid.ListGridField#setCellFormatter()

The following examples show how to use com.smartgwt.client.widgets.grid.ListGridField#setCellFormatter() . 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: UserHistoryPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onDraw() {
	ListGridField event = new ListGridField("event", I18N.message("event"), 200);
	ListGridField date = new ListGridField("date", I18N.message("date"), 110);
	date.setAlign(Alignment.CENTER);
	date.setType(ListGridFieldType.DATE);
	date.setCellFormatter(new DateCellFormatter(false));
	date.setCanFilter(false);
	ListGridField comment = new ListGridField("comment", I18N.message("comment"));
	ListGridField sid = new ListGridField("sid", I18N.message("sid"), 200);
	ListGridField ip = new ListGridField("ip", I18N.message("ip"), 100);

	ListGrid listGrid = new ListGrid();
	listGrid.setEmptyMessage(I18N.message("notitemstoshow"));
	listGrid.setCanFreezeFields(true);
	listGrid.setAutoFetchData(true);
	listGrid.setDataSource(new UserHistoryDS(userId));
	listGrid.setFields(event, date, ip, sid, comment);
	addMember(listGrid);
}
 
Example 2
Source File: MenusPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public MenusPanel() {
	setWidth100();

	// Initialize the listing panel as placeholder
	listing.setAlign(Alignment.CENTER);
	listing.setHeight("55%");
	listing.setShowResizeBar(true);

	ListGridField id = new ListGridField("id", 40);
	id.setHidden(true);

	ListGridField name = new ListGridField("name", I18N.message("name"), 350);
	name.setCanFilter(true);
	name.setCellFormatter(new I18NCellFormatter());

	menus = new TreeGrid();
	menus.setWidth100();
	menus.setShowHeader(false);
	menus.setLeaveScrollbarGap(false);
	menus.setCanReorderRecords(false);
	menus.setCanDragRecordsOut(false);
	menus.setAutoFetchData(true);
	menus.setLoadDataOnDemand(true);
	menus.setCanSelectAll(false);
	menus.setShowConnectors(true);
	menus.setShowRoot(false);
	menus.setCanAcceptDrop(false);
	menus.setCanAcceptDroppedRecords(false);
	menus.setNodeIcon(Util.imageUrl("cube_yellow16.png"));
	menus.setFolderIcon(Util.imageUrl("cube_yellow16.png"));
	menus.setDataSource(new MenusDS());
	menus.setFields(id, name);

	listing.addMember(menus);

	rightsContainer.setAlign(Alignment.CENTER);
	rightsContainer.addMember(rights);

	setMembers(listing, rightsContainer);

	menus.addSelectionChangedHandler(new SelectionChangedHandler() {
		@Override
		public void onSelectionChanged(SelectionEvent event) {
			Record record = menus.getSelectedRecord();
			if (record != null)
				SecurityService.Instance.get().getMenu(Long.parseLong(record.getAttributeAsString("id")),
						new AsyncCallback<GUIMenu>() {

							@Override
							public void onFailure(Throwable caught) {
								Log.serverError(caught);
							}

							@Override
							public void onSuccess(GUIMenu menu) {
								showRights(menu);
							}
						});
		}
	});
}
 
Example 3
Source File: ComparatorsPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void prepareAssociationsGrid() {
	associationsGrid = new ListGrid();
	associationsGrid.setEmptyMessage(I18N.message("notitemstoshow"));
	associationsGrid.setShowFilterEditor(true);
	associationsGrid.setFilterOnKeypress(true);
	associationsGrid.setAutoFetchData(true);
	associationsGrid.setEditByCell(true);
	associationsGrid.setSelectionType(SelectionStyle.SINGLE);
	associationsGrid.setEditEvent(ListGridEditEvent.CLICK);
	associationsGrid.setDataSource(new ComparatorsDS(null));
	associationsGrid.setAllowFilterOperators(true);
	associationsGrid.setShowRecordComponents(true);
	associationsGrid.setShowRecordComponentsByCell(true);

	ListGridField in = new ListGridField("in", I18N.message("ext"), 40);
	ListGridField comparator = new ListGridField("comparator", I18N.message("comparator"));
	comparator.setWidth("*");
	comparator.setCanEdit(!Session.get().isDemo());
	comparator.setCellFormatter(new CellFormatter() {

		@Override
		public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
			String label = getComparatorShortName(value != null ? value.toString() : null);
			boolean enabled = record.getAttributeAsBoolean("eenabled");
			if (!enabled)
				label = "<span style='color:red;'>" + label + "</span>";

			return label;
		}
	});
	comparator.setFilterEditorProperties(ItemFactory.newFormatConverterSelector());

	associationsGrid.setFields(in, comparator);

	associationsGrid.setEditorCustomizer(new ListGridEditorCustomizer() {
		public FormItem getEditor(ListGridEditorContext context) {
			ListGridField field = context.getEditField();

			if (field.getName().equals("comparator")) {
				final ListGridRecord selectedRecord = associationsGrid.getSelectedRecord();
				final SelectItem editorItem = ItemFactory
						.newComparatorSelector(selectedRecord.getAttributeAsString("in"));
				editorItem.setWidth("*");
				return editorItem;
			} else
				return context.getDefaultProperties();
		}
	});

	associationsGrid.addEditCompleteHandler(new EditCompleteHandler() {

		@Override
		public void onEditComplete(EditCompleteEvent event) {
			Record converterRecord = settingsGrid.find(new AdvancedCriteria("id", OperatorId.EQUALS,
					associationsGrid.getSelectedRecord().getAttributeAsString("comparator")));
			if (converterRecord != null)
				associationsGrid.getSelectedRecord().setAttribute("eenabled",
						converterRecord.getAttributeAsBoolean("eenabled"));
		}
	});
}
 
Example 4
Source File: TrashPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onDraw() {
	ListGridField id = new ListGridField("id");
	id.setHidden(true);

	ListGridField fileName = new ListGridField("filename", I18N.message("name"));
	fileName.setCanFilter(true);
	fileName.setWidth("*");

	ListGridField icon = new ListGridField("icon", " ", 24);
	icon.setType(ListGridFieldType.IMAGE);
	icon.setCanSort(false);
	icon.setAlign(Alignment.CENTER);
	icon.setShowDefaultContextMenu(false);
	icon.setImageURLPrefix(Util.imagePrefix());
	icon.setImageURLSuffix(".png");
	icon.setCanFilter(false);

	ListGridField lastModified = new ListGridField("lastModified", I18N.message("lastmodified"), 110);
	lastModified.setAlign(Alignment.CENTER);
	lastModified.setType(ListGridFieldType.DATE);
	lastModified.setCellFormatter(new DateCellFormatter(false));
	lastModified.setCanFilter(false);
	lastModified.setHidden(true);

	ListGridField customId = new ListGridField("customId", I18N.message("customid"), 110);
	customId.setType(ListGridFieldType.TEXT);
	customId.setCanFilter(true);
	customId.setHidden(true);

	list = new RefreshableListGrid();
	list.setEmptyMessage(I18N.message("notitemstoshow"));
	list.setWidth100();
	list.setHeight100();
	list.setAutoFetchData(true);
	list.setFields(icon, fileName, customId, lastModified);
	list.setSelectionType(SelectionStyle.MULTIPLE);
	list.setDataSource(new GarbageDS());
	list.setShowFilterEditor(true);
	list.setFilterOnKeypress(true);
	addMember(list);

	if (Session.get().getCurrentFolder() != null && Session.get().getCurrentFolder().isWrite())
		list.addCellContextClickHandler(new CellContextClickHandler() {
			@Override
			public void onCellContextClick(CellContextClickEvent event) {
				showContextMenu();
				event.cancel();
			}
		});
}
 
Example 5
Source File: FormatConvertersPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void prepareAssociationsGrid() {
	associationsGrid = new ListGrid();
	associationsGrid.setEmptyMessage(I18N.message("notitemstoshow"));
	associationsGrid.setShowFilterEditor(true);
	associationsGrid.setFilterOnKeypress(true);
	associationsGrid.setAutoFetchData(true);
	associationsGrid.setEditByCell(true);
	associationsGrid.setSelectionType(SelectionStyle.SINGLE);
	associationsGrid.setEditEvent(ListGridEditEvent.CLICK);
	associationsGrid.setDataSource(new FormatConvertersDS(null, null));
	associationsGrid.setAllowFilterOperators(true);
	associationsGrid.setShowRecordComponents(true);
	associationsGrid.setShowRecordComponentsByCell(true);

	ListGridField in = new ListGridField("in", I18N.message("in"), 40);
	ListGridField out = new ListGridField("out", I18N.message("out"), 40);
	ListGridField converter = new ListGridField("converter", I18N.message("converter"));
	converter.setWidth("*");
	converter.setCanEdit(!Session.get().isDemo());
	converter.setCellFormatter(new CellFormatter() {

		@Override
		public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
			String label = getConverterShortName(value != null ? value.toString() : null);
			boolean enabled = record.getAttributeAsBoolean("eenabled");
			if (!enabled)
				label = "<span style='color:red;'>" + label + "</span>";

			return label;
		}
	});
	converter.setFilterEditorProperties(ItemFactory.newFormatConverterSelector());

	associationsGrid.setFields(in, out, converter);

	associationsGrid.setEditorCustomizer(new ListGridEditorCustomizer() {
		public FormItem getEditor(ListGridEditorContext context) {
			ListGridField field = context.getEditField();

			if (field.getName().equals("converter")) {
				final ListGridRecord selectedRecord = associationsGrid.getSelectedRecord();
				final SelectItem editorItem = ItemFactory.newFormatConverterSelector(
						selectedRecord.getAttributeAsString("in"), selectedRecord.getAttributeAsString("out"));
				editorItem.setWidth("*");
				return editorItem;
			} else
				return context.getDefaultProperties();
		}
	});

	associationsGrid.addEditCompleteHandler(new EditCompleteHandler() {

		@Override
		public void onEditComplete(EditCompleteEvent event) {
			Record converterRecord = settingsGrid.find(new AdvancedCriteria("id", OperatorId.EQUALS,
					associationsGrid.getSelectedRecord().getAttributeAsString("converter")));
			if (converterRecord != null)
				associationsGrid.getSelectedRecord().setAttribute("eenabled",
						converterRecord.getAttributeAsBoolean("eenabled"));
		}
	});
}
 
Example 6
Source File: RunLevelPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private SectionStack prepareAspectsTable() {
	ListGridField id = new ListGridField("id", I18N.message("aspect"), 300);
	id.setCanEdit(false);
	id.setCanSort(false);
	id.setAutoFitWidth(true);
	id.setCellFormatter(new CellFormatter() {

		@Override
		public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
			return I18N.message("aspect." + record.getAttributeAsString("id"));
		}
	});

	ListGridField _default = new ListGridField("default", I18N.message("default"), 60);
	_default.setType(ListGridFieldType.BOOLEAN);
	_default.setCanEdit(true);
	_default.setAutoFitWidth(true);
	_default.setCanSort(false);
	
	ListGridField bulkload = new ListGridField("bulkload", I18N.message("bulkload"), 60);
	bulkload.setType(ListGridFieldType.BOOLEAN);
	bulkload.setCanEdit(true);
	bulkload.setAutoFitWidth(true);
	bulkload.setCanSort(false);

	ListGridField slave = new ListGridField("slave", I18N.message("slave"), 60);
	slave.setType(ListGridFieldType.BOOLEAN);
	slave.setCanEdit(true);
	slave.setAutoFitWidth(true);
	slave.setCanSort(false);
	
	ListGridField devel = new ListGridField("devel", I18N.message("devel"), 60);
	devel.setType(ListGridFieldType.BOOLEAN);
	devel.setCanEdit(true);
	devel.setAutoFitWidth(true);
	devel.setCanSort(false);

	ListGridField demo = new ListGridField("demo", I18N.message("demo"), 60);
	demo.setType(ListGridFieldType.BOOLEAN);
	demo.setCanEdit(true);
	demo.setAutoFitWidth(true);
	demo.setCanSort(false);

	aspects = new ListGrid();
	aspects.setEmptyMessage(I18N.message("notitemstoshow"));
	aspects.setCanFreezeFields(true);
	aspects.setAutoFetchData(true);
	aspects.setDataSource(new AspectsDS());
	aspects.setFields(id, _default, bulkload, slave, devel, demo);
	aspects.setHeaderHeight(44);
	aspects.setHeaderSpans(new HeaderSpan(I18N.message("runlevels"), new String[] { "default", "bulkload", "slave", "devel",
			"demo" }));

	SectionStack stack = new SectionStack();
	stack.setWidth100();
	stack.setHeight100();

	SectionStackSection section = new SectionStackSection(I18N.message("aspects"));
	section.setCanCollapse(false);
	section.setExpanded(true);

	section.setItems(aspects);
	stack.setSections(section);
	return stack;
}