Java Code Examples for com.google.gwt.user.cellview.client.Column

The following are top voted examples for showing how to use com.google.gwt.user.cellview.client.Column. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: kie-wb-common   File: ListenersPanelViewImpl.java   Source Code and License 7 votes vote down vote up
private void addDeleteColumn() {
    final ButtonCell deleteCell = new ButtonCell( ButtonType.DANGER, IconType.TRASH );
    final Column<ListenerModel, String> column = new Column<ListenerModel, String>( deleteCell ) {
        @Override
        public String getValue( ListenerModel object ) {
            return "";
        }
    };

    column.setFieldUpdater( new FieldUpdater<ListenerModel, String>() {
        @Override
        public void update( int index,
                            ListenerModel model,
                            String value ) {
            presenter.onDelete( model );
        }
    } );
    column.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );

    dataGrid.addColumn( column,
            CommonConstants.INSTANCE.Delete() );
    dataGrid.setColumnWidth( column,
            60,
            Style.Unit.PX );
}
 
Example 2
Project: kie-wb-common   File: ListenersPanelViewImpl.java   Source Code and License 7 votes vote down vote up
private void addKindColumn() {
    ArrayList<String> options = new ArrayList<String>();
    options.add(RULE_RUNTIME_EVENT_LISTENER);
    options.add( AGENDA_EVENT_LISTENER );
    options.add( PROCESS_EVENT_LISTENER );

    Column<ListenerModel, String> column = new Column<ListenerModel, String>( new SelectionCell( options ) ) {
        @Override
        public String getValue( ListenerModel listenerModel ) {
            if ( listenerModel.getKind() == null || listenerModel.getKind().equals( ListenerModel.Kind.RULE_RUNTIME_EVENT_LISTENER) ) {
                return RULE_RUNTIME_EVENT_LISTENER;
            } else if ( listenerModel.getKind().equals( ListenerModel.Kind.PROCESS_EVENT_LISTENER ) ) {
                return PROCESS_EVENT_LISTENER;
            } else if ( listenerModel.getKind().equals( ListenerModel.Kind.AGENDA_EVENT_LISTENER ) ) {
                return AGENDA_EVENT_LISTENER;
            } else {
                return listenerModel.getKind().toString();
            }
        }
    };

    column.setFieldUpdater( new FieldUpdater<ListenerModel, String>() {
        @Override
        public void update( int index,
                            ListenerModel model,
                            String value ) {
            if ( value.equals(RULE_RUNTIME_EVENT_LISTENER) ) {
                model.setKind( ListenerModel.Kind.RULE_RUNTIME_EVENT_LISTENER);
            } else if ( value.equals( PROCESS_EVENT_LISTENER ) ) {
                model.setKind( ListenerModel.Kind.PROCESS_EVENT_LISTENER );
            } else if ( value.equals( AGENDA_EVENT_LISTENER ) ) {
                model.setKind( ListenerModel.Kind.AGENDA_EVENT_LISTENER );
            }
        }
    } );

    dataGrid.addColumn( column,
                        ProjectEditorResources.CONSTANTS.Kind() );
}
 
Example 3
Project: essence   File: AnalyzerAndReportUI.java   Source Code and License 6 votes vote down vote up
private void setupAnalyzeResultDisplayPanel(CellTable<AnalyzerResultDTO> table,
											final ListDataProvider<AnalyzerResultDTO> dataProvider) {
	final ClickableTextCellRuleID clickableIDcell = new ClickableTextCellRuleID();

	Column<AnalyzerResultDTO,String> ruleIDColumn = new Column<AnalyzerResultDTO,String>(clickableIDcell) {
		@Override
		public String getValue (AnalyzerResultDTO dr) {
			if (dr.getRefRuleId() == null)
				  return "none";
			else
				  return dr.getRefRuleId().toString();
		}
	};
	table.addColumn(ruleIDColumn, "Ref Rule ID");
	table.addColumnStyleName(2, "ar_number_column_style");
	ruleIDColumn.setFieldUpdater(new FieldUpdater<AnalyzerResultDTO,String> () {
		public void update(int index, AnalyzerResultDTO ar, String value) {
			showRuleDetailDialog(ar);
		}
	});
}
 
