List of usage examples for org.eclipse.jface.viewers TableViewer getElementAt
public Object getElementAt(int index)
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.operational.OperationClassDialog.java
License:Apache License
private void addNewRow(TableViewer nameValueTableViewer) { NameValueProperty nameValueProperty = new NameValueProperty(); nameValueProperty.setPropertyName(""); nameValueProperty.setPropertyValue(""); if (!mappingSheetRow.getNameValueProperty().contains(nameValueProperty)) { mappingSheetRow.getNameValueProperty().add(nameValueProperty); nameValueTableViewer.refresh();//from w ww . ja v a2 s.co m nameValueTableViewer.editElement( nameValueTableViewer.getElementAt(mappingSheetRow.getNameValueProperty().size() - 1), 0); applyButton.setEnabled(true); } }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.operational.TransformDialog.java
License:Apache License
private void operationOutputTableAddButton(final MappingSheetRow mappingSheetRow, final TableViewer operationOutputtableViewer) { FilterProperties f = new FilterProperties(); f.setPropertyname(""); if (!mappingSheetRow.getOutputList().contains(f)) { mappingSheetRow.getOutputList().add(f); operationOutputtableViewer.refresh(); int i = mappingSheetRow.getOutputList().size() == 0 ? mappingSheetRow.getOutputList().size() : mappingSheetRow.getOutputList().size() - 1; operationalOutputFieldTableViewer.editElement(operationOutputtableViewer.getElementAt(i), 0); component.setLatestChangesInSchema(false); }/* ww w .j av a 2s.com*/ }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.operational.TransformDialog.java
License:Apache License
private void operationInputTableAddButton(MappingSheetRow mappingSheetRow, TableViewer tableViewer) { FilterProperties filterProperties = new FilterProperties(); filterProperties.setPropertyname(""); if (!mappingSheetRow.getInputFields().contains(filterProperties)) { mappingSheetRow.getInputFields().add(filterProperties); tableViewer.refresh();//w ww . jav a2 s . com int i = mappingSheetRow.getInputFields().size() == 0 ? mappingSheetRow.getInputFields().size() : mappingSheetRow.getInputFields().size() - 1; tableViewer.editElement(tableViewer.getElementAt(i), 0); } }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.schema.GeneralGridWidgetBuilder.java
License:Apache License
@Override public void createDefaultSchema(List grids, TableViewer tableViewer, Label errorLabel) { int rowSequence = getRowSequence(); BasicSchemaGridRow schemaGrid = new BasicSchemaGridRow(); schemaGrid.setFieldName("DefaultField" + rowSequence); schemaGrid.setDateFormat(""); schemaGrid.setPrecision(""); schemaGrid.setScale(""); schemaGrid.setScaleType(Integer.valueOf(Constants.DEFAULT_INDEX_VALUE_FOR_COMBOBOX)); schemaGrid.setScaleTypeValue(// w ww . j a v a 2 s . c o m getScaleTypeValue()[Integer.valueOf(Constants.DEFAULT_INDEX_VALUE_FOR_COMBOBOX)]); schemaGrid.setDataType(Integer.valueOf(Constants.DEFAULT_INDEX_VALUE_FOR_COMBOBOX)); schemaGrid .setDataTypeValue(getDataTypeValue()[Integer.valueOf(Constants.DEFAULT_INDEX_VALUE_FOR_COMBOBOX)]); schemaGrid.setDescription(""); int numberOfRows = grids.size(); do { if (!grids.contains(schemaGrid)) { grids.add(schemaGrid); tableViewer.setInput(grids); tableViewer.refresh(); tableViewer.editElement( tableViewer.getElementAt(grids.size() == 0 ? grids.size() : grids.size() - 1), 0); break; } schemaGrid.setFieldName("DefaultField" + rowSequence++); numberOfRows--; } while (numberOfRows >= -1); }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.schema.XPathGridWidgetBuilder.java
License:Apache License
@Override public void createDefaultSchema(List grids, TableViewer tableViewer, Label errorLabel) { int rowSequence = getRowSequence(); XPathGridRow schemaGrid = new XPathGridRow(); schemaGrid.setFieldName("DefaultField" + rowSequence); schemaGrid.setDateFormat(""); schemaGrid.setXPath(""); schemaGrid.setPrecision(""); schemaGrid.setScale(""); schemaGrid.setScaleType(Integer.valueOf(Constants.DEFAULT_INDEX_VALUE_FOR_COMBOBOX)); schemaGrid.setScaleTypeValue(//from ww w. j a v a 2 s . c o m getScaleTypeValue()[Integer.valueOf(Constants.DEFAULT_INDEX_VALUE_FOR_COMBOBOX)]); schemaGrid.setDataType(Integer.valueOf(Constants.DEFAULT_INDEX_VALUE_FOR_COMBOBOX)); schemaGrid .setDataTypeValue(getDataTypeValue()[Integer.valueOf(Constants.DEFAULT_INDEX_VALUE_FOR_COMBOBOX)]); schemaGrid.setDescription(""); int numberOfRows = grids.size(); do { if (!grids.contains(schemaGrid)) { grids.add(schemaGrid); tableViewer.setInput(grids); tableViewer.refresh(); tableViewer.editElement( tableViewer.getElementAt(grids.size() == 0 ? grids.size() : grids.size() - 1), 0); break; } schemaGrid.setFieldName("DefaultField" + rowSequence++); numberOfRows--; } while (numberOfRows >= -1); }
From source file:hydrograph.ui.propertywindow.widgets.dialogs.ELTOperationClassDialog.java
License:Apache License
private void addNewRow(TableViewer nameValueTableViewer) { NameValueProperty nameValueProperty = new NameValueProperty(); nameValueProperty.setPropertyName(""); nameValueProperty.setPropertyValue(""); if (!operationClassProperty.getNameValuePropertyList().contains(nameValueProperty)) { operationClassProperty.getNameValuePropertyList().add(nameValueProperty); nameValueTableViewer.refresh();/* www .java 2s .c o m*/ nameValueTableViewer.editElement( nameValueTableViewer.getElementAt(operationClassProperty.getNameValuePropertyList().size() - 1), 0); applyButton.setEnabled(true); } }
From source file:hydrograph.ui.propertywindow.widgets.listeners.ELTShortcutKeyGridListener.java
License:Apache License
private void attachShortcutKeyListener(Control currentControl, final PropertyDialogButtonBar propertyDialogButtonBar, final ListenerHelper helpers, final Widget[] widgets) { isKeyListenerAttached = true;//ww w . j a v a2 s . c o m currentControl.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent event) { if (event.keyCode == SWT.CTRL || event.keyCode == SWT.COMMAND) { ctrlKeyPressed = false; } } @Override public void keyPressed(KeyEvent event) { if (event.keyCode == SWT.CTRL || event.keyCode == SWT.COMMAND) { ctrlKeyPressed = true; } if (ctrlKeyPressed && event.keyCode == Constants.KEY_N) { propertyDialogButtonBar.enableApplyButton(true); table.getParent().getShell().setFocus(); ((Button) widgets[1]).setEnabled(true); ELTGridDetails eltGridDetails = (ELTGridDetails) helpers.get(HelperType.SCHEMA_GRID); if (eltGridDetails.getGrids().size() >= 1) { ((Button) widgets[2]).setEnabled(true); ((Button) widgets[3]).setEnabled(true); } GridWidgetCommonBuilder gridCommonBuilder = eltGridDetails.getGridWidgetCommonBuilder(); gridCommonBuilder.setRowSequence(rowSequence); gridCommonBuilder.createDefaultSchema(eltGridDetails.getGrids(), eltGridDetails.getTableViewer(), eltGridDetails.getLabel()); rowSequence++; ((Component) helpers.get(HelperType.COMPONENT)).setLatestChangesInSchema(true); } else if (ctrlKeyPressed && event.keyCode == Constants.KEY_D) { propertyDialogButtonBar.enableApplyButton(true); ELTGridDetails gridDetails = (ELTGridDetails) helpers.get(HelperType.SCHEMA_GRID); TableViewer tableViewer = gridDetails.getTableViewer(); Table table = tableViewer.getTable(); int[] indexes = table.getSelectionIndices(); if (table.getSelectionIndex() == -1) { WidgetUtility.errorMessage("Please Select row to delete"); } else { table.remove(indexes); List listOfItemsToRemove = new ArrayList(); for (int index : indexes) { listOfItemsToRemove.add(gridDetails.getGrids().get(index)); } List<GridRow> gridsList = gridDetails.getGrids(); gridsList.removeAll(listOfItemsToRemove); //highlight after deletion if (indexes.length == 1 && gridsList.size() > 0) {//only one item is deleted if (gridsList.size() == 1) {//list contains only one element table.select(0);// select the first element tableViewer.editElement(tableViewer.getElementAt(0), 0); } else if (gridsList.size() == indexes[0]) {//deleted last item table.select(gridsList.size() - 1);//select the last element which now at the end of the list tableViewer.editElement(tableViewer.getElementAt(gridsList.size() - 1), 0); } else if (gridsList.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 (gridsList.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); } } } if (gridDetails.getGrids().size() >= 1) { ((Button) widgets[1]).setEnabled(true); } else { ((Button) widgets[1]).setEnabled(false); } if (gridDetails.getGrids().size() >= 2) { ((Button) widgets[2]).setEnabled(true); ((Button) widgets[3]).setEnabled(true); } else { ((Button) widgets[2]).setEnabled(false); ((Button) widgets[3]).setEnabled(false); } ((Component) helpers.get(HelperType.COMPONENT)).setLatestChangesInSchema(true); } } }); }
From source file:hydrograph.ui.propertywindow.widgets.listeners.grid.ELTGridDeleteSelectionListener.java
License:Apache License
@Override public void selectionListenerAction(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) {//from w ww.ja v a 2s.c o m propertyDialogButtonBar.enableApplyButton(true); ELTGridDetails gridDetails = (ELTGridDetails) helpers.get(HelperType.SCHEMA_GRID); TableViewer tableViewer = gridDetails.getTableViewer(); Table table = tableViewer.getTable(); int[] indexes = table.getSelectionIndices(); if (table.getSelectionIndex() == -1) { WidgetUtility.errorMessage("Please Select row to delete"); } else { table.remove(indexes); List listOfItemsToRemove = new ArrayList(); for (int index : indexes) { listOfItemsToRemove.add(gridDetails.getGrids().get(index)); } List<GridRow> gridsList = gridDetails.getGrids(); gridsList.removeAll(listOfItemsToRemove); //highlight after deletion if (indexes.length == 1 && gridsList.size() > 0) {//only one item is deleted if (gridsList.size() == 1) {//list contains only one element table.select(0);// select the first element tableViewer.editElement(tableViewer.getElementAt(0), 0); } else if (gridsList.size() == indexes[0]) {//deleted last item table.select(gridsList.size() - 1);//select the last element which now at the end of the list tableViewer.editElement(tableViewer.getElementAt(gridsList.size() - 1), 0); } else if (gridsList.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 (gridsList.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); } } } if (gridDetails.getGrids().size() >= 1) { ((Button) widgets[1]).setEnabled(true); } else { ((Button) widgets[1]).setEnabled(false); } if (gridDetails.getGrids().size() >= 2) { ((Button) widgets[2]).setEnabled(true); ((Button) widgets[3]).setEnabled(true); } else { ((Button) widgets[2]).setEnabled(false); ((Button) widgets[3]).setEnabled(false); } ((Component) helpers.get(HelperType.COMPONENT)).setLatestChangesInSchema(true); }
From source file:hydrograph.ui.propertywindow.widgets.listeners.grid.transform.ELTTransforAddOpSysSelectionListener.java
License:Apache License
@Override public void createDefaultSchema(List grids, TableViewer tableViewer, Label errorLabel) { OperationSystemProperties opSystemProperties = new OperationSystemProperties(); opSystemProperties.setChecked(false); opSystemProperties.setOpSysValue(""); if (!grids.contains(opSystemProperties)) { grids.add(opSystemProperties);// ww w . j av a2 s.c o m tableViewer.setInput(grids); tableViewer.refresh(); tableViewer.editElement(tableViewer.getElementAt(grids.size() == 0 ? grids.size() : grids.size() - 1), 0); } }
From source file:hydrograph.ui.propertywindow.widgets.listeners.grid.transform.ELTTransforAddPropValueListener.java
License:Apache License
@Override public void createDefaultSchema(List grids, TableViewer tableViewer, Label errorLabel) { NameValueProperty nameValueProperty = new NameValueProperty(); nameValueProperty.setPropertyName(""); nameValueProperty.setPropertyValue(""); if (!grids.contains(nameValueProperty)) { grids.add(nameValueProperty);//from ww w. ja v a2 s . co m tableViewer.refresh(); tableViewer.editElement(tableViewer.getElementAt(grids.size() == 0 ? grids.size() : grids.size() - 1), 0); } }