List of usage examples for org.eclipse.jface.viewers TableViewer getTable
public Table getTable()
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
private CellLabelProvider getConditionalCellProvider(final TableViewer tableViewer, final List<Condition> conditionsList, final boolean isRemote) { return new CellLabelProvider() { @Override/*from ww w . j av a 2 s.c o m*/ public void update(ViewerCell cell) { final TableItem item = (TableItem) cell.getItem(); // DO NOT REMOVE THIS CONDITION. The condition is return to // prevent multiple updates on single item if (item.getData("ADDED_CONDITIONAL") == null) { item.setData("ADDED_CONDITIONAL", TRUE); CCombo combo; if (isRemote) { combo = addComboInTable(tableViewer, item, CONDITIONAL_OPERATORS, CONDITIONAL_COMBO_PANE, CONDITIONAL_EDITOR, cell.getColumnIndex(), new String[] {}, FilterHelper.INSTANCE.getConditionalOperatorSelectionListener(conditionsList, fieldsAndTypes, fieldNames, remoteSaveButton, remoteDisplayButton), FilterHelper.INSTANCE.getConditionalOperatorModifyListener(conditionsList, fieldsAndTypes, fieldNames, remoteSaveButton, remoteDisplayButton), FilterHelper.INSTANCE.getConditionalOperatorFocusListener()); } else { combo = addComboInTable(tableViewer, item, CONDITIONAL_OPERATORS, CONDITIONAL_COMBO_PANE, CONDITIONAL_EDITOR, cell.getColumnIndex(), new String[] {}, FilterHelper.INSTANCE.getConditionalOperatorSelectionListener(conditionsList, fieldsAndTypes, fieldNames, localSaveButton, localDisplayButton), FilterHelper.INSTANCE.getConditionalOperatorModifyListener(conditionsList, fieldsAndTypes, fieldNames, localSaveButton, localDisplayButton), FilterHelper.INSTANCE.getConditionalOperatorFocusListener()); } if (StringUtils .isNotBlank(dummyList.get(tableViewer.getTable().indexOf(item)).getFieldName())) { String fieldsName = dummyList.get(tableViewer.getTable().indexOf(item)).getFieldName(); if (fieldsAndTypes.containsKey(fieldsName)) { combo.setItems(typeBasedConditionalOperators.get(fieldsAndTypes.get(fieldsName))); } } else { combo.setItems(new String[] {}); } combo.setText((dummyList.get(tableViewer.getTable().indexOf(item))).getConditionalOperator()); item.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (item.getData("DISPOSED_CONDITIONAL") == null) { item.setData("DISPOSED_CONDITIONAL", TRUE); CCombo combo = (CCombo) item.getData(CONDITIONAL_OPERATORS); ((TableEditor) combo.getData(CONDITIONAL_EDITOR)).dispose(); combo.dispose(); Composite composite = (Composite) item.getData(CONDITIONAL_COMBO_PANE); composite.dispose(); } } }); } else { CCombo combo = (CCombo) item.getData(CONDITIONAL_OPERATORS); if (StringUtils .isNotBlank(dummyList.get(tableViewer.getTable().indexOf(item)).getFieldName())) { String fieldsName = dummyList.get(tableViewer.getTable().indexOf(item)).getFieldName(); if (fieldsAndTypes.containsKey(fieldsName)) { combo.setItems(typeBasedConditionalOperators.get(fieldsAndTypes.get(fieldsName))); } } else { combo.setItems(new String[] {}); } combo.setText((dummyList.get(tableViewer.getTable().indexOf(item))).getConditionalOperator()); } } }; }
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
private CellLabelProvider getFieldNameCellProvider(final TableViewer tableViewer, final List<Condition> conditionsList, final boolean isRemote) { return new CellLabelProvider() { @Override//from w w w .j ava 2 s . c o m public void update(ViewerCell cell) { final TableItem item = (TableItem) cell.getItem(); // DO NOT REMOVE THIS CONDITION. The condition is return to // prevent multiple updates on single item if (item.getData("ADDED_FIELD") == null) { item.setData("ADDED_FIELD", TRUE); CCombo combo; if (isRemote) { combo = addComboInTable(tableViewer, item, FIELD_NAMES, FIELD_COMBO_PANE, FIELD_EDITOR, cell.getColumnIndex(), fieldNames, FilterHelper.INSTANCE.getFieldNameSelectionListener(tableViewer, conditionsList, fieldsAndTypes, fieldNames, remoteSaveButton, remoteDisplayButton), FilterHelper.INSTANCE.getFieldNameModifyListener(tableViewer, conditionsList, fieldsAndTypes, fieldNames, remoteSaveButton, remoteDisplayButton), FilterHelper.INSTANCE.getConditionalOperatorFocusListener()); } else { combo = addComboInTable(tableViewer, item, FIELD_NAMES, FIELD_COMBO_PANE, FIELD_EDITOR, cell.getColumnIndex(), fieldNames, FilterHelper.INSTANCE.getFieldNameSelectionListener(tableViewer, conditionsList, fieldsAndTypes, fieldNames, localSaveButton, localDisplayButton), FilterHelper.INSTANCE.getFieldNameModifyListener(tableViewer, conditionsList, fieldsAndTypes, fieldNames, localSaveButton, localDisplayButton), FilterHelper.INSTANCE.getConditionalOperatorFocusListener()); } combo.setText((dummyList.get(tableViewer.getTable().indexOf(item))).getFieldName()); item.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (item.getData("DISPOSED_FIELD") == null) { item.setData("DISPOSED_FIELD", TRUE); CCombo combo = (CCombo) item.getData(FIELD_NAMES); ((TableEditor) combo.getData(FIELD_EDITOR)).dispose(); combo.dispose(); Composite composite = (Composite) item.getData(FIELD_COMBO_PANE); composite.dispose(); } } }); } else { CCombo fieldNameCombo = (CCombo) item.getData(FIELD_NAMES); fieldNameCombo.setText((dummyList.get(tableViewer.getTable().indexOf(item))).getFieldName()); } } }; }
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
private CellLabelProvider getRelationalCellProvider(final TableViewer tableViewer, final List<Condition> conditionsList, final boolean isRemote) { return new CellLabelProvider() { @Override// w w w.j a va 2 s . c o m public void update(ViewerCell cell) { final TableItem item = (TableItem) cell.getItem(); // DO NOT REMOVE THIS CONDITION. The condition is return to // prevent multiple updates on single item if (item.getData("ADDED_RELATIONAL") == null) { item.setData("ADDED_RELATIONAL", TRUE); CCombo combo; if (isRemote) { combo = addComboInTable(tableViewer, item, RELATIONAL_OPERATORS, RELATIONAL_COMBO_PANE, RELATIONAL_EDITOR, cell.getColumnIndex(), relationalOperators, FilterHelper.INSTANCE.getRelationalOpSelectionListener(conditionsList, fieldsAndTypes, fieldNames, remoteSaveButton, remoteDisplayButton), FilterHelper.INSTANCE.getRelationalOpModifyListener(conditionsList, fieldsAndTypes, fieldNames, remoteSaveButton, remoteDisplayButton), FilterHelper.INSTANCE.getConditionalOperatorFocusListener()); } else { combo = addComboInTable(tableViewer, item, RELATIONAL_OPERATORS, RELATIONAL_COMBO_PANE, RELATIONAL_EDITOR, cell.getColumnIndex(), relationalOperators, FilterHelper.INSTANCE.getRelationalOpSelectionListener(conditionsList, fieldsAndTypes, fieldNames, localSaveButton, localDisplayButton), FilterHelper.INSTANCE.getRelationalOpModifyListener(conditionsList, fieldsAndTypes, fieldNames, localSaveButton, localDisplayButton), FilterHelper.INSTANCE.getConditionalOperatorFocusListener()); } combo.setText((dummyList.get(tableViewer.getTable().indexOf(item))).getRelationalOperator()); if (tableViewer.getTable().indexOf(item) == 0) { combo.setVisible(false); } else { combo.setVisible(true); } item.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (item.getData("DISPOSED_RELATIONAL") == null) { item.setData("DISPOSED_RELATIONAL", TRUE); CCombo combo = (CCombo) item.getData(RELATIONAL_OPERATORS); ((TableEditor) combo.getData(RELATIONAL_EDITOR)).dispose(); combo.dispose(); Composite composite = (Composite) item.getData(RELATIONAL_COMBO_PANE); composite.dispose(); } } }); } else { CCombo combo = (CCombo) item.getData(RELATIONAL_OPERATORS); combo.setText((dummyList.get(tableViewer.getTable().indexOf(item))).getRelationalOperator()); } } }; }
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
private CellLabelProvider getDummyColumn(final TableViewer tableViewer, final List<Condition> conditionsList, final Integer columnIndex, final TreeMap<Integer, List<List<Integer>>> groupSelectionMap) { return new CellLabelProvider() { @Override/*from ww w . j a v a 2s. c o m*/ public void update(ViewerCell cell) { final TableItem item = (TableItem) cell.getItem(); List<List<Integer>> checkedGrpRowIndices = groupSelectionMap.get(columnIndex); if (cell.getColumnIndex() == (columnIndex + 3)) { if (null != checkedGrpRowIndices && !checkedGrpRowIndices.isEmpty()) { List tempList = new ArrayList(); for (List<Integer> checkedIndex : checkedGrpRowIndices) { tempList.addAll(checkedIndex); } int indexOf = tableViewer.getTable().indexOf(item); if (tempList.contains(indexOf)) { for (int i = 0; i < checkedGrpRowIndices.size(); i++) { if ((checkedGrpRowIndices.get(i)).contains(indexOf)) { cell.setBackground(FilterHelper.INSTANCE.getColor(i)); break; } } } else { cell.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255, 255, 255)); } } } } }; }
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
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;//from w ww . j a v a 2 s. co m editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); text.setData(editorName, editor); return text; }
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
private CCombo addComboInTable(TableViewer tableViewer, TableItem tableItem, String comboName, String comboPaneName, String editorName, int columnIndex, String[] relationalOperators, SelectionListener dropDownSelectionListener, ModifyListener modifyListener, FocusListener focusListener) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final CCombo combo = new CCombo(buttonPane, SWT.NONE); combo.setItems(relationalOperators); combo.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); tableItem.setData(comboName, combo); tableItem.setData(comboPaneName, buttonPane); combo.addSelectionListener(dropDownSelectionListener); combo.addModifyListener(modifyListener); combo.addFocusListener(focusListener); new AutoCompleteField(combo, new CComboContentAdapter(), combo.getItems()); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true;//w ww . ja v a 2 s . co m editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); combo.setData(editorName, editor); return combo; }
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
private void addButtonInTable(TableViewer tableViewer, TableItem tableItem, String columnName, String buttonPaneName, String editorName, int columnIndex, SelectionListener buttonSelectionListener, ImagePathConstant imagePath) {/*from w w w .j a v a 2 s .c o m*/ final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final Button button = new Button(buttonPane, SWT.NONE); //button.setText(columnName); button.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); tableItem.setData(columnName, button); tableItem.setData(buttonPaneName, buttonPane); button.addSelectionListener(buttonSelectionListener); button.setImage(imagePath.getImageFromRegistry()); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); button.setData(editorName, editor); }
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
private void addCheckButtonInTable(TableViewer tableViewer, TableItem tableItem, String columnName, String groupPaneName, String editorName, int columnIndex, SelectionListener buttonSelectionListener) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final Button button = new Button(buttonPane, SWT.CHECK); button.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); if (null != buttonSelectionListener) { button.addSelectionListener(buttonSelectionListener); }// www .j a va2s. c om tableItem.setData(columnName, button); tableItem.setData(groupPaneName, buttonPane); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); button.setData(editorName, editor); }
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
private boolean storeGroupSelection(TableViewer tableViewer, TreeMap<Integer, List<List<Integer>>> groupSelectionMap) { boolean retVal = false; List<List<Integer>> grpList = new ArrayList<>(); List<Integer> selectionList = new ArrayList<>(); TableItem[] items = tableViewer.getTable().getItems(); for (TableItem tableItem : items) { Button button = (Button) tableItem.getData(GROUP_CHECKBOX); if (button.getSelection()) { selectionList.add(tableViewer.getTable().indexOf(tableItem)); }/*www. j a v a 2 s . c o m*/ } if (groupSelectionMap.isEmpty()) { grpList.add(selectionList); groupSelectionMap.put(0, grpList); retVal = true; } else { if (FilterHelper.INSTANCE.validateUserGroupSelection(groupSelectionMap, selectionList)) { if (FilterHelper.INSTANCE.isColumnModifiable(groupSelectionMap, selectionList)) { retVal = true; } else { grpList.add(selectionList); Map<Integer, List<List<Integer>>> tempMap = new TreeMap<>(); tempMap.putAll(groupSelectionMap); groupSelectionMap.clear(); groupSelectionMap.put(0, grpList); for (int i = 0; i < tempMap.size(); i++) { groupSelectionMap.put(i + 1, tempMap.get(i)); } retVal = true; FilterHelper.INSTANCE.rearrangeGroups(groupSelectionMap, selectionList); } } } return retVal; }
From source file:hydrograph.ui.dataviewer.filter.FilterConditionsDialog.java
License:Apache License
/** * Removes the button listener.//from ww w. j av a 2 s . c o m * * @param tableViewer * the table viewer * @param conditionsList * the conditions list * @param dummyList * the dummy list * @param groupSelectionMap * the group selection map * @param btnAddGrp * the btn add grp * @param isRemote * the is remote * @return the selection listener */ public SelectionListener removeButtonListener(final TableViewer tableViewer, final List<Condition> conditionsList, final List<Condition> dummyList, final TreeMap<Integer, List<List<Integer>>> groupSelectionMap, final Button btnAddGrp, final boolean isRemote) { SelectionListener listener = new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { if (conditionsList.size() > 1) { Button button = (Button) e.getSource(); int removeIndex = (int) button.getData(FilterConstants.ROW_INDEX); conditionsList.remove(removeIndex); dummyList.clear(); dummyList.addAll(FilterHelper.INSTANCE.cloneList(conditionsList)); boolean isRemoveAllColumns = FilterHelper.INSTANCE.refreshGroupSelections(tableViewer, removeIndex, "DEL", groupSelectionMap); TableItem[] items = tableViewer.getTable().getItems(); items[removeIndex].dispose(); if (isRemoveAllColumns) { FilterHelper.INSTANCE.rearrangeGroupColumns(groupSelectionMap); } FilterHelper.INSTANCE.disposeAllColumns(tableViewer); redrawAllColumns(tableViewer, conditionsList, btnAddGrp, groupSelectionMap, isRemote); } tableViewer.refresh(); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }; return listener; }