### Eclipse Workspace Patch 1.0 #P org.eclipse.datatools.sqltools.data.ui Index: src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataLabelProvider.java =================================================================== RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.data.ui/src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataLabelProvider.java,v retrieving revision 1.3 diff -u -r1.3 TableDataLabelProvider.java --- src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataLabelProvider.java 25 Aug 2008 21:20:15 -0000 1.3 +++ src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataLabelProvider.java 3 Feb 2010 11:11:14 -0000 @@ -12,16 +12,22 @@ package org.eclipse.datatools.sqltools.data.internal.ui.editor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.datatools.connectivity.internal.DriverUtil; +import org.eclipse.datatools.connectivity.sqm.internal.core.connection.ConnectionAdapter; import org.eclipse.datatools.sqltools.data.internal.core.common.IColumnDataAccessor; import org.eclipse.datatools.sqltools.data.internal.core.editor.IRowData; +import org.eclipse.datatools.sqltools.data.internal.core.editor.TableDataImpl; import org.eclipse.datatools.sqltools.data.internal.ui.DataUIPlugin; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.custom.Field3270; import org.eclipse.swt.graphics.Image; public class TableDataLabelProvider implements ITableLabelProvider { protected static final int MAX_LABEL_LENGTH = Integer.MAX_VALUE; + private boolean is3270SupportRequired = false; + private boolean is3270SupportInitialized = false; public TableDataLabelProvider() { @@ -37,7 +43,14 @@ return (columnIndex==0)?Messages.getString("TableDataLabelProvider.newRow"):""; //$NON-NLS-1$ //$NON-NLS-2$ IRowData row = (IRowData)element; - + if (!is3270SupportInitialized){ + if ((row.getTable() instanceof TableDataImpl) && + (((TableDataImpl)row.getTable()).getConnection() instanceof ConnectionAdapter)){ + ConnectionAdapter ca = (ConnectionAdapter)((TableDataImpl)row.getTable()).getConnection(); + is3270SupportRequired = DriverUtil.is3270SupportRequired(ca.getConnectionInfo().getConnectionProfile()); + } + is3270SupportInitialized = true; + } try { Object o = row.getValue(columnIndex); IColumnDataAccessor acc = row.getTable().getColumnDataAccessor(columnIndex); @@ -56,6 +69,8 @@ } if (truncated) s += "..."; //$NON-NLS-1$ + if (is3270SupportRequired) + s = Field3270.LRO + s; return s; } } catch (Exception ex) { Index: src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataEditor.java =================================================================== RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.data.ui/src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataEditor.java,v retrieving revision 1.7 diff -u -r1.7 TableDataEditor.java --- src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataEditor.java 8 Dec 2009 00:43:58 -0000 1.7 +++ src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataEditor.java 3 Feb 2010 11:11:14 -0000 @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.datatools.connectivity.internal.DriverUtil; import org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo; import org.eclipse.datatools.connectivity.sqm.core.connection.DatabaseConnectionRegistry; import org.eclipse.datatools.connectivity.sqm.internal.core.connection.ConnectionInfoImpl; @@ -362,7 +363,15 @@ protected void configureTable() { - TextCellEditor textEditor = new TableDataCellEditor(this, tableViewer.getTable()); + TextCellEditor textEditor; + Database database = sqlTable.getSchema().getCatalog().getDatabase(); + ConnectionInfo connInfo = DatabaseConnectionRegistry.getConnectionForDatabase(database); + + if (!DriverUtil.is3270SupportRequired(connInfo.getConnectionProfile())) + textEditor = new TableDataCellEditor(this, tableViewer.getTable()); + else + textEditor = new Field3270TableDataCellEditor(this, tableViewer.getTable()); + CellEditor[] editors = new CellEditor[tableData.getColumnCount()]; String[] properties = new String[tableData.getColumnCount()]; Index: src/org/eclipse/datatools/sqltools/data/internal/ui/editor/DefaultExternalTableDataWizardPage.java =================================================================== RCS file: /cvsroot/datatools/org.eclipse.datatools.sqltools/plugins/org.eclipse.datatools.sqltools.data.ui/src/org/eclipse/datatools/sqltools/data/internal/ui/editor/DefaultExternalTableDataWizardPage.java,v retrieving revision 1.3 diff -u -r1.3 DefaultExternalTableDataWizardPage.java --- src/org/eclipse/datatools/sqltools/data/internal/ui/editor/DefaultExternalTableDataWizardPage.java 15 Feb 2008 04:21:40 -0000 1.3 +++ src/org/eclipse/datatools/sqltools/data/internal/ui/editor/DefaultExternalTableDataWizardPage.java 3 Feb 2010 11:11:13 -0000 @@ -19,13 +19,17 @@ import java.io.IOException; import org.eclipse.core.runtime.IStatus; +import org.eclipse.datatools.connectivity.internal.DriverUtil; +import org.eclipse.datatools.connectivity.sqm.internal.core.connection.ConnectionAdapter; import org.eclipse.datatools.modelbase.sql.tables.Column; import org.eclipse.datatools.sqltools.data.internal.core.editor.IRowData; +import org.eclipse.datatools.sqltools.data.internal.core.editor.TableDataImpl; import org.eclipse.datatools.sqltools.data.internal.ui.DataUIPlugin; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.Field3270; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; @@ -34,8 +38,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; /** * The default Wizard Page for external editing of the TableDataEditor. @@ -55,6 +59,8 @@ /** the default implementation of the edit area, a simple Text area */ protected Text textWidget; + /** the bidi-specific implementation of the edit area, a BidiStyledText area */ + protected Field3270 field3270Widget; /** The Import button */ protected Button btnImport; @@ -85,6 +91,8 @@ protected int buttonAreaSpan; + private boolean is3270SupportRequired = false; + /** * Creates the default page with the given editor * @param pageName the name of the page @@ -122,6 +130,12 @@ // how many buttons we create in the buttonArea buttonAreaSpan = 1; + + if ((rowData.getTable() instanceof TableDataImpl) && + (((TableDataImpl)rowData.getTable()).getConnection() instanceof ConnectionAdapter)){ + ConnectionAdapter ca = (ConnectionAdapter)((TableDataImpl)rowData.getTable()).getConnection(); + is3270SupportRequired = DriverUtil.is3270SupportRequired(ca.getConnectionInfo().getConnectionProfile()); + } } /** @@ -191,23 +205,30 @@ glEditor.marginWidth = 0; editorComp.setLayout(glEditor); editorComp.setLayoutData( new GridData(GridData.FILL_BOTH) ); - - textWidget = new Text(editorComp, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL ); + if (!is3270SupportRequired){ + textWidget = new Text(editorComp, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL ); + } else { + field3270Widget = new Field3270(editorComp, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + } // always enable it so that at least a manual copy and paste from a read-only table can be copied.. - textWidget.setEnabled(true); + getEditWidget().setEnabled(true); boolean editable = (!hasNullValue && !editor.isReadonly()) ; // if it is new (yet null) value of a non-nullable column (i.e. non-nullable and set to null) // we force the editorarea, import, export to be enabled and the null button is set to false // see further down as well boolean nonNullableCheck = (!((Column)editor.getSqlTable().getColumns().get(columnIndex)).isNullable() && hasNullValue); - textWidget.setEditable(editable || nonNullableCheck); + + if (!is3270SupportRequired) + textWidget.setEditable(editable || nonNullableCheck); + else + field3270Widget.setEditable(editable || nonNullableCheck); editorAreaIsSerialized = true; // as we deal with a text field, we want it serialized GridData gdtxtTextValue = new GridData(GridData.FILL_BOTH); gdtxtTextValue.grabExcessHorizontalSpace = true; gdtxtTextValue.grabExcessVerticalSpace = true; - textWidget.setLayoutData(gdtxtTextValue); + getEditWidget().setLayoutData(gdtxtTextValue); gdtxtTextValue.horizontalSpan = 1; //limit width/height of text area when string content is very wide or long gdtxtTextValue.widthHint = 400; @@ -403,7 +424,9 @@ // for others disable widget itself if (getEditWidget() instanceof Text){ ((Text)getEditWidget()).setEditable(!btnSetNull.getSelection()); - } else{ + } else if (getEditWidget() instanceof Field3270){ + ((Field3270)getEditWidget()).setEditable(!btnSetNull.getSelection()); + } else { getEditWidget().setEnabled(!btnSetNull.getSelection()); } if(displayImportBtn){ @@ -600,7 +623,12 @@ protected Object getEditorAreaContent(){ // we dont need to deserialize // as we deal with Strings - return textWidget.getText(); + if (!is3270SupportRequired) + return textWidget.getText(); + else + if (field3270Widget.isWidgetReversed() ^ field3270Widget.isPushMode()) + return Field3270.reverseStr(field3270Widget.getText()); + return field3270Widget.getText(); } /** @@ -616,9 +644,15 @@ } if (serializedContent == null){ hasNullValue = true; // input is still null - textWidget.setText(""); //$NON-NLS-1$ + if (!is3270SupportRequired) + textWidget.setText(""); //$NON-NLS-1$ + else + field3270Widget.setText(""); //$NON-NLS-1$ } else{ - textWidget.setText(serializedContent); + if (!is3270SupportRequired) + textWidget.setText(serializedContent); + else + field3270Widget.setText(serializedContent); hasNullValue = false; } } @@ -654,6 +688,8 @@ * @return the edit widget */ protected Control getEditWidget(){ - return textWidget; - } + if (!is3270SupportRequired) + return textWidget; + return field3270Widget; + } } Index: src/org/eclipse/datatools/sqltools/data/internal/ui/editor/Field3270TableDataCellEditor.java =================================================================== RCS file: src/org/eclipse/datatools/sqltools/data/internal/ui/editor/Field3270TableDataCellEditor.java diff -N src/org/eclipse/datatools/sqltools/data/internal/ui/editor/Field3270TableDataCellEditor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/datatools/sqltools/data/internal/ui/editor/Field3270TableDataCellEditor.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + ******************************************************************************/ + +package org.eclipse.datatools.sqltools.data.internal.ui.editor; + +import org.eclipse.jface.viewers.Field3270CellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +public class Field3270TableDataCellEditor extends Field3270CellEditor { + + protected TableDataEditor editor; + + public Field3270TableDataCellEditor(TableDataEditor editor, Composite parent) + { + super(parent); + this.editor = editor; + } + + protected Control createControl(Composite parent) { + Control c = super.createControl(parent); + c.addTraverseListener(new TraverseListener() { + public void keyTraversed(TraverseEvent e) { + handleTraverse(e); + + } + }); + return c; + } + + protected void handleTraverse(TraverseEvent e) + { + if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS || e.detail == SWT.TRAVERSE_TAB_NEXT) { + fireApplyEditorValue(); + deactivate(); + editor.getCursor().handleTraverse(e); + editor.getCursor().forceFocus(); + editor.getCursor().edit(); + } else if (e.detail == SWT.TRAVERSE_RETURN){ + editor.getCursor().forceFocus(); + } + } +}