View | Details | Raw Unified | Return to bug 298392 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataLabelProvider.java (-1 / +16 lines)
Lines 12-27 Link Here
12
package org.eclipse.datatools.sqltools.data.internal.ui.editor;
12
package org.eclipse.datatools.sqltools.data.internal.ui.editor;
13
13
14
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.datatools.connectivity.internal.DriverUtil;
16
import org.eclipse.datatools.connectivity.sqm.internal.core.connection.ConnectionAdapter;
15
import org.eclipse.datatools.sqltools.data.internal.core.common.IColumnDataAccessor;
17
import org.eclipse.datatools.sqltools.data.internal.core.common.IColumnDataAccessor;
16
import org.eclipse.datatools.sqltools.data.internal.core.editor.IRowData;
18
import org.eclipse.datatools.sqltools.data.internal.core.editor.IRowData;
19
import org.eclipse.datatools.sqltools.data.internal.core.editor.TableDataImpl;
17
import org.eclipse.datatools.sqltools.data.internal.ui.DataUIPlugin;
20
import org.eclipse.datatools.sqltools.data.internal.ui.DataUIPlugin;
18
import org.eclipse.jface.viewers.ILabelProviderListener;
21
import org.eclipse.jface.viewers.ILabelProviderListener;
19
import org.eclipse.jface.viewers.ITableLabelProvider;
22
import org.eclipse.jface.viewers.ITableLabelProvider;
23
import org.eclipse.swt.custom.Field3270;
20
import org.eclipse.swt.graphics.Image;
24
import org.eclipse.swt.graphics.Image;
21
25
22
public class TableDataLabelProvider implements ITableLabelProvider
26
public class TableDataLabelProvider implements ITableLabelProvider
23
{
27
{
24
    protected static final int MAX_LABEL_LENGTH = Integer.MAX_VALUE;
28
    protected static final int MAX_LABEL_LENGTH = Integer.MAX_VALUE;
29
    private boolean is3270SupportRequired = false;
30
    private boolean is3270SupportInitialized = false;
25
   
31
   
26
    public TableDataLabelProvider()
32
    public TableDataLabelProvider()
27
    {
33
    {
Lines 37-43 Link Here
37
            return (columnIndex==0)?Messages.getString("TableDataLabelProvider.newRow"):""; //$NON-NLS-1$ //$NON-NLS-2$
43
            return (columnIndex==0)?Messages.getString("TableDataLabelProvider.newRow"):""; //$NON-NLS-1$ //$NON-NLS-2$
38
    
44
    
39
        IRowData row = (IRowData)element;
45
        IRowData row = (IRowData)element;
40
    
46
        if (!is3270SupportInitialized){ 
47
        	if ((row.getTable() instanceof TableDataImpl) &&
48
        		(((TableDataImpl)row.getTable()).getConnection() instanceof  ConnectionAdapter)){
49
        		ConnectionAdapter ca = (ConnectionAdapter)((TableDataImpl)row.getTable()).getConnection();
50
        		is3270SupportRequired = DriverUtil.is3270SupportRequired(ca.getConnectionInfo().getConnectionProfile());
51
        	}
52
        	is3270SupportInitialized = true;
53
        }
41
        try {
54
        try {
42
            Object o = row.getValue(columnIndex);
55
            Object o = row.getValue(columnIndex);
43
            IColumnDataAccessor acc = row.getTable().getColumnDataAccessor(columnIndex);
56
            IColumnDataAccessor acc = row.getTable().getColumnDataAccessor(columnIndex);
Lines 56-61 Link Here
56
        	    }
69
        	    }
57
        	    if (truncated)
70
        	    if (truncated)
58
        	        s += "..."; //$NON-NLS-1$  
71
        	        s += "..."; //$NON-NLS-1$  
72
        	    if (is3270SupportRequired) 
73
        	    	s = Field3270.LRO + s;
59
        	    return s;
74
        	    return s;
60
            }
75
            }
61
        } catch (Exception ex) {
76
        } catch (Exception ex) {
(-)src/org/eclipse/datatools/sqltools/data/internal/ui/editor/TableDataEditor.java (-1 / +10 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.datatools.connectivity.internal.DriverUtil;
21
import org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo;
22
import org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo;
22
import org.eclipse.datatools.connectivity.sqm.core.connection.DatabaseConnectionRegistry;
23
import org.eclipse.datatools.connectivity.sqm.core.connection.DatabaseConnectionRegistry;
23
import org.eclipse.datatools.connectivity.sqm.internal.core.connection.ConnectionInfoImpl;
24
import org.eclipse.datatools.connectivity.sqm.internal.core.connection.ConnectionInfoImpl;
Lines 362-368 Link Here
362
363
363
    protected void configureTable()
364
    protected void configureTable()
364
    {
365
    {
365
        TextCellEditor textEditor = new TableDataCellEditor(this, tableViewer.getTable());
366
       	TextCellEditor textEditor;
367
    	Database database = sqlTable.getSchema().getCatalog().getDatabase();
368
    	ConnectionInfo connInfo = DatabaseConnectionRegistry.getConnectionForDatabase(database);
369
    	
370
    	if (!DriverUtil.is3270SupportRequired(connInfo.getConnectionProfile()))
371
    		textEditor = new TableDataCellEditor(this, tableViewer.getTable());
372
    	else
373
    		textEditor = new Field3270TableDataCellEditor(this, tableViewer.getTable());
374
366
        
375
        
367
        CellEditor[] editors = new CellEditor[tableData.getColumnCount()];
376
        CellEditor[] editors = new CellEditor[tableData.getColumnCount()];
368
        String[] properties = new String[tableData.getColumnCount()];
377
        String[] properties = new String[tableData.getColumnCount()];
(-)src/org/eclipse/datatools/sqltools/data/internal/ui/editor/DefaultExternalTableDataWizardPage.java (-12 / +48 lines)
Lines 19-31 Link Here
19
import java.io.IOException;
19
import java.io.IOException;
20
20
21
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.datatools.connectivity.internal.DriverUtil;
23
import org.eclipse.datatools.connectivity.sqm.internal.core.connection.ConnectionAdapter;
22
import org.eclipse.datatools.modelbase.sql.tables.Column;
24
import org.eclipse.datatools.modelbase.sql.tables.Column;
23
import org.eclipse.datatools.sqltools.data.internal.core.editor.IRowData;
25
import org.eclipse.datatools.sqltools.data.internal.core.editor.IRowData;
26
import org.eclipse.datatools.sqltools.data.internal.core.editor.TableDataImpl;
24
import org.eclipse.datatools.sqltools.data.internal.ui.DataUIPlugin;
27
import org.eclipse.datatools.sqltools.data.internal.ui.DataUIPlugin;
25
import org.eclipse.jface.dialogs.IDialogConstants;
28
import org.eclipse.jface.dialogs.IDialogConstants;
26
import org.eclipse.jface.dialogs.MessageDialog;
29
import org.eclipse.jface.dialogs.MessageDialog;
27
import org.eclipse.jface.wizard.WizardPage;
30
import org.eclipse.jface.wizard.WizardPage;
28
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.custom.Field3270;
29
import org.eclipse.swt.events.SelectionEvent;
33
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionListener;
34
import org.eclipse.swt.events.SelectionListener;
31
import org.eclipse.swt.layout.GridData;
35
import org.eclipse.swt.layout.GridData;
Lines 34-41 Link Here
34
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Control;
39
import org.eclipse.swt.widgets.Control;
36
import org.eclipse.swt.widgets.FileDialog;
40
import org.eclipse.swt.widgets.FileDialog;
37
import org.eclipse.swt.widgets.Text;
38
import org.eclipse.swt.widgets.TableItem;
41
import org.eclipse.swt.widgets.TableItem;
42
import org.eclipse.swt.widgets.Text;
39
43
40
/**
44
/**
41
 * The default Wizard Page for external editing of the TableDataEditor.
45
 * The default Wizard Page for external editing of the TableDataEditor.
Lines 55-60 Link Here
55
    /** the default implementation of the edit area, a simple Text area */
59
    /** the default implementation of the edit area, a simple Text area */
56
    protected Text textWidget; 
60
    protected Text textWidget; 
57
    
61
    
62
    /** the bidi-specific implementation of the edit area, a BidiStyledText area */
63
    protected Field3270 field3270Widget;
58
    /** The Import button */
64
    /** The Import button */
59
    protected Button btnImport;
65
    protected Button btnImport;
60
    
66
    
Lines 85-90 Link Here
85
    
91
    
86
    protected int buttonAreaSpan;
92
    protected int buttonAreaSpan;
87
    
93
    
94
    private boolean is3270SupportRequired = false;
95
    
88
    /**
96
    /**
89
     * Creates the default page with the given editor
97
     * Creates the default page with the given editor
90
	 * @param pageName the name of the page
98
	 * @param pageName the name of the page
Lines 122-127 Link Here
122
        
130
        
123
        // how many buttons we create in the buttonArea
131
        // how many buttons we create in the buttonArea
124
        buttonAreaSpan = 1;
132
        buttonAreaSpan = 1;
133
134
        if ((rowData.getTable() instanceof TableDataImpl) &&
135
            	(((TableDataImpl)rowData.getTable()).getConnection() instanceof  ConnectionAdapter)){
136
            	ConnectionAdapter ca = (ConnectionAdapter)((TableDataImpl)rowData.getTable()).getConnection();
137
            	is3270SupportRequired = DriverUtil.is3270SupportRequired(ca.getConnectionInfo().getConnectionProfile());
138
        }
125
	}
139
	}
126
140
127
	/**
141
	/**
Lines 191-213 Link Here
191
		glEditor.marginWidth = 0;
205
		glEditor.marginWidth = 0;
192
        editorComp.setLayout(glEditor);
206
        editorComp.setLayout(glEditor);
193
        editorComp.setLayoutData( new GridData(GridData.FILL_BOTH) );
207
        editorComp.setLayoutData( new GridData(GridData.FILL_BOTH) );
194
        
208
        if (!is3270SupportRequired){
195
        textWidget = new Text(editorComp, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
209
                textWidget = new Text(editorComp, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
210
        } else {
211
        	field3270Widget = new Field3270(editorComp, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
212
        }
196
		// always enable it so that at least a manual copy and paste from a read-only table can be copied..
213
		// always enable it so that at least a manual copy and paste from a read-only table can be copied..
197
        textWidget.setEnabled(true);
214
        getEditWidget().setEnabled(true);
198
        boolean editable = (!hasNullValue && !editor.isReadonly()) ;
215
        boolean editable = (!hasNullValue && !editor.isReadonly()) ;
199
        
216
        
200
        // if it is new (yet null) value of a non-nullable column (i.e. non-nullable and set to null) 
217
        // if it is new (yet null) value of a non-nullable column (i.e. non-nullable and set to null) 
201
		// we force the editorarea, import, export to be enabled and the null button is set to false
218
		// we force the editorarea, import, export to be enabled and the null button is set to false
202
		// see further down as well
219
		// see further down as well
203
        boolean nonNullableCheck =  (!((Column)editor.getSqlTable().getColumns().get(columnIndex)).isNullable() && hasNullValue);
220
        boolean nonNullableCheck =  (!((Column)editor.getSqlTable().getColumns().get(columnIndex)).isNullable() && hasNullValue);
204
		textWidget.setEditable(editable || nonNullableCheck);
221
        
222
        if (!is3270SupportRequired)
223
        	textWidget.setEditable(editable || nonNullableCheck);
224
        else
225
        	field3270Widget.setEditable(editable || nonNullableCheck);
205
	
226
	
206
        editorAreaIsSerialized = true;  // as we deal with a text field, we want it serialized
227
        editorAreaIsSerialized = true;  // as we deal with a text field, we want it serialized
207
		GridData gdtxtTextValue = new GridData(GridData.FILL_BOTH);
228
		GridData gdtxtTextValue = new GridData(GridData.FILL_BOTH);
208
		gdtxtTextValue.grabExcessHorizontalSpace = true;
229
		gdtxtTextValue.grabExcessHorizontalSpace = true;
209
		gdtxtTextValue.grabExcessVerticalSpace = true;
230
		gdtxtTextValue.grabExcessVerticalSpace = true;
210
		textWidget.setLayoutData(gdtxtTextValue);   
231
		getEditWidget().setLayoutData(gdtxtTextValue);   
211
        gdtxtTextValue.horizontalSpan = 1;
232
        gdtxtTextValue.horizontalSpan = 1;
212
        //limit width/height of text area when string content is very wide or long
233
        //limit width/height of text area when string content is very wide or long
213
        gdtxtTextValue.widthHint = 400;
234
        gdtxtTextValue.widthHint = 400;
Lines 403-409 Link Here
403
        // for others disable widget itself
424
        // for others disable widget itself
404
        if (getEditWidget() instanceof Text){
425
        if (getEditWidget() instanceof Text){
405
            ((Text)getEditWidget()).setEditable(!btnSetNull.getSelection());
426
            ((Text)getEditWidget()).setEditable(!btnSetNull.getSelection());
406
        } else{
427
        } else if (getEditWidget() instanceof Field3270){
428
        	((Field3270)getEditWidget()).setEditable(!btnSetNull.getSelection());
429
        } else {
407
            getEditWidget().setEnabled(!btnSetNull.getSelection());
430
            getEditWidget().setEnabled(!btnSetNull.getSelection());
408
        }
431
        }
409
        if(displayImportBtn){
432
        if(displayImportBtn){
Lines 600-606 Link Here
600
    protected Object getEditorAreaContent(){
623
    protected Object getEditorAreaContent(){
601
        // we dont need to deserialize
624
        // we dont need to deserialize
602
        // as we deal with Strings
625
        // as we deal with Strings
603
        return textWidget.getText();
626
    	if (!is3270SupportRequired)
627
    		return textWidget.getText();
628
    	else
629
    		if (field3270Widget.isWidgetReversed() ^ field3270Widget.isPushMode())
630
    			return Field3270.reverseStr(field3270Widget.getText()); 
631
    		return field3270Widget.getText(); 
604
    }
632
    }
605
    
633
    
606
    /**
634
    /**
Lines 616-624 Link Here
616
    	}
644
    	}
617
        if (serializedContent == null){
645
        if (serializedContent == null){
618
            hasNullValue = true;  // input is still null
646
            hasNullValue = true;  // input is still null
619
            textWidget.setText(""); //$NON-NLS-1$
647
            if (!is3270SupportRequired)
648
            	textWidget.setText(""); //$NON-NLS-1$
649
            else
650
            	field3270Widget.setText(""); //$NON-NLS-1$
620
        } else{
651
        } else{
621
            textWidget.setText(serializedContent);
652
        	if (!is3270SupportRequired)
653
        		textWidget.setText(serializedContent);
654
        	else
655
        		field3270Widget.setText(serializedContent); 
622
            hasNullValue = false;
656
            hasNullValue = false;
623
        }
657
        }
624
    }
658
    }
Lines 654-659 Link Here
654
     * @return the edit widget
688
     * @return the edit widget
655
     */
689
     */
656
    protected Control getEditWidget(){
690
    protected Control getEditWidget(){
657
        return textWidget;
691
    	if (!is3270SupportRequired)
658
    }
692
    		return textWidget;
693
    	return field3270Widget;
694
    }    
659
}    
695
}    
(-)src/org/eclipse/datatools/sqltools/data/internal/ui/editor/Field3270TableDataCellEditor.java (+54 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.datatools.sqltools.data.internal.ui.editor;
13
14
import org.eclipse.jface.viewers.Field3270CellEditor;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.TraverseEvent;
17
import org.eclipse.swt.events.TraverseListener;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Control;
20
21
public class Field3270TableDataCellEditor extends Field3270CellEditor {
22
23
    protected TableDataEditor editor;
24
    
25
    public Field3270TableDataCellEditor(TableDataEditor editor, Composite parent)
26
    {
27
        super(parent);
28
        this.editor = editor;
29
    }
30
    
31
    protected Control createControl(Composite parent) {
32
        Control c = super.createControl(parent);
33
		c.addTraverseListener(new TraverseListener() {
34
            public void keyTraversed(TraverseEvent e) {
35
                handleTraverse(e);
36
                
37
            }
38
		});
39
        return c;
40
    }
41
        
42
    protected void handleTraverse(TraverseEvent e)
43
    {
44
        if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS || e.detail == SWT.TRAVERSE_TAB_NEXT) {
45
            fireApplyEditorValue();
46
            deactivate();
47
            editor.getCursor().handleTraverse(e);
48
            editor.getCursor().forceFocus();
49
            editor.getCursor().edit();
50
        } else if (e.detail == SWT.TRAVERSE_RETURN){
51
        	editor.getCursor().forceFocus();
52
        }
53
    }
54
}

Return to bug 298392