Example 4
Project: ontobrowser   File: HistoryPopup.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void setupTable() {	    
    table.setWidth("100%");
    table.addStyleName("gwt-CellTable");
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    table.setSelectionModel(new NoSelectionModel<CuratorAction>(keyProvider));
    
    table.addColumn(new ActionDateColumn(), "Date");
    table.addColumn(new CuratorColumn(), "Curator");
    table.addColumn(new ActionColumn(), "Action");
    table.addColumn(new EntityColumn(), "Entity");
    table.addColumn(new OntologyColumn(), "Ontology/Codelist");
    table.addColumn(new TermColumn(), "Term");
    table.addColumn(new EntityValueColumn(), "Relationship/Synonym");
    table.addColumn(new CommentsColumn(), "Comments");
    	    	    
	ListHandler<CuratorAction> sortHandler = new ListHandler<CuratorAction>(dataProvider.getList());
	for(int i = 0; i < table.getColumnCount(); i++) {
		Column<CuratorAction, ?> column = table.getColumn(i);
		if(column.isSortable() && column instanceof Comparator<?>) {
			sortHandler.setComparator(column, (Comparator<CuratorAction>)column);
		}
	}
	table.addColumnSortHandler(sortHandler);
	table.getColumnSortList().push(table.getColumn(0));
}
 
Example 5
Project: ontobrowser   File: ReplaceRelationshipPopup.java   Source Code and License 6 votes vote down vote up
private void setupTable() {
	Column<Relationship, Boolean> checkColumn = new Column<Relationship, Boolean>(
			new CheckboxCell(true, false)) {
		@Override
		public Boolean getValue(Relationship object) {
			return selection.isSelected(object);
		}
	};
	
	table.addStyleName("gwt-CellTable");
	table.addStyleName("decorator-panel");
	table.setWidth("100%");
	table.setKeyboardPagingPolicy(KeyboardPagingPolicy.CURRENT_PAGE);
	table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);	
			
	table.addColumn(checkColumn);
	table.setColumnWidth(checkColumn, 16, Unit.PX);
	
	table.addColumn(new RelationshipColumn(), "Relationship");
	table.addColumn(new RelatedTermColumn(), "Related Term");
	table.addColumn(new StatusColumn(), "Status");
	
	table.setSelectionModel(selection, 
			DefaultSelectionEventManager.<Relationship>createCheckboxManager(0));
	
}
 
Example 6
Project: ontobrowser   File: ApproveRejectComposite.java   Source Code and License 6 votes vote down vote up
private void addApproveColumn() {
	int rejectColumnIndex = -1;
	for(int i = 0; i < table.getColumnCount(); i++) {
		Column<T, ?> column = table.getColumn(i);
		if(column instanceof ApproveRejectComposite<?>.ApprovedByColumn) {
			return;
		}
		if(column instanceof ApproveRejectComposite<?>.RejectedByColumn) {
			rejectColumnIndex = i;
		}
	}
	
	if(rejectColumnIndex >= 0) {
		table.insertColumn(rejectColumnIndex, new ApprovedByColumn(), 
				"Approved By");
	} else if(curator != null) {
		table.insertColumn(table.getColumnCount() - 2, new ApprovedByColumn(), 
				"Approved By");
	} else {
		table.addColumn(new ApprovedByColumn(), "Approved By");
	}
}
 
Example 7
Project: TreeGridGWT   File: TreeGrid.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void refreshColumns() {
	for (int i = 0; i < treeGrid.getColumnCount(); i++) {
		treeGrid.removeColumn(i);
		header.removeColumn(i);

	}
	for (Entry<Integer, Column<T, ?>> kv : columns.entrySet()) {
		if (kv.getValue() instanceof ExpandableColumn) {
			treeGrid.addExpandableColumn((ExpandableColumn<T>) kv
					.getValue());
			header.addColumn(kv.getValue(), columnNames.get(kv.getValue()));
		} else {
			treeGrid.addColumn(kv.getValue());
			header.addColumn(kv.getValue(), columnNames.get(kv.getValue()));
		}
	}
}
 
Example 8
Project: riscoss-corporate   File: DomainList.java   Source Code and License 6 votes vote down vote up
public DomainList() {
	
	table = new CellTable<>(15, (Resources) GWT.create(TableResources.class));
	
	table.addColumn( new Column<String,SafeHtml>(new SafeHtmlCell() ) {
		@Override
		public SafeHtml getValue(String domain) {
			return new LinkHtml( domain, "javascript:selectDomain(\"" + domain + "\")" ); };
	}, "Domain");
	
	dataProvider = new ListDataProvider<String>();
	dataProvider.addDataDisplay( table );
	
	SimplePager pager = new SimplePager();
    pager.setDisplay( table );
    
    table.setWidth("100%");
	tablePanel.add( table );
	tablePanel.add( pager );
	tablePanel.setWidth("100%");
	
	
}
 
