diff options
author | Kevin Barnes <krbarnes> | 2008-02-04 20:58:00 +0000 |
---|---|---|
committer | Kevin Barnes <krbarnes> | 2008-02-04 20:58:00 +0000 |
commit | b6dab3dc248d9135e08e65943e15a6ae36c16846 (patch) | |
tree | a467aae56763e51f17a3cc5e4b893c87c4ad8da5 | |
parent | 15cd4b3b02a9366a3c91dffa7606a25c162b7d95 (diff) | |
download | eclipse.platform.swt-b6dab3dc248d9135e08e65943e15a6ae36c16846.tar.gz eclipse.platform.swt-b6dab3dc248d9135e08e65943e15a6ae36c16846.tar.xz eclipse.platform.swt-b6dab3dc248d9135e08e65943e15a6ae36c16846.zip |
217746 - Table test failures
9 files changed, 113 insertions, 33 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.wpf.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.wpf.OS.properties index 1256ba4d5b..33f1be27f1 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.wpf.OS.properties +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.wpf.OS.properties @@ -1979,6 +1979,11 @@ OS_Object_GetType_0=cast=(Object ^),flags=gcobject OS_Object_ToString=flags=cpp gcobject OS_Object_ToString_0=cast=(Object ^),flags=gcobject +OS_ObservableCollectionGridViewColumn_Move=flags=cpp +OS_ObservableCollectionGridViewColumn_Move_0=cast=(ObservableCollection<GridViewColumn^>^),flags=gcobject +OS_ObservableCollectionGridViewColumn_Move_1= +OS_ObservableCollectionGridViewColumn_Move_2= + OS_OpenFileDialog_Multiselect=flags=setter OS_OpenFileDialog_Multiselect_0=cast=OpenFileDialog^,flags=gcobject OS_OpenFileDialog_Multiselect_1= diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.cpp b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.cpp index 84781ddc4b..7070d949b1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.cpp +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.cpp @@ -7241,6 +7241,17 @@ JNIEXPORT jint JNICALL OS_NATIVE(Object_1ToString) } #endif +#ifndef NO_ObservableCollectionGridViewColumn_1Move +extern "C" JNIEXPORT void JNICALL OS_NATIVE(ObservableCollectionGridViewColumn_1Move)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2); +JNIEXPORT void JNICALL OS_NATIVE(ObservableCollectionGridViewColumn_1Move) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + OS_NATIVE_ENTER(env, that, ObservableCollectionGridViewColumn_1Move_FUNC); + ((ObservableCollection<GridViewColumn^>^)TO_OBJECT(arg0))->Move(arg1, arg2); + OS_NATIVE_EXIT(env, that, ObservableCollectionGridViewColumn_1Move_FUNC); +} +#endif + #ifndef NO_OpenFileDialog_1Multiselect extern "C" JNIEXPORT void JNICALL OS_NATIVE(OpenFileDialog_1Multiselect)(JNIEnv *env, jclass that, jint arg0, jboolean arg1); JNIEXPORT void JNICALL OS_NATIVE(OpenFileDialog_1Multiselect) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.h index 4e02bfe028..15ec35306b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.h @@ -17,6 +17,7 @@ using namespace System; using namespace System::ComponentModel; using namespace System::Collections; +using namespace System::Collections::ObjectModel; using namespace System::Globalization; using namespace System::Reflection; using namespace System::Windows; diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.cpp b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.cpp index b1f568750a..29ac20dcb5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.cpp +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.cpp @@ -14,8 +14,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 1298; -int OS_nativeFunctionCallCount[1298]; +int OS_nativeFunctionCount = 1299; +int OS_nativeFunctionCallCount[1299]; char * OS_nativeFunctionNames[] = { "AccessText_1AccessKey", "AccessText_1Text", @@ -614,6 +614,7 @@ char * OS_nativeFunctionNames[] = { "Object_1Equals", "Object_1GetType", "Object_1ToString", + "ObservableCollectionGridViewColumn_1Move", "OpenFileDialog_1Multiselect", "Panel_1Background__I", "Panel_1Background__II", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.h index 4a8ebf1df3..7fec36ed63 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.h @@ -622,6 +622,7 @@ typedef enum { Object_1Equals_FUNC, Object_1GetType_FUNC, Object_1ToString_FUNC, + ObservableCollectionGridViewColumn_1Move_FUNC, OpenFileDialog_1Multiselect_FUNC, Panel_1Background__I_FUNC, Panel_1Background__II_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/org/eclipse/swt/internal/wpf/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/org/eclipse/swt/internal/wpf/OS.java index a43e8b5b33..ec2f9fea69 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/org/eclipse/swt/internal/wpf/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/org/eclipse/swt/internal/wpf/OS.java @@ -1003,6 +1003,7 @@ public static final native void NotifyIcon_Visible(int sender, boolean value); public static final native boolean Object_Equals(int sender, int o); public static final native int Object_GetType(int sender); public static final native int Object_ToString(int sender); +public static final native void ObservableCollectionGridViewColumn_Move(int sender, int oldIndex, int newIndex); public static final native void OpenFileDialog_Multiselect (int sender, boolean value); public static final native void RowDefinition_Height(int sender, int height); public static final native void RowDefinitionCollection_Add(int sender, int row); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java index 485cb9d273..b8af088f85 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java @@ -1682,6 +1682,7 @@ boolean mnemonicMatch (char key) { */ public void moveAbove (Control control) { checkWidget (); + if (parent == null) return; //TODO if (control != null) { if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT); if (parent != control.parent) return; @@ -1724,6 +1725,7 @@ public void moveAbove (Control control) { */ public void moveBelow (Control control) { checkWidget (); + if (parent == null) return; //TODO if (control != null) { if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT); if (parent != control.parent) return; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Table.java index 028d6c27be..b40261b1d6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Table.java @@ -64,6 +64,8 @@ public class Table extends Composite { int gridViewHandle, parentingHandle; int columnCount, itemCount; boolean ignoreSelection; + TableColumn [] columns; + boolean linesVisible; static final String CHECKBOX_PART_NAME = "SWT_PART_CHECKBOX"; static final String IMAGE_PART_NAME = "SWT_PART_IMAGE"; @@ -510,10 +512,10 @@ void createItem (TableColumn column, int index) { template = createCellTemplate (index); OS.GridViewColumn_CellTemplate (column.handle, template); OS.GCHandle_Free (template); - int columns = OS.GridView_Columns (gridViewHandle); - if (columnCount == 0) OS.GridViewColumnCollection_Clear (columns); - OS.GridViewColumnCollection_Insert (columns, index, column.handle); - OS.GCHandle_Free (columns); + int gvColumns = OS.GridView_Columns (gridViewHandle); + if (columnCount == 0) OS.GridViewColumnCollection_Clear (gvColumns); + OS.GridViewColumnCollection_Insert (gvColumns, index, column.handle); + OS.GCHandle_Free (gvColumns); // When columnCount is 0, a "default column" is created in // the WPF control, therefore there is no need to manipulate // the item's array the first time a TableColumn is created @@ -526,6 +528,12 @@ void createItem (TableColumn column, int index) { } OS.GCHandle_Free (items); } + if (columns == null) columns = new TableColumn [4]; + if (columns.length == columnCount) { + TableColumn [] newColumns = new TableColumn [columnCount + 4]; + System.arraycopy(columns, 0, newColumns, 0, columnCount); + } + columns [columnCount] = column; columnCount++; } @@ -578,8 +586,9 @@ public void deselect (int [] indices) { int items = OS.ItemsControl_Items (handle); ignoreSelection = true; for (int i=0; i<indices.length; i++) { - if (!(0 <= indices[i] && indices[i] < itemCount)) continue; - int item = OS.ItemCollection_GetItemAt (items, i); + int index = indices [i]; + if (!(0 <= index && index < itemCount)) continue; + int item = OS.ItemCollection_GetItemAt (items, index); OS.ListBoxItem_IsSelected (item, false); OS.GCHandle_Free (item); } @@ -661,15 +670,25 @@ public void deselectAll () { } void destroyItem (TableColumn column) { - int columns = OS.GridView_Columns (gridViewHandle); - int index = OS.GridViewColumnCollection_IndexOf (columns, column.handle); - boolean removed = OS.GridViewColumnCollection_Remove (columns, column.handle); - OS.GCHandle_Free (columns); + int gvColumns = OS.GridView_Columns (gridViewHandle); + int index = OS.GridViewColumnCollection_IndexOf (gvColumns, column.handle); + boolean removed = OS.GridViewColumnCollection_Remove (gvColumns, column.handle); + OS.GCHandle_Free (gvColumns); if (!removed) error (SWT.ERROR_ITEM_NOT_REMOVED); + int arrayIndex = -1; + for (int i = 0; i < columnCount; i++) { + TableColumn tc = columns [i]; + if (tc.equals(column)) { + arrayIndex = i; + break; + } + } columnCount--; + columns [arrayIndex] = null; + if (arrayIndex < columnCount) System.arraycopy (columns, arrayIndex+1, columns, arrayIndex, columnCount - arrayIndex); if (columnCount == 0) { createDefaultColumn (); - } + } int items = OS.ItemsControl_Items (handle); for (int i=0; i<itemCount; i++) { TableItem item = getItem (items, i, false); @@ -728,10 +747,7 @@ int findPartByType (int source, int type) { public TableColumn getColumn (int index) { checkWidget (); if (!(0 <= index && index < columnCount)) error (SWT.ERROR_INVALID_RANGE); - int columns = OS.GridView_Columns (gridViewHandle); - TableColumn column = getColumn (columns, index); - OS.GCHandle_Free (columns); - return column; + return columns [index]; } TableColumn getColumn (int columns, int index) { @@ -795,6 +811,13 @@ public int[] getColumnOrder () { //TODO int [] order = new int [columnCount]; for (int i=0; i<order.length; i++) order [i] = i; + int gvColumns = OS.GridView_Columns (gridViewHandle); + for (int i = 0; i < order.length; i++) { + TableColumn column = columns [i]; + int index = OS.IList_IndexOf (gvColumns, column.handle); + order [index] = i; + } + OS.GCHandle_Free (gvColumns); return order; } @@ -828,11 +851,9 @@ public int[] getColumnOrder () { public TableColumn [] getColumns () { checkWidget (); TableColumn [] result = new TableColumn [columnCount]; - int columns = OS.GridView_Columns (gridViewHandle); for (int i = 0; i < result.length; i++) { - result[i] = getColumn (columns, i); + result [i] = columns [i]; } - OS.GCHandle_Free (columns); return result; } @@ -871,6 +892,10 @@ public int getHeaderHeight () { int header = OS.GridViewColumn_Header (column); if (header != 0) { height = (int) OS.FrameworkElement_ActualHeight (header); + if (height == 0) { + updateLayout (header); + height = (int) OS.FrameworkElement_ActualHeight (header); + } OS.GCHandle_Free (header); } OS.GCHandle_Free (column); @@ -897,7 +922,6 @@ public int getHeaderHeight () { */ public boolean getHeaderVisible () { checkWidget (); - if (columnCount == 0) return false; int columns = OS.GridView_Columns (gridViewHandle); int column = OS.GridViewColumnCollection_default (columns, 0); int header = OS.GridViewColumn_Header (column); @@ -1076,7 +1100,7 @@ public TableItem [] getItems () { public boolean getLinesVisible () { checkWidget (); //TODO - return false; + return linesVisible; } /** @@ -1526,6 +1550,11 @@ void releaseHandle () { parentingHandle = 0; } +void releaseWidget () { + super.releaseWidget (); + columns = null; +} + /** * Removes the items from the receiver's list at the given * zero-relative indices. @@ -1554,10 +1583,15 @@ public void remove (int [] indices) { } int items = OS.ItemsControl_Items (handle); ignoreSelection = true; + int lastIndex = -1; for (int i = newIndices.length-1; i >= 0; i--) { - TableItem item = getItem (items, i, false); - if (item != null && !item.isDisposed ()) item.release (false); - OS.ItemCollection_RemoveAt (items, newIndices [i]); + int index = newIndices [i]; + if (index != lastIndex) { + TableItem item = getItem (items, index, false); + if (item != null && !item.isDisposed ()) item.release (false); + OS.ItemCollection_RemoveAt (items, index); + lastIndex = index; + } } ignoreSelection = false; itemCount = OS.ItemCollection_Count (items); @@ -1764,8 +1798,9 @@ public void select (int index) { */ public void select (int start, int end) { checkWidget (); + if ((style & SWT.SINGLE) != 0 && start != end) return; if (start <= 0 && end >= itemCount - 1) { - deselectAll (); + selectAll (); } else { start = Math.max (0, start); end = Math.min (end, itemCount - 1); @@ -1853,7 +1888,25 @@ int setBounds (int x, int y, int width, int height, int flags) { public void setColumnOrder (int [] order) { checkWidget (); if (order == null) error (SWT.ERROR_NULL_ARGUMENT); - //TODO + if (order.length != columnCount) error (SWT.ERROR_INVALID_ARGUMENT); + int [] oldOrder = getColumnOrder (); + boolean reorder = false; + boolean [] seen = new boolean [columnCount]; + for (int i=0; i<order.length; i++) { + int index = order [i]; + if (index < 0 || index >= columnCount) error (SWT.ERROR_INVALID_ARGUMENT); + if (seen [index]) error (SWT.ERROR_INVALID_ARGUMENT); + seen [index] = true; + if (order [i] != oldOrder [i]) reorder = true; + } + if (!reorder) return; + int gvColumns = OS.GridView_Columns (gridViewHandle); + for (int i = 0; i < order.length; i++) { + TableColumn column = columns [order [i]]; + int index = OS.IList_IndexOf (gvColumns, column.handle); + if (index != i) OS.ObservableCollectionGridViewColumn_Move (gvColumns, index, i); + } + OS.GCHandle_Free (gvColumns); } void setFont (int font, double size) { @@ -2018,7 +2071,7 @@ public void setItemCount (int count) { */ public void setLinesVisible (boolean show) { checkWidget (); - //TODO + linesVisible = show; } /** @@ -2112,7 +2165,7 @@ public void setSelection (TableItem [] items) { deselectAll (); int length = items.length; if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return; - for (int i=length-1; i>=0; --i) { + for (int i=0; i<length; i++) { int index = indexOf (items [i]); if (index != -1) { select (index); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableItem.java index bdd0a800d0..a5b1f8f932 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableItem.java @@ -270,14 +270,19 @@ int findPart (int column, String partName) { updateLayout (rowHandle); int contentPresenter = OS.VisualTreeHelper_GetChild (rowHandle, column); if (contentPresenter == 0) return 0; - int columns = OS.GridView_Columns (parent.gridViewHandle); - int columnHandle = OS.GridViewColumnCollection_default (columns, column); + int columnHandle; + if (parent.columnCount == 0) { + int columns = OS.GridView_Columns (parent.gridViewHandle); + columnHandle = OS.GridViewColumnCollection_default (columns, column); + OS.GCHandle_Free (columns); + } else { + columnHandle = parent.columns [column].handle; + } int cellTemplate = OS.GridViewColumn_CellTemplate (columnHandle); int name = createDotNetString (partName, false); int result = OS.FrameworkTemplate_FindName (cellTemplate, name, contentPresenter); OS.GCHandle_Free (contentPresenter); - OS.GCHandle_Free (columns); - OS.GCHandle_Free (columnHandle); + if (parent.columnCount == 0) OS.GCHandle_Free (columnHandle); OS.GCHandle_Free (cellTemplate); OS.GCHandle_Free (name); return result; |