Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/com/google/gwt/gen2/table/client/ListCellEditor.java

Diff revisions: vs.
  @@ -15,19 +15,18 @@
15 15 */
16 16 package com.google.gwt.gen2.table.client;
17 17
18 - import java.util.*;
19 -
20 18 import com.google.gwt.core.client.*;
21 19 import com.google.gwt.user.client.ui.*;
22 20
21 + import java.util.*;
22 +
23 23 /**
24 24 * An {@link InlineCellEditor} that allows the user to select a {@link String}
25 25 * from a drop down {@link ListBox}.
26 26 *
27 27 * @param <ColType> the data type of the column
28 28 */
29 - public class ListCellEditor<ColType> extends InlineCellEditor<ColType>
30 - {
29 + public class ListCellEditor<ColType> extends InlineCellEditor<ColType> {
31 30 /**
32 31 * The list box of options.
33 32 */
  @@ -42,8 +41,7 @@
42 41 /**
43 42 * Construct a new {@link ListCellEditor}.
44 43 */
45 - public ListCellEditor()
46 - {
44 + public ListCellEditor() {
47 45 this( new ListBox(), GWT.<InlineCellEditorImages>create( InlineCellEditorImages.class ) );
48 46 }
49 47
  @@ -52,8 +50,7 @@
52 50 *
53 51 * @param images the images to use for the accept/cancel buttons
54 52 */
55 - public ListCellEditor( InlineCellEditorImages images )
56 - {
53 + public ListCellEditor( InlineCellEditorImages images ) {
57 54 this( new ListBox(), images );
58 55 }
59 56
  @@ -64,8 +61,7 @@
64 61 * @param listBox the {@link ListBox} to use
65 62 * @param images the images to use for the accept/cancel buttons
66 63 */
67 - protected ListCellEditor( ListBox listBox, InlineCellEditorImages images )
68 - {
64 + protected ListCellEditor( ListBox listBox, InlineCellEditorImages images ) {
69 65 super( listBox, images );
70 66 this.listBox = listBox;
71 67 }
  @@ -76,15 +72,13 @@
76 72 * @param item the text of the item to be added
77 73 * @param value the value associated with the item
78 74 */
79 - public void addItem( String item, ColType value )
80 - {
75 + public void addItem( String item, ColType value ) {
81 76 listBox.addItem( item );
82 77 itemValues.add( value );
83 78 }
84 79
85 80 @Override
86 - public void editCell( CellEditInfo cellEditInfo, ColType cellValue, Callback<ColType> callback )
87 - {
81 + public void editCell( CellEditInfo cellEditInfo, ColType cellValue, Callback<ColType> callback ) {
88 82 super.editCell( cellEditInfo, cellValue, callback );
89 83 listBox.setFocus( true );
90 84 }
  @@ -99,10 +93,8 @@
99 93 * @throws IndexOutOfBoundsException if the index is out of range
100 94 */
101 95 public void insertItem( String item, int index, ColType value )
102 - throws IndexOutOfBoundsException
103 - {
104 - if ( index < 0 || index >= listBox.getItemCount() )
105 - {
96 + throws IndexOutOfBoundsException {
97 + if ( index < 0 || index >= listBox.getItemCount() ) {
106 98 throw new IndexOutOfBoundsException();
107 99 }
108 100 listBox.insertItem( item, index );
  @@ -117,29 +109,23 @@
117 109 * @throws IndexOutOfBoundsException if the index is out of range
118 110 */
119 111 public void removeItem( int index )
120 - throws IndexOutOfBoundsException
121 - {
112 + throws IndexOutOfBoundsException {
122 113 listBox.removeItem( index );
123 114 itemValues.remove( index );
124 115 }
125 116
126 117 @Override
127 - protected ColType getValue()
128 - {
118 + protected ColType getValue() {
129 119 int index = listBox.getSelectedIndex();
130 - if ( index < 0 )
131 - {
120 + if ( index < 0 ) {
132 121 return null;
133 - }
134 - else
135 - {
122 + } else {
136 123 return itemValues.get( index );
137 124 }
138 125 }
139 126
140 127 @Override
141 - protected void setValue( ColType cellValue )
142 - {
128 + protected void setValue( ColType cellValue ) {
143 129 listBox.setSelectedIndex( Math.max( 0, itemValues.indexOf( cellValue ) ) );
144 130 }
145 131 }