Example 9
Project: wbi   File: TableSeriesView.java   Source Code and License 6 votes vote down vote up
/**
 * Update list of sorted columns.
 *
 * @param columnSortList Table {@code ColumnSortList}.
 * @param ordering Ordering criteria.
 */
private void updateColumnSortList(
        ColumnSortList columnSortList,
        SeriesManager.Ordering ordering) {

    Column<?, ?> column;
    int by = ordering.getBy();

    if (by == SeriesManager.Ordering.BY_COUNTRY_NAME) {
        column = CountryNameColumn.get();
    } else {
        column = YearColumn.get(by);
    }

    ColumnSortList.ColumnSortInfo columnSortInfo =
        new ColumnSortList.ColumnSortInfo(column, ordering.isAscending());

    columnSortList.clear();
    columnSortList.push(columnSortInfo);
}
 
Example 10
Project: wbi   File: TableSeriesView.java   Source Code and License 6 votes vote down vote up
@Override
public void onColumnSort(ColumnSortEvent event) {
    SeriesManager.Ordering.Direction direction;
    if (event.isSortAscending()) {
        direction = SeriesManager.Ordering.Direction.ASC;
    } else {
        direction = SeriesManager.Ordering.Direction.DESC;
    }

    Column<?, ?> column = event.getColumn();

    if (column instanceof CountryNameColumn) {
        manager.setOrdering(new SeriesManager.Ordering(
            SeriesManager.Ordering.BY_COUNTRY_NAME, direction));
    }

    if (column instanceof YearColumn) {
        manager.setOrdering(new SeriesManager.Ordering(
            ((YearColumn) column).getYear(), direction));
    }
}
 
Example 11
Project: appformer   File: ColumnPickerTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testAddRemoveColumn() {
    final Column column = mock(Column.class);
    when(column.getDataStoreName()).thenReturn("id");
    final ColumnMeta meta = new ColumnMeta(column,
                                           "caption");
    meta.setHeader(new TextHeader("header"));
    columnPicker.addColumn(meta);
    assertTrue(columnPicker.getColumnMetaList().contains(meta));
    verify(dataGrid).addColumn(column,
                               meta.getHeader());
    assertEquals(1,
                 dataGrid.getColumnCount());
    columnPicker.removeColumn(meta);
    assertFalse(columnPicker.getColumnMetaList().contains(meta));
    verify(dataGrid).removeColumn(0);
    assertEquals(0,
                 dataGrid.getColumnCount());
}
 
Example 12
Project: appformer   File: ColumnPickerTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testSortColumn() {
    final Column column1 = mock(Column.class);
    final ColumnMeta meta1 = new ColumnMeta(column1,
                                            "caption1",
                                            true,
                                            1);
    meta1.setHeader(new TextHeader("header1"));
    final Column column0 = mock(Column.class);
    final ColumnMeta meta0 = new ColumnMeta(column0,
                                            "caption0",
                                            true,
                                            0);
    meta0.setHeader(new TextHeader("header0"));
    columnPicker.addColumns(Arrays.asList(meta1,
                                          meta0));
    assertEquals(2,
                 columnPicker.getColumnMetaList().size());
    verify(dataGrid).addColumn(column0,
                               meta0.getHeader());
    verify(dataGrid).addColumn(column1,
                               meta1.getHeader());
    assertEquals(2,
                 dataGrid.getColumnCount());
}
 
Example 13
Project: appformer   File: ColumnPickerTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testColumnPreference() {
    final Column column = mock(Column.class);
    when(column.getDataStoreName()).thenReturn("id");
    final ColumnMeta meta = new ColumnMeta(column,
                                           "caption");
    meta.setHeader(new TextHeader("header"));
    columnPicker.addColumn(meta);
    final List<GridColumnPreference> columnsState = columnPicker.getColumnsState();
    assertEquals(1,
                 columnsState.size());
    final GridColumnPreference preference = columnsState.get(0);
    assertEquals(preference.getName(),
                 column.getDataStoreName());
    assertEquals(0,
                 preference.getPosition().intValue());
}
 
Example 14
Project: appformer   File: ColumnPickerTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testSetColumnWidth() {
    final Column column1 = createColumn("col1",
                                        "col1");
    final ColumnMeta meta1 = new ColumnMeta(column1,
                                            "caption1",
                                            true,
                                            1);

    final Column column2 = createColumn("col2",
                                        "col2");
    final ColumnMeta meta2 = new ColumnMeta(column2,
                                            "caption2",
                                            true,
                                            0);

    when(dataGrid.getColumnWidth(column1)).thenReturn("38.0px");

    columnPicker.addColumns(Lists.newArrayList(meta1,
                                               meta2));

    verify(dataGrid).setColumnWidth(eq(column1),
                                    eq("38px"));
}
 
