diff --git a/widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/GridColumn.java b/widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/GridColumn.java index 868128312..7ce76c1a0 100644 --- a/widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/GridColumn.java +++ b/widgets/grid/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/GridColumn.java @@ -5,7 +5,7 @@ * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -102,7 +102,7 @@ public class GridColumn extends Item { private int headerHeight = NOT_CALCULATED_YET; - int getFooterHeight(GC gc) + int getFooterHeight(final GC gc) { if(footerHeight == NOT_CALCULATED_YET) { footerHeight = getFooterRenderer().computeSize(gc, getWidth(), SWT.DEFAULT, this).y; @@ -110,7 +110,7 @@ int getFooterHeight(GC gc) return footerHeight; } - int getHeaderHeight(GC gc) + int getHeaderHeight(final GC gc) { if(headerHeight == NOT_CALCULATED_YET) { headerHeight = getHeaderRenderer().computeSize(gc, getWidth(), SWT.DEFAULT, this).y; @@ -213,7 +213,7 @@ int getHeaderHeight(GC gc) * subclass * */ - public GridColumn(Grid parent, int style) { + public GridColumn(final Grid parent, final int style) { this(parent, style, -1); } @@ -242,7 +242,7 @@ public GridColumn(Grid parent, int style) { * subclass * */ - public GridColumn(Grid parent, int style, int index) { + public GridColumn(final Grid parent, final int style, final int index) { super(parent, style, index); init(parent, style, index); @@ -272,7 +272,7 @@ public GridColumn(Grid parent, int style, int index) { * subclass * */ - public GridColumn(GridColumnGroup parent, int style) { + public GridColumn(final GridColumnGroup parent, final int style) { super(parent.getParent(), style, parent.getNewColumnIndex()); init(parent.getParent(), style, parent.getNewColumnIndex()); @@ -282,8 +282,8 @@ public GridColumn(GridColumnGroup parent, int style) { group.newColumn(this, -1); } - private void init(Grid table, int style, int index) { - this.parent = table; + private void init(final Grid table, final int style, final int index) { + parent = table; table.newColumn(this, index); @@ -303,25 +303,26 @@ private void init(Grid table, int style, int index) { public void dispose() { if (!parent.isDisposing()) { parent.removeColumn(this); - if (group != null) + if (group != null) { group.removeColumn(this); + } - if (controlEditor != null ) { - controlEditor.dispose(); - } + if (controlEditor != null ) { + controlEditor.dispose(); + } } - if(cellRenderer != null) - { - cellRenderer.setDisplay(null); - cellRenderer = null; - } + if(cellRenderer != null) + { + cellRenderer.setDisplay(null); + cellRenderer = null; + } - if(headerRenderer != null) - { - headerRenderer.setDisplay(null); - headerRenderer = null; - } + if(headerRenderer != null) + { + headerRenderer.setDisplay(null); + headerRenderer = null; + } super.dispose(); } @@ -409,12 +410,12 @@ public int getWidth() { * thread that created the receiver * */ - public void setWidth(int width) { + public void setWidth(final int width) { checkWidget(); setWidth(width, true); } - void setWidth(int width, boolean redraw) { + void setWidth(final int width, final boolean redraw) { int widthToSet = Math.max(minimumWidth, width); if (parent.getColumnScrolling()) { /* @@ -422,7 +423,7 @@ void setWidth(int width, boolean redraw) { * can't scroll all to the right */ int availableVisibleWidthForColumns = parent.getClientArea().width; - if (IS_MAC && availableVisibleWidthForColumns == 1 && parent.getClientArea().height == 1) { + if (IS_MAC && availableVisibleWidthForColumns == 1 && parent.getClientArea().height <= 1) { // One sets column width before the grid size has been layouted availableVisibleWidthForColumns = width; } @@ -458,7 +459,7 @@ void setWidth(int width, boolean redraw) { * thread that created the receiver * */ - public void setSort(int style) { + public void setSort(final int style) { checkWidget(); sortStyle = style; parent.redraw(); @@ -500,12 +501,12 @@ public int getSort() { * thread that created the receiver * */ - public void addSelectionListener(SelectionListener listener) { + public void addSelectionListener(final SelectionListener listener) { checkWidget(); if (listener == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } - this.addListener(SWT.Selection, new TypedListener(listener)); + addListener(SWT.Selection, new TypedListener(listener)); } /** @@ -524,7 +525,7 @@ public void addSelectionListener(SelectionListener listener) { * thread that created the receiver * */ - public void removeSelectionListener(SelectionListener listener) { + public void removeSelectionListener(final SelectionListener listener) { checkWidget(); this.removeListener(SWT.Selection, listener); } @@ -533,12 +534,12 @@ public void removeSelectionListener(SelectionListener listener) { * Fires selection listeners. */ void fireListeners() { - Event e = new Event(); - e.display = this.getDisplay(); + final Event e = new Event(); + e.display = getDisplay(); e.item = this; e.widget = parent; - this.notifyListeners(SWT.Selection, e); + notifyListeners(SWT.Selection, e); } /** @@ -559,8 +560,8 @@ void fireListeners() { public boolean isVisible() { checkWidget(); if (group != null) { - if ((group.getExpanded() && !isDetail()) - || (!group.getExpanded() && !isSummary())) { + if (group.getExpanded() && !isDetail() + || !group.getExpanded() && !isSummary()) { return false; } } @@ -597,10 +598,10 @@ public boolean getVisible() { * thread that created the receiver * */ - public void setVisible(boolean visible) { + public void setVisible(final boolean visible) { checkWidget(); - boolean before = isVisible(); + final boolean before = isVisible(); this.visible = visible; @@ -615,23 +616,23 @@ public void setVisible(boolean visible) { * Move focus to the next visible column on the right * (or left if it is not possible) */ - if (parent.getFocusColumn() == this) { - GridItem focusItem = parent.getFocusItem(); + if (parent.getFocusColumn() == this) { + final GridItem focusItem = parent.getFocusItem(); if (focusItem != null) { GridColumn column = parent.getVisibleColumn_DegradeRight(focusItem, this); - if (column != null) + if (column != null) { parent.setFocusColumn(column); - else { + } else { column = parent.getVisibleColumn_DegradeLeft(focusItem, this); - if (column != null) + if (column != null) { parent.setFocusColumn(column); + } } } } - GridColumn[] colsOrdered = parent.getColumnsInOrder(); - for (int i = 0; i < colsOrdered.length; i++) { - GridColumn column = colsOrdered[i]; + final GridColumn[] colsOrdered = parent.getColumnsInOrder(); + for (final GridColumn column : colsOrdered) { if (column != this && column.isVisible()) { column.fireMoved(); } @@ -655,7 +656,7 @@ public void setVisible(boolean visible) { public void pack() { checkWidget(); - GC gc = new GC(parent); + final GC gc = new GC(parent); int newWidth = getHeaderRenderer().computeSize(gc, SWT.DEFAULT, SWT.DEFAULT, this).x; @@ -667,7 +668,7 @@ public void pack() { { for (int i = topIndex; i < bottomIndex; i++) { - GridItem item = parent.getItem(i); + final GridItem item = parent.getItem(i); if (item.isVisible()) { newWidth = Math.max(newWidth, getCellRenderer().computeSize(gc, SWT.DEFAULT, SWT.DEFAULT, item).x); @@ -684,7 +685,7 @@ public void pack() { { for (int i = 0; i < parent.getItemCount(); i++) { - GridItem item = parent.getItem(i); + final GridItem item = parent.getItem(i); if (item.isVisible()) { newWidth = Math.max(newWidth, getCellRenderer().computeSize(gc, SWT.DEFAULT, SWT.DEFAULT, item).x); @@ -749,7 +750,7 @@ public boolean isCheck() { * thread that created the receiver * */ - public void setCellRenderer(GridCellRenderer cellRenderer) { + public void setCellRenderer(final GridCellRenderer cellRenderer) { checkWidget(); this.cellRenderer = cellRenderer; @@ -769,7 +770,7 @@ public void setCellRenderer(GridCellRenderer cellRenderer) { * thread that created the receiver * */ - public void setHeaderRenderer(GridHeaderRenderer headerRenderer) { + public void setHeaderRenderer(final GridHeaderRenderer headerRenderer) { checkWidget(); this.headerRenderer = headerRenderer; initHeaderRenderer(); @@ -788,7 +789,7 @@ public void setHeaderRenderer(GridHeaderRenderer headerRenderer) { * thread that created the receiver * */ - public void setFooterRenderer(GridFooterRenderer footerRenderer) { + public void setFooterRenderer(final GridFooterRenderer footerRenderer) { checkWidget(); this.footerRenderer = footerRenderer; initFooterRenderer(); @@ -812,12 +813,12 @@ public void setFooterRenderer(GridFooterRenderer footerRenderer) { * thread that created the receiver * */ - public void addControlListener(ControlListener listener) { + public void addControlListener(final ControlListener listener) { checkWidget(); if (listener == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } - TypedListener typedListener = new TypedListener(listener); + final TypedListener typedListener = new TypedListener(listener); addListener(SWT.Resize, typedListener); addListener(SWT.Move, typedListener); } @@ -839,7 +840,7 @@ public void addControlListener(ControlListener listener) { * thread that created the receiver * */ - public void removeControlListener(ControlListener listener) { + public void removeControlListener(final ControlListener listener) { checkWidget(); if (listener == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); @@ -852,24 +853,24 @@ public void removeControlListener(ControlListener listener) { * Fires moved event. */ void fireMoved() { - Event e = new Event(); - e.display = this.getDisplay(); + final Event e = new Event(); + e.display = getDisplay(); e.item = this; e.widget = parent; - this.notifyListeners(SWT.Move, e); + notifyListeners(SWT.Move, e); } /** * Fires resized event. */ void fireResized() { - Event e = new Event(); - e.display = this.getDisplay(); + final Event e = new Event(); + e.display = getDisplay(); e.item = this; e.widget = parent; - this.notifyListeners(SWT.Resize, e); + notifyListeners(SWT.Resize, e); } /** @@ -885,7 +886,7 @@ void fireResized() { * thread that created the receiver * */ - public void setTree(boolean tree) { + public void setTree(final boolean tree) { checkWidget(); this.tree = tree; @@ -923,7 +924,7 @@ public int getAlignment() { * thread that created the receiver * */ - public void setAlignment(int alignment) { + public void setAlignment(final int alignment) { checkWidget(); cellRenderer.setAlignment(alignment); } @@ -940,26 +941,26 @@ public void setAlignment(int alignment) { * thread that created the receiver * */ - public int getVerticalAlignment() { - checkWidget(); - return cellRenderer.getVerticalAlignment(); - } - - /** - * Sets the column's vertical text alignment. - * - * @param alignment SWT.TOP (default), SWT.CENTER, SWT.BOTTOM - * @throws org.eclipse.swt.SWTException - *