Java Code Examples for com.smartgwt.client.widgets.grid.ListGrid#setShowRecordComponentsByCell()

The following examples show how to use com.smartgwt.client.widgets.grid.ListGrid#setShowRecordComponentsByCell() . 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: WorkflowTriggersPanel.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void refresh() {
	ListGridField workflow = new ListGridField("workflow", I18N.message("workflow"), 200);
	workflow.setCanFilter(true);

	ListGridField template = new ListGridField("template", I18N.message("template"), 200);
	template.setCanFilter(true);

	ListGridField checkin = new ListGridField("triggerAtCheckin", I18N.message("triggeratcheckin"));
	checkin.setCanFilter(false);
	checkin.setAlign(Alignment.LEFT);
	checkin.setWidth("*");

	list = new ListGrid() {
		@Override
		protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) {
			return super.getCellCSSText(record, rowNum, colNum);
		}
	};
	list.setEmptyMessage(I18N.message("notitemstoshow"));

	list.setShowRecordComponents(true);
	list.setShowRecordComponentsByCell(true);
	list.setCanFreezeFields(true);
	list.setAutoFetchData(true);
	list.setSelectionType(SelectionStyle.SINGLE);
	list.setFilterOnKeypress(true);
	list.setShowFilterEditor(false);
	list.setDataSource(new WorkflowTriggersDS("" + folder.getId()));
	list.setFields(workflow, template, checkin);

	list.addCellContextClickHandler(new CellContextClickHandler() {
		@Override
		public void onCellContextClick(CellContextClickEvent event) {
			showContextMenu();
			event.cancel();
		}
	});

	addMember(list, 0);
}
 
Example 2
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 3
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"));
		}
	});
}