Example 15
Project: appformer   File: UberfireSimpleTable.java   Source Code and License 6 votes vote down vote up
protected ResizableMovableHeader<T> getColumnHeader(final String caption,
                                                    final Column column) {
    final ResizableMovableHeader header = new ResizableMovableHeader<T>(caption,
                                                                        dataGrid,
                                                                        columnPicker,
                                                                        column) {
        @Override
        protected int getTableBodyHeight() {
            return dataGrid.getOffsetHeight();
        }
    };
    header.addColumnChangedHandler(new ColumnChangedHandler() {
        @Override
        public void afterColumnChanged() {
            afterColumnChangedHandler();
        }

        @Override
        public void beforeColumnChanged() {

        }
    });
    return header;
}
 
Example 16
Project: appformer   File: UberfireColumnPickerTest.java   Source Code and License 6 votes vote down vote up
private ColumnMeta createColumnTextCell(final String value,
                                        String dataStoreName) {
    Column<String, String> testColumn = new Column<String, String>(new TextCell()) {
        @Override
        public String getValue(String object) {
            return value;
        }
    };
    testColumn.setSortable(true);
    testColumn.setDataStoreName(dataStoreName);

    final Header<String> header = new TextHeader(value);
    ColumnMeta<String> columnMeta = new ColumnMeta(testColumn,
                                                   dataStoreName);
    columnMeta.setHeader(header);
    return columnMeta;
}
 
Example 17
Project: appformer   File: UberfireColumnPickerTest.java   Source Code and License 6 votes vote down vote up
private ColumnMeta createColumnCheckboxCell(String dataStoreName) {
    CheckboxCell checkboxCell = new CheckboxCell(true,
                                                 false);
    Column<String, Boolean> checkColumn = new Column<String, Boolean>(checkboxCell) {
        @Override
        public Boolean getValue(String object) {
            return true;
        }
    };

    Header<Boolean> selectPageHeader = new Header<Boolean>(checkboxCell) {
        @Override
        public Boolean getValue() {
            return true;
        }
    };

    checkColumn.setSortable(false);
    checkColumn.setDataStoreName(dataStoreName);
    ColumnMeta<String> checkColMeta = new ColumnMeta<String>(checkColumn,
                                                             "");
    checkColMeta.setHeader(selectPageHeader);
    return checkColMeta;
}
 
Example 18
Project: appformer   File: UserAttributesEditorTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testInit() {
    presenter.init();
    verify(view,
           times(1)).init(presenter);
    verify(view,
           times(1)).initWidgets(any(NewUserAttributeEditor.View.class));
    verify(view,
           times(1)).getColumnCount();
    verify(view,
           times(1)).setColumnSortHandler(any(ColumnSortEvent.ListHandler.class));
    verify(view,
           times(2)).addColumn(any(Column.class),
                               anyString());
    verify(view,
           times(0)).redraw();
    verify(view,
           times(0)).removeColumn(anyInt());
    verify(view,
           times(0)).setCanCreate(anyBoolean());
    verify(view,
           times(0)).showEmpty();
}
 
Example 19
Project: mvp4g-examples   File: MailListView.java   Source Code and License 6 votes vote down vote up
/**
 * Add a column with a header.
 *
 * @param <C>        the cell type
 * @param cell       the cell used to render the column
 * @param headerText the header string
 * @param getter     the value getter for the cell
 */
private <C> Column<MailItem, C> addColumn(com.google.gwt.cell.client.Cell<C> cell,
                                          String headerText,
                                          final GetValue<C> getter,
                                          FieldUpdater<MailItem, C> fieldUpdater) {
  Column<MailItem, C> column = new Column<MailItem, C>(cell) {
    @Override
    public C getValue(MailItem object) {
      return getter.getValue(object);
    }
  };
  column.setFieldUpdater(fieldUpdater);
  list.addColumn(column,
                 headerText);
  return column;
}
 
Example 20
Project: mvp4g-examples   File: UserListView.java   Source Code and License 6 votes vote down vote up
/**
 * Add a column with a header.
 *
 * @param <C>        the cell type
 * @param cell       the cell used to render the column
 * @param headerText the header string
 * @param getter     the value getter for the cell
 */
private <C> Column<UserBean, C> addColumn(Cell<C> cell,
                                          String headerText,
                                          final GetValue<C> getter,
                                          FieldUpdater<UserBean, C> fieldUpdater) {
  Column<UserBean, C> column = new Column<UserBean, C>(cell) {
    @Override
    public C getValue(UserBean object) {
      return getter.getValue(object);
    }
  };
  column.setFieldUpdater(fieldUpdater);
  grid.addColumn(column,
                 headerText);
  return column;
}
 
