Skip to content

Commit

Permalink
[BACKLOG-17366] - I want to support multiple topic ingestion from a s…
Browse files Browse the repository at this point in the history
…treaming ingestion step(insert variables) (#4221)
  • Loading branch information
Aliaksandr-Kastenka authored and Kurtis Walker committed Jul 28, 2017
1 parent b69fc8a commit 9dfe433
Showing 1 changed file with 72 additions and 22 deletions.
94 changes: 72 additions & 22 deletions ui/src/main/java/org/pentaho/di/ui/core/widget/TableView.java
Expand Up @@ -138,7 +138,7 @@ public interface TableViewModifyListener {
private PropsUI props;

private Control text;
private CCombo combo;
private Composite combo;
private Button button;

private TableItem activeTableItem;
Expand Down Expand Up @@ -624,7 +624,11 @@ public void focusLost( FocusEvent e ) {

if ( colnr > 0 ) {
try {
row.setText( colnr, combo.getText() );
if ( combo instanceof ComboVar ) {
row.setText( colnr, ( (ComboVar) combo ).getText() );
} else {
row.setText( colnr, ( (CCombo) combo ).getText() );
}
} catch ( Exception exc ) {
// Eat widget disposed error
}
Expand All @@ -647,7 +651,11 @@ public void modifyText( ModifyEvent e ) {
}
int colnr = activeTableColumn;
int rownr = table.indexOf( row );
row.setText( colnr, combo.getText() );
if ( combo instanceof ComboVar ) {
row.setText( colnr, ( (ComboVar) combo ).getText() );
} else {
row.setText( colnr, ( (CCombo) combo ).getText() );
}

String[] afterEdit = getItemText( row );
checkChanged( new String[][]{ beforeEdit }, new String[][]{ afterEdit }, new int[]{ rownr } );
Expand Down Expand Up @@ -755,7 +763,11 @@ public void keyPressed( KeyEvent e ) {
clipboard = new Clipboard( getDisplay() );
TextTransfer tran = TextTransfer.getInstance();
String text = (String) clipboard.getContents( tran );
combo.setText( text );
if ( combo instanceof ComboVar ) {
( (ComboVar) combo ).setText( text );
} else {
( (CCombo) combo ).setText( text );
}
return;
}

Expand Down Expand Up @@ -1499,7 +1511,12 @@ private void fireContentChangedListener( int rownr, int colnr, String textData )
}

private void applyComboChange( TableItem row, int rownr, int colnr ) {
String textData = combo.getText();
String textData;
if ( combo instanceof ComboVar ) {
textData = ( (ComboVar) combo ).getText();
} else {
textData = ( (CCombo) combo ).getText();
}
row.setText( colnr, textData );
combo.dispose();

Expand Down Expand Up @@ -2283,32 +2300,65 @@ private void editCombo( TableItem row, int rownr, int colnr ) {
}
}

combo = new CCombo( table, colinfo.isReadOnly() ? SWT.READ_ONLY : SWT.NONE );
props.setLook( combo, Props.WIDGET_STYLE_TABLE );
combo.addTraverseListener( lsTraverse );
combo.addModifyListener( lsModCombo );
combo.addFocusListener( lsFocusCombo );

String[] opt = getComboValues( row, colinfo );

if ( colinfo.getComboValuesSelectionListener() != null ) {
opt = colinfo.getComboValuesSelectionListener().getComboValues( row, rownr, colnr );
}
combo.setItems( opt );
combo.setVisibleItemCount( opt.length );
combo.setText( row.getText( colnr ) );
if ( lsMod != null ) {
combo.addModifyListener( lsMod );

final boolean useVariables = colinfo.isUsingVariables();
if ( useVariables ) {
GetCaretPositionInterface getCaretPositionInterface = new GetCaretPositionInterface() {
@Override
public int getCaretPosition() {
return 0;
}
};

// The text widget will be disposed when we get here
// So we need to write to the table row
//
InsertTextInterface insertTextInterface = new InsertTextInterface() {
@Override
public void insertText( String string, int position ) {
StringBuilder buffer = new StringBuilder( table.getItem( rownr ).getText( colnr ) );
buffer.insert( position, string );
table.getItem( rownr ).setText( colnr, buffer.toString() );
int newPosition = position + string.length();
edit( rownr, colnr );
}
};

combo = new ComboVar( variables, table, SWT.SINGLE | SWT.LEFT | SWT.BORDER, getCaretPositionInterface, insertTextInterface );
( (ComboVar) combo ).addModifyListener( lsModCombo );
( (ComboVar) combo ).setItems( opt );
( (ComboVar) combo ).setText( row.getText( colnr ) );

if ( lsMod != null ) {
( (ComboVar) combo ).addModifyListener( lsMod );
}
( (ComboVar) combo ).addModifyListener( lsUndo );
} else {
combo = new CCombo( table, colinfo.isReadOnly() ? SWT.READ_ONLY : SWT.NONE );
( (CCombo) combo ).addModifyListener( lsModCombo );
( (CCombo) combo ).setItems( opt );
( (CCombo) combo ).setVisibleItemCount( opt.length );
( (CCombo) combo ).setText( row.getText( colnr ) );
if ( lsMod != null ) {
( (CCombo) combo ).addModifyListener( lsMod );
}
( (CCombo) combo ).addModifyListener( lsUndo );
if ( colinfo.getSelectionAdapter() != null ) {
( (CCombo) combo ).addSelectionListener( columns[colnr - 1].getSelectionAdapter() );
}
}
combo.addModifyListener( lsUndo );

props.setLook( combo, Props.WIDGET_STYLE_TABLE );
combo.addFocusListener( lsFocusCombo );
combo.addTraverseListener( lsTraverse );
combo.setToolTipText( colinfo.getToolTip() == null ? "" : colinfo.getToolTip() );
combo.setVisible( true );
combo.addKeyListener( lsKeyCombo );

if ( colinfo.getSelectionAdapter() != null ) {
combo.addSelectionListener( columns[colnr - 1].getSelectionAdapter() );
}

editor.horizontalAlignment = SWT.LEFT;
editor.layout();

Expand Down

0 comments on commit 9dfe433

Please sign in to comment.