Table: fixed bug
authorjihye424.kim <jihye424.kim@samsung.com>
Wed, 21 Oct 2015 03:55:20 +0000 (12:55 +0900)
committerjihye424.kim <jihye424.kim@samsung.com>
Wed, 21 Oct 2015 03:55:20 +0000 (12:55 +0900)
- fixed insert error
-- error: if new table item has same index as selected item index,
throw index out of bounds exception when copy selection array
-- cause: table item set item index itself before creaetd by table
so items had same index are two...so throw exception
-- solution: table item does not set index itself, only table set item index

- fixed select table item error
-- error: when select table item..you can see parts that not drawing
-- cause: table item and table have different width
if table width has been changed, table item width has not changed..
-- solution: when table width has been changed, also change table item width

Change-Id: I2e30e145bee5ec0bb2844da91c993fdaee94cb90
Signed-off-by: jihye424.kim <jihye424.kim@samsung.com>
src/org/tizen/emulator/manager/ui/table/Table.java
src/org/tizen/emulator/manager/ui/table/TableItem.java

index 387f5a4..3a9ef1e 100644 (file)
@@ -894,11 +894,11 @@ public class Table extends TableScrolledComposite {
                items[index] = item;
                itemCount++;
 
-               if (itemCount == 1 &&isCheck) {
+               if (itemCount == 1 && isCheck) {
                        checkBox.setEnabled(true);
                }
 
-               adjustItemIndices( index );
+               adjustItemIndices(index);
 
                // advance focusIndex when an item is inserted before the focused item
                if( index <= focusIndex ) {
@@ -1069,6 +1069,7 @@ public class Table extends TableScrolledComposite {
                }
 
                setTableSize();
+
        }
 
        void computeTableSize() {
@@ -1098,14 +1099,25 @@ public class Table extends TableScrolledComposite {
                if (hVisible) {
                        tableHeight += this.getScrollBarWidth();
                }
-               int width = Math.max(tableWidth, rect.width);
-               int height = Math.max(tableHeight, rect.height);
+               tableWidth = Math.max(tableWidth, rect.width);
+               tableHeight = Math.max(tableHeight, rect.height);
+
+               table.setSize(tableWidth, tableHeight);
+
+               if (tableColumn.getBounds().width != tableWidth) {
+                       tableColumn.setBounds(0, 0, tableWidth, columnHeight);
+               }
 
-               table.setSize(width, height);
-               tableColumn.setBounds(0, 0, width, columnHeight);
-               tableItem.setBounds(0, columnHeight, width, height - columnHeight);
+               if (tableItem.getBounds().width != tableWidth) {
+                       tableItem.setBounds(0, columnHeight, tableWidth, tableHeight - columnHeight);
+                       for (TableItem item : items) {
+                               if (item != null) {
+                                       item.updateSizeAndLocation(-1);
+                               }
+                       }
+               }
 
-               if (rect.width == width && rect.height == height) {
+               if (rect.width == tableWidth && rect.height == tableHeight) {
                        redraw();
                }
 
@@ -1231,7 +1243,7 @@ public class Table extends TableScrolledComposite {
 
        // for table item
        int getTableWidth() {
-               return table.getSize().x;
+               return tableWidth;
        }
 
        public void showColumn(TableColumn column) {}
@@ -1280,7 +1292,6 @@ public class Table extends TableScrolledComposite {
                @Override
                public void paintControl(PaintEvent e) {
                        Rectangle rect= ((Composite)e.widget).getClientArea();
-
                        GC gc = e.gc;
                        int top = 0;
                        int height = getItemHeight();
index 7c1a352..3695519 100644 (file)
@@ -77,7 +77,7 @@ public class TableItem extends Canvas {
 
        private boolean checked;
        private boolean grayed;
-       private int index;
+       private int index = -1;
 
        //private boolean isHoverState = false;
        private boolean isSelected = false;
@@ -91,7 +91,7 @@ public class TableItem extends Canvas {
        public TableItem(final Table parent, int style, int index) {
                super(parent.tableItem, style);
                this.parent = parent;
-               this.index = index;
+               //this.index = index;
 
                makeTableItemCanvas();
 
@@ -544,11 +544,6 @@ public class TableItem extends Canvas {
                }
        }
 
-       @Override
-       public Rectangle getBounds() {
-               return getBounds(0);
-       }
-
        public Rectangle getBounds(int index) {
                checkWidget();
                if (!parent.checkData(this, parent.indexOf(this))) {
@@ -840,6 +835,10 @@ public class TableItem extends Canvas {
                        width += parent.getColumn(i).getWidth();
                }
 
+               if (parent.isChecked()) {
+                       width += parent.getCheckBoxWidth();
+               }
+
                width = Math.max(width, parent.getTableWidth());
                int top = getTop(index);
                int height = getHeight();