Example 21
Project: switchyard   File: ApplicationReferencesList.java   Source Code and License 6 votes vote down vote up
@Override
protected void createColumns(DefaultCellTable<Reference> table, ListDataProvider<Reference> dataProvider) {
    Column<Reference, String> nameColumn = new Column<Reference, String>(new ClickableTextCell()) {
        @Override
        public String getValue(Reference reference) {
            return reference.localName();
        }
    };
    nameColumn.setFieldUpdater(new FieldUpdater<Reference, String>() {
        @Override
        public void update(int index, Reference object, String value) {
            _presenter.onNavigateToReference(object, _application);
        }
    });
    nameColumn.setSortable(true);

    ColumnSortEvent.ListHandler<Reference> sortHandler = new ColumnSortEvent.ListHandler<Reference>(
            dataProvider.getList());
    sortHandler.setComparator(nameColumn, createColumnCommparator(nameColumn));

    table.addColumn(nameColumn, Singleton.MESSAGES.label_name());

    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(nameColumn);
}
 
Example 22
Project: platypus-js   File: ModelGrid.java   Source Code and License 6 votes vote down vote up
protected void clearColumns() {
	for (int i = getDataColumnCount() - 1; i >= 0; i--) {
		Column<JavaScriptObject, ?> toDel = getDataColumn(i);
		ModelColumn mCol = (ModelColumn) toDel;
		if (mCol == treeIndicatorColumn) {
			TreeExpandableCell<JavaScriptObject, ?> treeCell = (TreeExpandableCell<JavaScriptObject, ?>) mCol
					.getCell();
			treeCell.setDataProvider(null);
			treeIndicatorColumn = null;
		}
		mCol.setGrid(null);
	}
	for (int i = headerRight.getColumnCount() - 1; i >= 0; i--) {
		headerRight.removeColumn(i);
	}
	for (int i = headerLeft.getColumnCount() - 1; i >= 0; i--) {
		headerLeft.removeColumn(i);
	}
}
 
Example 23
Project: platypus-js   File: GridSection.java   Source Code and License 6 votes vote down vote up
@Override
public void removeColumn(int index) {
	if (columnsRemover != null) {
		columnsRemover.removeColumn(index);
	} else {
		Column<T, ?> col = getColumn(index);
		hiddenColumns.remove(col);
		super.removeColumn(index);
		NodeList<Element> colGroups = getElement().getElementsByTagName("colgroup");
		if (colGroups != null && colGroups.getLength() == 1) {
			TableColElement colGroup = colGroups.getItem(0).cast();
			if (getColumnCount() < colGroup.getChildCount()) {
				// It seems, that GWT's bug is still here.
				if (index >= 0 && index < colGroup.getChildCount()) {
					colGroup.removeChild(colGroup.getChild(index));
				}
			}
		}
	}
}
 
Example 24
Project: platypus-js   File: GridSection.java   Source Code and License 6 votes vote down vote up
@Override
protected void doSetColumnWidth(int index, String aValue) {
	if (index >= 0 && index < getColumnCount()) {
		super.doSetColumnWidth(index, aValue);
		if (columnsPartners != null) {
			for (AbstractCellTable<T> partner : columnsPartners) {
				if (index >= 0 && index < partner.getColumnCount()) {
					Column<T, ?> col = partner.getColumn(index);
					if (aValue == null) {
						partner.clearColumnWidth(col);
					} else {
						partner.setColumnWidth(col, aValue);
					}
				}
			}
		}
		widthChanged();
	}
}
 
Example 25
Project: platypus-js   File: Grid.java   Source Code and License 6 votes vote down vote up
public void setColumnWidth(Column<T, ?> aColumn, double aWidth, Style.Unit aUnit) {
	if (headerLeft.getColumnIndex(aColumn) != -1) {
		headerLeft.setColumnWidth(aColumn, aWidth, aUnit);
		frozenLeft.setColumnWidth(aColumn, aWidth, aUnit);
		scrollableLeft.setColumnWidth(aColumn, aWidth, aUnit);
		footerLeft.setColumnWidth(aColumn, aWidth, aUnit);
	} else if (headerRight.getColumnIndex(aColumn) != -1) {
		headerRight.setColumnWidth(aColumn, aWidth, aUnit);
		frozenRight.setColumnWidth(aColumn, aWidth, aUnit);
		scrollableRight.setColumnWidth(aColumn, aWidth, aUnit);
		footerRight.setColumnWidth(aColumn, aWidth, aUnit);
	} else {
		// Logger.getLogger(Grid.class.getName()).log(Level.WARNING,
		// "Unknown column is met while setting column width");
	}
}
 
