Bug 469535 - Replace system outputs with logger
Change-Id: Ib96d8f7925aefa35283fdf54c5f4debce582ba20
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/NatTable.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/NatTable.java
index e8bc943..ecec779 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/NatTable.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/NatTable.java
@@ -17,6 +17,8 @@
import java.util.List;
import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand;
import org.eclipse.nebula.widgets.nattable.command.ILayerCommand;
import org.eclipse.nebula.widgets.nattable.command.ILayerCommandHandler;
@@ -55,6 +57,7 @@
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
import org.eclipse.nebula.widgets.nattable.selection.event.ISelectionEvent;
+import org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent;
import org.eclipse.nebula.widgets.nattable.style.theme.ThemeConfiguration;
import org.eclipse.nebula.widgets.nattable.style.theme.ThemeManager;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
@@ -89,8 +92,9 @@
//this warning suppression is because of the ActiveCellEditorRegistry usage to ensure backwards compatibility
@SuppressWarnings("deprecation")
-public class NatTable extends Canvas implements ILayer, PaintListener,
- IClientAreaProvider, ILayerListener, IPersistable {
+public class NatTable extends Canvas implements ILayer, PaintListener, IClientAreaProvider, ILayerListener, IPersistable {
+
+ private static final Log log = LogFactory.getLog(NatTable.class);
public static final int DEFAULT_STYLE_OPTIONS = SWT.NO_BACKGROUND
| SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED | SWT.V_SCROLL
@@ -638,7 +642,7 @@
try {
notifyListeners(SWT.Selection, e);
} catch (RuntimeException re) {
- re.printStackTrace();
+ log.error("Error on SWT selection processing", re); //$NON-NLS-1$
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/ColumnCategoriesLabelProvider.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/ColumnCategoriesLabelProvider.java
index 7c7a9ac..78441ab 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/ColumnCategoriesLabelProvider.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/columnCategories/gui/ColumnCategoriesLabelProvider.java
@@ -12,6 +12,8 @@
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.nebula.widgets.nattable.Messages;
import org.eclipse.nebula.widgets.nattable.columnCategories.Node;
@@ -21,6 +23,8 @@
public class ColumnCategoriesLabelProvider extends LabelProvider {
+ private static final Log log = LogFactory.getLog(ColumnCategoriesLabelProvider.class);
+
List<ColumnEntry> hiddenEntries;
public ColumnCategoriesLabelProvider(List<ColumnEntry> hiddenEntries) {
@@ -35,13 +39,11 @@
return node.getData();
case COLUMN:
int index = Integer.parseInt(node.getData());
- ColumnEntry columnEntry = ColumnChooserUtils.find(
- this.hiddenEntries, index);
+ ColumnEntry columnEntry = ColumnChooserUtils.find(this.hiddenEntries, index);
if (ObjectUtils.isNull(columnEntry)) {
- System.err
- .println("Column index " + index + " is present " + //$NON-NLS-1$ //$NON-NLS-2$
- "in the Column Categories model, " + //$NON-NLS-1$
- "but not in the underlying data"); //$NON-NLS-1$
+ log.error("Column index " + index + " is present " + //$NON-NLS-1$ //$NON-NLS-2$
+ "in the Column Categories model, " + //$NON-NLS-1$
+ "but not in the underlying data"); //$NON-NLS-1$
return String.valueOf(index);
}
return columnEntry.getLabel();
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 cafbb5e..f81b092 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
@@ -14,12 +14,16 @@
import java.util.Properties;
import java.util.TreeMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer;
import org.eclipse.nebula.widgets.nattable.persistence.IPersistable;
import org.eclipse.nebula.widgets.nattable.util.PersistenceUtils;
public class RenameColumnHelper implements IPersistable {
+ private static final Log log = LogFactory.getLog(RenameColumnHelper.class);
+
public static final String PERSISTENCE_KEY_RENAMED_COLUMN_HEADERS = ".renamedColumnHeaders"; //$NON-NLS-1$
private final ColumnHeaderLayer columnHeaderLayer;
@@ -38,8 +42,7 @@
* @return <code>true</code> if the column at the given position was
* successfully changed.
*/
- public boolean renameColumnPosition(int columnPosition,
- String customColumnName) {
+ public boolean renameColumnPosition(int columnPosition, String customColumnName) {
int index = this.columnHeaderLayer.getColumnIndexByPosition(columnPosition);
return renameColumnIndex(index, customColumnName);
}
@@ -82,8 +85,8 @@
try {
this.renamedColumnsLabelsByIndex = PersistenceUtils.parseString(property);
} catch (Exception e) {
- System.err.println("Error while restoring renamed column headers: " + e.getMessage()); //$NON-NLS-1$
- System.err.println("Skipping restore."); //$NON-NLS-1$
+ log.error("Error while restoring renamed column headers: " + e.getMessage()); //$NON-NLS-1$
+ log.error("Skipping restore."); //$NON-NLS-1$
this.renamedColumnsLabelsByIndex.clear();
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/ExtendedReflectiveColumnPropertyAccessor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/ExtendedReflectiveColumnPropertyAccessor.java
index 934104a..0182aa2 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/ExtendedReflectiveColumnPropertyAccessor.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/data/ExtendedReflectiveColumnPropertyAccessor.java
@@ -12,8 +12,12 @@
import java.lang.reflect.Method;
-public class ExtendedReflectiveColumnPropertyAccessor<R> extends
- ReflectiveColumnPropertyAccessor<R> {
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ExtendedReflectiveColumnPropertyAccessor<R> extends ReflectiveColumnPropertyAccessor<R> {
+
+ private static final Log log = LogFactory.getLog(ExtendedReflectiveColumnPropertyAccessor.class);
/**
* @param propertyNames
@@ -77,11 +81,11 @@
getterMethod = objectClass.getMethod(getterName);
child = getterMethod.invoke(child);
} catch (Exception e1) {
- e.printStackTrace();
+ log.error("Error on reflective accessing the data model", e1); //$NON-NLS-1$
throw new RuntimeException(e);
}
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Error on reflective accessing the data model", e); //$NON-NLS-1$
throw new RuntimeException(e);
}
@@ -110,8 +114,7 @@
* @param value
* the value to set
*/
- private void setPropertyValue(Object object, String propertyName,
- Object value) {
+ private void setPropertyValue(Object object, String propertyName, Object value) {
assert object != null : "object can not be null!"; //$NON-NLS-1$
try {
@@ -121,8 +124,7 @@
singlePropertyObject = getPropertyValue(
object,
propertyName.substring(0, propertyName.lastIndexOf("."))); //$NON-NLS-1$
- singlePropertyName = propertyName.substring(propertyName
- .lastIndexOf(".") + 1); //$NON-NLS-1$
+ singlePropertyName = propertyName.substring(propertyName.lastIndexOf(".") + 1); //$NON-NLS-1$
} else {
singlePropertyObject = object;
singlePropertyName = propertyName;
@@ -137,8 +139,7 @@
setterName, new Class<?>[] { value.getClass() });
} else {
// as the value is null we can not access the setter method
- // directly
- // and have to search for the method
+ // directly and have to search for the method
Method[] methods = singlePropertyObject.getClass().getMethods();
for (Method m : methods) {
if (m.getName().equals(setterName)) {
@@ -148,7 +149,7 @@
}
setterMethod.invoke(singlePropertyObject, value);
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Error on reflective accessing the data model", e); //$NON-NLS-1$
throw new RuntimeException(e);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/export/NatExporter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/export/NatExporter.java
index ebab846..9276c93 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/export/NatExporter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/export/NatExporter.java
@@ -15,6 +15,8 @@
import java.io.OutputStream;
import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.eclipse.nebula.widgets.nattable.Messages;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
@@ -36,6 +38,8 @@
public class NatExporter {
+ private static final Log log = LogFactory.getLog(NatExporter.class);
+
private final Shell shell;
public NatExporter(Shell shell) {
@@ -80,7 +84,7 @@
try {
outputStream.close();
} catch (IOException e) {
- e.printStackTrace(System.err);
+ log.error("Failed to close the output stream", e); //$NON-NLS-1$
}
}
@@ -135,7 +139,7 @@
try {
outputStream.close();
} catch (IOException e) {
- e.printStackTrace(System.err);
+ log.error("Failed to close the output stream", e); //$NON-NLS-1$
}
}
@@ -234,7 +238,7 @@
exporter.exportLayerEnd(outputStream, layerName);
} catch (Exception e) {
- e.printStackTrace(System.err);
+ log.error("Export failed", e); //$NON-NLS-1$
} finally {
// These must be fired at the end of the thread execution
layer.setClientAreaProvider(originalClientAreaProvider);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/NatLayerPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/NatLayerPainter.java
index 218d5fb..6a0fb80 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/NatLayerPainter.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/painter/layer/NatLayerPainter.java
@@ -10,6 +10,8 @@
******************************************************************************/
package org.eclipse.nebula.widgets.nattable.painter.layer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
@@ -28,6 +30,8 @@
*/
public class NatLayerPainter implements ILayerPainter {
+ private static final Log log = LogFactory.getLog(NatLayerPainter.class);
+
private final NatTable natTable;
public NatLayerPainter(NatTable natTable) {
@@ -35,47 +39,48 @@
}
@Override
- public void paintLayer(ILayer natLayer, GC gc, int xOffset, int yOffset,
- Rectangle rectangle, IConfigRegistry configRegistry) {
+ public void paintLayer(
+ ILayer natLayer, GC gc,
+ int xOffset, int yOffset, Rectangle rectangle,
+ IConfigRegistry configRegistry) {
+
try {
- paintBackground(natLayer, gc, xOffset, yOffset, rectangle,
- configRegistry);
+ paintBackground(natLayer, gc, xOffset, yOffset, rectangle, configRegistry);
gc.setForeground(this.natTable.getForeground());
ILayerPainter layerPainter = this.natTable.getLayer().getLayerPainter();
- layerPainter.paintLayer(natLayer, gc, xOffset, yOffset, rectangle,
- configRegistry);
+ layerPainter.paintLayer(natLayer, gc, xOffset, yOffset, rectangle, configRegistry);
- paintOverlays(natLayer, gc, xOffset, yOffset, rectangle,
- configRegistry);
+ paintOverlays(natLayer, gc, xOffset, yOffset, rectangle, configRegistry);
} catch (Exception e) {
- e.printStackTrace(System.err);
- System.err.println("Error while painting table: " + e.getMessage()); //$NON-NLS-1$
+ log.error("Error while painting table", e); //$NON-NLS-1$
}
}
- protected void paintBackground(ILayer natLayer, GC gc, int xOffset,
- int yOffset, Rectangle rectangle, IConfigRegistry configRegistry) {
+ protected void paintBackground(ILayer natLayer, GC gc,
+ int xOffset, int yOffset, Rectangle rectangle,
+ IConfigRegistry configRegistry) {
+
gc.setBackground(this.natTable.getBackground());
// Clean Background
gc.fillRectangle(rectangle);
}
- protected void paintOverlays(ILayer natLayer, GC gc, int xOffset,
- int yOffset, Rectangle rectangle, IConfigRegistry configRegistry) {
+ protected void paintOverlays(ILayer natLayer, GC gc,
+ int xOffset, int yOffset, Rectangle rectangle,
+ IConfigRegistry configRegistry) {
+
for (IOverlayPainter overlayPainter : this.natTable.getOverlayPainters()) {
overlayPainter.paintOverlay(gc, this.natTable);
}
}
@Override
- public Rectangle adjustCellBounds(int columnPosition, int rowPosition,
- Rectangle cellBounds) {
+ public Rectangle adjustCellBounds(int columnPosition, int rowPosition, Rectangle cellBounds) {
ILayerPainter layerPainter = this.natTable.getLayer().getLayerPainter();
- return layerPainter.adjustCellBounds(columnPosition, rowPosition,
- cellBounds);
+ return layerPainter.adjustCellBounds(columnPosition, rowPosition, cellBounds);
}
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/ColumnReorderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/ColumnReorderLayer.java
index abca62b..59f2a91 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/ColumnReorderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/ColumnReorderLayer.java
@@ -19,6 +19,8 @@
import java.util.Properties;
import java.util.StringTokenizer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionUtil;
import org.eclipse.nebula.widgets.nattable.coordinate.Range;
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform;
@@ -43,8 +45,9 @@
*
* @see DefaultColumnReorderLayerConfiguration
*/
-public class ColumnReorderLayer extends AbstractLayerTransform implements
- IUniqueIndexLayer {
+public class ColumnReorderLayer extends AbstractLayerTransform implements IUniqueIndexLayer {
+
+ private static final Log log = LogFactory.getLog(ColumnReorderLayer.class);
public static final String PERSISTENCE_KEY_COLUMN_INDEX_ORDER = ".columnIndexOrder"; //$NON-NLS-1$
@@ -80,8 +83,7 @@
if (event instanceof IStructuralChangeEvent) {
IStructuralChangeEvent structuralChangeEvent = (IStructuralChangeEvent) event;
if (structuralChangeEvent.isHorizontalStructureChanged()) {
- Collection<StructuralDiff> structuralDiffs = structuralChangeEvent
- .getColumnDiffs();
+ Collection<StructuralDiff> structuralDiffs = structuralChangeEvent.getColumnDiffs();
if (structuralDiffs == null) {
// Assume everything changed
this.columnIndexOrder.clear();
@@ -89,11 +91,9 @@
} else {
// only react on ADD or DELETE and not on CHANGE
StructuralChangeEventHelper.handleColumnDelete(
- structuralDiffs, this.underlyingLayer,
- this.columnIndexOrder, true);
+ structuralDiffs, this.underlyingLayer, this.columnIndexOrder, true);
StructuralChangeEventHelper.handleColumnInsert(
- structuralDiffs, this.underlyingLayer,
- this.columnIndexOrder, true);
+ structuralDiffs, this.underlyingLayer, this.columnIndexOrder, true);
}
invalidateCache();
}
@@ -122,16 +122,14 @@
strBuilder.append(index);
strBuilder.append(',');
}
- properties.setProperty(prefix + PERSISTENCE_KEY_COLUMN_INDEX_ORDER,
- strBuilder.toString());
+ properties.setProperty(prefix + PERSISTENCE_KEY_COLUMN_INDEX_ORDER, strBuilder.toString());
}
}
@Override
public void loadState(String prefix, Properties properties) {
super.loadState(prefix, properties);
- String property = properties.getProperty(prefix
- + PERSISTENCE_KEY_COLUMN_INDEX_ORDER);
+ String property = properties.getProperty(prefix + PERSISTENCE_KEY_COLUMN_INDEX_ORDER);
if (property != null) {
List<Integer> newColumnIndexOrder = new ArrayList<Integer>();
@@ -159,19 +157,17 @@
*/
protected boolean isRestoredStateValid(List<Integer> newColumnIndexOrder) {
if (newColumnIndexOrder.size() != getColumnCount()) {
- System.err
- .println("Number of persisted columns (" + newColumnIndexOrder.size() + ") " + //$NON-NLS-1$ //$NON-NLS-2$
- "is not the same as the number of columns in the data source (" //$NON-NLS-1$
- + getColumnCount() + ").\n" + //$NON-NLS-1$
- "Skipping restore of column ordering"); //$NON-NLS-1$
+ log.error("Number of persisted columns (" + newColumnIndexOrder.size() + ") " + //$NON-NLS-1$ //$NON-NLS-2$
+ "is not the same as the number of columns in the data source (" //$NON-NLS-1$
+ + getColumnCount() + ").\n" + //$NON-NLS-1$
+ "Skipping restore of column ordering"); //$NON-NLS-1$
return false;
}
for (Integer index : newColumnIndexOrder) {
if (!this.columnIndexOrder.contains(index)) {
- System.err
- .println("Column index: " + index + " being restored, is not a available in the data soure.\n" + //$NON-NLS-1$ //$NON-NLS-2$
- "Skipping restore of column ordering"); //$NON-NLS-1$
+ log.error("Column index: " + index + " being restored, is not a available in the data soure.\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ "Skipping restore of column ordering"); //$NON-NLS-1$
return false;
}
}
@@ -206,25 +202,18 @@
}
@Override
- public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer,
- int underlyingColumnPosition) {
- int columnIndex = this.underlyingLayer
- .getColumnIndexByPosition(underlyingColumnPosition);
+ public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) {
+ int columnIndex = this.underlyingLayer.getColumnIndexByPosition(underlyingColumnPosition);
return getColumnPositionByIndex(columnIndex);
}
@Override
- public Collection<Range> underlyingToLocalColumnPositions(
- ILayer sourceUnderlyingLayer,
- Collection<Range> underlyingColumnPositionRanges) {
+ public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) {
List<Integer> reorderedColumnPositions = new ArrayList<Integer>();
for (Range underlyingColumnPositionRange : underlyingColumnPositionRanges) {
for (int underlyingColumnPosition = underlyingColumnPositionRange.start; underlyingColumnPosition < underlyingColumnPositionRange.end; underlyingColumnPosition++) {
- int localColumnPosition = underlyingToLocalColumnPosition(
- sourceUnderlyingLayer,
- underlyingColumnPositionRange.start);
- reorderedColumnPositions.add(Integer
- .valueOf(localColumnPosition));
+ int localColumnPosition = underlyingToLocalColumnPosition(sourceUnderlyingLayer, underlyingColumnPositionRange.start);
+ reorderedColumnPositions.add(Integer.valueOf(localColumnPosition));
}
}
Collections.sort(reorderedColumnPositions);
@@ -241,29 +230,24 @@
@Override
public int getStartXOfColumnPosition(int targetColumnPosition) {
- Integer cachedStartX = this.startXCache.get(Integer
- .valueOf(targetColumnPosition));
+ Integer cachedStartX = this.startXCache.get(Integer.valueOf(targetColumnPosition));
if (cachedStartX != null) {
return cachedStartX.intValue();
}
int aggregateWidth = 0;
for (int columnPosition = 0; columnPosition < targetColumnPosition; columnPosition++) {
- aggregateWidth += this.underlyingLayer
- .getColumnWidthByPosition(localToUnderlyingColumnPosition(columnPosition));
+ aggregateWidth += this.underlyingLayer.getColumnWidthByPosition(localToUnderlyingColumnPosition(columnPosition));
}
- this.startXCache.put(Integer.valueOf(targetColumnPosition),
- Integer.valueOf(aggregateWidth));
+ this.startXCache.put(Integer.valueOf(targetColumnPosition), Integer.valueOf(aggregateWidth));
return aggregateWidth;
}
private void populateIndexOrder() {
ILayer underlyingLayer = getUnderlyingLayer();
- for (int columnPosition = 0; columnPosition < underlyingLayer
- .getColumnCount(); columnPosition++) {
- this.columnIndexOrder.add(Integer.valueOf(underlyingLayer
- .getColumnIndexByPosition(columnPosition)));
+ for (int columnPosition = 0; columnPosition < underlyingLayer.getColumnCount(); columnPosition++) {
+ this.columnIndexOrder.add(Integer.valueOf(underlyingLayer.getColumnIndexByPosition(columnPosition)));
}
}
@@ -284,8 +268,7 @@
* @param toColumnPosition
* position to move the column to
*/
- private void moveColumn(int fromColumnPosition, int toColumnPosition,
- boolean reorderToLeftEdge) {
+ private void moveColumn(int fromColumnPosition, int toColumnPosition, boolean reorderToLeftEdge) {
if (!reorderToLeftEdge) {
toColumnPosition++;
}
@@ -293,13 +276,11 @@
Integer fromColumnIndex = this.columnIndexOrder.get(fromColumnPosition);
this.columnIndexOrder.add(toColumnPosition, fromColumnIndex);
- this.columnIndexOrder.remove(fromColumnPosition
- + (fromColumnPosition > toColumnPosition ? 1 : 0));
+ this.columnIndexOrder.remove(fromColumnPosition + (fromColumnPosition > toColumnPosition ? 1 : 0));
invalidateCache();
}
- public void reorderColumnPosition(int fromColumnPosition,
- int toColumnPosition) {
+ public void reorderColumnPosition(int fromColumnPosition, int toColumnPosition) {
boolean reorderToLeftEdge;
if (toColumnPosition < getColumnCount()) {
reorderToLeftEdge = true;
@@ -307,19 +288,15 @@
reorderToLeftEdge = false;
toColumnPosition--;
}
- reorderColumnPosition(fromColumnPosition, toColumnPosition,
- reorderToLeftEdge);
+ reorderColumnPosition(fromColumnPosition, toColumnPosition, reorderToLeftEdge);
}
- public void reorderColumnPosition(int fromColumnPosition,
- int toColumnPosition, boolean reorderToLeftEdge) {
+ public void reorderColumnPosition(int fromColumnPosition, int toColumnPosition, boolean reorderToLeftEdge) {
moveColumn(fromColumnPosition, toColumnPosition, reorderToLeftEdge);
- fireLayerEvent(new ColumnReorderEvent(this, fromColumnPosition,
- toColumnPosition, reorderToLeftEdge));
+ fireLayerEvent(new ColumnReorderEvent(this, fromColumnPosition, toColumnPosition, reorderToLeftEdge));
}
- public void reorderMultipleColumnPositions(
- List<Integer> fromColumnPositions, int toColumnPosition) {
+ public void reorderMultipleColumnPositions(List<Integer> fromColumnPositions, int toColumnPosition) {
boolean reorderToLeftEdge;
if (toColumnPosition < getColumnCount()) {
reorderToLeftEdge = true;
@@ -327,42 +304,33 @@
reorderToLeftEdge = false;
toColumnPosition--;
}
- reorderMultipleColumnPositions(fromColumnPositions, toColumnPosition,
- reorderToLeftEdge);
+ reorderMultipleColumnPositions(fromColumnPositions, toColumnPosition, reorderToLeftEdge);
}
- public void reorderMultipleColumnPositions(
- List<Integer> fromColumnPositions, int toColumnPosition,
- boolean reorderToLeftEdge) {
+ public void reorderMultipleColumnPositions(List<Integer> fromColumnPositions, int toColumnPosition, boolean reorderToLeftEdge) {
// Moving from left to right
final int fromColumnPositionsCount = fromColumnPositions.size();
- if (toColumnPosition > fromColumnPositions.get(
- fromColumnPositionsCount - 1).intValue()) {
+ if (toColumnPosition > fromColumnPositions.get(fromColumnPositionsCount - 1)) {
int firstColumnPosition = fromColumnPositions.get(0).intValue();
for (int columnCount = 0; columnCount < fromColumnPositionsCount; columnCount++) {
- final int fromColumnPosition = fromColumnPositions.get(0)
- .intValue();
- moveColumn(fromColumnPosition, toColumnPosition,
- reorderToLeftEdge);
+ final int fromColumnPosition = fromColumnPositions.get(0);
+ moveColumn(fromColumnPosition, toColumnPosition, reorderToLeftEdge);
if (fromColumnPosition < firstColumnPosition) {
firstColumnPosition = fromColumnPosition;
}
}
- } else if (toColumnPosition < fromColumnPositions.get(
- fromColumnPositionsCount - 1).intValue()) {
+ } else if (toColumnPosition < fromColumnPositions.get(fromColumnPositionsCount - 1).intValue()) {
// Moving from right to left
int targetColumnPosition = toColumnPosition;
for (Integer fromColumnPosition : fromColumnPositions) {
final int fromColumnPositionInt = fromColumnPosition.intValue();
- moveColumn(fromColumnPositionInt, targetColumnPosition++,
- reorderToLeftEdge);
+ moveColumn(fromColumnPositionInt, targetColumnPosition++, reorderToLeftEdge);
}
}
- fireLayerEvent(new ColumnReorderEvent(this, fromColumnPositions,
- toColumnPosition, reorderToLeftEdge));
+ fireLayerEvent(new ColumnReorderEvent(this, fromColumnPositions, toColumnPosition, reorderToLeftEdge));
}
private void invalidateCache() {
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/RowReorderLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/RowReorderLayer.java
index f226122..b2d74c0 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/RowReorderLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/reorder/RowReorderLayer.java
@@ -19,6 +19,8 @@
import java.util.Properties;
import java.util.StringTokenizer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionUtil;
import org.eclipse.nebula.widgets.nattable.coordinate.Range;
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform;
@@ -44,8 +46,9 @@
*
* @see DefaultRowReorderLayerConfiguration
*/
-public class RowReorderLayer extends AbstractLayerTransform implements
- IUniqueIndexLayer {
+public class RowReorderLayer extends AbstractLayerTransform implements IUniqueIndexLayer {
+
+ private static final Log log = LogFactory.getLog(RowReorderLayer.class);
public static final String PERSISTENCE_KEY_ROW_INDEX_ORDER = ".rowIndexOrder"; //$NON-NLS-1$
@@ -73,8 +76,7 @@
this(underlyingLayer, true);
}
- public RowReorderLayer(IUniqueIndexLayer underlyingLayer,
- boolean useDefaultConfiguration) {
+ public RowReorderLayer(IUniqueIndexLayer underlyingLayer, boolean useDefaultConfiguration) {
super(underlyingLayer);
this.underlyingLayer = underlyingLayer;
@@ -92,20 +94,15 @@
if (event instanceof IStructuralChangeEvent) {
IStructuralChangeEvent structuralChangeEvent = (IStructuralChangeEvent) event;
if (structuralChangeEvent.isVerticalStructureChanged()) {
- Collection<StructuralDiff> structuralDiffs = structuralChangeEvent
- .getRowDiffs();
+ Collection<StructuralDiff> structuralDiffs = structuralChangeEvent.getRowDiffs();
if (structuralDiffs == null) {
// Assume everything changed
this.rowIndexOrder.clear();
populateIndexOrder();
} else {
// only react on ADD or DELETE and not on CHANGE
- StructuralChangeEventHelper.handleRowDelete(
- structuralDiffs, this.underlyingLayer,
- this.rowIndexOrder, true);
- StructuralChangeEventHelper.handleRowInsert(
- structuralDiffs, this.underlyingLayer,
- this.rowIndexOrder, true);
+ StructuralChangeEventHelper.handleRowDelete(structuralDiffs, this.underlyingLayer, this.rowIndexOrder, true);
+ StructuralChangeEventHelper.handleRowInsert(structuralDiffs, this.underlyingLayer, this.rowIndexOrder, true);
}
invalidateCache();
}
@@ -134,21 +131,18 @@
strBuilder.append(index);
strBuilder.append(IPersistable.VALUE_SEPARATOR);
}
- properties.setProperty(prefix + PERSISTENCE_KEY_ROW_INDEX_ORDER,
- strBuilder.toString());
+ properties.setProperty(prefix + PERSISTENCE_KEY_ROW_INDEX_ORDER, strBuilder.toString());
}
}
@Override
public void loadState(String prefix, Properties properties) {
super.loadState(prefix, properties);
- String property = properties.getProperty(prefix
- + PERSISTENCE_KEY_ROW_INDEX_ORDER);
+ String property = properties.getProperty(prefix + PERSISTENCE_KEY_ROW_INDEX_ORDER);
if (property != null) {
List<Integer> newRowIndexOrder = new ArrayList<Integer>();
- StringTokenizer tok = new StringTokenizer(property,
- IPersistable.VALUE_SEPARATOR);
+ StringTokenizer tok = new StringTokenizer(property, IPersistable.VALUE_SEPARATOR);
while (tok.hasMoreTokens()) {
String index = tok.nextToken();
newRowIndexOrder.add(Integer.valueOf(index));
@@ -172,19 +166,17 @@
*/
protected boolean isRestoredStateValid(List<Integer> newRowIndexOrder) {
if (newRowIndexOrder.size() != getRowCount()) {
- System.err
- .println("Number of persisted rows (" + newRowIndexOrder.size() + ") " + //$NON-NLS-1$ //$NON-NLS-2$
- "is not the same as the number of rows in the data source (" //$NON-NLS-1$
- + getRowCount() + ").\n" + //$NON-NLS-1$
- "Skipping restore of row ordering"); //$NON-NLS-1$
+ log.error("Number of persisted rows (" + newRowIndexOrder.size() + ") " + //$NON-NLS-1$ //$NON-NLS-2$
+ "is not the same as the number of rows in the data source (" //$NON-NLS-1$
+ + getRowCount() + ").\n" + //$NON-NLS-1$
+ "Skipping restore of row ordering"); //$NON-NLS-1$
return false;
}
for (Integer index : newRowIndexOrder) {
if (!this.rowIndexOrder.contains(index)) {
- System.err
- .println("Row index: " + index + " being restored, is not a available in the data soure.\n" + //$NON-NLS-1$ //$NON-NLS-2$
- "Skipping restore of row ordering"); //$NON-NLS-1$
+ log.error("Row index: " + index + " being restored, is not a available in the data soure.\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ "Skipping restore of row ordering"); //$NON-NLS-1$
return false;
}
}
@@ -214,8 +206,7 @@
int aggregateWidth = 0;
for (int rowPosition = 0; rowPosition < targetRowPosition; rowPosition++) {
- aggregateWidth += this.underlyingLayer
- .getRowHeightByPosition(localToUnderlyingRowPosition(rowPosition));
+ aggregateWidth += this.underlyingLayer.getRowHeightByPosition(localToUnderlyingRowPosition(rowPosition));
}
this.startYCache.put(targetRowPosition, aggregateWidth);
@@ -228,8 +219,7 @@
private void populateIndexOrder() {
ILayer underlyingLayer = getUnderlyingLayer();
for (int rowPosition = 0; rowPosition < underlyingLayer.getRowCount(); rowPosition++) {
- this.rowIndexOrder.add(underlyingLayer
- .getRowIndexByPosition(rowPosition));
+ this.rowIndexOrder.add(underlyingLayer.getRowIndexByPosition(rowPosition));
}
}
@@ -264,22 +254,17 @@
}
@Override
- public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer,
- int underlyingRowPosition) {
- int rowIndex = this.underlyingLayer
- .getRowIndexByPosition(underlyingRowPosition);
+ public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition) {
+ int rowIndex = this.underlyingLayer.getRowIndexByPosition(underlyingRowPosition);
return getRowPositionByIndex(rowIndex);
}
@Override
- public Collection<Range> underlyingToLocalRowPositions(
- ILayer sourceUnderlyingLayer,
- Collection<Range> underlyingRowPositionRanges) {
+ public Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges) {
List<Integer> reorderedRowPositions = new ArrayList<Integer>();
for (Range underlyingRowPositionRange : underlyingRowPositionRanges) {
for (int underlyingRowPosition = underlyingRowPositionRange.start; underlyingRowPosition < underlyingRowPositionRange.end; underlyingRowPosition++) {
- int localRowPosition = underlyingToLocalRowPosition(
- sourceUnderlyingLayer, underlyingRowPositionRange.start);
+ int localRowPosition = underlyingToLocalRowPosition(sourceUnderlyingLayer, underlyingRowPositionRange.start);
reorderedRowPositions.add(localRowPosition);
}
}
@@ -301,8 +286,7 @@
* whether the move should be done above the given to position or
* not
*/
- private void moveRow(int fromRowPosition, int toRowPosition,
- boolean reorderToTopEdge) {
+ private void moveRow(int fromRowPosition, int toRowPosition, boolean reorderToTopEdge) {
if (!reorderToTopEdge) {
toRowPosition++;
}
@@ -310,8 +294,7 @@
Integer fromRowIndex = this.rowIndexOrder.get(fromRowPosition);
this.rowIndexOrder.add(toRowPosition, fromRowIndex);
- this.rowIndexOrder.remove(fromRowPosition
- + (fromRowPosition > toRowPosition ? 1 : 0));
+ this.rowIndexOrder.remove(fromRowPosition + (fromRowPosition > toRowPosition ? 1 : 0));
invalidateCache();
}
@@ -348,11 +331,9 @@
* whether the move should be done above the given to position or
* not
*/
- public void reorderRowPosition(int fromRowPosition, int toRowPosition,
- boolean reorderToTopEdge) {
+ public void reorderRowPosition(int fromRowPosition, int toRowPosition, boolean reorderToTopEdge) {
moveRow(fromRowPosition, toRowPosition, reorderToTopEdge);
- fireLayerEvent(new RowReorderEvent(this, fromRowPosition,
- toRowPosition, reorderToTopEdge));
+ fireLayerEvent(new RowReorderEvent(this, fromRowPosition, toRowPosition, reorderToTopEdge));
}
/**
@@ -365,8 +346,7 @@
* @param toRowPosition
* position to move the rows to
*/
- public void reorderMultipleRowPositions(List<Integer> fromRowPositions,
- int toRowPosition) {
+ public void reorderMultipleRowPositions(List<Integer> fromRowPositions, int toRowPosition) {
boolean reorderToTopEdge;
if (toRowPosition < getRowCount()) {
reorderToTopEdge = true;
@@ -374,8 +354,7 @@
reorderToTopEdge = false;
toRowPosition--;
}
- reorderMultipleRowPositions(fromRowPositions, toRowPosition,
- reorderToTopEdge);
+ reorderMultipleRowPositions(fromRowPositions, toRowPosition, reorderToTopEdge);
}
/**
@@ -390,8 +369,7 @@
* whether the move should be done above the given to position or
* not
*/
- public void reorderMultipleRowPositions(List<Integer> fromRowPositions,
- int toRowPosition, boolean reorderToTopEdge) {
+ public void reorderMultipleRowPositions(List<Integer> fromRowPositions, int toRowPosition, boolean reorderToTopEdge) {
final int fromRowPositionsCount = fromRowPositions.size();
if (toRowPosition > fromRowPositions.get(fromRowPositionsCount - 1)) {
@@ -405,19 +383,16 @@
firstRowPosition = fromRowPosition;
}
}
- } else if (toRowPosition < fromRowPositions
- .get(fromRowPositionsCount - 1)) {
+ } else if (toRowPosition < fromRowPositions.get(fromRowPositionsCount - 1)) {
// Moving from bottom to top
int targetRowPosition = toRowPosition;
for (Integer fromRowPosition : fromRowPositions) {
final int fromRowPositionInt = fromRowPosition;
- moveRow(fromRowPositionInt, targetRowPosition++,
- reorderToTopEdge);
+ moveRow(fromRowPositionInt, targetRowPosition++, reorderToTopEdge);
}
}
- fireLayerEvent(new RowReorderEvent(this, fromRowPositions,
- toRowPosition, reorderToTopEdge));
+ fireLayerEvent(new RowReorderEvent(this, fromRowPositions, toRowPosition, reorderToTopEdge));
}
/**
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/ColumnStyleEditorDialog.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/ColumnStyleEditorDialog.java
index cd9328b..535983c 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/ColumnStyleEditorDialog.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/style/editor/ColumnStyleEditorDialog.java
@@ -10,6 +10,8 @@
******************************************************************************/
package org.eclipse.nebula.widgets.nattable.style.editor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.eclipse.nebula.widgets.nattable.Messages;
import org.eclipse.nebula.widgets.nattable.style.BorderStyle;
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
@@ -27,6 +29,8 @@
public class ColumnStyleEditorDialog extends AbstractStyleEditorDialog {
+ private static final Log log = LogFactory.getLog(ColumnStyleEditorDialog.class);
+
// Tabs in the dialog
private CellStyleEditorPanel cellStyleEditorPanel;
private BorderStyleEditorPanel borderStyleEditorPanel;
@@ -43,8 +47,7 @@
this.newColumnCellStyle = columnCellStyle;
if (columnCellStyle != null) {
- this.newBorderStyle = this.columnStyle
- .getAttributeValue(CellStyleAttributes.BORDER_STYLE);
+ this.newBorderStyle = this.columnStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE);
}
}
@@ -82,10 +85,9 @@
try {
this.cellStyleEditorPanel.edit(this.columnStyle);
- this.borderStyleEditorPanel.edit(this.columnStyle
- .getAttributeValue(CellStyleAttributes.BORDER_STYLE));
+ this.borderStyleEditorPanel.edit(this.columnStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE));
} catch (Exception e) {
- e.printStackTrace(System.err);
+ log.error("Error on style editing", e); //$NON-NLS-1$
}
}
@@ -111,14 +113,11 @@
Composite columnPanel = new Composite(parent, SWT.NONE);
columnPanel.setLayout(new GridLayout());
- new SeparatorPanel(columnPanel,
- Messages.getString("ColumnStyleEditorDialog.styling")); //$NON-NLS-1$
+ new SeparatorPanel(columnPanel, Messages.getString("ColumnStyleEditorDialog.styling")); //$NON-NLS-1$
this.cellStyleEditorPanel = new CellStyleEditorPanel(columnPanel, SWT.NONE);
- new SeparatorPanel(columnPanel,
- Messages.getString("ColumnStyleEditorDialog.border")); //$NON-NLS-1$
- this.borderStyleEditorPanel = new BorderStyleEditorPanel(columnPanel,
- SWT.NONE);
+ new SeparatorPanel(columnPanel, Messages.getString("ColumnStyleEditorDialog.border")); //$NON-NLS-1$
+ this.borderStyleEditorPanel = new BorderStyleEditorPanel(columnPanel, SWT.NONE);
return columnPanel;
}
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 7fa948d..379a029 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
@@ -14,6 +14,8 @@
import java.util.LinkedList;
import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
import org.eclipse.nebula.widgets.nattable.ui.action.IDragMode;
@@ -26,6 +28,8 @@
public class UiBindingRegistry implements IUiBindingRegistry {
+ private static final Log log = LogFactory.getLog(UiBindingRegistry.class);
+
private NatTable natTable;
private LinkedList<KeyBinding> keyBindings = new LinkedList<KeyBinding>();
@@ -52,12 +56,10 @@
@Override
public IDragMode getDragMode(MouseEvent event) {
- LabelStack regionLabels = this.natTable
- .getRegionLabelsByXY(event.x, event.y);
+ LabelStack regionLabels = this.natTable.getRegionLabelsByXY(event.x, event.y);
for (DragBinding dragBinding : this.dragBindings) {
- if (dragBinding.getMouseEventMatcher().matches(this.natTable, event,
- regionLabels)) {
+ if (dragBinding.getMouseEventMatcher().matches(this.natTable, event, regionLabels)) {
return dragBinding.getDragMode();
}
}
@@ -102,8 +104,7 @@
// /////////////////////////////////////////////////////////////////////////
- private IMouseAction getMouseEventAction(MouseEventTypeEnum mouseEventType,
- MouseEvent event) {
+ private IMouseAction getMouseEventAction(MouseEventTypeEnum mouseEventType, MouseEvent event) {
// TODO: This code can be made more performant by mapping mouse bindings
// not only to the mouseEventType but
@@ -112,22 +113,19 @@
// list of mouse bindings that need to be searched. -- Azubuko.Obele
try {
- LinkedList<MouseBinding> mouseEventBindings = this.mouseBindingsMap
- .get(mouseEventType);
+ LinkedList<MouseBinding> mouseEventBindings = this.mouseBindingsMap.get(mouseEventType);
if (mouseEventBindings != null) {
- LabelStack regionLabels = this.natTable.getRegionLabelsByXY(event.x,
- event.y);
+ LabelStack regionLabels = this.natTable.getRegionLabelsByXY(event.x, event.y);
for (MouseBinding mouseBinding : mouseEventBindings) {
- if (mouseBinding.getMouseEventMatcher().matches(this.natTable,
- event, regionLabels)) {
+ if (mouseBinding.getMouseEventMatcher().matches(this.natTable, event, regionLabels)) {
return mouseBinding.getAction();
}
}
}
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception on retrieving a mouse event action", e); //$NON-NLS-1$
}
return null;
}
@@ -136,13 +134,11 @@
// Key
- public void registerFirstKeyBinding(IKeyEventMatcher keyMatcher,
- IKeyAction action) {
+ public void registerFirstKeyBinding(IKeyEventMatcher keyMatcher, IKeyAction action) {
this.keyBindings.addFirst(new KeyBinding(keyMatcher, action));
}
- public void registerKeyBinding(IKeyEventMatcher keyMatcher,
- IKeyAction action) {
+ public void registerKeyBinding(IKeyEventMatcher keyMatcher, IKeyAction action) {
this.keyBindings.addLast(new KeyBinding(keyMatcher, action));
}
@@ -157,13 +153,11 @@
// Drag
- public void registerFirstMouseDragMode(
- IMouseEventMatcher mouseEventMatcher, IDragMode dragMode) {
+ public void registerFirstMouseDragMode(IMouseEventMatcher mouseEventMatcher, IDragMode dragMode) {
this.dragBindings.addFirst(new DragBinding(mouseEventMatcher, dragMode));
}
- public void registerMouseDragMode(IMouseEventMatcher mouseEventMatcher,
- IDragMode dragMode) {
+ public void registerMouseDragMode(IMouseEventMatcher mouseEventMatcher, IDragMode dragMode) {
this.dragBindings.addLast(new DragBinding(mouseEventMatcher, dragMode));
}
@@ -178,16 +172,12 @@
// Mouse move
- public void registerFirstMouseMoveBinding(
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- registerMouseBinding(true, MouseEventTypeEnum.MOUSE_MOVE,
- mouseEventMatcher, action);
+ public void registerFirstMouseMoveBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(true, MouseEventTypeEnum.MOUSE_MOVE, mouseEventMatcher, action);
}
- public void registerMouseMoveBinding(IMouseEventMatcher mouseEventMatcher,
- IMouseAction action) {
- registerMouseBinding(false, MouseEventTypeEnum.MOUSE_MOVE,
- mouseEventMatcher, action);
+ public void registerMouseMoveBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(false, MouseEventTypeEnum.MOUSE_MOVE, mouseEventMatcher, action);
}
public void unregisterMouseMoveBinding(IMouseEventMatcher mouseEventMatcher) {
@@ -196,16 +186,12 @@
// Mouse down
- public void registerFirstMouseDownBinding(
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- registerMouseBinding(true, MouseEventTypeEnum.MOUSE_DOWN,
- mouseEventMatcher, action);
+ public void registerFirstMouseDownBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(true, MouseEventTypeEnum.MOUSE_DOWN, mouseEventMatcher, action);
}
- public void registerMouseDownBinding(IMouseEventMatcher mouseEventMatcher,
- IMouseAction action) {
- registerMouseBinding(false, MouseEventTypeEnum.MOUSE_DOWN,
- mouseEventMatcher, action);
+ public void registerMouseDownBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(false, MouseEventTypeEnum.MOUSE_DOWN, mouseEventMatcher, action);
}
public void unregisterMouseDownBinding(IMouseEventMatcher mouseEventMatcher) {
@@ -214,94 +200,68 @@
// Single click
- public void registerFirstSingleClickBinding(
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- registerMouseBinding(true, MouseEventTypeEnum.MOUSE_SINGLE_CLICK,
- mouseEventMatcher, action);
+ public void registerFirstSingleClickBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(true, MouseEventTypeEnum.MOUSE_SINGLE_CLICK, mouseEventMatcher, action);
}
- public void registerSingleClickBinding(
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- registerMouseBinding(false, MouseEventTypeEnum.MOUSE_SINGLE_CLICK,
- mouseEventMatcher, action);
+ public void registerSingleClickBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(false, MouseEventTypeEnum.MOUSE_SINGLE_CLICK, mouseEventMatcher, action);
}
- public void unregisterSingleClickBinding(
- IMouseEventMatcher mouseEventMatcher) {
- unregisterMouseBinding(MouseEventTypeEnum.MOUSE_SINGLE_CLICK,
- mouseEventMatcher);
+ public void unregisterSingleClickBinding(IMouseEventMatcher mouseEventMatcher) {
+ unregisterMouseBinding(MouseEventTypeEnum.MOUSE_SINGLE_CLICK, mouseEventMatcher);
}
// Double click
- public void registerFirstDoubleClickBinding(
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- registerMouseBinding(true, MouseEventTypeEnum.MOUSE_DOUBLE_CLICK,
- mouseEventMatcher, action);
+ public void registerFirstDoubleClickBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(true, MouseEventTypeEnum.MOUSE_DOUBLE_CLICK, mouseEventMatcher, action);
}
- public void registerDoubleClickBinding(
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- registerMouseBinding(false, MouseEventTypeEnum.MOUSE_DOUBLE_CLICK,
- mouseEventMatcher, action);
+ public void registerDoubleClickBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(false, MouseEventTypeEnum.MOUSE_DOUBLE_CLICK, mouseEventMatcher, action);
}
- public void unregisterDoubleClickBinding(
- IMouseEventMatcher mouseEventMatcher) {
- unregisterMouseBinding(MouseEventTypeEnum.MOUSE_DOUBLE_CLICK,
- mouseEventMatcher);
+ public void unregisterDoubleClickBinding(IMouseEventMatcher mouseEventMatcher) {
+ unregisterMouseBinding(MouseEventTypeEnum.MOUSE_DOUBLE_CLICK, mouseEventMatcher);
}
// Mouse hover
- public void registerFirstMouseHoverBinding(
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- registerMouseBinding(true, MouseEventTypeEnum.MOUSE_HOVER,
- mouseEventMatcher, action);
+ public void registerFirstMouseHoverBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(true, MouseEventTypeEnum.MOUSE_HOVER, mouseEventMatcher, action);
}
- public void registerMouseHoverBinding(IMouseEventMatcher mouseEventMatcher,
- IMouseAction action) {
- registerMouseBinding(false, MouseEventTypeEnum.MOUSE_HOVER,
- mouseEventMatcher, action);
+ public void registerMouseHoverBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(false, MouseEventTypeEnum.MOUSE_HOVER, mouseEventMatcher, action);
}
public void unregisterMouseHoverBinding(IMouseEventMatcher mouseEventMatcher) {
- unregisterMouseBinding(MouseEventTypeEnum.MOUSE_HOVER,
- mouseEventMatcher);
+ unregisterMouseBinding(MouseEventTypeEnum.MOUSE_HOVER, mouseEventMatcher);
}
// Mouse enter
- public void registerFirstMouseEnterBinding(
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- registerMouseBinding(true, MouseEventTypeEnum.MOUSE_ENTER,
- mouseEventMatcher, action);
+ public void registerFirstMouseEnterBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(true, MouseEventTypeEnum.MOUSE_ENTER, mouseEventMatcher, action);
}
- public void registerMouseEnterBinding(IMouseEventMatcher mouseEventMatcher,
- IMouseAction action) {
- registerMouseBinding(false, MouseEventTypeEnum.MOUSE_ENTER,
- mouseEventMatcher, action);
+ public void registerMouseEnterBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(false, MouseEventTypeEnum.MOUSE_ENTER, mouseEventMatcher, action);
}
public void unregisterMouseEnterBinding(IMouseEventMatcher mouseEventMatcher) {
- unregisterMouseBinding(MouseEventTypeEnum.MOUSE_ENTER,
- mouseEventMatcher);
+ unregisterMouseBinding(MouseEventTypeEnum.MOUSE_ENTER, mouseEventMatcher);
}
// Mouse exit
- public void registerFirstMouseExitBinding(
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- registerMouseBinding(true, MouseEventTypeEnum.MOUSE_EXIT,
- mouseEventMatcher, action);
+ public void registerFirstMouseExitBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(true, MouseEventTypeEnum.MOUSE_EXIT, mouseEventMatcher, action);
}
- public void registerMouseExitBinding(IMouseEventMatcher mouseEventMatcher,
- IMouseAction action) {
- registerMouseBinding(false, MouseEventTypeEnum.MOUSE_EXIT,
- mouseEventMatcher, action);
+ public void registerMouseExitBinding(IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
+ registerMouseBinding(false, MouseEventTypeEnum.MOUSE_EXIT, mouseEventMatcher, action);
}
public void unregisterMouseExitBinding(IMouseEventMatcher mouseEventMatcher) {
@@ -311,27 +271,21 @@
// /////////////////////////////////////////////////////////////////////////
private void registerMouseBinding(boolean first,
- MouseEventTypeEnum mouseEventType,
- IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
- LinkedList<MouseBinding> mouseEventBindings = this.mouseBindingsMap
- .get(mouseEventType);
+ 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);
}
if (first) {
- mouseEventBindings.addFirst(new MouseBinding(mouseEventMatcher,
- action));
+ mouseEventBindings.addFirst(new MouseBinding(mouseEventMatcher, action));
} else {
- mouseEventBindings.addLast(new MouseBinding(mouseEventMatcher,
- action));
+ mouseEventBindings.addLast(new MouseBinding(mouseEventMatcher, action));
}
}
- private void unregisterMouseBinding(MouseEventTypeEnum mouseEventType,
- IMouseEventMatcher mouseEventMatcher) {
- LinkedList<MouseBinding> mouseBindings = this.mouseBindingsMap
- .get(mouseEventType);
+ private void unregisterMouseBinding(MouseEventTypeEnum mouseEventType, IMouseEventMatcher mouseEventMatcher) {
+ LinkedList<MouseBinding> mouseBindings = this.mouseBindingsMap.get(mouseEventType);
for (MouseBinding mouseBinding : mouseBindings) {
if (mouseBinding.getMouseEventMatcher().equals(mouseEventMatcher)) {
mouseBindings.remove(mouseBinding);
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 0079372..8dc20e7 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
@@ -52,15 +52,10 @@
* {@link Matcher} that is used by this command as a static
* {@link MatcherEditor}. Otherwise these two functions will not work correctly
* together.
- *
- * @author Dirk Fauth
- *
*/
-public class GlazedListsRowHideShowLayer<T> extends AbstractLayerTransform
- implements IRowHideShowCommandLayer, IUniqueIndexLayer {
+public class GlazedListsRowHideShowLayer<T> extends AbstractLayerTransform implements IRowHideShowCommandLayer, IUniqueIndexLayer {
- private static final Log log = LogFactory
- .getLog(GlazedListsRowHideShowLayer.class);
+ private static final Log log = LogFactory.getLog(GlazedListsRowHideShowLayer.class);
/**
* Key for persisting the number of hidden row id's. This is necessary
@@ -112,8 +107,7 @@
* of the row object. This is necessary to determine the row
* object to hide in terms of content.
*/
- public GlazedListsRowHideShowLayer(ILayer underlyingLayer,
- IRowDataProvider<T> rowDataProvider, IRowIdAccessor<T> rowIdAccessor) {
+ public GlazedListsRowHideShowLayer(ILayer underlyingLayer, IRowDataProvider<T> rowDataProvider, IRowIdAccessor<T> rowIdAccessor) {
super(underlyingLayer);
if (rowIdAccessor == null) {
throw new IllegalArgumentException("rowIdAccessor can not be null!"); //$NON-NLS-1$
@@ -146,9 +140,11 @@
* The {@link FilterList} to apply the local row hide
* {@link Matcher} to.
*/
- public GlazedListsRowHideShowLayer(ILayer underlyingLayer,
+ public GlazedListsRowHideShowLayer(
+ ILayer underlyingLayer,
IRowDataProvider<T> rowDataProvider,
- IRowIdAccessor<T> rowIdAccessor, FilterList<T> filterList) {
+ IRowIdAccessor<T> rowIdAccessor,
+ FilterList<T> filterList) {
super(underlyingLayer);
if (rowIdAccessor == null) {
throw new IllegalArgumentException("rowIdAccessor can not be null!"); //$NON-NLS-1$
@@ -186,7 +182,8 @@
* The {@link CompositeMatcherEditor} to which the local row hide
* {@link Matcher} should be added.
*/
- public GlazedListsRowHideShowLayer(ILayer underlyingLayer,
+ public GlazedListsRowHideShowLayer(
+ ILayer underlyingLayer,
IRowDataProvider<T> rowDataProvider,
IRowIdAccessor<T> rowIdAccessor,
CompositeMatcherEditor<T> matcherEditor) {
@@ -231,8 +228,7 @@
Collection<Serializable> rowIds = new HashSet<Serializable>();
for (Integer rowPos : rowPositions) {
int rowIndex = getRowIndexByPosition(rowPos);
- rowIds.add(this.rowIdAccessor.getRowId(this.rowDataProvider
- .getRowObject(rowIndex)));
+ rowIds.add(this.rowIdAccessor.getRowId(this.rowDataProvider.getRowObject(rowIndex)));
}
hideRows(rowIds);
}
@@ -249,8 +245,7 @@
public void hideRowIndexes(Collection<Integer> rowIndexes) {
Collection<Serializable> rowIds = new HashSet<Serializable>();
for (Integer rowIndex : rowIndexes) {
- rowIds.add(this.rowIdAccessor.getRowId(this.rowDataProvider
- .getRowObject(rowIndex)));
+ rowIds.add(this.rowIdAccessor.getRowId(this.rowDataProvider.getRowObject(rowIndex)));
}
hideRows(rowIds);
}
@@ -267,8 +262,7 @@
public void showRowIndexes(Collection<Integer> rowIndexes) {
Collection<Serializable> rowIds = new HashSet<Serializable>();
for (Integer rowIndex : rowIndexes) {
- rowIds.add(this.rowIdAccessor.getRowId(this.rowDataProvider
- .getRowObject(rowIndex)));
+ rowIds.add(this.rowIdAccessor.getRowId(this.rowDataProvider.getRowObject(rowIndex)));
}
showRows(rowIds);
}
@@ -315,14 +309,12 @@
@Override
public int getColumnPositionByIndex(int columnIndex) {
- return ((IUniqueIndexLayer) getUnderlyingLayer())
- .getColumnPositionByIndex(columnIndex);
+ return ((IUniqueIndexLayer) getUnderlyingLayer()).getColumnPositionByIndex(columnIndex);
}
@Override
public int getRowPositionByIndex(int rowIndex) {
- return ((IUniqueIndexLayer) getUnderlyingLayer())
- .getRowPositionByIndex(rowIndex);
+ return ((IUniqueIndexLayer) getUnderlyingLayer()).getRowPositionByIndex(rowIndex);
}
@Override
@@ -349,7 +341,7 @@
try {
out.close();
} catch (IOException e) {
- e.printStackTrace();
+ log.error("Error on closing the output stream", e); //$NON-NLS-1$
}
}
}
@@ -361,16 +353,13 @@
@Override
public void loadState(String prefix, Properties properties) {
this.rowIdsToHide.clear();
- String property = properties.getProperty(prefix
- + PERSISTENCE_KEY_HIDDEN_ROW_IDS_COUNT);
+ String property = properties.getProperty(prefix + PERSISTENCE_KEY_HIDDEN_ROW_IDS_COUNT);
int count = property != null ? Integer.valueOf(property) : 0;
- property = properties.getProperty(prefix
- + PERSISTENCE_KEY_HIDDEN_ROW_IDS);
+ property = properties.getProperty(prefix + PERSISTENCE_KEY_HIDDEN_ROW_IDS);
if (property != null) {
ObjectInputStream in = null;
try {
- ByteArrayInputStream bis = new ByteArrayInputStream(
- Base64.decodeBase64(property.getBytes()));
+ ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decodeBase64(property.getBytes()));
in = new ObjectInputStream(bis);
Serializable ser = null;
for (int i = 0; i < count; i++) {
@@ -384,7 +373,7 @@
try {
in.close();
} catch (IOException e) {
- e.printStackTrace();
+ log.error("Error on closing the input stream", e); //$NON-NLS-1$
}
}
}
@@ -398,9 +387,6 @@
* {@link MatcherEditor} implementation that will only match objects that
* are not hidden by id. It also enables to fire change events to indicate
* changes to the filter.
- *
- * @author Dirk Fauth
- *
*/
class HideRowMatcherEditor extends AbstractMatcherEditor<T> {
/**