本文整理汇总了Java中org.eclipse.jface.viewers.TableViewer类的典型用法代码示例。如果您正苦于以下问题:Java TableViewer类的具体用法?Java TableViewer怎么用?Java TableViewer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableViewer类属于org.eclipse.jface.viewers包,在下文中一共展示了TableViewer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createControl
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
@Override
public void createControl ( final Composite parent )
{
// stores must not be disposed!
this.stores = Activator.getDefault ().getStoresSet ();
this.tableViewer = new TableViewer ( parent );
setControl ( this.tableViewer.getControl () );
this.tableViewer.setContentProvider ( new ObservableSetContentProvider () );
this.tableViewer.setLabelProvider ( new ConnectionLabelProvider () );
this.tableViewer.setInput ( this.stores );
this.tableViewer.addSelectionChangedListener ( new ISelectionChangedListener () {
@Override
public void selectionChanged ( final SelectionChangedEvent event )
{
update ();
}
} );
update ();
}
示例2: createTableViewer
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
private void createTableViewer() {
ArrayEditor arrayEditor = ((ArrayEditor) cellEditor);
tableViewer = new TableViewer(table);
tableViewer.setUseHashlookup(true);
tableViewer.setColumnProperties(arrayEditor.columnNames);
// Assign the cell editors to the viewer
CellEditor[] editors = arrayEditor.getColumnEditors(table);
tableViewer.setCellEditors(editors);
// Set the cell modifier for the viewer
tableViewer.setCellModifier(new ArrayEditorCellModifier(this, tableViewer));
// Set the label provider for the viewer
tableViewer.setLabelProvider(new ArrayEditorLabelProvider(cellEditor.getStyle()));
// Set the content provider
tableViewer.setContentProvider(new ArrayEditorContentProvider());
}
示例3: addTextBoxInTable
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
private Text addTextBoxInTable(TableViewer tableViewer, TableItem tableItem, String textBoxName,
String valueTextPane, String editorName, int columnIndex, Listener listener) {
final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE);
buttonPane.setLayout(new FillLayout());
final Text text = new Text(buttonPane, SWT.NONE);
text.addListener(SWT.Modify, listener);
text.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem));
tableItem.setData(textBoxName, text);
tableItem.setData(valueTextPane, buttonPane);
//text.addModifyListener(FilterHelper.INSTANCE.getTextModifyListener());
final TableEditor editor = new TableEditor(tableViewer.getTable());
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setEditor(buttonPane, tableItem, columnIndex);
editor.layout();
text.setData(editorName, editor);
return text;
}
示例4: getFieldNameModifyListener
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
/**
* Gets the field name modify listener.
*
* @param tableViewer
* the table viewer
* @param conditionsList
* the conditions list
* @param fieldsAndTypes
* the fields and types
* @param fieldNames
* the field names
* @param saveButton
* the save button
* @param displayButton
* the display button
* @return the field name modify listener
*/
public ModifyListener getFieldNameModifyListener(final TableViewer tableViewer, final List<Condition> conditionsList,
final Map<String, String> fieldsAndTypes, final String[] fieldNames, final Button saveButton, final Button displayButton) {
ModifyListener listener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
CCombo source = (CCombo) e.getSource();
int index = (int) source.getData(FilterConstants.ROW_INDEX);
Condition filterConditions = conditionsList.get(index);
String fieldName = source.getText();
filterConditions.setFieldName(fieldName);
if(StringUtils.isNotBlank(fieldName)){
String fieldType = fieldsAndTypes.get(fieldName);
TableItem item = tableViewer.getTable().getItem(index);
CCombo conditionalCombo = (CCombo) item.getData(FilterConditionsDialog.CONDITIONAL_OPERATORS);
if(conditionalCombo != null && StringUtils.isNotBlank(fieldType)){
conditionalCombo.setText(filterConditions.getConditionalOperator());
conditionalCombo.setItems(FilterHelper.INSTANCE.getTypeBasedOperatorMap().get(fieldType));
new AutoCompleteField(conditionalCombo, new CComboContentAdapter(), conditionalCombo.getItems());
}
}
validateCombo(source);
toggleSaveDisplayButton(conditionsList, fieldsAndTypes, fieldNames, saveButton, displayButton);
}
};
return listener;
}
示例5: run
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
@Override
public void run() {
ViewDataPreferencesVO viewDataPreferencesVO = debugDataViewer.getViewDataPreferences();
delimiter = viewDataPreferencesVO.getDelimiter();
quoteCharactor = viewDataPreferencesVO.getQuoteCharactor();
headerEnabled = viewDataPreferencesVO.getIncludeHeaders();
TableViewer tableViewer = debugDataViewer.getTableViewer();
List<RowData> eachRowData = getListOfRowData(tableViewer);
List<String[]> exportedfileDataList = new ArrayList<String[]>();
TableColumn[] columns = tableViewer.getTable().getColumns();
if (headerEnabled != null) {
addHeadersInList(tableViewer, exportedfileDataList, columns);
}
addRowsDataInList(tableViewer, eachRowData, exportedfileDataList);
FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE);
String filePath = getPathOfFileDialog(fileDialog);
writeDataInFile(exportedfileDataList, filePath);
}
示例6: createDialogArea
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
@Override
protected Control createDialogArea(Composite parent)
{
Composite dialogArea = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(dialogArea, SWT.NONE);
createMessageArea(composite);
listViewer = new TableViewer(composite, SWT.TOP | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = 400;
data.heightHint = 400;
listViewer.getTable().setLayoutData(data);
listViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
listViewer.setContentProvider(new JarProjectContentProvider(null));
listViewer.setComparator(new ViewerComparator());
listViewer.setInput(ResourcesPlugin.getWorkspace());
applyDialogFont(composite);
listViewer.setSelection(new StructuredSelection(initialSelection));
GridLayoutFactory.fillDefaults().generateLayout(composite);
return dialogArea;
}
示例7: loadProperties
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
private void loadProperties(TableViewer tv) {
if (runtimePropertyMap != null && !runtimePropertyMap.isEmpty()) {
for (String key : runtimePropertyMap.keySet()) {
RuntimeProperties p = new RuntimeProperties();
if (validateBeforeLoad(key, runtimePropertyMap.get(key))) {
p.setPropertyName(key);
p.setPropertyValue(runtimePropertyMap.get(key));
propertyList.add(p);
}
}
tv.refresh();
} //$NON-NLS-1$
}
示例8: isExistInTable
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
private boolean isExistInTable(TableViewer tableViewer, String text){
boolean isDataExist = false;
Table table = tableViewer.getTable();
TableItem[] tableItems = table.getItems();
for(int i=0;i<tableItems.length;i++){
TableItem tableItem = tableItems[i];
for(int j=1;j <= table.getColumnCount()-1;j++){
if(StringUtils.containsIgnoreCase(tableItem.getText(j), text)){
label.setVisible(false);
isDataExist = true;
return isDataExist;
}else{
label.setVisible(true);
label.setText(labelText);
isDataExist = false;
}
}
}
return isDataExist;
}
示例9: loadProperties
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
private void loadProperties(TableViewer tv) {
if (secondaryColumnsMap != null && !secondaryColumnsMap.isEmpty()) {
for (String key : secondaryColumnsMap.keySet()) {
SecondaryColumnKeysInformation p = new SecondaryColumnKeysInformation();
if (validateBeforeLoad(key, secondaryColumnsMap.get(key))) {
p.setColumnName(key);
p.setSortOrder(secondaryColumnsMap.get(key));
propertyList.add(p);
tv.refresh();
if(!sourceFieldsList.contains(key)){
tv.getTable().getItem(propertyList.size()-1).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
}else{
tv.getTable().getItem(propertyList.size()-1).setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
}
}
}
tv.refresh();
} //$NON-NLS-1$
}
示例10: loadProperties
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
private void loadProperties(TableViewer tv) {
if (fieldNameList != null && !fieldNameList.isEmpty()) {
for (String key : fieldNameList) {
FilterProperties filter = new FilterProperties();
if (validateBeforeLoad(key)) {
filter.setPropertyname(key);
propertyList.add(filter);
}
}
tv.refresh();
} else {
logger.debug("LodProperties :: Empty Map");
}
}
示例11: operationInputTableAddButton
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
private void operationInputTableAddButton(
MappingSheetRow mappingSheetRow,
TableViewer tableViewer) {
FilterProperties filterProperties = new FilterProperties();
filterProperties.setPropertyname("");
if (!mappingSheetRow.getInputFields().contains(filterProperties)) {
mappingSheetRow.getInputFields().add(filterProperties);
tableViewer.refresh();
int i = mappingSheetRow.getInputFields().size() == 0 ? mappingSheetRow.getInputFields().size()
: mappingSheetRow.getInputFields().size() - 1;
tableViewer.editElement(tableViewer.getElementAt(i), 0);
}
}
示例12: createDataModelTableViewer
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
/**
* Create a new {@link TableViewer} with {@link DataModel} elements.
*
* @param site The {@link IWorkbenchPartSite} used to register the table's context menu.
* @param table The {@link Table}.
* @param dataModelClass The {@link DataModel} element {@link Class}.
* @param dataModelElementType The {@link DataModel} {@link IElementType}.
* @param input The {@link TableViewer} input.
* @param inputElementType The input {@link IElementType}.
* @return A new {@link TableViewer}.
*/
public static TableViewer createDataModelTableViewer(IWorkbenchPartSite site, Table table, Class<?> dataModelClass,
final IElementType dataModelElementType, Object input, IElementType inputElementType) {
TableViewer tableViewer = createTableViewer(table, dataModelClass, dataModelElementType, input,
inputElementType, new DataModelElementBinding());
List<BaseAction> tableActions = dataModelElementType.getActions();
if (tableActions != null) {
for (BaseAction action : tableActions) {
action.setSelectionProvider(tableViewer);
}
MenuManager menuManager = new MenuManager("#PopupMenu");
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
dataModelElementType.fillContextMenu(manager);
}
});
Menu menu = menuManager.createContextMenu(table);
table.setMenu(menu);
site.registerContextMenu(menuManager, tableViewer);
}
return tableViewer;
}
示例13: setCursorOnDeleteRow
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
/**
* This method is used to set cursor position at last row when any field is
* deleted from table-viewer
*
* @param tableViewer
* @param indexes
* @param gridList
*/
public void setCursorOnDeleteRow(TableViewer tableViewer,int[] indexes,List<?> gridList){
Table table = tableViewer.getTable();
//highlight after deletion
if(indexes.length == 1 && gridList.size() > 0){//only one item is deleted
if(gridList.size() == 1){//list contains only one element
table.select(0);// select the first element
tableViewer.editElement(tableViewer.getElementAt(0), 0);
}
else if(gridList.size() == indexes[0]){//deleted last item
table.select(gridList.size() - 1);//select the last element which now at the end of the list
tableViewer.editElement(tableViewer.getElementAt(gridList.size() - 1), 0);
}
else if(gridList.size() > indexes[0]){//deleted element from middle of the list
table.select( indexes[0] == 0 ? 0 : (indexes[0] - 1) );//select the element from at the previous location
tableViewer.editElement(tableViewer.getElementAt(indexes[0] == 0 ? 0 : (indexes[0] - 1)), 0);
}
}
else if(indexes.length >= 2){//multiple items are selected for deletion
if(indexes[0] == 0){//delete from 0 to ...
if(gridList.size() >= 1){//list contains only one element
table.select(0);//select the remaining element
tableViewer.editElement(tableViewer.getElementAt(0), 0);
}
}
else{//delete started from element other than 0th element
table.select((indexes[0])-1);//select element before the start of selection
tableViewer.editElement(tableViewer.getElementAt((indexes[0])-1), 0);
}
}
}
示例14: initTableViewer
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
private static void initTableViewer(TableViewer tableViewer, ElementTypes elementTypes, Object input,
IElementBinding elementBinding) {
IViewerType viewerType = new TableViewerType();
Table table = tableViewer.getTable();
Class<?> contentProviderInterfaceType = IStructuredContentProvider.class;
if ((table.getStyle() & SWT.VIRTUAL) != 0) {
contentProviderInterfaceType = ILazyContentProvider.class;
}
registerTableListeners(table);
initViewer(tableViewer, elementTypes, input, elementBinding, viewerType, contentProviderInterfaceType);
}
示例15: elementsChanged
import org.eclipse.jface.viewers.TableViewer; //导入依赖的package包/类
private void elementsChanged() {
TableViewer tableViewer = getTableViewer();
tableViewer.refresh();
IElementType elementType = getElementType();
elementType.packTable(getTable());
layout(true);
fireOrchestrationChange();
}