Example 26
Project: yaph   File: PasswordView.java   Source Code and License 6 votes vote down vote up
@Override
protected boolean buildHeaderOrFooterImpl() {

	TableRowBuilder tr = startRow();
	ColumnSortList sortList = dataGrid.getColumnSortList();
	ColumnSortInfo sortedInfo = (sortList.size() == 0) ? null : sortList.get(0);
	Column<?, ?> sortedColumn = (sortedInfo == null) ? null : sortedInfo.getColumn();
	boolean isSortAscending = (sortedInfo == null) ? false : sortedInfo.isAscending();

	// Add column headers.
	tr = startRow();
	buildHeader(tr, titleHeader, titleColumn, sortedColumn, isSortAscending, false, false);
	tr.endTR();

	return true;
}
 
Example 27
Project: TreeGridGWT   File: TreeGrid.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void refreshColumns() {
	for (int i = 0; i < treeGrid.getColumnCount(); i++) {
		treeGrid.removeColumn(i);
		header.removeColumn(i);

	}
	for (Entry<Integer, Column<T, ?>> kv : columns.entrySet()) {
		if (kv.getValue() instanceof ExpandableColumn) {
			treeGrid.addExpandableColumn((ExpandableColumn<T>) kv
					.getValue());
			header.addColumn(kv.getValue(), columnNames.get(kv.getValue()));
		} else {
			treeGrid.addColumn(kv.getValue());
			header.addColumn(kv.getValue(), columnNames.get(kv.getValue()));
		}
	}
}
 
Example 28
Project: avro-ui   File: AbstractGrid.java   Source Code and License 6 votes vote down vote up
protected float constructBooleanColumn(DataGrid<T> table, String title,
        final BooleanValueProvider<T> valueProvider, 
        Comparator<T> comparator, Boolean isSortAscending, float prefWidth) {
    Header<SafeHtml> header = new SafeHtmlHeader(
            SafeHtmlUtils.fromSafeConstant(title));
    Column<T, Boolean> column = new Column<T, Boolean>(new UneditableCheckboxCell()) {
        @Override
        public Boolean getValue(T item) {
            return valueProvider.getValue(item);
        }
    };
    column.setFieldUpdater(new FieldUpdater<T,Boolean>() {
        @Override
        public void update(int index, T object, Boolean value) {
            onRowClicked(getObjectId(object));
        }
    });
    table.addColumn(column, header);
    table.setColumnWidth(column, prefWidth, Unit.PX);
    processColumnSort(table, column, comparator, isSortAscending);
    return prefWidth;
}
 
Example 29
Project: ineform   File: AbstractIneTable.java   Source Code and License 6 votes vote down vote up
public Column<AssistedObject, ?> getColumn() {
    ColRDesc colRdesc = (ColRDesc) tableRenderDescriptor
        .getRootNode()
        .findNodeByHierarchicalId(key)
        .getNodeElement();
    if (colRdesc.hasProp(ColRDesc.AS_CB)) {
        return new BooleanTableColumn(key);
    } else if (colRdesc.hasProp(ColRDesc.AS_THREEWAYCB)) {
        return new ThreeWayBooleanTableColumn(key);
    } else if (colRdesc.hasProp(ColRDesc.AS_AO_EDITOR_TEXTBOX)) {
        return new TextBoxTableColumn(key);
    } else {
        return new StringTableColumn(key);
    }

}
 
Example 30
Project: kaa   File: AbstractDataProvider.java   Source Code and License 6 votes vote down vote up
/**
 * Update data.
 */
public void updateData() {
  List<T> filteredData = dataGrid.filter(data);
  if (dataFilter != null) {
    List<T> newFilteredData = new ArrayList<>();
    for (T value : filteredData) {
      if (dataFilter.accept(value)) {
        newFilteredData.add(value);
      }
    }
    filteredData = newFilteredData;
  }
  updateRowCount(filteredData.size(), true);
  ColumnSortList sortList = dataGrid.getDataGrid().getColumnSortList();
  Column<?, ?> column = (sortList == null || sortList.size() == 0) ? null
      : sortList.get(0).getColumn();
  boolean isSortAscending = !(sortList == null || sortList.size() == 0)
      && sortList.get(0).isAscending();
  if (column != null) {
    dataGrid.sort(filteredData, column, isSortAscending);
  }
  updateRowData(0, filteredData);
}
 
