Skip to content

Commit 4bc2e59

Browse files
Copilotlaeubi
authored andcommitted
Fix javadoc issues and warnings in grid widget package
1 parent e3d428b commit 4bc2e59

28 files changed

+295
-221
lines changed

widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/jface/gridviewer/GridTableViewer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public GridTableViewer(Composite parent) {
9898
* input, no content provider, a default label provider, no sorter, and no
9999
* filters.
100100
*
101-
* @param dataVisualizer
101+
* @param dataVisualizer the data visualizer for managing grid item data
102102
* @param parent
103103
* the parent control
104104
* @param style
@@ -115,7 +115,7 @@ public GridTableViewer(DataVisualizer dataVisualizer, Composite parent, int styl
115115
* has no input, no content provider, a default label provider, no sorter, and
116116
* no filters.
117117
*
118-
* @param dataVisualizer
118+
* @param dataVisualizer the data visualizer for managing grid item data
119119
* @param parent
120120
* the parent control
121121
*/
@@ -392,7 +392,7 @@ protected void doSelect(int[] indices) {
392392
* height. Therefore it is suggested that this method be called before rows are
393393
* populated (i.e. before setInput).
394394
*
395-
* @param autoPreferredHeight
395+
* @param autoPreferredHeight true to enable automatic preferred height, false otherwise
396396
*/
397397
public void setAutoPreferredHeight(boolean autoPreferredHeight) {
398398
this.autoPreferredHeight = autoPreferredHeight;
@@ -587,7 +587,7 @@ public int compare(Object arg0, Object arg1) {
587587
indiceLists.add(indiceList);
588588
objectList.add(grid.getItem(curLine).getData());
589589
}
590-
indiceList.add(new Integer(ps[i].x));
590+
indiceList.add(Integer.valueOf(ps[i].x));
591591
}
592592

593593
Object focusElement = null;

widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/jface/gridviewer/GridTreeViewer.java

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
public class GridTreeViewer extends AbstractTreeViewer {
5454

5555
/** This viewer's grid control. */
56-
private Grid grid;
56+
private final Grid grid;
5757

5858
private GridViewerRow cachedRow;
5959

@@ -118,23 +118,27 @@ public Grid getGrid() {
118118
}
119119

120120
/** {@inheritDoc} */
121+
@Override
121122
protected Item getItemAt(Point point) {
122123
return grid.getItem(point);
123124
}
124125

125126
/** {@inheritDoc} */
127+
@Override
126128
protected ColumnViewerEditor createViewerEditor() {
127129
return new GridViewerEditor(this,
128130
new ColumnViewerEditorActivationStrategy(this),
129131
ColumnViewerEditor.DEFAULT);
130132
}
131133

132134
/** {@inheritDoc} */
135+
@Override
133136
protected void addTreeListener(Control control, TreeListener listener) {
134137
((Grid) control).addTreeListener(listener);
135138
}
136139

137140
/** {@inheritDoc} */
141+
@Override
138142
protected Item[] getChildren(Widget o) {
139143
if (o instanceof GridItem) {
140144
return ((GridItem) o).getItems();
@@ -146,36 +150,43 @@ protected Item[] getChildren(Widget o) {
146150
}
147151

148152
/** {@inheritDoc} */
153+
@Override
149154
protected boolean getExpanded(Item item) {
150155
return ((GridItem) item).isExpanded();
151156
}
152157

153158
/** {@inheritDoc} */
159+
@Override
154160
protected int getItemCount(Control control) {
155161
return ((Grid) control).getItemCount();
156162
}
157163

158164
/** {@inheritDoc} */
165+
@Override
159166
protected int getItemCount(Item item) {
160167
return ((GridItem) item).getItemCount();
161168
}
162169

163170
/** {@inheritDoc} */
171+
@Override
164172
protected Item[] getItems(Item item) {
165173
return ((GridItem) item).getItems();
166174
}
167175

168176
/** {@inheritDoc} */
177+
@Override
169178
protected Item getParentItem(Item item) {
170179
return ((GridItem) item).getParentItem();
171180
}
172181

173182
/** {@inheritDoc} */
183+
@Override
174184
protected Item[] getSelection(Control control) {
175185
return ((Grid) control).getSelection();
176186
}
177187

178188
/** {@inheritDoc} */
189+
@Override
179190
protected Item newItem(Widget parent, int style, int index) {
180191
GridItem item;
181192

@@ -219,16 +230,21 @@ private ViewerRow createNewRowPart(ViewerRow parent, int style, int rowIndex) {
219230
}
220231

221232
/** {@inheritDoc} */
233+
@Override
234+
@SuppressWarnings("deprecation")
222235
protected void removeAll(Control control) {
223236
((Grid) control).removeAll();
224237
}
225238

226239
/** {@inheritDoc} */
240+
@Override
227241
protected void setExpanded(Item item, boolean expand) {
228242
((GridItem) item).setExpanded(expand);
229243
}
230244

231245
/** {@inheritDoc} */
246+
@Override
247+
@SuppressWarnings({ "rawtypes", "unchecked" })
232248
protected void setSelection(List items) {
233249
Item[] current = getSelection(getGrid());
234250

@@ -237,24 +253,26 @@ protected void setSelection(List items) {
237253
return;
238254
}
239255

240-
GridItem[] newItems = new GridItem[items.size()];
241-
items.toArray(newItems);
242-
getGrid().setSelection(newItems);
256+
GridItem[] itemArray = (GridItem[]) items.toArray(GridItem[]::new);
257+
getGrid().setSelection(itemArray);
243258
getGrid().showSelection();
244259
}
245260

246261
/** {@inheritDoc} */
262+
@Override
247263
protected void showItem(Item item) {
248264
getGrid().showItem((GridItem) item);
249265

250266
}
251267

252268
/** {@inheritDoc} */
269+
@Override
253270
public Control getControl() {
254271
return getGrid();
255272
}
256273

257274
/** {@inheritDoc} */
275+
@Override
258276
protected ViewerRow getViewerRowFromItem(Widget item) {
259277
if (cachedRow == null) {
260278
cachedRow = new GridViewerRow((GridItem) item);
@@ -266,15 +284,17 @@ protected ViewerRow getViewerRowFromItem(Widget item) {
266284
}
267285

268286
/** {@inheritDoc} */
287+
@Override
269288
protected Widget getColumnViewerOwner(int columnIndex) {
270289
if (columnIndex < 0
271290
|| (columnIndex > 0 && columnIndex >= getGrid()
272291
.getColumnCount())) {
273292
return null;
274293
}
275294

276-
if (getGrid().getColumnCount() == 0)// Hang it off the table if it
295+
if (getGrid().getColumnCount() == 0) { // Hang it off the table if it
277296
return getGrid();
297+
}
278298

279299
return getGrid().getColumn(columnIndex);
280300
}
@@ -284,6 +304,7 @@ protected Widget getColumnViewerOwner(int columnIndex) {
284304
*
285305
* @return the number of columns
286306
*/
307+
@Override
287308
protected int doGetColumnCount() {
288309
return grid.getColumnCount();
289310
}
@@ -307,6 +328,8 @@ protected int doGetColumnCount() {
307328
* When this method is called, existing rows are not resized to their
308329
* preferred height. Therefore it is suggested that this method be called
309330
* before rows are populated (i.e. before setInput).
331+
*
332+
* @param autoPreferredHeight true to enable automatic preferred height, false otherwise
310333
*/
311334
public void setAutoPreferredHeight(boolean autoPreferredHeight) {
312335
this.autoPreferredHeight = autoPreferredHeight;
@@ -322,11 +345,13 @@ public boolean getAutoPreferredHeight() {
322345
}
323346

324347
/** {@inheritDoc} */
348+
@Override
325349
protected void doUpdateItem(final Item item, Object element) {
326350
super.doUpdateItem(item, element);
327351
updateRowHeader(item);
328-
if(autoPreferredHeight && !item.isDisposed())
352+
if(autoPreferredHeight && !item.isDisposed()) {
329353
((GridItem)item).pack();
354+
}
330355
}
331356

332357
/**
@@ -336,12 +361,15 @@ protected void doUpdateItem(final Item item, Object element) {
336361
* @param index child index
337362
* @since 3.3
338363
*/
364+
@SuppressWarnings({ "rawtypes", "unchecked" })
339365
public void remove(final Object parentOrTreePath, final int index) {
340-
if (checkBusy())
366+
if (checkBusy()) {
341367
return;
368+
}
342369
final List oldSelection = new LinkedList(Arrays
343370
.asList(((TreeSelection) getSelection()).getPaths()));
344371
preservingSelection(new Runnable() {
372+
@Override
345373
public void run() {
346374
TreePath removedPath = null;
347375
if (internalIsInputOrEmptyPath(parentOrTreePath)) {
@@ -358,8 +386,9 @@ public void run() {
358386
Widget[] parentItems = internalFindItems(parentOrTreePath);
359387
for (int i = 0; i < parentItems.length; i++) {
360388
GridItem parentItem = (GridItem) parentItems[i];
361-
if (parentItem.isDisposed())
389+
if (parentItem.isDisposed()) {
362390
continue;
391+
}
363392
if (index < parentItem.getItemCount()) {
364393
GridItem item = parentItem.getItem(index);
365394
if (item.getData() != null) {
@@ -381,10 +410,11 @@ public void run() {
381410
}
382411
}
383412
if (removed) {
384-
setSelection(new TreeSelection(
385-
(TreePath[]) oldSelection
413+
TreePath[] paths = (TreePath[]) oldSelection
386414
.toArray(new TreePath[oldSelection
387-
.size()]), getComparer()),
415+
.size()]);
416+
setSelection(new TreeSelection(
417+
paths, getComparer()),
388418
false);
389419
}
390420

widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/jface/gridviewer/GridViewerColumn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void handleEvent(Event event)
183183
{
184184
GridItem item = (GridItem)event.item;
185185
Object element = item.getData();
186-
checkEditingSupport.setValue(element, new Boolean(item.getChecked(colIndex)));
186+
checkEditingSupport.setValue(element, Boolean.valueOf(item.getChecked(colIndex)));
187187
}
188188
}
189189
});

widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/jface/gridviewer/GridViewerEditor.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ protected void updateFocusCell(ViewerCell focusCell, ColumnViewerEditorActivatio
137137
}
138138

139139
/**
140-
* FIXME
141-
* @param viewer
142-
* @param editorActivationStrategy
143-
* @param feature
140+
* Creates a grid viewer editor for the given table viewer.
141+
*
142+
* @param viewer the grid table viewer
143+
* @param editorActivationStrategy the editor activation strategy
144+
* @param feature the feature flags for the editor
144145
*/
145146
public static void create(GridTableViewer viewer,
146147
ColumnViewerEditorActivationStrategy editorActivationStrategy,
@@ -149,10 +150,11 @@ public static void create(GridTableViewer viewer,
149150
}
150151

151152
/**
152-
* FIXME
153-
* @param viewer
154-
* @param editorActivationStrategy
155-
* @param feature
153+
* Creates a grid viewer editor for the given tree viewer.
154+
*
155+
* @param viewer the grid tree viewer
156+
* @param editorActivationStrategy the editor activation strategy
157+
* @param feature the feature flags for the editor
156158
*/
157159
public static void create(GridTreeViewer viewer,
158160
ColumnViewerEditorActivationStrategy editorActivationStrategy,

widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/jface/gridviewer/internal/CellSelection.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
import java.util.List;
55

66
import org.eclipse.jface.viewers.IElementComparer;
7-
import org.eclipse.jface.viewers.StructuredSelection;
87

98
/**
10-
* FIXME
9+
* A selection that includes both elements and their corresponding cell indices.
1110
*/
1211
public class CellSelection extends SelectionWithFocusRow {
12+
@SuppressWarnings("rawtypes")
1313
private List indicesList;
14+
@SuppressWarnings("rawtypes")
1415
private List elements;
1516

1617
/**
@@ -21,21 +22,28 @@ public class CellSelection extends SelectionWithFocusRow {
2122
*
2223
* @param elements
2324
* list of selected elements
25+
* @param indicesList
26+
* list of indices for each element
27+
* @param focusElement
28+
* the element that has focus
2429
* @param comparer
2530
* the comparer, or null
2631
* @since 3.4
2732
*/
33+
@SuppressWarnings({ "rawtypes", "unchecked" })
2834
public CellSelection(List elements, List indicesList, Object focusElement, IElementComparer comparer) {
2935
super(elements,focusElement,comparer);
3036
this.elements = new ArrayList(elements);
3137
this.indicesList = indicesList;
3238
}
3339

3440
/**
35-
* FIXME
36-
* @param element
41+
* Returns the list of indices for the given element.
42+
*
43+
* @param element the element to get indices for
3744
* @return the indices
3845
*/
46+
@SuppressWarnings("rawtypes")
3947
public List getIndices(Object element) {
4048
return (List) indicesList.get(elements.indexOf(element));
4149
}

widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/jface/gridviewer/internal/SelectionWithFocusRow.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
* FIXME
1010
*/
1111
public class SelectionWithFocusRow extends StructuredSelection {
12-
private Object focusElement;
12+
private final Object focusElement;
1313

1414
/**
15-
* FIXME
16-
* @param elements
17-
* @param focusElement
18-
* @param comparer
15+
* Creates a new selection with focus row.
16+
*
17+
* @param elements the list of selected elements
18+
* @param focusElement the element that has focus
19+
* @param comparer the element comparer
1920
*/
21+
@SuppressWarnings("rawtypes")
2022
public SelectionWithFocusRow(List elements, Object focusElement, IElementComparer comparer) {
2123
super(elements,comparer);
2224
this.focusElement = focusElement;

0 commit comments

Comments
 (0)