Bug 565581 - Fix issues reported by Sonar
Change-Id: Ibf16ca8f132372d5a87b64da238d601f8835442f
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooserUtilsTest.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooserUtilsTest.java
index b934460..edb0868 100644
--- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooserUtilsTest.java
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooserUtilsTest.java
@@ -16,6 +16,7 @@
import static org.eclipse.nebula.widgets.nattable.test.fixture.layer.ColumnHeaderLayerFixture.getDataLayer;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
@@ -41,31 +42,34 @@
}
@Test
- public void find() throws Exception {
+ public void find() {
ColumnEntry found = ColumnChooserUtils.find(this.entriesFixture, 5);
assertEquals("Index5", found.getLabel());
+
+ found = ColumnChooserUtils.find(this.entriesFixture, 42);
+ assertNull(found);
}
@Test
- public void getPositionsFromEntries() throws Exception {
+ public void getPositionsFromEntries() {
List<Integer> positions = ColumnChooserUtils.getColumnEntryPositions(this.entriesFixture);
assertEquals("[2, 6, 3, 4, 5]", positions.toString());
}
@Test
- public void getIndexesFromEntries() throws Exception {
+ public void getIndexesFromEntries() {
List<Integer> indexes = ColumnChooserUtils.getColumnEntryIndexes(this.entriesFixture);
assertEquals("[1, 3, 5, 7, 9]", indexes.toString());
}
@Test
- public void listContainsEntry() throws Exception {
+ public void listContainsEntry() {
assertTrue(ColumnChooserUtils.containsIndex(this.entriesFixture, 9));
assertFalse(ColumnChooserUtils.containsIndex(this.entriesFixture, -9));
}
@Test
- public void shouldProvideRenamedLabelsIfTheColumnHasBeenRenamed() throws Exception {
+ public void shouldProvideRenamedLabelsIfTheColumnHasBeenRenamed() {
ColumnHeaderLayerFixture columnHeaderLayer = new ColumnHeaderLayerFixture();
assertEquals("[1, 0]", getColumnLabel(columnHeaderLayer, getDataLayer(), 1));
@@ -74,7 +78,7 @@
}
@Test
- public void getVisibleColumnEntries() throws Exception {
+ public void getVisibleColumnEntries() {
DefaultGridLayer gridLayer = new DefaultGridLayer(
RowDataListFixture.getList(),
RowDataListFixture.getPropertyNames(),
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/datachange/DataChangeLayerIdIndexTest.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/datachange/DataChangeLayerIdIndexTest.java
index db37593..195b727 100644
--- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/datachange/DataChangeLayerIdIndexTest.java
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/datachange/DataChangeLayerIdIndexTest.java
@@ -19,7 +19,6 @@
import java.io.Serializable;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.List;
@@ -572,13 +571,7 @@
assertEquals("Zoolander", this.dataLayer.getDataValue(1, 2));
// sort
- Collections.sort(this.dataModel, new Comparator<Person>() {
-
- @Override
- public int compare(Person o1, Person o2) {
- return o1.getLastName().compareTo(o2.getLastName());
- }
- });
+ Collections.sort(this.dataModel, (o1, o2) -> o1.getLastName().compareTo(o2.getLastName()));
// fire event to trigger update of cached row indexes
this.dataLayer.fireLayerEvent(new RowStructuralRefreshEvent(this.dataLayer));
@@ -617,7 +610,6 @@
}
@Test
- @SuppressWarnings("java:S2259")
public void shouldUpdateChangeOnSortAndSaveWithTemp() {
// enable temp data storage to test update on save
this.dataChangeLayer = new DataChangeLayer(this.dataLayer,
@@ -652,13 +644,7 @@
// NOTE: this is because we are storing the data temporary and therefore
// sorting for lastname would not respect the shown data.
this.dataLayer.setDataValueByPosition(0, 2, "Yosefine");
- Collections.sort(this.dataModel, new Comparator<Person>() {
-
- @Override
- public int compare(Person o1, Person o2) {
- return o1.getFirstName().compareTo(o2.getFirstName());
- }
- });
+ Collections.sort(this.dataModel, (o1, o2) -> o1.getFirstName().compareTo(o2.getFirstName()));
// fire event to trigger update of cached row indexes
this.dataLayer.fireLayerEvent(new RowStructuralRefreshEvent(this.dataLayer));
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/grid/GridLayerTest.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/grid/GridLayerTest.java
index 874b06b..d2d3ca5 100644
--- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/grid/GridLayerTest.java
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/grid/GridLayerTest.java
@@ -27,7 +27,6 @@
import org.eclipse.nebula.widgets.nattable.test.fixture.command.LayerCommandFixture;
import org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture;
import org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture;
-import org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture;
import org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider;
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
import org.eclipse.swt.graphics.Rectangle;
@@ -55,7 +54,7 @@
}
@Test
- public void getLayers() throws Exception {
+ public void getLayers() {
assertNotNull(this.gridLayerUnderTest.getBodyLayer());
assertNotNull(this.gridLayerUnderTest.getColumnHeaderLayer());
assertNotNull(this.gridLayerUnderTest.getRowHeaderLayer());
@@ -63,7 +62,7 @@
}
@Test
- public void doCommandInvokesBodyFirst() throws Exception {
+ public void doCommandInvokesBodyFirst() {
DummyCommandHandler bodyCommandHandler = new DummyCommandHandler(true);
DummyCommandHandler columnHeaderCommandHandler = new DummyCommandHandler(true);
DummyCommandHandler rowHeaderCommandHandler = new DummyCommandHandler(true);
@@ -85,7 +84,7 @@
}
@Test
- public void doCommandInvokesOtherLayers() throws Exception {
+ public void doCommandInvokesOtherLayers() {
DummyCommandHandler bodyCommandHandler = new DummyCommandHandler(false);
DummyCommandHandler columnHeaderCommandHandler = new DummyCommandHandler(false);
DummyCommandHandler rowHeaderCommandHandler = new DummyCommandHandler(false);
@@ -108,11 +107,8 @@
// **** New tests using fixtures ****
- /**
- * @see ViewportLayerFixture#DEFAULT_CLIENT_AREA
- */
@Test
- public void initBodyLayer() throws Exception {
+ public void initBodyLayer() {
DefaultGridLayer gridLayer = new GridLayerFixture();
ViewportLayer viewport = gridLayer.getBodyLayer().getViewportLayer();
@@ -134,7 +130,7 @@
}
@Test
- public void initRowHeaderHeight() throws Exception {
+ public void initRowHeaderHeight() {
GridLayer gridLayer = new GridLayerFixture();
gridLayer.doCommand(new InitializeClientAreaCommandFixture());
@@ -145,7 +141,7 @@
}
@Test
- public void initCorner() throws Exception {
+ public void initCorner() {
GridLayer gridLayer = new GridLayerFixture();
ILayer colHeader = gridLayer.getCornerLayer();
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupExpandCollapseLayerTest.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupExpandCollapseLayerTest.java
index 09d7467..418b255 100644
--- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupExpandCollapseLayerTest.java
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupExpandCollapseLayerTest.java
@@ -85,11 +85,11 @@
// assertFalse(expandCollapseLayer.isFirstVisibleColumnInGroup(2));
assertTrue(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(3,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(4,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(5,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
}
/*
@@ -102,13 +102,13 @@
this.underlyingLayer.hideColumnPositions(Arrays.asList(2, 3));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(2,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(3,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertTrue(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(4,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(5,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
}
/*
@@ -121,13 +121,13 @@
this.underlyingLayer.hideColumnPositions(Arrays.asList(2, 3, 4, 5));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(2,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(3,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(4,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(5,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
}
@Test
@@ -146,11 +146,11 @@
this.underlyingLayer.hideColumnPositions(Arrays.asList(2));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(0,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertTrue(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(2,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(3,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
}
/*
@@ -163,13 +163,13 @@
this.underlyingLayer.hideColumnPositions(Arrays.asList(2, 3));
assertFalse(ColumnGroupUtils.isLastVisibleColumnIndexInGroup(2,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isLastVisibleColumnIndexInGroup(3,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertFalse(ColumnGroupUtils.isLastVisibleColumnIndexInGroup(4,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
assertTrue(ColumnGroupUtils.isLastVisibleColumnIndexInGroup(5,
- this.expandCollapseLayer, this.underlyingLayer, this.model));
+ this.underlyingLayer, this.model));
}
@Test
@@ -177,7 +177,7 @@
collapse(2);
List<Integer> indexes = ColumnGroupUtils.getVisibleIndexesToTheRight(2,
- this.expandCollapseLayer, this.underlyingLayer, this.model);
+ this.underlyingLayer, this.model);
assertEquals(0, indexes.size());
}
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/RowGroupExpandCollapseLayerTest.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/RowGroupExpandCollapseLayerTest.java
new file mode 100644
index 0000000..e2ec562
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/group/RowGroupExpandCollapseLayerTest.java
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * Copyright (c) 2018, 2020 Dirk Fauth.
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.group;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.nebula.widgets.nattable.data.IRowDataProvider;
+import org.eclipse.nebula.widgets.nattable.dataset.person.Person;
+import org.eclipse.nebula.widgets.nattable.dataset.person.PersonService;
+import org.eclipse.nebula.widgets.nattable.grid.data.DefaultBodyDataProvider;
+import org.eclipse.nebula.widgets.nattable.group.model.IRowGroup;
+import org.eclipse.nebula.widgets.nattable.group.model.RowGroup;
+import org.eclipse.nebula.widgets.nattable.group.model.RowGroupModel;
+import org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer;
+import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RowGroupExpandCollapseLayerTest {
+
+ private RowGroupModel<Person> model;
+ private RowHideShowLayer rowHideShowLayer;
+ private RowGroupExpandCollapseLayer<Person> expandCollapseLayer;
+
+ @Before
+ public void setup() {
+ String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
+ IRowDataProvider<Person> bodyDataProvider =
+ new DefaultBodyDataProvider<>(PersonService.getFixedPersons(), propertyNames);
+ DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
+
+ this.rowHideShowLayer = new RowHideShowLayer(bodyDataLayer);
+ this.model = new RowGroupModel<>();
+ this.model.setDataProvider(bodyDataProvider);
+ this.expandCollapseLayer = new RowGroupExpandCollapseLayer<>(this.rowHideShowLayer, this.model);
+
+ // Create a group of rows for the model.
+ RowGroup<Person> rowGroup = new RowGroup<>(this.model, "Simpson", false);
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(0));
+ rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(1));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(2));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(3));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(4));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(5));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(6));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(7));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(8));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(9));
+ this.model.addRowGroup(rowGroup);
+
+ rowGroup = new RowGroup<>(this.model, "Flanders", false);
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(10));
+ rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(11));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(12));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(13));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(14));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(15));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(16));
+ rowGroup.addMemberRow(bodyDataProvider.getRowObject(17));
+ this.model.addRowGroup(rowGroup);
+ }
+
+ @Test
+ public void getRowCountWhenColumnsAddedToTheGroup() throws Exception {
+ assertEquals(18, this.expandCollapseLayer.getRowCount());
+
+ // get Flanders row group
+ IRowGroup<Person> group = this.model.getRowGroupForName("Flanders");
+
+ // Collapse and check count
+ group.collapse();
+ assertEquals(11, this.expandCollapseLayer.getRowCount());
+
+ // Expand and check count
+ group.expand();
+
+ // Collapse again
+ assertEquals(18, this.expandCollapseLayer.getRowCount());
+ }
+ //
+ // @Test
+ // public void getRowCountWhenColumnsAddedToTheGroup() throws Exception {
+ // assertEquals(18, this.expandCollapseLayer.getRowCount());
+ //
+ // // get Flanders row group
+ // IRowGroup<Person> group = this.model.getRowGroupForName("Flanders");
+ //
+ // // Collapse and check count
+ // group.collapse();
+ // assertEquals(11, this.expandCollapseLayer.getRowCount());
+ //
+ // // Expand and add a column
+ // expand(3);
+ // this.model.addColumnsIndexesToGroup(TEST_GROUP_NAME, 8);
+ //
+ // // Collapse again
+ // collapse(3);
+ // assertEquals(5, this.expandCollapseLayer.getColumnCount());
+ // }
+
+ // @Test
+ // public void getColumnCountWhenColumnsCollapsedAndHidden() throws
+ // Exception {
+ // // Columns 2 and 3 hidden
+ // this.underlyingLayer.hideColumnPositions(Arrays.asList(2, 3));
+ // assertEquals(7, this.expandCollapseLayer.getColumnCount());
+ //
+ // collapse(3);
+ // assertEquals(6, this.expandCollapseLayer.getColumnCount());
+ //
+ // expand(3);
+ // assertEquals(7, this.expandCollapseLayer.getColumnCount());
+ // }
+ //
+ // /*
+ // * Hide show layer 0 1 2(h) 3 4 5 6 7 8 9(h)
+ // * ------------------------------------------------- Expand/Collapse
+ // |<-----
+ // * CG1 ----->|
+ // */
+ // @Test
+ // public void isFirstVisibleWithFirstColumnHidden() throws Exception {
+ // this.underlyingLayer.hideColumnPositions(Arrays.asList(2));
+ //
+ // // assertFalse(expandCollapseLayer.isFirstVisibleColumnInGroup(2));
+ // assertTrue(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(3,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(4,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(5,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // }
+ //
+ // /*
+ // * Hide show layer 0 1 2(h) 3(h) 4 5 6 7 8 9(h)
+ // * ------------------------------------------------- Expand/Collapse
+ // * |<------ CG1 ------->|
+ // */
+ // @Test
+ // public void isFirstVisibleWithFirstTwoColumnsHidden() throws Exception {
+ // this.underlyingLayer.hideColumnPositions(Arrays.asList(2, 3));
+ //
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(2,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(3,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertTrue(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(4,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(5,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // }
+ //
+ // /*
+ // * Hide show layer 0 1 2(h) 3(h) 4(h) 5(h) 6 7 8 9(h)
+ // * ------------------------------------------------- Expand/Collapse
+ // * |<--------- CG1 ------->|
+ // */
+ // @Test
+ // public void isFirstVisibleWithAllColumnsHidden() throws Exception {
+ // this.underlyingLayer.hideColumnPositions(Arrays.asList(2, 3, 4, 5));
+ //
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(2,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(3,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(4,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(5,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // }
+ //
+ // @Test
+ // public void isFirstVisibleWithColumnsReordered() throws Exception {
+ // // Original indexes : 0 1 2 3 4
+ // // Indexes reordered : 4 1 0 2 3
+ // ColumnReorderLayer reorderLayer = new ColumnReorderLayerFixture();
+ // this.underlyingLayer = new ColumnHideShowLayerFixture(reorderLayer);
+ // this.expandCollapseLayer = new ColumnGroupExpandCollapseLayer(
+ // this.underlyingLayer, this.model);
+ //
+ // this.model.clear();
+ // this.model.addColumnsIndexesToGroup(TEST_GROUP_NAME, 0, 2, 3);
+ //
+ // // Hide index 0
+ // this.underlyingLayer.hideColumnPositions(Arrays.asList(2));
+ //
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(0,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertTrue(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(2,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(3,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // }
+ //
+ // /*
+ // * Hide show layer 0 1 2(h) 3(h) 4 5 6 7 8 9(h)
+ // * ------------------------------------------------- Expand/Collapse
+ // * |<------- CG1 ----->|
+ // */
+ // @Test
+ // public void isLastVisibleColumnIndexInGroup() throws Exception {
+ // this.underlyingLayer.hideColumnPositions(Arrays.asList(2, 3));
+ //
+ // assertFalse(ColumnGroupUtils.isLastVisibleColumnIndexInGroup(2,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isLastVisibleColumnIndexInGroup(3,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertFalse(ColumnGroupUtils.isLastVisibleColumnIndexInGroup(4,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // assertTrue(ColumnGroupUtils.isLastVisibleColumnIndexInGroup(5,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model));
+ // }
+ //
+ // @Test
+ // public void getVisibleColumnIndexesToTheRight() throws Exception {
+ // collapse(2);
+ //
+ // List<Integer> indexes = ColumnGroupUtils.getVisibleIndexesToTheRight(2,
+ // this.expandCollapseLayer, this.underlyingLayer, this.model);
+ // assertEquals(0, indexes.size());
+ // }
+ //
+ // /*
+ // * Hide show layer 0 1 2 3 4 5 6 7 8 9(h)
+ // * -------------------------------------- Expand/Collapse |<--- CG1 -->|
+ // */
+ // @Test
+ // public void getColumnIndexByPosition() throws Exception {
+ // assertEquals(2, this.expandCollapseLayer.getColumnIndexByPosition(2));
+ // assertEquals(3, this.expandCollapseLayer.getColumnIndexByPosition(3));
+ // assertEquals(4, this.expandCollapseLayer.getColumnIndexByPosition(4));
+ // assertEquals(5, this.expandCollapseLayer.getColumnIndexByPosition(5));
+ // assertEquals(9, this.expandCollapseLayer.getColumnCount());
+ //
+ // collapse(3);
+ //
+ // assertEquals(6, this.expandCollapseLayer.getColumnCount());
+ //
+ // assertEquals(2, this.expandCollapseLayer.getColumnIndexByPosition(2));
+ // assertEquals(6, this.expandCollapseLayer.getColumnIndexByPosition(3));
+ // assertEquals(7, this.expandCollapseLayer.getColumnIndexByPosition(4));
+ // assertEquals(8, this.expandCollapseLayer.getColumnIndexByPosition(5));
+ //
+ // assertEquals("[2, 0]", this.expandCollapseLayer.getDataValueByPosition(2,
+ // 0));
+ // assertEquals("[6, 0]", this.expandCollapseLayer.getDataValueByPosition(3,
+ // 0));
+ // assertEquals("[7, 0]", this.expandCollapseLayer.getDataValueByPosition(4,
+ // 0));
+ // assertEquals("[8, 0]", this.expandCollapseLayer.getDataValueByPosition(5,
+ // 0));
+ // }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/test/fixture/layer/ViewportLayerFixture.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/test/fixture/layer/ViewportLayerFixture.java
index 2c743b0..0eeec93 100644
--- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/test/fixture/layer/ViewportLayerFixture.java
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/test/fixture/layer/ViewportLayerFixture.java
@@ -32,9 +32,6 @@
public static final IClientAreaProvider DEFAULT_CLIENT_AREA_PROVIDER = getClientAreaProvider(DEFAULT_CLIENT_AREA);
public static final Scrollable DEFAULT_SCROLLABLE = scrollable();
- /**
- * Default Xtor
- */
public ViewportLayerFixture() {
super(new DataLayerFixture());
setClientAreaProvider(getClientAreaProvider(DEFAULT_CLIENT_AREA));
@@ -47,21 +44,10 @@
doCommand(new InitializeClientAreaCommandFixture());
}
- /**
- * Xtor Fixture with all columns equal width and all rows equal height.
- */
public ViewportLayerFixture(int width, int height) {
super(new DataLayerFixture(width, height));
}
- /**
- * Xtor Fixture with all columns equal width and all rows equal height.
- *
- * @param colCount
- * total number of columns
- * @param rowCount
- * total number of rows
- */
public ViewportLayerFixture(int colCount, int rowCount,
int defaultColWidth, int defaultRowHeight) {
super(new DataLayerFixture(colCount, rowCount, defaultColWidth,
@@ -69,9 +55,6 @@
setClientAreaProvider(DEFAULT_CLIENT_AREA_PROVIDER);
}
- /**
- * Xtor Provide your own <i>clientArea</i>
- */
public ViewportLayerFixture(final Rectangle clientArea) {
super(new DataLayerFixture());
setClientAreaProvider(getClientAreaProvider(clientArea));
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/test/integration/SWTUtils.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/test/integration/SWTUtils.java
index 5785dc9..a06d251 100644
--- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/test/integration/SWTUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/test/integration/SWTUtils.java
@@ -106,6 +106,8 @@
/**
* Some of the tests do not run on Unix, due to issues with Xvfb. This check
* helps skipping those tests.
+ *
+ * @return true if we are running on a Unix system.
*/
public static boolean isRunningOnUnix() {
return System.getProperty("os.name").equals("Linux");
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/Messages.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/Messages.java
index 073c6f2..c6db910 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/Messages.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/Messages.java
@@ -24,7 +24,7 @@
public class Messages {
private static final String BUNDLE_NAME = "org.eclipse.nebula.widgets.nattable.messages"; //$NON-NLS-1$
- private static ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+ private static ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
private Messages() {
}
@@ -40,7 +40,7 @@
*/
public static String getString(String key) {
try {
- return RESOURCE_BUNDLE.getString(key);
+ return resourceBundle.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
@@ -59,7 +59,7 @@
* {@link Locale} with replaced placeholders.
*/
public static String getString(String key, Object... args) {
- return MessageFormat.format(RESOURCE_BUNDLE.getString(key), args);
+ return MessageFormat.format(resourceBundle.getString(key), args);
}
/**
@@ -95,7 +95,7 @@
* @since 1.4
*/
public static void changeLocale(Locale locale) {
- RESOURCE_BUNDLE = ResourceBundle.getBundle(
+ resourceBundle = ResourceBundle.getBundle(
BUNDLE_NAME,
locale,
ResourceBundle.Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/BlinkConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/BlinkConfigAttributes.java
index 5a42f6d..06dd955 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/BlinkConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/BlinkConfigAttributes.java
@@ -14,8 +14,12 @@
import org.eclipse.nebula.widgets.nattable.style.ConfigAttribute;
-public class BlinkConfigAttributes {
+public final class BlinkConfigAttributes {
- public static final ConfigAttribute<IBlinkingCellResolver> BLINK_RESOLVER = new ConfigAttribute<IBlinkingCellResolver>();
+ private BlinkConfigAttributes() {
+ // private default constructor for constants class
+ }
+
+ public static final ConfigAttribute<IBlinkingCellResolver> BLINK_RESOLVER = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/BlinkLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/BlinkLayer.java
index 87033c1..c003dde 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/BlinkLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/BlinkLayer.java
@@ -70,10 +70,10 @@
private int blinkDurationInMilis = 1000;
/** Track the updates which are currently blinking */
- Map<String, PropertyUpdateEvent<T>> blinkingUpdates = new HashMap<String, PropertyUpdateEvent<T>>();
+ Map<String, PropertyUpdateEvent<T>> blinkingUpdates = new HashMap<>();
/** Track the blinking tasks which are currently running */
- Map<String, ScheduledFuture<?>> blinkingTasks = new HashMap<String, ScheduledFuture<?>>();
+ Map<String, ScheduledFuture<?>> blinkingTasks = new HashMap<>();
public BlinkLayer(IUniqueIndexLayer dataLayer,
IRowDataProvider<T> listDataProvider,
@@ -108,7 +108,7 @@
this.columnPropertyResolver = columnPropertyResolver;
this.configRegistry = configRegistry;
this.scheduler = scheduler;
- this.updateEventsCache = new UpdateEventsCache<T>(rowIdAccessor,
+ this.updateEventsCache = new UpdateEventsCache<>(rowIdAccessor,
triggerBlinkOnRowUpdate ? new RowKeyStrategyImpl()
: new CellKeyStrategyImpl(),
scheduler);
@@ -243,10 +243,8 @@
@SuppressWarnings("unchecked")
@Override
public void handleLayerEvent(ILayerEvent event) {
- if (this.blinkingEnabled) {
- if (event instanceof PropertyUpdateEvent) {
- this.updateEventsCache.put((PropertyUpdateEvent<T>) event);
- }
+ if (this.blinkingEnabled && event instanceof PropertyUpdateEvent) {
+ this.updateEventsCache.put((PropertyUpdateEvent<T>) event);
}
super.handleLayerEvent(event);
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/UpdateEventsCache.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/UpdateEventsCache.java
index b400ec0..98bca7f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/UpdateEventsCache.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/blink/UpdateEventsCache.java
@@ -51,7 +51,7 @@
this.rowIdAccessor = rowIdAccessor;
this.keyStrategy = keyStrategy;
this.cleanupScheduler = cleanupScheduler;
- this.updateEvents = new HashMap<String, TimeStampedEvent>();
+ this.updateEvents = new HashMap<>();
}
/**
@@ -60,7 +60,7 @@
*/
private Runnable getStaleUpdatesCleanupTask() {
return () -> {
- Map<String, TimeStampedEvent> recentEvents = new HashMap<String, TimeStampedEvent>();
+ Map<String, TimeStampedEvent> recentEvents = new HashMap<>();
Date recent = new Date(System.currentTimeMillis()
- TIME_TO_LIVE);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/ChooseColumnsFromCategoriesCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/ChooseColumnsFromCategoriesCommandHandler.java
index d2256df..3309092 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/ChooseColumnsFromCategoriesCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/ChooseColumnsFromCategoriesCommandHandler.java
@@ -140,7 +140,7 @@
* @return a List of destination positions
*/
protected List<Integer> getDestinationPositions(MoveDirectionEnum direction, List<List<Integer>> selectedPositions) {
- List<Integer> destinationPositions = new ArrayList<Integer>();
+ List<Integer> destinationPositions = new ArrayList<>();
for (List<Integer> contiguousPositions : selectedPositions) {
switch (direction) {
case UP:
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/Node.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/Node.java
index 27eab43..bd94636 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/Node.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/Node.java
@@ -23,9 +23,9 @@
private static final long serialVersionUID = 7855L;
- public static enum Type {
+ public enum Type {
ROOT, COLUMN, CATEGORY, UNKNOWN
- };
+ }
private Type type;
private String data;
@@ -67,7 +67,7 @@
*/
public List<Node> getChildren() {
if (this.children == null) {
- return new ArrayList<Node>();
+ return new ArrayList<>();
}
return this.children;
}
@@ -94,7 +94,7 @@
*/
public Node addChild(Node child) {
if (this.children == null) {
- this.children = new ArrayList<Node>();
+ this.children = new ArrayList<>();
}
this.children.add(child);
child.setParent(this);
@@ -119,18 +119,14 @@
* the position to insert at.
* @param child
* the Node object to insert.
- * @throws IndexOutOfBoundsException
- * if thrown.
*/
- public void insertChildAt(int index, Node child)
- throws IndexOutOfBoundsException {
+ public void insertChildAt(int index, Node child) {
if (index == getNumberOfChildren()) {
// this is really an append
addChild(child);
- return;
} else {
- this.children.get(index); // just to throw the exception, and stop
- // here
+ // just to throw the exception, and stop here
+ this.children.get(index);
this.children.add(index, child);
}
}
@@ -140,10 +136,8 @@
*
* @param index
* the index of the element to delete.
- * @throws IndexOutOfBoundsException
- * if thrown.
*/
- public void removeChildAt(int index) throws IndexOutOfBoundsException {
+ public void removeChildAt(int index) {
this.children.remove(index);
}
@@ -158,13 +152,13 @@
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("{").append(this.type).append(",").append(getData().toString()).append(",["); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ sb.append("{").append(this.type).append(",").append(getData()).append(",["); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
int i = 0;
for (Node e : getChildren()) {
if (i > 0) {
sb.append(","); //$NON-NLS-1$
}
- sb.append(e.getData().toString());
+ sb.append(e.getData());
i++;
}
sb.append("]").append("}"); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/Tree.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/Tree.java
index e6f4f7f..360c08b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/Tree.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/Tree.java
@@ -62,7 +62,7 @@
* @return a List<Node>.
*/
public List<Node> toList() {
- List<Node> list = new ArrayList<Node>();
+ List<Node> list = new ArrayList<>();
walk(this.rootElement, list);
return list;
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/AvailableColumnCategoriesProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/AvailableColumnCategoriesProvider.java
index ee1e31f..9455ade 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/AvailableColumnCategoriesProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/AvailableColumnCategoriesProvider.java
@@ -31,7 +31,7 @@
public class AvailableColumnCategoriesProvider implements ITreeContentProvider {
private final ColumnCategoriesModel model;
- private List<String> hiddenIndexes = new ArrayList<String>();
+ private List<String> hiddenIndexes = new ArrayList<>();
public AvailableColumnCategoriesProvider(ColumnCategoriesModel model) {
this.model = model;
@@ -74,7 +74,7 @@
}
private List<Node> getFilteredChildren(List<Node> allChildren) {
- List<Node> children = new ArrayList<Node>(allChildren);
+ List<Node> children = new ArrayList<>(allChildren);
for (Node child : allChildren) {
if (this.hiddenIndexes.contains(child.getData())) {
children.remove(child);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/ColumnCategoriesDialog.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/ColumnCategoriesDialog.java
index 5ff9126..c0d3e0f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/ColumnCategoriesDialog.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/ColumnCategoriesDialog.java
@@ -349,7 +349,7 @@
private List<ColumnEntry> getSelectedColumnEntriesFromListViewer() {
this.lastListSelection = this.listViewer.getSelection();
Object[] objects = ((StructuredSelection) this.lastListSelection).toArray();
- List<ColumnEntry> entries = new ArrayList<ColumnEntry>();
+ List<ColumnEntry> entries = new ArrayList<>();
for (Object object : objects) {
entries.add((ColumnEntry) object);
@@ -363,7 +363,7 @@
private List<Integer> getColumnIndexesFromTreeNodes() {
Object[] nodes = ((TreeSelection) this.treeViewer.getSelection()).toArray();
- List<Integer> indexes = new ArrayList<Integer>();
+ List<Integer> indexes = new ArrayList<>();
for (Object object : nodes) {
Node node = (Node) object;
if (Type.COLUMN == node.getType()) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooser.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooser.java
index c1c7b6b..edfa88f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooser.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooser.java
@@ -50,7 +50,7 @@
private final org.eclipse.nebula.widgets.nattable.group.performance.ColumnGroupHeaderLayer columnGroupHeaderLayer;
- List<Integer> nonModifiableColumns = new ArrayList<Integer>();
+ List<Integer> nonModifiableColumns = new ArrayList<>();
/**
* Constructor to be used with the old column grouping feature.
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooserUtils.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooserUtils.java
index a4e5605..1c042c0 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooserUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnChooserUtils.java
@@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
import org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer;
import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
@@ -23,7 +24,11 @@
import org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnShowCommand;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
-public class ColumnChooserUtils {
+public final class ColumnChooserUtils {
+
+ private ColumnChooserUtils() {
+ // private default constructor for helper class
+ }
public static final String RENAMED_COLUMN_INDICATOR = "*"; //$NON-NLS-1$
@@ -67,43 +72,59 @@
}
/**
+ *
* @param columnHeaderLayer
+ * The {@link ColumnHeaderLayer} to retrieve a possible renamed
+ * column header label.
* @param columnHeaderDataLayer
+ * The column header {@link DataLayer} to retrieve the column
+ * header label from.
* @param columnIndex
+ * The column index of the column whose label is requested.
* @return The renamed column header name for the given column index (if the
* column has been renamed), the original column name otherwise.
*/
- public static String getColumnLabel(ColumnHeaderLayer columnHeaderLayer,
- DataLayer columnHeaderDataLayer, Integer columnIndex) {
+ public static String getColumnLabel(
+ ColumnHeaderLayer columnHeaderLayer,
+ DataLayer columnHeaderDataLayer,
+ Integer columnIndex) {
+
String label = ""; //$NON-NLS-1$
if (columnHeaderLayer.isColumnRenamed(columnIndex)) {
label = columnHeaderLayer.getRenamedColumnLabelByIndex(columnIndex)
+ RENAMED_COLUMN_INDICATOR;
} else {
- int position = columnHeaderDataLayer
- .getColumnPositionByIndex(columnIndex.intValue());
- label = columnHeaderDataLayer.getDataValueByPosition(position, 0)
- .toString();
+ int position = columnHeaderDataLayer.getColumnPositionByIndex(columnIndex.intValue());
+ label = columnHeaderDataLayer.getDataValueByPosition(position, 0).toString();
}
return label;
}
/**
- * Get all visible columns from the selection layer and the corresponding
- * labels in the header
+ * Get all visible columns and the corresponding labels in the header.
+ *
+ * @param columnHideShowLayer
+ * The {@link ColumnHideShowLayer} to get all visible columns.
+ * @param columnHeaderLayer
+ * The {@link ColumnHeaderLayer} to retrieve a possible renamed
+ * column header label.
+ * @param columnHeaderDataLayer
+ * The column header {@link DataLayer} to retrieve the column
+ * header label from.
+ * @return All visible columns and the corresponding labels in the header.
*/
public static List<ColumnEntry> getVisibleColumnsEntries(
ColumnHideShowLayer columnHideShowLayer,
- ColumnHeaderLayer columnHeaderLayer, DataLayer columnHeaderDataLayer) {
+ ColumnHeaderLayer columnHeaderLayer,
+ DataLayer columnHeaderDataLayer) {
+
int visibleColumnCount = columnHideShowLayer.getColumnCount();
- ArrayList<ColumnEntry> visibleColumnEntries = new ArrayList<ColumnEntry>();
+ ArrayList<ColumnEntry> visibleColumnEntries = new ArrayList<>();
for (int i = 0; i < visibleColumnCount; i++) {
int index = columnHideShowLayer.getColumnIndexByPosition(i);
- String label = getColumnLabel(columnHeaderLayer,
- columnHeaderDataLayer, index);
- ColumnEntry columnEntry = new ColumnEntry(label,
- Integer.valueOf(index), Integer.valueOf(i));
+ String label = getColumnLabel(columnHeaderLayer, columnHeaderDataLayer, index);
+ ColumnEntry columnEntry = new ColumnEntry(label, index, i);
visibleColumnEntries.add(columnEntry);
}
return visibleColumnEntries;
@@ -111,46 +132,50 @@
/**
* Search the collection for the entry with the given index.
+ *
+ * @param entries
+ * The collection of {@link ColumnEntry} objects.
+ * @param indexToFind
+ * The column index to find.
+ * @return The {@link ColumnEntry} for the given column index.
*/
public static ColumnEntry find(List<ColumnEntry> entries, int indexToFind) {
- for (ColumnEntry columnEntry : entries) {
- if (columnEntry.getIndex() == indexToFind) {
- return columnEntry;
- }
- }
- return null;
+ return entries.stream().filter(entry -> entry.getIndex() == indexToFind).findFirst().orElse(null);
}
/**
* Get ColumnEntry positions for the ColumnEntry objects.
+ *
+ * @param columnEntries
+ * The {@link ColumnEntry} objects.
+ * @return The column positions of the provided {@link ColumnEntry} objects.
*/
- public static List<Integer> getColumnEntryPositions(
- List<ColumnEntry> columnEntries) {
- List<Integer> columnEntryPositions = new ArrayList<Integer>();
- for (ColumnEntry columnEntry : columnEntries) {
- columnEntryPositions.add(columnEntry.getPosition());
- }
- return columnEntryPositions;
+ public static List<Integer> getColumnEntryPositions(List<ColumnEntry> columnEntries) {
+ return columnEntries.stream().map(ColumnEntry::getPosition).collect(Collectors.toList());
}
/**
- * Get ColumnEntry positions for the ColumnEntry objects.
+ * Get ColumnEntry indexes for the ColumnEntry objects.
+ *
+ * @param columnEntries
+ * The {@link ColumnEntry} objects.
+ * @return The column indexes of the provided {@link ColumnEntry} objects.
*/
- public static List<Integer> getColumnEntryIndexes(
- List<ColumnEntry> columnEntries) {
- List<Integer> columnEntryIndexes = new ArrayList<Integer>();
- for (ColumnEntry columnEntry : columnEntries) {
- columnEntryIndexes.add(columnEntry.getIndex());
- }
- return columnEntryIndexes;
+ public static List<Integer> getColumnEntryIndexes(List<ColumnEntry> columnEntries) {
+ return columnEntries.stream().map(ColumnEntry::getIndex).collect(Collectors.toList());
}
/**
- * @return TRUE if the list contains an entry with the given index
+ *
+ * @param entries
+ * The collection of {@link ColumnEntry} objects.
+ * @param indexToFind
+ * The column index to find.
+ * @return <code>true</code> if the list contains an entry with the given
+ * index.
*/
- public static boolean containsIndex(List<ColumnEntry> entries,
- int indexToFind) {
- return find(entries, indexToFind) != null;
+ public static boolean containsIndex(List<ColumnEntry> entries, int indexToFind) {
+ return entries.stream().anyMatch(entry -> entry.getIndex() == indexToFind);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnGroupEntry.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnGroupEntry.java
index d6ab045..5c39609 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnGroupEntry.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ColumnGroupEntry.java
@@ -106,7 +106,7 @@
}
public static List<Integer> getColumnGroupEntryPositions(List<ColumnGroupEntry> columnEntries) {
- List<Integer> columnGroupEntryPositions = new ArrayList<Integer>();
+ List<Integer> columnGroupEntryPositions = new ArrayList<>();
for (ColumnGroupEntry columnGroupEntry : columnEntries) {
columnGroupEntryPositions.add(columnGroupEntry.getFirstElementPosition());
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ISelectionTreeListener.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ISelectionTreeListener.java
index 7b547e0..bf7893e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ISelectionTreeListener.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/ISelectionTreeListener.java
@@ -22,12 +22,6 @@
void itemsRemoved(List<ColumnEntry> removedItems);
- /**
- * If columns moved are adjacent to each other, they are grouped together.
- *
- * @param direction
- * @param selectedColumnGroupEntries
- */
void itemsMoved(MoveDirectionEnum direction,
List<ColumnGroupEntry> selectedColumnGroupEntries,
List<ColumnEntry> movedColumnEntries,
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/command/DisplayColumnChooserCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/command/DisplayColumnChooserCommandHandler.java
index 79d83ef..369102d 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/command/DisplayColumnChooserCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/command/DisplayColumnChooserCommandHandler.java
@@ -37,7 +37,7 @@
private final boolean sortAvailableColumns;
private final boolean preventHidingAllColumns;
private IDialogSettings dialogSettings;
- private List<Integer> nonModifiableColumns = new ArrayList<Integer>();
+ private List<Integer> nonModifiableColumns = new ArrayList<>();
private final org.eclipse.nebula.widgets.nattable.group.performance.ColumnGroupHeaderLayer cghLayer;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/gui/AbstractColumnChooserDialog.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/gui/AbstractColumnChooserDialog.java
index 1e19a81..41112e7 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/gui/AbstractColumnChooserDialog.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnChooser/gui/AbstractColumnChooserDialog.java
@@ -28,7 +28,7 @@
public abstract class AbstractColumnChooserDialog extends Dialog {
- private IDialogSettings dialogSettings;;
+ private IDialogSettings dialogSettings;
public AbstractColumnChooserDialog(Shell parent) {
super(parent);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/DisplayColumnRenameDialogCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/DisplayColumnRenameDialogCommand.java
index 19e3981..4b13a42 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/DisplayColumnRenameDialogCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/DisplayColumnRenameDialogCommand.java
@@ -25,6 +25,9 @@
private final NatTable natTable;
/**
+ * @param natTable
+ * The NatTable instance (top level layer) to which the column
+ * position matches.
* @param columnPosition
* of the column to be renamed
*/
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/RenameColumnHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/RenameColumnHelper.java
index fcd0e9e..2e00f75 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/RenameColumnHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/RenameColumnHelper.java
@@ -44,7 +44,7 @@
/**
* Tracks the renamed labels provided by the user.
*/
- protected Map<Integer, String> renamedColumnsLabelsByIndex = new TreeMap<Integer, String>();
+ protected Map<Integer, String> renamedColumnsLabelsByIndex = new TreeMap<>();
/**
*
@@ -97,6 +97,8 @@
}
/**
+ * @param columnIndex
+ * the column index
* @return the custom label for this column as specified by the user Null if
* the columns is not renamed
*/
@@ -105,6 +107,8 @@
}
/**
+ * @param columnIndex
+ * the column index
* @return <code>true</code> if the column at the specified index was
* renamed by a user.
*/
@@ -130,7 +134,7 @@
public void handleStructuralChanges(Collection<StructuralDiff> columnDiffs) {
// the number of all deleted columns that don't have a corresponding
// index anymore (last column cases)
- List<Integer> toRemove = new ArrayList<Integer>();
+ List<Integer> toRemove = new ArrayList<>();
for (StructuralDiff columnDiff : columnDiffs) {
if (columnDiff.getDiffType() != null
&& columnDiff.getDiffType().equals(DiffTypeEnum.DELETE)) {
@@ -148,10 +152,10 @@
}
// modify column indexes regarding the deleted columns
- List<Integer> indices = new ArrayList<Integer>(this.renamedColumnsLabelsByIndex.keySet());
+ List<Integer> indices = new ArrayList<>(this.renamedColumnsLabelsByIndex.keySet());
Collections.sort(indices);
- Map<Integer, String> modified = new TreeMap<Integer, String>();
+ Map<Integer, String> modified = new TreeMap<>();
for (Integer column : indices) {
// check number of removed indexes that are lower than the current
// one
@@ -172,12 +176,12 @@
if (columnDiff.getDiffType() != null
&& columnDiff.getDiffType().equals(DiffTypeEnum.ADD)) {
- indices = new ArrayList<Integer>(this.renamedColumnsLabelsByIndex.keySet());
+ indices = new ArrayList<>(this.renamedColumnsLabelsByIndex.keySet());
Collections.sort(indices);
Range beforePositionRange = columnDiff.getBeforePositionRange();
Range afterPositionRange = columnDiff.getAfterPositionRange();
- Map<Integer, String> modifiedColumns = new TreeMap<Integer, String>();
+ Map<Integer, String> modifiedColumns = new TreeMap<>();
int beforeIndex = this.columnHeaderLayer.getColumnIndexByPosition(beforePositionRange.start);
for (Integer column : indices) {
if (column >= beforeIndex) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/event/RenameColumnHeaderEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/event/RenameColumnHeaderEvent.java
index 0a6efd7..f5722c7 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/event/RenameColumnHeaderEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnRename/event/RenameColumnHeaderEvent.java
@@ -23,6 +23,11 @@
public class RenameColumnHeaderEvent extends ColumnVisualChangeEvent {
/**
+ *
+ * @param layer
+ * The layer to which the column position matches.
+ * @param columnPosition
+ * The renamed column position.
* @since 1.4
*/
public RenameColumnHeaderEvent(ILayer layer, int columnPosition) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/AbstractMultiColumnCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/AbstractMultiColumnCommand.java
index 0f6300a..698ad02 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/AbstractMultiColumnCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/AbstractMultiColumnCommand.java
@@ -94,7 +94,7 @@
.filter(Objects::nonNull)
.collect(Collectors.toCollection(HashSet::new));
- if (converted.size() > 0) {
+ if (!converted.isEmpty()) {
this.columnPositionCoordinates = converted;
return true;
} else {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/AbstractMultiRowCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/AbstractMultiRowCommand.java
index 05d1b2c..21e009e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/AbstractMultiRowCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/AbstractMultiRowCommand.java
@@ -94,7 +94,7 @@
.filter(Objects::nonNull)
.collect(Collectors.toCollection(HashSet::new));
- if (converted.size() > 0) {
+ if (!converted.isEmpty()) {
this.rowPositionCoordinates = converted;
return true;
} else {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/LayerCommandUtil.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/LayerCommandUtil.java
index 1e86fb8..709987a 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/LayerCommandUtil.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/command/LayerCommandUtil.java
@@ -25,6 +25,10 @@
*/
public class LayerCommandUtil {
+ private LayerCommandUtil() {
+ // private default constructor for helper class
+ }
+
/**
* Convert the given {@link PositionCoordinate} to the given target
* {@link ILayer}.
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/AggregateConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/AggregateConfiguration.java
index a46bc54..c1882ad 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/AggregateConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/AggregateConfiguration.java
@@ -24,7 +24,7 @@
*/
public class AggregateConfiguration implements IConfiguration {
- private final Collection<IConfiguration> configurations = new LinkedList<IConfiguration>();
+ private final Collection<IConfiguration> configurations = new LinkedList<>();
public void addConfiguration(IConfiguration configuration) {
this.configurations.add(configuration);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/CellConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/CellConfigAttributes.java
index 9972161..73e4550 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/CellConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/CellConfigAttributes.java
@@ -20,41 +20,42 @@
/**
* Interface that specifies configuration attributes for cell rendering.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
*/
-public interface CellConfigAttributes {
+public final class CellConfigAttributes {
+
+ private CellConfigAttributes() {
+ // private default constructor for constants class
+ }
/**
* Attribute for configuring the ICellPainter that should be used to render
* a cell.
*/
- ConfigAttribute<ICellPainter> CELL_PAINTER = new ConfigAttribute<ICellPainter>();
+ public static final ConfigAttribute<ICellPainter> CELL_PAINTER = new ConfigAttribute<>();
/**
* Attribute for configuring the IStyle that should be used to render a
* cell.
*/
- ConfigAttribute<IStyle> CELL_STYLE = new ConfigAttribute<IStyle>();
+ public static final ConfigAttribute<IStyle> CELL_STYLE = new ConfigAttribute<>();
/**
* Attribute for configuring the IDisplayConverter that should be used to
* convert the data in a cell for rendering.
*/
- ConfigAttribute<IDisplayConverter> DISPLAY_CONVERTER = new ConfigAttribute<IDisplayConverter>();
+ public static final ConfigAttribute<IDisplayConverter> DISPLAY_CONVERTER = new ConfigAttribute<>();
/**
* Attribute for configuring the Color that should be used to render the
* grid lines. Will be interpreted by the GridLineCellLayerPainter.
*/
- ConfigAttribute<Color> GRID_LINE_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> GRID_LINE_COLOR = new ConfigAttribute<>();
/**
* Attribute for configuring whether grid lines should be rendered or not.
* Will be interpreted by the GridLineCellLayerPainter.
*/
- ConfigAttribute<Boolean> RENDER_GRID_LINES = new ConfigAttribute<Boolean>();
+ public static final ConfigAttribute<Boolean> RENDER_GRID_LINES = new ConfigAttribute<>();
/**
* Attribute for configuring the width of the grid lines. Is for example
@@ -62,5 +63,5 @@
*
* @since 1.4
*/
- ConfigAttribute<Integer> GRID_LINE_WIDTH = new ConfigAttribute<Integer>();
+ public static final ConfigAttribute<Integer> GRID_LINE_WIDTH = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/ConfigRegistry.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/ConfigRegistry.java
index 0246cdd..d790877 100755
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/ConfigRegistry.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/ConfigRegistry.java
@@ -25,7 +25,7 @@
public class ConfigRegistry implements IConfigRegistry {
// Map<configAttributeType, Map<displayMode, Map<configLabel, value>>>
- Map<ConfigAttribute<?>, Map<String, Map<String, ?>>> configRegistry = new HashMap<ConfigAttribute<?>, Map<String, Map<String, ?>>>();
+ Map<ConfigAttribute<?>, Map<String, Map<String, ?>>> registry = new HashMap<>();
@Override
public <T> T getConfigAttribute(
@@ -48,7 +48,7 @@
T attributeValue = null;
- Map<String, Map<String, ?>> displayModeConfigAttributeMap = this.configRegistry.get(configAttribute);
+ Map<String, Map<String, ?>> displayModeConfigAttributeMap = this.registry.get(configAttribute);
if (displayModeConfigAttributeMap != null) {
for (String displayMode : this.displayModeOrdering.getDisplayModeOrdering(targetDisplayMode)) {
Map<String, T> configAttributeMap = (Map<String, T>) displayModeConfigAttributeMap.get(displayMode);
@@ -81,7 +81,7 @@
T attributeValue = null;
- Map<String, Map<String, ?>> displayModeConfigAttributeMap = this.configRegistry.get(configAttribute);
+ Map<String, Map<String, ?>> displayModeConfigAttributeMap = this.registry.get(configAttribute);
if (displayModeConfigAttributeMap != null) {
Map<String, T> configAttributeMap = (Map<String, T>) displayModeConfigAttributeMap.get(displayMode);
if (configAttributeMap != null) {
@@ -120,20 +120,14 @@
String displayMode,
String configLabel) {
- Map<String, Map<String, ?>> displayModeConfigAttributeMap = this.configRegistry.get(configAttribute);
- if (displayModeConfigAttributeMap == null) {
- displayModeConfigAttributeMap = new HashMap<String, Map<String, ?>>();
- this.configRegistry.put(configAttribute, displayModeConfigAttributeMap);
- }
+ Map<String, Map<String, ?>> displayModeConfigAttributeMap =
+ this.registry.computeIfAbsent(configAttribute, cf -> new HashMap<>());
- Map<String, T> configAttributeMap = (Map<String, T>) displayModeConfigAttributeMap.get(displayMode);
- if (configAttributeMap == null) {
- configAttributeMap = new HashMap<String, T>();
- displayModeConfigAttributeMap.put(displayMode, configAttributeMap);
- }
+ Map<String, T> configAttributeMap =
+ (Map<String, T>) displayModeConfigAttributeMap.computeIfAbsent(displayMode, dm -> new HashMap<>());
configAttributeMap.put(configLabel, attributeValue);
- };
+ }
@Override
public <T> void unregisterConfigAttribute(
@@ -157,7 +151,7 @@
String displayMode,
String configLabel) {
- Map<String, Map<String, ?>> displayModeConfigAttributeMap = this.configRegistry.get(configAttributeType);
+ Map<String, Map<String, ?>> displayModeConfigAttributeMap = this.registry.get(configAttributeType);
if (displayModeConfigAttributeMap != null) {
Map<String, T> configAttributeMap = (Map<String, T>) displayModeConfigAttributeMap.get(displayMode);
if (configAttributeMap != null) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/DefaultNatTableStyleConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/DefaultNatTableStyleConfiguration.java
index f07bf31..38627e6 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/DefaultNatTableStyleConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/DefaultNatTableStyleConfiguration.java
@@ -25,6 +25,8 @@
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
+//fields are public by design to make it easy for adapters to customize styling
+@SuppressWarnings("java:S1104")
public class DefaultNatTableStyleConfiguration extends AbstractRegistryConfiguration {
public Color bgColor = GUIHelper.COLOR_WHITE;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/NatTableConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/NatTableConfigAttributes.java
index f57bd90..5503dbb 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/NatTableConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/config/NatTableConfigAttributes.java
@@ -27,19 +27,19 @@
* Configuration attribute for registering an {@link IDpiConverter} to
* convert dimensions horizontally.
*/
- public static final ConfigAttribute<IDpiConverter> HORIZONTAL_DPI_CONVERTER = new ConfigAttribute<IDpiConverter>();
+ public static final ConfigAttribute<IDpiConverter> HORIZONTAL_DPI_CONVERTER = new ConfigAttribute<>();
/**
* Configuration attribute for registering an {@link IDpiConverter} to
* convert dimensions vertically.
*/
- public static final ConfigAttribute<IDpiConverter> VERTICAL_DPI_CONVERTER = new ConfigAttribute<IDpiConverter>();
+ public static final ConfigAttribute<IDpiConverter> VERTICAL_DPI_CONVERTER = new ConfigAttribute<>();
/**
* Configuration attribute for registering the font scaling factor in case
* scaling is active.
*/
- public static final ConfigAttribute<Float> FONT_SCALING_FACTOR = new ConfigAttribute<Float>();
+ public static final ConfigAttribute<Float> FONT_SCALING_FACTOR = new ConfigAttribute<>();
private NatTableConfigAttributes() {
// empty default constructor
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/AbstractEventConflater.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/AbstractEventConflater.java
index f9b6a7d..b0dbbd0 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/AbstractEventConflater.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/AbstractEventConflater.java
@@ -19,7 +19,7 @@
public abstract class AbstractEventConflater implements IEventConflater {
- protected List<ILayerEvent> queue = new LinkedList<ILayerEvent>();
+ protected List<ILayerEvent> queue = new LinkedList<>();
@Override
public void addEvent(ILayerEvent event) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/EventConflaterChain.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/EventConflaterChain.java
index fbf2fda..dad58a6 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/EventConflaterChain.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/EventConflaterChain.java
@@ -30,7 +30,7 @@
public static final long DEFAULT_REFRESH_INTERVAL = 20;
private static final Scheduler scheduler = new Scheduler("EventConflaterChain"); //$NON-NLS-1$
- private final List<IEventConflater> chain = new LinkedList<IEventConflater>();
+ private final List<IEventConflater> chain = new LinkedList<>();
private ScheduledFuture<?> future;
private boolean started;
private final long refreshInterval;
@@ -41,6 +41,12 @@
}
/**
+ *
+ * @param refreshInterval
+ * the delay between the termination of one execution and the
+ * commencement of the next
+ * @param initialDelay
+ * the time to delay first execution
* @since 2.0
*/
public EventConflaterChain(long refreshInterval, long initialDelay) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/VisualChangeEventConflater.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/VisualChangeEventConflater.java
index 06042c8..a37c5db 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/VisualChangeEventConflater.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/conflation/VisualChangeEventConflater.java
@@ -39,7 +39,7 @@
@Override
public Runnable getConflaterTask() {
return () -> {
- if (VisualChangeEventConflater.this.queue.size() > 0) {
+ if (!VisualChangeEventConflater.this.queue.isEmpty()) {
clearQueue();
VisualChangeEventConflater.this.natTable.getDisplay().asyncExec(VisualChangeEventConflater.this.natTable::updateResize);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/coordinate/PositionUtil.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/coordinate/PositionUtil.java
index 72a0d51..f053e35 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/coordinate/PositionUtil.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/coordinate/PositionUtil.java
@@ -27,6 +27,10 @@
public class PositionUtil {
+ private PositionUtil() {
+ // private constructor for helper class
+ }
+
/**
* Implementation to create Ranges from contiguous numbers.
*
@@ -37,7 +41,7 @@
@Override
public void accept(ArrayList<Range> ranges, int i) {
Range lastGroup;
- if (ranges.size() > 0) {
+ if (!ranges.isEmpty()) {
lastGroup = ranges.get(ranges.size() - 1);
} else {
lastGroup = new Range(i, i + 1);
@@ -63,17 +67,17 @@
* @return Collection of groups with contiguous numbers.
*/
public static List<List<Integer>> getGroupedByContiguous(Collection<Integer> numberCollection) {
- List<Integer> numbers = new ArrayList<Integer>(numberCollection);
+ List<Integer> numbers = new ArrayList<>(numberCollection);
Collections.sort(numbers);
- ArrayList<Integer> contiguous = new ArrayList<Integer>();
- ArrayList<List<Integer>> grouped = new ArrayList<List<Integer>>();
+ ArrayList<Integer> contiguous = new ArrayList<>();
+ ArrayList<List<Integer>> grouped = new ArrayList<>();
for (int i = 0; i < numbers.size() - 1; i++) {
if (numbers.get(i).intValue() + 1 != numbers.get(i + 1).intValue()) {
contiguous.add(numbers.get(i));
grouped.add(contiguous);
- contiguous = new ArrayList<Integer>();
+ contiguous = new ArrayList<>();
} else {
contiguous.add(numbers.get(i));
}
@@ -101,9 +105,7 @@
.collect(
ArrayList<Range>::new,
new RangeAccumulator(),
- (g1, g2) -> {
- g1.addAll(g2);
- });
+ (g1, g2) -> g1.addAll(g2));
return ranges.stream()
.map(Range::getMembersArray)
@@ -131,10 +133,8 @@
.collect(
ArrayList<Range>::new,
new RangeAccumulator(),
- (g1, g2) -> {
- g1.addAll(g2);
- })
- : new ArrayList<Range>();
+ (g1, g2) -> g1.addAll(g2))
+ : new ArrayList<>();
}
/**
@@ -159,10 +159,8 @@
.collect(
ArrayList<Range>::new,
new RangeAccumulator(),
- (g1, g2) -> {
- g1.addAll(g2);
- })
- : new ArrayList<Range>();
+ (g1, g2) -> g1.addAll(g2))
+ : new ArrayList<>();
}
/**
@@ -183,7 +181,7 @@
* @since 1.6
*/
public static int[] getPositions(Collection<Range> ranges) {
- if ((ranges == null) || (ranges.size() == 0)) {
+ if (ranges == null || ranges.isEmpty()) {
return new int[0];
}
@@ -232,7 +230,7 @@
}
// put to list
- ArrayList<Range> sortedRanges = new ArrayList<Range>(ranges);
+ ArrayList<Range> sortedRanges = new ArrayList<>(ranges);
// sort by 1) start, 2) end position
Collections.sort(sortedRanges, (o1, o2) -> {
@@ -269,7 +267,7 @@
* @since 1.6
*/
public static List<Range> mergeRanges(Collection<Range> ranges) {
- TreeSet<Integer> numbers = new TreeSet<Integer>();
+ TreeSet<Integer> numbers = new TreeSet<>();
for (Range range : ranges) {
for (int number = range.start; number < range.end; number++) {
numbers.add(number);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/coordinate/Range.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/coordinate/Range.java
index 6635ff8..6ecb953 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/coordinate/Range.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/coordinate/Range.java
@@ -52,6 +52,8 @@
/**
* Check if the given position is contained in this {@link Range}.
*
+ * @param position
+ * the position to check.
* @return <code>true</code> if the range contains the given position.
*/
public boolean contains(int position) {
@@ -78,7 +80,7 @@
* @return The values represented by this {@link Range}.
*/
public Set<Integer> getMembers() {
- Set<Integer> members = new HashSet<Integer>();
+ Set<Integer> members = new HashSet<>();
for (int i = this.start; i < this.end; i++) {
members.add(Integer.valueOf(i));
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/copy/command/CopyDataCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/copy/command/CopyDataCommandHandler.java
index 5bca1c4..7dec322 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/copy/command/CopyDataCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/copy/command/CopyDataCommandHandler.java
@@ -179,7 +179,7 @@
*/
protected ILayerCell[][] assembleCopiedDataStructure() {
final Set<Range> selectedRows = this.selectionLayer.getSelectedRowPositions();
- final List<ILayerCell[]> copiedCells = new ArrayList<ILayerCell[]>();
+ final List<ILayerCell[]> copiedCells = new ArrayList<>();
final ILayerCell[][] columnHeaderCells = assembleColumnHeaders();
for (ILayerCell[] cells : columnHeaderCells) {
@@ -192,7 +192,7 @@
// this is needed because taking only the Range.start into account leads
// to overriding values in the array instead of adding if there are
// multiple Ranges returned
- Set<Integer> selectedRowPositions = new TreeSet<Integer>();
+ Set<Integer> selectedRowPositions = new TreeSet<>();
for (Range range : selectedRows) {
for (int rowPosition = range.start; rowPosition < range.end; rowPosition++) {
if (this.selectionLayer.getRowHeightByPosition(rowPosition) > 0) {
@@ -331,7 +331,7 @@
* @since 1.6
*/
protected int[] getSelectedColumnPositions() {
- List<Integer> selected = new ArrayList<Integer>();
+ List<Integer> selected = new ArrayList<>();
for (int pos : this.selectionLayer.getSelectedColumnPositions()) {
if (this.selectionLayer.getColumnWidthByPosition(pos) > 0) {
selected.add(pos);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/copy/serializing/CopyDataToClipboardSerializer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/copy/serializing/CopyDataToClipboardSerializer.java
index 66781a4..610ea3a 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/copy/serializing/CopyDataToClipboardSerializer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/copy/serializing/CopyDataToClipboardSerializer.java
@@ -68,7 +68,7 @@
return String.valueOf(cell.getDataValue());
}
- final protected CopyDataToClipboardCommand getCommand() {
+ protected final CopyDataToClipboardCommand getCommand() {
return this.command;
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/AutomaticSpanningDataProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/AutomaticSpanningDataProvider.java
index 367b41b..72612fd 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/AutomaticSpanningDataProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/AutomaticSpanningDataProvider.java
@@ -71,14 +71,14 @@
* <b>Note: </b>If this list is empty, all columns will do auto row
* spanning.
*/
- private List<Integer> autoSpanColumns = new ArrayList<Integer>();
+ private List<Integer> autoSpanColumns = new ArrayList<>();
/**
* List of row positions for which automatic spanning is enabled.
* <p>
* <b>Note: </b>If this list is empty, all rows will do auto column
* spanning.
*/
- private List<Integer> autoSpanRows = new ArrayList<Integer>();
+ private List<Integer> autoSpanRows = new ArrayList<>();
/**
*
@@ -433,12 +433,12 @@
public void saveState(String prefix, Properties properties) {
properties.setProperty(
prefix + PERSISTENCE_KEY_AUTO_COLUMN_SPAN,
- Boolean.valueOf(this.autoColumnSpan).toString());
+ Boolean.toString(this.autoColumnSpan));
properties.setProperty(
prefix + PERSISTENCE_KEY_AUTO_ROW_SPAN,
- Boolean.valueOf(this.autoRowSpan).toString());
+ Boolean.toString(this.autoRowSpan));
- if (this.autoSpanColumns.size() > 0) {
+ if (!this.autoSpanColumns.isEmpty()) {
StringBuilder strBuilder = new StringBuilder();
for (Integer index : this.autoSpanColumns) {
strBuilder.append(index);
@@ -449,7 +449,7 @@
strBuilder.toString());
}
- if (this.autoSpanRows.size() > 0) {
+ if (!this.autoSpanRows.isEmpty()) {
StringBuilder strBuilder = new StringBuilder();
for (Integer index : this.autoSpanRows) {
strBuilder.append(index);
@@ -476,7 +476,7 @@
this.autoSpanColumns.clear();
property = properties.getProperty(prefix + PERSISTENCE_KEY_AUTO_SPAN_COLUMNS);
if (property != null) {
- List<Integer> newAutoSpanColumns = new ArrayList<Integer>();
+ List<Integer> newAutoSpanColumns = new ArrayList<>();
StringTokenizer tok = new StringTokenizer(property, IPersistable.VALUE_SEPARATOR);
while (tok.hasMoreTokens()) {
String index = tok.nextToken();
@@ -489,7 +489,7 @@
this.autoSpanRows.clear();
property = properties.getProperty(prefix + PERSISTENCE_KEY_AUTO_SPAN_ROWS);
if (property != null) {
- List<Integer> newAutoSpanRows = new ArrayList<Integer>();
+ List<Integer> newAutoSpanRows = new ArrayList<>();
StringTokenizer tok = new StringTokenizer(property, IPersistable.VALUE_SEPARATOR);
while (tok.hasMoreTokens()) {
String index = tok.nextToken();
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/IColumnPropertyResolver.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/IColumnPropertyResolver.java
index fc7d42f..d328eca 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/IColumnPropertyResolver.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/IColumnPropertyResolver.java
@@ -21,12 +21,14 @@
/**
* @param columnIndex
* i.e the order of the column in the backing bean
+ * @return the column property name for the provided column index.
*/
public String getColumnProperty(int columnIndex);
/**
* @param propertyName
* i.e the name of the column in the backing bean
+ * @return the column index for the provided property name.
*/
public int getColumnIndex(String propertyName);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowDeleteCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowDeleteCommandHandler.java
index 95db916..e4ac89b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowDeleteCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowDeleteCommandHandler.java
@@ -55,7 +55,7 @@
if (command.convertToTargetLayer(targetLayer)) {
int[] positions = command.getRowPositionsArray();
- HashMap<Integer, T> deleted = new HashMap<Integer, T>();
+ HashMap<Integer, T> deleted = new HashMap<>();
for (int i = positions.length - 1; i >= 0; i--) {
// remove the element
int pos = positions[i];
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowInsertCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowInsertCommand.java
index e72fe02..755b4a4 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowInsertCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowInsertCommand.java
@@ -74,7 +74,7 @@
*/
public RowInsertCommand(int rowIndex, T object) {
this.rowIndex = rowIndex;
- this.objects = new ArrayList<T>(1);
+ this.objects = new ArrayList<>(1);
this.objects.add(object);
}
@@ -99,7 +99,7 @@
*/
public RowInsertCommand(T object) {
this.rowIndex = -1;
- this.objects = new ArrayList<T>(1);
+ this.objects = new ArrayList<>(1);
this.objects.add(object);
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowObjectDeleteCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowObjectDeleteCommand.java
index d75b101..29c3483 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowObjectDeleteCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowObjectDeleteCommand.java
@@ -28,7 +28,7 @@
*/
public class RowObjectDeleteCommand<T> extends AbstractContextFreeCommand {
- private List<T> objectsToDelete = new ArrayList<T>();
+ private List<T> objectsToDelete = new ArrayList<>();
/**
* Creates a {@link RowObjectDeleteCommand}.
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowObjectDeleteCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowObjectDeleteCommandHandler.java
index a8407ba..a106edf 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowObjectDeleteCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/command/RowObjectDeleteCommandHandler.java
@@ -59,7 +59,7 @@
// changes via DataChangeLayer in the correct order again
int[] indexes = new int[command.getObjectsToDelete().size()];
int idx = 0;
- Map<Integer, T> deleted = new TreeMap<Integer, T>();
+ Map<Integer, T> deleted = new TreeMap<>();
for (Object rowObject : command.getObjectsToDelete()) {
int index = this.bodyData.indexOf(rowObject);
deleted.put(index, (T) rowObject);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/convert/DefaultDateDisplayConverter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/convert/DefaultDateDisplayConverter.java
index 645d0fb..c3e49bf 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/convert/DefaultDateDisplayConverter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/convert/DefaultDateDisplayConverter.java
@@ -80,7 +80,7 @@
return this.dateFormat.parse(displayValue.toString());
} catch (Exception e) {
throw new ConversionFailedException(Messages.getString("DefaultDateDisplayConverter.failure", //$NON-NLS-1$
- new Object[] { displayValue, this.dateFormat.toPattern() }), e);
+ displayValue, this.dateFormat.toPattern()), e);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/convert/PercentageDisplayConverter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/convert/PercentageDisplayConverter.java
index e68727e..c556366 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/convert/PercentageDisplayConverter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/convert/PercentageDisplayConverter.java
@@ -33,7 +33,7 @@
displayString.length() - 1);
}
displayString = displayString.trim();
- int displayInt = Integer.valueOf(displayString).intValue();
+ int displayInt = Integer.parseInt(displayString);
double percentageValue = (double) displayInt / 100;
return Double.valueOf(percentageValue);
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/validate/IDataValidator.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/validate/IDataValidator.java
index 799a42e..42ee4e8 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/validate/IDataValidator.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/validate/IDataValidator.java
@@ -34,7 +34,8 @@
*
* @see IDataProvider#getDataValue(int, int)
*
- * @return true is newValue is valid. False otherwise.
+ * @return <code>true</code> if newValue is valid, <code>false</code>
+ * otherwise.
*/
public boolean validate(int columnIndex, int rowIndex, Object newValue);
@@ -43,6 +44,8 @@
* @param cell
* LayerCell which should be validated
* @param configRegistry
+ * The {@link IConfigRegistry} used to retrieve contextual
+ * information for the cell.
* @param newValue
* Value entered through the edit control text box, combo box
* etc. Note: In case of the {@link TextCellEditor} the text
@@ -51,16 +54,15 @@
*
* @see IDataProvider#getDataValue(int, int)
*
- * @return true is newValue is valid. False otherwise.
+ * @return <code>true</code> if newValue is valid, <code>false</code>
+ * otherwise.
*/
- public boolean validate(ILayerCell cell, IConfigRegistry configRegistry,
- Object newValue);
+ public boolean validate(ILayerCell cell, IConfigRegistry configRegistry, Object newValue);
public static final IDataValidator ALWAYS_VALID = new IDataValidator() {
@Override
- public boolean validate(ILayerCell cell,
- IConfigRegistry configRegistry, Object newValue) {
+ public boolean validate(ILayerCell cell, IConfigRegistry configRegistry, Object newValue) {
return true;
}
@@ -74,8 +76,7 @@
public static final IDataValidator NEVER_VALID = new IDataValidator() {
@Override
- public boolean validate(ILayerCell cell,
- IConfigRegistry configRegistry, Object newValue) {
+ public boolean validate(ILayerCell cell, IConfigRegistry configRegistry, Object newValue) {
return false;
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/DataChangeLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/DataChangeLayer.java
index e3b0353..4f2e8a9 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/DataChangeLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/DataChangeLayer.java
@@ -55,13 +55,13 @@
* The {@link DataChangeHandler} registered with this
* {@link DataChangeLayer} to keep track of data changes.
*/
- protected final List<DataChangeHandler> dataChangeHandler = new ArrayList<DataChangeHandler>();
+ protected final List<DataChangeHandler> dataChangeHandler = new ArrayList<>();
/**
* The list of {@link DataChange}s that need to be handled on save or
* discard.
*/
- protected final List<DataChange> dataChanges = new ArrayList<DataChange>();
+ protected final List<DataChange> dataChanges = new ArrayList<>();
/**
* Data provider that returns temporary stored data changes.
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/IdIndexKeyHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/IdIndexKeyHandler.java
index 279e65d..cefd83d 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/IdIndexKeyHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/IdIndexKeyHandler.java
@@ -59,7 +59,7 @@
// added to the underlying list
if (rowObject.getClass().equals(this.clazz)) {
Object rowId = this.rowIdAccessor.getRowId(rowObject);
- return new IdIndexIdentifier<T>(columnIndex, rowId, rowObject);
+ return new IdIndexIdentifier<>(columnIndex, rowId, rowObject);
}
}
return null;
@@ -67,7 +67,7 @@
@Override
public IdIndexIdentifier<T> getKeyWithColumnUpdate(IdIndexIdentifier<T> oldKey, int columnIndex) {
- return new IdIndexIdentifier<T>(columnIndex, oldKey.rowId, oldKey.rowObject);
+ return new IdIndexIdentifier<>(columnIndex, oldKey.rowId, oldKey.rowObject);
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/PersistenceUpdateDataChangeHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/PersistenceUpdateDataChangeHandler.java
index 786a500..63a5e73 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/PersistenceUpdateDataChangeHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/PersistenceUpdateDataChangeHandler.java
@@ -38,7 +38,7 @@
* for a specific key.
*/
public PersistenceUpdateDataChangeHandler(DataChangeLayer layer, CellKeyHandler<?> keyHandler) {
- super(layer, keyHandler, new ConcurrentHashMap<Object, PersistenceUpdateDataChange>());
+ super(layer, keyHandler, new ConcurrentHashMap<>());
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/RowDeleteDataChangeHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/RowDeleteDataChangeHandler.java
index 0e61d81..94dc048 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/RowDeleteDataChangeHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/RowDeleteDataChangeHandler.java
@@ -42,7 +42,7 @@
* for a specific key.
*/
public RowDeleteDataChangeHandler(DataChangeLayer layer, CellKeyHandler<?> keyHandler) {
- super(layer, keyHandler, new ConcurrentHashMap<Object, RowDeleteDataChange>());
+ super(layer, keyHandler, new ConcurrentHashMap<>());
}
@Override
@@ -74,7 +74,7 @@
// we need to ensure that the data changes are in reverse order
// to ensure that inserting them back again insert in the
// correct places
- Map<Integer, Object> map = new TreeMap<Integer, Object>(Collections.reverseOrder());
+ Map<Integer, Object> map = new TreeMap<>(Collections.reverseOrder());
map.putAll(event.getDeletedObjects());
for (Map.Entry<Integer, Object> deleted : map.entrySet()) {
// store the change locally
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/RowInsertDataChangeHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/RowInsertDataChangeHandler.java
index 07082d1..e305299 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/RowInsertDataChangeHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/RowInsertDataChangeHandler.java
@@ -54,7 +54,7 @@
* for a specific key.
*/
public RowInsertDataChangeHandler(DataChangeLayer layer, CellKeyHandler<?> keyHandler) {
- super(layer, keyHandler, new ConcurrentHashMap<Object, RowInsertDataChange>());
+ super(layer, keyHandler, new ConcurrentHashMap<>());
}
@Override
@@ -85,10 +85,10 @@
private void handleRowDelete(Collection<StructuralDiff> rowDiffs) {
// for correct calculation the diffs need to be processed from lowest
// position to highest
- List<StructuralDiff> diffs = new ArrayList<StructuralDiff>(rowDiffs);
+ List<StructuralDiff> diffs = new ArrayList<>(rowDiffs);
Collections.sort(diffs, (o1, o2) -> o1.getBeforePositionRange().start - o2.getBeforePositionRange().start);
- List<Integer> toRemove = new ArrayList<Integer>();
+ List<Integer> toRemove = new ArrayList<>();
for (StructuralDiff rowDiff : diffs) {
if (rowDiff.getDiffType() != null
&& rowDiff.getDiffType().equals(DiffTypeEnum.DELETE)) {
@@ -104,7 +104,7 @@
if (!toRemove.isEmpty()) {
// modify row indexes regarding the deleted rows
- Map<Object, RowInsertDataChange> modifiedRows = new HashMap<Object, RowInsertDataChange>();
+ Map<Object, RowInsertDataChange> modifiedRows = new HashMap<>();
for (Map.Entry<Object, RowInsertDataChange> entry : this.dataChanges.entrySet()) {
int rowIndex = this.keyHandler.getRowIndex(entry.getKey());
if (!toRemove.contains(rowIndex)) {
@@ -146,7 +146,7 @@
private void handleRowInsert(Collection<StructuralDiff> rowDiffs) {
// for correct calculation the diffs need to be processed from highest
// position to lowest
- List<StructuralDiff> diffs = new ArrayList<StructuralDiff>(rowDiffs);
+ List<StructuralDiff> diffs = new ArrayList<>(rowDiffs);
Collections.sort(diffs, (o1, o2) -> o2.getBeforePositionRange().start - o1.getBeforePositionRange().start);
for (StructuralDiff rowDiff : diffs) {
@@ -154,7 +154,7 @@
&& rowDiff.getDiffType().equals(DiffTypeEnum.ADD)) {
Range beforePositionRange = rowDiff.getBeforePositionRange();
// modify row indexes regarding the inserted rows
- Map<Object, RowInsertDataChange> modifiedRows = new HashMap<Object, RowInsertDataChange>();
+ Map<Object, RowInsertDataChange> modifiedRows = new HashMap<>();
for (Map.Entry<Object, RowInsertDataChange> entry : this.dataChanges.entrySet()) {
int rowIndex = this.keyHandler.getRowIndex(entry.getKey());
@@ -203,7 +203,7 @@
synchronized (this.dataChanges) {
if (event instanceof KeyRowInsertEvent) {
KeyRowInsertEvent e = (KeyRowInsertEvent) event;
- List<Object> keys = new ArrayList<Object>(e.getKeys());
+ List<Object> keys = new ArrayList<>(e.getKeys());
Collections.reverse(keys);
for (Object key : keys) {
// store the change locally
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/TemporaryUpdateDataChangeHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/TemporaryUpdateDataChangeHandler.java
index 0a7c562..97fd48e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/TemporaryUpdateDataChangeHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/TemporaryUpdateDataChangeHandler.java
@@ -43,7 +43,7 @@
* for a specific key.
*/
public TemporaryUpdateDataChangeHandler(DataChangeLayer layer, CellKeyHandler<?> keyHandler) {
- super(layer, keyHandler, new ConcurrentHashMap<Object, TemporaryUpdateDataChange>());
+ super(layer, keyHandler, new ConcurrentHashMap<>());
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/UpdateDataChangeHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/UpdateDataChangeHandler.java
index 7a1611f..3e997dd 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/UpdateDataChangeHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/UpdateDataChangeHandler.java
@@ -38,12 +38,12 @@
/**
* The column indexes of columns that contain dirty cells.
*/
- protected final Set<Integer> changedColumns = new HashSet<Integer>();
+ protected final Set<Integer> changedColumns = new HashSet<>();
/**
* The row indexes of rows that contain dirty cells.
*/
- protected final Set<Integer> changedRows = new HashSet<Integer>();
+ protected final Set<Integer> changedRows = new HashSet<>();
/**
* Flag to configure if the tracked changes in the {@link DataChangeLayer}
@@ -67,6 +67,8 @@
* @param keyHandler
* The {@link CellKeyHandler} that is used to store data changes
* for a specific key.
+ * @param dataChanges
+ * The map to track the data changes locally.
*/
public UpdateDataChangeHandler(DataChangeLayer layer, CellKeyHandler<?> keyHandler, Map<Object, T> dataChanges) {
super(layer, keyHandler, dataChanges);
@@ -113,10 +115,10 @@
private void handleRowDelete(Collection<StructuralDiff> rowDiffs) {
// for correct calculation the diffs need to be processed from lowest
// position to highest
- List<StructuralDiff> diffs = new ArrayList<StructuralDiff>(rowDiffs);
+ List<StructuralDiff> diffs = new ArrayList<>(rowDiffs);
Collections.sort(diffs, (o1, o2) -> o1.getBeforePositionRange().start - o2.getBeforePositionRange().start);
- List<Integer> toRemove = new ArrayList<Integer>();
+ List<Integer> toRemove = new ArrayList<>();
for (StructuralDiff rowDiff : diffs) {
if (rowDiff.getDiffType() != null
&& rowDiff.getDiffType().equals(DiffTypeEnum.DELETE)) {
@@ -132,7 +134,7 @@
if (!toRemove.isEmpty()) {
// modify row indexes regarding the deleted rows
- Map<Object, T> modifiedRows = new HashMap<Object, T>();
+ Map<Object, T> modifiedRows = new HashMap<>();
for (Map.Entry<Object, T> entry : this.dataChanges.entrySet()) {
int rowIndex = this.keyHandler.getRowIndex(entry.getKey());
if (!toRemove.contains(rowIndex)) {
@@ -198,7 +200,7 @@
private void handleRowInsert(Collection<StructuralDiff> rowDiffs) {
// for correct calculation the diffs need to be processed from highest
// position to lowest
- List<StructuralDiff> diffs = new ArrayList<StructuralDiff>(rowDiffs);
+ List<StructuralDiff> diffs = new ArrayList<>(rowDiffs);
Collections.sort(diffs, (o1, o2) -> o2.getBeforePositionRange().start - o1.getBeforePositionRange().start);
for (StructuralDiff rowDiff : diffs) {
@@ -206,7 +208,7 @@
&& rowDiff.getDiffType().equals(DiffTypeEnum.ADD)) {
Range beforePositionRange = rowDiff.getBeforePositionRange();
// modify row indexes regarding the inserted rows
- Map<Object, T> modifiedRows = new HashMap<Object, T>();
+ Map<Object, T> modifiedRows = new HashMap<>();
for (Map.Entry<Object, T> entry : this.dataChanges.entrySet()) {
int rowIndex = this.keyHandler.getRowIndex(entry.getKey());
@@ -259,10 +261,10 @@
public void handleColumnDelete(Collection<StructuralDiff> columnDiffs) {
// for correct calculation the diffs need to be processed from lowest
// position to highest
- List<StructuralDiff> diffs = new ArrayList<StructuralDiff>(columnDiffs);
+ List<StructuralDiff> diffs = new ArrayList<>(columnDiffs);
Collections.sort(diffs, (o1, o2) -> o1.getBeforePositionRange().start - o2.getBeforePositionRange().start);
- List<Integer> toRemove = new ArrayList<Integer>();
+ List<Integer> toRemove = new ArrayList<>();
for (StructuralDiff columnDiff : diffs) {
if (columnDiff.getDiffType() != null
&& columnDiff.getDiffType().equals(DiffTypeEnum.DELETE)) {
@@ -279,7 +281,7 @@
// only perform modifications if items where deleted
if (!toRemove.isEmpty()) {
// modify column indexes regarding the deleted column
- Map<Object, T> modifiedColumns = new HashMap<Object, T>();
+ Map<Object, T> modifiedColumns = new HashMap<>();
for (Map.Entry<Object, T> entry : this.dataChanges.entrySet()) {
int columnIndex = this.keyHandler.getColumnIndex(entry.getKey());
if (!toRemove.contains(columnIndex)) {
@@ -343,7 +345,7 @@
public void handleColumnInsert(Collection<StructuralDiff> columnDiffs) {
// for correct calculation the diffs need to be processed from highest
// position to lowest
- List<StructuralDiff> diffs = new ArrayList<StructuralDiff>(columnDiffs);
+ List<StructuralDiff> diffs = new ArrayList<>(columnDiffs);
Collections.sort(diffs, (o1, o2) -> o2.getBeforePositionRange().start - o1.getBeforePositionRange().start);
for (StructuralDiff columnDiff : diffs) {
@@ -351,7 +353,7 @@
&& columnDiff.getDiffType().equals(DiffTypeEnum.ADD)) {
Range beforePositionRange = columnDiff.getBeforePositionRange();
// modify column indexes regarding the inserted columns
- Map<Object, T> modifiedColumns = new HashMap<Object, T>();
+ Map<Object, T> modifiedColumns = new HashMap<>();
for (Map.Entry<Object, T> entry : this.dataChanges.entrySet()) {
int columnIndex = this.keyHandler.getColumnIndex(entry.getKey());
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/command/KeyRowInsertCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/command/KeyRowInsertCommandHandler.java
index 7fc43d3..2b18563 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/command/KeyRowInsertCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/command/KeyRowInsertCommandHandler.java
@@ -69,7 +69,7 @@
this.bodyData.addAll(command.getObjects());
- List<Object> keys = new ArrayList<Object>();
+ List<Object> keys = new ArrayList<>();
for (int i = 0; i < command.getObjects().size(); i++) {
keys.add(this.keyHandler.getKey(-1, start + i));
}
@@ -83,7 +83,7 @@
} else {
this.bodyData.addAll(command.getRowIndex(), command.getObjects());
- List<Object> keys = new ArrayList<Object>();
+ List<Object> keys = new ArrayList<>();
for (int i = 0; i < command.getObjects().size(); i++) {
keys.add(this.keyHandler.getKey(-1, command.getRowIndex() + i));
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/event/KeyRowInsertEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/event/KeyRowInsertEvent.java
index 7cc8fbe..95472ec 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/event/KeyRowInsertEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/datachange/event/KeyRowInsertEvent.java
@@ -31,7 +31,7 @@
*/
public class KeyRowInsertEvent extends RowInsertEvent {
- private final List<Object> keys = new ArrayList<Object>();
+ private final List<Object> keys = new ArrayList<>();
private final CellKeyHandler<?> keyHandler;
/**
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConfigAttributes.java
index 970aa6d..80845eb 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConfigAttributes.java
@@ -27,19 +27,23 @@
/**
* The configuration attributes for configuring editing behavior.
*/
-public interface EditConfigAttributes {
+public final class EditConfigAttributes {
+
+ private EditConfigAttributes() {
+ // private default constructor for constants class
+ }
/**
* The configuration attribute for the {@link IEditableRule} that is used to
* determine whether a cell is editable or not.
*/
- public static final ConfigAttribute<IEditableRule> CELL_EDITABLE_RULE = new ConfigAttribute<IEditableRule>();
+ public static final ConfigAttribute<IEditableRule> CELL_EDITABLE_RULE = new ConfigAttribute<>();
/**
* The configuration attribute for the {@link ICellEditor} that should be
* used for editing a cell value.
*/
- public static final ConfigAttribute<ICellEditor> CELL_EDITOR = new ConfigAttribute<ICellEditor>();
+ public static final ConfigAttribute<ICellEditor> CELL_EDITOR = new ConfigAttribute<>();
/**
* The configuration attribute to register the {@link IDataValidator} that
@@ -48,19 +52,19 @@
* might also be used without editing, e.g. converting a date for correct
* display.
*/
- public static final ConfigAttribute<IDataValidator> DATA_VALIDATOR = new ConfigAttribute<IDataValidator>();
+ public static final ConfigAttribute<IDataValidator> DATA_VALIDATOR = new ConfigAttribute<>();
/**
* The configuration attribute for the {@link IEditErrorHandler} that should
* be used for conversion failure handling.
*/
- public static final ConfigAttribute<IEditErrorHandler> CONVERSION_ERROR_HANDLER = new ConfigAttribute<IEditErrorHandler>();
+ public static final ConfigAttribute<IEditErrorHandler> CONVERSION_ERROR_HANDLER = new ConfigAttribute<>();
/**
* The configuration attribute for the {@link IEditErrorHandler} that should
* be used for validation failure handling.
*/
- public static final ConfigAttribute<IEditErrorHandler> VALIDATION_ERROR_HANDLER = new ConfigAttribute<IEditErrorHandler>();
+ public static final ConfigAttribute<IEditErrorHandler> VALIDATION_ERROR_HANDLER = new ConfigAttribute<>();
/**
* The configuration attribute for the style that should be used on just in
@@ -70,7 +74,7 @@
* TextCellEditor in combination with the RenderErrorHandling for just in
* time conversion error rendering.
*/
- public static final ConfigAttribute<IStyle> CONVERSION_ERROR_STYLE = new ConfigAttribute<IStyle>();
+ public static final ConfigAttribute<IStyle> CONVERSION_ERROR_STYLE = new ConfigAttribute<>();
/**
* The configuration attribute for the style that should be used on just in
@@ -80,7 +84,7 @@
* TextCellEditor in combination with the RenderErrorHandling for just in
* time validation error rendering.
*/
- public static final ConfigAttribute<IStyle> VALIDATION_ERROR_STYLE = new ConfigAttribute<IStyle>();
+ public static final ConfigAttribute<IStyle> VALIDATION_ERROR_STYLE = new ConfigAttribute<>();
/**
* The configuration attribute to specify if cell editors should be opened
@@ -90,7 +94,7 @@
* @see ICellEditor#openInline(IConfigRegistry configRegistry, List
* configLabels)
*/
- public static final ConfigAttribute<Boolean> OPEN_IN_DIALOG = new ConfigAttribute<Boolean>();
+ public static final ConfigAttribute<Boolean> OPEN_IN_DIALOG = new ConfigAttribute<>();
/**
* The configuration attribute to specify behavior after committing a value
@@ -101,7 +105,7 @@
* registered, the default value used is <code>false</code> as this is the
* default behavior prior to this.
*/
- public static final ConfigAttribute<Boolean> OPEN_ADJACENT_EDITOR = new ConfigAttribute<Boolean>();
+ public static final ConfigAttribute<Boolean> OPEN_ADJACENT_EDITOR = new ConfigAttribute<>();
/**
* The configuration attribute to specify whether an editor should be
@@ -112,7 +116,7 @@
*
* @see EditConfigAttributes#OPEN_ADJACENT_EDITOR
*/
- public static final ConfigAttribute<Boolean> ACTIVATE_EDITOR_ON_TRAVERSAL = new ConfigAttribute<Boolean>();
+ public static final ConfigAttribute<Boolean> ACTIVATE_EDITOR_ON_TRAVERSAL = new ConfigAttribute<>();
/**
* The configuration attribute to specify whether an editor supports multi
@@ -124,7 +128,7 @@
* conditional validation, where a value is validated against another value
* in the data model.
*/
- public static final ConfigAttribute<Boolean> SUPPORT_MULTI_EDIT = new ConfigAttribute<Boolean>();
+ public static final ConfigAttribute<Boolean> SUPPORT_MULTI_EDIT = new ConfigAttribute<>();
/**
* The configuration attribute to specify custom dialog settings for edit
@@ -140,5 +144,5 @@
* @see ICellEditDialog#DIALOG_SHELL_RESIZABLE
* @see ICellEditDialog#DIALOG_MESSAGE
*/
- public static final ConfigAttribute<Map<String, Object>> EDIT_DIALOG_SETTINGS = new ConfigAttribute<Map<String, Object>>();
+ public static final ConfigAttribute<Map<String, Object>> EDIT_DIALOG_SETTINGS = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConfigHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConfigHelper.java
index 658adb8..ea80863 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConfigHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConfigHelper.java
@@ -24,11 +24,12 @@
/**
* Helper class that will retrieve edit configuration values out of the
* {@link IConfigRegistry}.
- *
- * @author Dirk Fauth
- *
*/
-public class EditConfigHelper {
+public final class EditConfigHelper {
+
+ private EditConfigHelper() {
+ // private default constructor for helper class
+ }
/**
* Searches for the registered {@link IEditErrorHandler} that should be used
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConstants.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConstants.java
index 0c5d33d..9622362 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConstants.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditConstants.java
@@ -16,14 +16,17 @@
* Definition of editing related constants.
*
* @since 1.4
- * @noextend This class is not intended to be subclassed by clients.
*/
-public interface EditConstants {
+public final class EditConstants {
+
+ private EditConstants() {
+ // private default constructor for constants class
+ }
/**
* Value constant that is used in conjunction with multi select combo boxes
* with checkboxes. Indicates that all values in the combo box are selected.
*/
- String SELECT_ALL_ITEMS_VALUE = "SELECT_ALL"; //$NON-NLS-1$
+ public static final String SELECT_ALL_ITEMS_VALUE = "SELECT_ALL"; //$NON-NLS-1$
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditController.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditController.java
index 0d29866..6cc9089 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditController.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/EditController.java
@@ -37,6 +37,10 @@
*/
public class EditController {
+ private EditController() {
+ // private default constructor for helper class
+ }
+
private static final Logger LOG = LoggerFactory.getLogger(EditController.class);
/**
@@ -122,7 +126,7 @@
layer.fireLayerEvent(new CellEditorCreatedEvent(cellEditor));
}
} else {
- List<ILayerCell> cells = new ArrayList<ILayerCell>();
+ List<ILayerCell> cells = new ArrayList<>();
cells.add(cell);
editCells(cells, parent, initialCanonicalValue, configRegistry);
}
@@ -191,7 +195,7 @@
if (returnValue == Window.OK) {
for (ILayerCell selectedCell : cells) {
Object editorValue = dialog.getCommittedValue();
- if (!(dialog.getEditType() == EditTypeEnum.SET)) {
+ if (dialog.getEditType() != EditTypeEnum.SET) {
editorValue = dialog.calculateValue(
selectedCell.getDataValue(),
editorValue);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/config/DialogErrorHandling.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/config/DialogErrorHandling.java
index d310f74..9e609f2 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/config/DialogErrorHandling.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/config/DialogErrorHandling.java
@@ -157,34 +157,37 @@
/**
* Shows a warning dialog if the conversion or the validation returned an
* error message. Otherwise nothing happens.
+ *
+ * @param dialogMessage
+ * the dialog message
+ * @param dialogTitle
+ * the dialog title
*/
protected void showWarningDialog(String dialogMessage, String dialogTitle) {
- if (!isWarningDialogActive()) {
+ if (!isWarningDialogActive() && dialogMessage != null) {
// conversion/validation failed - so open dialog with error message
- if (dialogMessage != null) {
- String[] buttonLabels = this.allowCommit ? new String[] { getChangeButtonLabel(), getDiscardButtonLabel(), getCommitButtonLabel() }
- : new String[] { getChangeButtonLabel(), getDiscardButtonLabel() };
+ String[] buttonLabels = this.allowCommit ? new String[] { getChangeButtonLabel(), getDiscardButtonLabel(), getCommitButtonLabel() }
+ : new String[] { getChangeButtonLabel(), getDiscardButtonLabel() };
- MessageDialog warningDialog = new MessageDialog(
- Display.getDefault().getActiveShell(),
- dialogTitle,
- null,
- dialogMessage,
- MessageDialog.WARNING,
- buttonLabels,
- 0);
+ MessageDialog warningDialog = new MessageDialog(
+ Display.getDefault().getActiveShell(),
+ dialogTitle,
+ null,
+ dialogMessage,
+ MessageDialog.WARNING,
+ buttonLabels,
+ 0);
- // if discard was selected close the editor
- int returnCode = warningDialog.open();
- if (returnCode == 1) {
- this.editor.close();
- }
- // if commit was selected, commit the value by skipping the
- // validation
- else if (returnCode == 2) {
- this.editor.commit(MoveDirectionEnum.NONE, true, true);
- }
+ // if discard was selected close the editor
+ int returnCode = warningDialog.open();
+ if (returnCode == 1) {
+ this.editor.close();
+ }
+ // if commit was selected, commit the value by skipping the
+ // validation
+ else if (returnCode == 2) {
+ this.editor.commit(MoveDirectionEnum.NONE, true, true);
}
}
}
@@ -200,13 +203,10 @@
// check if the current active shell is a conversion or validation
// failure warning dialog
Shell control = Display.getDefault().getActiveShell();
- if (control != null
+ return (control != null
&& (getConversionFailureShellTitle().equals(control.getText())
|| getValidationFailureShellTitle().equals(control.getText())
- || getFailureShellTitle().equals(control.getText()))) {
- return true;
- }
- return false;
+ || getFailureShellTitle().equals(control.getText())));
}
/**
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/AbstractCellEditor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/AbstractCellEditor.java
index 983099b..a9fa8ba 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/AbstractCellEditor.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/AbstractCellEditor.java
@@ -377,14 +377,10 @@
return committed;
}
- } catch (ConversionFailedException e) {
- // do nothing as exceptions caused by conversion are handled
- // already we just need this catch block for stopping the
- // process if conversion failed with an exception
- } catch (ValidationFailedException e) {
- // do nothing as exceptions caused by validation are handled
- // already we just need this catch block for stopping the
- // process if validation failed with an exception
+ } catch (ConversionFailedException | ValidationFailedException e) {
+ // do nothing as exceptions caused by conversion/validation are
+ // handled already we just need this catch block for stopping
+ // the process if conversion failed with an exception
} catch (Exception e) {
// if another exception occured that wasn't thrown by us, it
// should at least be logged without killing the whole
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/CheckBoxCellEditor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/CheckBoxCellEditor.java
index 363f854..619083e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/CheckBoxCellEditor.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/CheckBoxCellEditor.java
@@ -68,11 +68,9 @@
commit(MoveDirectionEnum.NONE, false);
- if (this.editMode == EditModeEnum.INLINE) {
+ if (this.editMode == EditModeEnum.INLINE && this.canvas != null && !this.canvas.isDisposed()) {
// Close editor so it will react to subsequent clicks on the cell
- if (this.canvas != null && !this.canvas.isDisposed()) {
- close();
- }
+ close();
}
return this.canvas;
@@ -103,7 +101,7 @@
if (value instanceof Boolean) {
this.checked = ((Boolean) value).booleanValue();
} else if (value instanceof String) {
- this.checked = Boolean.valueOf((String) value).booleanValue();
+ this.checked = Boolean.parseBoolean((String) value);
} else {
this.checked = false;
}
@@ -117,17 +115,17 @@
@Override
public Canvas createEditorControl(Composite parent) {
- final Canvas canvas = new Canvas(parent, SWT.NONE);
+ final Canvas checkboxCanvas = new Canvas(parent, SWT.NONE);
- canvas.addMouseListener(new MouseAdapter() {
+ checkboxCanvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
CheckBoxCellEditor.this.checked = !CheckBoxCellEditor.this.checked;
- canvas.redraw();
+ checkboxCanvas.redraw();
}
});
- return canvas;
+ return checkboxCanvas;
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/AbstractDialogCellEditor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/AbstractDialogCellEditor.java
index ac279b7..34a16c0 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/AbstractDialogCellEditor.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/AbstractDialogCellEditor.java
@@ -287,16 +287,10 @@
return committed;
}
- } catch (ConversionFailedException e) {
- // do nothing as exceptions caused by conversion are handled
- // already we just need this catch block for stopping the
- // process
- // if conversion failed with an exception
- } catch (ValidationFailedException e) {
- // do nothing as exceptions caused by validation are handled
- // already we just need this catch block for stopping the
- // process
- // if validation failed with an exception
+ } catch (ConversionFailedException | ValidationFailedException e) {
+ // do nothing as exceptions caused by conversion/validation are
+ // handled already we just need this catch block for stopping
+ // the process if conversion failed with an exception
} catch (Exception e) {
// if another exception occured that wasn't thrown by us, it
// should at least be logged without killing the whole
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/CellEditDialog.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/CellEditDialog.java
index 705d94e..a9a6281 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/CellEditDialog.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/CellEditDialog.java
@@ -135,7 +135,7 @@
shellTitle = settingsShellTitle;
}
Object settingsShellImage = this.editDialogSettings.get(DIALOG_SHELL_ICON);
- if (settingsShellImage != null && settingsShellImage instanceof Image) {
+ if (settingsShellImage instanceof Image) {
shellIcon = (Image) settingsShellImage;
}
}
@@ -152,7 +152,7 @@
protected Point getInitialLocation(Point initialSize) {
if (this.editDialogSettings != null) {
Object settingsLocation = this.editDialogSettings.get(DIALOG_SHELL_LOCATION);
- if (settingsLocation != null && settingsLocation instanceof Point) {
+ if (settingsLocation instanceof Point) {
return (Point) settingsLocation;
}
}
@@ -163,7 +163,7 @@
protected Point getInitialSize() {
if (this.editDialogSettings != null) {
Object settingsSize = this.editDialogSettings.get(DIALOG_SHELL_SIZE);
- if (settingsSize != null && settingsSize instanceof Point) {
+ if (settingsSize instanceof Point) {
return (Point) settingsSize;
}
}
@@ -297,7 +297,7 @@
// otherwise this configuration wouldn't have any effect.
if (this.editDialogSettings != null) {
Object settingsResizable = this.editDialogSettings.get(DIALOG_SHELL_RESIZABLE);
- if (settingsResizable != null && settingsResizable instanceof Boolean) {
+ if (settingsResizable instanceof Boolean) {
if ((Boolean) settingsResizable) {
setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.MAX | SWT.RESIZE | getDefaultOrientation());
} else {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/CellEditDialogFactory.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/CellEditDialogFactory.java
index 79f7e14..79ed4d2 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/CellEditDialogFactory.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/CellEditDialogFactory.java
@@ -27,7 +27,11 @@
* Factory to create {@link ICellEditDialog} instances that should be opened for
* editing cell values.
*/
-public class CellEditDialogFactory {
+public final class CellEditDialogFactory {
+
+ private CellEditDialogFactory() {
+ // private default constructor for helper class
+ }
/**
* Will determine and return the {@link ICellEditDialog} to open for editing
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/TickUpdateCellEditDialog.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/TickUpdateCellEditDialog.java
index 5daaed4..dbe0fdd 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/TickUpdateCellEditDialog.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/gui/TickUpdateCellEditDialog.java
@@ -206,19 +206,14 @@
int selectionIndex = TickUpdateCellEditDialog.this.updateCombo.getSelectionIndex();
if (TickUpdateCellEditDialog.this.useAdjustBy) {
- switch (selectionIndex) {
- case 1:
- TickUpdateCellEditDialog.this.editType = EditTypeEnum.ADJUST;
- break;
+ if (selectionIndex == 1) {
+ TickUpdateCellEditDialog.this.editType = EditTypeEnum.ADJUST;
}
} else {
- switch (selectionIndex) {
- case 1:
- TickUpdateCellEditDialog.this.editType = EditTypeEnum.INCREASE;
- break;
- case 2:
- TickUpdateCellEditDialog.this.editType = EditTypeEnum.DECREASE;
- break;
+ if (selectionIndex == 1) {
+ TickUpdateCellEditDialog.this.editType = EditTypeEnum.INCREASE;
+ } else if (selectionIndex == 2) {
+ TickUpdateCellEditDialog.this.editType = EditTypeEnum.DECREASE;
}
}
}
@@ -240,7 +235,7 @@
? 0
: (processValue instanceof Number)
? ((Number) processValue).doubleValue()
- : Double.valueOf((String) processValue).doubleValue());
+ : Double.parseDouble((String) processValue));
if (this.editType == EditTypeEnum.ADJUST) {
if (delta >= 0) {
this.editType = EditTypeEnum.INCREASE;
@@ -250,13 +245,11 @@
}
Object newValue = null;
- switch (this.editType) {
- case INCREASE:
- newValue = this.tickUpdateHandler.getIncrementedValue(currentValue, delta);
- break;
- case DECREASE:
- newValue = this.tickUpdateHandler.getDecrementedValue(currentValue, delta);
- break;
+ EditTypeEnum editType = this.editType;
+ if (editType == EditTypeEnum.INCREASE) {
+ newValue = this.tickUpdateHandler.getIncrementedValue(currentValue, delta);
+ } else if (editType == EditTypeEnum.DECREASE) {
+ newValue = this.tickUpdateHandler.getDecrementedValue(currentValue, delta);
}
try {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/export/ExportConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/export/ExportConfigAttributes.java
index cdc0e4a..ee3d524 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/export/ExportConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/export/ExportConfigAttributes.java
@@ -16,29 +16,29 @@
/**
* Configuration attributes that are used to configure the export functionality.
- *
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- *
*/
-public interface ExportConfigAttributes {
+public final class ExportConfigAttributes {
+
+ private ExportConfigAttributes() {
+ // private default constructor for constants class
+ }
/**
* The configuration attribute for specifying the concrete implementation
* instance of {@link ILayerExporter} that should be used for exporting the
* NatTable.
*/
- ConfigAttribute<ILayerExporter> EXPORTER = new ConfigAttribute<ILayerExporter>();
+ public static final ConfigAttribute<ILayerExporter> EXPORTER = new ConfigAttribute<>();
/**
* The configuration attribute for specifying a formatter that should be
* used to format the values for the export.
*/
- ConfigAttribute<IExportFormatter> EXPORT_FORMATTER = new ConfigAttribute<IExportFormatter>();
+ public static final ConfigAttribute<IExportFormatter> EXPORT_FORMATTER = new ConfigAttribute<>();
/**
* The configuration attribute for specifying the format that should be used
* for exporting Calendar or Date objects appropriately.
*/
- ConfigAttribute<String> DATE_FORMAT = new ConfigAttribute<String>();
+ public static final ConfigAttribute<String> DATE_FORMAT = new ConfigAttribute<>();
/**
* The configuration attribute for specifying the concrete implementation
* instance of ITableExporter that should be used for exporting the
@@ -46,5 +46,5 @@
*
* @since 1.5
*/
- ConfigAttribute<ITableExporter> TABLE_EXPORTER = new ConfigAttribute<ITableExporter>();
+ public static final ConfigAttribute<ITableExporter> TABLE_EXPORTER = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/FillHandleLayerPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/FillHandleLayerPainter.java
index 1f8b51a..c62bd79 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/FillHandleLayerPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/FillHandleLayerPainter.java
@@ -522,6 +522,9 @@
* @param configRegistry
* The {@link ConfigRegistry} to retrieve the style information
* from.
+ *
+ * @return the border style that should be used
+ *
* @since 1.6
*/
protected BorderStyle getCopyBorderStyle(IConfigRegistry configRegistry) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/command/FillHandlePasteCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/command/FillHandlePasteCommandHandler.java
index 221117b..ac123d5 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/command/FillHandlePasteCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/command/FillHandlePasteCommandHandler.java
@@ -156,11 +156,9 @@
// copy
if (diff != null) {
if (value instanceof Byte) {
- byte result = (byte) (((Byte) value).byteValue() + (Byte) diff);
- return result;
+ return (byte) (((Byte) value).byteValue() + (Byte) diff);
} else if (value instanceof Short) {
- short result = (short) (((Short) value).shortValue() + (Short) diff);
- return result;
+ return (short) (((Short) value).shortValue() + (Short) diff);
} else if (value instanceof Integer) {
return (Integer) value + (Integer) diff;
} else if (value instanceof Long) {
@@ -212,8 +210,7 @@
return null;
}
}
- byte result = (byte) (diff * rowDiff);
- return result;
+ return (byte) (diff * rowDiff);
} else if (type == Short.class) {
Short diff = calculateShortDiff(cells[1][columnArrayIndex], cells[0][columnArrayIndex]);
if (diff == null) {
@@ -226,8 +223,7 @@
return null;
}
}
- short result = (short) (diff * rowDiff);
- return result;
+ return (short) (diff * rowDiff);
} else if (type == Integer.class) {
Integer diff = calculateIntDiff(cells[1][columnArrayIndex], cells[0][columnArrayIndex]);
if (diff == null) {
@@ -345,8 +341,7 @@
return null;
}
}
- byte result = (byte) (diff * columnDiff);
- return result;
+ return (byte) (diff * columnDiff);
} else if (type == Short.class) {
Short diff = calculateShortDiff(cells[rowArrayIndex][1], cells[rowArrayIndex][0]);
if (diff == null) {
@@ -359,8 +354,7 @@
return null;
}
}
- short result = (short) (diff * columnDiff);
- return result;
+ return (short) (diff * columnDiff);
} else if (type == Integer.class) {
Integer diff = calculateIntDiff(cells[rowArrayIndex][1], cells[rowArrayIndex][0]);
if (diff == null) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/config/FillHandleConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/config/FillHandleConfigAttributes.java
index 31ed4ac..828ed51 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/config/FillHandleConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/fillhandle/config/FillHandleConfigAttributes.java
@@ -23,40 +23,41 @@
* This interface contains {@link ConfigAttribute}s that can be used to
* configure the fill handle behavior.
*
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- *
* @since 1.4
*/
-public interface FillHandleConfigAttributes {
+public final class FillHandleConfigAttributes {
+
+ private FillHandleConfigAttributes() {
+ // private default constructor for constants class
+ }
/**
* ConfigAttribute to configure the line style used to render a special
* border on dragging the fill handle.
*/
- ConfigAttribute<BorderStyle> FILL_HANDLE_REGION_BORDER_STYLE = new ConfigAttribute<BorderStyle>();
+ public static final ConfigAttribute<BorderStyle> FILL_HANDLE_REGION_BORDER_STYLE = new ConfigAttribute<>();
/**
* ConfigAttribute to configure the border style of the fill handle itself.
*/
- ConfigAttribute<BorderStyle> FILL_HANDLE_BORDER_STYLE = new ConfigAttribute<BorderStyle>();
+ public static final ConfigAttribute<BorderStyle> FILL_HANDLE_BORDER_STYLE = new ConfigAttribute<>();
/**
* ConfigAttribute to configure the color of the fill handle.
*/
- ConfigAttribute<Color> FILL_HANDLE_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> FILL_HANDLE_COLOR = new ConfigAttribute<>();
/**
* ConfigAttribute to configure the date field that should be incremented
* when inserting a series via fill handle. Fields from the {@link Calendar}
* class should be used for configuration.
*/
- ConfigAttribute<Integer> INCREMENT_DATE_FIELD = new ConfigAttribute<Integer>();
+ public static final ConfigAttribute<Integer> INCREMENT_DATE_FIELD = new ConfigAttribute<>();
/**
* ConfigAttribute to configure the directions that are allowed for the fill
* handle. If nothing is specified {@link Direction#BOTH} will be used
* implicitly.
*/
- ConfigAttribute<Direction> ALLOWED_FILL_DIRECTION = new ConfigAttribute<Direction>();
+ public static final ConfigAttribute<Direction> ALLOWED_FILL_DIRECTION = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/FilterRowDataProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/FilterRowDataProvider.java
index 320a2b9..28ddcc9 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/FilterRowDataProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/FilterRowDataProvider.java
@@ -93,7 +93,7 @@
* data storage for the set filters in the filter row so they are visible to
* the user who entered them.
*/
- private Map<Integer, Object> filterIndexToObjectMap = new HashMap<Integer, Object>();
+ private Map<Integer, Object> filterIndexToObjectMap = new HashMap<>();
/**
*
@@ -194,7 +194,7 @@
@Override
public void saveState(String prefix, Properties properties) {
- Map<Integer, String> filterTextByIndex = new HashMap<Integer, String>();
+ Map<Integer, String> filterTextByIndex = new HashMap<>();
for (Integer columnIndex : this.filterIndexToObjectMap.keySet()) {
final IDisplayConverter converter = this.configRegistry.getConfigAttribute(
CellConfigAttributes.DISPLAY_CONVERTER,
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/ParseResult.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/ParseResult.java
index a69a76c..3562582 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/ParseResult.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/ParseResult.java
@@ -56,7 +56,7 @@
}
return NONE;
}
- };
+ }
private MatchType matchType = MatchType.NONE;
private String valueToMatch;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterNatCombo.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterNatCombo.java
index 369dd49..36427df 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterNatCombo.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterNatCombo.java
@@ -72,7 +72,7 @@
* once it is created. Kept locally because the table creation is deferred
* to the first access.
*/
- private List<ICheckStateListener> checkStateListener = new ArrayList<ICheckStateListener>();
+ private List<ICheckStateListener> checkStateListener = new ArrayList<>();
/**
* Creates a new FilterNatCombo using the given IStyle for rendering,
@@ -335,7 +335,7 @@
});
final String selectAllLabel = Messages.getString("FilterNatCombo.selectAll"); //$NON-NLS-1$
- List<String> input = new ArrayList<String>();
+ List<String> input = new ArrayList<>();
input.add(selectAllLabel);
this.selectAllItemViewer.setInput(input);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterRowComboBoxDataProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterRowComboBoxDataProvider.java
index adfc310..6c812a1 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterRowComboBoxDataProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/combobox/FilterRowComboBoxDataProvider.java
@@ -73,11 +73,11 @@
* GlazedLists for example, the combobox would only contain the value which
* is currently used for filtering.
*/
- private final Map<Integer, List<?>> valueCache = new HashMap<Integer, List<?>>();
+ private final Map<Integer, List<?>> valueCache = new HashMap<>();
/**
* List of listeners that get informed if the value cache gets updated.
*/
- private List<IFilterRowComboUpdateListener> cacheUpdateListener = new ArrayList<IFilterRowComboUpdateListener>();
+ private List<IFilterRowComboUpdateListener> cacheUpdateListener = new ArrayList<>();
/**
* Flag to indicate whether the combo box content should be loaded lazily.
*
@@ -292,7 +292,7 @@
this.valueCacheLock.writeLock().lock();
try {
// remember the cache before updating
- Map<Integer, List<?>> cacheBefore = new HashMap<Integer, List<?>>(this.valueCache);
+ Map<Integer, List<?>> cacheBefore = new HashMap<>(this.valueCache);
// perform a refresh of the whole cache
this.valueCache.clear();
@@ -330,8 +330,8 @@
* <code>null</code> if nothing has changed.
*/
protected FilterRowComboUpdateEvent buildUpdateEvent(int columnIndex, List<?> cacheBefore, List<?> cacheAfter) {
- Set<Object> addedValues = new HashSet<Object>();
- Set<Object> removedValues = new HashSet<Object>();
+ Set<Object> addedValues = new HashSet<>();
+ Set<Object> removedValues = new HashSet<>();
// find the added values
if (cacheAfter != null && cacheBefore != null) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/DefaultFilterRowConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/DefaultFilterRowConfiguration.java
index 0fe0704..b63e551 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/DefaultFilterRowConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/DefaultFilterRowConfiguration.java
@@ -33,6 +33,8 @@
import org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher;
import org.eclipse.swt.SWT;
+//fields are public by design to make it easy for adapters to customize configuration
+@SuppressWarnings("java:S1104")
public class DefaultFilterRowConfiguration extends AbstractRegistryConfiguration {
public FilterRowPainter cellPainter = new FilterRowPainter();
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/FilterRowConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/FilterRowConfigAttributes.java
index 0e0d195..6638e51 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/FilterRowConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/config/FilterRowConfigAttributes.java
@@ -23,20 +23,24 @@
*
* @see DefaultFilterRowConfiguration
*/
-public interface FilterRowConfigAttributes {
+public final class FilterRowConfigAttributes {
- public static final ConfigAttribute<String> TEXT_DELIMITER = new ConfigAttribute<String>();
- public static final ConfigAttribute<TextMatchingMode> TEXT_MATCHING_MODE = new ConfigAttribute<TextMatchingMode>();
+ private FilterRowConfigAttributes() {
+ // private default constructor for constants class
+ }
+
+ public static final ConfigAttribute<String> TEXT_DELIMITER = new ConfigAttribute<>();
+ public static final ConfigAttribute<TextMatchingMode> TEXT_MATCHING_MODE = new ConfigAttribute<>();
/** Comparator to be used for threshold matching */
- public static final ConfigAttribute<Comparator<?>> FILTER_COMPARATOR = new ConfigAttribute<Comparator<?>>();
+ public static final ConfigAttribute<Comparator<?>> FILTER_COMPARATOR = new ConfigAttribute<>();
/**
* Display converter used to convert the string typed by the user to the
* data type of the column or in case of combo boxes to convert the filter
* object to string.
*/
- public static final ConfigAttribute<IDisplayConverter> FILTER_DISPLAY_CONVERTER = new ConfigAttribute<IDisplayConverter>();
+ public static final ConfigAttribute<IDisplayConverter> FILTER_DISPLAY_CONVERTER = new ConfigAttribute<>();
/**
* Display converter that is used for text filter operations to convert the
@@ -45,5 +49,5 @@
*
* @since 2.0
*/
- public static final ConfigAttribute<IDisplayConverter> FILTER_CONTENT_DISPLAY_CONVERTER = new ConfigAttribute<IDisplayConverter>();
+ public static final ConfigAttribute<IDisplayConverter> FILTER_CONTENT_DISPLAY_CONVERTER = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/FormulaParser.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/FormulaParser.java
index 2b9d764..86a53db 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/FormulaParser.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/FormulaParser.java
@@ -189,7 +189,7 @@
* of the parsed function string.
*/
public FunctionValue parseFunction(String function) {
- return parseFunction(function, new HashMap<Integer, FunctionValue>(), new LinkedHashMap<IndexCoordinate, Set<IndexCoordinate>>(), null);
+ return parseFunction(function, new HashMap<>(), new LinkedHashMap<>(), null);
}
/**
@@ -210,7 +210,7 @@
*/
protected FunctionValue parseFunction(String function,
Map<IndexCoordinate, Set<IndexCoordinate>> parsedReferences, IndexCoordinate referer) {
- return parseFunction(function, new HashMap<Integer, FunctionValue>(), parsedReferences, referer);
+ return parseFunction(function, new HashMap<>(), parsedReferences, referer);
}
/**
@@ -742,7 +742,7 @@
// avoid circular references
IndexCoordinate ref = new IndexCoordinate(column, row);
if (!parsedReferences.containsKey(ref)) {
- parsedReferences.put(ref, new HashSet<IndexCoordinate>());
+ parsedReferences.put(ref, new HashSet<>());
}
if (referer != null) {
parsedReferences.get(referer).add(ref);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/FormulaTooltipErrorReporter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/FormulaTooltipErrorReporter.java
index 275c5df..09aa461 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/FormulaTooltipErrorReporter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/FormulaTooltipErrorReporter.java
@@ -32,7 +32,7 @@
*/
public class FormulaTooltipErrorReporter extends NatTableContentTooltip implements FormulaErrorReporter {
- protected Map<IndexCoordinate, String> formulaErrors = new HashMap<IndexCoordinate, String>();
+ protected Map<IndexCoordinate, String> formulaErrors = new HashMap<>();
protected IUniqueIndexLayer bodyDataLayer;
/**
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/command/FormulaFillHandlePasteCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/command/FormulaFillHandlePasteCommandHandler.java
index defc77a..3df1211 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/command/FormulaFillHandlePasteCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/command/FormulaFillHandlePasteCommandHandler.java
@@ -82,8 +82,7 @@
}
cellValue = e.getErrorMarkup();
}
- } else if (cellValue != null
- && cellValue instanceof String
+ } else if (cellValue instanceof String
&& this.dataProvider.getFormulaParser().isNumber((String) cellValue)) {
final BigDecimal converted = this.dataProvider.getFormulaParser().convertToBigDecimal((String) cellValue);
ILayerCell temp = new LayerCell(cell.getLayer(),
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractFunction.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractFunction.java
index 35eabc3..08c13ce 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractFunction.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractFunction.java
@@ -25,7 +25,7 @@
protected List<FunctionValue> values;
public AbstractFunction() {
- this(new ArrayList<FunctionValue>());
+ this(new ArrayList<>());
}
public AbstractFunction(List<FunctionValue> values) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractMathSingleValueFunction.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractMathSingleValueFunction.java
index d357627..4a91a26 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractMathSingleValueFunction.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractMathSingleValueFunction.java
@@ -25,7 +25,7 @@
public abstract class AbstractMathSingleValueFunction extends AbstractMathFunction {
public AbstractMathSingleValueFunction() {
- this(new ArrayList<FunctionValue>());
+ this(new ArrayList<>());
}
public AbstractMathSingleValueFunction(FunctionValue value) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractSingleValueFunction.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractSingleValueFunction.java
index 7baee21..fd695bf 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractSingleValueFunction.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/AbstractSingleValueFunction.java
@@ -25,7 +25,7 @@
public abstract class AbstractSingleValueFunction extends AbstractFunction {
public AbstractSingleValueFunction() {
- this(new ArrayList<FunctionValue>());
+ this(new ArrayList<>());
}
public AbstractSingleValueFunction(FunctionValue value) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/ModFunction.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/ModFunction.java
index 0a1970c..63b1072 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/ModFunction.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/ModFunction.java
@@ -33,7 +33,7 @@
if (values.size() > 2) {
throw new FunctionException("#N/A", //$NON-NLS-1$
- Messages.getString("FormulaParser.error.wrongNumberOfArguments", new Object[] { 2, values.size() })); //$NON-NLS-1$
+ Messages.getString("FormulaParser.error.wrongNumberOfArguments", 2, values.size())); //$NON-NLS-1$
}
}
@@ -41,7 +41,7 @@
public BigDecimal getValue() {
if (this.values.size() != 2) {
throw new FunctionException("#N/A", //$NON-NLS-1$
- Messages.getString("FormulaParser.error.wrongNumberOfArguments", new Object[] { 2, this.values.size() })); //$NON-NLS-1$
+ Messages.getString("FormulaParser.error.wrongNumberOfArguments", 2, this.values.size())); //$NON-NLS-1$
}
BigDecimal number = convertValue(this.values.get(0).getValue());
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/MultipleValueFunctionValue.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/MultipleValueFunctionValue.java
index c56a05a..617ff79 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/MultipleValueFunctionValue.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/formula/function/MultipleValueFunctionValue.java
@@ -26,7 +26,7 @@
protected List<FunctionValue> values;
public MultipleValueFunctionValue() {
- this(new ArrayList<FunctionValue>());
+ this(new ArrayList<>());
}
public MultipleValueFunctionValue(List<FunctionValue> values) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/IFreezeConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/FreezeConfigAttributes.java
similarity index 74%
rename from org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/IFreezeConfigAttributes.java
rename to org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/FreezeConfigAttributes.java
index 04c793c..4e1ebdb 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/IFreezeConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/FreezeConfigAttributes.java
@@ -17,19 +17,25 @@
/**
* Configuration attributes for the freeze separator visualization.
+ *
+ * @since 2.0
*/
-public interface IFreezeConfigAttributes {
+public final class FreezeConfigAttributes {
+
+ private FreezeConfigAttributes() {
+ // private default constructor for constants class
+ }
/**
* Configuration attribute to configure the color of the separator line.
*/
- ConfigAttribute<Color> SEPARATOR_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> SEPARATOR_COLOR = new ConfigAttribute<>();
/**
* Configuration attribute to configure the width of the separator line.
*
* @since 1.6
*/
- ConfigAttribute<Integer> SEPARATOR_WIDTH = new ConfigAttribute<Integer>();
+ public static final ConfigAttribute<Integer> SEPARATOR_WIDTH = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/FreezeHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/FreezeHelper.java
index b70a374..d40f4b8 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/FreezeHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/FreezeHelper.java
@@ -36,7 +36,11 @@
* @see FreezeSelectionCommand
* @see UnFreezeGridCommand
*/
-public class FreezeHelper {
+public final class FreezeHelper {
+
+ private FreezeHelper() {
+ // private default constructor for helper class
+ }
/**
* Freezes the grid at the specified position. This method is for internal
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/event/FreezeEventHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/event/FreezeEventHandler.java
index fbc6ef1..e36141c 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/event/FreezeEventHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/event/FreezeEventHandler.java
@@ -20,6 +20,7 @@
import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEventHandler;
import org.eclipse.nebula.widgets.nattable.layer.event.IStructuralChangeEvent;
import org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff;
+import org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff.DiffTypeEnum;
public class FreezeEventHandler implements
ILayerEventHandler<IStructuralChangeEvent> {
@@ -47,31 +48,29 @@
int rightOffset = 0;
for (StructuralDiff columnDiff : columnDiffs) {
- switch (columnDiff.getDiffType()) {
- case ADD:
- Range afterPositionRange = columnDiff
- .getAfterPositionRange();
- if (afterPositionRange.start < topLeftPosition.columnPosition) {
- leftOffset += afterPositionRange.size();
- }
- if (afterPositionRange.start <= bottomRightPosition.columnPosition) {
- rightOffset += afterPositionRange.size();
- }
- break;
- case DELETE:
- Range beforePositionRange = columnDiff
- .getBeforePositionRange();
- if (beforePositionRange.start < topLeftPosition.columnPosition) {
- leftOffset -= Math.min(beforePositionRange.end,
- topLeftPosition.columnPosition + 1)
- - beforePositionRange.start;
- }
- if (beforePositionRange.start <= bottomRightPosition.columnPosition) {
- rightOffset -= Math.min(beforePositionRange.end,
- bottomRightPosition.columnPosition + 1)
- - beforePositionRange.start;
- }
- break;
+ DiffTypeEnum diffType = columnDiff.getDiffType();
+ if (diffType == DiffTypeEnum.ADD) {
+ Range afterPositionRange = columnDiff
+ .getAfterPositionRange();
+ if (afterPositionRange.start < topLeftPosition.columnPosition) {
+ leftOffset += afterPositionRange.size();
+ }
+ if (afterPositionRange.start <= bottomRightPosition.columnPosition) {
+ rightOffset += afterPositionRange.size();
+ }
+ } else if (diffType == DiffTypeEnum.DELETE) {
+ Range beforePositionRange = columnDiff
+ .getBeforePositionRange();
+ if (beforePositionRange.start < topLeftPosition.columnPosition) {
+ leftOffset -= Math.min(beforePositionRange.end,
+ topLeftPosition.columnPosition + 1)
+ - beforePositionRange.start;
+ }
+ if (beforePositionRange.start <= bottomRightPosition.columnPosition) {
+ rightOffset -= Math.min(beforePositionRange.end,
+ bottomRightPosition.columnPosition + 1)
+ - beforePositionRange.start;
+ }
}
}
@@ -85,31 +84,29 @@
int rightOffset = 0;
for (StructuralDiff rowDiff : rowDiffs) {
- switch (rowDiff.getDiffType()) {
- case ADD:
- Range afterPositionRange = rowDiff
- .getAfterPositionRange();
- if (afterPositionRange.start < topLeftPosition.rowPosition) {
- leftOffset += afterPositionRange.size();
- }
- if (afterPositionRange.start <= bottomRightPosition.rowPosition) {
- rightOffset += afterPositionRange.size();
- }
- break;
- case DELETE:
- Range beforePositionRange = rowDiff
- .getBeforePositionRange();
- if (beforePositionRange.start < topLeftPosition.rowPosition) {
- leftOffset -= Math.min(beforePositionRange.end,
- topLeftPosition.rowPosition + 1)
- - beforePositionRange.start;
- }
- if (beforePositionRange.start <= bottomRightPosition.rowPosition) {
- rightOffset -= Math.min(beforePositionRange.end,
- bottomRightPosition.rowPosition + 1)
- - beforePositionRange.start;
- }
- break;
+ DiffTypeEnum diffType = rowDiff.getDiffType();
+ if (diffType == DiffTypeEnum.ADD) {
+ Range afterPositionRange = rowDiff
+ .getAfterPositionRange();
+ if (afterPositionRange.start < topLeftPosition.rowPosition) {
+ leftOffset += afterPositionRange.size();
+ }
+ if (afterPositionRange.start <= bottomRightPosition.rowPosition) {
+ rightOffset += afterPositionRange.size();
+ }
+ } else if (diffType == DiffTypeEnum.DELETE) {
+ Range beforePositionRange = rowDiff
+ .getBeforePositionRange();
+ if (beforePositionRange.start < topLeftPosition.rowPosition) {
+ leftOffset -= Math.min(beforePositionRange.end,
+ topLeftPosition.rowPosition + 1)
+ - beforePositionRange.start;
+ }
+ if (beforePositionRange.start <= bottomRightPosition.rowPosition) {
+ rightOffset -= Math.min(beforePositionRange.end,
+ bottomRightPosition.rowPosition + 1)
+ - beforePositionRange.start;
+ }
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/GridRegion.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/GridRegion.java
index 9d5cc44..0c4043b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/GridRegion.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/GridRegion.java
@@ -19,7 +19,11 @@
* For example all the cells in the column header are painted differently and
* can respond to sorting actions.
*/
-public interface GridRegion {
+public final class GridRegion {
+
+ private GridRegion() {
+ // private default constructor for constants class
+ }
public static final String CORNER = "CORNER"; //$NON-NLS-1$
public static final String COLUMN_HEADER = "COLUMN_HEADER"; //$NON-NLS-1$
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/command/AutoResizeColumnCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/command/AutoResizeColumnCommandHandler.java
index 988fd38..bc470d8 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/command/AutoResizeColumnCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/command/AutoResizeColumnCommandHandler.java
@@ -96,7 +96,7 @@
// only perform further actions if the widths could be calculated
// could fail and return null for example if the GCFactory fails
- if (gridColumnWidths != null) {
+ if (gridColumnWidths != null && gridColumnWidths.length > 0) {
this.commandLayer.doCommand(
new MultiColumnResizeCommand(this.commandLayer, gridColumnPositions, gridColumnWidths, true));
targetLayer.doCommand(new TurnViewportOnCommand());
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/command/AutoResizeRowCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/command/AutoResizeRowCommandHandler.java
index 8788e2d..7cda60d 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/command/AutoResizeRowCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/command/AutoResizeRowCommandHandler.java
@@ -93,7 +93,7 @@
// only perform further actions if the heights could be calculated
// could fail and return null for example if the GCFactory fails
- if (gridRowHeights != null) {
+ if (gridRowHeights != null && gridRowHeights.length > 0) {
this.commandLayer.doCommand(
new MultiRowResizeCommand(this.commandLayer, gridRowPositions, gridRowHeights, true));
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DefaultBodyDataProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DefaultBodyDataProvider.java
index 7675b96..6e2253a 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DefaultBodyDataProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DefaultBodyDataProvider.java
@@ -20,7 +20,7 @@
public class DefaultBodyDataProvider<T> extends ListDataProvider<T> {
public DefaultBodyDataProvider(List<T> rowData, String[] propertyNames) {
- super(rowData, new ReflectiveColumnPropertyAccessor<T>(propertyNames));
+ super(rowData, new ReflectiveColumnPropertyAccessor<>(propertyNames));
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DefaultSummaryRowHeaderDataProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DefaultSummaryRowHeaderDataProvider.java
index 45f3673..fde30bd 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DefaultSummaryRowHeaderDataProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DefaultSummaryRowHeaderDataProvider.java
@@ -31,6 +31,8 @@
}
/**
+ * @param bodyDataProvider
+ * The data provider of the connected body region.
* @param summaryRowLabel
* label to display in the row header for the Summary Row
*/
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DummyBodyDataProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DummyBodyDataProvider.java
index 6b7da4c..8ff5dce 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DummyBodyDataProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DummyBodyDataProvider.java
@@ -24,7 +24,7 @@
private final int rowCount;
- private Map<Point, Object> values = new HashMap<Point, Object>();
+ private Map<Point, Object> values = new HashMap<>();
public DummyBodyDataProvider(int columnCount, int rowCount) {
this.columnCount = columnCount;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DummyModifiableBodyDataProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DummyModifiableBodyDataProvider.java
index 2a0c731..bbb152b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DummyModifiableBodyDataProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/data/DummyModifiableBodyDataProvider.java
@@ -24,7 +24,7 @@
private int rowCount;
- private Map<Point, Object> values = new HashMap<Point, Object>();
+ private Map<Point, Object> values = new HashMap<>();
public DummyModifiableBodyDataProvider(int columnCount, int rowCount) {
this.columnCount = columnCount;
@@ -47,6 +47,7 @@
* after using this method for refreshing the NatTable.
*
* @param columnCount
+ * The column count to use.
*/
public void setColumnCount(int columnCount) {
this.columnCount = columnCount;
@@ -58,6 +59,7 @@
* after using this method for refreshing the NatTable.
*
* @param rowCount
+ * The row count to use.
*/
public void setRowCount(int rowCount) {
this.rowCount = rowCount;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/ColumnHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/ColumnHeaderLayer.java
index a35aa3c..320b030 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/ColumnHeaderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/ColumnHeaderLayer.java
@@ -279,6 +279,8 @@
}
/**
+ * @param columnPosition
+ * the column position for which the original label is requested
* @return column header as defined by the data source
*/
public String getOriginalColumnLabel(int columnPosition) {
@@ -287,6 +289,8 @@
}
/**
+ * @param columnPosition
+ * the column position for which the renamed label is requested
* @return renamed column header if the column has been renamed, NULL
* otherwise
*/
@@ -296,6 +300,8 @@
}
/**
+ * @param columnIndex
+ * the column index for which the renamed label is requested
* @return renamed column header if the column has been renamed, NULL
* otherwise
*/
@@ -304,8 +310,10 @@
}
/**
- * @return TRUE if the column at the given index has been given a custom
- * name by the user.
+ * @param columnIndex
+ * the column index that should be checked
+ * @return <code>true</code> if the column at the given index has been given
+ * a custom name by the user.
*/
public boolean isColumnRenamed(int columnIndex) {
return this.renameColumnHelper.isColumnRenamed(columnIndex);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/DimensionallyDependentLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/DimensionallyDependentLayer.java
index e18a309..f7f47ef 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/DimensionallyDependentLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/DimensionallyDependentLayer.java
@@ -267,7 +267,7 @@
@Override
public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition) {
- Collection<ILayer> underlyingLayers = new HashSet<ILayer>();
+ Collection<ILayer> underlyingLayers = new HashSet<>();
underlyingLayers.add(this.baseLayer);
return underlyingLayers;
}
@@ -358,7 +358,7 @@
@Override
public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition) {
- Collection<ILayer> underlyingLayers = new HashSet<ILayer>();
+ Collection<ILayer> underlyingLayers = new HashSet<>();
underlyingLayers.add(this.baseLayer);
return underlyingLayers;
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/config/DefaultRowStyleConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/config/DefaultRowStyleConfiguration.java
index 37b72e7..df992a0 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/config/DefaultRowStyleConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/grid/layer/config/DefaultRowStyleConfiguration.java
@@ -26,6 +26,8 @@
* Sets up alternate row coloring. Applied by
* {@link DefaultGridLayerConfiguration}
*/
+// fields are public by design to make it easy for adapters to customize styling
+@SuppressWarnings("java:S1104")
public class DefaultRowStyleConfiguration extends AbstractRegistryConfiguration {
public Color evenRowBgColor = GUIHelper.COLOR_WIDGET_BACKGROUND;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupExpandCollapseLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupExpandCollapseLayer.java
index ca2f03b..3c46445 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupExpandCollapseLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupExpandCollapseLayer.java
@@ -65,7 +65,7 @@
IUniqueIndexLayer underlyingLayer = getUnderlyingLayer();
boolean isHiddeninUnderlyingLayer =
- ColumnGroupUtils.isColumnIndexHiddenInUnderLyingLayer(columnIndex, this, underlyingLayer);
+ ColumnGroupUtils.isColumnIndexHiddenInUnderLyingLayer(columnIndex, underlyingLayer);
if (isHiddeninUnderlyingLayer) {
return true;
@@ -75,7 +75,7 @@
ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
boolean isCollapsedAndStaticColumn = columnGroup != null
&& columnGroup.isCollapsed()
- && !ColumnGroupUtils.isStaticOrFirstVisibleColumn(columnIndex, underlyingLayer, underlyingLayer, model);
+ && !ColumnGroupUtils.isStaticOrFirstVisibleColumn(columnIndex, underlyingLayer, model);
if (isCollapsedAndStaticColumn) {
return true;
@@ -103,7 +103,7 @@
ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
if (columnGroup != null && columnGroup.isCollapsed()) {
- if (!ColumnGroupUtils.isStaticOrFirstVisibleColumn(columnIndex, underlyingLayer, underlyingLayer, model)) {
+ if (!ColumnGroupUtils.isStaticOrFirstVisibleColumn(columnIndex, underlyingLayer, model)) {
hiddenColumnIndexes.add(columnIndex);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupGroupHeaderLayer.java
index 097c1b7..fde422e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupGroupHeaderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupGroupHeaderLayer.java
@@ -47,6 +47,18 @@
private final ColumnGroupModel model;
private final ColumnGroupHeaderLayer columnGroupHeaderLayer;
+ /**
+ *
+ * @param columnGroupHeaderLayer
+ * The {@link ColumnGroupHeaderLayer} to stack on.
+ * @param selectionLayer
+ * unused
+ * @param columnGroupModel
+ * The {@link ColumnGroupModel} used to build the column groups.
+ *
+ * @deprecated Use constructor without SelectionLayer parameter
+ */
+ @Deprecated
public ColumnGroupGroupHeaderLayer(
ColumnGroupHeaderLayer columnGroupHeaderLayer,
SelectionLayer selectionLayer,
@@ -54,6 +66,21 @@
this(columnGroupHeaderLayer, selectionLayer, columnGroupModel, true);
}
+ /**
+ *
+ * @param columnGroupHeaderLayer
+ * The {@link ColumnGroupHeaderLayer} to stack on.
+ * @param selectionLayer
+ * unused
+ * @param columnGroupModel
+ * The {@link ColumnGroupModel} used to build the column groups.
+ * @param useDefaultConfiguration
+ * <code>true</code> if the default configuration should be
+ * applied, <code>false</code> if not.
+ *
+ * @deprecated Use constructor without SelectionLayer parameter
+ */
+ @Deprecated
public ColumnGroupGroupHeaderLayer(
ColumnGroupHeaderLayer columnGroupHeaderLayer,
SelectionLayer selectionLayer,
@@ -70,6 +97,48 @@
}
}
+ /**
+ *
+ * @param columnGroupHeaderLayer
+ * The {@link ColumnGroupHeaderLayer} to stack on.
+ * @param columnGroupModel
+ * The {@link ColumnGroupModel} used to build the column groups.
+ *
+ * @since 2.0
+ */
+ public ColumnGroupGroupHeaderLayer(
+ ColumnGroupHeaderLayer columnGroupHeaderLayer,
+ ColumnGroupModel columnGroupModel) {
+ this(columnGroupHeaderLayer, columnGroupModel, true);
+ }
+
+ /**
+ *
+ * @param columnGroupHeaderLayer
+ * The {@link ColumnGroupHeaderLayer} to stack on.
+ * @param columnGroupModel
+ * The {@link ColumnGroupModel} used to build the column groups.
+ * @param useDefaultConfiguration
+ * <code>true</code> if the default configuration should be
+ * applied, <code>false</code> if not.
+ *
+ * @since 2.0
+ */
+ public ColumnGroupGroupHeaderLayer(
+ ColumnGroupHeaderLayer columnGroupHeaderLayer,
+ ColumnGroupModel columnGroupModel,
+ boolean useDefaultConfiguration) {
+ super(columnGroupHeaderLayer);
+ this.columnGroupHeaderLayer = columnGroupHeaderLayer;
+ this.model = columnGroupModel;
+
+ registerCommandHandler(new ConfigureScalingCommandHandler(null, this.rowHeightConfig));
+
+ if (useDefaultConfiguration) {
+ addConfiguration(new DefaultColumnGroupHeaderLayerConfiguration(columnGroupModel));
+ }
+ }
+
// Vertical features
// Rows
@@ -244,7 +313,7 @@
*
* @param columnPosition
* position of any column belonging to the group
- *
+ * @return the column span
* @since 1.6
*/
public int getColumnSpan(int columnPosition) {
@@ -399,9 +468,6 @@
return this.model.isPartOfAGroup(bodyColumnIndex);
}
- /**
- * @see ColumnGroup#setUnbreakable(boolean)
- */
public void setGroupUnbreakable(int columnIndex) {
ColumnGroup columnGroup = this.model.getColumnGroupByIndex(columnIndex);
columnGroup.setUnbreakable(true);
@@ -424,8 +490,7 @@
labels.add(DefaultColumnGroupHeaderLayerConfiguration.GROUP_EXPANDED_CONFIG_TYPE);
// add the labels configured via IConfigLabelAccumulator
- if (getConfigLabelAccumulator() != null
- && getConfigLabelAccumulator() instanceof IConfigLabelProvider) {
+ if (getConfigLabelAccumulator() instanceof IConfigLabelProvider) {
labels.addAll(((IConfigLabelProvider) getConfigLabelAccumulator()).getProvidedLabels());
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupHeaderLayer.java
index f7fab7c..d1f9ad3 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupHeaderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupHeaderLayer.java
@@ -295,6 +295,7 @@
* @param columnPosition
* position of any column belonging to the group
*
+ * @return the column span
* @since 1.6
*/
public int getColumnSpan(int columnPosition) {
@@ -426,9 +427,6 @@
return this.model.isPartOfAGroup(bodyColumnIndex);
}
- /**
- * @see ColumnGroup#setUnbreakable(boolean)
- */
public void setGroupUnbreakable(int columnIndex) {
ColumnGroup columnGroup = this.model.getColumnGroupByIndex(columnIndex);
columnGroup.setUnbreakable(true);
@@ -468,8 +466,7 @@
labels.add(DefaultColumnGroupHeaderLayerConfiguration.GROUP_EXPANDED_CONFIG_TYPE);
// add the labels configured via IConfigLabelAccumulator
- if (getConfigLabelAccumulator() != null
- && getConfigLabelAccumulator() instanceof IConfigLabelProvider) {
+ if (getConfigLabelAccumulator() instanceof IConfigLabelProvider) {
labels.addAll(((IConfigLabelProvider) getConfigLabelAccumulator()).getProvidedLabels());
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupModel.java
index 29d9799..739249e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupModel.java
@@ -35,9 +35,9 @@
/** Column group header name to column indexes */
- private final List<ColumnGroup> columnGroups = new LinkedList<ColumnGroup>();
+ private final List<ColumnGroup> columnGroups = new LinkedList<>();
- private final Collection<IColumnGroupModelListener> listeners = new HashSet<IColumnGroupModelListener>();
+ private final Collection<IColumnGroupModelListener> listeners = new HashSet<>();
private boolean defaultCollapseable = true;
@@ -65,7 +65,7 @@
// if this columnGroup has members, continue without saving state.
// A group can haven no members if groups are used to organize
// columns on a higher abstraction level ...
- if (columnGroup.members.size() == 0) {
+ if (columnGroup.members.isEmpty()) {
continue;
}
@@ -173,6 +173,10 @@
* Creates the column group if one does not exist with the given name and
* adds the column indexes to it.
*
+ * @param colGroupName
+ * The name of the column group.
+ * @param bodyColumnIndexs
+ * The column indexes that should be added to the group.
* @see #insertColumnIndexes(String, int[])
*/
public void addColumnsIndexesToGroup(String colGroupName, int... bodyColumnIndexs) {
@@ -197,7 +201,7 @@
* column group
*/
public boolean insertColumnIndexes(String colGroupName, int... columnIndexesToInsert) {
- LinkedList<Integer> members = new LinkedList<Integer>();
+ LinkedList<Integer> members = new LinkedList<>();
ColumnGroup columnGroup = getColumnGroupByName(colGroupName);
if (columnGroup.unbreakable) {
@@ -266,6 +270,7 @@
* @param colGroupName
* to add the indexes to
* @param staticColumnIndexes
+ * the column indexes that should be treated as static columns
*/
public void setStaticColumnIndexesByGroup(String colGroupName, int[] staticColumnIndexes) {
if (getColumnGroupByName(colGroupName) == null) {
@@ -285,10 +290,11 @@
* @param colGroupName
* to add the indexes to
* @param columnIndexesToInsert
+ * the column indexes that should be treated as static columns
*/
public void insertStaticColumnIndexes(String colGroupName, int... columnIndexesToInsert) {
- LinkedList<Integer> staticColumnIndexes = new LinkedList<Integer>();
+ LinkedList<Integer> staticColumnIndexes = new LinkedList<>();
ColumnGroup columnGroup = getColumnGroupByName(colGroupName);
// Check if any of the indexes belong to existing groups
@@ -344,7 +350,9 @@
}
/**
- * @return TRUE if a group by this name exists
+ * @param cellValue
+ * the name that should be checked
+ * @return <code>true</code> if a group by this name exists
*/
public boolean isAGroup(String cellValue) {
for (ColumnGroup columnGroup : this.columnGroups) {
@@ -370,14 +378,14 @@
* @return TRUE if no column groups exist
*/
public boolean isEmpty() {
- return this.columnGroups.size() == 0;
+ return this.columnGroups.isEmpty();
}
/**
* @return all the indexes which belong to groups
*/
public List<Integer> getAllIndexesInGroups() {
- List<Integer> indexes = new LinkedList<Integer>();
+ List<Integer> indexes = new LinkedList<>();
for (ColumnGroup columnGroup : this.columnGroups) {
indexes.addAll(columnGroup.members);
}
@@ -385,8 +393,11 @@
}
/**
- * @return TRUE if <code>bodyColumnIndex</code> is contained in the list of
- * static columns of the column group this index belongs to
+ * @param bodyColumnIndex
+ * the column index to check
+ * @return <code>true</code> if <code>bodyColumnIndex</code> is contained in
+ * the list of static columns of the column group this index belongs
+ * to
*/
public boolean isStaticColumn(int bodyColumnIndex) {
if (isPartOfAGroup(bodyColumnIndex)) {
@@ -412,6 +423,7 @@
/**
* @param bodyColumnIndex
+ * the column index to check
* @return The position of the index within the column group
*/
public int getColumnGroupPositionFromIndex(int bodyColumnIndex) {
@@ -522,10 +534,10 @@
public class ColumnGroup {
/** Body column indexes */
- private final LinkedList<Integer> members = new LinkedList<Integer>();
+ private final LinkedList<Integer> members = new LinkedList<>();
/** column indexes which remain visible when collapsing this group */
- private LinkedList<Integer> staticColumnIndexes = new LinkedList<Integer>();
+ private LinkedList<Integer> staticColumnIndexes = new LinkedList<>();
private String name;
@@ -591,7 +603,7 @@
public List<Integer> getMembersSorted() {
- List<Integer> sortedMembers = new LinkedList<Integer>(this.members);
+ List<Integer> sortedMembers = new LinkedList<>(this.members);
Collections.sort(sortedMembers);
return sortedMembers;
@@ -610,12 +622,16 @@
}
/**
- * @return TRUE if index successfully removed from its group.
+ * @param bodyColumnIndex
+ * the body column index that should be removed from its
+ * group.
+ * @return <code>true</code> if index successfully removed from its
+ * group.
*/
public boolean removeColumn(int bodyColumnIndex) {
if (this.members.contains(bodyColumnIndex) && !this.unbreakable) {
this.members.remove(Integer.valueOf(bodyColumnIndex));
- if (this.members.size() == 0) {
+ if (this.members.isEmpty()) {
ColumnGroupModel.this.columnGroups.remove(this);
}
notifyListeners();
@@ -636,7 +652,7 @@
@Override
public String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
buffer.append("Column Group Model:\n"); //$NON-NLS-1$
for (ColumnGroup columnGroup : this.columnGroups) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupReorderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupReorderLayer.java
index b68724a..ef1fa4c 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupReorderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupReorderLayer.java
@@ -131,7 +131,7 @@
public List<Integer> getColumnGroupPositions(int fromColumnIndex) {
List<Integer> fromColumnIndexes =
this.model.getColumnGroupByIndex(fromColumnIndex).getMembers();
- List<Integer> fromColumnPositions = new ArrayList<Integer>(fromColumnIndexes.size());
+ List<Integer> fromColumnPositions = new ArrayList<>(fromColumnIndexes.size());
for (Integer columnIndex : fromColumnIndexes) {
fromColumnPositions.add(
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupUtils.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupUtils.java
index 5c47737..a53e1cd 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/ColumnGroupUtils.java
@@ -29,7 +29,11 @@
import org.eclipse.nebula.widgets.nattable.layer.LayerUtil;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
-public class ColumnGroupUtils {
+public final class ColumnGroupUtils {
+
+ private ColumnGroupUtils() {
+ // private default constructor for helper class
+ }
/**
* Calculates the move direction based on the from and to position.
@@ -67,42 +71,110 @@
* column will be used.
*
* @param columnIndex
+ * The column index to check.
* @param layer
+ * unused
* @param underlyingLayer
+ * The underlying layer.
* @param model
+ * The column group model.
*
* @return <code>TRUE</code> if the given <code>columnIndex</code> is either
* a defined static column or (if not) the first visible column the
* it's group
+ *
+ * @deprecated Use
+ * {@link #isStaticOrFirstVisibleColumn(int, IUniqueIndexLayer, ColumnGroupModel)}
*/
+ @Deprecated
public static boolean isStaticOrFirstVisibleColumn(
int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) {
+ return isStaticOrFirstVisibleColumn(columnIndex, underlyingLayer, model);
+ }
+
+ /**
+ * Checks whether <code>columnIndex</code> is either a defined static column
+ * or (if not) the first visible column in the group containing group. This
+ * method provides downward compatibility for all group definitions without
+ * static columns. When no static columns are defined the first visible
+ * column will be used.
+ *
+ * @param columnIndex
+ * The column index to check.
+ * @param underlyingLayer
+ * The underlying layer.
+ * @param model
+ * The column group model.
+ *
+ * @return <code>TRUE</code> if the given <code>columnIndex</code> is either
+ * a defined static column or (if not) the first visible column the
+ * it's group
+ *
+ * @since 2.0
+ */
+ public static boolean isStaticOrFirstVisibleColumn(
+ int columnIndex, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) {
ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
- if (columnGroup.getStaticColumnIndexes().size() == 0) {
- return isFirstVisibleColumnIndexInGroup(columnIndex, layer, underlyingLayer, model);
+ if (columnGroup.getStaticColumnIndexes().isEmpty()) {
+ return isFirstVisibleColumnIndexInGroup(columnIndex, underlyingLayer, model);
} else {
return model.isStaticColumn(columnIndex);
}
}
+ /**
+ *
+ * @param columnIndex
+ * The column index to check.
+ * @param layer
+ * unused
+ * @param underlyingLayer
+ * The underlying layer.
+ * @param model
+ * The column group model.
+ * @return <code>true</code> if the given column index is the first column
+ * in a column group.
+ *
+ * @deprecated Use
+ * {@link #isFirstVisibleColumnIndexInGroup(int, IUniqueIndexLayer, ColumnGroupModel)}
+ */
+ @Deprecated
public static boolean isFirstVisibleColumnIndexInGroup(
int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) {
+ return isFirstVisibleColumnIndexInGroup(columnIndex, underlyingLayer, model);
+ }
- if (isColumnIndexHiddenInUnderLyingLayer(columnIndex, layer, underlyingLayer)) {
+ /**
+ *
+ * @param columnIndex
+ * The column index to check.
+ * @param underlyingLayer
+ * The underlying layer.
+ * @param model
+ * The column group model.
+ * @return <code>true</code> if the given column index is the first column
+ * in a column group.
+ *
+ * @since 2.0
+ */
+ public static boolean isFirstVisibleColumnIndexInGroup(
+ int columnIndex, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) {
+
+ if (isColumnIndexHiddenInUnderLyingLayer(columnIndex, underlyingLayer)) {
return false;
}
int columnPosition = underlyingLayer.getColumnPositionByIndex(columnIndex);
List<Integer> columnIndexesInGroup = model.getColumnGroupByIndex(columnIndex).getMembers();
- List<Integer> previousVisibleColumnIndexes = new ArrayList<Integer>();
+ List<Integer> previousVisibleColumnIndexes = new ArrayList<>();
// All other indexes in the column group which are visible and
// are positioned before me
for (Integer currentIndex : columnIndexesInGroup) {
int currentPosition = underlyingLayer.getColumnPositionByIndex(currentIndex.intValue());
- if (!isColumnIndexHiddenInUnderLyingLayer(currentIndex.intValue(), layer, underlyingLayer)
+ if (!isColumnIndexHiddenInUnderLyingLayer(currentIndex.intValue(), underlyingLayer)
&& currentPosition < columnPosition) {
previousVisibleColumnIndexes.add(currentIndex);
}
@@ -111,24 +183,94 @@
return previousVisibleColumnIndexes.isEmpty();
}
+ /**
+ *
+ * @param columnIndex
+ * The column index to check.
+ * @param layer
+ * unused
+ * @param underlyingLayer
+ * The underlying layer.
+ * @param model
+ * The column group model.
+ * @return <code>true</code> if the given column index is the last column in
+ * a column group.
+ *
+ * @deprecated Use
+ * {@link #isLastVisibleColumnIndexInGroup(int, IUniqueIndexLayer, ColumnGroupModel)}
+ */
+ @Deprecated
public static boolean isLastVisibleColumnIndexInGroup(
int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) {
+ return isLastVisibleColumnIndexInGroup(columnIndex, underlyingLayer, model);
+ }
- if (isColumnIndexHiddenInUnderLyingLayer(columnIndex, layer, underlyingLayer)) {
+ /**
+ *
+ * @param columnIndex
+ * The column index to check.
+ * @param underlyingLayer
+ * The underlying layer.
+ * @param model
+ * The column group model.
+ * @return <code>true</code> if the given column index is the last column in
+ * a column group.
+ *
+ * @since 2.0
+ */
+ public static boolean isLastVisibleColumnIndexInGroup(
+ int columnIndex, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) {
+
+ if (isColumnIndexHiddenInUnderLyingLayer(columnIndex, underlyingLayer)) {
return false;
}
- List<Integer> visibleIndexesToTheRight = getVisibleIndexesToTheRight(columnIndex, layer, underlyingLayer, model);
+ List<Integer> visibleIndexesToTheRight = getVisibleIndexesToTheRight(columnIndex, underlyingLayer, model);
return visibleIndexesToTheRight.size() == 1
&& visibleIndexesToTheRight.get(0).intValue() == columnIndex;
}
/**
- * Inclusive of the columnIndex passed as the parameter.
+ *
+ * @param columnIndex
+ * The index to check.
+ * @param layer
+ * unused
+ * @param underlyingLayer
+ * The underlying layer to retrieve the visible columns to the
+ * right.
+ * @param model
+ * The {@link ColumnGroupModel} to get the group from.
+ * @return The column indexes to the right of the given column index
+ * (inclusive)
+ *
+ * @deprecated Use
+ * {@link #getVisibleIndexesToTheRight(int, IUniqueIndexLayer, ColumnGroupModel)}
*/
+ @Deprecated
public static List<Integer> getVisibleIndexesToTheRight(
int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) {
+ return getVisibleIndexesToTheRight(columnIndex, underlyingLayer, model);
+ }
+
+ /**
+ *
+ * @param columnIndex
+ * The index to check.
+ * @param underlyingLayer
+ * The underlying layer to retrieve the visible columns to the
+ * right.
+ * @param model
+ * The {@link ColumnGroupModel} to get the group from.
+ * @return The column indexes to the right of the given column index
+ * (inclusive)
+ *
+ * @since 2.0
+ */
+ public static List<Integer> getVisibleIndexesToTheRight(
+ int columnIndex, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) {
+
ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
if (columnGroup.isCollapsed()) {
@@ -137,11 +279,11 @@
List<Integer> columnIndexesInGroup = columnGroup.getMembers();
int columnPosition = underlyingLayer.getColumnPositionByIndex(columnIndex);
- List<Integer> visibleColumnIndexesOnRight = new ArrayList<Integer>();
+ List<Integer> visibleColumnIndexesOnRight = new ArrayList<>();
for (Integer currentIndex : columnIndexesInGroup) {
int currentPosition = underlyingLayer.getColumnPositionByIndex(currentIndex.intValue());
- if (!isColumnIndexHiddenInUnderLyingLayer(currentIndex.intValue(), layer, underlyingLayer)
+ if (!isColumnIndexHiddenInUnderLyingLayer(currentIndex.intValue(), underlyingLayer)
&& currentPosition >= columnPosition) {
visibleColumnIndexesOnRight.add(currentIndex);
}
@@ -150,14 +292,74 @@
return visibleColumnIndexesOnRight;
}
+ /**
+ *
+ * @param columnIndex
+ * The column index to check.
+ * @param layer
+ * unused
+ * @param underlyingLayer
+ * The underlying layer to check against.
+ * @return <code>true</code> if the column is hidden in the underlying
+ * layer, <code>false</code> if not.
+ *
+ * @deprecated Use
+ * {@link #isColumnIndexHiddenInUnderLyingLayer(int, IUniqueIndexLayer)}
+ */
+ @Deprecated
public static boolean isColumnIndexHiddenInUnderLyingLayer(int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer) {
+ return isColumnIndexHiddenInUnderLyingLayer(columnIndex, underlyingLayer);
+ }
+
+ /**
+ *
+ * @param columnIndex
+ * The column index to check.
+ * @param underlyingLayer
+ * The underlying layer to check against.
+ * @return <code>true</code> if the column is hidden in the underlying
+ * layer, <code>false</code> if not.
+ *
+ * @since 2.0
+ */
+ public static boolean isColumnIndexHiddenInUnderLyingLayer(int columnIndex, IUniqueIndexLayer underlyingLayer) {
return underlyingLayer.getColumnPositionByIndex(columnIndex) == -1;
}
+ /**
+ *
+ * @param columnPosition
+ * The column position matching the underlying layer.
+ * @param layer
+ * unused
+ * @param underlyingLayer
+ * The underlying layer to check against.
+ * @return <code>true</code> if the column position is hidden in the
+ * underlying layer, <code>false</code> if not.
+ *
+ * @deprecated Use
+ * {@link #isColumnPositionHiddenInUnderLyingLayer(int, IUniqueIndexLayer)}
+ */
+ @Deprecated
public static boolean isColumnPositionHiddenInUnderLyingLayer(int columnPosition, ILayer layer, IUniqueIndexLayer underlyingLayer) {
+ return isColumnPositionHiddenInUnderLyingLayer(columnPosition, underlyingLayer);
+ }
+
+ /**
+ *
+ * @param columnPosition
+ * The column position matching the underlying layer.
+ * @param underlyingLayer
+ * The underlying layer to check against.
+ * @return <code>true</code> if the column position is hidden in the
+ * underlying layer, <code>false</code> if not.
+ *
+ * @since 2.0
+ */
+ public static boolean isColumnPositionHiddenInUnderLyingLayer(int columnPosition, IUniqueIndexLayer underlyingLayer) {
if (columnPosition < underlyingLayer.getColumnCount() && columnPosition >= 0) {
int columnIndex = underlyingLayer.getColumnIndexByPosition(columnPosition);
- return isColumnIndexHiddenInUnderLyingLayer(columnIndex, layer, underlyingLayer);
+ return isColumnIndexHiddenInUnderLyingLayer(columnIndex, underlyingLayer);
}
return true;
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupExpandCollapseLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupExpandCollapseLayer.java
index 6eab438..e6d9e64 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupExpandCollapseLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupExpandCollapseLayer.java
@@ -34,7 +34,7 @@
model.registerRowGroupModelListener(this);
- registerCommandHandler(new RowGroupExpandCollapseCommandHandler<T>(this));
+ registerCommandHandler(new RowGroupExpandCollapseCommandHandler<>(this));
}
public IRowGroupModel<T> getModel() {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderLayer.java
index 56badac..5455701 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupHeaderLayer.java
@@ -74,7 +74,7 @@
registerCommandHandlers();
if (useDefaultConfiguration) {
- addConfiguration(new DefaultRowGroupHeaderLayerConfiguration<T>());
+ addConfiguration(new DefaultRowGroupHeaderLayerConfiguration());
}
}
@@ -101,7 +101,7 @@
@Override
protected void registerCommandHandlers() {
- registerCommandHandler(new SelectRowGroupCommandHandler<T>(this.model, this.selectionLayer, this));
+ registerCommandHandler(new SelectRowGroupCommandHandler<>(this.model, this.selectionLayer, this));
registerCommandHandler(new ConfigureScalingCommandHandler(this.columnWidthConfig, null));
}
@@ -348,7 +348,7 @@
}
private List<Integer> convertToRowIndexes(final int[] rowPositions) {
- final List<Integer> rowIndexes = new ArrayList<Integer>(rowPositions.length);
+ final List<Integer> rowIndexes = new ArrayList<>(rowPositions.length);
for (final Integer rowPosition : rowPositions) {
rowIndexes.add(this.selectionLayer.getRowIndexByPosition(rowPosition));
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupUtils.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupUtils.java
index 19ce4d9..d1dc7b5 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/RowGroupUtils.java
@@ -39,7 +39,11 @@
* @author Matt Biggs
*
*/
-public class RowGroupUtils {
+public final class RowGroupUtils {
+
+ private RowGroupUtils() {
+ // private default constructor for helper class
+ }
public static <T> IRowGroup<T> getRowGroupForRowIndex(final IRowGroupModel<T> model, final int rowIndex) {
final T row = model.getRowFromIndexCache(rowIndex);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/command/ColumnGroupsCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/command/ColumnGroupsCommandHandler.java
index 513460c..f5904c4 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/command/ColumnGroupsCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/command/ColumnGroupsCommandHandler.java
@@ -108,7 +108,7 @@
}
protected void loadSelectedColumnsIndexesWithPositions() {
- this.columnIndexesToPositionsMap = new LinkedHashMap<Integer, Integer>();
+ this.columnIndexesToPositionsMap = new LinkedHashMap<>();
int[] fullySelectedColumns = this.selectionLayer.getFullySelectedColumnPositions();
if (fullySelectedColumns.length > 0) {
@@ -127,7 +127,7 @@
public void handleGroupColumnsCommand(String columnGroupName) {
try {
- Set<Integer> positions = new HashSet<Integer>();
+ Set<Integer> positions = new HashSet<>();
List<Integer> selectedPositions = null;
ColumnGroup group = this.model.getColumnGroupByName(columnGroupName);
@@ -139,9 +139,9 @@
positions.add(this.selectionLayer.getColumnPositionByIndex(pos));
}
positions.addAll(this.columnIndexesToPositionsMap.values());
- selectedPositions = new ArrayList<Integer>(positions);
+ selectedPositions = new ArrayList<>(positions);
} else {
- selectedPositions = new ArrayList<Integer>(this.columnIndexesToPositionsMap.values());
+ selectedPositions = new ArrayList<>(this.columnIndexesToPositionsMap.values());
}
Collections.sort(selectedPositions);
@@ -158,7 +158,8 @@
new MultiColumnReorderCommand(this.selectionLayer, selectedPositions, selectedPositions.get(0)));
this.model.addColumnsIndexesToGroup(columnGroupName, fullySelectedColumns);
this.selectionLayer.clear();
- } catch (Throwable t) {
+ } catch (Exception t) {
+ // do nothing
}
this.contextLayer.fireLayerEvent(new GroupColumnsEvent(this.contextLayer));
}
@@ -166,7 +167,7 @@
public void handleUngroupCommand() {
// Grab fully selected column positions
int[] fullySelectedColumns = this.selectionLayer.getFullySelectedColumnPositions();
- Map<String, Integer> toColumnPositions = new HashMap<String, Integer>();
+ Map<String, Integer> toColumnPositions = new HashMap<>();
if (fullySelectedColumns.length > 0) {
// Pick the ones which belong to a group and remove them from the
@@ -202,7 +203,7 @@
final int columnGroupSize = columnIndexesInGroup.size();
if (!toColumnPositions.containsKey(columnGroupName)) {
for (int colGroupIndex : columnIndexesInGroup) {
- if (ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(colGroupIndex, this.contextLayer, this.selectionLayer, this.model)) {
+ if (ColumnGroupUtils.isFirstVisibleColumnIndexInGroup(colGroupIndex, this.selectionLayer, this.model)) {
int toPosition = this.selectionLayer.getColumnPositionByIndex(colGroupIndex);
if (colGroupIndex == columnIndex) {
if (columnGroupSize == 1) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/command/ReorderColumnsAndGroupsCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/command/ReorderColumnsAndGroupsCommandHandler.java
index 9d4ee02..41344ea 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/command/ReorderColumnsAndGroupsCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/command/ReorderColumnsAndGroupsCommandHandler.java
@@ -44,10 +44,10 @@
protected boolean doCommand(ReorderColumnsAndGroupsCommand command) {
final ILayer underlyingLayer = this.columnGroupReorderLayer
.getUnderlyingLayer();
- List<String> groupsProcessed = new ArrayList<String>();
+ List<String> groupsProcessed = new ArrayList<>();
List<Integer> fromColumnPositions = command.getFromColumnPositions();
- List<Integer> fromColumnPositionsWithGroupColumns = new ArrayList<Integer>();
+ List<Integer> fromColumnPositionsWithGroupColumns = new ArrayList<>();
for (Integer fromColumnPosition : fromColumnPositions) {
int fromColumnIndex = underlyingLayer
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultRowGroupHeaderLayerConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultRowGroupHeaderLayerConfiguration.java
index 8e7c68c..3a69843 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultRowGroupHeaderLayerConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/config/DefaultRowGroupHeaderLayerConfiguration.java
@@ -28,7 +28,7 @@
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
import org.eclipse.swt.SWT;
-public class DefaultRowGroupHeaderLayerConfiguration<T> implements IConfiguration {
+public class DefaultRowGroupHeaderLayerConfiguration implements IConfiguration {
public static final String GROUP_COLLAPSED_CONFIG_TYPE = "GROUP_COLLAPSED"; //$NON-NLS-1$
public static final String GROUP_EXPANDED_CONFIG_TYPE = "GROUP_EXPANDED"; //$NON-NLS-1$
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/gui/CreateColumnGroupDialog.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/gui/CreateColumnGroupDialog.java
index b5d9cb0..7e72506 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/gui/CreateColumnGroupDialog.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/gui/CreateColumnGroupDialog.java
@@ -160,11 +160,6 @@
close();
}
- @Override
- public boolean close() {
- return super.close();
- }
-
private void doColumnGrouping() {
BusyIndicator.showWhile(super.getShell().getDisplay(), () -> {
final CreateColumnGroupCommand command = new CreateColumnGroupCommand(
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/IRowGroup.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/IRowGroup.java
index 0839f73..dfe11dc 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/IRowGroup.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/IRowGroup.java
@@ -21,6 +21,7 @@
* @author Stefan Bolton
*
* @param <T>
+ * the type of the row objects.
*/
public interface IRowGroup<T> {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/RowGroup.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/RowGroup.java
index 4997d16..bf952a5 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/RowGroup.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/RowGroup.java
@@ -24,6 +24,7 @@
* @author Stefan Bolton
*
* @param <T>
+ * the type of the row objects.
*/
public class RowGroup<T> implements IRowGroup<T> {
@@ -37,7 +38,7 @@
private final RowGroupModel<T> rowGroupModel;
// The rows and static rows in this group.
- private List<T> rowMembers;;
+ private List<T> rowMembers;
private List<T> staticRowMembers;
// A list of child groups.
@@ -72,7 +73,7 @@
.synchronizedList(new ArrayList<T>());
this.childGroups = Collections
.synchronizedList(new ArrayList<IRowGroup<T>>());
- this.data = new HashMap<String, Object>();
+ this.data = new HashMap<>();
}
@Override
@@ -171,8 +172,8 @@
// Bump row positions to compensate.
this.rowGroupModel.removeMemberRow(row);
- if ((getOwnMemberRows(false).size() == 0)
- && (getRowGroups().size() == 0)) {
+ if ((getOwnMemberRows(false).isEmpty())
+ && (getRowGroups().isEmpty())) {
// If there are no more member rows, then clean-up any
// static rows and remove the group from the model.
for (T staticRow : this.getOwnStaticMemberRows()) {
@@ -195,7 +196,7 @@
if (removed) {
// Remove empty child groups from the model.
- if (rowGroup.getOwnMemberRows(false).size() == 0) {
+ if (rowGroup.getOwnMemberRows(false).isEmpty()) {
this.childGroups.remove(rowGroup);
}
break;
@@ -293,7 +294,7 @@
*/
@Override
public List<T> getOwnMemberRows(final boolean includeStaticRows) {
- List<T> rows = new ArrayList<T>(this.rowMembers);
+ List<T> rows = new ArrayList<>(this.rowMembers);
if (includeStaticRows) {
rows.addAll(this.staticRowMembers);
@@ -336,7 +337,7 @@
@Override
public List<T> getMemberRows(final boolean includeStaticRows) {
- final List<T> memberRows = new ArrayList<T>();
+ final List<T> memberRows = new ArrayList<>();
// Return all the member rows from nested groups.
synchronized (this.childGroups) {
@@ -353,7 +354,7 @@
@Override
public List<T> getStaticMemberRows() {
- final List<T> staticMemberRows = new ArrayList<T>();
+ final List<T> staticMemberRows = new ArrayList<>();
// Return all the member rows from nested groups.
synchronized (this.childGroups) {
@@ -419,7 +420,7 @@
sb.append(String.format("*%s", row.toString())); //$NON-NLS-1$
}
- if (this.childGroups.size() > 0) {
+ if (!this.childGroups.isEmpty()) {
sb.append(String.format("Start Child Groups for [%s] :- \n", getGroupName())); //$NON-NLS-1$
for (final IRowGroup<T> rowGroup : this.childGroups) {
sb.append(rowGroup.toString());
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/RowGroupModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/RowGroupModel.java
index 50e64f3..aae3a9b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/RowGroupModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/model/RowGroupModel.java
@@ -32,6 +32,7 @@
* @author Stefan Bolton
*
* @param <T>
+ * the type of the row objects.
*/
public class RowGroupModel<T> implements IRowGroupModel<T> {
@@ -55,10 +56,10 @@
private boolean suppressNoficiations;
public RowGroupModel() {
- this.rowToGroups = new ConcurrentHashMap<T, IRowGroup<T>>();
- this.namesToGroups = new ConcurrentHashMap<String, IRowGroup<T>>();
- this.rowCache = new RowCache<T>();
- this.listeners = new HashSet<IRowGroupModelListener>();
+ this.rowToGroups = new ConcurrentHashMap<>();
+ this.namesToGroups = new ConcurrentHashMap<>();
+ this.rowCache = new RowCache<>();
+ this.listeners = new HashSet<>();
this.suppressNoficiations = false;
}
@@ -70,7 +71,7 @@
@Override
public int getIndexFromRowCache(final T row) {
return this.rowCache.getIndexFromRowCache(row);
- };
+ }
@Override
public void invalidateIndexCache() {
@@ -248,8 +249,8 @@
private final Map<E, Integer> rowsToIndexes;
public RowCache() {
- this.indexesToRows = new LinkedHashMap<Integer, E>();
- this.rowsToIndexes = new LinkedHashMap<E, Integer>();
+ this.indexesToRows = new LinkedHashMap<>();
+ this.rowsToIndexes = new LinkedHashMap<>();
}
public IRowDataProvider<E> getDataProvider() {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayer.java
index b87ca3f..ac322be 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/ColumnGroupHeaderLayer.java
@@ -156,7 +156,7 @@
/**
* Map in which it is stored if reordering is supported per level.
*/
- private Map<Integer, Boolean> reorderSupportedOnLevel = new HashMap<Integer, Boolean>();
+ private Map<Integer, Boolean> reorderSupportedOnLevel = new HashMap<>();
/**
* The {@link CompositeFreezeLayer} in case it is part of the layer
@@ -388,7 +388,7 @@
}
};
- this.model = new ArrayList<GroupModel>(numberOfGroupLevels);
+ this.model = new ArrayList<>(numberOfGroupLevels);
for (int i = 0; i < numberOfGroupLevels; i++) {
GroupModel groupModel = new GroupModel();
groupModel.setIndexPositionConverter(this.indexPositionConverter);
@@ -521,7 +521,7 @@
List<ILayer> findLayerPath(ILayer layer, int columnPosition) {
if (layer == getPositionLayer()) {
- List<ILayer> result = new ArrayList<ILayer>();
+ List<ILayer> result = new ArrayList<>();
result.add(layer);
return result;
}
@@ -664,7 +664,7 @@
// load the group model
groupModel.loadState(prefix + PERSISTENCE_KEY_COLUMN_GROUPS + "_" + level, properties); //$NON-NLS-1$
// trigger real collapse of collapsed groups in model
- List<Group> collapsedGroups = new ArrayList<Group>();
+ List<Group> collapsedGroups = new ArrayList<>();
for (Group group : groupModel.getGroups()) {
if (group.isCollapsed()) {
collapsedGroups.add(group);
@@ -1082,8 +1082,7 @@
if (posColumn > -1) {
GroupModel groupModel = getGroupModel(level);
if (groupModel != null) {
- Group group = groupModel.getGroupByPosition(posColumn);
- return group;
+ return groupModel.getGroupByPosition(posColumn);
}
}
return null;
@@ -2292,8 +2291,7 @@
labels.add(GroupHeaderConfigLabels.GROUP_EXPANDED_CONFIG_TYPE);
// add the labels configured via IConfigLabelAccumulator
- if (getConfigLabelAccumulator() != null
- && getConfigLabelAccumulator() instanceof IConfigLabelProvider) {
+ if (getConfigLabelAccumulator() instanceof IConfigLabelProvider) {
labels.addAll(((IConfigLabelProvider) getConfigLabelAccumulator()).getProvidedLabels());
}
@@ -2343,7 +2341,7 @@
updateVisibleStartPositions();
for (GroupModel groupModel : ColumnGroupHeaderLayer.this.model) {
- Map<Group, UpdateColumnGroupCollapseCommand> collapseUpdates = new HashMap<Group, UpdateColumnGroupCollapseCommand>();
+ Map<Group, UpdateColumnGroupCollapseCommand> collapseUpdates = new HashMap<>();
// find group and update visible span
for (int i = diff.getAfterPositionRange().start; i < diff.getAfterPositionRange().end; i++) {
@@ -2482,7 +2480,7 @@
// find the positions in the group
// that are hidden
- MutableIntList hiddenGroupPositions = groupPositions.select(groupPos -> groupPositionList.contains(groupPos));
+ MutableIntList hiddenGroupPositions = groupPositions.select(groupPositionList::contains);
// update the positionList as we
// handled the hidden columns
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/GroupModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/GroupModel.java
index 9941af4..8ea11f6 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/GroupModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/GroupModel.java
@@ -62,7 +62,7 @@
/**
* Collection of groups managed by this GroupModel.
*/
- private final List<Group> groups = new LinkedList<Group>();
+ private final List<Group> groups = new LinkedList<>();
/**
*
@@ -419,7 +419,7 @@
* @return The collection of {@link Group}s that have been modified.
*/
public Collection<Group> removePositionsFromGroup(int... positions) {
- Set<Group> changed = new HashSet<Group>();
+ Set<Group> changed = new HashSet<>();
Group group = null;
Arrays.sort(positions);
for (int i = positions.length - 1; i >= 0; i--) {
@@ -708,7 +708,7 @@
* {@link GroupModel}.
*/
public boolean isEmpty() {
- return this.groups.size() == 0;
+ return this.groups.isEmpty();
}
/**
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayer.java
index 6ccde6d..0e69fc8 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/RowGroupHeaderLayer.java
@@ -154,7 +154,7 @@
/**
* Map in which it is stored if reordering is supported per level.
*/
- private Map<Integer, Boolean> reorderSupportedOnLevel = new HashMap<Integer, Boolean>();
+ private Map<Integer, Boolean> reorderSupportedOnLevel = new HashMap<>();
/**
* The {@link CompositeFreezeLayer} in case it is part of the layer
@@ -382,7 +382,7 @@
}
};
- this.model = new ArrayList<GroupModel>(numberOfGroupLevels);
+ this.model = new ArrayList<>(numberOfGroupLevels);
for (int i = 0; i < numberOfGroupLevels; i++) {
GroupModel groupModel = new GroupModel();
groupModel.setIndexPositionConverter(this.indexPositionConverter);
@@ -514,7 +514,7 @@
List<ILayer> findLayerPath(ILayer layer, int rowPosition) {
if (layer == getPositionLayer()) {
- List<ILayer> result = new ArrayList<ILayer>();
+ List<ILayer> result = new ArrayList<>();
result.add(layer);
return result;
}
@@ -657,7 +657,7 @@
// load the group model
groupModel.loadState(prefix + PERSISTENCE_KEY_ROW_GROUPS + "_" + level, properties); //$NON-NLS-1$
// trigger real collapse of collapsed groups in model
- List<Group> collapsedGroups = new ArrayList<Group>();
+ List<Group> collapsedGroups = new ArrayList<>();
for (Group group : groupModel.getGroups()) {
if (group.isCollapsed()) {
collapsedGroups.add(group);
@@ -1075,8 +1075,7 @@
if (posRow > -1) {
GroupModel groupModel = getGroupModel(level);
if (groupModel != null) {
- Group group = groupModel.getGroupByPosition(posRow);
- return group;
+ return groupModel.getGroupByPosition(posRow);
}
}
return null;
@@ -2283,8 +2282,7 @@
labels.add(GroupHeaderConfigLabels.GROUP_EXPANDED_CONFIG_TYPE);
// add the labels configured via IConfigLabelAccumulator
- if (getConfigLabelAccumulator() != null
- && getConfigLabelAccumulator() instanceof IConfigLabelProvider) {
+ if (getConfigLabelAccumulator() instanceof IConfigLabelProvider) {
labels.addAll(((IConfigLabelProvider) getConfigLabelAccumulator()).getProvidedLabels());
}
@@ -2334,7 +2332,7 @@
updateVisibleStartPositions();
for (GroupModel groupModel : RowGroupHeaderLayer.this.model) {
- Map<Group, UpdateRowGroupCollapseCommand> collapseUpdates = new HashMap<Group, UpdateRowGroupCollapseCommand>();
+ Map<Group, UpdateRowGroupCollapseCommand> collapseUpdates = new HashMap<>();
// find group and update visible span
for (int i = diff.getAfterPositionRange().start; i < diff.getAfterPositionRange().end; i++) {
@@ -2473,7 +2471,7 @@
// find the positions in the group
// that are hidden
- MutableIntList hiddenGroupPositions = groupPositions.select(groupPos -> groupPositionList.contains(groupPos));
+ MutableIntList hiddenGroupPositions = groupPositions.select(groupPositionList::contains);
// update the positionList as we
// handled the hidden rows
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupCollapseCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupCollapseCommand.java
index 6234f10..9a46ae0 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupCollapseCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupCollapseCommand.java
@@ -38,12 +38,12 @@
public ColumnGroupCollapseCommand(GroupModel groupModel, Collection<Group> groups) {
this.groupModel = groupModel;
- this.groups = new ArrayList<Group>(groups);
+ this.groups = new ArrayList<>(groups);
}
protected ColumnGroupCollapseCommand(ColumnGroupCollapseCommand command) {
this.groupModel = command.groupModel;
- this.groups = new ArrayList<Group>(command.groups);
+ this.groups = new ArrayList<>(command.groups);
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupExpandCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupExpandCommand.java
index 66500fc..dda6c50 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupExpandCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupExpandCommand.java
@@ -38,12 +38,12 @@
public ColumnGroupExpandCommand(GroupModel groupModel, Collection<Group> groups) {
this.groupModel = groupModel;
- this.groups = new ArrayList<Group>(groups);
+ this.groups = new ArrayList<>(groups);
}
protected ColumnGroupExpandCommand(ColumnGroupExpandCommand command) {
this.groupModel = command.groupModel;
- this.groups = new ArrayList<Group>(command.groups);
+ this.groups = new ArrayList<>(command.groups);
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupsCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupsCommandHandler.java
index 24a11d9..5961902 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupsCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/ColumnGroupsCommandHandler.java
@@ -113,7 +113,7 @@
}
}
- HashSet<Group> existingGroups = new HashSet<Group>();
+ HashSet<Group> existingGroups = new HashSet<>();
for (MutableIntIterator it = positionsToGroup.intIterator(); it.hasNext();) {
int column = it.next();
Group group = model.getGroupByPosition(column);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/GroupMultiColumnReorderCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/GroupMultiColumnReorderCommandHandler.java
index 4aa91eb..ecec55f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/GroupMultiColumnReorderCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/GroupMultiColumnReorderCommandHandler.java
@@ -100,9 +100,7 @@
int toIndex = this.columnGroupHeaderLayer.getPositionLayer().getColumnIndexByPosition(toColumnPosition);
// expand all collapsed groups
- collapsed.forEach((model, collapsedGroups) -> {
- collapsedGroups.forEach(group -> this.columnGroupHeaderLayer.expandGroup(model, group));
- });
+ collapsed.forEach((model, collapsedGroups) -> collapsedGroups.forEach(group -> this.columnGroupHeaderLayer.expandGroup(model, group)));
// update fromColumnPositions and toColumnPosition
int[] fromPositions = Arrays.stream(fromIndexes)
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/GroupMultiRowReorderCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/GroupMultiRowReorderCommandHandler.java
index 08fe1ec..0879990 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/GroupMultiRowReorderCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/GroupMultiRowReorderCommandHandler.java
@@ -100,9 +100,7 @@
int toIndex = this.rowGroupHeaderLayer.getPositionLayer().getRowIndexByPosition(toRowPosition);
// expand all collapsed groups
- collapsed.forEach((model, collapsedGroups) -> {
- collapsedGroups.forEach(group -> this.rowGroupHeaderLayer.expandGroup(model, group));
- });
+ collapsed.forEach((model, collapsedGroups) -> collapsedGroups.forEach(group -> this.rowGroupHeaderLayer.expandGroup(model, group)));
// update fromColumnPositions and toColumnPosition
int[] fromPositions = Arrays.stream(fromIndexes)
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupCollapseCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupCollapseCommand.java
index a1044a0..4bb7042 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupCollapseCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupCollapseCommand.java
@@ -38,12 +38,12 @@
public RowGroupCollapseCommand(GroupModel groupModel, Collection<Group> groups) {
this.groupModel = groupModel;
- this.groups = new ArrayList<Group>(groups);
+ this.groups = new ArrayList<>(groups);
}
protected RowGroupCollapseCommand(RowGroupCollapseCommand command) {
this.groupModel = command.groupModel;
- this.groups = new ArrayList<Group>(command.groups);
+ this.groups = new ArrayList<>(command.groups);
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupExpandCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupExpandCommand.java
index 3f00379..eba7a32 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupExpandCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupExpandCommand.java
@@ -38,12 +38,12 @@
public RowGroupExpandCommand(GroupModel groupModel, Collection<Group> groups) {
this.groupModel = groupModel;
- this.groups = new ArrayList<Group>(groups);
+ this.groups = new ArrayList<>(groups);
}
protected RowGroupExpandCommand(RowGroupExpandCommand command) {
this.groupModel = command.groupModel;
- this.groups = new ArrayList<Group>(command.groups);
+ this.groups = new ArrayList<>(command.groups);
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupsCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupsCommandHandler.java
index 45a3d81..71cdb85 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupsCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/group/performance/command/RowGroupsCommandHandler.java
@@ -113,7 +113,7 @@
}
}
- HashSet<Group> existingGroups = new HashSet<Group>();
+ HashSet<Group> existingGroups = new HashSet<>();
for (MutableIntIterator it = positionsToGroup.intIterator(); it.hasNext();) {
int row = it.next();
Group group = model.getGroupByPosition(row);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/AbstractColumnHideShowLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/AbstractColumnHideShowLayer.java
index b2840fe..a0c49f3 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/AbstractColumnHideShowLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/AbstractColumnHideShowLayer.java
@@ -210,7 +210,7 @@
@Override
public Collection<Range> underlyingToLocalColumnPositions(
ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) {
- Collection<Range> localColumnPositionRanges = new ArrayList<Range>(underlyingColumnPositionRanges.size());
+ Collection<Range> localColumnPositionRanges = new ArrayList<>(underlyingColumnPositionRanges.size());
for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) {
int startColumnPosition = getAdjustedUnderlyingToLocalStartPosition(
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/RowIdHideShowLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/RowIdHideShowLayer.java
index 64ca335..d20e050 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/RowIdHideShowLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/RowIdHideShowLayer.java
@@ -59,7 +59,7 @@
protected final IRowDataProvider<T> rowDataProvider;
protected final IRowIdAccessor<T> rowIdAccessor;
- protected Map<Serializable, T> hiddenRows = new TreeMap<Serializable, T>();
+ protected Map<Serializable, T> hiddenRows = new TreeMap<>();
protected IDisplayConverter idConverter;
@@ -126,7 +126,7 @@
String property = properties.getProperty(prefix + PERSISTENCE_KEY_HIDDEN_ROW_IDS);
if (property != null) {
StringTokenizer tok = new StringTokenizer(property, IPersistable.VALUE_SEPARATOR);
- Set<Serializable> ids = new HashSet<Serializable>();
+ Set<Serializable> ids = new HashSet<>();
while (tok.hasMoreTokens()) {
String id = tok.nextToken();
if (this.idConverter != null) {
@@ -215,7 +215,7 @@
@Override
public void hideRowPositions(int... rowPositions) {
- Map<Serializable, T> toHide = new HashMap<Serializable, T>();
+ Map<Serializable, T> toHide = new HashMap<>();
for (int rowPosition : rowPositions) {
T rowObject = getRowObjectByPosition(rowPosition);
toHide.put(this.rowIdAccessor.getRowId(rowObject), rowObject);
@@ -321,8 +321,7 @@
private T getRowObjectByIndex(int rowIndex) {
if (rowIndex >= 0) {
try {
- T rowObject = this.rowDataProvider.getRowObject(rowIndex);
- return rowObject;
+ return this.rowDataProvider.getRowObject(rowIndex);
} catch (Exception e) {
// row index is invalid for the data provider
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/indicator/HideIndicatorConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/indicator/HideIndicatorConfigAttributes.java
index 31af46a..d1f677b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/indicator/HideIndicatorConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hideshow/indicator/HideIndicatorConfigAttributes.java
@@ -28,12 +28,12 @@
* Configuration attribute for configuring the line width of the hide
* indicator.
*/
- public static final ConfigAttribute<Integer> HIDE_INDICATOR_LINE_WIDTH = new ConfigAttribute<Integer>();
+ public static final ConfigAttribute<Integer> HIDE_INDICATOR_LINE_WIDTH = new ConfigAttribute<>();
/**
* Configuration attribute for configuring the color of the hide indicator.
*/
- public static final ConfigAttribute<Color> HIDE_INDICATOR_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> HIDE_INDICATOR_COLOR = new ConfigAttribute<>();
private HideIndicatorConfigAttributes() {
// empty constructor for constants class
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/HierarchicalHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/HierarchicalHelper.java
index 7897d79..45f3f62 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/HierarchicalHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/HierarchicalHelper.java
@@ -129,7 +129,7 @@
HierarchicalWrapper rootWrapper = new HierarchicalWrapper(nestedArray.length + 1);
rootWrapper.setObject(0, root);
result.addAll(deNormalizeWithDirectChildren(rootWrapper, 0, nestedArray,
- new HashMap<Class<?>, Map<String, PropertyDescriptor>>(), addParentObject));
+ new HashMap<>(), addParentObject));
}
}
}
@@ -290,7 +290,7 @@
if (split.length == currentLevel) {
columns.add(col);
} else if (split.length > currentLevel) {
- columns = new ArrayList<Integer>();
+ columns = new ArrayList<>();
columns.add(col);
levelIndexMapping.put(currentLevel, columns);
currentLevel++;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/HierarchicalTreeLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/HierarchicalTreeLayer.java
index c8479e7..dd992f2 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/HierarchicalTreeLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/HierarchicalTreeLayer.java
@@ -129,15 +129,15 @@
* Mapping of level to the first column index of the level which is showing
* the tree nodes.
*/
- private Map<Integer, Integer> nodeColumnMapping = new LinkedHashMap<Integer, Integer>();
+ private Map<Integer, Integer> nodeColumnMapping = new LinkedHashMap<>();
/**
* Mapping of the level to the list of all columns belonging to a level.
*/
- private Map<Integer, List<Integer>> levelIndexMapping = new LinkedHashMap<Integer, List<Integer>>();
+ private Map<Integer, List<Integer>> levelIndexMapping = new LinkedHashMap<>();
/**
* Set of tree node coordinates based on indexes that are collapsed.
*/
- protected final Set<HierarchicalTreeNode> collapsedNodes = new HashSet<HierarchicalTreeNode>();
+ protected final Set<HierarchicalTreeNode> collapsedNodes = new HashSet<>();
/**
* Collection of all row indexes that are hidden if tree nodes are
* collapsed.
@@ -319,7 +319,7 @@
if (propertyNames.length > 0) {
int currentLevel = 1;
this.nodeColumnMapping.put(0, 0);
- List<Integer> columns = new ArrayList<Integer>();
+ List<Integer> columns = new ArrayList<>();
columns.add(0);
this.levelIndexMapping.put(0, columns);
for (int col = 1; col < propertyNames.length; col++) {
@@ -328,7 +328,7 @@
columns.add(col);
} else if (split.length > currentLevel) {
this.nodeColumnMapping.put(currentLevel, col);
- columns = new ArrayList<Integer>();
+ columns = new ArrayList<>();
columns.add(col);
this.levelIndexMapping.put(currentLevel, columns);
currentLevel++;
@@ -498,7 +498,7 @@
// build a new collection of nodes to avoid duplication clashes
// as nodes are equal per column and row index
int negativeIndex = -1;
- Set<HierarchicalTreeNode> updatedCollapsedNodes = new HashSet<HierarchicalTreeNode>();
+ Set<HierarchicalTreeNode> updatedCollapsedNodes = new HashSet<>();
for (HierarchicalTreeNode node : this.collapsedNodes) {
int newRowIndex = findTopRowIndex(node.columnIndex, node.rowObject);
// add the updated node if the row object still exists in
@@ -695,12 +695,10 @@
IndentedTreeImagePainter result = null;
if (painter instanceof IndentedTreeImagePainter) {
result = (IndentedTreeImagePainter) painter;
- } else if (painter != null
- && painter instanceof CellPainterWrapper
+ } else if (painter instanceof CellPainterWrapper
&& ((CellPainterWrapper) painter).getWrappedPainter() != null) {
result = findIndentedTreeImagePainter(((CellPainterWrapper) painter).getWrappedPainter());
- } else if (painter != null
- && painter instanceof CellPainterDecorator) {
+ } else if (painter instanceof CellPainterDecorator) {
result = findIndentedTreeImagePainter(((CellPainterDecorator) painter).getBaseCellPainter());
if (result == null) {
result = findIndentedTreeImagePainter(((CellPainterDecorator) painter).getDecoratorCellPainter());
@@ -1620,7 +1618,7 @@
@Override
public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) {
if (isShowTreeLevelHeader()) {
- Collection<Range> localColumnPositionRanges = new ArrayList<Range>();
+ Collection<Range> localColumnPositionRanges = new ArrayList<>();
for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) {
int start = underlyingToLocalColumnPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.start);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerConfiguration.java
index 670e3c0..f94ab62 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerConfiguration.java
@@ -13,9 +13,9 @@
package org.eclipse.nebula.widgets.nattable.hierarchical.config;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
-import org.eclipse.nebula.widgets.nattable.config.EditableRule;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.config.IConfiguration;
+import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.grid.cell.AlternatingRowConfigLabelAccumulator;
@@ -56,6 +56,8 @@
*
* @since 1.6
*/
+// fields are public by design to make it easy for adapters to customize styling
+@SuppressWarnings("java:S1104")
public class DefaultHierarchicalTreeLayerConfiguration implements IConfiguration {
protected HierarchicalTreeLayer treeLayer;
@@ -189,21 +191,21 @@
// disable editing always for level header columns
configRegistry.registerConfigAttribute(
EditConfigAttributes.CELL_EDITABLE_RULE,
- EditableRule.NEVER_EDITABLE,
+ IEditableRule.NEVER_EDITABLE,
DisplayMode.NORMAL,
HierarchicalTreeLayer.LEVEL_HEADER_CELL);
// disable editing always for collapsed childs
configRegistry.registerConfigAttribute(
EditConfigAttributes.CELL_EDITABLE_RULE,
- EditableRule.NEVER_EDITABLE,
+ IEditableRule.NEVER_EDITABLE,
DisplayMode.NORMAL,
HierarchicalTreeLayer.COLLAPSED_CHILD);
// disable editing always for empty childs
configRegistry.registerConfigAttribute(
EditConfigAttributes.CELL_EDITABLE_RULE,
- EditableRule.NEVER_EDITABLE,
+ IEditableRule.NEVER_EDITABLE,
DisplayMode.NORMAL,
HierarchicalTreeLayer.NO_OBJECT_IN_LEVEL);
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerThemeExtension.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerThemeExtension.java
index 23892ad..8f7050f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerThemeExtension.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/hierarchical/config/DefaultHierarchicalTreeLayerThemeExtension.java
@@ -54,6 +54,8 @@
*
* @since 2.0
*/
+// fields are public by design to make it easy for adapters to customize a theme
+@SuppressWarnings("java:S1104")
public class DefaultHierarchicalTreeLayerThemeExtension implements IThemeExtension {
// default cell style
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractIndexLayerTransform.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractIndexLayerTransform.java
index cc4489f..cf32e6e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractIndexLayerTransform.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractIndexLayerTransform.java
@@ -157,7 +157,7 @@
public Collection<Range> underlyingToLocalColumnPositions(
ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) {
- Collection<Range> localColumnPositionRanges = new ArrayList<Range>(underlyingColumnPositionRanges.size());
+ Collection<Range> localColumnPositionRanges = new ArrayList<>(underlyingColumnPositionRanges.size());
for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) {
localColumnPositionRanges.add(new Range(
underlyingToLocalColumnPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.start),
@@ -213,7 +213,7 @@
@Override
public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition) {
- Collection<ILayer> underlyingLayers = new HashSet<ILayer>();
+ Collection<ILayer> underlyingLayers = new HashSet<>();
underlyingLayers.add(this.underlyingLayer);
return underlyingLayers;
}
@@ -254,7 +254,7 @@
public Collection<Range> underlyingToLocalRowPositions(
ILayer sourceUnderlyingLayer,
Collection<Range> underlyingRowPositionRanges) {
- Collection<Range> localRowPositionRanges = new ArrayList<Range>(underlyingRowPositionRanges.size());
+ Collection<Range> localRowPositionRanges = new ArrayList<>(underlyingRowPositionRanges.size());
for (Range underlyingRowPositionRange : underlyingRowPositionRanges) {
localRowPositionRanges.add(new Range(
underlyingToLocalRowPosition(sourceUnderlyingLayer, underlyingRowPositionRange.start),
@@ -310,7 +310,7 @@
@Override
public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition) {
- Collection<ILayer> underlyingLayers = new HashSet<ILayer>();
+ Collection<ILayer> underlyingLayers = new HashSet<>();
underlyingLayers.add(this.underlyingLayer);
return underlyingLayers;
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractLayer.java
index 9254ed7..4e63c9c 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractLayer.java
@@ -59,14 +59,12 @@
private IClientAreaProvider clientAreaProvider = IClientAreaProvider.DEFAULT;
private IConfigLabelAccumulator configLabelAccumulator;
- protected final Map<Class<? extends ILayerCommand>, ILayerCommandHandler<? extends ILayerCommand>> commandHandlers =
- new LinkedHashMap<Class<? extends ILayerCommand>, ILayerCommandHandler<? extends ILayerCommand>>();
- protected Map<Class<? extends ILayerEvent>, ILayerEventHandler<? extends ILayerEvent>> eventHandlers =
- new HashMap<Class<? extends ILayerEvent>, ILayerEventHandler<? extends ILayerEvent>>();
+ protected final Map<Class<? extends ILayerCommand>, ILayerCommandHandler<? extends ILayerCommand>> commandHandlers = new LinkedHashMap<>();
+ protected Map<Class<? extends ILayerEvent>, ILayerEventHandler<? extends ILayerEvent>> eventHandlers = new HashMap<>();
- private final List<IPersistable> persistables = new LinkedList<IPersistable>();
- private final Set<ILayerListener> listeners = new LinkedHashSet<ILayerListener>();
- private final Collection<IConfiguration> configurations = new LinkedList<IConfiguration>();
+ private final List<IPersistable> persistables = new LinkedList<>();
+ private final Set<ILayerListener> listeners = new LinkedHashSet<>();
+ private final Collection<IConfiguration> configurations = new LinkedList<>();
private boolean configurationApplied = false;
@@ -273,7 +271,7 @@
public void registerEventHandler(ILayerEventHandler<?> eventHandler) {
this.eventHelperLock.writeLock().lock();
try {
- this.eventHandlers = new HashMap<Class<? extends ILayerEvent>, ILayerEventHandler<? extends ILayerEvent>>(this.eventHandlers);
+ this.eventHandlers = new HashMap<>(this.eventHandlers);
this.eventHandlers.put(eventHandler.getLayerEventClass(), eventHandler);
} finally {
this.eventHelperLock.writeLock().unlock();
@@ -283,7 +281,7 @@
public void unregisterEventHandler(ILayerEventHandler<?> eventHandler) {
this.eventHelperLock.writeLock().lock();
try {
- this.eventHandlers = new HashMap<Class<? extends ILayerEvent>, ILayerEventHandler<? extends ILayerEvent>>(this.eventHandlers);
+ this.eventHandlers = new HashMap<>(this.eventHandlers);
this.eventHandlers.remove(eventHandler.getLayerEventClass());
} finally {
this.eventHelperLock.writeLock().unlock();
@@ -296,7 +294,7 @@
*/
@Override
public void fireLayerEvent(ILayerEvent event) {
- if (this.listeners.size() > 0) {
+ if (!this.listeners.isEmpty()) {
Iterator<ILayerListener> it = this.listeners.iterator();
boolean isLastListener = false;
do {
@@ -440,8 +438,7 @@
}
// add the labels configured via IConfigLabelAccumulator
- if (this.configLabelAccumulator != null
- && this.configLabelAccumulator instanceof IConfigLabelProvider) {
+ if (this.configLabelAccumulator instanceof IConfigLabelProvider) {
labels.addAll(((IConfigLabelProvider) this.configLabelAccumulator).getProvidedLabels());
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractLayerTransform.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractLayerTransform.java
index 8cdd0e9..4addf6e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractLayerTransform.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/AbstractLayerTransform.java
@@ -154,7 +154,7 @@
@Override
public Collection<Range> underlyingToLocalColumnPositions(
ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) {
- Collection<Range> localColumnPositionRanges = new ArrayList<Range>(underlyingColumnPositionRanges.size());
+ Collection<Range> localColumnPositionRanges = new ArrayList<>(underlyingColumnPositionRanges.size());
for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) {
localColumnPositionRanges.add(new Range(
@@ -208,7 +208,7 @@
@Override
public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition) {
- Collection<ILayer> underlyingLayers = new HashSet<ILayer>();
+ Collection<ILayer> underlyingLayers = new HashSet<>();
underlyingLayers.add(this.underlyingLayer);
return underlyingLayers;
}
@@ -247,7 +247,7 @@
public Collection<Range> underlyingToLocalRowPositions(
ILayer sourceUnderlyingLayer,
Collection<Range> underlyingRowPositionRanges) {
- Collection<Range> localRowPositionRanges = new ArrayList<Range>(underlyingRowPositionRanges.size());
+ Collection<Range> localRowPositionRanges = new ArrayList<>(underlyingRowPositionRanges.size());
for (Range underlyingRowPositionRange : underlyingRowPositionRanges) {
localRowPositionRanges.add(new Range(
@@ -301,7 +301,7 @@
@Override
public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition) {
- Collection<ILayer> underlyingLayers = new HashSet<ILayer>();
+ Collection<ILayer> underlyingLayers = new HashSet<>();
underlyingLayers.add(this.underlyingLayer);
return underlyingLayers;
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/CompositeLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/CompositeLayer.java
index ab00946..c2d588b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/CompositeLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/CompositeLayer.java
@@ -321,7 +321,7 @@
@Override
public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition) {
- Collection<ILayer> underlyingLayers = new HashSet<ILayer>();
+ Collection<ILayer> underlyingLayers = new HashSet<>();
for (int layoutX = 0; layoutX < this.childLayerLayout.length; layoutX++) {
int columnPositionOffset = getColumnPositionOffset(layoutX);
@@ -490,7 +490,7 @@
@Override
public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition) {
- Collection<ILayer> underlyingLayers = new HashSet<ILayer>();
+ Collection<ILayer> underlyingLayers = new HashSet<>();
for (int layoutY = 0; layoutY < this.childLayerLayout[0].length; layoutY++) {
int rowPositionOffset = getRowPositionOffset(layoutY);
@@ -659,6 +659,11 @@
/**
* Sets the IConfigLabelAccumulator for the given named region. Replaces any
* existing IConfigLabelAccumulator.
+ *
+ * @param regionName
+ * the region name.
+ * @param configLabelAccumulator
+ * the {@link IConfigLabelAccumulator} to set.
*/
public void setConfigLabelAccumulatorForRegion(
String regionName, IConfigLabelAccumulator configLabelAccumulator) {
@@ -667,6 +672,11 @@
/**
* Adds the configLabelAccumulator to the existing label accumulators.
+ *
+ * @param regionName
+ * the region name.
+ * @param configLabelAccumulator
+ * the {@link IConfigLabelAccumulator} to add.
*/
public void addConfigLabelAccumulatorForRegion(
String regionName, IConfigLabelAccumulator configLabelAccumulator) {
@@ -732,9 +742,7 @@
childLayer.getPreferredWidth(),
childLayer.getPreferredHeight());
- final Rectangle intersection = compositeClientArea.intersection(childClientArea);
-
- return intersection;
+ return compositeClientArea.intersection(childClientArea);
}
/**
@@ -1023,7 +1031,7 @@
labels.add(regionName);
IConfigLabelAccumulator accumulator = this.regionNameToConfigLabelAccumulatorMap.get(regionName);
- if (accumulator != null && accumulator instanceof IConfigLabelProvider) {
+ if (accumulator instanceof IConfigLabelProvider) {
labels.addAll(((IConfigLabelProvider) accumulator).getProvidedLabels());
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/ILayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/ILayer.java
index 6e5065f..af0cda5 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/ILayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/ILayer.java
@@ -75,7 +75,7 @@
* header layer, and corner layer:
* </p>
* <table border=1>
- * <caption></caption>
+ * <caption>layer composition</caption>
* <tr>
* <td>corner</td>
* <td>column header</td>
@@ -652,7 +652,7 @@
* @since 2.0
*/
public default Collection<String> getProvidedLabels() {
- return new LinkedHashSet<String>();
+ return new LinkedHashSet<>();
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/InvertUtil.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/InvertUtil.java
index 776f8fa..2d58c0a 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/InvertUtil.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/InvertUtil.java
@@ -14,7 +14,11 @@
import org.eclipse.swt.graphics.Rectangle;
-public class InvertUtil {
+public final class InvertUtil {
+
+ private InvertUtil() {
+ // private default constructor for helper class
+ }
public static Rectangle invertRectangle(Rectangle rect) {
if (rect != null)
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/LayerUtil.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/LayerUtil.java
index e870dff..8ec4b17 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/LayerUtil.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/LayerUtil.java
@@ -13,7 +13,11 @@
******************************************************************************/
package org.eclipse.nebula.widgets.nattable.layer;
-public class LayerUtil {
+public final class LayerUtil {
+
+ private LayerUtil() {
+ // private default constructor for helper class
+ }
/**
* Modifier that is used by layers if they add additional columns or rows.
@@ -119,12 +123,10 @@
return sourceColumnPosition;
}
int columnIndex = sourceLayer.getColumnIndexByPosition(sourceColumnPosition);
- if (columnIndex < 0) {
+ if (columnIndex < 0 && (columnIndex % ADDITIONAL_POSITION_MODIFIER != 0)) {
// if the negative index is multiplied with the additional position
// modifier we assume that the back conversion is possible
- if (columnIndex % ADDITIONAL_POSITION_MODIFIER != 0) {
- return -1;
- }
+ return -1;
}
return targetLayer.getColumnPositionByIndex(columnIndex);
}
@@ -147,12 +149,10 @@
return sourceRowPosition;
}
int rowIndex = sourceLayer.getRowIndexByPosition(sourceRowPosition);
- if (rowIndex < 0) {
+ if (rowIndex < 0 && (rowIndex % ADDITIONAL_POSITION_MODIFIER != 0)) {
// if the negative index is multiplied with the additional position
// modifier we assume that the back conversion is possible
- if (rowIndex % ADDITIONAL_POSITION_MODIFIER != 0) {
- return -1;
- }
+ return -1;
}
return targetLayer.getRowPositionByIndex(rowIndex);
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/AbstractOverrider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/AbstractOverrider.java
index 9deac7b..0c64ff9 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/AbstractOverrider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/AbstractOverrider.java
@@ -23,7 +23,7 @@
public abstract class AbstractOverrider implements IConfigLabelProvider {
- private Map<Serializable, List<String>> overrides = new HashMap<Serializable, List<String>>();
+ private Map<Serializable, List<String>> overrides = new HashMap<>();
/**
* Remove all registered labels from the key-label overrides for the given
@@ -140,7 +140,7 @@
*/
@Override
public Collection<String> getProvidedLabels() {
- Collection<String> result = new HashSet<String>();
+ Collection<String> result = new HashSet<>();
for (List<String> labels : this.overrides.values()) {
result.addAll(labels);
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/AggregateConfigLabelAccumulator.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/AggregateConfigLabelAccumulator.java
index 75b1c4d..df8a80b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/AggregateConfigLabelAccumulator.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/AggregateConfigLabelAccumulator.java
@@ -28,7 +28,7 @@
*/
public class AggregateConfigLabelAccumulator implements IConfigLabelProvider {
- private List<IConfigLabelAccumulator> accumulators = new ArrayList<IConfigLabelAccumulator>();
+ private List<IConfigLabelAccumulator> accumulators = new ArrayList<>();
public void add(IConfigLabelAccumulator r) {
if (r == null)
@@ -56,7 +56,7 @@
*/
@Override
public Collection<String> getProvidedLabels() {
- Collection<String> result = new HashSet<String>();
+ Collection<String> result = new HashSet<>();
for (IConfigLabelAccumulator accumulator : this.accumulators) {
if (accumulator instanceof IConfigLabelProvider) {
result.addAll(((IConfigLabelProvider) accumulator).getProvidedLabels());
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/CellDisplayConversionUtils.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/CellDisplayConversionUtils.java
index 2babeed..3034c25 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/CellDisplayConversionUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/CellDisplayConversionUtils.java
@@ -16,7 +16,11 @@
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
-public class CellDisplayConversionUtils {
+public final class CellDisplayConversionUtils {
+
+ private CellDisplayConversionUtils() {
+ // private default constructor for helper class
+ }
public static String convertDataType(ILayerCell cell, IConfigRegistry configRegistry) {
Object canonicalValue = cell.getDataValue();
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/ClassNameConfigLabelAccumulator.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/ClassNameConfigLabelAccumulator.java
index 552a36f..ca051ec 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/ClassNameConfigLabelAccumulator.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/ClassNameConfigLabelAccumulator.java
@@ -44,7 +44,7 @@
*/
@Override
public Collection<String> getProvidedLabels() {
- Collection<String> result = new HashSet<String>();
+ Collection<String> result = new HashSet<>();
for (int i = 0; i < this.dataProvider.getColumnCount(); i++) {
Object value = this.dataProvider.getDataValue(i, 0);
if (value != null) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/ColumnLabelAccumulator.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/ColumnLabelAccumulator.java
index 4c17b41..0351627 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/ColumnLabelAccumulator.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/cell/ColumnLabelAccumulator.java
@@ -69,7 +69,7 @@
*/
@Override
public Collection<String> getProvidedLabels() {
- Collection<String> result = new HashSet<String>();
+ Collection<String> result = new HashSet<>();
if (this.dataProvider != null) {
for (int i = 0; i < this.dataProvider.getColumnCount(); i++) {
result.add(COLUMN_LABEL_PREFIX + i);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultColumnHeaderStyleConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultColumnHeaderStyleConfiguration.java
index 6dcda1b..9ec23d4 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultColumnHeaderStyleConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultColumnHeaderStyleConfiguration.java
@@ -35,6 +35,8 @@
* Sets up column header styling. Added by
* {@link DefaultColumnHeaderLayerConfiguration}
*/
+// fields are public by design to make it easy for adapters to customize styling
+@SuppressWarnings("java:S1104")
public class DefaultColumnHeaderStyleConfiguration extends AbstractRegistryConfiguration {
public Font font = GUIHelper.getFont(new FontData("Verdana", 10, SWT.NORMAL)); //$NON-NLS-1$
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultRowHeaderStyleConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultRowHeaderStyleConfiguration.java
index f494ee2..87e80b9 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultRowHeaderStyleConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/config/DefaultRowHeaderStyleConfiguration.java
@@ -30,6 +30,8 @@
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
+//fields are public by design to make it easy for adapters to customize styling
+@SuppressWarnings("java:S1104")
public class DefaultRowHeaderStyleConfiguration extends AbstractRegistryConfiguration {
public Font font = GUIHelper.getFont(new FontData("Verdana", 10, SWT.NORMAL)); //$NON-NLS-1$
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/CellVisualChangeEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/CellVisualChangeEvent.java
index b4f132d..fadfa6b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/CellVisualChangeEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/CellVisualChangeEvent.java
@@ -68,8 +68,7 @@
@Override
public Collection<Rectangle> getChangedPositionRectangles() {
- return Arrays.asList(new Rectangle[] { new Rectangle(this.columnPosition,
- this.rowPosition, 1, 1) });
+ return Arrays.asList(new Rectangle(this.columnPosition, this.rowPosition, 1, 1));
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnDeleteEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnDeleteEvent.java
index da647ce..3f278f6 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnDeleteEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnDeleteEvent.java
@@ -75,7 +75,7 @@
@Override
public Collection<StructuralDiff> getColumnDiffs() {
Collection<StructuralDiff> columnDiffs =
- new ArrayList<StructuralDiff>(getColumnPositionRanges().size());
+ new ArrayList<>(getColumnPositionRanges().size());
for (Range range : getColumnPositionRanges()) {
columnDiffs.add(new StructuralDiff(
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnInsertEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnInsertEvent.java
index 0f1dfdb..2d37a3f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnInsertEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnInsertEvent.java
@@ -76,7 +76,7 @@
@Override
public Collection<StructuralDiff> getColumnDiffs() {
Collection<StructuralDiff> columnDiffs =
- new ArrayList<StructuralDiff>(getColumnPositionRanges().size());
+ new ArrayList<>(getColumnPositionRanges().size());
for (Range range : getColumnPositionRanges()) {
columnDiffs.add(new StructuralDiff(
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnStructuralChangeEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnStructuralChangeEvent.java
index 816946d..04f82e7 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnStructuralChangeEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnStructuralChangeEvent.java
@@ -100,7 +100,7 @@
Collection<Rectangle> changedPositionRectangles = new ArrayList<>();
Collection<Range> ranges = getColumnPositionRanges();
- if (ranges != null && ranges.size() > 0) {
+ if (ranges != null && !ranges.isEmpty()) {
int leftmostColumnPosition = Integer.MAX_VALUE;
for (Range range : ranges) {
if (range.start < leftmostColumnPosition) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnVisualChangeEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnVisualChangeEvent.java
index 6f05679..e0082b5 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnVisualChangeEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ColumnVisualChangeEvent.java
@@ -136,7 +136,7 @@
* @return The column position ranges for the columns that have changed.
*/
public Collection<Range> getColumnPositionRanges() {
- return this.columnPositionRanges != null ? this.columnPositionRanges : new ArrayList<Range>(0);
+ return this.columnPositionRanges != null ? this.columnPositionRanges : new ArrayList<>(0);
}
/**
@@ -176,7 +176,7 @@
this.layer = localLayer;
- return this.columnPositionRanges != null && this.columnPositionRanges.size() > 0;
+ return this.columnPositionRanges != null && !this.columnPositionRanges.isEmpty();
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ResizeStructuralRefreshEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ResizeStructuralRefreshEvent.java
index 09b08d8..3789790 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ResizeStructuralRefreshEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/ResizeStructuralRefreshEvent.java
@@ -40,11 +40,11 @@
@Override
public Collection<StructuralDiff> getColumnDiffs() {
- return new ArrayList<StructuralDiff>();
+ return new ArrayList<>();
}
@Override
public Collection<StructuralDiff> getRowDiffs() {
- return new ArrayList<StructuralDiff>();
+ return new ArrayList<>();
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowDeleteEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowDeleteEvent.java
index d956800..0b37a50 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowDeleteEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowDeleteEvent.java
@@ -86,7 +86,7 @@
}
public Collection<Integer> getDeletedRowIndexes() {
- Set<Integer> rowIndexes = new HashSet<Integer>();
+ Set<Integer> rowIndexes = new HashSet<>();
for (Range range : getRowPositionRanges()) {
for (int i = range.start; i < range.end; i++) {
rowIndexes.add(getLayer().getRowIndexByPosition(i));
@@ -97,7 +97,7 @@
@Override
public Collection<StructuralDiff> getRowDiffs() {
- Collection<StructuralDiff> rowDiffs = new ArrayList<StructuralDiff>(getRowPositionRanges().size());
+ Collection<StructuralDiff> rowDiffs = new ArrayList<>(getRowPositionRanges().size());
for (Range range : getRowPositionRanges()) {
rowDiffs.add(new StructuralDiff(
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowInsertEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowInsertEvent.java
index 8530a77..cdde7e5 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowInsertEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowInsertEvent.java
@@ -80,7 +80,7 @@
@Override
public Collection<StructuralDiff> getRowDiffs() {
- Collection<StructuralDiff> rowDiffs = new ArrayList<StructuralDiff>(getRowPositionRanges().size());
+ Collection<StructuralDiff> rowDiffs = new ArrayList<>(getRowPositionRanges().size());
for (Range range : getRowPositionRanges()) {
rowDiffs.add(new StructuralDiff(
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowObjectDeleteEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowObjectDeleteEvent.java
index 6f7391c..f382c17 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowObjectDeleteEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowObjectDeleteEvent.java
@@ -27,7 +27,7 @@
*/
public class RowObjectDeleteEvent extends RowDeleteEvent {
- private Map<Integer, Object> deletedObjects = new HashMap<Integer, Object>();
+ private Map<Integer, Object> deletedObjects = new HashMap<>();
/**
* Creates a {@link RowObjectDeleteEvent} for one deleted row object.
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowStructuralChangeEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowStructuralChangeEvent.java
index ae0ae54..eac3294 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowStructuralChangeEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowStructuralChangeEvent.java
@@ -100,7 +100,7 @@
Collection<Rectangle> changedPositionRectangles = new ArrayList<>();
Collection<Range> ranges = getRowPositionRanges();
- if (ranges != null && ranges.size() > 0) {
+ if (ranges != null && !ranges.isEmpty()) {
int topmostColumnPosition = Integer.MAX_VALUE;
for (Range range : ranges) {
if (range.start < topmostColumnPosition) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowVisualChangeEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowVisualChangeEvent.java
index 145d25c..2ea5cf4 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowVisualChangeEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/RowVisualChangeEvent.java
@@ -134,7 +134,7 @@
* @return The row position ranges for the rows that have changed.
*/
public Collection<Range> getRowPositionRanges() {
- return this.rowPositionRanges != null ? this.rowPositionRanges : new ArrayList<Range>(0);
+ return this.rowPositionRanges != null ? this.rowPositionRanges : new ArrayList<>(0);
}
/**
@@ -174,7 +174,7 @@
this.layer = localLayer;
- return this.rowPositionRanges != null && this.rowPositionRanges.size() > 0;
+ return this.rowPositionRanges != null && !this.rowPositionRanges.isEmpty();
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/StructuralChangeEventHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/StructuralChangeEventHelper.java
index 6ac38d7..1890972 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/StructuralChangeEventHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/event/StructuralChangeEventHelper.java
@@ -26,7 +26,11 @@
* Helper class providing support for modifying cached index lists for
* IStructuralChangeEvents.
*/
-public class StructuralChangeEventHelper {
+public final class StructuralChangeEventHelper {
+
+ private StructuralChangeEventHelper() {
+ // private default constructor for helper class
+ }
/**
* Will check for events that indicate that rows has been deleted. In that
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/stack/DefaultBodyLayerStack.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/stack/DefaultBodyLayerStack.java
index 07eb501..35a7666 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/stack/DefaultBodyLayerStack.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/layer/stack/DefaultBodyLayerStack.java
@@ -18,7 +18,6 @@
import org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer;
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
-import org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider;
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
public class DefaultBodyLayerStack extends AbstractIndexLayerTransform {
@@ -38,11 +37,6 @@
registerCommandHandler(new CopyDataCommandHandler(this.selectionLayer));
}
- @Override
- public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) {
- super.setClientAreaProvider(clientAreaProvider);
- }
-
public ColumnReorderLayer getColumnReorderLayer() {
return this.columnReorderLayer;
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/AbstractTextPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/AbstractTextPainter.java
index d466a5d..61ab2cb 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/AbstractTextPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/AbstractTextPainter.java
@@ -75,8 +75,8 @@
private Color originalForeground;
private Font originalFont;
- private static Map<String, Integer> temporaryMap = new WeakHashMap<String, Integer>();
- private static Map<org.eclipse.swt.graphics.Font, FontData[]> fontDataCache = new WeakHashMap<org.eclipse.swt.graphics.Font, FontData[]>();
+ private static Map<String, Integer> temporaryMap = new WeakHashMap<>();
+ private static Map<org.eclipse.swt.graphics.Font, FontData[]> fontDataCache = new WeakHashMap<>();
public AbstractTextPainter() {
this(false, true);
@@ -185,6 +185,12 @@
/**
* Convert the data value of the cell using the {@link IDisplayConverter}
* from the {@link IConfigRegistry}
+ *
+ * @param cell
+ * The cell whose data value should be converted.
+ * @param configRegistry
+ * The {@link IConfigRegistry} to retrieve the converter.
+ * @return The data value converted to a String.
*/
protected String convertDataType(ILayerCell cell, IConfigRegistry configRegistry) {
return CellDisplayConversionUtils.convertDataType(cell, configRegistry);
@@ -219,6 +225,7 @@
* Reset the GC to the original values.
*
* @param gc
+ * The {@link GC} that is used for rendering.
*
* @since 1.4
*/
@@ -310,11 +317,7 @@
}
}
text = buffer.toString();
- Integer width = temporaryMap.get(text);
- if (width == null) {
- width = Integer.valueOf(gc.textExtent(originalString).x);
- temporaryMap.put(text, width);
- }
+ Integer width = temporaryMap.computeIfAbsent(text, t -> Integer.valueOf(gc.textExtent(originalString).x));
return width.intValue();
}
@@ -720,26 +723,24 @@
* @since 1.4
*/
protected void paintDecoration(IStyle cellStyle, GC gc, int x, int y, int length, int fontHeight) {
- boolean underline = renderUnderlined(cellStyle);
- boolean strikethrough = renderStrikethrough(cellStyle);
+ boolean ul = renderUnderlined(cellStyle);
+ boolean st = renderStrikethrough(cellStyle);
- if (underline || strikethrough) {
- if (length > 0) {
- // check and draw underline and strikethrough separately
- // so it is possible to combine both
- if (underline) {
- // y = start y of text + font height - half of the font
- // descent so the underline is between baseline and bottom
- int underlineY = y + fontHeight - (gc.getFontMetrics().getDescent() / 2);
- gc.drawLine(x, underlineY, x + length, underlineY);
- }
+ if ((ul || st) && length > 0) {
+ // check and draw underline and strikethrough separately
+ // so it is possible to combine both
+ if (ul) {
+ // y = start y of text + font height - half of the font
+ // descent so the underline is between baseline and bottom
+ int underlineY = y + fontHeight - (gc.getFontMetrics().getDescent() / 2);
+ gc.drawLine(x, underlineY, x + length, underlineY);
+ }
- if (strikethrough) {
- // y = start y of text + half of font height + ascent
- // this way lower case characters are also strikethrough
- int strikeY = y + (fontHeight / 2) + (gc.getFontMetrics().getLeading() / 2);
- gc.drawLine(x, strikeY, x + length, strikeY);
- }
+ if (st) {
+ // y = start y of text + half of font height + ascent
+ // this way lower case characters are also strikethrough
+ int strikeY = y + (fontHeight / 2) + (gc.getFontMetrics().getLeading() / 2);
+ gc.drawLine(x, strikeY, x + length, strikeY);
}
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/BlendedBackgroundPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/BlendedBackgroundPainter.java
index 124d3de..dffdb94 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/BlendedBackgroundPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/BlendedBackgroundPainter.java
@@ -90,7 +90,7 @@
colours.add(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
}
- if (colours.size() == 0) {
+ if (colours.isEmpty()) {
return null;
} else if (colours.size() == 1) {
return colours.get(0);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/BorderPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/BorderPainter.java
index 7788722..84d7b68 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/BorderPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/BorderPainter.java
@@ -152,11 +152,11 @@
// -----
//
// when considering the cell in (1,1) it should draw a top border between it
- // and the outside cell at (1,0);
+ // and the outside cell at (1,0)
// but it can't use the width of cell (1,1) otherwise it will draw a border
- // also under the inside cell (0,0);
+ // also under the inside cell (0,0)
// therefore its upper cell (1,0) is considered to find the correct position
- // and width of the border line;
+ // and width of the border line
// in this case:
// x = max((1,1).x0, (1,0).x0)
// l = min((1,1).x1, (1,0).x1) - x
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/ButtonCellPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/ButtonCellPainter.java
index 02508ed..0cd6eae 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/ButtonCellPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/ButtonCellPainter.java
@@ -44,7 +44,7 @@
private int columnPosClicked;
private int rowPosClicked;
private boolean recentlyClicked;
- private final List<IMouseAction> clickLiseners = new ArrayList<IMouseAction>();
+ private final List<IMouseAction> clickLiseners = new ArrayList<>();
/**
* @param interiorPainter
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/GraphicsUtils.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/GraphicsUtils.java
index 1c58020..95f7c60 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/GraphicsUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/GraphicsUtils.java
@@ -33,7 +33,11 @@
* "http://java-gui.info/Apress-The.Definitive.Guide.to.SWT.and.JFace/8886final/LiB0095.html">GC
* snippets</a>
*/
-public class GraphicsUtils {
+public final class GraphicsUtils {
+
+ private GraphicsUtils() {
+ // private default constructor for helper class
+ }
/**
* Draws text vertically (rotates plus or minus 90 degrees). Uses the
@@ -59,8 +63,7 @@
* Note: Only one of the style UP or DOWN may be specified.
* </p>
*/
- public static void drawVerticalText(String string, int x, int y, GC gc,
- int style) {
+ public static void drawVerticalText(String string, int x, int y, GC gc, int style) {
drawVerticalText(string, x, y, false, false, true, gc, style);
}
@@ -106,7 +109,6 @@
SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
// Determine string's dimensions
- // FontMetrics fm = gc.getFontMetrics();
Point pt = gc.textExtent(string.trim());
// Create an image the same size as the string
@@ -297,7 +299,6 @@
gc.setFont(font);
// Determine string's dimensions
- // FontMetrics fm = gc.getFontMetrics();
Point pt = gc.textExtent(text);
// Dispose that gc
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/ImagePainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/ImagePainter.java
index 010bd9a..964e3ba 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/ImagePainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/ImagePainter.java
@@ -38,21 +38,46 @@
protected boolean calculateByWidth;
protected boolean calculateByHeight;
+ /**
+ * Creates an {@link ImagePainter} that retrieves the image to render from
+ * the {@link IConfigRegistry}.
+ */
public ImagePainter() {
this(null);
}
+ /**
+ * Creates an {@link ImagePainter} that renders the provided image.
+ *
+ * @param image
+ * The image to render.
+ */
public ImagePainter(Image image) {
this(image, true);
}
/**
+ * Creates an {@link ImagePainter} that retrieves the image to render from
+ * the {@link IConfigRegistry}.
+ *
+ * @param paintBg
+ * <code>true</code> if the cell background should be painted by
+ * this painter, <code>false</code> if it should be skipped.
* @since 1.4
*/
public ImagePainter(boolean paintBg) {
this.paintBg = paintBg;
}
+ /**
+ * Creates an {@link ImagePainter} that renders the provided image.
+ *
+ * @param image
+ * The image to render.
+ * @param paintBg
+ * <code>true</code> if the cell background should be painted by
+ * this painter, <code>false</code> if it should be skipped.
+ */
public ImagePainter(Image image, boolean paintBg) {
this.image = image;
this.paintBg = paintBg;
@@ -60,9 +85,9 @@
@Override
public int getPreferredWidth(ILayerCell cell, GC gc, IConfigRegistry configRegistry) {
- Image image = getImage(cell, configRegistry);
- if (image != null) {
- return image.getBounds().width;
+ Image img = getImage(cell, configRegistry);
+ if (img != null) {
+ return img.getBounds().width;
} else {
return 0;
}
@@ -70,9 +95,9 @@
@Override
public int getPreferredHeight(ILayerCell cell, GC gc, IConfigRegistry configRegistry) {
- Image image = getImage(cell, configRegistry);
- if (image != null) {
- return image.getBounds().height;
+ Image img = getImage(cell, configRegistry);
+ if (img != null) {
+ return img.getBounds().height;
} else {
return 0;
}
@@ -82,9 +107,9 @@
public ICellPainter getCellPainterAt(int x, int y, ILayerCell cell, GC gc,
Rectangle bounds, IConfigRegistry configRegistry) {
- Image image = getImage(cell, configRegistry);
- if (image != null) {
- Rectangle imageBounds = image.getBounds();
+ Image img = getImage(cell, configRegistry);
+ if (img != null) {
+ Rectangle imageBounds = img.getBounds();
IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
int x0 = bounds.x
+ CellStyleUtil.getHorizontalAlignmentPadding(cellStyle, bounds, imageBounds.width);
@@ -104,9 +129,9 @@
super.paintCell(cell, gc, bounds, configRegistry);
}
- Image image = getImage(cell, configRegistry);
- if (image != null) {
- Rectangle imageBounds = image.getBounds();
+ Image img = getImage(cell, configRegistry);
+ if (img != null) {
+ Rectangle imageBounds = img.getBounds();
IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
int contentHeight = imageBounds.height;
@@ -132,7 +157,7 @@
}
gc.drawImage(
- image,
+ img,
bounds.x + CellStyleUtil.getHorizontalAlignmentPadding(cellStyle, bounds, imageBounds.width),
bounds.y + CellStyleUtil.getVerticalAlignmentPadding(cellStyle, bounds, imageBounds.height));
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/TableCellPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/TableCellPainter.java
index 5cc7ddd..add88ad 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/TableCellPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/TableCellPainter.java
@@ -280,7 +280,7 @@
* calculate inner cells.
*/
protected ILayerCell createSubLayerCell(final ILayerCell cell, final Object dataValue) {
- LayerCell subCell = new LayerCell(cell.getLayer(),
+ return new LayerCell(cell.getLayer(),
cell.getOriginColumnPosition(), cell.getOriginRowPosition(),
// no spanning
cell.getColumnPosition(), cell.getRowPosition(), 0, 0) {
@@ -292,8 +292,6 @@
return dataValue;
}
};
-
- return subCell;
}
/**
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/decorator/PaddingDecorator.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/decorator/PaddingDecorator.java
index 60238a4..7104961 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/decorator/PaddingDecorator.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/decorator/PaddingDecorator.java
@@ -256,25 +256,19 @@
HorizontalAlignmentEnum horizontalAlignment =
cellStyle.getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT);
int horizontalAlignmentPadding = 0;
- switch (horizontalAlignment) {
- case LEFT:
- horizontalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.leftPadding, configRegistry);
- break;
- case CENTER:
- horizontalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.leftPadding, configRegistry) / 2;
- break;
+ if (horizontalAlignment == HorizontalAlignmentEnum.LEFT) {
+ horizontalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.leftPadding, configRegistry);
+ } else if (horizontalAlignment == HorizontalAlignmentEnum.CENTER) {
+ horizontalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.leftPadding, configRegistry) / 2;
}
VerticalAlignmentEnum verticalAlignment =
cellStyle.getAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT);
int verticalAlignmentPadding = 0;
- switch (verticalAlignment) {
- case TOP:
- verticalAlignmentPadding = GUIHelper.convertVerticalPixelToDpi(this.topPadding, configRegistry);
- break;
- case MIDDLE:
- verticalAlignmentPadding = GUIHelper.convertVerticalPixelToDpi(this.topPadding, configRegistry) / 2;
- break;
+ if (verticalAlignment == VerticalAlignmentEnum.TOP) {
+ verticalAlignmentPadding = GUIHelper.convertVerticalPixelToDpi(this.topPadding, configRegistry);
+ } else if (verticalAlignment == VerticalAlignmentEnum.MIDDLE) {
+ verticalAlignmentPadding = GUIHelper.convertVerticalPixelToDpi(this.topPadding, configRegistry) / 2;
}
return super.getCellPainterAt(
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/decorator/PercentageBarDecorator.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/decorator/PercentageBarDecorator.java
index 65e3e4c..83dc4f8 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/decorator/PercentageBarDecorator.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/cell/decorator/PercentageBarDecorator.java
@@ -32,9 +32,9 @@
*/
public class PercentageBarDecorator extends CellPainterWrapper {
- public static final ConfigAttribute<Color> PERCENTAGE_BAR_COMPLETE_REGION_START_COLOR = new ConfigAttribute<Color>();
- public static final ConfigAttribute<Color> PERCENTAGE_BAR_COMPLETE_REGION_END_COLOR = new ConfigAttribute<Color>();
- public static final ConfigAttribute<Color> PERCENTAGE_BAR_INCOMPLETE_REGION_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> PERCENTAGE_BAR_COMPLETE_REGION_START_COLOR = new ConfigAttribute<>();
+ public static final ConfigAttribute<Color> PERCENTAGE_BAR_COMPLETE_REGION_END_COLOR = new ConfigAttribute<>();
+ public static final ConfigAttribute<Color> PERCENTAGE_BAR_INCOMPLETE_REGION_COLOR = new ConfigAttribute<>();
private static final Color DEFAULT_COMPLETE_REGION_START_COLOR = GUIHelper.getColor(new RGB(187, 216, 254));
private static final Color DEFAULT_COMPLETE_REGION_END_COLOR = GUIHelper.getColor(new RGB(255, 255, 255));
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/CellLayerPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/CellLayerPainter.java
index 5215fa4..2c24fa8 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/CellLayerPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/CellLayerPainter.java
@@ -71,7 +71,7 @@
calculateDimensionInfo(positionRectangle);
- Collection<ILayerCell> spannedCells = new HashSet<ILayerCell>();
+ Collection<ILayerCell> spannedCells = new HashSet<>();
for (int columnPosition = positionRectangle.x; columnPosition < positionRectangle.x
+ positionRectangle.width; columnPosition++) {
@@ -108,6 +108,8 @@
* behaviour is used. Only for special cases like split viewports
* with one header, per position a different behaviour may be
* needed.
+ * @return <code>true</code> if the left cell will be clipped,
+ * <code>false</code> if the right cell will be clipped.
*/
protected boolean isClipLeft(int position) {
return this.clipLeft;
@@ -124,6 +126,8 @@
* requested. By default for all rows the same clipping behaviour
* is used. Only for special cases like split viewports with one
* header, per position a different behaviour may be needed.
+ * @return <code>true</code> if the top cell will be clipped,
+ * <code>false</code> if the bottom cell will be clipped.
*/
protected boolean isClipTop(int position) {
return this.clipTop;
@@ -131,7 +135,7 @@
private void calculateDimensionInfo(Rectangle positionRectangle) {
{
- this.horizontalPositionToPixelMap = new HashMap<Integer, Integer>();
+ this.horizontalPositionToPixelMap = new HashMap<>();
final int startPosition = positionRectangle.x;
final int endPosition = startPosition + positionRectangle.width;
int previousEndX = (startPosition > 0)
@@ -151,7 +155,7 @@
}
}
{
- this.verticalPositionToPixelMap = new HashMap<Integer, Integer>();
+ this.verticalPositionToPixelMap = new HashMap<>();
final int startPosition = positionRectangle.y;
final int endPosition = startPosition + positionRectangle.height;
int previousEndY = (startPosition > 0)
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/CompositeFreezeLayerPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/CompositeFreezeLayerPainter.java
index 14cd349..c4a6f12 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/CompositeFreezeLayerPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/CompositeFreezeLayerPainter.java
@@ -17,7 +17,7 @@
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer;
-import org.eclipse.nebula.widgets.nattable.freeze.IFreezeConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.freeze.FreezeConfigAttributes;
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer;
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.CompositeLayerPainter;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
@@ -33,8 +33,8 @@
* also on adjacent regions, e.g. in a GridLayer to render the freeze border
* also inside the column header and row header.
*
- * @see IFreezeConfigAttributes#SEPARATOR_COLOR
- * @see IFreezeConfigAttributes#SEPARATOR_WIDTH
+ * @see FreezeConfigAttributes#SEPARATOR_COLOR
+ * @see FreezeConfigAttributes#SEPARATOR_WIDTH
*
* @since 1.6
*/
@@ -49,12 +49,12 @@
* ILayer that should be used to shift the freeze border down in case of
* nested composite layers, e.g. with fixed summary rows.
*/
- private final Collection<ILayer> nestedVerticalLayers = new ArrayList<ILayer>();
+ private final Collection<ILayer> nestedVerticalLayers = new ArrayList<>();
/**
* ILayer that should be used to shift the freeze border to the right in
* case of nested composite layers.
*/
- private final Collection<ILayer> nestedHorizontalLayers = new ArrayList<ILayer>();
+ private final Collection<ILayer> nestedHorizontalLayers = new ArrayList<>();
/**
* Creates a {@link CompositeFreezeLayerPainter} that can be set directly on
@@ -136,14 +136,14 @@
super.paintLayer(natLayer, gc, xOffset, yOffset, rectangle, configRegistry);
Color separatorColor = configRegistry.getConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_COLOR,
+ FreezeConfigAttributes.SEPARATOR_COLOR,
DisplayMode.NORMAL);
if (separatorColor == null) {
separatorColor = GUIHelper.COLOR_BLUE;
}
Integer separatorWidth = configRegistry.getConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_WIDTH,
+ FreezeConfigAttributes.SEPARATOR_WIDTH,
DisplayMode.NORMAL);
if (separatorWidth == null) {
separatorWidth = 1;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/GridLineCellLayerPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/GridLineCellLayerPainter.java
index d525dae..442b3b1 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/GridLineCellLayerPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/GridLineCellLayerPainter.java
@@ -112,7 +112,7 @@
Rectangle rectangle, IConfigRegistry configRegistry) {
Boolean renderConfig = null;
LabelStack stack = natLayer.getRegionLabelsByXY(xOffset, yOffset);
- List<String> labels = new ArrayList<String>();
+ List<String> labels = new ArrayList<>();
if (stack != null) {
labels = stack;
// check if there is a configuration telling to not rendering grid
@@ -158,6 +158,19 @@
}
/**
+ *
+ * @param natLayer
+ * The layer to paint on.
+ * @param gc
+ * GC used for painting
+ * @param rectangle
+ * area the layer can paint in
+ * @param configRegistry
+ * {@link IConfigRegistry} in use, needed to retrieve configured
+ * grid line color.
+ * @param labels
+ * region labels needed to retrieve the configured grid line
+ * color.
* @since 1.4
*/
protected void drawGridLines(ILayer natLayer, GC gc, Rectangle rectangle, IConfigRegistry configRegistry, List<String> labels) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/ILayerPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/ILayerPainter.java
index b91d4e6..2118c69 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/ILayerPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/ILayerPainter.java
@@ -27,26 +27,36 @@
/**
* @param natLayer
+ * The layer to paint.
* @param gc
* GC used for painting
* @param xOffset
- * of the layer from the origin of the table
+ * x offset of the layer from the origin of the table
* @param yOffset
- * of the layer from the origin of the table
+ * y offset of the layer from the origin of the table
* @param rectangle
* area the layer can paint in
* @param configuration
- * in use by NatTable. Useful for looking up associated painters.
+ * {@link IConfigRegistry} in use by NatTable. Useful for looking
+ * up associated painters.
*/
- public void paintLayer(ILayer natLayer, GC gc, int xOffset, int yOffset,
+ public void paintLayer(ILayer natLayer, GC gc,
+ int xOffset, int yOffset,
Rectangle rectangle, IConfigRegistry configuration);
/**
* This method is used to adjust the cell bounds when painting the layer.
* This is most often used to reduce the size of the cell to accommodate
* grid lines.
+ *
+ * @param columnPosition
+ * The column position.
+ * @param rowPosition
+ * The row position.
+ * @param cellBounds
+ * The actual cell bounds.
+ * @return The adjusted cell bounds.
*/
- public Rectangle adjustCellBounds(int columnPosition, int rowPosition,
- Rectangle cellBounds);
+ public Rectangle adjustCellBounds(int columnPosition, int rowPosition, Rectangle cellBounds);
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/ColorPersistor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/ColorPersistor.java
index fb9437e..106117e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/ColorPersistor.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/ColorPersistor.java
@@ -23,7 +23,11 @@
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
-public class ColorPersistor {
+public final class ColorPersistor {
+
+ private ColorPersistor() {
+ // private default constructor for helper class
+ }
public static final String STYLE_PERSISTENCE_PREFIX = "color"; //$NON-NLS-1$
public static final Color DEFAULT_COLOR = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
@@ -49,7 +53,11 @@
}
/**
- * Create a String representation of the SWT Color
+ *
+ * @param color
+ * The {@link Color} for which the String representation is
+ * requested.
+ * @return The String representation of the provided SWT {@link Color}.
*/
public static String asString(Color color) {
return StringConverter.asString(color.getRGB());
@@ -57,7 +65,11 @@
/**
* Create a Color instance using the String created by
- * {@link ColorPersistor#asColor(String)}
+ * {@link ColorPersistor#asColor(String)}.
+ *
+ * @param colorAsString
+ * The String representation of a SWT {@link Color}.
+ * @return The SWT {@link Color} for the given String.
*/
public static Color asColor(String colorAsString) {
try {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/PersistenceHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/PersistenceHelper.java
index abd0bb3..c85d60a 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/PersistenceHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/PersistenceHelper.java
@@ -24,7 +24,11 @@
/**
* Helper class for dealing with persistence of NatTable states.
*/
-public class PersistenceHelper {
+public final class PersistenceHelper {
+
+ private PersistenceHelper() {
+ // private default constructor for helper class
+ }
/**
* Deletes the keys for a state that is identified by given prefix out of
@@ -47,7 +51,7 @@
String keyPrefix = prefix + IPersistable.DOT;
// collect the keys to remove
- List<Object> keysToRemove = new ArrayList<Object>();
+ List<Object> keysToRemove = new ArrayList<>();
for (Object key : properties.keySet()) {
if (key.toString().startsWith(keyPrefix)) {
keysToRemove.add(key);
@@ -73,7 +77,7 @@
* properties.
*/
public static Collection<String> getAvailableStates(Properties properties) {
- Set<String> stateNames = new HashSet<String>();
+ Set<String> stateNames = new HashSet<>();
if (properties != null && !properties.isEmpty()) {
for (Object key : properties.keySet()) {
String keyString = key.toString();
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/StylePersistor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/StylePersistor.java
index 6465d8d..5b1d94e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/StylePersistor.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/StylePersistor.java
@@ -37,7 +37,11 @@
* Foreground color - Background color - Horizontal alignment - Vertical
* alignment - Font - Border style
*/
-public class StylePersistor {
+public final class StylePersistor {
+
+ private StylePersistor() {
+ // private default constructor for helper class
+ }
// Style prefix constants
public static final String STYLE_PERSISTENCE_PREFIX = "style"; //$NON-NLS-1$
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/command/DisplayPersistenceDialogCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/command/DisplayPersistenceDialogCommandHandler.java
index b3feb97..236ff5f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/command/DisplayPersistenceDialogCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/command/DisplayPersistenceDialogCommandHandler.java
@@ -46,7 +46,7 @@
* while this handler will deal the correct registering.
* </p>
*/
- private List<IStateChangedListener> stateChangeListeners = new ArrayList<IStateChangedListener>();
+ private List<IStateChangedListener> stateChangeListeners = new ArrayList<>();
/**
* Create a new {@link DisplayPersistenceDialogCommandHandler}. Using this
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/gui/PersistenceDialog.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/gui/PersistenceDialog.java
index 53a5d59..7c86c73 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/gui/PersistenceDialog.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/persistence/gui/PersistenceDialog.java
@@ -127,7 +127,7 @@
* List of {@link IStateChangedListener}s that will be notified if states
* are changed using this dialog.
*/
- private List<IStateChangedListener> stateChangeListeners = new ArrayList<IStateChangedListener>();
+ private List<IStateChangedListener> stateChangeListeners = new ArrayList<>();
/**
* Create a new dialog for handling NatTable state.
@@ -225,8 +225,7 @@
this.viewer
.addSelectionChangedListener(event -> {
ISelection selection = event.getSelection();
- if (selection != null
- && selection instanceof IStructuredSelection) {
+ if (selection instanceof IStructuredSelection) {
String configName = ((IStructuredSelection) selection)
.getFirstElement().toString();
PersistenceDialog.this.configNameText.setText(configName);
@@ -304,7 +303,7 @@
StateChangeType.CREATE));
} else if (buttonId == DELETE_ID) {
ISelection selection = this.viewer.getSelection();
- if (selection != null && selection instanceof IStructuredSelection) {
+ if (selection instanceof IStructuredSelection) {
String configName = ((IStructuredSelection) selection)
.getFirstElement().toString();
PersistenceHelper.deleteState(configName, this.properties);
@@ -318,7 +317,7 @@
}
} else if (buttonId == LOAD_ID) {
ISelection selection = this.viewer.getSelection();
- if (selection != null && selection instanceof IStructuredSelection) {
+ if (selection instanceof IStructuredSelection) {
String configName = ((IStructuredSelection) selection)
.getFirstElement().toString();
this.natTable.loadState(configName, this.properties);
@@ -342,7 +341,7 @@
return new Point(
GUIHelper.convertHorizontalPixelToDpi(500, true),
GUIHelper.convertVerticalPixelToDpi(300, true));
- };
+ }
/**
* @return The Properties instance that is used for saving and loading.
@@ -448,7 +447,7 @@
private Styler italicStyler;
ViewConfigurationNameLabelProvider() {
- this.italicFont = GUIHelper.getFont(new FontData[] { new FontData("Arial", 8, SWT.ITALIC) }); //$NON-NLS-1$
+ this.italicFont = GUIHelper.getFont(new FontData("Arial", 8, SWT.ITALIC)); //$NON-NLS-1$
this.italicStyler = new Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/print/config/PrintConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/print/config/PrintConfigAttributes.java
index b664389..a30dd04 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/print/config/PrintConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/print/config/PrintConfigAttributes.java
@@ -19,12 +19,13 @@
/**
* Configuration attributes that are used to configure printing.
*
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- *
* @since 1.5
*/
-public interface PrintConfigAttributes {
+public final class PrintConfigAttributes {
+
+ private PrintConfigAttributes() {
+ // private default constructor for constants class
+ }
/**
* Configuration attribute to configure the scaling mode on printing.
@@ -39,7 +40,7 @@
* and rows are printed on one page</li>
* </ul>
*/
- ConfigAttribute<Direction> FITTING_MODE = new ConfigAttribute<Direction>();
+ public static final ConfigAttribute<Direction> FITTING_MODE = new ConfigAttribute<>();
/**
* Configuration attribute to configure a scaling option in case
@@ -52,28 +53,28 @@
* {@link Direction#HORIZONTAL}.
* </p>
*/
- ConfigAttribute<Boolean> STRETCH = new ConfigAttribute<Boolean>();
+ public static final ConfigAttribute<Boolean> STRETCH = new ConfigAttribute<>();
/**
* Configuration attribute to configure the date format that is used for
* rendering the print date in the footer region. If not specified the
* default value <i>EEE, d MMM yyyy HH:mm a</i> will be used.
*/
- ConfigAttribute<String> DATE_FORMAT = new ConfigAttribute<String>();
+ public static final ConfigAttribute<String> DATE_FORMAT = new ConfigAttribute<>();
/**
* Configuration attribute to configure the height of the footer. Needs to
* be specified in printer DPI value. If not set the default value 300 will
* be used.
*/
- ConfigAttribute<Integer> FOOTER_HEIGHT = new ConfigAttribute<Integer>();
+ public static final ConfigAttribute<Integer> FOOTER_HEIGHT = new ConfigAttribute<>();
/**
* Configuration attribute to configure the style that should be used to
* print the footer. Currently only background color, foreground color and
* font style attributes are supported.
*/
- ConfigAttribute<IStyle> FOOTER_STYLE = new ConfigAttribute<IStyle>();
+ public static final ConfigAttribute<IStyle> FOOTER_STYLE = new ConfigAttribute<>();
/**
* Configuration attribute to configure the pattern for rendering the page
@@ -81,7 +82,7 @@
* current page and the total page count, where {0} = current page and {1} =
* total page count, e.g. <i>Page {0}/{1}</i> to show <i>Page 1/6</i>
*/
- ConfigAttribute<String> FOOTER_PAGE_PATTERN = new ConfigAttribute<String>();
+ public static final ConfigAttribute<String> FOOTER_PAGE_PATTERN = new ConfigAttribute<>();
/**
* Configuration attribute to configure the default orientation of the paper
@@ -90,5 +91,5 @@
*
* @since 1.6
*/
- ConfigAttribute<Integer> DEFAULT_PAGE_ORIENTATION = new ConfigAttribute<Integer>();
+ public static final ConfigAttribute<Integer> DEFAULT_PAGE_ORIENTATION = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/action/ColumnReorderDragMode.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/action/ColumnReorderDragMode.java
index ca6888d..97524b8 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/action/ColumnReorderDragMode.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/action/ColumnReorderDragMode.java
@@ -106,13 +106,10 @@
int dragToGridColumnPosition = -1;
if (moveDirection != null) {
- switch (moveDirection) {
- case LEFT:
- dragToGridColumnPosition = gridColumnPosition;
- break;
- case RIGHT:
- dragToGridColumnPosition = gridColumnPosition + 1;
- break;
+ if (moveDirection == CellEdgeEnum.LEFT) {
+ dragToGridColumnPosition = gridColumnPosition;
+ } else if (moveDirection == CellEdgeEnum.RIGHT) {
+ dragToGridColumnPosition = gridColumnPosition + 1;
}
}
@@ -184,13 +181,10 @@
if (moveDirection != null) {
Rectangle selectedColumnHeaderRect = getColumnCell(ColumnReorderDragMode.this.currentEvent.x).getBounds();
- switch (moveDirection) {
- case LEFT:
- dragToColumnHandleX = selectedColumnHeaderRect.x;
- break;
- case RIGHT:
- dragToColumnHandleX = selectedColumnHeaderRect.x + selectedColumnHeaderRect.width;
- break;
+ if (moveDirection == CellEdgeEnum.LEFT) {
+ dragToColumnHandleX = selectedColumnHeaderRect.x;
+ } else if (moveDirection == CellEdgeEnum.RIGHT) {
+ dragToColumnHandleX = selectedColumnHeaderRect.x + selectedColumnHeaderRect.width;
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/action/RowReorderDragMode.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/action/RowReorderDragMode.java
index fa00e29..75a6800 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/action/RowReorderDragMode.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/action/RowReorderDragMode.java
@@ -117,13 +117,10 @@
int dragToGridRowPosition = -1;
if (moveDirection != null) {
- switch (moveDirection) {
- case TOP:
- dragToGridRowPosition = gridRowPosition;
- break;
- case BOTTOM:
- dragToGridRowPosition = gridRowPosition + 1;
- break;
+ if (moveDirection == CellEdgeEnum.TOP) {
+ dragToGridRowPosition = gridRowPosition;
+ } else if (moveDirection == CellEdgeEnum.BOTTOM) {
+ dragToGridRowPosition = gridRowPosition + 1;
}
}
@@ -228,13 +225,10 @@
Rectangle selectedRowHeaderRect =
getRowCell(RowReorderDragMode.this.currentEvent.y).getBounds();
- switch (moveDirection) {
- case TOP:
- dragToRowHandleY = selectedRowHeaderRect.y;
- break;
- case BOTTOM:
- dragToRowHandleY = selectedRowHeaderRect.y + selectedRowHeaderRect.height;
- break;
+ if (moveDirection == CellEdgeEnum.TOP) {
+ dragToRowHandleY = selectedRowHeaderRect.y;
+ } else if (moveDirection == CellEdgeEnum.BOTTOM) {
+ dragToRowHandleY = selectedRowHeaderRect.y + selectedRowHeaderRect.height;
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/command/MultiColumnReorderCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/command/MultiColumnReorderCommand.java
index e9ec142..16add78 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/command/MultiColumnReorderCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/command/MultiColumnReorderCommand.java
@@ -274,7 +274,7 @@
ColumnPositionCoordinate targetToColumnPositionCoordinate =
LayerCommandUtil.convertColumnPositionToTargetContext(this.toColumnPositionCoordinate, targetLayer);
- if (convertedFromColumnPositionCoordinates.size() > 0
+ if (!convertedFromColumnPositionCoordinates.isEmpty()
&& targetToColumnPositionCoordinate != null) {
this.fromColumnPositionCoordinates = convertedFromColumnPositionCoordinates;
this.toColumnPositionCoordinate = targetToColumnPositionCoordinate;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/command/MultiRowReorderCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/command/MultiRowReorderCommand.java
index c8520c9..88a53f5 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/command/MultiRowReorderCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/command/MultiRowReorderCommand.java
@@ -279,7 +279,7 @@
RowPositionCoordinate targetToRowPositionCoordinate =
LayerCommandUtil.convertRowPositionToTargetContext(this.toRowPositionCoordinate, targetLayer);
- if (convertedFromRowPositionCoordinates.size() > 0
+ if (!convertedFromRowPositionCoordinates.isEmpty()
&& targetToRowPositionCoordinate != null) {
this.fromRowPositionCoordinates = convertedFromRowPositionCoordinates;
this.toRowPositionCoordinate = targetToRowPositionCoordinate;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/event/ColumnReorderEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/event/ColumnReorderEvent.java
index cd749b1..8afe6d6 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/event/ColumnReorderEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/event/ColumnReorderEvent.java
@@ -161,7 +161,7 @@
public ColumnReorderEvent(ColumnReorderEvent event) {
super(event);
this.beforeLayer = event.beforeLayer;
- this.beforeFromColumnPositionRanges = new ArrayList<Range>(event.beforeFromColumnPositionRanges);
+ this.beforeFromColumnPositionRanges = new ArrayList<>(event.beforeFromColumnPositionRanges);
this.beforeFromColumnIndexes = IntLists.mutable.ofAll(event.beforeFromColumnIndexes);
this.beforeToColumnPosition = event.beforeToColumnPosition;
this.beforeToColumnIndex = event.beforeToColumnIndex;
@@ -239,7 +239,7 @@
@Override
public Collection<StructuralDiff> getColumnDiffs() {
- Collection<StructuralDiff> columnDiffs = new ArrayList<StructuralDiff>();
+ Collection<StructuralDiff> columnDiffs = new ArrayList<>();
Collection<Range> beforeFromColumnPositionRanges = getBeforeFromColumnPositionRanges();
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/event/RowReorderEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/event/RowReorderEvent.java
index 23effcb..3576e95 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/event/RowReorderEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/event/RowReorderEvent.java
@@ -238,7 +238,7 @@
@Override
public Collection<StructuralDiff> getRowDiffs() {
- Collection<StructuralDiff> rowDiffs = new ArrayList<StructuralDiff>();
+ Collection<StructuralDiff> rowDiffs = new ArrayList<>();
Collection<Range> beforeFromRowPositionRanges = getBeforeFromRowPositionRanges();
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/AutoResizeHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/AutoResizeHelper.java
index a6a36b3..df2ab17 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/AutoResizeHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/AutoResizeHelper.java
@@ -329,11 +329,11 @@
// only perform further actions if the heights could be
// calculated
// could fail and return null for example if the GCFactory fails
- if (calculatedRowHeights != null) {
+ if (calculatedRowHeights != null && calculatedRowHeights.length > 0) {
// only perform row resize where necessary
// avoid unnecessary commands
- final List<Integer> positions = new ArrayList<Integer>(rowPos.length);
- final List<Integer> heights = new ArrayList<Integer>(rowPos.length);
+ final List<Integer> positions = new ArrayList<>(rowPos.length);
+ final List<Integer> heights = new ArrayList<>(rowPos.length);
for (int i = 0; i < rowPos.length; i++) {
if (this.cancelled) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/MaxCellBoundsHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/MaxCellBoundsHelper.java
index 0e5dc39..04c62da 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/MaxCellBoundsHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/MaxCellBoundsHelper.java
@@ -31,6 +31,10 @@
*/
public class MaxCellBoundsHelper {
+ private MaxCellBoundsHelper() {
+ // private default constructor for helper class
+ }
+
/**
* Calculates the preferred column widths of the given columns based on the
* given {@link IConfigRegistry}. The preferred column width is the width
@@ -64,7 +68,7 @@
return columnWidths;
} else {
- return null;
+ return new int[0];
}
}
@@ -158,7 +162,7 @@
return rowHeights;
} else {
- return null;
+ return new int[0];
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/command/MultiColumnResizeCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/command/MultiColumnResizeCommand.java
index d704647..da3eb76 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/command/MultiColumnResizeCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/command/MultiColumnResizeCommand.java
@@ -26,7 +26,7 @@
public class MultiColumnResizeCommand extends AbstractMultiColumnCommand {
private int commonColumnWidth = -1;
- protected Map<ColumnPositionCoordinate, Integer> colPositionToWidth = new HashMap<ColumnPositionCoordinate, Integer>();
+ protected Map<ColumnPositionCoordinate, Integer> colPositionToWidth = new HashMap<>();
private final boolean downScale;
/**
@@ -124,7 +124,7 @@
protected MultiColumnResizeCommand(MultiColumnResizeCommand command) {
super(command);
this.commonColumnWidth = command.commonColumnWidth;
- this.colPositionToWidth = new HashMap<ColumnPositionCoordinate, Integer>(command.colPositionToWidth);
+ this.colPositionToWidth = new HashMap<>(command.colPositionToWidth);
this.downScale = command.downScale;
}
@@ -172,7 +172,7 @@
*/
@Override
public boolean convertToTargetLayer(ILayer targetLayer) {
- Map<ColumnPositionCoordinate, Integer> newColPositionToWidth = new HashMap<ColumnPositionCoordinate, Integer>();
+ Map<ColumnPositionCoordinate, Integer> newColPositionToWidth = new HashMap<>();
for (ColumnPositionCoordinate columnPositionCoordinate : this.colPositionToWidth.keySet()) {
ColumnPositionCoordinate convertedColumnPositionCoordinate =
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/command/MultiRowResizeCommand.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/command/MultiRowResizeCommand.java
index 65b7891..e61388e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/command/MultiRowResizeCommand.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/command/MultiRowResizeCommand.java
@@ -26,7 +26,7 @@
public class MultiRowResizeCommand extends AbstractMultiRowCommand {
private int commonRowHeight = -1;
- protected Map<RowPositionCoordinate, Integer> rowPositionToHeight = new HashMap<RowPositionCoordinate, Integer>();
+ protected Map<RowPositionCoordinate, Integer> rowPositionToHeight = new HashMap<>();
private final boolean downScale;
/**
@@ -122,7 +122,7 @@
protected MultiRowResizeCommand(MultiRowResizeCommand command) {
super(command);
this.commonRowHeight = command.commonRowHeight;
- this.rowPositionToHeight = new HashMap<RowPositionCoordinate, Integer>(command.rowPositionToHeight);
+ this.rowPositionToHeight = new HashMap<>(command.rowPositionToHeight);
this.downScale = command.downScale;
}
@@ -164,7 +164,7 @@
@Override
public boolean convertToTargetLayer(ILayer targetLayer) {
- Map<RowPositionCoordinate, Integer> newRowPositionToHeight = new HashMap<RowPositionCoordinate, Integer>();
+ Map<RowPositionCoordinate, Integer> newRowPositionToHeight = new HashMap<>();
for (RowPositionCoordinate rowPositionCoordinate : this.rowPositionToHeight.keySet()) {
RowPositionCoordinate convertedRowPositionCoordinate =
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/event/ColumnResizeEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/event/ColumnResizeEvent.java
index 7d09fd1..2d9167c 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/event/ColumnResizeEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/event/ColumnResizeEvent.java
@@ -42,7 +42,7 @@
@Override
public Collection<StructuralDiff> getColumnDiffs() {
- Collection<StructuralDiff> rowDiffs = new ArrayList<StructuralDiff>(getColumnPositionRanges().size());
+ Collection<StructuralDiff> rowDiffs = new ArrayList<>(getColumnPositionRanges().size());
for (Range range : getColumnPositionRanges()) {
rowDiffs.add(new StructuralDiff(DiffTypeEnum.CHANGE, range, range));
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/event/RowResizeEvent.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/event/RowResizeEvent.java
index 144ff04..0512581 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/event/RowResizeEvent.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/event/RowResizeEvent.java
@@ -42,7 +42,7 @@
@Override
public Collection<StructuralDiff> getRowDiffs() {
- Collection<StructuralDiff> rowDiffs = new ArrayList<StructuralDiff>(getRowPositionRanges().size());
+ Collection<StructuralDiff> rowDiffs = new ArrayList<>(getRowPositionRanges().size());
for (Range range : getRowPositionRanges()) {
new StructuralDiff(DiffTypeEnum.CHANGE, range, range);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/mode/ColumnResizeDragMode.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/mode/ColumnResizeDragMode.java
index be71a0c..320d9d6 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/mode/ColumnResizeDragMode.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/mode/ColumnResizeDragMode.java
@@ -72,7 +72,7 @@
} else {
int overlayExtent = ColumnResizeOverlayPainter.COLUMN_RESIZE_OVERLAY_WIDTH / 2;
- Set<Integer> columnsToRepaint = new HashSet<Integer>();
+ Set<Integer> columnsToRepaint = new HashSet<>();
columnsToRepaint.add(natTable.getColumnPositionByX(this.currentX - overlayExtent));
columnsToRepaint.add(natTable.getColumnPositionByX(this.currentX + overlayExtent));
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/mode/RowResizeDragMode.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/mode/RowResizeDragMode.java
index daba8ed..ca2c9f3 100755
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/mode/RowResizeDragMode.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/resize/mode/RowResizeDragMode.java
@@ -71,7 +71,7 @@
} else {
int overlayExtent = RowResizeOverlayPainter.ROW_RESIZE_OVERLAY_HEIGHT / 2;
- Set<Integer> rowsToRepaint = new HashSet<Integer>();
+ Set<Integer> rowsToRepaint = new HashSet<>();
rowsToRepaint.add(natTable.getRowPositionByY(this.currentY - overlayExtent));
rowsToRepaint.add(natTable.getRowPositionByY(this.currentY + overlayExtent));
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/action/SearchAction.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/action/SearchAction.java
index a8ce739..6fe65de 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/action/SearchAction.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/action/SearchAction.java
@@ -131,7 +131,7 @@
setActiveContext();
if (this.dialog == null) {
this.dialog = new SearchDialog(this.natTable.getShell(),
- new CellValueAsStringComparator<String>(),
+ new CellValueAsStringComparator<>(),
this.modal ? SWT.NONE : SWT.APPLICATION_MODAL);
this.dialog.setInput(this.natTable, this.dialogSettings);
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/command/SearchGridCellsCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/command/SearchGridCellsCommandHandler.java
index 85c0f75..d06ead0 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/command/SearchGridCellsCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/command/SearchGridCellsCommandHandler.java
@@ -12,8 +12,6 @@
******************************************************************************/
package org.eclipse.nebula.widgets.nattable.search.command;
-import java.util.regex.PatternSyntaxException;
-
import org.eclipse.nebula.widgets.nattable.command.ILayerCommandHandler;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
@@ -35,10 +33,10 @@
@Override
public Class<SearchCommand> getCommandClass() {
return SearchCommand.class;
- };
+ }
@Override
- public boolean doCommand(ILayer targetLayer, SearchCommand searchCommand) throws PatternSyntaxException {
+ public boolean doCommand(ILayer targetLayer, SearchCommand searchCommand) {
searchCommand.convertToTargetLayer(targetLayer);
final ILayerListener searchEventListener = searchCommand.getSearchEventListener();
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/gui/SearchDialog.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/gui/SearchDialog.java
index a9e158b..19a5efb 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/gui/SearchDialog.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/gui/SearchDialog.java
@@ -13,12 +13,12 @@
******************************************************************************/
package org.eclipse.nebula.widgets.nattable.search.gui;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.Stack;
import java.util.regex.PatternSyntaxException;
import org.eclipse.jface.dialogs.Dialog;
@@ -91,7 +91,7 @@
* when the search term is shortened. In non-incremental mode, the stack
* contains only the most recent selection.
*/
- private Stack<SelectionItem> selections = new Stack<SelectionItem>();
+ private ArrayDeque<SelectionItem> selections = new ArrayDeque<>();
// Dialog settings
private IDialogSettings originalSettings;
@@ -101,7 +101,7 @@
// Find Combo box
private Combo findCombo;
- private List<String> findHistory = new ArrayList<String>(5);
+ private List<String> findHistory = new ArrayList<>(5);
// Direction radio
private Button forwardButton;
@@ -150,7 +150,7 @@
this.natTable = natTable;
if (natTable != null) {
ILayer result = findSelectionLayer(this.natTable.getLayer());
- if (result != null && result instanceof SelectionLayer) {
+ if (result instanceof SelectionLayer) {
this.selectionLayer = (SelectionLayer) result;
if (this.findButton != null && !this.findButton.isDisposed()) {
this.findButton.setEnabled(true);
@@ -223,7 +223,7 @@
// search SelectionLayer in layer stack
ILayer result = findSelectionLayer(this.natTable.getLayer());
- if (result != null && result instanceof SelectionLayer) {
+ if (result instanceof SelectionLayer) {
this.selectionLayer = (SelectionLayer) result;
}
@@ -833,7 +833,7 @@
*/
private void writeHistory(List<String> history, IDialogSettings settings, String sectionName) {
int itemCount = history.size();
- Set<String> distinctItems = new HashSet<String>(itemCount);
+ Set<String> distinctItems = new HashSet<>(itemCount);
for (int i = 0; i < itemCount; i++) {
String item = history.get(i);
if (distinctItems.contains(item)) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/CellDisplayValueSearchUtil.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/CellDisplayValueSearchUtil.java
index 87cd006..3a7479a 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/CellDisplayValueSearchUtil.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/CellDisplayValueSearchUtil.java
@@ -29,7 +29,11 @@
import org.eclipse.nebula.widgets.nattable.search.strategy.GridSearchStrategy.GridRectangle;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
-public class CellDisplayValueSearchUtil {
+public final class CellDisplayValueSearchUtil {
+
+ private CellDisplayValueSearchUtil() {
+ // private default constructor for helper class
+ }
static List<PositionCoordinate> getCellCoordinates(
ILayer contextLayer,
@@ -37,7 +41,7 @@
int startingRowPosition,
int width,
int height) {
- List<PositionCoordinate> coordinates = new ArrayList<PositionCoordinate>(width * height);
+ List<PositionCoordinate> coordinates = new ArrayList<>(width * height);
for (int columnPosition = 0; columnPosition < width; columnPosition++) {
for (int rowPosition = 0; rowPosition < height; rowPosition++) {
PositionCoordinate coordinate = new PositionCoordinate(
@@ -57,7 +61,7 @@
int startingRowPosition,
int width,
int height) {
- List<PositionCoordinate> coordinates = new ArrayList<PositionCoordinate>(width * height);
+ List<PositionCoordinate> coordinates = new ArrayList<>(width * height);
for (int columnPosition = width; columnPosition >= 0 && startingColumnPosition >= 0; columnPosition--) {
for (int rowPosition = height; rowPosition >= 0 && startingRowPosition >= 0; rowPosition--) {
PositionCoordinate coordinate = new PositionCoordinate(
@@ -77,7 +81,7 @@
int startingRowPosition,
int width,
int height) {
- List<PositionCoordinate> coordinates = new ArrayList<PositionCoordinate>(width * height);
+ List<PositionCoordinate> coordinates = new ArrayList<>(width * height);
for (int rowPosition = 0; rowPosition < height; rowPosition++) {
for (int columnPosition = 0; columnPosition < width; columnPosition++) {
PositionCoordinate coordinate = new PositionCoordinate(
@@ -97,7 +101,7 @@
int startingRowPosition,
int width,
int height) {
- List<PositionCoordinate> coordinates = new ArrayList<PositionCoordinate>(width * height);
+ List<PositionCoordinate> coordinates = new ArrayList<>(width * height);
for (int rowPosition = height; rowPosition >= 0 && startingRowPosition >= 0; rowPosition--) {
for (int columnPosition = width; columnPosition >= 0 && startingColumnPosition >= 0; columnPosition--) {
PositionCoordinate coordinate = new PositionCoordinate(
@@ -136,7 +140,7 @@
final boolean caseSensitive,
final boolean wholeWord,
final boolean regex,
- final boolean includeCollapsed) throws PatternSyntaxException {
+ final boolean includeCollapsed) {
String stringValue = caseSensitive ? valueToMatch.toString() : valueToMatch.toString().toLowerCase();
Pattern pattern = regex ? Pattern.compile(stringValue) : null;
for (int cellIndex = 0; cellIndex < cellsToSearch.length; cellIndex++) {
@@ -184,7 +188,7 @@
final boolean wholeWord,
final boolean regex,
final boolean columnFirst,
- final boolean includeCollapsed) throws PatternSyntaxException {
+ final boolean includeCollapsed) {
String stringValue = caseSensitive ? valueToMatch.toString() : valueToMatch.toString().toLowerCase();
Pattern pattern = regex ? Pattern.compile(stringValue) : null;
for (GridRectangle cellRectangle : cellRectangles) {
@@ -247,7 +251,7 @@
boolean wholeWord,
boolean regex,
final boolean columnFirst,
- boolean includeCollapsed) throws PatternSyntaxException {
+ boolean includeCollapsed) {
int columnPosition;
int rowPosition;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/ColumnSearchStrategy.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/ColumnSearchStrategy.java
index 722ae8d..4796c93 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/ColumnSearchStrategy.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/ColumnSearchStrategy.java
@@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
-import java.util.regex.PatternSyntaxException;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
@@ -40,7 +39,7 @@
}
@Override
- public PositionCoordinate executeSearch(Object valueToMatch) throws PatternSyntaxException {
+ public PositionCoordinate executeSearch(Object valueToMatch) {
@SuppressWarnings("unchecked")
Comparator<String> comparator = (Comparator<String>) getComparator();
return CellDisplayValueSearchUtil.findCell(
@@ -64,7 +63,7 @@
}
protected PositionCoordinate[] getColumnCellsToSearch(ILayer contextLayer) {
- List<PositionCoordinate> cellsToSearch = new ArrayList<PositionCoordinate>();
+ List<PositionCoordinate> cellsToSearch = new ArrayList<>();
int rowPosition = this.startingRowPosition;
// See how many rows we can add, depends on where the search is starting
// from
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/GridSearchStrategy.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/GridSearchStrategy.java
index 831ee12..6798bb6 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/GridSearchStrategy.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/GridSearchStrategy.java
@@ -17,7 +17,6 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
-import java.util.regex.PatternSyntaxException;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
@@ -47,11 +46,11 @@
}
@Override
- public PositionCoordinate executeSearch(Object valueToMatch) throws PatternSyntaxException {
+ public PositionCoordinate executeSearch(Object valueToMatch) {
ILayer contextLayer = getContextLayer();
if (!(contextLayer instanceof SelectionLayer)) {
- throw new RuntimeException("For the GridSearchStrategy to work it needs the selectionLayer to be passed as the contextLayer."); //$NON-NLS-1$
+ throw new IllegalStateException("For the GridSearchStrategy to work it needs the selectionLayer to be passed as the contextLayer."); //$NON-NLS-1$
}
SelectionLayer selectionLayer = (SelectionLayer) contextLayer;
PositionCoordinate selectionAnchor = selectionLayer.getSelectionAnchor();
@@ -166,7 +165,7 @@
int firstDimPosition, int secondDimPosition, int direction,
int firstDimStart, int firstDimEnd, int secondDimStart, int secondDimEnd) {
- List<GridRectangle> gridRanges = new ArrayList<GridRectangle>();
+ List<GridRectangle> gridRanges = new ArrayList<>();
GridRectangle gridRange;
// One first-dimension slice starting at the second
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/RowSearchStrategy.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/RowSearchStrategy.java
index 70d1710..3db3e9d 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/RowSearchStrategy.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/RowSearchStrategy.java
@@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
-import java.util.regex.PatternSyntaxException;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
@@ -40,7 +39,7 @@
}
@Override
- public PositionCoordinate executeSearch(Object valueToMatch) throws PatternSyntaxException {
+ public PositionCoordinate executeSearch(Object valueToMatch) {
@SuppressWarnings("unchecked")
Comparator<String> comparator = (Comparator<String>) getComparator();
return CellDisplayValueSearchUtil.findCell(
@@ -64,7 +63,7 @@
}
protected PositionCoordinate[] getRowCellsToSearch(ILayer contextLayer) {
- List<PositionCoordinate> cellsToSearch = new ArrayList<PositionCoordinate>();
+ List<PositionCoordinate> cellsToSearch = new ArrayList<>();
int columnPosition = this.startingColumnPosition;
// See how many columns we can add, depends on where the search is
// starting from
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/SelectionSearchStrategy.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/SelectionSearchStrategy.java
index 2784b35..9b16fc4 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/SelectionSearchStrategy.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/search/strategy/SelectionSearchStrategy.java
@@ -17,7 +17,6 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import java.util.regex.PatternSyntaxException;
import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommand;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
@@ -45,7 +44,7 @@
}
@Override
- public PositionCoordinate executeSearch(Object valueToMatch) throws PatternSyntaxException {
+ public PositionCoordinate executeSearch(Object valueToMatch) {
ILayer contextLayer = getContextLayer();
if (!(contextLayer instanceof SelectionLayer)) {
throw new RuntimeException("For the SelectionSearchStrategy to work it needs the selectionLayer to be passed as the contextLayer."); //$NON-NLS-1$
@@ -89,7 +88,7 @@
int index = coordinates.indexOf(selectionAnchor);
// reorder to make the selection anchor the first element in the
// list
- List<PositionCoordinate> reordered = new ArrayList<PositionCoordinate>(coordinates.subList(index + 1, coordinates.size()));
+ List<PositionCoordinate> reordered = new ArrayList<>(coordinates.subList(index + 1, coordinates.size()));
if (this.wrapSearch) {
reordered.addAll(coordinates.subList(0, index + 1));
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/ITraversalStrategy.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/ITraversalStrategy.java
index 127cb3d..8f4b821 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/ITraversalStrategy.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/ITraversalStrategy.java
@@ -120,7 +120,7 @@
@Override
public boolean isValidTarget(ILayerCell from, ILayerCell to) {
return true;
- };
+ }
};
/**
@@ -155,7 +155,7 @@
@Override
public boolean isValidTarget(ILayerCell from, ILayerCell to) {
return true;
- };
+ }
};
/**
@@ -191,7 +191,7 @@
@Override
public boolean isValidTarget(ILayerCell from, ILayerCell to) {
return true;
- };
+ }
};
/**
@@ -227,6 +227,6 @@
@Override
public boolean isValidTarget(ILayerCell from, ILayerCell to) {
return true;
- };
+ }
};
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/RowSelectionModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/RowSelectionModel.java
index f51a222..60ce677 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/RowSelectionModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/RowSelectionModel.java
@@ -64,7 +64,7 @@
this.rowIdAccessor = rowIdAccessor;
this.multipleSelectionAllowed = multipleSelectionAllowed;
- this.selectedRows = new HashMap<Serializable, R>();
+ this.selectedRows = new HashMap<>();
this.selectionsLock = new ReentrantReadWriteLock();
}
@@ -181,7 +181,7 @@
} finally {
this.selectionsLock.writeLock().unlock();
}
- };
+ }
@Override
public boolean isEmpty() {
@@ -379,8 +379,7 @@
private Serializable getRowIdByPosition(int rowPosition) {
R rowObject = getRowObjectByPosition(rowPosition);
if (rowObject != null) {
- Serializable rowId = this.rowIdAccessor.getRowId(rowObject);
- return rowId;
+ return this.rowIdAccessor.getRowId(rowObject);
}
return null;
}
@@ -392,8 +391,7 @@
int rowIndex = this.selectionLayer.getRowIndexByPosition(rowPosition);
if (rowIndex >= 0) {
try {
- R rowObject = this.rowDataProvider.getRowObject(rowIndex);
- return rowObject;
+ return this.rowDataProvider.getRowObject(rowIndex);
} catch (Exception e) {
// row index is invalid for the data provider
}
@@ -414,8 +412,7 @@
if (rowIndex == -1) {
return -1;
}
- int rowPosition = this.selectionLayer.getRowPositionByIndex(rowIndex);
- return rowPosition;
+ return this.selectionLayer.getRowPositionByIndex(rowIndex);
} finally {
this.selectionsLock.readLock().unlock();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/RowSelectionProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/RowSelectionProvider.java
index 628fa92..eaa5153 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/RowSelectionProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/RowSelectionProvider.java
@@ -62,7 +62,7 @@
/**
* Collection of ISelectionChangedListeners to this ISelectionProvider
*/
- private Set<ISelectionChangedListener> listeners = new HashSet<ISelectionChangedListener>();
+ private Set<ISelectionChangedListener> listeners = new HashSet<>();
/**
* Locally stored previous selection which is used to determine if a
* SelectionChangedEvent should be fired. It is used to avoid firing events
@@ -238,7 +238,7 @@
}
if (!selection.isEmpty()) {
List<T> rowObjects = ((IStructuredSelection) selection).toList();
- Set<Integer> rowPositions = new HashSet<Integer>();
+ Set<Integer> rowPositions = new HashSet<>();
for (T rowObject : rowObjects) {
int rowIndex = this.rowDataProvider.indexOfRowObject(rowObject);
int rowPosition = this.selectionLayer.getRowPositionByIndex(rowIndex);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectRowCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectRowCommandHandler.java
index f596c34..628620d 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectRowCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectRowCommandHandler.java
@@ -116,7 +116,7 @@
boolean withControlMask,
int rowPositionToMoveIntoViewport) {
- HashSet<Range> changedRowRanges = new HashSet<Range>();
+ HashSet<Range> changedRowRanges = new HashSet<>();
for (int rowPosition : rowPositions) {
changedRowRanges.addAll(
@@ -152,7 +152,7 @@
int columnPosition, int rowPosition,
boolean withShiftMask, boolean withControlMask) {
- HashSet<Range> changedRowRanges = new HashSet<Range>();
+ HashSet<Range> changedRowRanges = new HashSet<>();
if (noShiftOrControl(withShiftMask, withControlMask)) {
changedRowRanges.addAll(this.selectionLayer.getSelectedRowPositions());
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectRowGroupCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectRowGroupCommandHandler.java
index a5d3074..f72cb6a 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectRowGroupCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectRowGroupCommandHandler.java
@@ -100,7 +100,7 @@
int rowPositionToMoveIntoViewport,
boolean moveAnchorToTopOfGroup) {
- HashSet<Range> changedRowRanges = new HashSet<Range>();
+ HashSet<Range> changedRowRanges = new HashSet<>();
if (rowPositions.length > 0) {
changedRowRanges.addAll(internalSelectRow(
@@ -132,7 +132,7 @@
boolean withControlMask,
boolean moveAnchorToTopOfGroup) {
- HashSet<Range> changedRowRanges = new HashSet<Range>();
+ HashSet<Range> changedRowRanges = new HashSet<>();
if (noShiftOrControl(withShiftMask, withControlMask)) {
changedRowRanges.addAll(this.selectionLayer.getSelectedRowPositions());
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionConfigAttributes.java
index be0ab30..a712ece 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionConfigAttributes.java
@@ -24,12 +24,16 @@
*
* @since 1.4
*/
-public interface SelectionConfigAttributes {
+public final class SelectionConfigAttributes {
+
+ private SelectionConfigAttributes() {
+ // private default constructor for constants class
+ }
/**
* ConfigAttribute to configure the line style used to render the selection
* border around selected cells. This is the line that surrounds an active
* selection. By default this is the black dotted one pixel line.
*/
- ConfigAttribute<BorderStyle> SELECTION_GRID_LINE_STYLE = new ConfigAttribute<BorderStyle>();
+ public static final ConfigAttribute<BorderStyle> SELECTION_GRID_LINE_STYLE = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayer.java
index 6290a22..2e88b3f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayer.java
@@ -287,7 +287,7 @@
int[] selectedColumnPositions = getSelectedColumnPositions();
Set<Range> selectedRowPositions = getSelectedRowPositions();
- List<PositionCoordinate> selectedCells = new LinkedList<PositionCoordinate>();
+ List<PositionCoordinate> selectedCells = new LinkedList<>();
for (int columnPositionIndex = 0; columnPositionIndex < selectedColumnPositions.length; columnPositionIndex++) {
final int columnPosition = selectedColumnPositions[columnPositionIndex];
@@ -311,7 +311,7 @@
* @return The selected ILayerCells
*/
public Collection<ILayerCell> getSelectedCells() {
- Set<ILayerCell> selectedCells = new LinkedHashSet<ILayerCell>();
+ Set<ILayerCell> selectedCells = new LinkedHashSet<>();
PositionCoordinate[] selectedCoords = getSelectedCellPositions();
for (PositionCoordinate coord : selectedCoords) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayerPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayerPainter.java
index aa4b0d1..fbb1624 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayerPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayerPainter.java
@@ -247,6 +247,7 @@
* the starting y coordinate of the area we can draw on. The fix
* will not be applied if the <code>cellBounds</code> are placed
* on this limit.
+ * @return Updated rectangle.
*
* @since 1.5
*/
@@ -279,6 +280,20 @@
* detecting overlapping of cells, which should not be possible in the same
* layer. It's not perfect, there might be false positives.
*
+ * @param ix
+ * column position
+ * @param iy
+ * row position
+ * @param xOffset
+ * column offset
+ * @param yOffset
+ * row offset
+ * @param cellBounds
+ * cell bounds
+ * @param borderCells
+ * available border cells
+ * @return <code>true</code> if the cell is part of the current layer.
+ *
* @since 1.5
*/
protected boolean isInCurrentLayer(int ix, int iy, int xOffset, int yOffset, Rectangle cellBounds, BorderCell[][] borderCells) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionModel.java
index 1f70544..8bba251 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionModel.java
@@ -64,7 +64,7 @@
this.selectionLayer = selectionLayer;
this.multipleSelectionAllowed = multipleSelectionAllowed;
- this.selections = new LinkedList<Rectangle>();
+ this.selections = new LinkedList<>();
this.selectionsLock = new ReentrantReadWriteLock();
}
@@ -105,7 +105,7 @@
if (intersection.equals(r)) {
// r is a subset of intersection
if (itemsToRemove == null) {
- itemsToRemove = new ArrayList<Rectangle>();
+ itemsToRemove = new ArrayList<>();
}
itemsToRemove.add(r);
@@ -152,8 +152,8 @@
@Override
public void clearSelection(Rectangle removedSelection) {
- List<Rectangle> removedItems = new LinkedList<Rectangle>();
- List<Rectangle> addedItems = new LinkedList<Rectangle>();
+ List<Rectangle> removedItems = new LinkedList<>();
+ List<Rectangle> addedItems = new LinkedList<>();
this.selectionsLock.readLock().lock();
@@ -187,7 +187,7 @@
this.selectionsLock.readLock().unlock();
}
- if (removedItems.size() > 0) {
+ if (!removedItems.isEmpty()) {
this.selectionsLock.writeLock().lock();
try {
this.selections.removeAll(removedItems);
@@ -198,7 +198,7 @@
removedItems.clear();
}
- if (addedItems.size() > 0) {
+ if (!addedItems.isEmpty()) {
this.selectionsLock.writeLock().lock();
try {
this.selections.addAll(addedItems);
@@ -257,7 +257,7 @@
@Override
public int[] getSelectedColumnPositions() {
- TreeSet<Integer> selectedColumns = new TreeSet<Integer>();
+ TreeSet<Integer> selectedColumns = new TreeSet<>();
this.selectionsLock.readLock().lock();
@@ -286,7 +286,7 @@
* @since 1.5
*/
protected Set<Range> internalGetSelectedColumnPositions() {
- Set<Range> selectedColumnsRange = new HashSet<Range>();
+ Set<Range> selectedColumnsRange = new HashSet<>();
this.selectionsLock.readLock().lock();
@@ -302,9 +302,9 @@
this.selectionsLock.readLock().unlock();
}
- ArrayList<Range> ranges = new ArrayList<Range>(selectedColumnsRange);
+ ArrayList<Range> ranges = new ArrayList<>(selectedColumnsRange);
Range.sortByStart(ranges);
- List<Range> uniqueRanges = new ArrayList<Range>(ranges.size());
+ List<Range> uniqueRanges = new ArrayList<>(ranges.size());
// Adjust for overlaps - between consecutive selections
for (int i = 0; i < ranges.size(); i++) {
@@ -323,7 +323,7 @@
uniqueRanges.add(ranges.get(i));
}
}
- return new HashSet<Range>(uniqueRanges);
+ return new HashSet<>(uniqueRanges);
}
@Override
@@ -371,7 +371,7 @@
try {
// Aggregate all rectangles in the column which are in the selection
// model
- List<Rectangle> selectedRectanglesInColumn = new ArrayList<Rectangle>(this.selections.size());
+ List<Rectangle> selectedRectanglesInColumn = new ArrayList<>(this.selections.size());
// If X is same add up the height of the selected area
for (Rectangle r : this.selections) {
@@ -432,7 +432,7 @@
@Override
public Set<Range> getSelectedRowPositions() {
- Set<Range> selectedRowsRange = new HashSet<Range>();
+ Set<Range> selectedRowsRange = new HashSet<>();
this.selectionsLock.readLock().lock();
@@ -448,9 +448,9 @@
this.selectionsLock.readLock().unlock();
}
- ArrayList<Range> ranges = new ArrayList<Range>(selectedRowsRange);
+ ArrayList<Range> ranges = new ArrayList<>(selectedRowsRange);
Range.sortByStart(ranges);
- List<Range> uniqueRanges = new ArrayList<Range>(ranges.size());
+ List<Range> uniqueRanges = new ArrayList<>(ranges.size());
// Adjust for overlaps - between consecutive selections
for (int i = 0; i < ranges.size(); i++) {
@@ -469,7 +469,7 @@
uniqueRanges.add(ranges.get(i));
}
}
- return new HashSet<Range>(uniqueRanges);
+ return new HashSet<>(uniqueRanges);
}
@Override
@@ -513,7 +513,7 @@
try {
// Aggregate all rectangles in the row which are in the selection
// model
- List<Rectangle> selectedRectanglesInRow = new ArrayList<Rectangle>(this.selections.size());
+ List<Rectangle> selectedRectanglesInRow = new ArrayList<>(this.selections.size());
// If X is same add up the width of the selected area
for (Rectangle r : this.selections) {
@@ -575,12 +575,11 @@
private Rectangle getLeftSelection(Rectangle intersection, Rectangle selection) {
if (intersection.x > selection.x) {
- Rectangle leftSelection = new Rectangle(
+ return new Rectangle(
selection.x,
selection.y,
intersection.x - selection.x,
selection.height);
- return leftSelection;
}
return null;
@@ -590,13 +589,11 @@
int newX = intersection.x + intersection.width;
if (newX < selection.x + selection.width) {
- Rectangle rightSelection = new Rectangle(
+ return new Rectangle(
newX,
selection.y,
selection.x + selection.width - newX,
selection.height);
-
- return rightSelection;
}
return null;
@@ -604,12 +601,11 @@
private Rectangle getTopSelection(Rectangle intersection, Rectangle selection) {
if (intersection.y > selection.y) {
- Rectangle topSelection = new Rectangle(
+ return new Rectangle(
selection.x,
selection.y,
selection.width,
intersection.y - selection.y);
- return topSelection;
}
return null;
}
@@ -618,12 +614,11 @@
int newY = intersection.y + intersection.height;
if (newY < selection.y + selection.height) {
- Rectangle bottomSelection = new Rectangle(
+ return new Rectangle(
selection.x,
newY,
selection.width,
selection.y + selection.height - newY);
- return bottomSelection;
}
return null;
@@ -725,11 +720,7 @@
}
// if the selection layer is empty, we should clear the selection also
- if (this.selectionLayer.getRowCount() == 0 && !this.isEmpty()) {
- return true;
- }
-
- return false;
+ return (this.selectionLayer.getRowCount() == 0 && !this.isEmpty());
}
private boolean selectedColumnModified(Range changedRange) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionUtils.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionUtils.java
index d8dbf18..3d99a63 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionUtils.java
@@ -26,7 +26,11 @@
/**
* Helper class to operate with selections.
*/
-public class SelectionUtils {
+public final class SelectionUtils {
+
+ private SelectionUtils() {
+ // private default constructor for helper class
+ }
/**
*
@@ -209,7 +213,7 @@
IRowDataProvider<T> rowDataProvider,
boolean fullySelectedRowsOnly) {
- List<RowObjectIndexHolder<T>> rows = new ArrayList<RowObjectIndexHolder<T>>();
+ List<RowObjectIndexHolder<T>> rows = new ArrayList<>();
if (selectionLayer != null) {
if (fullySelectedRowsOnly) {
@@ -226,7 +230,7 @@
}
}
Collections.sort(rows);
- List<T> rowObjects = new ArrayList<T>(rows.size());
+ List<T> rowObjects = new ArrayList<>(rows.size());
for (RowObjectIndexHolder<T> holder : rows) {
rowObjects.add(holder.getRow());
}
@@ -242,7 +246,7 @@
int rowIndex = selectionLayer.getRowIndexByPosition(rowPosition);
if (rowIndex >= 0 && rowIndex < rowDataProvider.getRowCount()) {
T rowObject = rowDataProvider.getRowObject(rowIndex);
- rows.add(new RowObjectIndexHolder<T>(rowIndex, rowObject));
+ rows.add(new RowObjectIndexHolder<>(rowIndex, rowObject));
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/DefaultRowSelectionLayerConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/DefaultRowSelectionLayerConfiguration.java
index a77218c..17fff3e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/DefaultRowSelectionLayerConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/DefaultRowSelectionLayerConfiguration.java
@@ -25,7 +25,6 @@
addConfiguration(new RowOnlySelectionBindings());
}
- @SuppressWarnings("rawtypes")
@Override
protected void addMoveSelectionConfig() {
addConfiguration(new RowOnlySelectionConfiguration());
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/DefaultSelectionStyleConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/DefaultSelectionStyleConfiguration.java
index 0381245..2905090 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/DefaultSelectionStyleConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/DefaultSelectionStyleConfiguration.java
@@ -31,6 +31,8 @@
/**
* Sets up rendering style used for selected areas and the selection anchor.
*/
+// fields are public by design to make it easy for adapters to customize styling
+@SuppressWarnings("java:S1104")
public class DefaultSelectionStyleConfiguration extends AbstractRegistryConfiguration {
// Selection style
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/RowOnlySelectionConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/RowOnlySelectionConfiguration.java
index 7ba8580..4f2c3f7 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/RowOnlySelectionConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/config/RowOnlySelectionConfiguration.java
@@ -23,7 +23,7 @@
*
* @see DefaultMoveSelectionConfiguration
*/
-public class RowOnlySelectionConfiguration<T> extends AbstractLayerConfiguration<SelectionLayer> {
+public class RowOnlySelectionConfiguration extends AbstractLayerConfiguration<SelectionLayer> {
@Override
public void configureTypedLayer(SelectionLayer layer) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/preserve/PreserveSelectionModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/preserve/PreserveSelectionModel.java
index 23925bb..708ee96 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/preserve/PreserveSelectionModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/preserve/PreserveSelectionModel.java
@@ -630,7 +630,7 @@
this.selectionAnchor = null;
} else {
this.selectionAnchor =
- new CellPosition<T>(getRowObjectByPosition(coordinate.y), coordinate.x);
+ new CellPosition<>(getRowObjectByPosition(coordinate.y), coordinate.x);
}
} finally {
this.selectionsLock.writeLock().unlock();
@@ -647,7 +647,7 @@
this.lastSelectedCell = null;
} else {
this.lastSelectedCell =
- new CellPosition<T>(getRowObjectByPosition(coordinate.y), coordinate.x);
+ new CellPosition<>(getRowObjectByPosition(coordinate.y), coordinate.x);
}
} finally {
this.selectionsLock.writeLock().unlock();
@@ -708,7 +708,7 @@
// first handle deletion, then handle insert
// this is to avoid mixed operations that might lead to
// confusing indexes
- List<Integer> removed = new ArrayList<Integer>();
+ List<Integer> removed = new ArrayList<>();
for (StructuralDiff columnDiff : diffs) {
if (columnDiff.getDiffType() != null
&& columnDiff.getDiffType().equals(DiffTypeEnum.DELETE)) {
@@ -752,7 +752,7 @@
if (event.isVerticalStructureChanged()) {
// the change is already done and we don't know about indexes, so we
// need to check if the selected objects still exist
- Collection<Serializable> keysToRemove = new ArrayList<Serializable>();
+ Collection<Serializable> keysToRemove = new ArrayList<>();
for (Selections.Row<T> row : this.selections.getRows()) {
if (!ignoreVerticalChange(row)) {
int rowIndex = this.rowDataProvider.indexOfRowObject(row.getRowObject());
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/preserve/Selections.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/preserve/Selections.java
index f8238c5..bf52d64 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/preserve/Selections.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/preserve/Selections.java
@@ -39,7 +39,7 @@
/**
* A map for looking up rows given their row IDs
*/
- private HashMap<Serializable, Row<T>> selectedRows = new HashMap<Serializable, Row<T>>();
+ private HashMap<Serializable, Row<T>> selectedRows = new HashMap<>();
/**
* A map for looking up columns given their column positions
@@ -123,7 +123,7 @@
this.selectedColumns.remove(columnPosition);
}
- HashSet<Serializable> toRemove = new HashSet<Serializable>();
+ HashSet<Serializable> toRemove = new HashSet<>();
for (Map.Entry<Serializable, Row<T>> entry : this.selectedRows.entrySet()) {
entry.getValue().removeItem(columnPosition);
if (!entry.getValue().hasSelection()) {
@@ -148,8 +148,8 @@
// also update the row references
for (Row<T> row : this.selectedRows.values()) {
- HashSet<Integer> toRemove = new HashSet<Integer>();
- HashSet<Integer> toAdd = new HashSet<Integer>();
+ HashSet<Integer> toRemove = new HashSet<>();
+ HashSet<Integer> toAdd = new HashSet<>();
for (Integer col : row.getItems()) {
if (col <= i) {
toRemove.add(i);
@@ -175,8 +175,8 @@
// also update the row references
for (Row<T> row : this.selectedRows.values()) {
- HashSet<Integer> toRemove = new HashSet<Integer>();
- HashSet<Integer> toAdd = new HashSet<Integer>();
+ HashSet<Integer> toRemove = new HashSet<>();
+ HashSet<Integer> toAdd = new HashSet<>();
for (Integer col : row.getItems()) {
if (col >= i) {
toRemove.add(i);
@@ -249,10 +249,10 @@
* @return all selected cell positions
*/
Collection<CellPosition<T>> getSelections() {
- ArrayList<CellPosition<T>> selectedCells = new ArrayList<CellPosition<T>>();
+ ArrayList<CellPosition<T>> selectedCells = new ArrayList<>();
for (Row<T> row : this.selectedRows.values()) {
for (int columnPosition : row.getItems()) {
- CellPosition<T> cell = new CellPosition<T>(row.getRowObject(), columnPosition);
+ CellPosition<T> cell = new CellPosition<>(row.getRowObject(), columnPosition);
selectedCells.add(cell);
}
}
@@ -310,7 +310,7 @@
private Row<T> retrieveRow(Serializable rowId, T rowObject) {
Row<T> row = getSelectedColumns(rowId);
if (row == null) {
- row = new Row<T>(rowId, rowObject);
+ row = new Row<>(rowId, rowObject);
this.selectedRows.put(rowId, row);
}
return row;
@@ -413,7 +413,7 @@
/**
* The selected items
*/
- private HashSet<S> content = new HashSet<S>();
+ private HashSet<S> content = new HashSet<>();
/**
* Creates a line with the specified ID
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/ISortModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/ISortModel.java
index d3af988..aa3bf6f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/ISortModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/ISortModel.java
@@ -29,17 +29,24 @@
public List<Integer> getSortedColumnIndexes();
/**
- * @return TRUE if the column with the given index is sorted at the moment.
+ * @param columnIndex
+ * The column index to check.
+ * @return <code>true</code> if the column with the given index is sorted at
+ * the moment.
*/
public boolean isColumnIndexSorted(int columnIndex);
/**
+ * @param columnIndex
+ * The column index for which the sort direction is requested.
* @return the direction in which the column with the given index is
* currently sorted
*/
public SortDirectionEnum getSortDirection(int columnIndex);
/**
+ * @param columnIndex
+ * The column index for which the sort order is requested.
* @return when multiple columns are sorted, this returns the order of the
* column index in the sort
* <p>
@@ -72,6 +79,10 @@
* This method is called by the {@link SortCommandHandler} in response to a
* sort command. It is responsible for sorting the requested column.
*
+ * @param columnIndex
+ * The column index to sort.
+ * @param sortDirection
+ * The sort direction to apply.
* @param accumulate
* flag indicating if the column should added to a previous sort.
*/
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortConfigAttributes.java
index c4bb3b7..508eeea 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortConfigAttributes.java
@@ -16,8 +16,12 @@
import org.eclipse.nebula.widgets.nattable.style.ConfigAttribute;
-public interface SortConfigAttributes {
+public final class SortConfigAttributes {
- public static final ConfigAttribute<Comparator<?>> SORT_COMPARATOR = new ConfigAttribute<Comparator<?>>();
+ private SortConfigAttributes() {
+ // private default constructor for constants class
+ }
+
+ public static final ConfigAttribute<Comparator<?>> SORT_COMPARATOR = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortHeaderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortHeaderLayer.java
index 23a6db2..a89346c 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortHeaderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortHeaderLayer.java
@@ -45,7 +45,7 @@
this.sortModel = sortModel;
registerPersistable(new SortStatePersistor<T>(sortModel));
- registerCommandHandler(new SortCommandHandler<T>(sortModel, this));
+ registerCommandHandler(new SortCommandHandler<>(sortModel, this));
if (useDefaultConfiguration) {
addConfiguration(new DefaultSortConfiguration());
@@ -75,13 +75,10 @@
SortDirectionEnum sortDirection = this.sortModel.getSortDirection(columnIndex);
- switch (sortDirection) {
- case ASC:
- configLabels.addLabelOnTop(DefaultSortConfiguration.SORT_UP_CONFIG_TYPE);
- break;
- case DESC:
- configLabels.addLabelOnTop(DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE);
- break;
+ if (sortDirection == SortDirectionEnum.ASC) {
+ configLabels.addLabelOnTop(DefaultSortConfiguration.SORT_UP_CONFIG_TYPE);
+ } else if (sortDirection == SortDirectionEnum.DESC) {
+ configLabels.addLabelOnTop(DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE);
}
configLabels.addLabelOnTop(DefaultSortConfiguration.SORT_CONFIG_TYPE);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortStatePersistor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortStatePersistor.java
index 38d5274..3032647 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortStatePersistor.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/SortStatePersistor.java
@@ -49,7 +49,7 @@
*/
@Override
public void saveState(String prefix, Properties properties) {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
for (int columnIndex : this.sortModel.getSortedColumnIndexes()) {
SortDirectionEnum sortDirection = this.sortModel
@@ -92,7 +92,7 @@
try {
String savedState = savedValue.toString();
String[] sortedColumns = savedState.split("\\|"); //$NON-NLS-1$
- final List<SortState> stateInfo = new ArrayList<SortState>();
+ final List<SortState> stateInfo = new ArrayList<>();
// Parse string
for (String token : sortedColumns) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/config/DefaultSortConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/config/DefaultSortConfiguration.java
index 4e1293f..1f79f48 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/config/DefaultSortConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/config/DefaultSortConfiguration.java
@@ -85,11 +85,11 @@
@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
uiBindingRegistry.registerSingleClickBinding(
- new MouseEventMatcher(SWT.MOD3, GridRegion.COLUMN_HEADER.toString(), 1),
+ new MouseEventMatcher(SWT.MOD3, GridRegion.COLUMN_HEADER, 1),
new SortColumnAction(false));
uiBindingRegistry.registerSingleClickBinding(
- new MouseEventMatcher(SWT.MOD3 | SWT.MOD2, GridRegion.COLUMN_HEADER.toString(), 1),
+ new MouseEventMatcher(SWT.MOD3 | SWT.MOD2, GridRegion.COLUMN_HEADER, 1),
new SortColumnAction(true));
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/painter/SortIconPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/painter/SortIconPainter.java
index e56ab75..cc1f095 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/painter/SortIconPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/sort/painter/SortIconPainter.java
@@ -109,7 +109,7 @@
for (String configLabel : cell.getConfigLabels()) {
if (configLabel.startsWith(DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE)) {
String[] tokens = configLabel.split("_"); //$NON-NLS-1$
- sortSeq = Integer.valueOf(tokens[tokens.length - 1]).intValue();
+ sortSeq = Integer.parseInt(tokens[tokens.length - 1]);
}
}
return sortSeq;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/CellStyleAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/CellStyleAttributes.java
index c45548e..d95816f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/CellStyleAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/CellStyleAttributes.java
@@ -16,67 +16,71 @@
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
-public interface CellStyleAttributes {
+public final class CellStyleAttributes {
+
+ private CellStyleAttributes() {
+ // private default constructor for constants class
+ }
/**
* Attribute for configuring the background color of a cell.
*/
- public static final ConfigAttribute<Color> BACKGROUND_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> BACKGROUND_COLOR = new ConfigAttribute<>();
/**
* Attribute for configuring the foreground color of a cell.
*/
- public static final ConfigAttribute<Color> FOREGROUND_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> FOREGROUND_COLOR = new ConfigAttribute<>();
/**
* Attribute for configuring the gradient sweeping background color. Is used
* by the GradientBackgroundPainter.
*/
- public static final ConfigAttribute<Color> GRADIENT_BACKGROUND_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> GRADIENT_BACKGROUND_COLOR = new ConfigAttribute<>();
/**
* Attribute for configuring the gradient sweeping foreground color. Is used
* by the GradientBackgroundPainter.
*/
- public static final ConfigAttribute<Color> GRADIENT_FOREGROUND_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> GRADIENT_FOREGROUND_COLOR = new ConfigAttribute<>();
/**
* Attribute for configuring the horizontal alignment of a cell.
*/
- public static final ConfigAttribute<HorizontalAlignmentEnum> HORIZONTAL_ALIGNMENT = new ConfigAttribute<HorizontalAlignmentEnum>();
+ public static final ConfigAttribute<HorizontalAlignmentEnum> HORIZONTAL_ALIGNMENT = new ConfigAttribute<>();
/**
* Attribute for configuring the vertical alignment of a cell.
*/
- public static final ConfigAttribute<VerticalAlignmentEnum> VERTICAL_ALIGNMENT = new ConfigAttribute<VerticalAlignmentEnum>();
+ public static final ConfigAttribute<VerticalAlignmentEnum> VERTICAL_ALIGNMENT = new ConfigAttribute<>();
/**
* Attribute for configuring the font to be used on rendering text. Is used
* by all specialisations of the AbstractTextPainter.
*/
- public static final ConfigAttribute<Font> FONT = new ConfigAttribute<Font>();
+ public static final ConfigAttribute<Font> FONT = new ConfigAttribute<>();
/**
* Attribute for configuring the image to rendered. Is used by the
* ImagePainter to determine the image to render dynamically.
*/
- public static final ConfigAttribute<Image> IMAGE = new ConfigAttribute<Image>();
+ public static final ConfigAttribute<Image> IMAGE = new ConfigAttribute<>();
/**
* Attribute for configuring the border style. Is used by the
* LineBorderDecorator.
*/
- public static final ConfigAttribute<BorderStyle> BORDER_STYLE = new ConfigAttribute<BorderStyle>();
+ public static final ConfigAttribute<BorderStyle> BORDER_STYLE = new ConfigAttribute<>();
/**
* Attribute for configuring the echo character that should be used by
* PasswordTextPainter and PasswordCellEditor.
*/
- public static final ConfigAttribute<Character> PASSWORD_ECHO_CHAR = new ConfigAttribute<Character>();
+ public static final ConfigAttribute<Character> PASSWORD_ECHO_CHAR = new ConfigAttribute<>();
/**
* Attribute for configuring the text decoration (underline and/or
* strikethrough). Is used by all specialisations of the AbstractTextPainter
*/
- public static final ConfigAttribute<TextDecorationEnum> TEXT_DECORATION = new ConfigAttribute<TextDecorationEnum>();
+ public static final ConfigAttribute<TextDecorationEnum> TEXT_DECORATION = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/CellStyleUtil.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/CellStyleUtil.java
index c53ff5e..115a041 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/CellStyleUtil.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/CellStyleUtil.java
@@ -96,13 +96,10 @@
int padding = 0;
- switch (horizontalAlignment) {
- case CENTER:
- padding = (rectangle.width - contentWidth) / 2;
- break;
- case RIGHT:
- padding = rectangle.width - contentWidth;
- break;
+ if (horizontalAlignment == HorizontalAlignmentEnum.CENTER) {
+ padding = (rectangle.width - contentWidth) / 2;
+ } else if (horizontalAlignment == HorizontalAlignmentEnum.RIGHT) {
+ padding = rectangle.width - contentWidth;
}
if (padding < 0) {
@@ -163,13 +160,10 @@
int padding = 0;
- switch (verticalAlignment) {
- case MIDDLE:
- padding = (rectangle.height - contentHeight) / 2;
- break;
- case BOTTOM:
- padding = rectangle.height - contentHeight;
- break;
+ if (verticalAlignment == VerticalAlignmentEnum.MIDDLE) {
+ padding = (rectangle.height - contentHeight) / 2;
+ } else if (verticalAlignment == VerticalAlignmentEnum.BOTTOM) {
+ padding = rectangle.height - contentHeight;
}
if (padding < 0) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/SelectionStyleLabels.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/SelectionStyleLabels.java
index 33462cc..6ae687d 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/SelectionStyleLabels.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/SelectionStyleLabels.java
@@ -21,36 +21,37 @@
/**
* Interface that contains labels that are used to style selection related
* components.
- *
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
*/
-public interface SelectionStyleLabels {
+public final class SelectionStyleLabels {
+
+ private SelectionStyleLabels() {
+ // private default constructor for constants class
+ }
/**
* Label that is applied to the cell which is currently holding the
* selection anchor.
*/
- String SELECTION_ANCHOR_STYLE = "selectionAnchor"; //$NON-NLS-1$
+ public static final String SELECTION_ANCHOR_STYLE = "selectionAnchor"; //$NON-NLS-1$
/**
* Label that is used to configure the line style of the selection grid
* line. This is the line that surrounds an active selection. By default
* this is the black dotted one pixel line.
*/
- String SELECTION_ANCHOR_GRID_LINE_STYLE = "selectionAnchorGridLine"; //$NON-NLS-1$
+ public static final String SELECTION_ANCHOR_GRID_LINE_STYLE = "selectionAnchorGridLine"; //$NON-NLS-1$
/**
* Label that is applied to the column header cell of the column that is
* fully selected.
*/
- String COLUMN_FULLY_SELECTED_STYLE = GridRegion.COLUMN_HEADER + "_FULL"; //$NON-NLS-1$
+ public static final String COLUMN_FULLY_SELECTED_STYLE = GridRegion.COLUMN_HEADER + "_FULL"; //$NON-NLS-1$
/**
* Label that is applied to the row header cell of the row that is fully
* selected.
*/
- String ROW_FULLY_SELECTED_STYLE = GridRegion.ROW_HEADER + "_FULL"; //$NON-NLS-1$
+ public static final String ROW_FULLY_SELECTED_STYLE = GridRegion.ROW_HEADER + "_FULL"; //$NON-NLS-1$
/**
* Label that is used to mark cells as part of the fill handle region. This
@@ -59,7 +60,7 @@
*
* @since 1.4
*/
- String FILL_HANDLE_REGION = "FILL_HANDLE_REGION"; //$NON-NLS-1$
+ public static final String FILL_HANDLE_REGION = "FILL_HANDLE_REGION"; //$NON-NLS-1$
/**
* Label that is added to the bottom right cell of a contiguous selection.
@@ -67,7 +68,7 @@
*
* @since 1.4
*/
- String FILL_HANDLE_CELL = "selectionHandleCell"; //$NON-NLS-1$
+ public static final String FILL_HANDLE_CELL = "selectionHandleCell"; //$NON-NLS-1$
/**
* Style label for configuring the copy border.
@@ -79,5 +80,5 @@
*
* @since 1.4
*/
- String COPY_BORDER_STYLE = "copyBorderStyle"; //$NON-NLS-1$
+ public static final String COPY_BORDER_STYLE = "copyBorderStyle"; //$NON-NLS-1$
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/AbstractEditorPanel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/AbstractEditorPanel.java
index cfa400b..9abdeff 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/AbstractEditorPanel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/AbstractEditorPanel.java
@@ -25,16 +25,25 @@
/**
* Initialize UI widgets to match the initial state of T
+ *
+ * @param t
+ * the object to edit
+ * @throws Exception
+ * if an error occurs
*/
public abstract void edit(T t) throws Exception;
/**
* Get the new value of T with the user modifications
+ *
+ * @return the edited value
*/
public abstract T getNewValue();
/**
- * Use friendly name for this editor (used as tab labels).
+ * User friendly name for this editor (used as tab labels).
+ *
+ * @return the user friendly name of this editor
*/
public abstract String getEditorName();
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/AbstractStyleEditorDialog.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/AbstractStyleEditorDialog.java
index 4ba43d2..fe23427 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/AbstractStyleEditorDialog.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/AbstractStyleEditorDialog.java
@@ -59,7 +59,10 @@
}
/**
- * Create all widgets to be displayed in the editor
+ * Create all widgets to be displayed in the editor.
+ *
+ * @param shell
+ * the parent shell
*/
protected abstract void initComponents(Shell shell);
@@ -87,6 +90,9 @@
/**
* Create OK, Reset and Cancel buttons
+ *
+ * @param shell
+ * the parent shell
*/
protected void createButtons(final Shell shell) {
Composite buttonPanel = new Composite(shell, SWT.NONE);
@@ -147,6 +153,9 @@
/**
* Respond to the OK button press. Read new state from the form.
+ *
+ * @param shell
+ * the parent shell
*/
protected abstract void doFormOK(Shell shell);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/GridStyleParameterObject.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/GridStyleParameterObject.java
index 0b10b2f..08f158a 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/GridStyleParameterObject.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/GridStyleParameterObject.java
@@ -21,6 +21,8 @@
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
+//fields are public by design to make it easy for adapters to customize styling
+@SuppressWarnings("java:S1104")
public class GridStyleParameterObject {
public Font tableFont;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/command/DisplayColumnStyleEditorCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/command/DisplayColumnStyleEditorCommandHandler.java
index 4461bdb..91ac046 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/command/DisplayColumnStyleEditorCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/command/DisplayColumnStyleEditorCommandHandler.java
@@ -53,7 +53,7 @@
protected ColumnOverrideLabelAccumulator columnLabelAccumulator;
private final IConfigRegistry configRegistry;
protected ColumnStyleEditorDialog dialog;
- protected final Map<String, Style> stylesToPersist = new HashMap<String, Style>();
+ protected final Map<String, Style> stylesToPersist = new HashMap<>();
public DisplayColumnStyleEditorCommandHandler(
SelectionLayer selectionLayer,
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DefaultNatTableThemeConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DefaultNatTableThemeConfiguration.java
index 2e4e7da..67b7959 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DefaultNatTableThemeConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/DefaultNatTableThemeConfiguration.java
@@ -87,6 +87,8 @@
* or the ModernGroupByThemeExtension for example.
* </p>
*/
+// fields are public by design to make it easy for adapters to customize a theme
+@SuppressWarnings("java:S1104")
public class DefaultNatTableThemeConfiguration extends ThemeConfiguration {
{
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ThemeConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ThemeConfiguration.java
index 0f4e193..a36ec69 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ThemeConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/theme/ThemeConfiguration.java
@@ -23,7 +23,7 @@
import org.eclipse.nebula.widgets.nattable.datachange.DataChangeLayer;
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
import org.eclipse.nebula.widgets.nattable.fillhandle.config.FillHandleConfigAttributes;
-import org.eclipse.nebula.widgets.nattable.freeze.IFreezeConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.freeze.FreezeConfigAttributes;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.grid.cell.AlternatingRowConfigLabelAccumulator;
import org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultGridLayerConfiguration;
@@ -2401,13 +2401,13 @@
protected void configureFreezeStyle(IConfigRegistry configRegistry) {
if (getFreezeSeparatorColor() != null) {
configRegistry.registerConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_COLOR,
+ FreezeConfigAttributes.SEPARATOR_COLOR,
getFreezeSeparatorColor());
}
if (getFreezeSeparatorWidth() != null) {
configRegistry.registerConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_WIDTH,
+ FreezeConfigAttributes.SEPARATOR_WIDTH,
getFreezeSeparatorWidth());
}
}
@@ -3303,12 +3303,12 @@
// unregister freeze separator color
if (getFreezeSeparatorColor() != null) {
- configRegistry.unregisterConfigAttribute(IFreezeConfigAttributes.SEPARATOR_COLOR);
+ configRegistry.unregisterConfigAttribute(FreezeConfigAttributes.SEPARATOR_COLOR);
}
// unregister freeze separator width
if (getFreezeSeparatorWidth() != null) {
- configRegistry.unregisterConfigAttribute(IFreezeConfigAttributes.SEPARATOR_WIDTH);
+ configRegistry.unregisterConfigAttribute(FreezeConfigAttributes.SEPARATOR_WIDTH);
}
// unregister grid line configuration
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/summaryrow/DefaultSummaryRowConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/summaryrow/DefaultSummaryRowConfiguration.java
index 1759f8b..aa99946 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/summaryrow/DefaultSummaryRowConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/summaryrow/DefaultSummaryRowConfiguration.java
@@ -27,6 +27,8 @@
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
+//fields are public by design to make it easy for adapters to customize configuration
+@SuppressWarnings("java:S1104")
public class DefaultSummaryRowConfiguration extends AbstractRegistryConfiguration {
public BorderStyle summaryRowBorderStyle = new BorderStyle(0, GUIHelper.COLOR_BLACK, LineStyleEnum.DOTTED);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/summaryrow/SummaryRowConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/summaryrow/SummaryRowConfigAttributes.java
index bdfa597..2f1ff60 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/summaryrow/SummaryRowConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/summaryrow/SummaryRowConfigAttributes.java
@@ -20,12 +20,16 @@
*
* @see SummaryRowLayer
*/
-public class SummaryRowConfigAttributes {
+public final class SummaryRowConfigAttributes {
+
+ private SummaryRowConfigAttributes() {
+ // private default constructor for constants class
+ }
/**
* The configuration attribute that is used to calculate the summary for a
* column.
*/
- public static final ConfigAttribute<ISummaryProvider> SUMMARY_PROVIDER = new ConfigAttribute<ISummaryProvider>();
+ public static final ConfigAttribute<ISummaryProvider> SUMMARY_PROVIDER = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tickupdate/TickUpdateConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tickupdate/TickUpdateConfigAttributes.java
index 6c269bd..91761eb 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tickupdate/TickUpdateConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tickupdate/TickUpdateConfigAttributes.java
@@ -18,13 +18,17 @@
/**
* The configuration attributes for tick updates.
*/
-public class TickUpdateConfigAttributes {
+public final class TickUpdateConfigAttributes {
+
+ private TickUpdateConfigAttributes() {
+ // private default constructor for helper class
+ }
/**
* The configuration attribute for registering the
* {@link ITickUpdateHandler} to use.
*/
- public static final ConfigAttribute<ITickUpdateHandler> UPDATE_HANDLER = new ConfigAttribute<ITickUpdateHandler>();
+ public static final ConfigAttribute<ITickUpdateHandler> UPDATE_HANDLER = new ConfigAttribute<>();
/**
* The configuration attribute to configure how the tick updates should be
@@ -32,5 +36,5 @@
* registered for this attribute the dialog will be opened with this value
* set to <code>false</code>.
*/
- public static final ConfigAttribute<Boolean> USE_ADJUST_BY = new ConfigAttribute<Boolean>();
+ public static final ConfigAttribute<Boolean> USE_ADJUST_BY = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/AbstractTreeRowModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/AbstractTreeRowModel.java
index 014b340..37a87bf 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/AbstractTreeRowModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/AbstractTreeRowModel.java
@@ -71,12 +71,12 @@
@Override
public List<Integer> collapse(T object) {
return collapse(this.getTreeData().indexOf(object));
- };
+ }
@Override
public List<Integer> expand(T object) {
return expand(this.getTreeData().indexOf(object));
- };
+ }
@Override
public List<Integer> expandToLevel(T object, int level) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/SortableTreeComparator.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/SortableTreeComparator.java
index 40f40ac..234e9fc 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/SortableTreeComparator.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/SortableTreeComparator.java
@@ -39,23 +39,20 @@
return 0;
} else {
List<Integer> sortedColumnIndexes = this.sortModel.getSortedColumnIndexes();
- if (sortedColumnIndexes != null && sortedColumnIndexes.size() > 0) {
- List<Comparator<T>> comparators = new ArrayList<Comparator<T>>();
+ if (sortedColumnIndexes != null && !sortedColumnIndexes.isEmpty()) {
+ List<Comparator<T>> comparators = new ArrayList<>();
for (int sortedColumnIndex : sortedColumnIndexes) {
// get comparator for column index... somehow
List<Comparator> columnComparators =
this.sortModel.getComparatorsForColumnIndex(sortedColumnIndex);
- if (columnComparators != null) {
+ if (!columnComparators.isEmpty()) {
SortDirectionEnum sortDirection = this.sortModel.getSortDirection(sortedColumnIndex);
for (Comparator columnComparator : columnComparators) {
- switch (sortDirection) {
- case ASC:
- comparators.add(columnComparator);
- break;
- case DESC:
- comparators.add(Collections.reverseOrder(columnComparator));
- break;
+ if (sortDirection == SortDirectionEnum.ASC) {
+ comparators.add(columnComparator);
+ } else if (sortDirection == SortDirectionEnum.DESC) {
+ comparators.add(Collections.reverseOrder(columnComparator));
}
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java
index c63ceed..8d5101b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java
@@ -278,12 +278,10 @@
IndentedTreeImagePainter result = null;
if (painter instanceof IndentedTreeImagePainter) {
result = (IndentedTreeImagePainter) painter;
- } else if (painter != null
- && painter instanceof CellPainterWrapper
+ } else if (painter instanceof CellPainterWrapper
&& ((CellPainterWrapper) painter).getWrappedPainter() != null) {
result = findIndentedTreeImagePainter(((CellPainterWrapper) painter).getWrappedPainter());
- } else if (painter != null
- && painter instanceof CellPainterDecorator) {
+ } else if (painter instanceof CellPainterDecorator) {
result = findIndentedTreeImagePainter(((CellPainterDecorator) painter).getBaseCellPainter());
if (result == null) {
result = findIndentedTreeImagePainter(((CellPainterDecorator) painter).getDecoratorCellPainter());
@@ -525,7 +523,7 @@
protected boolean handleMultiRowHideCommand(MultiRowHideCommand command) {
// transform position to index
if (command.convertToTargetLayer(this)) {
- List<Integer> rowPositionsToHide = new ArrayList<Integer>();
+ List<Integer> rowPositionsToHide = new ArrayList<>();
for (int rowPos : command.getRowPositionsArray()) {
rowPositionsToHide.add(rowPos);
int rowIndex = getRowIndexByPosition(rowPos);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeRowModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeRowModel.java
index 5e60bcf..c8f13a2 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeRowModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeRowModel.java
@@ -29,7 +29,7 @@
*/
public class TreeRowModel<T> extends AbstractTreeRowModel<T> {
- protected final Set<Integer> parentIndexes = new HashSet<Integer>();
+ protected final Set<Integer> parentIndexes = new HashSet<>();
public TreeRowModel(ITreeData<T> treeData) {
super(treeData);
@@ -65,7 +65,7 @@
@Override
public List<Integer> collapseAll() {
- Set<Integer> collapsedChildren = new HashSet<Integer>();
+ Set<Integer> collapsedChildren = new HashSet<>();
for (int i = (getTreeData().getElementCount() - 1); i >= 0; i--) {
if (hasChildren(i) && !isCollapsed(i)) {
@@ -73,7 +73,7 @@
}
}
- List<Integer> children = new ArrayList<Integer>(collapsedChildren);
+ List<Integer> children = new ArrayList<>(collapsedChildren);
Collections.sort(children);
notifyListeners();
return children;
@@ -81,7 +81,7 @@
@Override
public List<Integer> expand(int index) {
- List<Integer> children = new ArrayList<Integer>(internalExpand(index));
+ List<Integer> children = new ArrayList<>(internalExpand(index));
Collections.sort(children);
notifyListeners();
return children;
@@ -100,7 +100,7 @@
protected Collection<Integer> internalExpand(int index) {
this.parentIndexes.remove(index);
List<Integer> directChildren = getDirectChildIndexes(index);
- Set<Integer> expandedChildren = new HashSet<Integer>(directChildren);
+ Set<Integer> expandedChildren = new HashSet<>(directChildren);
for (Integer child : directChildren) {
if (hasChildren(child) && !isCollapsed(child)) {
expandedChildren.addAll(internalExpand(child));
@@ -111,12 +111,12 @@
@Override
public List<Integer> expandAll() {
- Set<Integer> expandedChildren = new HashSet<Integer>();
+ Set<Integer> expandedChildren = new HashSet<>();
for (int index : this.parentIndexes) {
expandedChildren.addAll(getChildIndexes(index));
}
this.parentIndexes.clear();
- List<Integer> children = new ArrayList<Integer>(expandedChildren);
+ List<Integer> children = new ArrayList<>(expandedChildren);
Collections.sort(children);
notifyListeners();
return children;
@@ -124,13 +124,13 @@
@Override
public List<Integer> expandToLevel(int level) {
- Set<Integer> expandedChildren = new HashSet<Integer>();
- List<Integer> parentCopy = new ArrayList<Integer>(this.parentIndexes);
+ Set<Integer> expandedChildren = new HashSet<>();
+ List<Integer> parentCopy = new ArrayList<>(this.parentIndexes);
for (int index : parentCopy) {
expandedChildren.addAll(internalExpandToLevel(index, level));
}
- List<Integer> children = new ArrayList<Integer>(expandedChildren);
+ List<Integer> children = new ArrayList<>(expandedChildren);
Collections.sort(children);
notifyListeners();
return children;
@@ -138,7 +138,7 @@
@Override
public List<Integer> expandToLevel(int parentIndex, int level) {
- List<Integer> children = new ArrayList<Integer>(internalExpandToLevel(parentIndex, level));
+ List<Integer> children = new ArrayList<>(internalExpandToLevel(parentIndex, level));
Collections.sort(children);
notifyListeners();
return children;
@@ -158,7 +158,7 @@
* visible by performing the expand operation.
*/
protected Collection<Integer> internalExpandToLevel(int index, int level) {
- Set<Integer> expandedChildren = new HashSet<Integer>();
+ Set<Integer> expandedChildren = new HashSet<>();
if (depth(index) <= (level - 1)) {
this.parentIndexes.remove(index);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/config/TreeConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/config/TreeConfigAttributes.java
index 01d229f..c97f158 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/config/TreeConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/config/TreeConfigAttributes.java
@@ -21,7 +21,11 @@
* Configuration attributes for configuring the visualization of a tree
* representation.
*/
-public interface TreeConfigAttributes {
+public final class TreeConfigAttributes {
+
+ private TreeConfigAttributes() {
+ // private default constructor for constants class
+ }
/**
* Configuration attribute to specify the painter that should be used to
@@ -31,6 +35,6 @@
* {@link IndentedTreeImagePainter} in the painter hierarchy, this
* configuration attribute will be ignored by the TreeLayer.
*/
- ConfigAttribute<ICellPainter> TREE_STRUCTURE_PAINTER = new ConfigAttribute<ICellPainter>();
+ public static final ConfigAttribute<ICellPainter> TREE_STRUCTURE_PAINTER = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/painter/IndentedTreeImagePainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/painter/IndentedTreeImagePainter.java
index b59bcfb..a9c53d4 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/painter/IndentedTreeImagePainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/painter/IndentedTreeImagePainter.java
@@ -358,7 +358,7 @@
for (String configLabel : cell.getConfigLabels()) {
if (configLabel.startsWith(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE)) {
String[] tokens = configLabel.split("_"); //$NON-NLS-1$
- depth = Integer.valueOf(tokens[tokens.length - 1]).intValue();
+ depth = Integer.parseInt(tokens[tokens.length - 1]);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/action/AggregateDragMode.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/action/AggregateDragMode.java
index 0eb55a1..c5839af 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/action/AggregateDragMode.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/action/AggregateDragMode.java
@@ -23,7 +23,7 @@
private MouseEvent initialEvent;
private MouseEvent currentEvent;
- private final Collection<IDragMode> dragModes = new LinkedHashSet<IDragMode>();
+ private final Collection<IDragMode> dragModes = new LinkedHashSet<>();
public AggregateDragMode() {
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/binding/UiBindingRegistry.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/binding/UiBindingRegistry.java
index 449b495..bdb7631 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/binding/UiBindingRegistry.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/binding/UiBindingRegistry.java
@@ -34,11 +34,11 @@
private NatTable natTable;
- private LinkedList<KeyBinding> keyBindings = new LinkedList<KeyBinding>();
+ private LinkedList<KeyBinding> keyBindings = new LinkedList<>();
- private Map<MouseEventTypeEnum, LinkedList<MouseBinding>> mouseBindingsMap = new HashMap<MouseEventTypeEnum, LinkedList<MouseBinding>>();
+ private Map<MouseEventTypeEnum, LinkedList<MouseBinding>> mouseBindingsMap = new HashMap<>();
- private LinkedList<DragBinding> dragBindings = new LinkedList<DragBinding>();
+ private LinkedList<DragBinding> dragBindings = new LinkedList<>();
public UiBindingRegistry(NatTable natTable) {
this.natTable = natTable;
@@ -273,11 +273,7 @@
// /////////////////////////////////////////////////////////////////////////
private void registerMouseBinding(boolean first, MouseEventTypeEnum mouseEventType, IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- LinkedList<MouseBinding> mouseEventBindings = this.mouseBindingsMap.get(mouseEventType);
- if (mouseEventBindings == null) {
- mouseEventBindings = new LinkedList<MouseBinding>();
- this.mouseBindingsMap.put(mouseEventType, mouseEventBindings);
- }
+ LinkedList<MouseBinding> mouseEventBindings = this.mouseBindingsMap.computeIfAbsent(mouseEventType, type -> new LinkedList<>());
if (first) {
mouseEventBindings.addFirst(new MouseBinding(mouseEventMatcher, action));
} else {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/matcher/LetterOrDigitKeyEventMatcher.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/matcher/LetterOrDigitKeyEventMatcher.java
index f5ce69b..1807c1c 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/matcher/LetterOrDigitKeyEventMatcher.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/matcher/LetterOrDigitKeyEventMatcher.java
@@ -88,8 +88,7 @@
public static boolean isLetterOrDigit(char character) {
return Character.isLetterOrDigit(character)
|| Character
- .valueOf(character)
- .toString()
+ .toString(character)
.matches("[\\.:,;\\-_#\'+*~!?§$%&/()\\[\\]\\{\\}=\\\\\"]"); //$NON-NLS-1$
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/matcher/MouseEventMatcher.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/matcher/MouseEventMatcher.java
index 1392665..56cb268 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/matcher/MouseEventMatcher.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/matcher/MouseEventMatcher.java
@@ -46,13 +46,18 @@
* Constructor
*
* @param stateMask
- * @see "org.eclipse.swt.events.MouseEvent.stateMask"
+ * the state of the keyboard modifier keys and mouse masks at the
+ * time the event was generated.
* @param eventRegion
- * {@linkplain org.eclipse.nebula.widgets.nattable.grid.GridRegion}
+ * the grid region in which the mouse event should be matched
* @param button
+ * the button that was pressed or released, e.g.
+ * {@link MouseEventMatcher#LEFT_BUTTON},
+ * {@link MouseEventMatcher#RIGHT_BUTTON}
+ *
+ * @see org.eclipse.swt.events.MouseEvent#stateMask
+ * @see org.eclipse.nebula.widgets.nattable.grid.GridRegion
* @see org.eclipse.swt.events.MouseEvent#button
- * {@link MouseEventMatcher#LEFT_BUTTON},
- * {@link MouseEventMatcher#RIGHT_BUTTON} can be used for convenience
*/
public MouseEventMatcher(int stateMask, String eventRegion, int button) {
this.stateMask = stateMask;
@@ -130,13 +135,11 @@
}
public static MouseEventMatcher columnHeaderLeftClick(int mask) {
- return new MouseEventMatcher(mask, GridRegion.COLUMN_HEADER,
- LEFT_BUTTON);
+ return new MouseEventMatcher(mask, GridRegion.COLUMN_HEADER, LEFT_BUTTON);
}
public static MouseEventMatcher columnHeaderRightClick(int mask) {
- return new MouseEventMatcher(mask, GridRegion.COLUMN_HEADER,
- RIGHT_BUTTON);
+ return new MouseEventMatcher(mask, GridRegion.COLUMN_HEADER, RIGHT_BUTTON);
}
public static MouseEventMatcher rowHeaderLeftClick(int mask) {
@@ -156,22 +159,18 @@
}
public static MouseEventMatcher columnGroupHeaderLeftClick(int mask) {
- return new MouseEventMatcher(mask, GridRegion.COLUMN_GROUP_HEADER,
- LEFT_BUTTON);
+ return new MouseEventMatcher(mask, GridRegion.COLUMN_GROUP_HEADER, LEFT_BUTTON);
}
public static MouseEventMatcher columnGroupHeaderRightClick(int mask) {
- return new MouseEventMatcher(mask, GridRegion.COLUMN_GROUP_HEADER,
- RIGHT_BUTTON);
+ return new MouseEventMatcher(mask, GridRegion.COLUMN_GROUP_HEADER, RIGHT_BUTTON);
}
public static MouseEventMatcher rowGroupHeaderLeftClick(int mask) {
- return new MouseEventMatcher(mask, GridRegion.ROW_GROUP_HEADER,
- LEFT_BUTTON);
+ return new MouseEventMatcher(mask, GridRegion.ROW_GROUP_HEADER, LEFT_BUTTON);
}
public static MouseEventMatcher rowGroupHeaderRightClick(int mask) {
- return new MouseEventMatcher(mask, GridRegion.ROW_GROUP_HEADER,
- RIGHT_BUTTON);
+ return new MouseEventMatcher(mask, GridRegion.ROW_GROUP_HEADER, RIGHT_BUTTON);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemProviders.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemProviders.java
index 30cf6d3..a6e5c91 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemProviders.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemProviders.java
@@ -70,7 +70,11 @@
* that can be used within a popup menu in the NatTable to execute NatTable
* specific actions.
*/
-public class MenuItemProviders {
+public final class MenuItemProviders {
+
+ private MenuItemProviders() {
+ // private default constructor for helper class
+ }
/**
* Key that is used to put the NatEventData into the data of a menu.
@@ -87,7 +91,7 @@
*/
public static NatEventData getNatEventData(SelectionEvent selectionEvent) {
Widget widget = selectionEvent.widget;
- if (widget == null || !(widget instanceof MenuItem)) {
+ if (!(widget instanceof MenuItem)) {
return null;
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemStateMap.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemStateMap.java
index 4d538fb..35c7a43 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemStateMap.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemStateMap.java
@@ -43,9 +43,9 @@
*/
protected boolean isActive(String id, NatEventData natEventData) {
if (this.states != null) {
- List<IMenuItemState> states = this.states.get(id);
- if (states != null) {
- for (IMenuItemState state : states) {
+ List<IMenuItemState> menuItemStates = this.states.get(id);
+ if (menuItemStates != null) {
+ for (IMenuItemState state : menuItemStates) {
if (!state.isActive(natEventData)) {
return false;
}
@@ -66,16 +66,12 @@
*/
public void addMenuItemState(String id, IMenuItemState state) {
if (this.states == null) {
- this.states = new HashMap<String, List<IMenuItemState>>();
+ this.states = new HashMap<>();
}
- List<IMenuItemState> states = this.states.get(id);
- if (states == null) {
- states = new ArrayList<IMenuItemState>();
- this.states.put(id, states);
- }
+ List<IMenuItemState> menuItemStates = this.states.computeIfAbsent(id, i -> new ArrayList<>());
- states.add(state);
+ menuItemStates.add(state);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/PopupMenuBuilder.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/PopupMenuBuilder.java
index 7e4fdb0..1e7d919 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/PopupMenuBuilder.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/PopupMenuBuilder.java
@@ -225,7 +225,7 @@
// if the menu is build up using a MenuManager, remember that for
// further use
Object mgr = menu.getData("org.eclipse.jface.action.MenuManager.managerKey"); //$NON-NLS-1$
- if (mgr != null && mgr instanceof MenuManager) {
+ if (mgr instanceof MenuManager) {
this.menuManager = (MenuManager) mgr;
}
}
@@ -1179,7 +1179,7 @@
Object eventData = (PopupMenuBuilder.this.popupMenu != null && !PopupMenuBuilder.this.popupMenu.isDisposed())
? PopupMenuBuilder.this.popupMenu.getData(MenuItemProviders.NAT_EVENT_DATA_KEY)
: PopupMenuBuilder.this.menuManager.getMenu().getData(MenuItemProviders.NAT_EVENT_DATA_KEY);
- if (eventData != null && eventData instanceof NatEventData) {
+ if (eventData instanceof NatEventData) {
return PopupMenuBuilder.this.enablement.isActive(getId(), (NatEventData) eventData);
}
}
@@ -1192,7 +1192,7 @@
Object eventData = (PopupMenuBuilder.this.popupMenu != null && !PopupMenuBuilder.this.popupMenu.isDisposed())
? PopupMenuBuilder.this.popupMenu.getData(MenuItemProviders.NAT_EVENT_DATA_KEY)
: PopupMenuBuilder.this.menuManager.getMenu().getData(MenuItemProviders.NAT_EVENT_DATA_KEY);
- if (eventData != null && eventData instanceof NatEventData) {
+ if (eventData instanceof NatEventData) {
return PopupMenuBuilder.this.visibility.isActive(getId(), (NatEventData) eventData);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/mode/Mode.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/mode/Mode.java
index 3649a13..22a828f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/mode/Mode.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/mode/Mode.java
@@ -12,7 +12,11 @@
******************************************************************************/
package org.eclipse.nebula.widgets.nattable.ui.mode;
-public interface Mode {
+public final class Mode {
+
+ private Mode() {
+ // private default constructor for constants class
+ }
public static final String NORMAL_MODE = "NORMAL_MODE"; //$NON-NLS-1$
public static final String COLUMN_RESIZE_MODE = "COLUMN_RESIZE_MODE"; //$NON-NLS-1$
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/mode/ModeSupport.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/mode/ModeSupport.java
index eef9ed5..206615d 100755
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/mode/ModeSupport.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/mode/ModeSupport.java
@@ -35,13 +35,13 @@
*/
public class ModeSupport implements KeyListener, MouseListener, MouseMoveListener, MouseTrackListener, FocusListener {
- private static final boolean isMac;
+ private static final boolean IS_MAC;
static {
- isMac = System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0; //$NON-NLS-1$ //$NON-NLS-2$
+ IS_MAC = System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0; //$NON-NLS-1$ //$NON-NLS-2$
}
- private Map<String, IModeEventHandler> modeEventHandlerMap = new HashMap<String, IModeEventHandler>();
+ private Map<String, IModeEventHandler> modeEventHandlerMap = new HashMap<>();
private IModeEventHandler currentModeEventHandler;
@@ -156,7 +156,7 @@
* The {@link MouseEvent} to modify
*/
private void modifyMouseEventForMac(MouseEvent event) {
- if (isMac) {
+ if (IS_MAC) {
if (event.stateMask == SWT.MOD4 && event.button == 1) {
event.stateMask = event.stateMask & ~SWT.MOD4;
event.button = 3;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/scaling/ScalingUtil.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/scaling/ScalingUtil.java
index ec463af..f7a7af8 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/scaling/ScalingUtil.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/scaling/ScalingUtil.java
@@ -27,7 +27,11 @@
*
* @since 2.0
*/
-public class ScalingUtil {
+public final class ScalingUtil {
+
+ private ScalingUtil() {
+ // private default constructor for helper class
+ }
/**
* Performs a {@link ConfigureScalingCommand} to increase the scaling to
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/util/CellEdgeDetectUtil.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/util/CellEdgeDetectUtil.java
index 29465ad..d16a3f2 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/util/CellEdgeDetectUtil.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/util/CellEdgeDetectUtil.java
@@ -24,7 +24,11 @@
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-public class CellEdgeDetectUtil {
+public final class CellEdgeDetectUtil {
+
+ private CellEdgeDetectUtil() {
+ // private default constructor for helper class
+ }
/**
* Calculate the column position depending on the cursor's position on the
@@ -42,11 +46,11 @@
public static int getColumnPosition(ILayer layer, Point clickPoint) {
int columnPosition = layer.getColumnPositionByX(clickPoint.x);
if (columnPosition >= 0) {
- switch (getHorizontalCellEdge(layer, clickPoint, DEFAULT_RESIZE_HANDLE_SIZE)) {
- case LEFT:
- return columnPosition - 1;
- case RIGHT:
- return columnPosition;
+ CellEdgeEnum horizontalCellEdge = getHorizontalCellEdge(layer, clickPoint, DEFAULT_RESIZE_HANDLE_SIZE);
+ if (horizontalCellEdge == CellEdgeEnum.LEFT) {
+ return columnPosition - 1;
+ } else if (horizontalCellEdge == CellEdgeEnum.RIGHT) {
+ return columnPosition;
}
}
return -1;
@@ -69,15 +73,15 @@
public static int getColumnPositionToResize(ILayer layer, Point clickPoint) {
int columnPosition = layer.getColumnPositionByX(clickPoint.x);
if (columnPosition >= 0) {
- switch (getHorizontalCellEdge(layer, clickPoint, DEFAULT_RESIZE_HANDLE_SIZE)) {
- case LEFT:
- if (columnPosition == 1) {
- // can't resize left edge of first column
- break;
- }
- return columnPosition - 1;
- case RIGHT:
- return columnPosition;
+ CellEdgeEnum horizontalCellEdge = getHorizontalCellEdge(layer, clickPoint, DEFAULT_RESIZE_HANDLE_SIZE);
+ if (horizontalCellEdge == CellEdgeEnum.LEFT) {
+ if (columnPosition == 1) {
+ // can't resize left edge of first column
+ return -1;
+ }
+ return columnPosition - 1;
+ } else if (horizontalCellEdge == CellEdgeEnum.RIGHT) {
+ return columnPosition;
}
}
return -1;
@@ -99,11 +103,11 @@
public static int getRowPosition(ILayer layer, Point clickPoint) {
int rowPosition = layer.getRowPositionByY(clickPoint.y);
if (rowPosition >= 0) {
- switch (getVerticalCellEdge(layer, clickPoint, DEFAULT_RESIZE_HANDLE_SIZE)) {
- case TOP:
- return rowPosition - 1;
- case BOTTOM:
- return rowPosition;
+ CellEdgeEnum verticalCellEdge = getVerticalCellEdge(layer, clickPoint, DEFAULT_RESIZE_HANDLE_SIZE);
+ if (verticalCellEdge == CellEdgeEnum.TOP) {
+ return rowPosition - 1;
+ } else if (verticalCellEdge == CellEdgeEnum.BOTTOM) {
+ return rowPosition;
}
}
return -1;
@@ -126,15 +130,15 @@
public static int getRowPositionToResize(ILayer layer, Point clickPoint) {
int rowPosition = layer.getRowPositionByY(clickPoint.y);
if (rowPosition >= 0) {
- switch (getVerticalCellEdge(layer, clickPoint, DEFAULT_RESIZE_HANDLE_SIZE)) {
- case TOP:
- if (rowPosition == 1) {
- // can't resize top edge of first row
- break;
- }
- return rowPosition - 1;
- case BOTTOM:
- return rowPosition;
+ CellEdgeEnum verticalCellEdge = getVerticalCellEdge(layer, clickPoint, DEFAULT_RESIZE_HANDLE_SIZE);
+ if (verticalCellEdge == CellEdgeEnum.TOP) {
+ if (rowPosition == 1) {
+ // can't resize top edge of first row
+ return -1;
+ }
+ return rowPosition - 1;
+ } else if (verticalCellEdge == CellEdgeEnum.BOTTOM) {
+ return rowPosition;
}
}
return -1;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/util/MouseEventHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/util/MouseEventHelper.java
index 20287dc..2078479 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/util/MouseEventHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/util/MouseEventHelper.java
@@ -21,7 +21,11 @@
*
* @since 1.4
*/
-public class MouseEventHelper {
+public final class MouseEventHelper {
+
+ private MouseEventHelper() {
+ // private default constructor for helper class
+ }
/**
* Checks if the mouse down event and the mouse up event was triggered with
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/ArrayUtil.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/ArrayUtil.java
index 3ae9e8f..cecd7fc 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/ArrayUtil.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/ArrayUtil.java
@@ -13,24 +13,26 @@
package org.eclipse.nebula.widgets.nattable.util;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import java.util.stream.Collectors;
-public class ArrayUtil {
+public final class ArrayUtil {
+
+ private ArrayUtil() {
+ // private default constructor for helper class
+ }
public static final String[] STRING_TYPE_ARRAY = new String[] {};
public static final int[] INT_TYPE_ARRAY = new int[] {};
public static <T> List<T> asList(T[] array) {
- return new ArrayList<T>(ArrayUtil.asCollection(array));
+ return new ArrayList<>(ArrayUtil.asCollection(array));
}
public static <T> Collection<T> asCollection(T[] array) {
- List<T> list = new ArrayList<T>(array.length);
- for (int i = 0; i < array.length; i++) {
- list.add(array[i]);
- }
- return list;
+ return Arrays.asList(array);
}
public static int[] asIntArray(int... ints) {
@@ -38,11 +40,7 @@
}
public static List<Integer> asIntegerList(int... ints) {
- ArrayList<Integer> list = new ArrayList<Integer>(ints.length);
- for (Integer integer : ints) {
- list.add(integer);
- }
- return list;
+ return Arrays.stream(ints).boxed().collect(Collectors.toList());
}
public static boolean isEmpty(int[] array) {
@@ -93,7 +91,7 @@
*/
public static int[] subarray(int[] array, int startIndexInclusive, int endIndexExclusive) {
if (array == null) {
- return null;
+ return new int[0];
}
if (startIndexInclusive < 0) {
startIndexInclusive = 0;
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/CalculatedValueCache.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/CalculatedValueCache.java
index 16edce5..072135f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/CalculatedValueCache.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/CalculatedValueCache.java
@@ -57,7 +57,7 @@
* updates, and will be used to determine whether a new calculation is
* necessary.
*/
- private Map<ICalculatedValueCacheKey, Object> cache = new ConcurrentHashMap<ICalculatedValueCacheKey, Object>();
+ private Map<ICalculatedValueCacheKey, Object> cache = new ConcurrentHashMap<>();
/**
* Cache copy of the calculated values.
@@ -70,7 +70,7 @@
* calculation has finished instead of switching to the default calculation
* value on updates.
*/
- private Map<ICalculatedValueCacheKey, Object> cacheCopy = new ConcurrentHashMap<ICalculatedValueCacheKey, Object>();
+ private Map<ICalculatedValueCacheKey, Object> cacheCopy = new ConcurrentHashMap<>();
/**
* Flag to specify if the column position should be used as cache key.
@@ -155,7 +155,7 @@
Runtime.getRuntime().availableProcessors() + 1,
5000,
TimeUnit.MILLISECONDS,
- new LinkedBlockingQueue<Runnable>());
+ new LinkedBlockingQueue<>());
((ThreadPoolExecutor) this.executor).allowCoreThreadTimeOut(true);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/GUIHelper.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/GUIHelper.java
index a9f1b7b..a1606b8 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/GUIHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/GUIHelper.java
@@ -35,7 +35,11 @@
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
-public class GUIHelper {
+public final class GUIHelper {
+
+ private GUIHelper() {
+ // private default constructor for helper class
+ }
private static final String KEY_PREFIX = GUIHelper.class.getCanonicalName() + "."; //$NON-NLS-1$
@@ -92,8 +96,8 @@
public static final int DEFAULT_RESIZE_HANDLE_SIZE = 4;
public static final int DEFAULT_MIN_DISPLAY_SIZE = 5;
- public static final int DEFAULT_ANTIALIAS = SWT.DEFAULT;;
- public static final int DEFAULT_TEXT_ANTIALIAS = SWT.DEFAULT;;
+ public static final int DEFAULT_ANTIALIAS = SWT.DEFAULT;
+ public static final int DEFAULT_TEXT_ANTIALIAS = SWT.DEFAULT;
public static Font getFont(FontData... fontDatas) {
StringBuilder keyBuilder = new StringBuilder();
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/ObjectUtils.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/ObjectUtils.java
index fe106f7..31e1737 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/ObjectUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/ObjectUtils.java
@@ -23,20 +23,28 @@
import java.util.Random;
import java.util.TreeSet;
-public class ObjectUtils {
+public final class ObjectUtils {
+
+ private ObjectUtils() {
+ // private default constructor for helper class
+ }
/**
- * Transfers the iterator to an unmodifiable collection.
+ * Transfers the given iterator to an unmodifiable collection.
*
- * @return Contents of the Iterator<Cell> as a Collection.
+ * @param <T>
+ * The type of the objects contained in the iterator.
+ * @param iterator
+ * The iterator to transfer.
+ * @return Contents of the iterator as an unmodifiable Collection.
*/
public static <T> Collection<T> asCollection(Iterator<T> iterator) {
- Collection<T> collection = new ArrayList<T>();
+ Collection<T> collection = new ArrayList<>();
return addToCollection(iterator, collection);
}
public static <T> List<T> asList(Collection<T> collection) {
- return new ArrayList<T>(collection);
+ return new ArrayList<>(collection);
}
public static int[] asIntArray(Collection<Integer> collection) {
@@ -52,20 +60,23 @@
}
/**
- * Returns an unmodifiable ordered collection.
+ * Transfers the given iterator into an unmodifiable ordered collection
+ * based on the given comparator.
*
* @param <T>
+ * The type of the objects contained in the iterator.
* @param iterator
- * @return An unmodified ordered collection.
+ * The iterator to transfer.
+ * @param comparator
+ * The comparator to order the collection.
+ * @return Contents of the iterator as an unmodifiable ordered Collection.
*/
- public static <T> Collection<T> asOrderedCollection(Iterator<T> iterator,
- Comparator<T> comparator) {
- Collection<T> collection = new TreeSet<T>(comparator);
+ public static <T> Collection<T> asOrderedCollection(Iterator<T> iterator, Comparator<T> comparator) {
+ Collection<T> collection = new TreeSet<>(comparator);
return addToCollection(iterator, collection);
}
- private static <T> Collection<T> addToCollection(Iterator<T> iterator,
- Collection<T> collection) {
+ private static <T> Collection<T> addToCollection(Iterator<T> iterator, Collection<T> collection) {
while (iterator.hasNext()) {
T object = iterator.next();
collection.add(object);
@@ -80,8 +91,9 @@
String out = "[ "; //$NON-NLS-1$
int count = 1;
for (T object : collection) {
- if (object == null)
+ if (object == null) {
continue;
+ }
out = out + object.toString();
if (collection.size() != count) {
out = out + ";\n"; //$NON-NLS-1$
@@ -97,42 +109,70 @@
}
/**
- * @return TRUE is collection is null or contains no elements
+ *
+ * @param <T>
+ * The type of objects in the collection.
+ * @param collection
+ * The collection to check.
+ * @return <code>true</code> if the given collection is <code>null</code> or
+ * empty.
*/
public static <T> boolean isEmpty(Collection<T> collection) {
- return collection == null || collection.size() == 0;
+ return collection == null || collection.isEmpty();
}
/**
- * @return TRUE if string == null || string.length() == 0
+ *
+ * @param string
+ * The string to check.
+ * @return <code>true</code> if the given string is <code>null</code> or
+ * empty.
*/
- public static <T> boolean isEmpty(String string) {
+ public static boolean isEmpty(String string) {
return string == null || string.length() == 0;
}
/**
- * @return TRUE if string != null && string.length() > 0
+ *
+ * @param string
+ * The string to check.
+ * @return <code>true</code> if the given string is not <code>null</code>
+ * and not empty.
*/
- public static <T> boolean isNotEmpty(String string) {
+ public static boolean isNotEmpty(String string) {
return string != null && string.length() > 0;
}
/**
- * @see ObjectUtils#isEmpty(Collection)
+ *
+ * @param <T>
+ * The type of objects in the collection.
+ * @param collection
+ * The collection to check.
+ * @return <code>true</code> if the given collection is not
+ * <code>null</code> and not empty.
*/
public static <T> boolean isNotEmpty(Collection<T> collection) {
return !isEmpty(collection);
}
/**
- * @return TRUE if object reference is null
+ *
+ * @param object
+ * The object to check.
+ * @return <code>true</code> if the given object reference is
+ * <code>null</code>.
*/
public static boolean isNull(Object object) {
return object == null;
}
/**
- * @return TRUE if object reference is NOT null
+ *
+ * @param object
+ * The object to check.
+ * @return <code>true</code> if the given object reference is not
+ * <code>null</code>.
*/
public static boolean isNotNull(Object object) {
return object != null;
@@ -155,6 +195,9 @@
}
/**
+ *
+ * @param max
+ * the upper bound (exclusive)
* @return random Integer number between 0 and parameter max
*/
public static int getRandomNumber(int max) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/PersistenceUtils.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/PersistenceUtils.java
index ea0ca71..81a0463 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/PersistenceUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/util/PersistenceUtils.java
@@ -16,7 +16,11 @@
import java.util.Map.Entry;
import java.util.TreeMap;
-public class PersistenceUtils {
+public final class PersistenceUtils {
+
+ private PersistenceUtils() {
+ // private default constructor for helper class
+ }
/**
* The character that is used to separate the column and the value that
@@ -33,7 +37,7 @@
* from the properties file.
*/
public static Map<Integer, String> parseString(Object property) {
- TreeMap<Integer, String> map = new TreeMap<Integer, String>();
+ TreeMap<Integer, String> map = new TreeMap<>();
if (property != null) {
String value = (String) property;
@@ -71,7 +75,7 @@
* reconstruct this Map object from the String.
*/
public static String mapAsString(Map<Integer, String> map) {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
for (Entry<Integer, String> entry : map.entrySet()) {
buffer.append(entry.getKey() + COLUMN_VALUE_SEPARATOR
+ entry.getValue() + "|"); //$NON-NLS-1$
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/viewport/ViewportLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/viewport/ViewportLayer.java
index 5b67ec4..6406a0b 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/viewport/ViewportLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/viewport/ViewportLayer.java
@@ -665,12 +665,6 @@
return this.cachedWidth;
}
- @Override
- public int getColumnWidthByPosition(int columnPosition) {
- int width = super.getColumnWidthByPosition(columnPosition);
- return width;
- }
-
// Column resize
@Override
@@ -774,12 +768,6 @@
return this.cachedHeight;
}
- @Override
- public int getRowHeightByPosition(int rowPosition) {
- int height = super.getRowHeightByPosition(rowPosition);
- return height;
- }
-
// Row resize
// Y
@@ -1190,6 +1178,7 @@
*
* @param originX
* The origin x value to adjust if necessary.
+ * @return the adjusted x
*/
protected int adjustOriginX(int originX) {
if (getColumnCount() == 0) {
@@ -1244,6 +1233,7 @@
*
* @param originY
* The origin y value to adjust if necessary.
+ * @return the adjusted y
*/
protected int adjustOriginY(int originY) {
if (getRowCount() == 0) {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/viewport/event/ViewportEventHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/viewport/event/ViewportEventHandler.java
index 5516380..4e69487 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/viewport/event/ViewportEventHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/viewport/event/ViewportEventHandler.java
@@ -19,6 +19,7 @@
import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEventHandler;
import org.eclipse.nebula.widgets.nattable.layer.event.IStructuralChangeEvent;
import org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff;
+import org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff.DiffTypeEnum;
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
public class ViewportEventHandler implements ILayerEventHandler<IStructuralChangeEvent> {
@@ -58,29 +59,27 @@
.getMinimumOrigin().getX());
}
for (StructuralDiff columnDiff : columnDiffs) {
- switch (columnDiff.getDiffType()) {
- case ADD:
- Range afterPositionRange = columnDiff
- .getAfterPositionRange();
- if (minimumOriginColumnPosition > 0) {
- for (int i = afterPositionRange.start; i < afterPositionRange.end; i++) {
- if (i < minimumOriginColumnPosition) {
- minimumOriginColumnPosition++;
- }
+ DiffTypeEnum diffType = columnDiff.getDiffType();
+ if (diffType == DiffTypeEnum.ADD) {
+ Range afterPositionRange = columnDiff
+ .getAfterPositionRange();
+ if (minimumOriginColumnPosition > 0) {
+ for (int i = afterPositionRange.start; i < afterPositionRange.end; i++) {
+ if (i < minimumOriginColumnPosition) {
+ minimumOriginColumnPosition++;
}
}
- break;
- case DELETE:
- Range beforePositionRange = columnDiff
- .getBeforePositionRange();
- if (minimumOriginColumnPosition > 0) {
- for (int i = beforePositionRange.start; i < beforePositionRange.end; i++) {
- if (i < minimumOriginColumnPosition) {
- columnOffset -= 1;
- }
+ }
+ } else if (diffType == DiffTypeEnum.DELETE) {
+ Range beforePositionRange = columnDiff
+ .getBeforePositionRange();
+ if (minimumOriginColumnPosition > 0) {
+ for (int i = beforePositionRange.start; i < beforePositionRange.end; i++) {
+ if (i < minimumOriginColumnPosition) {
+ columnOffset -= 1;
}
}
- break;
+ }
}
}
}
@@ -136,29 +135,27 @@
.getY());
}
for (StructuralDiff rowDiff : rowDiffs) {
- switch (rowDiff.getDiffType()) {
- case ADD:
- Range afterPositionRange = rowDiff
- .getAfterPositionRange();
- if (minimumOriginRowPosition > 0) {
- for (int i = afterPositionRange.start; i < afterPositionRange.end; i++) {
- if (i < minimumOriginRowPosition) {
- minimumOriginRowPosition++;
- }
+ DiffTypeEnum diffType = rowDiff.getDiffType();
+ if (diffType == DiffTypeEnum.ADD) {
+ Range afterPositionRange = rowDiff
+ .getAfterPositionRange();
+ if (minimumOriginRowPosition > 0) {
+ for (int i = afterPositionRange.start; i < afterPositionRange.end; i++) {
+ if (i < minimumOriginRowPosition) {
+ minimumOriginRowPosition++;
}
}
- break;
- case DELETE:
- Range beforePositionRange = rowDiff
- .getBeforePositionRange();
- if (minimumOriginRowPosition > 0) {
- for (int i = beforePositionRange.start; i < beforePositionRange.end; i++) {
- if (i < minimumOriginRowPosition) {
- rowOffset -= 1;
- }
+ }
+ } else if (diffType == DiffTypeEnum.DELETE) {
+ Range beforePositionRange = rowDiff
+ .getBeforePositionRange();
+ if (minimumOriginRowPosition > 0) {
+ for (int i = beforePositionRange.start; i < beforePositionRange.end; i++) {
+ if (i < minimumOriginRowPosition) {
+ rowOffset -= 1;
}
}
- break;
+ }
}
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/widget/NatCombo.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/widget/NatCombo.java
index 9e97786..3f95b98 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/widget/NatCombo.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/widget/NatCombo.java
@@ -240,38 +240,38 @@
* list of listeners because the two controls that are combined in this
* control share the same focus.
*/
- private List<FocusListener> focusListener = new ArrayList<FocusListener>();
+ private List<FocusListener> focusListener = new ArrayList<>();
/**
* List of KeyListener that should be added to the dropdown table once it is
* created. Kept locally because the table creation is deferred to the first
* access.
*/
- private List<KeyListener> keyListener = new ArrayList<KeyListener>();
+ private List<KeyListener> keyListener = new ArrayList<>();
/**
* List of TraverseListener that should be added to the dropdown table once
* it is created. Kept locally because the table creation is deferred to the
* first access.
*/
- private List<TraverseListener> traverseListener = new ArrayList<TraverseListener>();
+ private List<TraverseListener> traverseListener = new ArrayList<>();
/**
* List of MouseListener that should be added to the dropdown table once it
* is created. Kept locally because the table creation is deferred to the
* first access.
*/
- private List<MouseListener> mouseListener = new ArrayList<MouseListener>();
+ private List<MouseListener> mouseListener = new ArrayList<>();
/**
* List of SelectionListener that should be added to the dropdown table once
* it is created. Kept locally because the table creation is deferred to the
* first access.
*/
- private List<SelectionListener> selectionListener = new ArrayList<SelectionListener>();
+ private List<SelectionListener> selectionListener = new ArrayList<>();
/**
* List of ShellListener that should be added to the dropdown table once it
* is created. Kept locally because the table creation is deferred to the
* first access.
*/
- private List<ShellListener> shellListener = new ArrayList<ShellListener>();
+ private List<ShellListener> shellListener = new ArrayList<>();
/**
* Creates a new NatCombo using the given IStyle for rendering, showing the
@@ -440,7 +440,7 @@
public void setItems(String[] items) {
if (items != null) {
this.itemList = Arrays.asList(items);
- this.selectionStateMap = new LinkedHashMap<String, Boolean>();
+ this.selectionStateMap = new LinkedHashMap<>();
for (String item : items) {
this.selectionStateMap.put(item, Boolean.FALSE);
}
@@ -744,7 +744,7 @@
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (null != element && element instanceof String) {
+ if (element instanceof String) {
return ((String) element).toLowerCase().contains(NatCombo.this.filterBox.getText().toLowerCase());
}
return false;
@@ -972,7 +972,7 @@
*/
public int[] getSelectionIndices() {
if (this.selectionStateMap != null) {
- List<Integer> selectedIndices = new ArrayList<Integer>();
+ List<Integer> selectedIndices = new ArrayList<>();
for (String item : this.selectionStateMap.keySet()) {
if (this.selectionStateMap.get(item)) {
selectedIndices.add(this.itemList.indexOf(item));
@@ -1000,7 +1000,7 @@
*/
public int getSelectionCount() {
if (this.selectionStateMap != null) {
- List<Integer> selectedIndices = new ArrayList<Integer>();
+ List<Integer> selectedIndices = new ArrayList<>();
for (String item : this.selectionStateMap.keySet()) {
if (this.selectionStateMap.get(item)) {
selectedIndices.add(this.itemList.indexOf(item));
@@ -1306,7 +1306,7 @@
* @return Array containing all selected TableItem text attributes
*/
protected String[] getTransformedSelection() {
- List<String> selectedItems = new ArrayList<String>();
+ List<String> selectedItems = new ArrayList<>();
for (String item : this.selectionStateMap.keySet()) {
Boolean isSelected = this.selectionStateMap.get(item);
if (isSelected != null && isSelected) {
@@ -1326,7 +1326,7 @@
*/
protected void setDropdownSelection(String[] selection) {
java.util.List<String> selectionList = Arrays.asList(selection);
- java.util.List<TableItem> selectedItems = new ArrayList<TableItem>();
+ java.util.List<TableItem> selectedItems = new ArrayList<>();
for (TableItem item : getDropdownTable().getItems()) {
if (selectionList.contains(EditConstants.SELECT_ALL_ITEMS_VALUE)
|| selectionList.contains(item.getText())) {
@@ -1503,7 +1503,7 @@
NatCombo.this.hasFocus = false;
Display.getCurrent().timerExec(100, () -> {
if (!NatCombo.this.hasFocus) {
- List<FocusListener> copy = new ArrayList<FocusListener>(NatCombo.this.focusListener);
+ List<FocusListener> copy = new ArrayList<>(NatCombo.this.focusListener);
for (FocusListener f : copy) {
f.focusLost(e);
}
diff --git a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowDataFixture.java b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowDataFixture.java
index 03ea0db..f836132 100644
--- a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowDataFixture.java
+++ b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowDataFixture.java
@@ -139,10 +139,16 @@
/**
* Convenience method to quickly get a new instance
+ *
+ * @param description
+ * The description.
+ * @param rating
+ * The rating.
+ * @return A new {@link RowDataFixture} instance.
*/
- public static RowDataFixture getInstance(String descrition, String rating) {
+ public static RowDataFixture getInstance(String description, String rating) {
return new RowDataFixture("US" + getRandomNumber(1000),
- descrition, rating, getRandomDate(), PRICING_MANUAL, 1.000, 10,
+ description, rating, getRandomDate(), PRICING_MANUAL, 1.000, 10,
1000, true, 1.00, 1.01, -.01, 1000, 1000, 1000D);
}
@@ -163,6 +169,8 @@
}
/**
+ * @param max
+ * The upper bound
* @return random Integer number between 0 and parameter max
*/
public static int getRandomNumber(int max) {
diff --git a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowDataListFixture.java b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowDataListFixture.java
index 71cbef4..1ee2f47 100644
--- a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowDataListFixture.java
+++ b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowDataListFixture.java
@@ -188,8 +188,7 @@
propertyToLabelMap.put(EPS_PROP_NAME, "EPS");
propertyToLabelMap.put(VOLUME_PROP_NAME, "Volume");
propertyToLabelMap.put(MARKET_CAP_PROP_NAME, "Market Cap.");
- propertyToLabelMap
- .put(INSTITUTION_OWNED_PROP_NAME, "Institution Owned");
+ propertyToLabelMap.put(INSTITUTION_OWNED_PROP_NAME, "Institution Owned");
propertyToLabelMap.put(FIELD_20_PROP_NAME, "Field 20");
propertyToLabelMap.put(FIELD_21_PROP_NAME, "Field 21");
@@ -221,12 +220,9 @@
return Arrays.asList(RowDataListFixture.getPropertyNames());
}
- /**
- * Get the index of the property name. This will be same as the order in
- * which the columns/properties were initially supplied.
- */
public static int getColumnIndexOfProperty(String propertyName) {
- return RowDataListFixture.getPropertyNamesAsList()
- .indexOf(propertyName);
+ // Get the index of the property name. This will be same as the order in
+ // which the columns/properties were initially supplied.
+ return RowDataListFixture.getPropertyNamesAsList().indexOf(propertyName);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowGroupDataFixture.java b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowGroupDataFixture.java
index 67d09e2..11ab0ea 100644
--- a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowGroupDataFixture.java
+++ b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowGroupDataFixture.java
@@ -136,11 +136,16 @@
// }
/**
* Convenience method to quickly get a new instance
+ *
+ * @param description
+ * The description.
+ * @param rating
+ * The rating.
+ * @return A new {@link RowGroupDataFixture} instance.
*/
- public static RowGroupDataFixture getInstance(String descrition,
- String rating) {
+ public static RowGroupDataFixture getInstance(String description, String rating) {
return new RowGroupDataFixture(
- "US" + RowDataFixture.getRandomNumber(1000), descrition, rating,
+ "US" + RowDataFixture.getRandomNumber(1000), description, rating,
RowDataFixture.getRandomDate(), PRICING_MANUAL, 1.000, 10, 1000, true, 1.00,
1.01, -.01, 1000, 1000, 1000D);
}
diff --git a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowGroupDataListFixture.java b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowGroupDataListFixture.java
index 4cbc74f..bc457b7 100644
--- a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowGroupDataListFixture.java
+++ b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/fixture/data/RowGroupDataListFixture.java
@@ -177,7 +177,7 @@
}
public static Map<String, String> getPropertyToLabelMap() {
- Map<String, String> propertyToLabelMap = new LinkedHashMap<String, String>();
+ Map<String, String> propertyToLabelMap = new LinkedHashMap<>();
propertyToLabelMap.put(SECURITY_ID_PROP_NAME, "ISIN");
propertyToLabelMap.put(SECURITY_DESCRIPTION_PROP_NAME, "Sec Desc");
// rating
@@ -194,8 +194,7 @@
propertyToLabelMap.put(EPS_PROP_NAME, "EPS");
propertyToLabelMap.put(VOLUME_PROP_NAME, "Volume");
propertyToLabelMap.put(MARKET_CAP_PROP_NAME, "Market Cap.");
- propertyToLabelMap
- .put(INSTITUTION_OWNED_PROP_NAME, "Institution Owned");
+ propertyToLabelMap.put(INSTITUTION_OWNED_PROP_NAME, "Institution Owned");
propertyToLabelMap.put(FIELD_20_PROP_NAME, "Field 20");
propertyToLabelMap.put(FIELD_21_PROP_NAME, "Field 21");
@@ -227,12 +226,9 @@
return Arrays.asList(RowGroupDataListFixture.getPropertyNames());
}
- /**
- * Get the index of the property name. This will be same as the order in
- * which the columns/properties were initially supplied.
- */
public static int getColumnIndexOfProperty(String propertyName) {
- return RowGroupDataListFixture.getPropertyNamesAsList().indexOf(
- propertyName);
+ // Get the index of the property name. This will be same as the order in
+ // which the columns/properties were initially supplied.
+ return RowGroupDataListFixture.getPropertyNamesAsList().indexOf(propertyName);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/generator/GenerateListOfStrings.java b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/generator/GenerateListOfStrings.java
index 8cd7c2f..ead6571 100644
--- a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/generator/GenerateListOfStrings.java
+++ b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/generator/GenerateListOfStrings.java
@@ -28,6 +28,8 @@
* generated with the weighting given (eg adding 6 nulls to a list of 6
* strings ought to produce nulls 50% of the time). Default is zero ie no
* nulls.
+ *
+ * @return the number of nulls to generate
*/
int nullLoadFactor() default 0;
diff --git a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/person/PersonService.java b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/person/PersonService.java
index 0d481b7..82059a4 100644
--- a/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/person/PersonService.java
+++ b/org.eclipse.nebula.widgets.nattable.dataset/src/org/eclipse/nebula/widgets/nattable/dataset/person/PersonService.java
@@ -27,7 +27,11 @@
* Class that acts as service for accessing numerous {@link Person}s. The values
* are randomly put together out of names and places from "The Simpsons"
*/
-public class PersonService {
+public final class PersonService {
+
+ private PersonService() {
+ // private default constructor for helper class
+ }
private static Random randomGenerator = new SecureRandom();
@@ -58,7 +62,7 @@
* @return A list containing the given amount of random generated persons.
*/
public static List<Person> getRandomPersons(int numberOfPersons) {
- List<Person> result = new ArrayList<Person>();
+ List<Person> result = new ArrayList<>();
for (int i = 0; i < numberOfPersons; i++) {
result.add(createPerson(i));
@@ -68,117 +72,89 @@
}
/**
- * Creates a fixed list of {@link Person}s.
+ *
+ * @return A fixed list of {@link Person}s.
*/
public static List<Person> getFixedPersons() {
- List<Person> result = new ArrayList<Person>();
+ List<Person> result = new ArrayList<>();
// create 10 Simpsons
// 3 Homer
- result.add(new Person(1, maleNames[1], lastNames[0], Gender.MALE, true,
- new Date(), 100d));
- result.add(new Person(2, maleNames[1], lastNames[0], Gender.MALE, true,
- new Date(), 100d));
- result.add(new Person(3, maleNames[1], lastNames[0], Gender.MALE, true,
- new Date(), 100d));
+ result.add(new Person(1, maleNames[1], lastNames[0], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(2, maleNames[1], lastNames[0], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(3, maleNames[1], lastNames[0], Gender.MALE, true, new Date(), 100d));
// 3 Bart
- result.add(new Person(4, maleNames[0], lastNames[0], Gender.MALE,
- false, new Date(), 100d));
- result.add(new Person(5, maleNames[0], lastNames[0], Gender.MALE,
- false, new Date(), 100d));
- result.add(new Person(6, maleNames[0], lastNames[0], Gender.MALE,
- false, new Date(), 100d));
+ result.add(new Person(4, maleNames[0], lastNames[0], Gender.MALE, false, new Date(), 100d));
+ result.add(new Person(5, maleNames[0], lastNames[0], Gender.MALE, false, new Date(), 100d));
+ result.add(new Person(6, maleNames[0], lastNames[0], Gender.MALE, false, new Date(), 100d));
// 2 Marge
- result.add(new Person(7, femaleNames[0], lastNames[0], Gender.FEMALE,
- true, new Date(), 100d));
- result.add(new Person(8, femaleNames[0], lastNames[0], Gender.FEMALE,
- true, new Date(), 100d));
+ result.add(new Person(7, femaleNames[0], lastNames[0], Gender.FEMALE, true, new Date(), 100d));
+ result.add(new Person(8, femaleNames[0], lastNames[0], Gender.FEMALE, true, new Date(), 100d));
// 2 Lisa
- result.add(new Person(9, femaleNames[1], lastNames[0], Gender.FEMALE,
- false, new Date(), 100d));
- result.add(new Person(10, femaleNames[1], lastNames[0], Gender.FEMALE,
- false, new Date(), 100d));
+ result.add(new Person(9, femaleNames[1], lastNames[0], Gender.FEMALE, false, new Date(), 100d));
+ result.add(new Person(10, femaleNames[1], lastNames[0], Gender.FEMALE, false, new Date(), 100d));
// create 8 Flanders
// 2 Ned
- result.add(new Person(11, maleNames[5], lastNames[4], Gender.MALE,
- true, new Date(), 100d));
- result.add(new Person(12, maleNames[5], lastNames[4], Gender.MALE,
- true, new Date(), 100d));
+ result.add(new Person(11, maleNames[5], lastNames[4], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(12, maleNames[5], lastNames[4], Gender.MALE, true, new Date(), 100d));
// 2 Maude
- result.add(new Person(13, femaleNames[6], lastNames[4], Gender.FEMALE,
- true, new Date(), 100d));
- result.add(new Person(14, femaleNames[6], lastNames[4], Gender.FEMALE,
- true, new Date(), 100d));
+ result.add(new Person(13, femaleNames[6], lastNames[4], Gender.FEMALE, true, new Date(), 100d));
+ result.add(new Person(14, femaleNames[6], lastNames[4], Gender.FEMALE, true, new Date(), 100d));
// 2 Rod
- result.add(new Person(15, maleNames[7], lastNames[4], Gender.MALE,
- false, new Date(), 100d));
- result.add(new Person(16, maleNames[7], lastNames[4], Gender.MALE,
- false, new Date(), 100d));
+ result.add(new Person(15, maleNames[7], lastNames[4], Gender.MALE, false, new Date(), 100d));
+ result.add(new Person(16, maleNames[7], lastNames[4], Gender.MALE, false, new Date(), 100d));
// 2 Tod
- result.add(new Person(17, maleNames[8], lastNames[4], Gender.MALE,
- false, new Date(), 100d));
- result.add(new Person(18, maleNames[8], lastNames[4], Gender.MALE,
- false, new Date(), 100d));
+ result.add(new Person(17, maleNames[8], lastNames[4], Gender.MALE, false, new Date(), 100d));
+ result.add(new Person(18, maleNames[8], lastNames[4], Gender.MALE, false, new Date(), 100d));
return result;
}
/**
- * Creates a fixed list of {@link Person}s with a few null values.
+ *
+ * @return A fixed list of {@link Person}s with a few null values.
*/
public static List<Person> getFixedPersonsWithNull() {
- List<Person> result = new ArrayList<Person>();
+ List<Person> result = new ArrayList<>();
// create 5 Simpsons
// 2 Homer
- result.add(new Person(1, maleNames[1], lastNames[0], Gender.MALE, true,
- new Date(), 100d));
- result.add(new Person(3, maleNames[1], lastNames[0], Gender.MALE, true,
- new Date(), 100d));
+ result.add(new Person(1, maleNames[1], lastNames[0], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(3, maleNames[1], lastNames[0], Gender.MALE, true, new Date(), 100d));
// 2 Marge
- result.add(new Person(7, femaleNames[0], lastNames[0], Gender.FEMALE,
- true, new Date(), 100d));
- result.add(new Person(8, femaleNames[0], lastNames[0], Gender.FEMALE,
- true, new Date(), 100d));
+ result.add(new Person(7, femaleNames[0], lastNames[0], Gender.FEMALE, true, new Date(), 100d));
+ result.add(new Person(8, femaleNames[0], lastNames[0], Gender.FEMALE, true, new Date(), 100d));
// 1 Bart without money
- result.add(new Person(7, femaleNames[0], lastNames[0], Gender.FEMALE,
- true, new Date(), null));
+ result.add(new Person(7, femaleNames[0], lastNames[0], Gender.FEMALE, true, new Date(), null));
// create 2 Flanders without last name
// 1 Ned
- result.add(new Person(11, maleNames[5], null, Gender.MALE,
- true, new Date(), 100d));
+ result.add(new Person(11, maleNames[5], null, Gender.MALE, true, new Date(), 100d));
// 1 Maude
- result.add(new Person(13, femaleNames[6], null, Gender.FEMALE,
- true, new Date(), 100d));
+ result.add(new Person(13, femaleNames[6], null, Gender.FEMALE, true, new Date(), 100d));
return result;
}
+ /**
+ *
+ * @return A fixed list of {@link Person}s with a few double values.
+ */
public static List<Person> getFixedMixedPersons() {
- List<Person> result = new ArrayList<Person>();
+ List<Person> result = new ArrayList<>();
- result.add(new Person(21, maleNames[0], lastNames[2], Gender.MALE,
- true, new Date(), 100d));
- result.add(new Person(22, maleNames[1], lastNames[2], Gender.MALE,
- true, new Date(), 100d));
- result.add(new Person(23, maleNames[5], lastNames[2], Gender.MALE,
- true, new Date(), 100d));
- result.add(new Person(24, femaleNames[0], lastNames[2], Gender.FEMALE,
- false, new Date(), 100d));
- result.add(new Person(25, femaleNames[6], lastNames[2], Gender.FEMALE,
- false, new Date(), 100d));
+ result.add(new Person(21, maleNames[0], lastNames[2], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(22, maleNames[1], lastNames[2], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(23, maleNames[5], lastNames[2], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(24, femaleNames[0], lastNames[2], Gender.FEMALE, false, new Date(), 100d));
+ result.add(new Person(25, femaleNames[6], lastNames[2], Gender.FEMALE, false, new Date(), 100d));
// add doubles
- result.add(new Person(30, maleNames[1], lastNames[0], Gender.MALE,
- true, new Date(), 100d));
- result.add(new Person(31, maleNames[1], lastNames[0], Gender.MALE,
- true, new Date(), 100d));
- result.add(new Person(32, maleNames[1], lastNames[2], Gender.MALE,
- true, new Date(), 100d));
- result.add(new Person(33, maleNames[1], lastNames[2], Gender.MALE,
- true, new Date(), 100d));
+ result.add(new Person(30, maleNames[1], lastNames[0], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(31, maleNames[1], lastNames[0], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(32, maleNames[1], lastNames[2], Gender.MALE, true, new Date(), 100d));
+ result.add(new Person(33, maleNames[1], lastNames[2], Gender.MALE, true, new Date(), 100d));
return result;
}
@@ -188,10 +164,10 @@
*
* @param numberOfPersons
* The number of {@link Person}s that should be generated.
- * @return
+ * @return A list of {@link Person}s.
*/
public static List<Person> getPersons(int numberOfPersons) {
- List<Person> result = new ArrayList<Person>();
+ List<Person> result = new ArrayList<>();
for (int i = 0; i < numberOfPersons; i++) {
result.add(createPerson(i));
@@ -205,10 +181,10 @@
*
* @param number
* The number of {@link Address} that should be generated.
- * @return
+ * @return A list of {@link Address}.
*/
public static List<Address> getAddress(int number) {
- List<Address> result = new ArrayList<Address>();
+ List<Address> result = new ArrayList<>();
for (int i = 0; i < number; i++) {
result.add(createAddress());
@@ -223,11 +199,10 @@
* @param numberOfPersons
* The number of {@link PersonWithAddress} that should be
* generated.
- * @return
+ * @return A list of {@link PersonWithAddress}.
*/
- public static List<PersonWithAddress> getPersonsWithAddress(
- int numberOfPersons) {
- List<PersonWithAddress> result = new ArrayList<PersonWithAddress>();
+ public static List<PersonWithAddress> getPersonsWithAddress(int numberOfPersons) {
+ List<PersonWithAddress> result = new ArrayList<>();
for (int i = 0; i < numberOfPersons; i++) {
result.add(createPersonWithAddress(i));
@@ -242,11 +217,10 @@
* @param numberOfPersons
* The number of {@link ExtendedPersonWithAddress} that should be
* generated.
- * @return
+ * @return A list of {@link ExtendedPersonWithAddress}.
*/
- public static List<ExtendedPersonWithAddress> getExtendedPersonsWithAddress(
- int numberOfPersons) {
- List<ExtendedPersonWithAddress> result = new ArrayList<ExtendedPersonWithAddress>();
+ public static List<ExtendedPersonWithAddress> getExtendedPersonsWithAddress(int numberOfPersons) {
+ List<ExtendedPersonWithAddress> result = new ArrayList<>();
for (int i = 0; i < numberOfPersons; i++) {
result.add(createExtendedPersonWithAddress(i));
@@ -259,7 +233,9 @@
* Creates a random person out of names which are taken from "The Simpsons"
* and enrich them with random generated married state and birthday date.
*
- * @return
+ * @param id
+ * A unique id for the person.
+ * @return A random person.
*/
private static Person createPerson(int id) {
Person result = new Person(id);
@@ -287,7 +263,7 @@
try {
result.setBirthday(sdf.parse("" + year + "-" + month + "-" + day));
} catch (ParseException e) {
- // do nothing as there should be no parse exception;
+ // do nothing as there should be no parse exception
}
result.setMoney(randomGenerator.nextDouble() * 100);
@@ -299,7 +275,7 @@
* which are taken from "The Simpsons" (i haven't found postal codes, so
* here i invented some for the example)
*
- * @return
+ * @return A random address.
*/
public static Address createAddress() {
String[] streets = getStreetNames();
@@ -324,7 +300,9 @@
* names which are taken from "The Simpsons" (i haven't found postal codes,
* so here i invented some for the example)
*
- * @return
+ * @param id
+ * A unique id for the person.
+ * @return A random person with a random address.
*/
public static PersonWithAddress createPersonWithAddress(int id) {
return new PersonWithAddress(createPerson(id), createAddress());
@@ -339,13 +317,20 @@
* like a password, a random long description text, a money balance and
* collections of favourite food and drinks.
*
- * @return
+ * @param id
+ * A unique id for the person.
+ * @return A random person with a random address and some random extended
+ * information.
*/
public static ExtendedPersonWithAddress createExtendedPersonWithAddress(int id) {
- return new ExtendedPersonWithAddress(createPerson(id),
- createAddress(), generateSimplePassword(),
- createRandomLengthText(), createRandomMoneyAmount(),
- createFavouriteFood(), createFavouriteDrinks());
+ return new ExtendedPersonWithAddress(
+ createPerson(id),
+ createAddress(),
+ generateSimplePassword(),
+ createRandomLengthText(),
+ createRandomMoneyAmount(),
+ createFavouriteFood(),
+ createFavouriteDrinks());
}
/**
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/AbstractNatExample.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/AbstractNatExample.java
index 2b5f707..0723c96 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/AbstractNatExample.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/AbstractNatExample.java
@@ -77,7 +77,10 @@
}
/**
- * Text area at the bottom
+ *
+ * @param parent
+ * The parent composite.
+ * @return The Text area at the bottom.
*/
public Text setupTextArea(Composite parent) {
this.outputArea = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_300_Data/_302_CustomColumnPropertyAccessorExample.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_300_Data/_302_CustomColumnPropertyAccessorExample.java
index d1a280d..8374ab9 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_300_Data/_302_CustomColumnPropertyAccessorExample.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_300_Data/_302_CustomColumnPropertyAccessorExample.java
@@ -86,13 +86,15 @@
}
/**
- * Creates the {@link IDataProvider} for the column header of this
- * {@link GridLayer}. Should always return the same column count and values
- * for all columns that are defined within the {@link IDataProvider} of the
- * body layer stack. Uses the {@link DefaultColumnHeaderDataProvider} which
- * simply checks for the property name within the propertyNames array and
- * returns the corresponding value out of the propertyToLabelMap. Another
- * approach is to implement a completely new {@link IDataProvider}
+ *
+ * @return The {@link IDataProvider} for the column header of this
+ * {@link GridLayer}. Should always return the same column count and
+ * values for all columns that are defined within the
+ * {@link IDataProvider} of the body layer stack. Uses the
+ * {@link DefaultColumnHeaderDataProvider} which simply checks for
+ * the property name within the propertyNames array and returns the
+ * corresponding value out of the propertyToLabelMap. Another
+ * approach is to implement a completely new {@link IDataProvider}.
*/
protected IDataProvider createColumnHeaderDataProvider() {
String[] propertyNames = {
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_511_Grouping/_5112_TwoLevelColumnGroupingExample.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_511_Grouping/_5112_TwoLevelColumnGroupingExample.java
index 107a149..690895c 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_511_Grouping/_5112_TwoLevelColumnGroupingExample.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_511_Grouping/_5112_TwoLevelColumnGroupingExample.java
@@ -141,7 +141,7 @@
columnGroupHeaderLayer.setGroupUnbreakable(1);
ColumnGroupGroupHeaderLayer sndGroup =
- new ColumnGroupGroupHeaderLayer(columnGroupHeaderLayer, selectionLayer, sndColumnGroupModel);
+ new ColumnGroupGroupHeaderLayer(columnGroupHeaderLayer, sndColumnGroupModel);
sndGroup.addColumnsIndexesToGroup("PersonWithAddress", 0, 1, 2, 3, 4, 5, 6, 7);
sndGroup.addColumnsIndexesToGroup("Additional Information", 8, 9, 10, 11, 12, 13);
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_800_Integration/_807_SortableFilterableColumnGroupExample.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_800_Integration/_807_SortableFilterableColumnGroupExample.java
index 85540ec..208034a 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_800_Integration/_807_SortableFilterableColumnGroupExample.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_800_Integration/_807_SortableFilterableColumnGroupExample.java
@@ -166,7 +166,6 @@
ColumnGroupGroupHeaderLayer sndGroup =
new ColumnGroupGroupHeaderLayer(
columnGroupHeaderLayer,
- bodyLayer.getSelectionLayer(),
this.sndColumnGroupModel);
sndGroup.addColumnsIndexesToGroup("PersonWithAddress", 0, 1, 2, 3, 4, 5, 6, 7);
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_800_Integration/_816_EditableFixedSummaryRowWithFreezeExample.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_800_Integration/_816_EditableFixedSummaryRowWithFreezeExample.java
index 221b143..517cf23 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_800_Integration/_816_EditableFixedSummaryRowWithFreezeExample.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_800_Integration/_816_EditableFixedSummaryRowWithFreezeExample.java
@@ -37,7 +37,7 @@
import org.eclipse.nebula.widgets.nattable.examples.runner.StandaloneNatExampleRunner;
import org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer;
import org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer;
-import org.eclipse.nebula.widgets.nattable.freeze.IFreezeConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.freeze.FreezeConfigAttributes;
import org.eclipse.nebula.widgets.nattable.freeze.config.DefaultFreezeGridBindings;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
@@ -166,7 +166,7 @@
DisplayMode.NORMAL);
configRegistry.registerConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_COLOR,
+ FreezeConfigAttributes.SEPARATOR_COLOR,
GUIHelper.COLOR_RED);
}
});
@@ -251,7 +251,7 @@
DisplayMode.NORMAL);
configRegistry.registerConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_COLOR,
+ FreezeConfigAttributes.SEPARATOR_COLOR,
GUIHelper.COLOR_RED);
}
});
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_103_Events/Real_time_data_updates.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_103_Events/Real_time_data_updates.java
index 7e6a0a5..a464be0 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_103_Events/Real_time_data_updates.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_103_Events/Real_time_data_updates.java
@@ -103,7 +103,7 @@
.getBodyDataProvider();
// Select complete rows
- RowOnlySelectionConfiguration<RowDataFixture> selectionConfig = new RowOnlySelectionConfiguration<>();
+ RowOnlySelectionConfiguration selectionConfig = new RowOnlySelectionConfiguration();
selectionLayer.addConfiguration(selectionConfig);
this.nattable.addConfiguration(new RowOnlySelectionBindings());
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_120_Selection/Selection_events.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_120_Selection/Selection_events.java
index ac11b16..d8d4ed1 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_120_Selection/Selection_events.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_120_Selection/Selection_events.java
@@ -76,8 +76,7 @@
}));
- selectionLayer
- .addConfiguration(new RowOnlySelectionConfiguration<RowDataFixture>());
+ selectionLayer.addConfiguration(new RowOnlySelectionConfiguration());
this.nattable.addConfiguration(new RowOnlySelectionBindings());
this.nattable.configure();
@@ -86,8 +85,7 @@
// Layout widgets
parent.setLayout(new GridLayout(1, true));
- this.nattable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
- true));
+ this.nattable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
setupTextArea(parent);
return this.nattable;
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_150_Column_and_row_grouping/_001_Two_level_column_groups.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_150_Column_and_row_grouping/_001_Two_level_column_groups.java
index abd85fd..ab7ee1f 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_150_Column_and_row_grouping/_001_Two_level_column_groups.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/examples/_150_Column_and_row_grouping/_001_Two_level_column_groups.java
@@ -92,7 +92,6 @@
ColumnGroupGroupHeaderLayer sndGroup =
new ColumnGroupGroupHeaderLayer(
columnGroupHeaderLayer,
- bodyLayer.getSelectionLayer(),
this.sndColumnGroupModel);
sndGroup.addColumnsIndexesToGroup("GroupGroup 1", 1, 2, 3, 4, 5, 6, 7);
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/fixtures/GlazedListsGridLayer.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/fixtures/GlazedListsGridLayer.java
index 1b9f15f..9d2518d 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/fixtures/GlazedListsGridLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/fixtures/GlazedListsGridLayer.java
@@ -30,9 +30,6 @@
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
-import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
-import org.eclipse.nebula.widgets.nattable.sort.command.SortColumnCommand;
-import org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.SortedList;
@@ -52,34 +49,33 @@
private ListDataProvider<T> bodyDataProvider;
private GlazedListsColumnHeaderLayerStack<T> columnHeaderLayerStack;
- public GlazedListsGridLayer(EventList<T> eventList, String[] propertyNames,
+ public GlazedListsGridLayer(
+ EventList<T> eventList,
+ String[] propertyNames,
Map<String, String> propertyToLabelMap,
IConfigRegistry configRegistry) {
this(eventList, propertyNames, propertyToLabelMap, configRegistry, true);
}
- /**
- * The underlying {@link DataLayer} created is able to handle Events raised
- * by GlazedLists and fire corresponding NatTable events.
- *
- * The {@link SortHeaderLayer} triggers sorting on the the underlying
- * SortedList when a {@link SortColumnCommand} is received.
- */
- public GlazedListsGridLayer(EventList<T> eventList, String[] propertyNames,
+ public GlazedListsGridLayer(
+ EventList<T> eventList,
+ String[] propertyNames,
Map<String, String> propertyToLabelMap,
- IConfigRegistry configRegistry, boolean useDefaultConfiguration) {
+ IConfigRegistry configRegistry,
+ boolean useDefaultConfiguration) {
- this(eventList, new ReflectiveColumnPropertyAccessor<T>(propertyNames),
- new DefaultColumnHeaderDataProvider(propertyNames,
- propertyToLabelMap),
+ this(eventList, new ReflectiveColumnPropertyAccessor<>(propertyNames),
+ new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap),
configRegistry,
useDefaultConfiguration);
}
- public GlazedListsGridLayer(EventList<T> eventList,
+ public GlazedListsGridLayer(
+ EventList<T> eventList,
IColumnPropertyAccessor<T> columnPropertyAccessor,
IDataProvider columnHeaderDataProvider,
- IConfigRegistry configRegistry, boolean useDefaultConfiguration) {
+ IConfigRegistry configRegistry,
+ boolean useDefaultConfiguration) {
super(useDefaultConfiguration);
@@ -87,33 +83,46 @@
// NOTE: Remember to use the SortedList constructor with 'null' for the
// Comparator
SortedList<T> sortedList = new SortedList<>(eventList, null);
- this.bodyDataProvider = new ListDataProvider<>(sortedList,
- columnPropertyAccessor);
+ this.bodyDataProvider = new ListDataProvider<>(sortedList, columnPropertyAccessor);
- this.bodyDataLayer = new DataLayer(this.bodyDataProvider);
- GlazedListsEventLayer<T> glazedListsEventLayer = new GlazedListsEventLayer<>(
- this.bodyDataLayer, eventList);
- this.bodyLayerStack = new DefaultBodyLayerStack(glazedListsEventLayer);
+ this.bodyDataLayer =
+ new DataLayer(this.bodyDataProvider);
+ GlazedListsEventLayer<T> glazedListsEventLayer =
+ new GlazedListsEventLayer<>(this.bodyDataLayer, eventList);
+ this.bodyLayerStack =
+ new DefaultBodyLayerStack(glazedListsEventLayer);
// Column header
- this.columnHeaderLayerStack = new GlazedListsColumnHeaderLayerStack<>(
- columnHeaderDataProvider, sortedList, columnPropertyAccessor,
- configRegistry, this.bodyLayerStack);
+ this.columnHeaderLayerStack =
+ new GlazedListsColumnHeaderLayerStack<>(
+ columnHeaderDataProvider,
+ sortedList,
+ columnPropertyAccessor,
+ configRegistry, this.bodyLayerStack);
// Row header
- DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
- this.bodyDataProvider);
- DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(
- rowHeaderDataProvider);
- RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer,
- this.bodyLayerStack, this.bodyLayerStack.getSelectionLayer());
+ DefaultRowHeaderDataProvider rowHeaderDataProvider =
+ new DefaultRowHeaderDataProvider(this.bodyDataProvider);
+ DefaultRowHeaderDataLayer rowHeaderDataLayer =
+ new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
+ RowHeaderLayer rowHeaderLayer =
+ new RowHeaderLayer(
+ rowHeaderDataLayer,
+ this.bodyLayerStack,
+ this.bodyLayerStack.getSelectionLayer());
// Corner
- DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
- this.columnHeaderLayerStack.getDataProvider(), rowHeaderDataProvider);
- DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
- CornerLayer cornerLayer = new CornerLayer(cornerDataLayer,
- rowHeaderLayer, this.columnHeaderLayerStack);
+ DefaultCornerDataProvider cornerDataProvider =
+ new DefaultCornerDataProvider(
+ this.columnHeaderLayerStack.getDataProvider(),
+ rowHeaderDataProvider);
+ DataLayer cornerDataLayer =
+ new DataLayer(cornerDataProvider);
+ CornerLayer cornerLayer =
+ new CornerLayer(
+ cornerDataLayer,
+ rowHeaderLayer,
+ this.columnHeaderLayerStack);
// Grid
setBodyLayer(this.bodyLayerStack);
@@ -126,11 +135,6 @@
return this.columnLabelAccumulator;
}
- @Override
- public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) {
- super.setClientAreaProvider(clientAreaProvider);
- }
-
public DataLayer getBodyDataLayer() {
return this.bodyDataLayer;
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSConstants.java b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSConstants.java
index 986953d..15909a4 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSConstants.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSConstants.java
@@ -19,11 +19,12 @@
/**
* Constants class for NatTable CSS support.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
*/
-public interface NatTableCSSConstants {
+public final class NatTableCSSConstants {
+
+ private NatTableCSSConstants() {
+ // private default constructor for helper class
+ }
// CSS properties
@@ -31,12 +32,12 @@
* CSS property for the NatTable background color. This has effect on the
* area that does not show cells or cells with a transparent background.
*/
- String BACKGROUND_COLOR = "background-color";
+ public static final String BACKGROUND_COLOR = "background-color";
/**
* CSS property for the NatTable background image. This has effect on the
* area that does not show cells or cells with a transparent background.
*/
- String BACKGROUND_IMAGE = "background-image";
+ public static final String BACKGROUND_IMAGE = "background-image";
/**
* CSS property to specify the border color that is applied around the
* NatTable. Triggers the usage of the NatTableBorderOverlayPainter to apply
@@ -46,7 +47,7 @@
* the table border color.
* </p>
*/
- String TABLE_BORDER_COLOR = "table-border-color";
+ public static final String TABLE_BORDER_COLOR = "table-border-color";
/**
* CSS property for enabling/disabling the automatic painter resolution
* based on CSS properties.
@@ -54,7 +55,7 @@
* Available values: <code>true, false</code>
* </p>
*/
- String PAINTER_RESOLUTION = "painter-resolution";
+ public static final String PAINTER_RESOLUTION = "painter-resolution";
/**
* CSS property for configuring the painter.
* <p>
@@ -67,7 +68,7 @@
* .
* </p>
*/
- String PAINTER = "painter";
+ public static final String PAINTER = "painter";
/**
* CSS property for configuring the tree structure painter. Similar to
* {@link #PAINTER} but specific for the tree structure configuration as it
@@ -84,72 +85,72 @@
* evaluated dynamically.
* </p>
*/
- String TREE_STRUCTURE_PAINTER = "tree-structure-painter";
+ public static final String TREE_STRUCTURE_PAINTER = "tree-structure-painter";
/**
* CSS property for {@link CellStyleAttributes#BACKGROUND_COLOR}.
*/
- String CELL_BACKGROUND_COLOR = "cell-background-color";
+ public static final String CELL_BACKGROUND_COLOR = "cell-background-color";
/**
* CSS property for configuring a background based on an image.
*/
- String CELL_BACKGROUND_IMAGE = "cell-background-image";
+ public static final String CELL_BACKGROUND_IMAGE = "cell-background-image";
/**
* CSS property for {@link CellStyleAttributes#FOREGROUND_COLOR}.
*/
- String FOREGROUND_COLOR = "color";
+ public static final String FOREGROUND_COLOR = "color";
/**
* CSS property for {@link CellStyleAttributes#HORIZONTAL_ALIGNMENT}.
*/
- String HORIZONTAL_ALIGNMENT = "text-align";
+ public static final String HORIZONTAL_ALIGNMENT = "text-align";
/**
* CSS property for {@link CellStyleAttributes#VERTICAL_ALIGNMENT}.
*/
- String VERTICAL_ALIGNMENT = "vertical-align";
+ public static final String VERTICAL_ALIGNMENT = "vertical-align";
/**
* CSS property for {@link CellStyleAttributes#FONT}.
*/
- String FONT = "font";
+ public static final String FONT = "font";
/**
* CSS property for {@link CellStyleAttributes#FONT}.
*/
- String FONT_FAMILY = "font-family";
+ public static final String FONT_FAMILY = "font-family";
/**
* CSS property for {@link CellStyleAttributes#FONT}.
*/
- String FONT_SIZE = "font-size";
+ public static final String FONT_SIZE = "font-size";
/**
* CSS property for {@link CellStyleAttributes#FONT}.
*/
- String FONT_STYLE = "font-style";
+ public static final String FONT_STYLE = "font-style";
/**
* CSS property for {@link CellStyleAttributes#FONT}.
*/
- String FONT_WEIGHT = "font-weight";
+ public static final String FONT_WEIGHT = "font-weight";
/**
* CSS property for {@link CellStyleAttributes#IMAGE}. Triggers the usage of
* the ImagePainter.
*/
- String IMAGE = "image";
+ public static final String IMAGE = "image";
/**
* CSS property for {@link CellStyleAttributes#BORDER_STYLE}. Triggers the
* usage of the LineBorderDecorator.
*/
- String BORDER = "border";
+ public static final String BORDER = "border";
/**
* CSS property for {@link CellStyleAttributes#BORDER_STYLE}. Triggers the
* usage of the LineBorderDecorator.
*/
- String BORDER_COLOR = "border-color";
+ public static final String BORDER_COLOR = "border-color";
/**
* CSS property for {@link CellStyleAttributes#BORDER_STYLE}. Triggers the
* usage of the LineBorderDecorator.
*/
- String BORDER_STYLE = "border-style";
+ public static final String BORDER_STYLE = "border-style";
/**
* CSS property for {@link CellStyleAttributes#BORDER_STYLE}. Triggers the
* usage of the LineBorderDecorator.
*/
- String BORDER_WIDTH = "border-width";
+ public static final String BORDER_WIDTH = "border-width";
/**
* CSS property for {@link CellStyleAttributes#BORDER_STYLE}. Triggers the
* usage of the LineBorderDecorator.
@@ -159,13 +160,13 @@
*
* @since 1.1
*/
- String BORDER_MODE = "border-mode";
+ public static final String BORDER_MODE = "border-mode";
/**
* CSS property for {@link CellStyleAttributes#PASSWORD_ECHO_CHAR}. Does not
* trigger the usage of the PasswordTextPainter. This needs to be done via
* additional {@link IConfiguration} or <i>painter</i> CSS property.
*/
- String PASSWORD_ECHO_CHAR = "password-echo-char";
+ public static final String PASSWORD_ECHO_CHAR = "password-echo-char";
/**
* CSS property for {@link CellStyleAttributes#TEXT_DECORATION}.
* <p>
@@ -175,32 +176,32 @@
* Combinations are possible via space separated list.
* </p>
*/
- String TEXT_DECORATION = "text-decoration";
+ public static final String TEXT_DECORATION = "text-decoration";
/**
* CSS property for the color of the freeze separator.
*/
- String FREEZE_SEPARATOR_COLOR = "freeze-separator-color";
+ public static final String FREEZE_SEPARATOR_COLOR = "freeze-separator-color";
/**
* CSS property for the width of the freeze separator.
*
* @since 1.2
*/
- String FREEZE_SEPARATOR_WIDTH = "freeze-separator-width";
+ public static final String FREEZE_SEPARATOR_WIDTH = "freeze-separator-width";
/**
* CSS property for the color of the grid lines.
*/
- String GRID_LINE_COLOR = "grid-line-color";
+ public static final String GRID_LINE_COLOR = "grid-line-color";
/**
* CSS property for the width of the grid lines.
*/
- String GRID_LINE_WIDTH = "grid-line-width";
+ public static final String GRID_LINE_WIDTH = "grid-line-width";
/**
* CSS property to specify whether grid lines should be rendered or not.
* <p>
* Available values: <code>true, false</code>
* </p>
*/
- String RENDER_GRID_LINES = "render-grid-lines";
+ public static final String RENDER_GRID_LINES = "render-grid-lines";
/**
* CSS property to specify whether words should automatically or not.
* Default is <code>false</code>.
@@ -210,7 +211,7 @@
*
* @since 1.1
*/
- String WORD_WRAP = "word-wrap";
+ public static final String WORD_WRAP = "word-wrap";
/**
* CSS property to specify whether text should automatically wrapped between
* words or not. Default is <code>false</code>.
@@ -218,7 +219,7 @@
* Available values: <code>true, false</code>
* </p>
*/
- String TEXT_WRAP = "text-wrap";
+ public static final String TEXT_WRAP = "text-wrap";
/**
* CSS property to specify whether text should be trimmed on rendering words
* or not. Default is <code>true</code>.
@@ -226,7 +227,7 @@
* Available values: <code>true, false</code>
* </p>
*/
- String TEXT_TRIM = "text-trim";
+ public static final String TEXT_TRIM = "text-trim";
/**
* CSS property to specify whether text should be rendered horizontally or
* vertically. Default is <code>horizontal</code>.
@@ -234,7 +235,7 @@
* Available values: <code>horizontal, vertical</code>
* </p>
*/
- String TEXT_DIRECTION = "text-direction";
+ public static final String TEXT_DIRECTION = "text-direction";
/**
* CSS property to specify an additional spacing between lines in a text. By
* default this value is zero which means the line height is specified only
@@ -242,7 +243,7 @@
*
* @since 1.1
*/
- String LINE_SPACING = "line-spacing";
+ public static final String LINE_SPACING = "line-spacing";
/**
* CSS property to configure the column width. Available values are:
* <ul>
@@ -254,7 +255,7 @@
* <li>number value (e.g. 100px)- configure column width</li>
* </ul>
*/
- String COLUMN_WIDTH = "column-width";
+ public static final String COLUMN_WIDTH = "column-width";
/**
* CSS property to configure the row height. Available values are:
* <ul>
@@ -266,7 +267,7 @@
* <li>number value (e.g. 100px)- configure row height</li>
* </ul>
*/
- String ROW_HEIGHT = "row-height";
+ public static final String ROW_HEIGHT = "row-height";
/**
* CSS property to configure the display converter. Possible values are:
* <ul>
@@ -285,7 +286,7 @@
* <li>big-decimal [min-fraction-digits] [max-fraction-digits]</li>
* </ul>
*/
- String CONVERTER = "converter";
+ public static final String CONVERTER = "converter";
/**
* CSS property to configure a decoration. Consists of 4 values:
* <ul>
@@ -296,7 +297,7 @@
* <li>true|false to configure decoration dependent rendering</li>
* </ul>
*/
- String DECORATION = "decoration";
+ public static final String DECORATION = "decoration";
/**
* CSS property to configure whether default decorator icons should be
* inverted.
@@ -304,162 +305,162 @@
* Available values: <code>true, false</code>
* </p>
*/
- String INVERT_ICONS = "invert-icons";
+ public static final String INVERT_ICONS = "invert-icons";
/**
* CSS property to specify the border style of the fill region.
*/
- String FILL_REGION_BORDER = "fill-region-border";
+ public static final String FILL_REGION_BORDER = "fill-region-border";
/**
* CSS property to specify the border of the fill drag handle.
*/
- String FILL_HANDLE_BORDER = "fill-handle-border";
+ public static final String FILL_HANDLE_BORDER = "fill-handle-border";
/**
* CSS property to specify the color of the fill drag handle.
*/
- String FILL_HANDLE_COLOR = "fill-handle-color";
+ public static final String FILL_HANDLE_COLOR = "fill-handle-color";
/**
* CSS property to specify cell padding. Triggers usage of the
* PaddingDecorator if painter resolution is enabled.
*/
- String PADDING = "padding";
+ public static final String PADDING = "padding";
/**
* CSS property to specify the top padding of a cell. Triggers usage of the
* PaddingDecorator if painter resolution is enabled.
*/
- String PADDING_TOP = "padding-top";
+ public static final String PADDING_TOP = "padding-top";
/**
* CSS property to specify the right padding of a cell. Triggers usage of
* the PaddingDecorator if painter resolution is enabled.
*/
- String PADDING_RIGHT = "padding-right";
+ public static final String PADDING_RIGHT = "padding-right";
/**
* CSS property to specify the bottom padding of a cell. Triggers usage of
* the PaddingDecorator if painter resolution is enabled.
*/
- String PADDING_BOTTOM = "padding-bottom";
+ public static final String PADDING_BOTTOM = "padding-bottom";
/**
* CSS property to specify the left padding of a cell. Triggers usage of the
* PaddingDecorator if painter resolution is enabled.
*/
- String PADDING_LEFT = "padding-left";
+ public static final String PADDING_LEFT = "padding-left";
/**
* CSS property for configuring the colors to use with the
* PercentageBarDecorator.
*/
- String PERCENTAGE_DECORATOR_COLORS = "percentage-decorator-colors";
+ public static final String PERCENTAGE_DECORATOR_COLORS = "percentage-decorator-colors";
/**
* CSS property for specifying the font of a text cell editor on conversion
* error.
*/
- String CONVERSION_ERROR_FONT = "conversion-error-font";
+ public static final String CONVERSION_ERROR_FONT = "conversion-error-font";
/**
* CSS property for specifying the font family of a text cell editor on
* conversion error.
*/
- String CONVERSION_ERROR_FONT_FAMILY = "conversion-error-font-family";
+ public static final String CONVERSION_ERROR_FONT_FAMILY = "conversion-error-font-family";
/**
* CSS property for specifying the font size of a text cell editor on
* conversion error.
*/
- String CONVERSION_ERROR_FONT_SIZE = "conversion-error-font-size";
+ public static final String CONVERSION_ERROR_FONT_SIZE = "conversion-error-font-size";
/**
* CSS property for specifying the font style of a text cell editor on
* conversion error.
*/
- String CONVERSION_ERROR_FONT_STYLE = "conversion-error-font-style";
+ public static final String CONVERSION_ERROR_FONT_STYLE = "conversion-error-font-style";
/**
* CSS property for specifying the font weight of a text cell editor on
* conversion error.
*/
- String CONVERSION_ERROR_FONT_WEIGHT = "conversion-error-font-weight";
+ public static final String CONVERSION_ERROR_FONT_WEIGHT = "conversion-error-font-weight";
/**
* CSS property for specifying the background color of a text cell editor on
* conversion error.
*/
- String CONVERSION_ERROR_BACKGROUND_COLOR = "conversion-error-background-color";
+ public static final String CONVERSION_ERROR_BACKGROUND_COLOR = "conversion-error-background-color";
/**
* CSS property for specifying the foreground color of a text cell editor on
* conversion error.
*/
- String CONVERSION_ERROR_FOREGROUND_COLOR = "conversion-error-color";
+ public static final String CONVERSION_ERROR_FOREGROUND_COLOR = "conversion-error-color";
/**
* CSS property for specifying the font of a text cell editor on validation
* error.
*/
- String VALIDATION_ERROR_FONT = "validation-error-font";
+ public static final String VALIDATION_ERROR_FONT = "validation-error-font";
/**
* CSS property for specifying the font family of a text cell editor on
* validation error.
*/
- String VALIDATION_ERROR_FONT_FAMILY = "validation-error-font-family";
+ public static final String VALIDATION_ERROR_FONT_FAMILY = "validation-error-font-family";
/**
* CSS property for specifying the font size of a text cell editor on
* validation error.
*/
- String VALIDATION_ERROR_FONT_SIZE = "validation-error-font-size";
+ public static final String VALIDATION_ERROR_FONT_SIZE = "validation-error-font-size";
/**
* CSS property for specifying the font style of a text cell editor on
* validation error.
*/
- String VALIDATION_ERROR_FONT_STYLE = "validation-error-font-style";
+ public static final String VALIDATION_ERROR_FONT_STYLE = "validation-error-font-style";
/**
* CSS property for specifying the font weight of a text cell editor on
* validation error.
*/
- String VALIDATION_ERROR_FONT_WEIGHT = "validation-error-font-weight";
+ public static final String VALIDATION_ERROR_FONT_WEIGHT = "validation-error-font-weight";
/**
* CSS property for specifying the background color of a text cell editor on
* validation error.
*/
- String VALIDATION_ERROR_BACKGROUND_COLOR = "validation-error-background-color";
+ public static final String VALIDATION_ERROR_BACKGROUND_COLOR = "validation-error-background-color";
/**
* CSS property for specifying the foreground color of a text cell editor on
* validation error.
*/
- String VALIDATION_ERROR_FOREGROUND_COLOR = "validation-error-color";
+ public static final String VALIDATION_ERROR_FOREGROUND_COLOR = "validation-error-color";
/**
* CSS property for the color of the hide indicator.
*
* @since 2.0
*/
- String HIDE_INDICATOR_COLOR = "hide-indicator-color";
+ public static final String HIDE_INDICATOR_COLOR = "hide-indicator-color";
/**
* CSS property for the width of the hide indicator.
*
* @since 2.0
*/
- String HIDE_INDICATOR_WIDTH = "hide-indicator-width";
+ public static final String HIDE_INDICATOR_WIDTH = "hide-indicator-width";
// context value keys
/**
* Context value key for background painter
*/
- String CV_BACKGROUND_PAINTER = "bg-painter";
+ public static final String CV_BACKGROUND_PAINTER = "bg-painter";
/**
* Context value key for decorator painter list
*/
- String CV_DECORATOR_PAINTER = "decorator-painter";
+ public static final String CV_DECORATOR_PAINTER = "decorator-painter";
/**
* Context value key for content painter
*/
- String CV_CONTENT_PAINTER = "content-painter";
+ public static final String CV_CONTENT_PAINTER = "content-painter";
/**
* Context value key for content painter configuration values
*/
- String CV_PAINTER_CONFIGURATION = "content-painter-config";
+ public static final String CV_PAINTER_CONFIGURATION = "content-painter-config";
/**
* Context value key for border properties
*/
- String CV_BORDER_CONFIGURATION = "border-config";
+ public static final String CV_BORDER_CONFIGURATION = "border-config";
/**
* Context value key for conversion error font properties
*/
- String CV_CONVERSION_ERROR_FONT_PROPERTIES = "conversion-error-font";
+ public static final String CV_CONVERSION_ERROR_FONT_PROPERTIES = "conversion-error-font";
/**
* Context value key for validation error font properties
*/
- String CV_VALIDATION_ERROR_FONT_PROPERTIES = "validation-error-font";
+ public static final String CV_VALIDATION_ERROR_FONT_PROPERTIES = "validation-error-font";
// painter properties map key
@@ -467,35 +468,35 @@
* Painter properties key to store whether a GradientBackgroundPainter
* should sweep from top to bottom or from left to right.
*/
- String GRADIENT_BACKGROUND_VERTICAL = "gradient-background-vertical";
+ public static final String GRADIENT_BACKGROUND_VERTICAL = "gradient-background-vertical";
/**
* Painter properties key to store the decorator spacing used by the
* CellPainterDecorator.
*/
- String DECORATOR_SPACING = "decorator-spacing";
+ public static final String DECORATOR_SPACING = "decorator-spacing";
/**
* Painter properties key to store the decorator cell edge used by the
* CellPainterDecorator.
*/
- String DECORATOR_EDGE = "decorator-edge";
+ public static final String DECORATOR_EDGE = "decorator-edge";
/**
* Painter properties key to store the decorator image used by the
* CellPainterDecorator.
*/
- String DECORATOR_IMAGE = "decorator-image";
+ public static final String DECORATOR_IMAGE = "decorator-image";
/**
* Painter properties key to store the value for decorator dependent flag
* used by the CellPainterDecorator.
*/
- String PAINT_DECORATION_DEPENDENT = "decoration-dependent";
+ public static final String PAINT_DECORATION_DEPENDENT = "decoration-dependent";
/**
* Painter properties key to specify whether the cell/row height should be
* calculated dependent on the content. Default is <code>false</code>.
*/
- String CALCULATE_CELL_HEIGHT = "calculate-cell-height";
+ public static final String CALCULATE_CELL_HEIGHT = "calculate-cell-height";
/**
* Painter properties key to specify whether the cell/column width should be
* calculated dependent on the content. Default is <code>false</code>.
*/
- String CALCULATE_CELL_WIDTH = "calculate-cell-width";
+ public static final String CALCULATE_CELL_WIDTH = "calculate-cell-width";
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSHandler.java b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSHandler.java
index 7354955..2ab93f9 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSHandler.java
@@ -37,7 +37,7 @@
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
import org.eclipse.nebula.widgets.nattable.extension.e4.painterfactory.CellPainterFactory;
import org.eclipse.nebula.widgets.nattable.fillhandle.config.FillHandleConfigAttributes;
-import org.eclipse.nebula.widgets.nattable.freeze.IFreezeConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.freeze.FreezeConfigAttributes;
import org.eclipse.nebula.widgets.nattable.hideshow.indicator.HideIndicatorConfigAttributes;
import org.eclipse.nebula.widgets.nattable.painter.IOverlayPainter;
import org.eclipse.nebula.widgets.nattable.painter.NatTableBorderOverlayPainter;
@@ -100,7 +100,7 @@
if (natTable != null) {
context = engine.getCSSElementContext(control);
- Boolean resolvePainter = NatTableCSSHelper.resolvePainter(context, natTableContext, displayMode);
+ boolean resolvePainter = NatTableCSSHelper.resolvePainter(context, natTableContext, displayMode);
// check property
if (NatTableCSSConstants.PAINTER_RESOLUTION.equalsIgnoreCase(property)) {
@@ -389,14 +389,14 @@
} else if (NatTableCSSConstants.FREEZE_SEPARATOR_COLOR.equalsIgnoreCase(property)
&& (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE)) {
natTable.getConfigRegistry().registerConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_COLOR,
+ FreezeConfigAttributes.SEPARATOR_COLOR,
(Color) engine.convert(value, Color.class, natTable.getDisplay()),
displayMode,
label);
} else if (NatTableCSSConstants.FREEZE_SEPARATOR_WIDTH.equalsIgnoreCase(property)
&& (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE)) {
natTable.getConfigRegistry().registerConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_WIDTH,
+ FreezeConfigAttributes.SEPARATOR_WIDTH,
(int) ((CSSPrimitiveValue) value).getFloatValue(CSSPrimitiveValue.CSS_PT),
displayMode,
label);
@@ -1107,14 +1107,14 @@
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return cssValueConverter.convert(
natTable.getConfigRegistry().getConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_COLOR,
+ FreezeConfigAttributes.SEPARATOR_COLOR,
displayMode,
label),
engine,
null);
} else if (NatTableCSSConstants.FREEZE_SEPARATOR_WIDTH.equalsIgnoreCase(property)) {
Integer width = natTable.getConfigRegistry().getConfigAttribute(
- IFreezeConfigAttributes.SEPARATOR_WIDTH,
+ FreezeConfigAttributes.SEPARATOR_WIDTH,
displayMode,
label);
if (width == null) {
@@ -1645,7 +1645,7 @@
}
Object pv = NatTableCSSHelper.getContextValue(context, displayMode, NatTableCSSConstants.PAINTER);
- if (pv != null && pv instanceof List<?>) {
+ if (pv instanceof List<?>) {
@SuppressWarnings("unchecked")
List<String> painterValues = (List<String>) pv;
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSHelper.java b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSHelper.java
index 60c101b..184f53d 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSHelper.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableCSSHelper.java
@@ -68,7 +68,11 @@
* Helper class for converting and applying CSS styles.
*/
@SuppressWarnings("restriction")
-public class NatTableCSSHelper {
+public final class NatTableCSSHelper {
+
+ private NatTableCSSHelper() {
+ // private default constructor for helper class
+ }
private static final IDisplayModeOrdering displayModeOrdering = new DefaultDisplayModeOrdering();
@@ -293,6 +297,8 @@
* inheritance model to always retrieve a style configuration attribute if
* there is one configured at any level.
*
+ * @param <T>
+ * The type of the configuration attribute.
* @param natTable
* The NatTable whose {@link ConfigRegistry} should be checked
* for the style configuration.
@@ -318,6 +324,8 @@
* Apply a style attribute value for the {@link IStyle} registered for
* {@link CellConfigAttributes#CELL_STYLE}.
*
+ * @param <T>
+ * The type of the configuration attribute.
* @param natTable
* The NatTable to apply the style configuration to.
* @param styleConfig
@@ -344,6 +352,8 @@
* Apply a style attribute value for the {@link IStyle} registered for the
* given styleAttribute.
*
+ * @param <T>
+ * The type of the configuration attribute.
* @param natTable
* The NatTable to apply the style configuration to.
* @param styleAttribute
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableElementAdapter.java b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableElementAdapter.java
index a40599c..87295d7 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableElementAdapter.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/css/NatTableElementAdapter.java
@@ -23,16 +23,11 @@
import org.eclipse.e4.ui.css.swt.dom.WidgetElement;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -68,13 +63,7 @@
addVirtualChild(label);
}
- natTable.addDisposeListener(new DisposeListener() {
-
- @Override
- public void widgetDisposed(DisposeEvent e) {
- dispose();
- }
- });
+ natTable.addDisposeListener(e -> dispose());
// the special NatTable related update listener should only be
// registered once, there is no need to add additional listeners for
@@ -89,8 +78,7 @@
Control control = getControl();
Composite parent = control.getParent();
if (parent != null) {
- Element element = getElement(parent);
- return element;
+ return getElement(parent);
}
return null;
}
@@ -139,7 +127,7 @@
if (node instanceof NatTableWrapperElementAdapter) {
((NatTableWrapperElementAdapter) node).dispose();
- if (this.engine != null && this.engine instanceof AbstractCSSEngine) {
+ if (this.engine instanceof AbstractCSSEngine) {
try {
Method method = AbstractCSSEngine.class.getDeclaredMethod("handleWidgetDisposed", Object.class);
if (method != null) {
@@ -174,12 +162,9 @@
public NatTableSkinListener(Display display, final CSSEngine cssEngine) {
this.engine = cssEngine;
- display.addListener(SWT.Skin, new Listener() {
- @Override
- public void handleEvent(Event event) {
- if (NatTableSkinListener.this.engine != null && event.widget instanceof NatTable) {
- NatTableSkinListener.this.engine.applyStyles(event.widget, true);
- }
+ display.addListener(SWT.Skin, event -> {
+ if (NatTableSkinListener.this.engine != null && event.widget instanceof NatTable) {
+ NatTableSkinListener.this.engine.applyStyles(event.widget, true);
}
});
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/painterfactory/CellPainterFactory.java b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/painterfactory/CellPainterFactory.java
index 3a4549c..1fa0a16 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/painterfactory/CellPainterFactory.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/painterfactory/CellPainterFactory.java
@@ -93,16 +93,16 @@
/**
* Singleton instance
*/
- private static CellPainterFactory INSTANCE;
+ private static CellPainterFactory instance;
/**
* @return The singleton instance of {@link CellPainterFactory}
*/
public static CellPainterFactory getInstance() {
- if (INSTANCE == null) {
- INSTANCE = new CellPainterFactory();
+ if (instance == null) {
+ instance = new CellPainterFactory();
}
- return INSTANCE;
+ return instance;
}
/**
@@ -112,9 +112,7 @@
// default background painter initializations
this.backgroundPainter.put(
BACKGROUND_PAINTER_KEY,
- (painterProperties, underlying) -> {
- return new BackgroundPainter(underlying);
- });
+ (painterProperties, underlying) -> new BackgroundPainter(underlying));
this.backgroundPainter.put(
BACKGROUND_IMAGE_PAINTER_KEY,
(painterProperties, underlying) -> {
@@ -134,19 +132,13 @@
// default decorator painter initializations
this.decoratorPainter.put(
LINE_BORDER_DECORATOR_KEY,
- (painterProperties, underlying) -> {
- return new LineBorderDecorator(underlying);
- });
+ (painterProperties, underlying) -> new LineBorderDecorator(underlying));
this.decoratorPainter.put(
CUSTOM_LINE_BORDER_DECORATOR_KEY,
- (painterProperties, underlying) -> {
- return new CustomLineBorderDecorator(underlying);
- });
+ (painterProperties, underlying) -> new CustomLineBorderDecorator(underlying));
this.decoratorPainter.put(
BEVELED_BORDER_DECORATOR_KEY,
- (painterProperties, underlying) -> {
- return new BeveledBorderDecorator(underlying);
- });
+ (painterProperties, underlying) -> new BeveledBorderDecorator(underlying));
this.decoratorPainter.put(
PADDING_DECORATOR_KEY,
@@ -290,14 +282,10 @@
});
this.contentPainter.put(
PASSWORD_PAINTER_KEY,
- (painterProperties, underlying) -> {
- return new PasswordTextPainter(false, false);
- });
+ (painterProperties, underlying) -> new PasswordTextPainter(false, false));
this.contentPainter.put(
PERCENTAGEBAR_PAINTER_KEY,
- (painterProperties, underlying) -> {
- return new PercentageBarCellPainter();
- });
+ (painterProperties, underlying) -> new PercentageBarCellPainter());
this.contentPainter.put(
TABLE_PAINTER_KEY,
(painterProperties, underlying) -> {
@@ -363,16 +351,16 @@
ICellPainter painter = null;
// resolve content painter
- ICellPainter contentPainter = null;
+ ICellPainter cp = null;
if (isContentPainterKey(contentKey)) {
- contentPainter = getContentPainter(contentKey, painterProperties);
+ cp = getContentPainter(contentKey, painterProperties);
} else if (!NONE.equalsIgnoreCase(contentKey)) {
// fallback for unknown content painter key
- contentPainter = getContentPainter(TEXT_PAINTER_KEY, painterProperties);
+ cp = getContentPainter(TEXT_PAINTER_KEY, painterProperties);
}
// intermediate result = content painter
- painter = contentPainter;
+ painter = cp;
// resolve decorators
String decoratorKey = null;
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/fixture/ViewportLayerFixture.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/fixture/ViewportLayerFixture.java
index b6e4984..7e9d2d5 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/fixture/ViewportLayerFixture.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/fixture/ViewportLayerFixture.java
@@ -31,9 +31,6 @@
public static final IClientAreaProvider DEFAULT_CLIENT_AREA_PROVIDER = getClientAreaProvider(DEFAULT_CLIENT_AREA);
public static final Scrollable DEFAULT_SCROLLABLE = scrollable();
- /**
- * Default Xtor
- */
public ViewportLayerFixture() {
super(new DataLayerFixture());
setClientAreaProvider(getClientAreaProvider(DEFAULT_CLIENT_AREA));
@@ -45,29 +42,15 @@
doCommand(new InitializeClientAreaCommandFixture());
}
- /**
- * Xtor Fixture with all columns equal width and all rows equal height.
- */
public ViewportLayerFixture(int width, int height) {
super(new DataLayerFixture(width, height));
}
- /**
- * Xtor Fixture with all columns equal width and all rows equal height.
- *
- * @param colCount
- * total number of columns
- * @param rowCount
- * total number of rows
- */
public ViewportLayerFixture(int colCount, int rowCount, int defaultColWidth, int defaultRowHeight) {
super(new DataLayerFixture(colCount, rowCount, defaultColWidth, defaultRowHeight));
setClientAreaProvider(DEFAULT_CLIENT_AREA_PROVIDER);
}
- /**
- * Xtor Provide your own <i>clientArea</i>
- */
public ViewportLayerFixture(final Rectangle clientArea) {
super(new DataLayerFixture());
setClientAreaProvider(getClientAreaProvider(clientArea));
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/GlazedListsGridLayer.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/GlazedListsGridLayer.java
index 3b15698..223033c 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/GlazedListsGridLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/GlazedListsGridLayer.java
@@ -34,8 +34,6 @@
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
-import org.eclipse.nebula.widgets.nattable.sort.command.SortColumnCommand;
-import org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.SortedList;
@@ -61,13 +59,6 @@
this(eventList, propertyNames, propertyToLabelMap, configRegistry, true);
}
- /**
- * The underlying {@link DataLayer} created is able to handle Events raised
- * by GlazedLists and fire corresponding NatTable events.
- *
- * The {@link SortHeaderLayer} triggers sorting on the the underlying
- * SortedList when a {@link SortColumnCommand} is received.
- */
public GlazedListsGridLayer(EventList<T> eventList, String[] propertyNames,
Map<String, String> propertyToLabelMap,
IConfigRegistry configRegistry, boolean useDefaultConfiguration) {
@@ -123,11 +114,6 @@
return this.columnLabelAccumulator;
}
- @Override
- public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) {
- super.setClientAreaProvider(clientAreaProvider);
- }
-
public DataLayer getBodyDataLayer() {
return this.bodyDataLayer;
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/HideMultipleColumnsIntegrationTest.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/HideMultipleColumnsIntegrationTest.java
index 6b4d597..6be3f67 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/HideMultipleColumnsIntegrationTest.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/HideMultipleColumnsIntegrationTest.java
@@ -53,9 +53,7 @@
this.natTableFixture.addLayerListener(this.listenerFixture);
}
- /**
- * Exposing bug: http://nattable.org/jira/browse/NTBL-471
- */
+ // Exposing bug: http://nattable.org/jira/browse/NTBL-471
@Test
public void hideAllColumnsWithColumnGroupsEnabled() throws Exception {
assertEquals(37, this.bodyLayerStackFixture.getBodyDataProvider().getColumnCount());
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/SWTUtils.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/SWTUtils.java
index f486035..1e50d70 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/SWTUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists.test/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/test/integration/SWTUtils.java
@@ -106,6 +106,8 @@
/**
* Some of the tests do not run on Unix, due to issues with Xvfb. This check
* helps skipping those tests.
+ *
+ * @return true if we are running on a Unix system.
*/
public static boolean isRunningOnUnix() {
return System.getProperty("os.name").equals("Linux");
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/DetailGlazedListsEventLayer.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/DetailGlazedListsEventLayer.java
index 8bbc4fe..f02b386 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/DetailGlazedListsEventLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/DetailGlazedListsEventLayer.java
@@ -117,8 +117,8 @@
// deleted
int deleteCount = 0;
- final List<Range> deleteRanges = new ArrayList<Range>();
- final List<Range> insertRanges = new ArrayList<Range>();
+ final List<Range> deleteRanges = new ArrayList<>();
+ final List<Range> insertRanges = new ArrayList<>();
while (event.next()) {
int eventType = event.getType();
@@ -171,21 +171,11 @@
*/
private void internalFireEvents(final List<Range> deleteRanges, final List<Range> insertRanges) {
if (!deleteRanges.isEmpty()) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- fireLayerEvent(new RowDeleteEvent(getUnderlyingLayer(), deleteRanges));
- }
- });
+ Display.getDefault().syncExec(() -> fireLayerEvent(new RowDeleteEvent(getUnderlyingLayer(), deleteRanges)));
}
if (!insertRanges.isEmpty()) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- fireLayerEvent(new RowInsertEvent(getUnderlyingLayer(), insertRanges));
- }
- });
+ Display.getDefault().syncExec(() -> fireLayerEvent(new RowInsertEvent(getUnderlyingLayer(), insertRanges)));
}
}
@@ -196,7 +186,7 @@
public void propertyChange(PropertyChangeEvent event) {
// We can cast since we know that the EventList is of type T
final PropertyUpdateEvent<T> updateEvent =
- new PropertyUpdateEvent<T>(
+ new PropertyUpdateEvent<>(
this,
(T) event.getSource(),
event.getPropertyName(),
@@ -209,12 +199,7 @@
// from the SWT Display thread.
// As a property change doesn't indicate a structural change, the
// event can be fired asynchronously.
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- fireLayerEvent(updateEvent);
- }
- });
+ Display.getDefault().asyncExec(() -> fireLayerEvent(updateEvent));
}
/**
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsDataProvider.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsDataProvider.java
index 52628b7..5cdb06f 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsDataProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsDataProvider.java
@@ -18,7 +18,6 @@
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.event.ListEvent;
-import ca.odell.glazedlists.event.ListEventListener;
/**
* This class implements "last row" caching for much faster column value access
@@ -54,18 +53,15 @@
// of the current row we have cached, we update as well, inserts we
// don't need to as they are new items and the index will never be the
// same anyway.
- list.addListEventListener(new ListEventListener<T>() {
- @Override
- public void listChanged(ListEvent<T> event) {
- while (event.next()) {
- int sourceIndex = event.getIndex();
- int changeType = event.getType();
+ list.addListEventListener(event -> {
+ while (event.next()) {
+ int sourceIndex = event.getIndex();
+ int changeType = event.getType();
- if (changeType == ListEvent.DELETE
- || sourceIndex == GlazedListsDataProvider.this.lastRowIndex) {
- inputChanged();
- break;
- }
+ if (changeType == ListEvent.DELETE
+ || sourceIndex == GlazedListsDataProvider.this.lastRowIndex) {
+ inputChanged();
+ break;
}
}
});
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsEventLayer.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsEventLayer.java
index 7d18641..8cc2b4b 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsEventLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsEventLayer.java
@@ -79,21 +79,18 @@
* NatTable refresh event.
*/
protected Runnable getEventNotifier() {
- return new Runnable() {
- @Override
- public void run() {
- if (GlazedListsEventLayer.this.eventsToProcess && GlazedListsEventLayer.this.active) {
- ILayerEvent layerEvent;
- if (GlazedListsEventLayer.this.structuralChangeEventsToProcess) {
- layerEvent = new RowStructuralRefreshEvent(getUnderlyingLayer());
- } else {
- layerEvent = new VisualRefreshEvent(getUnderlyingLayer());
- }
- fireEventFromSWTDisplayThread(layerEvent);
-
- GlazedListsEventLayer.this.eventsToProcess = false;
- GlazedListsEventLayer.this.structuralChangeEventsToProcess = false;
+ return () -> {
+ if (GlazedListsEventLayer.this.eventsToProcess && GlazedListsEventLayer.this.active) {
+ ILayerEvent layerEvent;
+ if (GlazedListsEventLayer.this.structuralChangeEventsToProcess) {
+ layerEvent = new RowStructuralRefreshEvent(getUnderlyingLayer());
+ } else {
+ layerEvent = new VisualRefreshEvent(getUnderlyingLayer());
}
+ fireEventFromSWTDisplayThread(layerEvent);
+
+ GlazedListsEventLayer.this.eventsToProcess = false;
+ GlazedListsEventLayer.this.structuralChangeEventsToProcess = false;
}
};
}
@@ -117,7 +114,7 @@
@SuppressWarnings("unchecked")
public void propertyChange(PropertyChangeEvent event) {
// We can cast since we know that the EventList is of type T
- PropertyUpdateEvent<T> updateEvent = new PropertyUpdateEvent<T>(
+ PropertyUpdateEvent<T> updateEvent = new PropertyUpdateEvent<>(
this,
(T) event.getSource(),
event.getPropertyName(),
@@ -138,12 +135,7 @@
*/
protected void fireEventFromSWTDisplayThread(final ILayerEvent event) {
if (!this.testMode && Display.getCurrent() == null) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- fireLayerEvent(event);
- }
- });
+ Display.getDefault().asyncExec(() -> fireLayerEvent(event));
} else {
fireLayerEvent(event);
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsSortModel.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsSortModel.java
index 2ee7b20..8ab0d23 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsSortModel.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/GlazedListsSortModel.java
@@ -67,12 +67,12 @@
protected NatTableComparatorChooser<T> getComparatorChooser() {
if (this.comparatorChooser == null) {
- this.tableFormat = new NatColumnTableFormat<T>(
+ this.tableFormat = new NatColumnTableFormat<>(
this.columnAccessor,
this.columnPropertyResolver,
this.configRegistry,
this.columnHeaderDataLayer);
- this.comparatorChooser = new NatTableComparatorChooser<T>(
+ this.comparatorChooser = new NatTableComparatorChooser<>(
this.sortedList,
this.tableFormat);
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/NatTableComparatorChooser.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/NatTableComparatorChooser.java
index 05c528b..a21c0c5 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/NatTableComparatorChooser.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/NatTableComparatorChooser.java
@@ -61,7 +61,7 @@
private void removeSortingColumnIndex(int columnIndex) {
// Save comparators
- List<ComparatorInfo> comparatorInfos = new ArrayList<ComparatorInfo>();
+ List<ComparatorInfo> comparatorInfos = new ArrayList<>();
for (int sortingColumnIndex : getSortingColumns()) {
if (sortingColumnIndex != columnIndex) {
boolean reverse = isColumnReverse(sortingColumnIndex);
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowDeleteCommandHandler.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowDeleteCommandHandler.java
index b1399d6..48e6c1d 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowDeleteCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowDeleteCommandHandler.java
@@ -58,7 +58,7 @@
// convert the transported position to the target layer
if (command.convertToTargetLayer(targetLayer)) {
int[] positions = command.getRowPositionsArray();
- Map<Integer, T> deleted = new HashMap<Integer, T>();
+ Map<Integer, T> deleted = new HashMap<>();
this.bodyData.getReadWriteLock().writeLock().lock();
try {
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowInsertCommandHandler.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowInsertCommandHandler.java
index 9d2f974..2a32dc1 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowInsertCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowInsertCommandHandler.java
@@ -72,10 +72,8 @@
this.bodyData.getReadWriteLock().writeLock().unlock();
}
- if (event != null) {
- // fire the event to refresh
- targetLayer.fireLayerEvent(event);
- }
+ // fire the event to refresh
+ targetLayer.fireLayerEvent(event);
return true;
}
return false;
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowObjectDeleteCommandHandler.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowObjectDeleteCommandHandler.java
index afff6c8..0e06847 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowObjectDeleteCommandHandler.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/data/command/GlazedListsRowObjectDeleteCommandHandler.java
@@ -62,7 +62,7 @@
// changes via DataChangeLayer in the correct order again
int[] indexes = new int[command.getObjectsToDelete().size()];
int idx = 0;
- Map<Integer, T> deleted = new TreeMap<Integer, T>();
+ Map<Integer, T> deleted = new TreeMap<>();
this.bodyData.getReadWriteLock().writeLock().lock();
try {
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxFilterRowHeaderComposite.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxFilterRowHeaderComposite.java
index 1490c57..fb3393b 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxFilterRowHeaderComposite.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxFilterRowHeaderComposite.java
@@ -170,7 +170,7 @@
boolean useDefaultConfiguration) {
this(filterList,
- new GlazedListsFilterRowComboBoxDataProvider<T>(
+ new GlazedListsFilterRowComboBoxDataProvider<>(
bodyLayer,
baseCollection,
bodyDataColumnAccessor),
@@ -232,7 +232,7 @@
boolean useDefaultConfiguration) {
this(filterList,
- new GlazedListsFilterRowComboBoxDataProvider<T>(
+ new GlazedListsFilterRowComboBoxDataProvider<>(
bodyLayer,
baseCollection,
bodyDataColumnAccessor,
@@ -302,7 +302,7 @@
this(filterList,
matcherEditor,
- new GlazedListsFilterRowComboBoxDataProvider<T>(
+ new GlazedListsFilterRowComboBoxDataProvider<>(
bodyLayer,
baseCollection,
bodyDataColumnAccessor),
@@ -375,7 +375,7 @@
this(filterList,
matcherEditor,
- new GlazedListsFilterRowComboBoxDataProvider<T>(
+ new GlazedListsFilterRowComboBoxDataProvider<>(
bodyLayer,
baseCollection,
bodyDataColumnAccessor,
@@ -472,7 +472,7 @@
boolean useDefaultConfiguration) {
this(
- new ComboBoxGlazedListsFilterStrategy<T>(
+ new ComboBoxGlazedListsFilterStrategy<>(
comboBoxDataProvider,
filterList,
bodyDataColumnAccessor,
@@ -536,7 +536,7 @@
boolean useDefaultConfiguration) {
this(
- new ComboBoxGlazedListsFilterStrategy<T>(
+ new ComboBoxGlazedListsFilterStrategy<>(
comboBoxDataProvider,
filterList,
matcherEditor,
@@ -596,7 +596,7 @@
this.comboBoxDataProvider.addCacheUpdateListener(this);
this.filterRowDataLayer =
- new FilterRowDataLayer<T>(
+ new FilterRowDataLayer<>(
this.filterStrategy,
columnHeaderLayer,
columnHeaderDataProvider,
@@ -752,7 +752,7 @@
Map<Integer, Object> filterIndexToObjectMap =
this.filterRowDataLayer.getFilterRowDataProvider().getFilterIndexToObjectMap();
Object filterObject = filterIndexToObjectMap.get(event.getColumnIndex());
- if (filterObject != null && filterObject instanceof Collection) {
+ if (filterObject instanceof Collection) {
Collection filterCollection = (Collection) filterObject;
// if a new value was added than ensure it is also added to the
// filter
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxGlazedListsFilterStrategy.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxGlazedListsFilterStrategy.java
index 16204d6..59eb93c 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxGlazedListsFilterStrategy.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/ComboBoxGlazedListsFilterStrategy.java
@@ -134,7 +134,7 @@
// we need to create a new Map for applying a filter using the parent
// class otherwise we would remove the previous added pre-selected
// values
- Map<Integer, Object> newIndexToObjectMap = new HashMap<Integer, Object>();
+ Map<Integer, Object> newIndexToObjectMap = new HashMap<>();
newIndexToObjectMap.putAll(filterIndexToObjectMap);
// remove all complete selected
@@ -148,7 +148,7 @@
// selecting all is transported as String to support lazy
// loading of combo box values
- Collection filterCollection = (filterObject != null && filterObject instanceof Collection) ? (Collection) filterObject : null;
+ Collection filterCollection = (filterObject instanceof Collection) ? (Collection) filterObject : null;
if (filterCollection == null || filterCollection.isEmpty()) {
// for one column there are no items selected in the combo,
// therefore nothing matches
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/DefaultGlazedListsFilterStrategy.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/DefaultGlazedListsFilterStrategy.java
index c081317..848b249 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/DefaultGlazedListsFilterStrategy.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/DefaultGlazedListsFilterStrategy.java
@@ -92,7 +92,7 @@
IColumnAccessor<T> columnAccessor,
IConfigRegistry configRegistry) {
- this(filterList, new CompositeMatcherEditor<T>(), columnAccessor, configRegistry);
+ this(filterList, new CompositeMatcherEditor<>(), columnAccessor, configRegistry);
this.matcherEditor.setMode(CompositeMatcherEditor.AND);
}
@@ -157,7 +157,7 @@
}
try {
- EventList<MatcherEditor<T>> matcherEditors = new BasicEventList<MatcherEditor<T>>();
+ EventList<MatcherEditor<T>> matcherEditors = new BasicEventList<>();
for (Entry<Integer, Object> mapEntry : filterIndexToObjectMap.entrySet()) {
Integer columnIndex = mapEntry.getKey();
@@ -180,7 +180,7 @@
List<ParseResult> parseResults = FilterRowUtils.parse(filterText, textDelimiter, textMatchingMode);
- EventList<MatcherEditor<T>> stringMatcherEditors = new BasicEventList<MatcherEditor<T>>();
+ EventList<MatcherEditor<T>> stringMatcherEditors = new BasicEventList<>();
for (ParseResult parseResult : parseResults) {
try {
MatchType matchOperation = parseResult.getMatchOperation();
@@ -205,9 +205,8 @@
}
}
- if (stringMatcherEditors.size() > 0) {
- final CompositeMatcherEditor<T> stringCompositeMatcherEditor =
- new CompositeMatcherEditor<T>(stringMatcherEditors);
+ if (!stringMatcherEditors.isEmpty()) {
+ CompositeMatcherEditor<T> stringCompositeMatcherEditor = new CompositeMatcherEditor<>(stringMatcherEditors);
stringCompositeMatcherEditor.setMode(CompositeMatcherEditor.OR);
matcherEditors.add(stringCompositeMatcherEditor);
}
@@ -233,9 +232,9 @@
// Add the new matchers that are added from
// 'filterIndexToObjectMap'
- for (final MatcherEditor<T> matcherEditor : matcherEditors) {
- if (!containsMatcherEditor(this.matcherEditor.getMatcherEditors(), matcherEditor)) {
- this.matcherEditor.getMatcherEditors().add(matcherEditor);
+ for (final MatcherEditor<T> me : matcherEditors) {
+ if (!containsMatcherEditor(this.matcherEditor.getMatcherEditors(), me)) {
+ this.matcherEditor.getMatcherEditors().add(me);
changed = true;
}
}
@@ -340,7 +339,7 @@
MatchType matchOperation) {
ThresholdMatcherEditor<T, Object> thresholdMatcherEditor =
- new ThresholdMatcherEditor<T, Object>(threshold, null, comparator, columnValueProvider);
+ new ThresholdMatcherEditor<>(threshold, null, comparator, columnValueProvider);
FilterRowUtils.setMatchOperation(thresholdMatcherEditor, matchOperation);
return thresholdMatcherEditor;
@@ -355,12 +354,7 @@
* index from a row object
*/
protected FunctionList.Function<T, Object> getColumnValueProvider(final int columnIndex) {
- return new FunctionList.Function<T, Object>() {
- @Override
- public Object evaluate(T rowObject) {
- return DefaultGlazedListsFilterStrategy.this.columnAccessor.getDataValue(rowObject, columnIndex);
- }
- };
+ return rowObject -> DefaultGlazedListsFilterStrategy.this.columnAccessor.getDataValue(rowObject, columnIndex);
}
/**
@@ -383,7 +377,7 @@
TextMatchingMode textMatchingMode,
IDisplayConverter converter,
String filterText) {
- final TextMatcherEditor<T> textMatcherEditor = new TextMatcherEditor<T>(getTextFilterator(columnIndex, converter));
+ TextMatcherEditor<T> textMatcherEditor = new TextMatcherEditor<>(getTextFilterator(columnIndex, converter));
textMatcherEditor.setFilterText(new String[] { filterText });
textMatcherEditor.setMode(getGlazedListsTextMatcherEditorMode(textMatchingMode));
return textMatcherEditor;
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/DefaultGlazedListsStaticFilterStrategy.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/DefaultGlazedListsStaticFilterStrategy.java
index fbb7122..612e9bc 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/DefaultGlazedListsStaticFilterStrategy.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/DefaultGlazedListsStaticFilterStrategy.java
@@ -36,7 +36,7 @@
*/
public class DefaultGlazedListsStaticFilterStrategy<T> extends DefaultGlazedListsFilterStrategy<T> {
- protected Map<Matcher<T>, MatcherEditor<T>> staticMatcherEditor = new HashMap<Matcher<T>, MatcherEditor<T>>();
+ protected Map<Matcher<T>, MatcherEditor<T>> staticMatcherEditor = new HashMap<>();
/**
* Create a new DefaultGlazedListsStaticFilterStrategy on top of the given
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/FilterRowUtils.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/FilterRowUtils.java
index f3b33a3..78cb84f 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/FilterRowUtils.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/FilterRowUtils.java
@@ -26,11 +26,18 @@
import ca.odell.glazedlists.matchers.ThresholdMatcherEditor;
-public class FilterRowUtils {
+public final class FilterRowUtils {
- public static List<ParseResult> parse(String string, String textDelimiter,
+ private FilterRowUtils() {
+ // private default constructor for helper class
+ }
+
+ public static List<ParseResult> parse(
+ String string,
+ String textDelimiter,
TextMatchingMode textMatchingMode) {
- List<ParseResult> parseResults = new ArrayList<ParseResult>();
+
+ List<ParseResult> parseResults = new ArrayList<>();
if (textDelimiter != null) {
StringTokenizer tok = new StringTokenizer(string, textDelimiter);
@@ -44,21 +51,20 @@
return parseResults;
}
- private static void parse(String string, TextMatchingMode textMatchingMode,
+ private static void parse(
+ String string,
+ TextMatchingMode textMatchingMode,
List<ParseResult> parseResults) {
+
ParseResult parseResult;
- switch (textMatchingMode) {
- case REGULAR_EXPRESSION:
- parseResult = parseExpression(string);
- break;
- default:
- parseResult = parseLiteral(string);
+ if (textMatchingMode == TextMatchingMode.REGULAR_EXPRESSION) {
+ parseResult = parseExpression(string);
+ } else {
+ parseResult = parseLiteral(string);
}
- if (parseResult != null) {
- parseResults.add(parseResult);
- }
+ parseResults.add(parseResult);
}
/**
@@ -68,6 +74,7 @@
*
* @param string
* entered by the user in the filter row text box
+ * @return the result of the parse operation
*/
public static ParseResult parseExpression(String string) {
Scanner scanner = new Scanner(string.trim());
@@ -101,6 +108,11 @@
*
* @param <T>
* type of the row object
+ * @param thresholdMatcherEditor
+ * The {@link ThresholdMatcherEditor} on which the match
+ * operation should be applied.
+ * @param matchType
+ * The match type to apply.
*/
public static <T> void setMatchOperation(
ThresholdMatcherEditor<T, Object> thresholdMatcherEditor,
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/GlazedListsFilterRowComboBoxDataProvider.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/GlazedListsFilterRowComboBoxDataProvider.java
index 03221cb..474d2c5 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/GlazedListsFilterRowComboBoxDataProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/filterrow/GlazedListsFilterRowComboBoxDataProvider.java
@@ -119,50 +119,46 @@
public void listChanged(ListEvent<T> listChanges) {
if (!this.changeHandlingProcessing.getAndSet(true)) {
// a new row was added or a row was deleted
- SCHEDULER.schedule(new Runnable() {
+ SCHEDULER.schedule(() -> {
+ List<FilterRowComboUpdateEvent> updateEvents = new ArrayList<>();
+ getValueCacheLock().writeLock().lock();
+ try {
+ // remember the cache before updating
+ Map<Integer, List<?>> cacheBefore = new HashMap<>(getValueCache());
- @Override
- public void run() {
- List<FilterRowComboUpdateEvent> updateEvents = new ArrayList<FilterRowComboUpdateEvent>();
- getValueCacheLock().writeLock().lock();
- try {
- // remember the cache before updating
- Map<Integer, List<?>> cacheBefore = new HashMap<Integer, List<?>>(getValueCache());
+ // perform a refresh of the whole cache
+ getValueCache().clear();
- // perform a refresh of the whole cache
- getValueCache().clear();
-
- if (!GlazedListsFilterRowComboBoxDataProvider.this.lazyLoading) {
- buildValueCache();
- } else {
- // to determine the diff for the update event
- // the current values need to be collected,
- // otherwise on clear() - addAll() a full reset
- // will be triggered since there are no cached
- // values
- for (Map.Entry<Integer, List<?>> entry : cacheBefore.entrySet()) {
- getValueCache().put(entry.getKey(),
- collectValues(entry.getKey()));
- }
- }
-
- // fire events for every column that has cached data
+ if (!GlazedListsFilterRowComboBoxDataProvider.this.lazyLoading) {
+ buildValueCache();
+ } else {
+ // to determine the diff for the update event
+ // the current values need to be collected,
+ // otherwise on clear() - addAll() a full reset
+ // will be triggered since there are no cached
+ // values
for (Map.Entry<Integer, List<?>> entry : cacheBefore.entrySet()) {
- updateEvents.add(buildUpdateEvent(
- entry.getKey(),
- entry.getValue(),
- getValueCache().get(entry.getKey())));
+ getValueCache().put(entry.getKey(),
+ collectValues(entry.getKey()));
}
-
- GlazedListsFilterRowComboBoxDataProvider.this.changeHandlingProcessing.set(false);
- } finally {
- getValueCacheLock().writeLock().unlock();
}
- if (isUpdateEventsEnabled()) {
- for (FilterRowComboUpdateEvent event : updateEvents) {
- fireCacheUpdateEvent(event);
- }
+ // fire events for every column that has cached data
+ for (Map.Entry<Integer, List<?>> entry : cacheBefore.entrySet()) {
+ updateEvents.add(buildUpdateEvent(
+ entry.getKey(),
+ entry.getValue(),
+ getValueCache().get(entry.getKey())));
+ }
+
+ GlazedListsFilterRowComboBoxDataProvider.this.changeHandlingProcessing.set(false);
+ } finally {
+ getValueCacheLock().writeLock().unlock();
+ }
+
+ if (isUpdateEventsEnabled()) {
+ for (FilterRowComboUpdateEvent event : updateEvents) {
+ fireCacheUpdateEvent(event);
}
}
}, 100);
@@ -172,38 +168,30 @@
@Override
public void handleLayerEvent(final ILayerEvent event) {
// we only need to perform event handling if caching is enabled
- if (this.cachingEnabled) {
- if (event instanceof CellVisualChangeEvent) {
- SCHEDULER.schedule(new Runnable() {
+ if (this.cachingEnabled && event instanceof CellVisualChangeEvent) {
+ SCHEDULER.schedule(() -> {
+ // usually this is fired for data updates so we need to update
+ // the value cache for the updated column
+ getValueCacheLock().writeLock().lock();
+ try {
+ int column = ((CellVisualChangeEvent) event).getColumnPosition();
- @Override
- public void run() {
- // usually this is fired for data updates
- // so we need to update the value cache for the updated
- // column
- getValueCacheLock().writeLock().lock();
- try {
- int column = ((CellVisualChangeEvent) event).getColumnPosition();
+ List<?> cacheBefore = getValueCache().get(column);
- List<?> cacheBefore = getValueCache().get(column);
-
- // only update the cache in case a cache was build
- // already
- if (!GlazedListsFilterRowComboBoxDataProvider.this.lazyLoading
- || cacheBefore != null) {
- getValueCache().put(column, collectValues(column));
- }
-
- if (isUpdateEventsEnabled()) {
- // get the diff and fire the event
- fireCacheUpdateEvent(buildUpdateEvent(column, cacheBefore, getValueCache().get(column)));
- }
- } finally {
- getValueCacheLock().writeLock().unlock();
- }
+ // only update the cache in case a cache was build already
+ if (!GlazedListsFilterRowComboBoxDataProvider.this.lazyLoading
+ || cacheBefore != null) {
+ getValueCache().put(column, collectValues(column));
}
- }, 0);
- }
+
+ if (isUpdateEventsEnabled()) {
+ // get the diff and fire the event
+ fireCacheUpdateEvent(buildUpdateEvent(column, cacheBefore, getValueCache().get(column)));
+ }
+ } finally {
+ getValueCacheLock().writeLock().unlock();
+ }
+ }, 0);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DefaultGroupByThemeExtension.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DefaultGroupByThemeExtension.java
index 835dce6..d00cc52 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DefaultGroupByThemeExtension.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/DefaultGroupByThemeExtension.java
@@ -53,6 +53,8 @@
* </pre>
*
*/
+// fields are public by design to make it easy for adapters to customize a theme
+@SuppressWarnings("java:S1104")
public class DefaultGroupByThemeExtension implements IThemeExtension {
// group by header background color
@@ -717,11 +719,11 @@
* which the style configuration should be applied to.
*/
protected void configureGroupByHint(IConfigRegistry configRegistry) {
- String groupByHint = getGroupByHint();
- if (groupByHint != null && groupByHint.length() > 0) {
+ String hint = getGroupByHint();
+ if (hint != null && hint.length() > 0) {
configRegistry.registerConfigAttribute(
GroupByConfigAttributes.GROUP_BY_HINT,
- groupByHint);
+ hint);
}
IStyle hintStyle = getGroupByHintStyle();
@@ -796,11 +798,11 @@
GroupByHeaderLayer.GROUP_BY_REGION);
}
- String groupByHint = getGroupByHint();
- if (groupByHint != null && groupByHint.length() > 0) {
+ String hint = getGroupByHint();
+ if (hint != null && hint.length() > 0) {
configRegistry.unregisterConfigAttribute(
GroupByConfigAttributes.GROUP_BY_HINT,
- groupByHint);
+ hint);
}
if (!ThemeConfiguration.isStyleEmpty(getGroupByObjectStyle())) {
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByComparator.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByComparator.java
index e204ccc..8eeb0fd 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByComparator.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByComparator.java
@@ -56,7 +56,7 @@
* information whether a column is a summary column is only retrieved once
* and not calculated everytime.
*/
- protected Map<Integer, Boolean> summaryColumnCache = new HashMap<Integer, Boolean>();
+ protected Map<Integer, Boolean> summaryColumnCache = new HashMap<>();
/**
* Cache that is used to increase the performance on sorting by summary
@@ -73,8 +73,7 @@
* cleared on every structural change.
* </p>
*/
- protected Map<GroupByObject, GroupByObjectValueCache> groupByObjectComparatorCache =
- new HashMap<GroupByObject, GroupByObjectValueCache>();
+ protected Map<GroupByObject, GroupByObjectValueCache> groupByObjectComparatorCache = new HashMap<>();
/**
*
@@ -321,11 +320,7 @@
if (this.dataLayer != null) {
// check if a cache object is already there
- GroupByObjectValueCache cache = this.groupByObjectComparatorCache.get(groupBy);
- if (cache == null) {
- cache = new GroupByObjectValueCache();
- this.groupByObjectComparatorCache.put(groupBy, cache);
- }
+ GroupByObjectValueCache cache = this.groupByObjectComparatorCache.computeIfAbsent(groupBy, g -> new GroupByObjectValueCache());
// check if the cache object already contains information about the
// column
@@ -382,6 +377,6 @@
* a {@link GroupByObject}.
*/
class GroupByObjectValueCache {
- Map<Integer, Object> valueCache = new HashMap<Integer, Object>();
+ Map<Integer, Object> valueCache = new HashMap<>();
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByConfigAttributes.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByConfigAttributes.java
index e2b78b6..d815fc6 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByConfigAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByConfigAttributes.java
@@ -17,14 +17,18 @@
import org.eclipse.nebula.widgets.nattable.style.IStyle;
import org.eclipse.swt.graphics.Color;
-public interface GroupByConfigAttributes {
+public final class GroupByConfigAttributes {
+
+ private GroupByConfigAttributes() {
+ // private constructor for helper class
+ }
/**
* The configuration attribute that is used to calculate the summary for a
* column.
*/
@SuppressWarnings("rawtypes")
- ConfigAttribute<IGroupBySummaryProvider> GROUP_BY_SUMMARY_PROVIDER = new ConfigAttribute<IGroupBySummaryProvider>();
+ public static final ConfigAttribute<IGroupBySummaryProvider> GROUP_BY_SUMMARY_PROVIDER = new ConfigAttribute<>();
/**
* Configuration attribute to specify a pattern that is used to render the
@@ -36,25 +40,25 @@
* </li>
* </ul>
*/
- ConfigAttribute<String> GROUP_BY_CHILD_COUNT_PATTERN = new ConfigAttribute<String>();
+ public static final ConfigAttribute<String> GROUP_BY_CHILD_COUNT_PATTERN = new ConfigAttribute<>();
/**
* Configuration attribute to specify a hint that should be shown in case no
* grouping is applied.
*/
- ConfigAttribute<String> GROUP_BY_HINT = new ConfigAttribute<String>();
+ public static final ConfigAttribute<String> GROUP_BY_HINT = new ConfigAttribute<>();
/**
* Configuration attribute to specify the style of a group by hint. Setting
* the values for foreground, background and font is supported.
*/
- ConfigAttribute<IStyle> GROUP_BY_HINT_STYLE = new ConfigAttribute<IStyle>();
+ public static final ConfigAttribute<IStyle> GROUP_BY_HINT_STYLE = new ConfigAttribute<>();
/**
* Attribute for configuring the Color that should be used to render the
* background of the GroupByHeaderLayer. Will be interpreted by the
* GroupByHeaderPainter.
*/
- ConfigAttribute<Color> GROUP_BY_HEADER_BACKGROUND_COLOR = new ConfigAttribute<Color>();
+ public static final ConfigAttribute<Color> GROUP_BY_HEADER_BACKGROUND_COLOR = new ConfigAttribute<>();
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDataLayer.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDataLayer.java
index eb4a4f2..c565ca4 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDataLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDataLayer.java
@@ -54,7 +54,6 @@
import org.eclipse.nebula.widgets.nattable.util.CalculatedValueCache;
import org.eclipse.nebula.widgets.nattable.util.ICalculatedValueCache;
import org.eclipse.nebula.widgets.nattable.util.ICalculatedValueCacheKey;
-import org.eclipse.nebula.widgets.nattable.util.ICalculator;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
@@ -153,13 +152,7 @@
* {@link Matcher} to filter for {@link GroupByObject}s in the
* {@link TreeList}.
*/
- private Matcher<Object> groupByMatcher = new Matcher<Object>() {
-
- @Override
- public boolean matches(Object item) {
- return item instanceof GroupByObject;
- }
- };
+ private Matcher<Object> groupByMatcher = item -> item instanceof GroupByObject;
/**
* Create a new {@link GroupByDataLayer} with the given configuration that:
@@ -470,7 +463,7 @@
this.groupByColumnAccessor = new GroupByColumnAccessor(columnAccessor);
this.treeFormat = createGroupByTreeFormat(groupByModel, (IColumnAccessor<T>) this.groupByColumnAccessor);
- this.treeFormat.setComparator(new GroupByComparator<T>(groupByModel, columnAccessor, this));
+ this.treeFormat.setComparator(new GroupByComparator<>(groupByModel, columnAccessor, this));
if (expansionModel == null) {
this.groupByExpansionModel = new GroupByExpansionModel();
@@ -479,8 +472,8 @@
this.treeList = new TreeList(eventList, this.treeFormat, expansionModel);
}
- this.treeData = new GlazedListTreeData<Object>(this.treeList);
- this.treeRowModel = new GlazedListTreeRowModel<Object>(this.treeData);
+ this.treeData = new GlazedListTreeData<>(this.treeList);
+ this.treeRowModel = new GlazedListTreeRowModel<>(this.treeData);
this.configRegistry = configRegistry;
@@ -506,7 +499,7 @@
* structure.
*/
protected GroupByTreeFormat<T> createGroupByTreeFormat(GroupByModel groupByModel, IColumnAccessor<T> groupByColumnAccessor) {
- return new GroupByTreeFormat<T>(groupByModel, groupByColumnAccessor);
+ return new GroupByTreeFormat<>(groupByModel, groupByColumnAccessor);
}
/**
@@ -587,36 +580,30 @@
// Perform the update showing the busy indicator, as creating the
// groupby structure costs time. This is related to dynamically building
// a tree structure with additional objects
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
+ BusyIndicator.showWhile(Display.getDefault(), () -> {
+ GroupByDataLayer.this.eventList.getReadWriteLock().writeLock().lock();
+ try {
+ /*
+ * The workaround for the update issue suggested on the mailing
+ * list iterates over the whole list. This causes a lot of list
+ * change events, which also cost processing time. Instead we
+ * are performing a clear()-addAll() which is slightly faster.
+ */
+ EventList<T> temp = GlazedLists.eventList(GroupByDataLayer.this.eventList);
+ GroupByDataLayer.this.eventList.clear();
+ GroupByDataLayer.this.eventList.addAll(temp);
- @Override
- public void run() {
- GroupByDataLayer.this.eventList.getReadWriteLock().writeLock().lock();
- try {
- /*
- * The workaround for the update issue suggested on the
- * mailing list iterates over the whole list. This causes a
- * lot of list change events, which also cost processing
- * time. Instead we are performing a clear()-addAll() which
- * is slightly faster.
- */
- EventList<T> temp = GlazedLists.eventList(GroupByDataLayer.this.eventList);
- GroupByDataLayer.this.eventList.clear();
- GroupByDataLayer.this.eventList.addAll(temp);
-
- /*
- * Collect the created GroupByObjects and cleanup local
- * caches
- */
- if (GroupByDataLayer.this.groupByExpansionModel != null) {
- FilterList<Object> groupByObjects = new FilterList<Object>(
- GroupByDataLayer.this.treeList,
- GroupByDataLayer.this.groupByMatcher);
- GroupByDataLayer.this.groupByExpansionModel.cleanupCollapsed(groupByObjects);
- }
- } finally {
- GroupByDataLayer.this.eventList.getReadWriteLock().writeLock().unlock();
+ /*
+ * Collect the created GroupByObjects and cleanup local caches
+ */
+ if (GroupByDataLayer.this.groupByExpansionModel != null) {
+ FilterList<Object> groupByObjects = new FilterList<>(
+ GroupByDataLayer.this.treeList,
+ GroupByDataLayer.this.groupByMatcher);
+ GroupByDataLayer.this.groupByExpansionModel.cleanupCollapsed(groupByObjects);
}
+ } finally {
+ GroupByDataLayer.this.eventList.getReadWriteLock().writeLock().unlock();
}
});
}
@@ -746,12 +733,7 @@
rowPosition,
new GroupByValueCacheKey(columnPosition, rowPosition, groupByObject),
calculateInBackground,
- new ICalculator() {
- @Override
- public Object executeCalculation() {
- return summaryProvider.summarize(columnPosition, children);
- }
- });
+ () -> summaryProvider.summarize(columnPosition, children));
}
}
return super.getDataValueByPosition(columnPosition, rowPosition);
@@ -830,12 +812,12 @@
GroupByObject groupByObject = (GroupByObject) this.treeData.getDataAtIndex(i);
final List<T> children = getItemsInGroup(groupByObject);
final int col = j;
- this.valueCache.getCalculatedValue(j, i, new GroupByValueCacheKey(j, i, groupByObject), false, new ICalculator() {
- @Override
- public Object executeCalculation() {
- return summaryProvider.summarize(col, children);
- }
- });
+ this.valueCache.getCalculatedValue(
+ j,
+ i,
+ new GroupByValueCacheKey(j, i, groupByObject),
+ false,
+ () -> summaryProvider.summarize(col, children));
}
}
}
@@ -897,7 +879,7 @@
private class GroupByExpansionModel implements TreeList.ExpansionModel<Object> {
// remember collapsed states because of update workaround
- Set<Object> collapsed = new HashSet<Object>();
+ Set<Object> collapsed = new HashSet<>();
/**
* Determine the specified element's initial expand/collapse state.
@@ -949,18 +931,16 @@
* @since 1.5
*/
public List<T> getItemsInGroup(GroupByObject group) {
- List<T> elementsInGroup = this.itemsByGroup.get(group);
- if (elementsInGroup == null) {
+ return this.itemsByGroup.computeIfAbsent(group, g -> {
+
this.eventList.getReadWriteLock().readLock().lock();
try {
- FilterList<T> filterList = new FilterList<T>(this.eventList, getGroupDescriptorMatcher(group, this.columnAccessor));
- elementsInGroup = new ArrayList<T>(filterList);
- this.itemsByGroup.put(group, elementsInGroup);
+ FilterList<T> filterList = new FilterList<>(this.eventList, getGroupDescriptorMatcher(g, this.columnAccessor));
+ return new ArrayList<>(filterList);
} finally {
this.eventList.getReadWriteLock().readLock().unlock();
}
- }
- return elementsInGroup;
+ });
}
/**
@@ -977,7 +957,7 @@
* @see GroupDescriptorMatcher
*/
protected Matcher<T> getGroupDescriptorMatcher(GroupByObject group, IColumnAccessor<T> columnAccessor) {
- return new GroupDescriptorMatcher<T>(group, columnAccessor);
+ return new GroupDescriptorMatcher<>(group, columnAccessor);
}
/**
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDataLayerConfiguration.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDataLayerConfiguration.java
index 1c1d093..71c58b4 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDataLayerConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDataLayerConfiguration.java
@@ -15,8 +15,8 @@
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
-import org.eclipse.nebula.widgets.nattable.config.EditableRule;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
@@ -55,7 +55,7 @@
// changed
configRegistry.registerConfigAttribute(
EditConfigAttributes.CELL_EDITABLE_RULE,
- EditableRule.NEVER_EDITABLE,
+ IEditableRule.NEVER_EDITABLE,
DisplayMode.NORMAL,
GroupByDataLayer.GROUP_BY_OBJECT);
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDisplayConverter.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDisplayConverter.java
index a4f2e49..1a6633f 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDisplayConverter.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByDisplayConverter.java
@@ -53,8 +53,8 @@
private Object defaultSummaryValue = ISummaryProvider.DEFAULT_SUMMARY_VALUE;
- protected final Map<Integer, IDisplayConverter> wrappedConverters = new HashMap<Integer, IDisplayConverter>();
- protected final Map<Integer, IDisplayConverter> converterCache = new HashMap<Integer, IDisplayConverter>();
+ protected final Map<Integer, IDisplayConverter> wrappedConverters = new HashMap<>();
+ protected final Map<Integer, IDisplayConverter> converterCache = new HashMap<>();
protected final GroupByDataLayer<T> groupByDataLayer;
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByHeaderMenuConfiguration.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByHeaderMenuConfiguration.java
index 034da37..432761d 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByHeaderMenuConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByHeaderMenuConfiguration.java
@@ -21,7 +21,6 @@
import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
-import org.eclipse.nebula.widgets.nattable.ui.menu.IMenuItemProvider;
import org.eclipse.nebula.widgets.nattable.ui.menu.MenuItemProviders;
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
@@ -94,28 +93,25 @@
*/
protected PopupMenuBuilder createGroupByHeaderMenu(NatTable natTable) {
return new PopupMenuBuilder(natTable).withMenuItemProvider(UNGROUP_BY_MENU_ITEM_ID,
- new IMenuItemProvider() {
- @Override
- public void addMenuItem(final NatTable natTable, Menu popupMenu) {
- MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
- menuItem.setText(Messages.getLocalizedMessage("%GroupByHeaderMenuConfiguration.ungroupBy")); //$NON-NLS-1$
- menuItem.setEnabled(true);
+ (natTable1, popupMenu) -> {
+ MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
+ menuItem.setText(Messages.getLocalizedMessage("%GroupByHeaderMenuConfiguration.ungroupBy")); //$NON-NLS-1$
+ menuItem.setEnabled(true);
- menuItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- NatEventData natEventData = MenuItemProviders.getNatEventData(event);
- MouseEvent originalEvent = natEventData.getOriginalEvent();
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ NatEventData natEventData = MenuItemProviders.getNatEventData(event);
+ MouseEvent originalEvent = natEventData.getOriginalEvent();
- int groupByColumnIndex =
- GroupByHeaderMenuConfiguration.this.groupByHeaderLayer.getGroupByColumnIndexAtXY(
- originalEvent.x,
- originalEvent.y);
+ int groupByColumnIndex =
+ GroupByHeaderMenuConfiguration.this.groupByHeaderLayer.getGroupByColumnIndexAtXY(
+ originalEvent.x,
+ originalEvent.y);
- natTable.doCommand(new UngroupByColumnIndexCommand(groupByColumnIndex));
- }
- });
- }
+ natTable1.doCommand(new UngroupByColumnIndexCommand(groupByColumnIndex));
+ }
+ });
});
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByHeaderPainter.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByHeaderPainter.java
index 334e306..d7b79d3 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByHeaderPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByHeaderPainter.java
@@ -44,7 +44,7 @@
private final IDataProvider columnHeaderDataProvider;
private final ColumnHeaderLayer columnHeaderLayer;
- private List<Rectangle> groupByCellBounds = new ArrayList<Rectangle>();
+ private List<Rectangle> groupByCellBounds = new ArrayList<>();
/**
*
@@ -102,16 +102,16 @@
gc.setTextAntialias(GUIHelper.DEFAULT_TEXT_ANTIALIAS);
List<Integer> groupByColumnIndexes = this.groupByModel.getGroupByColumnIndexes();
- if (groupByColumnIndexes.size() > 0) {
+ if (!groupByColumnIndexes.isEmpty()) {
int textHeight = gc.textExtent("X").y; //$NON-NLS-1$
int x0 = bounds.x + LEFT_INDENT;
int y0 = bounds.y + bounds.height / 2 - textHeight / 2 - Y_PADDING;
- int y_height = Y_PADDING + textHeight + Y_PADDING;
+ int yHeight = Y_PADDING + textHeight + Y_PADDING;
// Draw leftmost edge
- gc.drawLine(x0, y0, x0, y0 + y_height);
+ gc.drawLine(x0, y0, x0, y0 + yHeight);
x0++;
// Draw group by columns
@@ -127,11 +127,11 @@
}
int textWidth = gc.textExtent(columnName).x;
- this.groupByCellBounds.add(new Rectangle(x0, y0, X_PADDING + textWidth + X_PADDING, y_height));
+ this.groupByCellBounds.add(new Rectangle(x0, y0, X_PADDING + textWidth + X_PADDING, yHeight));
- gc.fillRectangle(x0, y0, X_PADDING + textWidth + X_PADDING, y_height);
+ gc.fillRectangle(x0, y0, X_PADDING + textWidth + X_PADDING, yHeight);
gc.drawLine(x0, y0, x0 + X_PADDING + textWidth + X_PADDING, y0);
- gc.drawLine(x0, y0 + y_height, x0 + X_PADDING + textWidth + X_PADDING, y0 + y_height);
+ gc.drawLine(x0, y0 + yHeight, x0 + X_PADDING + textWidth + X_PADDING, y0 + yHeight);
gc.drawText(columnName, x0 + X_PADDING, y0 + Y_PADDING);
@@ -139,14 +139,14 @@
// Draw end cap
if (i < lastColumnIndex) {
- gc.fillRectangle(x0, y0, ENDCAP_WIDTH, y_height);
+ gc.fillRectangle(x0, y0, ENDCAP_WIDTH, yHeight);
gc.drawLine(x0, y0, x0 + ENDCAP_WIDTH, y0);
- gc.drawLine(x0, y0 + y_height, x0 + ENDCAP_WIDTH, y0 + y_height);
+ gc.drawLine(x0, y0 + yHeight, x0 + ENDCAP_WIDTH, y0 + yHeight);
} else {
- gc.fillPolygon(new int[] { x0, y0, x0 + ENDCAP_WIDTH, y0 + y_height / 2, x0, y0 + y_height });
+ gc.fillPolygon(new int[] { x0, y0, x0 + ENDCAP_WIDTH, y0 + yHeight / 2, x0, y0 + yHeight });
}
- gc.drawLine(x0, y0, x0 + ENDCAP_WIDTH - 1, y0 + y_height / 2);
- gc.drawLine(x0, y0 + y_height, x0 + ENDCAP_WIDTH - 1, y0 + y_height / 2);
+ gc.drawLine(x0, y0, x0 + ENDCAP_WIDTH - 1, y0 + yHeight / 2);
+ gc.drawLine(x0, y0 + yHeight, x0 + ENDCAP_WIDTH - 1, y0 + yHeight / 2);
x0 += ENDCAP_WIDTH;
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByModel.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByModel.java
index 6f031e9..4e26266 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByModel.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByModel.java
@@ -29,7 +29,7 @@
public static final String PERSISTENCE_KEY_GROUP_BY_COLUMN_INDEXES = ".groupByColumnIndexes"; //$NON-NLS-1$
- private List<Integer> groupByColumnIndexes = new ArrayList<Integer>();
+ private List<Integer> groupByColumnIndexes = new ArrayList<>();
/**
* Add the given column index to the list of column indexes that are
@@ -66,7 +66,7 @@
update();
return true;
} else {
- // unchanged;
+ // unchanged
return false;
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByTreeFormat.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByTreeFormat.java
index 4c276d1..690ecc6 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByTreeFormat.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/GroupByTreeFormat.java
@@ -72,7 +72,7 @@
public void getPath(List<Object> path, Object element) {
List<Integer> groupByColumns = this.model.getGroupByColumnIndexes();
if (!groupByColumns.isEmpty()) {
- LinkedHashMap<Integer, Object> descriptor = new LinkedHashMap<Integer, Object>();
+ LinkedHashMap<Integer, Object> descriptor = new LinkedHashMap<>();
for (int columnIndex : groupByColumns) {
// Build a unique descriptor for the group
Object columnValue = this.columnAccessor.getDataValue((T) element, columnIndex);
@@ -95,7 +95,7 @@
* @return The {@link GroupByObject} for the given value and descriptor.
*/
protected GroupByObject getGroupByObject(Object columnValue, Map<Integer, Object> descriptor) {
- return new GroupByObject(columnValue, new LinkedHashMap<Integer, Object>(descriptor));
+ return new GroupByObject(columnValue, new LinkedHashMap<>(descriptor));
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/summary/IGroupBySummaryProvider.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/summary/IGroupBySummaryProvider.java
index d461a04..e8b5318 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/summary/IGroupBySummaryProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/groupBy/summary/IGroupBySummaryProvider.java
@@ -22,6 +22,8 @@
* @param columnIndex
* The column index of the column for which the summary should be
* calculated.
+ * @param children
+ * The child objects to operate on.
* @return The calculated summary value for the column.
*/
public Object summarize(int columnIndex, List<T> children);
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hideshow/GlazedListsRowHideShowLayer.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hideshow/GlazedListsRowHideShowLayer.java
index fb1265e..7cbeace 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hideshow/GlazedListsRowHideShowLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hideshow/GlazedListsRowHideShowLayer.java
@@ -72,7 +72,7 @@
/**
* The collection of row id's that are hidden.
*/
- private final HashSet<Serializable> rowIdsToHide = new HashSet<Serializable>();
+ private final HashSet<Serializable> rowIdsToHide = new HashSet<>();
/**
* The {@link IRowIdAccessor} that is used to extract the id out of the row
@@ -359,11 +359,11 @@
@Override
public void saveState(String prefix, Properties properties) {
- if (this.rowIdsToHide.size() > 0) {
+ if (!this.rowIdsToHide.isEmpty()) {
// store the number of row id's that will be hidden
properties.setProperty(prefix
+ PERSISTENCE_KEY_HIDDEN_ROW_IDS_COUNT,
- Integer.valueOf(this.rowIdsToHide.size()).toString());
+ Integer.toString(this.rowIdsToHide.size()));
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos)) {
@@ -412,13 +412,7 @@
* The {@link Matcher} that is used to filter the rows with the
* specified id's.
*/
- private final Matcher<T> hideRowByIdMatcher = new Matcher<T>() {
- @Override
- public boolean matches(T rowObject) {
- return !GlazedListsRowHideShowLayer.this.rowIdsToHide
- .contains(GlazedListsRowHideShowLayer.this.rowIdAccessor.getRowId(rowObject));
- }
- };
+ private final Matcher<T> hideRowByIdMatcher = rowObject -> !GlazedListsRowHideShowLayer.this.rowIdsToHide.contains(GlazedListsRowHideShowLayer.this.rowIdAccessor.getRowId(rowObject));
/**
* Fire a change so the listeners can be informed about a change for the
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hierarchical/HierarchicalWrapperSortModel.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hierarchical/HierarchicalWrapperSortModel.java
index 2b2eefc..d506780 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hierarchical/HierarchicalWrapperSortModel.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hierarchical/HierarchicalWrapperSortModel.java
@@ -14,6 +14,8 @@
package org.eclipse.nebula.widgets.nattable.extension.glazedlists.hierarchical;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
@@ -48,7 +50,7 @@
private DataLayer columnHeaderDataLayer;
private ConfigRegistry configRegistry;
- private Map<Integer, SortDirectionEnum> sortingState = new LinkedHashMap<Integer, SortDirectionEnum>();
+ private Map<Integer, SortDirectionEnum> sortingState = new LinkedHashMap<>();
/**
*
@@ -83,7 +85,7 @@
@Override
public List<Integer> getSortedColumnIndexes() {
- return new ArrayList<Integer>(this.sortingState.keySet());
+ return new ArrayList<>(this.sortingState.keySet());
}
@Override
@@ -108,16 +110,7 @@
public List<Comparator> getComparatorsForColumnIndex(int columnIndex) {
SortDirectionEnum sort = this.sortingState.get(columnIndex);
// we only support one comparator per column
- if (sort == null) {
- return null;
- } else {
- List<Comparator> result = new ArrayList<Comparator>();
- result.add(getColumnComparator(columnIndex));
- return result;
- }
- // this does not compile with Java 6 but would with Java 8
- // return sort != null ? Arrays.asList(getColumnComparator(columnIndex))
- // : null;
+ return sort != null ? Arrays.asList(getColumnComparator(columnIndex)) : Collections.emptyList();
}
@Override
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hierarchical/HierarchicalWrapperTreeFormat.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hierarchical/HierarchicalWrapperTreeFormat.java
index 20af8ef..60661d2 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hierarchical/HierarchicalWrapperTreeFormat.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/hierarchical/HierarchicalWrapperTreeFormat.java
@@ -41,9 +41,9 @@
this.levels = Math.max(this.levels, property.split(HierarchicalHelper.PROPERTY_SEPARATOR_REGEX).length);
}
- this.parentMapping = new ArrayList<Map<Object, HierarchicalWrapper>>(this.levels);
+ this.parentMapping = new ArrayList<>(this.levels);
for (int i = 0; i < this.levels; i++) {
- this.parentMapping.add(new HashMap<Object, HierarchicalWrapper>());
+ this.parentMapping.add(new HashMap<>());
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/tree/GlazedListTreeData.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/tree/GlazedListTreeData.java
index 16569a4..65e19ef 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/tree/GlazedListTreeData.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/tree/GlazedListTreeData.java
@@ -82,7 +82,7 @@
}
private List<T> getNodeChildren(Node<T> treeNode) {
- List<T> children = new ArrayList<T>();
+ List<T> children = new ArrayList<>();
for (Node<T> child : treeNode.getChildren()) {
children.add(child.getElement());
children.addAll(getNodeChildren(child));
@@ -92,7 +92,7 @@
@Override
public List<T> getChildren(T object, boolean fullDepth) {
- if (fullDepth == false) {
+ if (!fullDepth) {
return getChildren(object);
}
int index = indexOf(object);
@@ -106,7 +106,7 @@
@Override
public List<T> getChildren(int index) {
if (!isValidIndex(index)) {
- return null;
+ return new ArrayList<>();
}
List<T> children = null;
@@ -114,13 +114,13 @@
Node<T> treeNode = this.treeList.getTreeNode(index);
if (treeNode != null) {
List<Node<T>> childrenNodes = treeNode.getChildren();
- children = new ArrayList<T>(childrenNodes.size());
+ children = new ArrayList<>(childrenNodes.size());
for (Node<T> node : childrenNodes) {
children.add(node.getElement());
}
}
}
- return children != null ? children : new ArrayList<T>();
+ return children != null ? children : new ArrayList<>();
}
@Override
@@ -130,7 +130,7 @@
@Override
public boolean isValidIndex(int index) {
- return (!(index < 0) && index < this.treeList.size());
+ return (index >= 0 && index < this.treeList.size());
}
/**
diff --git a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/tree/GlazedListTreeRowModel.java b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/tree/GlazedListTreeRowModel.java
index 1e2a425..bedd267 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/tree/GlazedListTreeRowModel.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.glazedlists/src/org/eclipse/nebula/widgets/nattable/extension/glazedlists/tree/GlazedListTreeRowModel.java
@@ -57,7 +57,7 @@
notifyListeners();
}
- return new ArrayList<Integer>();
+ return new ArrayList<>();
}
/**
@@ -94,7 +94,7 @@
}
notifyListeners();
- return new ArrayList<Integer>();
+ return new ArrayList<>();
}
/**
@@ -114,7 +114,7 @@
notifyListeners();
}
- return new ArrayList<Integer>();
+ return new ArrayList<>();
}
@Override
@@ -124,7 +124,7 @@
notifyListeners();
}
- return new ArrayList<Integer>();
+ return new ArrayList<>();
}
/**
@@ -164,7 +164,7 @@
public List<Integer> expandAll() {
internalExpandAll();
notifyListeners();
- return new ArrayList<Integer>();
+ return new ArrayList<>();
}
/**
@@ -213,7 +213,7 @@
public List<Integer> expandToLevel(int level) {
internalExpandToLevel(level);
notifyListeners();
- return new ArrayList<Integer>();
+ return new ArrayList<>();
}
/**
diff --git a/org.eclipse.nebula.widgets.nattable.extension.nebula/src/org/eclipse/nebula/widgets/nattable/extension/nebula/cdatetime/CDateTimeCellEditor.java b/org.eclipse.nebula.widgets.nattable.extension.nebula/src/org/eclipse/nebula/widgets/nattable/extension/nebula/cdatetime/CDateTimeCellEditor.java
index ddbe048..cbf094d 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.nebula/src/org/eclipse/nebula/widgets/nattable/extension/nebula/cdatetime/CDateTimeCellEditor.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.nebula/src/org/eclipse/nebula/widgets/nattable/extension/nebula/cdatetime/CDateTimeCellEditor.java
@@ -26,8 +26,6 @@
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
@@ -180,21 +178,17 @@
@Override
protected void addTextListener() {
super.addTextListener();
- this.text.getControl().addTraverseListener(new TraverseListener() {
-
- @Override
- public void keyTraversed(TraverseEvent event) {
- boolean committed = false;
- if (event.keyCode == SWT.TAB && event.stateMask == SWT.MOD2) {
- committed = commit(MoveDirectionEnum.LEFT);
- } else if (event.keyCode == SWT.TAB && event.stateMask == 0) {
- committed = commit(MoveDirectionEnum.RIGHT);
- } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
- close();
- }
- if (!committed) {
- event.doit = false;
- }
+ this.text.getControl().addTraverseListener(event -> {
+ boolean committed = false;
+ if (event.keyCode == SWT.TAB && event.stateMask == SWT.MOD2) {
+ committed = commit(MoveDirectionEnum.LEFT);
+ } else if (event.keyCode == SWT.TAB && event.stateMask == 0) {
+ committed = commit(MoveDirectionEnum.RIGHT);
+ } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
+ close();
+ }
+ if (!committed) {
+ event.doit = false;
}
});
}
@@ -212,7 +206,7 @@
dateControl.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent event) {
- boolean commit = (event.stateMask == SWT.MOD3) ? false : true;
+ boolean commit = (event.stateMask != SWT.MOD3);
MoveDirectionEnum move = MoveDirectionEnum.NONE;
if (CDateTimeCellEditor.this.moveSelectionOnEnter
&& CDateTimeCellEditor.this.editMode == EditModeEnum.INLINE) {
@@ -223,8 +217,9 @@
}
}
- if (commit)
+ if (commit) {
commit(move);
+ }
if (CDateTimeCellEditor.this.editMode == EditModeEnum.DIALOG) {
parent.forceFocus();
diff --git a/org.eclipse.nebula.widgets.nattable.extension.nebula/src/org/eclipse/nebula/widgets/nattable/extension/nebula/richtext/MarkupDisplayConverter.java b/org.eclipse.nebula.widgets.nattable.extension.nebula/src/org/eclipse/nebula/widgets/nattable/extension/nebula/richtext/MarkupDisplayConverter.java
index 2da846f..b440a56 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.nebula/src/org/eclipse/nebula/widgets/nattable/extension/nebula/richtext/MarkupDisplayConverter.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.nebula/src/org/eclipse/nebula/widgets/nattable/extension/nebula/richtext/MarkupDisplayConverter.java
@@ -87,10 +87,10 @@
* The String that will be added as suffix to the value.
*/
public void registerMarkup(String value, String markupPrefix, String markupSuffix) {
- MarkupValue markup = new MarkupValue();
- markup.originalValue = value;
- markup.markupValue = markupPrefix + value + markupSuffix;
- registerMarkup(value, markup);
+ MarkupValue markupValue = new MarkupValue();
+ markupValue.original = value;
+ markupValue.markup = markupPrefix + value + markupSuffix;
+ registerMarkup(value, markupValue);
}
/**
@@ -158,15 +158,15 @@
* replacement.
*/
protected class MarkupValue implements MarkupProcessor {
- String originalValue;
- String markupValue;
+ String original;
+ String markup;
/**
* @since 1.1
*/
@Override
public String applyMarkup(String input) {
- return input.replaceAll(this.originalValue, this.markupValue);
+ return input.replaceAll(this.original, this.markup);
}
/**
@@ -174,7 +174,7 @@
*/
@Override
public String removeMarkup(String input) {
- return input.replaceAll(this.markupValue, this.originalValue);
+ return input.replaceAll(this.markup, this.original);
}
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/ExcelCellStyleAttributes.java b/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/ExcelCellStyleAttributes.java
index b4867ff..6e291b2 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/ExcelCellStyleAttributes.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/ExcelCellStyleAttributes.java
@@ -33,6 +33,26 @@
}
/**
+ *
+ * @param fg
+ * The foreground color.
+ * @param bg
+ * The background color.
+ * @param fontData
+ * The font data.
+ * @param dataFormat
+ * The data format.
+ * @param hAlign
+ * The horizontal alignment.
+ * @param vAlign
+ * The vertical alignment.
+ * @param vertical
+ * Flag to indicate that text is rendered vertically.
+ * @param wrap
+ * Flag to indicate that word wrapping is enabled.
+ * @param border
+ * Flag to indicate that borders should be applied.
+ *
* @since 1.5
*/
public ExcelCellStyleAttributes(Color fg, Color bg, FontData fontData,
diff --git a/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/HSSFExcelExporter.java b/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/HSSFExcelExporter.java
index 79a00e1..2767820 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/HSSFExcelExporter.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/HSSFExcelExporter.java
@@ -26,11 +26,10 @@
public class HSSFExcelExporter extends PoiExcelExporter {
- private List<Color> colorIndex = new ArrayList<Color>();
+ private List<Color> colorIndex = new ArrayList<>();
public HSSFExcelExporter() {
- super(
- new FileOutputStreamProvider("table_export.xls", new String[] { "Excel Workbook (*.xls)" }, new String[] { "*.xls" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ super(new FileOutputStreamProvider("table_export.xls", new String[] { "Excel Workbook (*.xls)" }, new String[] { "*.xls" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public HSSFExcelExporter(IOutputStreamProvider outputStreamProvider) {
@@ -39,7 +38,7 @@
@Override
protected Workbook createWorkbook() {
- this.colorIndex = new ArrayList<Color>();
+ this.colorIndex = new ArrayList<>();
return new HSSFWorkbook();
}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/PoiExcelExporter.java b/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/PoiExcelExporter.java
index 2419818..cb4434b 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/PoiExcelExporter.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.poi/src/org/eclipse/nebula/widgets/nattable/extension/poi/PoiExcelExporter.java
@@ -96,7 +96,7 @@
protected boolean exportOnSameSheet = false;
protected int currentRow = 0;
- private Set<Integer> hiddenColumnPositions = new HashSet<Integer>();
+ private Set<Integer> hiddenColumnPositions = new HashSet<>();
public PoiExcelExporter(IOutputStreamProvider outputStreamProvider) {
this.outputStreamProvider = outputStreamProvider;
@@ -109,7 +109,7 @@
@Override
public void exportBegin(OutputStream outputStream) throws IOException {
- this.xlCellStyles = new HashMap<ExcelCellStyleAttributes, CellStyle>();
+ this.xlCellStyles = new HashMap<>();
this.xlWorkbook = createWorkbook();
// the hidden column positions are determined by inspection so
// it needs to be cleared at the beginning
@@ -225,8 +225,8 @@
CellConfigAttributes.CELL_PAINTER,
DisplayMode.NORMAL,
cell.getConfigLabels());
- boolean vertical = this.applyVerticalTextConfiguration ? isVertical(cellPainter) : false;
- boolean wrap = this.applyTextWrapping ? wrapText(cellPainter) : false;
+ boolean vertical = this.applyVerticalTextConfiguration && isVertical(cellPainter);
+ boolean wrap = this.applyTextWrapping && wrapText(cellPainter);
CellStyle xlCellStyle = getExcelCellStyle(fg, bg, fontData, dataFormat, hAlign, vAlign, vertical, wrap, this.applyCellBorders);
xlCell.setCellStyle(xlCellStyle);