Example 31
Project: Peergos   File: CwCellSampler.java   Source Code and License 6 votes vote down vote up
/**
 * Add a column with a header.
 * 
 * @param <C> the cell type
 * @param cell the cell used to render the column
 * @param headerText the header string
 * @param getter the value getter for the cell
 */
@ShowcaseSource
private <C> Column<ContactInfo, C> addColumn(Cell<C> cell, String headerText,
    final GetValue<C> getter, FieldUpdater<ContactInfo, C> fieldUpdater) {
  Column<ContactInfo, C> column = new Column<ContactInfo, C>(cell) {
    @Override
    public C getValue(ContactInfo object) {
      return getter.getValue(object);
    }
  };
  column.setFieldUpdater(fieldUpdater);
  if (cell instanceof AbstractEditableCell<?, ?>) {
    editableCells.add((AbstractEditableCell<?, ?>) cell);
  }
  contactList.addColumn(column, headerText);
  return column;
}
 
Example 32
Project: kie-wb-common   File: WorkItemHandlersPanelViewImpl.java   Source Code and License 6 votes vote down vote up
private void addDeleteColumn() {
    final ButtonCell deleteCell = new ButtonCell( ButtonType.DANGER, IconType.TRASH );
    final Column<WorkItemHandlerModel, String> column = new Column<WorkItemHandlerModel, String>( deleteCell ) {
        @Override
        public String getValue( WorkItemHandlerModel object ) {
            return "";
        }
    };

    column.setFieldUpdater( new FieldUpdater<WorkItemHandlerModel, String>() {
        @Override
        public void update( int index,
                            WorkItemHandlerModel model,
                            String value ) {
            presenter.onDelete( model );
        }
    } );
    column.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );

    dataGrid.addColumn( column,
            CommonConstants.INSTANCE.Delete() );
    dataGrid.setColumnWidth( column,
            60,
            Style.Unit.PX );
}
 
Example 33
Project: kie-wb-common   File: ListenersPanelViewImpl.java   Source Code and License 6 votes vote down vote up
private void addTypeColumn() {

        Column<ListenerModel, String> column = new Column<ListenerModel, String>( new EditTextCell() ) {
            @Override
            public String getValue( ListenerModel listenerModel ) {
                return listenerModel.getType();
            }
        };

        column.setFieldUpdater( new FieldUpdater<ListenerModel, String>() {
            @Override
            public void update( int index,
                                ListenerModel model,
                                String value ) {
                model.setType( value );
            }
        } );

        dataGrid.addColumn( column,
                            ProjectEditorResources.CONSTANTS.Type() );
    }
 
Example 34
Project: kie-wb-common   File: KSessionsPanelViewImpl.java   Source Code and License 6 votes vote down vote up
private void setUpClockColumn() {
    ArrayList<String> options = new ArrayList<String>();
    options.add( ProjectEditorResources.CONSTANTS.Realtime() );
    options.add( ProjectEditorResources.CONSTANTS.Pseudo() );

    Column<KSessionModel, String> column = new Column<KSessionModel, String>( new SelectionCell( options ) ) {
        @Override
        public String getValue( KSessionModel kSessionModel ) {
            if ( kSessionModel.getClockType().equals( ClockTypeOption.PSEUDO ) ) {
                return ProjectEditorResources.CONSTANTS.Pseudo();
            } else if ( kSessionModel.getClockType().equals( ClockTypeOption.REALTIME ) ) {
                return ProjectEditorResources.CONSTANTS.Realtime();
            } else {
                return kSessionModel.getClockType().toString();
            }
        }
    };

    column.setFieldUpdater( new FieldUpdater<KSessionModel, String>() {
        @Override
        public void update( int index,
                            KSessionModel model,
                            String value ) {
            if ( value.equals( ProjectEditorResources.CONSTANTS.Pseudo() ) ) {
                model.setClockType( ClockTypeOption.PSEUDO );
            } else {
                model.setClockType( ClockTypeOption.REALTIME );
            }
        }
    } );

    dataGrid.addColumn( column,
                        ProjectEditorResources.CONSTANTS.Clock() );
    dataGrid.setColumnWidth( column,
                             60,
                             Style.Unit.PCT );
}
 
Example 35
Project: kie-wb-common   File: ProjectClassListViewImpl.java   Source Code and License 6 votes vote down vote up
private void addClassNameColumn() {
    Column<ClassRow, String> column = new Column<ClassRow, String>( new TextCell() ) {
        @Override
        public String getValue( ClassRow classRow ) {
            if ( classRow.getClassName() != null ) {
                return classRow.getClassName();
            } else {
                return "";
            }
        }
    };

    dataGrid.addColumn( column,
                        Constants.INSTANCE.project_class_list_class_name_column() );
    dataGrid.setColumnWidth( column, 90, Style.Unit.PCT );
}
 
Example 36
Project: kie-wb-common   File: PersistenceUnitPropertyGridViewImpl.java   Source Code and License 6 votes vote down vote up
private void addPropertyNameColumn() {
    Column<PropertyRow, String> column = new Column<PropertyRow, String>( new EditTextCell() ) {
        @Override
        public String getValue( PropertyRow propertyRow ) {
            if ( propertyRow.getName() != null ) {
                return propertyRow.getName();
            } else {
                return "";
            }
        }
    };

    column.setFieldUpdater( new PropertyNameFieldUpdater<PropertyRow, String>( (EditTextCell) column.getCell() ) );

    dataGrid.addColumn( column,
                        Constants.INSTANCE.persistence_unit_property_grid_property_name_column() );
    dataGrid.setColumnWidth( column, 45, Style.Unit.PCT );
}
 
Example 37
Project: kie-wb-common   File: PersistenceUnitPropertyGridViewImpl.java   Source Code and License 6 votes vote down vote up
private void addPropertyValueColumn() {
    final Column<PropertyRow, String> column = new Column<PropertyRow, String>( new EditTextCell() ) {

        @Override
        public String getValue( PropertyRow propertyRow ) {
            if ( propertyRow.getValue() != null ) {
                return propertyRow.getValue();
            } else {
                return "";
            }
        }
    };

    column.setFieldUpdater( new PropertyValueFieldUpdater<PropertyRow, String>( (EditTextCell) column.getCell() ) );

    dataGrid.addColumn( column,
                        Constants.INSTANCE.persistence_unit_property_grid_property_value_column() );
    dataGrid.setColumnWidth( column, 45, Style.Unit.PCT );
}
 
Example 38
Project: kie-wb-common   File: DataObjectBrowserViewImpl.java   Source Code and License 6 votes vote down vote up
private void addPropertyNameColumn() {

        Column<ObjectProperty, String> column = new Column<ObjectProperty, String>(new TextCell()) {

            @Override
            public String getValue(ObjectProperty objectProperty) {
                if (objectProperty.getName() != null) {
                    return objectProperty.getName();
                } else {
                    return "";
                }
            }
        };

        column.setSortable(true);
        propertiesTable.addColumn(column,
                                  Constants.INSTANCE.objectBrowser_columnName());
        propertiesTable.setColumnWidth(column,
                                       25,
                                       Style.Unit.PCT);
        columnIds.put(column,
                      ColumnId.NAME_COLUMN);
    }
 
Example 39
Project: kie-wb-common   File: DataObjectBrowserViewImpl.java   Source Code and License 6 votes vote down vote up
private void addPropertyLabelColumn() {

        Column<ObjectProperty, String> column = new Column<ObjectProperty, String>(new TextCell()) {

            @Override
            public String getValue(ObjectProperty objectProperty) {
                if (objectProperty.getName() != null) {
                    return AnnotationValueHandler.getStringValue(objectProperty,
                                                                 MainDomainAnnotations.LABEL_ANNOTATION,
                                                                 MainDomainAnnotations.VALUE_PARAM);
                } else {
                    return "";
                }
            }
        };

        column.setSortable(true);
        propertiesTable.addColumn(column,
                                  Constants.INSTANCE.objectBrowser_columnLabel());
        propertiesTable.setColumnWidth(column,
                                       25,
                                       Style.Unit.PCT);
        columnIds.put(column,
                      ColumnId.LABEL_COLUMN);
    }
 
Example 40
Project: kie-wb-common   File: DataObjectBrowserViewImpl.java   Source Code and License 6 votes vote down vote up
private void addSortHandler() {

        propertiesTable.addColumnSortHandler(new ColumnSortEvent.Handler() {
            @Override
            public void onColumnSort(ColumnSortEvent event) {
                Column<?, ?> column = event.getColumn();
                ColumnId columnId;

                if ((columnId = columnIds.get(column)) != null) {
                    switch (columnId) {
                        case NAME_COLUMN:
                            presenter.onSortByName(event.isSortAscending());
                            break;
                        case LABEL_COLUMN:
                            presenter.onSortByLabel(event.isSortAscending());
                            break;
                        case TYPE_COLUMN:
                            presenter.onSortByType(event.isSortAscending());
                    }
                }
            }
        });
    }