evolvement of the basic stub
diff --git a/org.eclipse.nebula.widgets.nattable.core/META-INF/MANIFEST.MF b/org.eclipse.nebula.widgets.nattable.core/META-INF/MANIFEST.MF
index 08c8611..8067a6e 100644
--- a/org.eclipse.nebula.widgets.nattable.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.nebula.widgets.nattable.core/META-INF/MANIFEST.MF
@@ -4,10 +4,11 @@
Bundle-SymbolicName: org.eclipse.nebula.widgets.nattable.core
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Import-Package: org.eclipse.swt,
- org.eclipse.swt.events,
- org.eclipse.swt.graphics,
- org.eclipse.swt.widgets
Export-Package: org.eclipse.nebula.widgets.nattable.core,
+ org.eclipse.nebula.widgets.nattable.core.config,
org.eclipse.nebula.widgets.nattable.core.layer,
- org.eclipse.nebula.widgets.nattable.core.layer.event
+ org.eclipse.nebula.widgets.nattable.core.layer.cell,
+ org.eclipse.nebula.widgets.nattable.core.layer.event,
+ org.eclipse.nebula.widgets.nattable.core.painter,
+ org.eclipse.nebula.widgets.nattable.core.painter.cell,
+ org.eclipse.nebula.widgets.nattable.core.style
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/NatTableConfiguration.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/INatTableConfiguration.java
similarity index 96%
rename from org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/NatTableConfiguration.java
rename to org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/INatTableConfiguration.java
index adf7765..c690a6f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/NatTableConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/INatTableConfiguration.java
@@ -9,7 +9,7 @@
* @author Dirk Fauth
*
*/
-public interface NatTableConfiguration {
+public interface INatTableConfiguration {
/**
* Starts constructing the NatTable with the given configuration.
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/NatTable.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/NatTable.java
index 1430448..ae21755 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/NatTable.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/NatTable.java
@@ -16,7 +16,8 @@
import org.eclipse.nebula.widgets.nattable.core.layer.ILayer;
import org.eclipse.nebula.widgets.nattable.core.layer.ILayerListener;
import org.eclipse.nebula.widgets.nattable.core.layer.event.ILayerEvent;
-import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.nebula.widgets.nattable.core.painter.IGraphicsContext;
+import org.eclipse.nebula.widgets.nattable.core.painter.Rectangle;
/**
* Presentation model of the NatTable.
@@ -53,7 +54,7 @@
- public NatTable(NatTableConfiguration natConfig) {
+ public NatTable(INatTableConfiguration natConfig) {
if (natConfig != null) {
//if a NatTableConfiguration is given, start configuring it by this
//e.g. if using the E4 extension, the layers and other configurations will
@@ -231,11 +232,8 @@
// overlayPainters.remove(overlayPainter);
// }
- public void paintControl(final PaintEvent event) {
- paintNatTable(event);
- }
- private void paintNatTable(final PaintEvent event) {
+ public void paintNatTable(final IGraphicsContext gc, final Rectangle rectangle) {
// getLayerPainter().paintLayer(this, event.gc, 0, 0, new Rectangle(event.x, event.y, event.width, event.height), getConfigRegistry());
}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/config/IConfigRegistry.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/config/IConfigRegistry.java
new file mode 100644
index 0000000..b185fed
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/config/IConfigRegistry.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.config;
+
+import java.util.List;
+
+import org.eclipse.nebula.widgets.nattable.core.style.ConfigAttribute;
+import org.eclipse.nebula.widgets.nattable.core.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.core.style.IDisplayModeOrdering;
+
+/**
+ * Holds all the settings, bindings and other configuration for a NatTable instance.</br>
+ *
+ * @see ConfigRegistry
+ * @see ConfigRegistryTest for a better understanding
+ */
+public interface IConfigRegistry {
+
+ /**
+ * If retrieving registered values<br/>
+ * Example 1:<br/>
+ * configRegistry.getConfigAttribute(attribute, DisplayMode.EDIT);<br/>
+ * <ol>
+ * <li>It will look for an attribute registered using the EDIT display mode</li>
+ * <li>If it can't find that it will try and find an attribute under the NORMAL mode</li>
+ * <li>If it can't find one it will try and find one registered without a display mode {@link #registerConfigAttribute(ConfigAttribute, Object)}</li>
+ * </ol>
+ * Example 2:<br/>
+ * configRegistry.getConfigAttribute(attribute, DisplayMode.NORMAL, "testLabel", "testLabel_1");<br/>
+ * <ol>
+ * <li>It will look for an attribute registered by display mode NORMAL and "testLabel"<li/>
+ * <li>It will look for an attribute registered by display mode NORMAL and "testLabel_1"<li/>
+ * </ol>
+ * @param <T> Type of the attribute
+ * @param configAttribute to be registered
+ * @param targetDisplayMode display mode the cell needs to be in, for this attribute to be returned
+ * @param configLabels the cell needs to have, for this attribute to be returned
+ * @return the configAttribute, if the display mode and the configLabels match
+ */
+ public <T> T getConfigAttribute(ConfigAttribute<T> configAttribute, String targetDisplayMode, String...configLabels);
+
+ /**
+ * @see #getConfigAttribute(ConfigAttribute, String, String...)
+ */
+ public <T> T getConfigAttribute(ConfigAttribute<T> configAttribute, String targetDisplayMode, List<String> configLabels);
+
+ /**
+ * @see #getConfigAttribute(ConfigAttribute, String, String...)
+ */
+ public <T> T getSpecificConfigAttribute(ConfigAttribute<T> configAttribute, String displayMode, String configLabel);
+
+ /**
+ * Register a configuration attribute
+ * @param configAttribute The {@link ConfigAttribute} to register.
+ * @param attributeValue The value to register for the {@link ConfigAttribute}.
+ */
+ public <T> void registerConfigAttribute(ConfigAttribute<T> configAttribute, T attributeValue);
+
+ /**
+ * Register an attribute against a {@link DisplayMode}.
+ * @param configAttribute The {@link ConfigAttribute} to register.
+ * @param attributeValue The value to register for the {@link ConfigAttribute}.
+ * @param targetDisplayMode The {@link DisplayMode} to register the {@link ConfigAttribute} against.
+ */
+ public <T> void registerConfigAttribute(ConfigAttribute<T> configAttribute, T attributeValue, String targetDisplayMode);
+
+ /**
+ * Register an attribute against a {@link DisplayMode} and configuration label (applied to cells)
+ * @param configAttribute The {@link ConfigAttribute} to register.
+ * @param attributeValue The value to register for the {@link ConfigAttribute}.
+ * @param targetDisplayMode The {@link DisplayMode} to register the {@link ConfigAttribute} against.
+ * @param configLabel The label to register the {@link ConfigAttribute} against.
+ */
+ public <T> void registerConfigAttribute(ConfigAttribute<T> configAttribute, T attributeValue, String targetDisplayMode, String configLabel);
+
+ /**
+ * Unregister the given {@link ConfigAttribute} specified by {@link DisplayMode} and label.
+ * @param configAttributeType The {@link ConfigAttribute} to unregister.
+ * @param displayMode The {@link DisplayMode} against which the {@link ConfigAttribute} is registered.
+ * @param configLabel The label against which the {@link ConfigAttribute} is registered.
+ */
+ public <T> void unregisterConfigAttribute(ConfigAttribute<T> configAttributeType, String displayMode, String configLabel);
+
+ /**
+ * TODO javadoc
+ *
+ * @return
+ */
+ public IDisplayModeOrdering getDisplayModeOrdering();
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/LabelStack.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/LabelStack.java
new file mode 100644
index 0000000..555dca0
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/LabelStack.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.layer;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.nebula.widgets.nattable.core.layer.cell.IConfigLabelAccumulator;
+
+/**
+ * The LabelStack is a list of labels attached to a ILayerCell.
+ * With the label stack mechanism it is possible to configure
+ * special rendering or behavior, dependent on labels included in
+ * the stack.
+ *
+ * <p>A LabelStack can not contain duplicate labels. So you might
+ * want to think of the LabelStack as an ordered java.util.Set
+ *
+ * <p>To add labels to the LabelStack, usually a {@link IConfigLabelAccumulator}
+ * is used.
+ */
+public class LabelStack {
+
+ /**
+ * List implementation saves the overhead of popping labels off
+ * in the {@link #getLabels()} method
+ */
+ private final List<String> labels = new LinkedList<String>();
+
+ /**
+ * Create a new LabelStack which is initialized with the specified
+ * collection of labels. Duplicate labels are not allowed and will
+ * be filtered on initialization automatically.
+ * @param labels The labels which should be used to initialize the
+ * new LabelStack
+ */
+ public LabelStack(String...labels) {
+ for (String label : labels) {
+ if (label != null) {
+ addLabel(label);
+ }
+ }
+ }
+
+ /**
+ * Adds a label at the bottom of this LabelStack.
+ * The label is only added if it is not present yet.
+ * @param label The label to add to this LabelStack.
+ */
+ public void addLabel(String label) {
+ if(!hasLabel(label)) {
+ labels.add(label);
+ }
+ }
+
+ /**
+ * Adds a label to the top of this LabelStack.
+ * If the specified label is already included in this LabelStack,
+ * it is moved to the top.
+ * @param label The label to add to this LabelStack
+ */
+ public void addLabelOnTop(String label) {
+ if (hasLabel(label)) {
+ removeLabel(label);
+ }
+ labels.add(0, label);
+ }
+
+ /**
+ *
+ * @return The list of labels included in this LabelStack
+ */
+ public List<String> getLabels() {
+ return labels;
+ }
+
+ /**
+ * Checks if this LabelStack contains the specified label.
+ * @param label The label whose presence need to be tested.
+ * @return <code>true</code> if this LabelStack contains the specified label.
+ */
+ public boolean hasLabel(String label) {
+ return labels.contains(label);
+ }
+
+ /**
+ * Removes the specified label from this LabelStack.
+ * @param label The label to remove.
+ * @return <code>true</code> if this LabelStack contained the specified label.
+ */
+ public boolean removeLabel(String label) {
+ return labels.remove(label);
+ }
+
+ @Override
+ public String toString() {
+ return labels.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this)
+ return true;
+
+ if (!(obj instanceof LabelStack))
+ return false;
+
+ return this.labels.equals(((LabelStack) obj).labels);
+ }
+
+ @Override
+ public int hashCode() {
+ return labels.hashCode();
+ }
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/IConfigLabelAccumulator.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/IConfigLabelAccumulator.java
new file mode 100644
index 0000000..88a1011
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/IConfigLabelAccumulator.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.layer.cell;
+
+import org.eclipse.nebula.widgets.nattable.core.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.core.layer.LabelStack;
+
+/**
+ * Resolves the configuration/config label(s) which are tied to a given cell.<br/>
+ * Various attributes can be registered in the {@link IConfigRegistry} against this</br>
+ * label</br>
+ */
+public interface IConfigLabelAccumulator {
+
+ /**
+ * Add labels applicable to this cell position
+ * @param configLabels the labels currently applied to the cell. The labels contributed by this
+ * provider must be <i>added</i> to this stack
+ * @param columnPosition of the cell for which labels are being gathered
+ * @param rowPosition of the cell for which labels are being gathered
+ */
+ public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition);
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/ILayerCell.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/ILayerCell.java
new file mode 100644
index 0000000..b88188e
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/layer/cell/ILayerCell.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.layer.cell;
+
+import org.eclipse.nebula.widgets.nattable.core.layer.ILayer;
+import org.eclipse.nebula.widgets.nattable.core.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.core.painter.Rectangle;
+
+public interface ILayerCell {
+
+ public int getOriginColumnPosition();
+
+ public int getOriginRowPosition();
+
+ public ILayer getLayer();
+
+ public int getColumnPosition();
+
+ public int getRowPosition();
+
+ public int getColumnIndex();
+
+ public int getRowIndex();
+
+ public int getColumnSpan();
+
+ public int getRowSpan();
+
+ public boolean isSpannedCell();
+
+ public String getDisplayMode();
+
+ public LabelStack getConfigLabels();
+
+ public Object getDataValue();
+
+ public Rectangle getBounds();
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/IGraphicsContext.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/IGraphicsContext.java
new file mode 100644
index 0000000..f0695cf
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/IGraphicsContext.java
@@ -0,0 +1,86 @@
+package org.eclipse.nebula.widgets.nattable.core.painter;
+
+import org.eclipse.nebula.widgets.nattable.core.style.IStyle;
+
+/**
+ * Interface for implementing a proxy to a UI toolkit dependent graphics context
+ * implementation. The graphics context is at the end the on who paints lines
+ * shapes etc. to the canvas to create the NatTable.
+ *
+ * e.g. org.eclipse.swt.graphics.GC
+ *
+ * @author Dirk Fauth
+ *
+ */
+public interface IGraphicsContext {
+
+ /**
+ *
+ * @param style {@link IStyle} instance containing the style information that
+ * should be used in the following painting operations.
+ */
+ void initStyle(IStyle style);
+
+ /**
+ * Resets the styling that was set by calling initStyle(IStyle).
+ * Usually this don't need to called, as every drawing operation in a NatTable
+ * painter will set the style information previous to a drawing operation,
+ * but to have a clean API, this method should be provided.
+ *
+ * <p>You could think of a use case where a custom control needs to be painted
+ * into a NatTable. If this custom control uses the same graphics context then
+ * the NatTable, it might cause strange effects if the style is not resetted
+ * to the previous values.
+ */
+ void resetStyle();
+
+ /**
+ * Draws the specified text at the position specified by x and y coordinates.
+ * Ensure that drawing the text doesn't draw a background and line delimiters
+ * are handled correctly.
+ * @param text The text to draw.
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ */
+ void drawText(String text, int x, int y);
+
+ /**
+ * Draws the specified text vertically at the position specified by x and y coordinates.
+ * The vertical translation is done by rotating plus or minus 90 degrees dependent on the
+ * specified up flag. Ensure that drawing the text doesn't draw a background and line
+ * delimiters are handled correctly.
+ *
+ * @param text the text to draw
+ * @param x the x coordinate of the top left corner of the drawing rectangle
+ * @param y the y coordinate of the top left corner of the drawing rectangle
+ * @param up if <code>true</code> the text will be drawed from the bottom to the top
+ * (this means the text will be rotated minus 90 degrees), while <code>false</code>
+ * will draw the text from top to bottom (which means rotation plus 90 degrees).
+ */
+ void drawVerticalText(String text, int x, int y, boolean up);
+
+ /**
+ * Draws a line, using the foreground color, between the points
+ * (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
+ *
+ * @param x1 the first point's x coordinate
+ * @param y1 the first point's y coordinate
+ * @param x2 the second point's x coordinate
+ * @param y2 the second point's y coordinate
+ */
+ void drawLine(int x1, int y1, int x2, int y2);
+
+ /**
+ * Returns the extent of the given string. Tab expansion and
+ * carriage return processing are performed.
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param text the text to measure
+ * @return a point containing the extent of the string
+ */
+ Point calculateTextExtend(String text);
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/Point.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/Point.java
new file mode 100644
index 0000000..af80531
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/Point.java
@@ -0,0 +1,100 @@
+package org.eclipse.nebula.widgets.nattable.core.painter;
+
+
+/**
+ * Instances of this class represent places on the (x, y)
+ * coordinate plane.
+ * <p>
+ * The coordinate space for rectangles and points is considered
+ * to have increasing values downward and to the right from its
+ * origin making this the normal, computer graphics oriented notion
+ * of (x, y) coordinates rather than the strict mathematical one.
+ * </p>
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * <p>
+ * There might be an implementation for this in every UI toolkit, like
+ * org.eclipse.swt.graphics.Point or java.awt.Point, but they are
+ * dependent to the UI toolkit because of their package and inheritance.
+ * That's why we reimplemented it again to make use of it in NatTable core
+ * without any further dependencies.
+ * </p>
+ * <p>
+ * This implementation is based on org.eclipse.swt.graphics.Point.
+ * </p>
+ */
+public class Point {
+
+ /**
+ * the x coordinate of the point
+ */
+ public int x;
+
+ /**
+ * the y coordinate of the point
+ */
+ public int y;
+
+ /**
+ * Constructs a new point with the given x and y coordinates.
+ *
+ * @param x the x coordinate of the new point
+ * @param y the y coordinate of the new point
+ */
+ public Point (int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+ public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Point)) return false;
+ Point p = (Point)object;
+ return (p.x == this.x) && (p.y == this.y);
+ }
+
+ /**
+ * Returns an integer hash code for the receiver. Any two
+ * objects that return <code>true</code> when passed to
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+ public int hashCode () {
+ return x ^ y;
+ }
+
+ /**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the point
+ */
+ public String toString () {
+ return "Point {" + x + ", " + y + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+}
+
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/Rectangle.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/Rectangle.java
new file mode 100644
index 0000000..49b938b
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/Rectangle.java
@@ -0,0 +1,316 @@
+package org.eclipse.nebula.widgets.nattable.core.painter;
+
+/**
+ * Instances of this class represent rectangular areas in an
+ * (x, y) coordinate system. The top left corner of the rectangle
+ * is specified by its x and y values, and the extent of the
+ * rectangle is specified by its width and height.
+ * <p>
+ * The coordinate space for rectangles and points is considered
+ * to have increasing values downward and to the right from its
+ * origin making this the normal, computer graphics oriented notion
+ * of (x, y) coordinates rather than the strict mathematical one.
+ * </p>
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * <p>
+ * There might be an implementation for this in every UI toolkit, like
+ * org.eclipse.swt.graphics.Rectangle or java.awt.Rectangle, but they are
+ * dependent to the UI toolkit because of their package and inheritance.
+ * That's why we reimplemented it again to make use of it in NatTable core
+ * without any further dependencies.
+ * </p>
+ * <p>
+ * This implementation is based on org.eclipse.swt.graphics.Rectangle.
+ * </p>
+ */
+public class Rectangle {
+
+ /**
+ * the x coordinate of the rectangle
+ */
+ public int x;
+
+ /**
+ * the y coordinate of the rectangle
+ */
+ public int y;
+
+ /**
+ * the width of the rectangle
+ */
+ public int width;
+
+ /**
+ * the height of the rectangle
+ */
+ public int height;
+
+ /**
+ * Construct a new instance of this class given the
+ * x, y, width and height values.
+ *
+ * @param x the x coordinate of the origin of the rectangle
+ * @param y the y coordinate of the origin of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ */
+ public Rectangle (int x, int y, int width, int height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ /**
+ * Destructively replaces the x, y, width and height values
+ * in the receiver with ones which represent the union of the
+ * rectangles specified by the receiver and the given rectangle.
+ * <p>
+ * The union of two rectangles is the smallest single rectangle
+ * that completely covers both of the areas covered by the two
+ * given rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to merge with the receiver
+ *
+ * @throws IllegalArgumentException if the specified rectangle is <code>null</code>
+ */
+ public void add (Rectangle rect) {
+ if (rect == null) throw new IllegalArgumentException("rectangle can not be null"); //$NON-NLS-1$
+ int left = x < rect.x ? x : rect.x;
+ int top = y < rect.y ? y : rect.y;
+ int lhs = x + width;
+ int rhs = rect.x + rect.width;
+ int right = lhs > rhs ? lhs : rhs;
+ lhs = y + height;
+ rhs = rect.y + rect.height;
+ int bottom = lhs > rhs ? lhs : rhs;
+ x = left; y = top; width = right - left; height = bottom - top;
+ }
+
+ /**
+ * Returns <code>true</code> if the point specified by the
+ * arguments is inside the area specified by the receiver,
+ * and <code>false</code> otherwise.
+ *
+ * @param x the x coordinate of the point to test for containment
+ * @param y the y coordinate of the point to test for containment
+ * @return <code>true</code> if the rectangle contains the point and <code>false</code> otherwise
+ */
+ public boolean contains (int x, int y) {
+ return (x >= this.x) && (y >= this.y) && x < (this.x + width) && y < (this.y + height);
+ }
+
+ /**
+ * Returns <code>true</code> if the given point is inside the
+ * area specified by the receiver, and <code>false</code>
+ * otherwise.
+ *
+ * @param pt the point to test for containment
+ * @return <code>true</code> if the rectangle contains the point and <code>false</code> otherwise
+ *
+ * @throws IllegalArgumentException if the specified point is <code>null</code>
+ */
+ public boolean contains (Point pt) {
+ if (pt == null) throw new IllegalArgumentException("point can not be null"); //$NON-NLS-1$
+ return contains(pt.x, pt.y);
+ }
+
+ /**
+ * Returns <code>true</code> if the receiver does not cover any
+ * area in the (x, y) coordinate plane, and <code>false</code> if
+ * the receiver does cover some area in the plane.
+ * <p>
+ * A rectangle is considered to <em>cover area</em> in the
+ * (x, y) coordinate plane if both its width and height are
+ * non-zero.
+ * </p>
+ *
+ * @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise
+ */
+ public boolean isEmpty () {
+ return (width <= 0) || (height <= 0);
+ }
+
+ /**
+ * Destructively replaces the x, y, width and height values
+ * in the receiver with ones which represent the intersection of the
+ * rectangles specified by the receiver and the given rectangle.
+ *
+ * @param rect the rectangle to intersect with the receiver
+ *
+ * @throws IllegalArgumentException if the specified rectangle is <code>null</code>
+ */
+ public void intersect (Rectangle rect) {
+ if (rect == null) throw new IllegalArgumentException("rectangle can not be null"); //$NON-NLS-1$
+ if (this == rect) return;
+ int left = x > rect.x ? x : rect.x;
+ int top = y > rect.y ? y : rect.y;
+ int lhs = x + width;
+ int rhs = rect.x + rect.width;
+ int right = lhs < rhs ? lhs : rhs;
+ lhs = y + height;
+ rhs = rect.y + rect.height;
+ int bottom = lhs < rhs ? lhs : rhs;
+ x = right < left ? 0 : left;
+ y = bottom < top ? 0 : top;
+ width = right < left ? 0 : right - left;
+ height = bottom < top ? 0 : bottom - top;
+ }
+
+ /**
+ * Returns a new rectangle which represents the intersection
+ * of the receiver and the given rectangle.
+ * <p>
+ * The intersection of two rectangles is the rectangle that
+ * covers the area which is contained within both rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to intersect with the receiver
+ * @return the intersection of the receiver and the argument
+ *
+ * @throws IllegalArgumentException if the specified rectangle is <code>null</code>
+ */
+ public Rectangle intersection (Rectangle rect) {
+ if (rect == null) throw new IllegalArgumentException("rectangle can not be null"); //$NON-NLS-1$
+ if (this == rect) return new Rectangle (x, y, width, height);
+ int left = x > rect.x ? x : rect.x;
+ int top = y > rect.y ? y : rect.y;
+ int lhs = x + width;
+ int rhs = rect.x + rect.width;
+ int right = lhs < rhs ? lhs : rhs;
+ lhs = y + height;
+ rhs = rect.y + rect.height;
+ int bottom = lhs < rhs ? lhs : rhs;
+ return new Rectangle (
+ right < left ? 0 : left,
+ bottom < top ? 0 : top,
+ right < left ? 0 : right - left,
+ bottom < top ? 0 : bottom - top);
+ }
+
+ /**
+ * Returns <code>true</code> if the rectangle described by the
+ * arguments intersects with the receiver and <code>false</code>
+ * otherwise.
+ * <p>
+ * Two rectangles intersect if the area of the rectangle
+ * representing their intersection is not empty.
+ * </p>
+ *
+ * @param x the x coordinate of the origin of the rectangle
+ * @param y the y coordinate of the origin of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @see #intersection(Rectangle)
+ * @see #isEmpty()
+ */
+ public boolean intersects (int x, int y, int width, int height) {
+ return (x < this.x + this.width) && (y < this.y + this.height) &&
+ (x + width > this.x) && (y + height > this.y);
+ }
+
+ /**
+ * Returns <code>true</code> if the given rectangle intersects
+ * with the receiver and <code>false</code> otherwise.
+ * <p>
+ * Two rectangles intersect if the area of the rectangle
+ * representing their intersection is not empty.
+ * </p>
+ *
+ * @param rect the rectangle to test for intersection
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @throws IllegalArgumentException if the specified rectangle is <code>null</code>
+ *
+ * @see #intersection(Rectangle)
+ * @see #isEmpty()
+ */
+ public boolean intersects (Rectangle rect) {
+ if (rect == null) throw new IllegalArgumentException("rectangle can not be null"); //$NON-NLS-1$
+ return rect == this || intersects (rect.x, rect.y, rect.width, rect.height);
+ }
+
+ /**
+ * Returns a new rectangle which represents the union of
+ * the receiver and the given rectangle.
+ * <p>
+ * The union of two rectangles is the smallest single rectangle
+ * that completely covers both of the areas covered by the two
+ * given rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to perform union with
+ * @return the union of the receiver and the argument
+ *
+ * @throws IllegalArgumentException if the specified rectangle is <code>null</code>
+ *
+ * @see #add(Rectangle)
+ */
+ public Rectangle union (Rectangle rect) {
+ if (rect == null) throw new IllegalArgumentException("rectangle can not be null"); //$NON-NLS-1$
+ int left = x < rect.x ? x : rect.x;
+ int top = y < rect.y ? y : rect.y;
+ int lhs = x + width;
+ int rhs = rect.x + rect.width;
+ int right = lhs > rhs ? lhs : rhs;
+ lhs = y + height;
+ rhs = rect.y + rect.height;
+ int bottom = lhs > rhs ? lhs : rhs;
+ return new Rectangle (left, top, right - left, bottom - top);
+ }
+
+ /**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+ public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Rectangle)) return false;
+ Rectangle r = (Rectangle)object;
+ return (r.x == this.x) && (r.y == this.y) && (r.width == this.width) && (r.height == this.height);
+ }
+
+ /**
+ * Returns an integer hash code for the receiver. Any two
+ * objects that return <code>true</code> when passed to
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+ public int hashCode () {
+ return x ^ y ^ width ^ height;
+ }
+
+ /**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the rectangle
+ */
+ public String toString () {
+ return "Rectangle {" + x + ", " + y + ", " + width + ", " + height + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/cell/ICellPainter.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/cell/ICellPainter.java
new file mode 100644
index 0000000..4bc6ddf
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/painter/cell/ICellPainter.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.painter.cell;
+
+import org.eclipse.nebula.widgets.nattable.core.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.core.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.core.painter.IGraphicsContext;
+import org.eclipse.nebula.widgets.nattable.core.painter.Rectangle;
+
+/**
+ * Implementations are responsible for painting a cell.<br/>
+ *
+ * Custom {@link ICellPainter} can be registered in the {@link IConfigRegistry}.
+ * This is a mechanism for plugging in custom cell painting.
+ *
+ * TODO remove the IConfigRegistry from the API and modify the code for usage of DI
+ */
+public interface ICellPainter {
+
+ /**
+ * Paint the specified cell to the NatTable.
+ * @param cell The {@link ILayerCell} to paint.
+ * @param gc The {@link IGraphicsContext} that should be used for painting
+ * @param bounds The bounds of the cell.
+ * @param configRegistry The configuration that should be used for retrieving the
+ * style information
+ */
+ public void paintCell(ILayerCell cell, IGraphicsContext gc, Rectangle bounds, IConfigRegistry configRegistry);
+
+ /**
+ * Get the preferred width of the cell when rendered by this painter. Used for auto-resize.
+ * @param cell The {@link ILayerCell} whose preferred width is requested.
+ * @param gc The {@link IGraphicsContext} that is used for painting
+ * @param configRegistry The configuration that should be used for retrieving the
+ * style information
+ * @return The preferred width of the cell when rendered by this painter.
+ */
+ public int getPreferredWidth(ILayerCell cell, IGraphicsContext gc, IConfigRegistry configRegistry);
+
+ /**
+ * Get the preferred height of the cell when rendered by this painter. Used for auto-resize.
+ * @param cell The {@link ILayerCell} whose preferred width is requested.
+ * @param gc The {@link IGraphicsContext} that is used for painting
+ * @param configRegistry The configuration that should be used for retrieving the
+ * style information
+ * @return The preferred height of the cell when rendered by this painter.
+ */
+ public int getPreferredHeight(ILayerCell cell, IGraphicsContext gc, IConfigRegistry configRegistry);
+
+
+ /**
+ * TODO javadoc
+ *
+ * @param x
+ * @param y
+ * @param cell
+ * @param gc
+ * @param adjustedCellBounds
+ * @param configRegistry
+ * @return
+ */
+ public ICellPainter getCellPainterAt(int x, int y, ILayerCell cell, IGraphicsContext gc, Rectangle adjustedCellBounds, IConfigRegistry configRegistry);
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/resources/Messages.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/resources/Messages.java
new file mode 100644
index 0000000..dcbe4d7
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/resources/Messages.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.resources;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Helper class for localization within the NatTable.
+ * Uses String based localization by reading directly out of a {@link ResourceBundle} that
+ * is contained in the package structure. A constant based approach like it can be seen in
+ * an Eclipse environment is not used here because of the fact that the NatTable might be
+ * used in a non OSGi environment.
+ */
+public class Messages {
+
+ /**
+ * The name of the NatTable internal {@link ResourceBundle}
+ */
+ private static final String BUNDLE_NAME = "org.eclipse.nebula.widgets.nattable.core.resources.messages"; //$NON-NLS-1$
+
+ /**
+ * The NatTable internal {@link ResourceBundle}
+ */
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ /**
+ * Gets a translation for the given key from the NatTable internal resource bundle.
+ * @param key the key for the desired translation
+ * @return the translation for the given key or the key prefixed and suffixed with "!" if
+ * there is no translation found for the given key.
+ * @throws NullPointerException if <code>key</code> is <code>null</code>
+ */
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+
+ /**
+ * Gets a translation for the given key from the NatTable internal resource bundle.
+ * Will format the returned value by replacing placeholders with the values specified
+ * in the args parameter.
+ * @param key the key for the desired translation
+ * @param args the arguments which should be used for replacement of placeholders in the
+ * translation
+ * @return the translation for the given key or the key prefixed and suffixed with "!" if
+ * there is no translation found for the given key.
+ * @throws NullPointerException if <code>key</code> is <code>null</code>
+ * @see Messages#getString(String)
+ * @see MessageFormat#format(String, Object...)
+ */
+ public static String getString (String key, Object... args) {
+ return MessageFormat.format(getString(key), args);
+ }
+
+ private Messages() {}
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/resources/messages.properties b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/resources/messages.properties
new file mode 100644
index 0000000..97c899f
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/resources/messages.properties
@@ -0,0 +1,133 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2012 Original authors and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Original authors and others - initial API and implementation
+#-------------------------------------------------------------------------------
+AbstractCellEditor.validationFailure=Error whilst validating cell value!
+
+AbstractColumnChooserDialog.doneButton=Done
+AbstractColumnChooserDialog.shellTitle=Column Chooser
+
+AbstractStyleEditorDialog.okButton=OK
+AbstractStyleEditorDialog.clearButton=Clear
+AbstractStyleEditorDialog.clearButtonTooltip=Reset to original settings
+AbstractStyleEditorDialog.cancelButton=Cancel
+
+BorderStyleEditorPanel.editorName=Border Style
+BorderStyleEditorPanel.noBorder=No Border
+BorderStyleEditorPanel.color=Color
+BorderStyleEditorPanel.lineStyle=Line Style
+BorderStyleEditorPanel.thickness=Thickness
+
+BorderThicknessPicker.thin=Thin
+BorderThicknessPicker.thick=Thick
+BorderThicknessPicker.veryThick=Very Thick
+
+CellStyleEditorPanel.backgroundColor=Background Color
+CellStyleEditorPanel.editorName=Basic Style
+CellStyleEditorPanel.font=Font
+CellStyleEditorPanel.foregroundColor=Foreground Color
+CellStyleEditorPanel.horizontalAlignment=Horizonatal Alignment
+CellStyleEditorPanel.verticalAlignment=Vertical Alignment
+
+ColumnChooser.availableColumns=Available Columns
+ColumnChooser.selectedColumns=Selected Columns
+
+ColumnEntry.0=No Label
+
+ColumnGroups.createColumnGroupDialogTitle=Create Column Group
+ColumnGroups.selectNonGroupedColumns=Please select non-grouped columns prior to creating a group.
+ColumnGroups.createButtonLabel=&Group
+ColumnGroups.createGroupLabel=G&roup Name
+ColumnGroups.removeColumnGroup=Remove column group
+ColumnGroups.renameColumnGroup=Rename column group
+
+ColumnLabel.original=Original
+ColumnLabel.rename=Rename
+ColumnLabel.editorName=Column label
+
+ColumnRenameDialog.shellTitle=Rename column
+
+ColumnStyleEditorDialog.border=Border
+ColumnStyleEditorDialog.column=Column
+ColumnStyleEditorDialog.shellTitle=Customize style
+ColumnStyleEditorDialog.styling=Styling
+
+DefaultCharacterDisplayConverter.failure=[{0}] is not a valid character.
+DefaultDateDisplayConverter.failure=[{0}] is not a valid date. Insert in format [{1}]
+
+DialogErrorHandlingStrategy.failureTitle=Failure
+DialogErrorHandlingStrategy.conversionFailureTitle=Conversion failed
+DialogErrorHandlingStrategy.validationFailureTitle=Validation failed
+DialogErrorHandlingStrategy.warningDialog.changeButton=Change
+DialogErrorHandlingStrategy.warningDialog.discardButton=Discard
+
+ErrorDialog.title=Error Message
+
+FontPicker.tooltip=Click to select font
+
+GridColorsEditorPanel.editorName=Grid colors
+GridColorsEditorPanel.evenRowColor=Even row color
+GridColorsEditorPanel.font=Font
+GridColorsEditorPanel.oddRowColor=Odd row color
+GridColorsEditorPanel.selectionColor=Selection Color
+
+HorizontalAlignmentPicker.center=Center
+HorizontalAlignmentPicker.left=Left
+HorizontalAlignmentPicker.right=Right
+
+LineStylePicker.dashdot=Dashdot
+LineStylePicker.dashdotdot=Dashdotdot
+LineStylePicker.dashed=Dashed
+LineStylePicker.dotted=Dotted
+LineStylePicker.solid=Solid
+
+MenuItemProviders.hideColumn=Hide column
+MenuItemProviders.showAllColumns=Show all columns
+MenuItemProviders.autoResizeColumn=Auto resize column
+MenuItemProviders.autoResizeRow=Auto resize row
+MenuItemProviders.autoResizeAllSelectedColumns=Auto resize all selected columns
+MenuItemProviders.chooseColumns=Choose columns
+MenuItemProviders.columnCategoriesChooser=Choose columns
+MenuItemProviders.editStyles=Edit styles
+MenuItemProviders.renameColumn=Rename column
+MenuItemProviders.createColumnGroup=Group selected columns
+MenuItemProviders.ungroupColumns=Ungroup selected columns
+MenuItemProviders.clearAllFilters=Clear all filters
+MenuItemProviders.toggleFilterRow=Toggle filter row
+MenuItemProviders.debugInfo=Debug info
+MenuItemProviders.debugInformation=Debug Information
+
+MultiCellEditDialog.decrease=Decrease by
+MultiCellEditDialog.increase=Increase by
+MultiCellEditDialog.adjust=Adjust by
+MultiCellEditDialog.set=Set
+MultiCellEditDialog.shellTitle=Enter new value
+
+NatExporter.exporting=Exporting.. please wait
+
+NumericDisplayConverter.failure=[{0}] is not a valid number.
+
+Printer.page=Page
+
+Search.find=Find
+Search.findButtonLabel=&Find
+Search.findLabel=F&ind
+Search.direction=Direction
+Search.forwardButtonLabel=F&orward
+Search.backwardButtonLabel=&Backward
+Search.options=Options
+Search.caseSensitiveButtonLabel=&Case Sensitive
+Search.wrapSearchButtonLabel=&Wrap Search
+Search.textNotFound=Text not found
+
+Unknown=Unknown
+
+VerticalAlignmentPicker.bottom=Bottom
+VerticalAlignmentPicker.middle=Middle
+VerticalAlignmentPicker.top=Top
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/resources/messages_de.properties b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/resources/messages_de.properties
new file mode 100644
index 0000000..5d2d605
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/resources/messages_de.properties
@@ -0,0 +1,102 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2012 Original authors and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Original authors and others - initial API and implementation
+#-------------------------------------------------------------------------------
+AbstractCellEditor.validationFailure=Fehler bei der Validierung des eingegebenen Wertes!
+
+AbstractColumnChooserDialog.doneButton=Fertig
+AbstractColumnChooserDialog.shellTitle=Spalten ausw\u00E4hlen
+
+AbstractStyleEditorDialog.okButton=OK
+AbstractStyleEditorDialog.clearButton=Zur\u00FCcksetzen
+AbstractStyleEditorDialog.clearButtonTooltip=Auf die Originalwerte zur\u00FCcksetzen
+AbstractStyleEditorDialog.cancelButton=Abbrechen
+
+BorderStyleEditorPanel.editorName=Rahmen
+BorderStyleEditorPanel.noBorder=Kein Rahmen
+BorderStyleEditorPanel.color=Farbe
+BorderStyleEditorPanel.lineStyle=Art
+BorderStyleEditorPanel.thickness=Breite
+
+BorderThicknessPicker.thin=D\u00FCnn
+BorderThicknessPicker.thick=Breit
+BorderThicknessPicker.veryThick=Sehr breit
+
+CellStyleEditorPanel.editorName=Zelleigenschaften
+CellStyleEditorPanel.backgroundColor=Hintergrundfarbe
+CellStyleEditorPanel.font=Schrift
+CellStyleEditorPanel.foregroundColor=Schriftfarbe
+CellStyleEditorPanel.horizontalAlignment=Horizontale Ausrichtung
+CellStyleEditorPanel.verticalAlignment=Vertikale Ausrichtung
+
+ColumnChooser.availableColumns=Verf\u00FCgbare Spalten
+ColumnChooser.selectedColumns=Ausgew\u00E4hlte Spalten
+
+ColumnEntry.0=Keine Bezeichnung
+
+ColumnRenameDialog.shellTitle=Spalte umbenennen
+
+ColumnStyleEditorDialog.border=Rahmen
+ColumnStyleEditorDialog.column=Spalte
+ColumnStyleEditorDialog.shellTitle=Zellen formatieren
+ColumnStyleEditorDialog.styling=Darstellung
+
+DefaultCharacterDisplayConverter.failure=[{0}] ist kein Character.
+DefaultDateDisplayConverter.failure=[{0}] ist kein g\u00FCltiges Datum. Verwenden Sie folgendes Format [{1}]
+
+DialogErrorHandlingStrategy.failureTitle=Fehler
+DialogErrorHandlingStrategy.conversionFailureTitle=Konvertierung fehlgeschlagen
+DialogErrorHandlingStrategy.validationFailureTitle=Validierung fehlgeschlagen
+DialogErrorHandlingStrategy.warningDialog.changeButton=\u00C4ndern
+DialogErrorHandlingStrategy.warningDialog.discardButton=Verwerfen
+
+FontPicker.tooltip=Anklicken um Schriftart zu w\u00E4hlen
+
+GridColorsEditorPanel.editorName=Gitterfarbe
+GridColorsEditorPanel.evenRowColor=gerade Zeilenfarbe
+GridColorsEditorPanel.font=Schriftart
+GridColorsEditorPanel.oddRowColor=ungerade Zeilenfarbe
+GridColorsEditorPanel.selectionColor=Selektionsfarbe
+
+HorizontalAlignmentPicker.center=Zentriert
+HorizontalAlignmentPicker.left=Linksb\u00FCndig
+HorizontalAlignmentPicker.right=Rechtsb\u00FCndig
+
+LineStylePicker.dashdot=Strich Punkt
+LineStylePicker.dashdotdot=Strich Punkt Punkt
+LineStylePicker.dashed=gestrichelt
+LineStylePicker.dotted=gepunktet
+LineStylePicker.solid=durchgezogen
+
+MenuItemProviders.hideColumn=Spalte ausblenden
+MenuItemProviders.showAllColumns=Alle Spalten anzeigen
+MenuItemProviders.autoResizeColumn=Automatische Spaltenbreite
+MenuItemProviders.autoResizeRow=Automatische Zeilenh\u00F6he
+MenuItemProviders.autoResizeAllSelectedColumns=Automatische Spaltenbreite für ausgew\u00E4hlte Spalten
+MenuItemProviders.chooseColumns=Spalten ausw\u00E4hlen
+MenuItemProviders.columnCategoriesChooser=Spalten ausw\u00E4hlen
+MenuItemProviders.editStyles=Zellen formatieren
+MenuItemProviders.renameColumn=Spalte umbenennen
+MenuItemProviders.createColumnGroup=Gruppierung erzeugen
+MenuItemProviders.ungroupColumns=Gruppierung aufheben
+MenuItemProviders.clearAllFilters=Alle Filter aufheben
+MenuItemProviders.toggleFilterRow=Filterzeile ein-/ausblenden
+MenuItemProviders.debugInfo=Debug info
+MenuItemProviders.debugInformation=Debug Information
+
+MultiCellEditDialog.decrease=Verringern um
+MultiCellEditDialog.increase=Erh\u00F6hen um
+MultiCellEditDialog.set=Setzen
+MultiCellEditDialog.shellTitle=Neuer Wert
+
+NumericDisplayConverter.failure=[{0}] ist keine Zahl.
+
+VerticalAlignmentPicker.bottom=Unten
+VerticalAlignmentPicker.middle=Zentriert
+VerticalAlignmentPicker.top=Oben
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/ConfigAttribute.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/ConfigAttribute.java
new file mode 100644
index 0000000..00be728
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/ConfigAttribute.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.style;
+
+/**
+ * TODO javadoc
+ *
+ * @param <T>
+ */
+public class ConfigAttribute<T> {
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/DisplayMode.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/DisplayMode.java
new file mode 100644
index 0000000..3ed4059
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/DisplayMode.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.style;
+
+/**
+ * The various modes the table can be under.
+ * <ol>
+ * <li>During normal display a cell is in NORMAL mode.</li>
+ * <li>If the contents of the cell are being edited, its in EDIT mode.</li>
+ * <li>If a cell has been selected, its in SELECT mode.</li>
+ * </ol>
+ *
+ * These modes are used to bind different settings to different modes.<br/>
+ * For example, a different style can be registered for a cell
+ * when it is in SELECT mode.
+ *
+ */
+public interface DisplayMode {
+
+ /**
+ * DisplayMode for rendering and handling in normal state.
+ */
+ public static final String NORMAL = "NORMAL"; //$NON-NLS-1$
+ /**
+ * DisplayMode for rendering and handling in selected state.
+ */
+ public static final String SELECT = "SELECT"; //$NON-NLS-1$
+ /**
+ * DisplayMode for rendering and handling in editing state.
+ */
+ public static final String EDIT = "EDIT"; //$NON-NLS-1$
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/IDisplayModeOrdering.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/IDisplayModeOrdering.java
new file mode 100644
index 0000000..af96e9c
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/IDisplayModeOrdering.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.style;
+
+import java.util.List;
+
+/**
+ * TODO javadoc
+ *
+ */
+public interface IDisplayModeOrdering {
+
+ /**
+ * TODO javadoc
+ *
+ * @param targetDisplayMode
+ * @return
+ */
+ public List<String> getDisplayModeOrdering(String targetDisplayMode);
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/IStyle.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/IStyle.java
new file mode 100644
index 0000000..2fa2e6b
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/IStyle.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.style;
+
+/**
+ * Used to store attributes reflecting a (usually display) style.
+ */
+public interface IStyle {
+
+ /**
+ * Returns the value for the specified {@link ConfigAttribute} configured for
+ * this style or <code>null</code> if there is no value configured.
+ * @param styleAttribute The {@link ConfigAttribute} whose value is requested.
+ * @return The value for the specified {@link ConfigAttribute} or <code>null</code>
+ * if this style doesn't contain a value for it.
+ */
+ public <T> T getAttributeValue(ConfigAttribute<T> styleAttribute);
+
+ /**
+ * Set the specified {@link ConfigAttribute} as a value of this style.
+ * @param styleAttribute The {@link ConfigAttribute} to set.
+ * @param value The value for the specified {@link ConfigAttribute}.
+ */
+ public <T> void setAttributeValue(ConfigAttribute<T> styleAttribute, T value);
+}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/Style.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/Style.java
new file mode 100644
index 0000000..2708b51
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/core/style/Style.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.core.style;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * Implementation of {@link IStyle} that stores the configuration values within a map.
+ */
+public class Style implements IStyle {
+
+ /**
+ * Map containing the style configurations.
+ */
+ private final Map<ConfigAttribute<?>, Object> styleAttributeValueMap = new HashMap<ConfigAttribute<?>, Object>();
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getAttributeValue(ConfigAttribute<T> styleAttribute) {
+ return (T) styleAttributeValueMap.get(styleAttribute);
+ }
+
+ @Override
+ public <T> void setAttributeValue(ConfigAttribute<T> styleAttribute, T value) {
+ styleAttributeValueMap.put(styleAttribute, value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder resultBuilder = new StringBuilder();
+ resultBuilder.append(this.getClass().getSimpleName() + ": "); //$NON-NLS-1$
+
+ Set<Entry<ConfigAttribute<?>, Object>> entrySet = styleAttributeValueMap.entrySet();
+
+ for (Entry<ConfigAttribute<?>, Object> entry : entrySet) {
+ resultBuilder.append(entry.getKey() + ": " + entry.getValue() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return resultBuilder.toString();
+ }
+
+}
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/.classpath b/org.eclipse.nebula.widgets.nattable.extension.e4/.classpath
index ad32c83..098194c 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/.classpath
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.nebula.widgets.nattable.extension.e4/.settings/org.eclipse.jdt.core.prefs
index c537b63..f42de36 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/META-INF/MANIFEST.MF b/org.eclipse.nebula.widgets.nattable.extension.e4/META-INF/MANIFEST.MF
index a5c7fd6..3bfa6c0 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/META-INF/MANIFEST.MF
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Name: NatTable Extension for Eclipse 4
Bundle-SymbolicName: org.eclipse.nebula.widgets.nattable.extension.e4
Bundle-Version: 1.0.0.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.eclipse.e4.core.contexts;bundle-version="1.1.0",
org.eclipse.e4.core.di;bundle-version="1.1.0",
org.eclipse.nebula.widgets.nattable.core;bundle-version="1.0.0"
diff --git a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/E4NatTableConfiguration.java b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/E4NatTableConfiguration.java
index fe9c5a3..f88dcc7 100644
--- a/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/E4NatTableConfiguration.java
+++ b/org.eclipse.nebula.widgets.nattable.extension.e4/src/org/eclipse/nebula/widgets/nattable/extension/e4/E4NatTableConfiguration.java
@@ -2,7 +2,7 @@
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
-import org.eclipse.nebula.widgets.nattable.core.NatTableConfiguration;
+import org.eclipse.nebula.widgets.nattable.core.INatTableConfiguration;
/**
* NatTableConfiguration that supports dependency injection with the Eclipse 4
@@ -13,7 +13,7 @@
* @author Dirk Fauth
*
*/
-public class E4NatTableConfiguration implements NatTableConfiguration {
+public class E4NatTableConfiguration implements INatTableConfiguration {
/**
* The NatTable local IEclipseContext used for injection of NatTable specific
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.swt/.classpath b/org.eclipse.nebula.widgets.nattable.renderer.swt/.classpath
index ad32c83..098194c 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.swt/.classpath
+++ b/org.eclipse.nebula.widgets.nattable.renderer.swt/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.swt/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.nebula.widgets.nattable.renderer.swt/.settings/org.eclipse.jdt.core.prefs
index c537b63..f42de36 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.swt/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.nebula.widgets.nattable.renderer.swt/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.swt/META-INF/MANIFEST.MF b/org.eclipse.nebula.widgets.nattable.renderer.swt/META-INF/MANIFEST.MF
index 8b076f1..2353a20 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.swt/META-INF/MANIFEST.MF
+++ b/org.eclipse.nebula.widgets.nattable.renderer.swt/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Name: NatTable SWT Renderer
Bundle-SymbolicName: org.eclipse.nebula.widgets.nattable.renderer.swt
Bundle-Version: 1.0.0.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: org.eclipse.swt,
org.eclipse.swt.events,
org.eclipse.swt.graphics,
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/GraphicsUtils.java b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/GraphicsUtils.java
new file mode 100644
index 0000000..e8eec35
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/GraphicsUtils.java
@@ -0,0 +1,324 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.nebula.widgets.nattable.renderer.swt;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * This class contains utility methods for drawing graphics
+ *
+ * @see <a href="http://java-gui.info/Apress-The.Definitive.Guide.to.SWT.and.JFace/8886final/LiB0095.html">GC snippets</a>
+ */
+public class GraphicsUtils {
+
+ /**
+ * Draws text vertically (rotates plus or minus 90 degrees). Uses the current
+ * font, color, and background.
+ * <dl>
+ * <dt><b>Styles: </b></dt>
+ * <dd>UP, DOWN</dd>
+ * </dl>
+ *
+ * @param string the text to draw
+ * @param x the x coordinate of the top left corner of the drawing rectangle
+ * @param y the y coordinate of the top left corner of the drawing rectangle
+ * @param gc the GC on which to draw the text
+ * @param style the style (SWT.UP or SWT.DOWN)
+ * <p>
+ * 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) {
+ drawVerticalText(string, x, y, false, false, true, gc, style);
+ }
+
+ /**
+ * Draws text vertically (rotates plus or minus 90 degrees). Uses the current
+ * font, color, and background.
+ * <dl>
+ * <dt><b>Styles: </b></dt>
+ * <dd>UP, DOWN</dd>
+ * </dl>
+ *
+ * @param string the text to draw
+ * @param x the x coordinate of the top left corner of the drawing rectangle
+ * @param y the y coordinate of the top left corner of the drawing rectangle
+ * @param underline set to <code>true</code> to render the text underlined
+ * @param strikethrough set to <code>true</code> to render the text strikethrough
+ * @param paintBackground set to <code>false</code> to render the background transparent.
+ * Needed for example to render the background with an image or gradient with another painter
+ * so the text drawn here should have no background.
+ * @param gc the GC on which to draw the text
+ * @param style the style (SWT.UP or SWT.DOWN)
+ * <p>
+ * Note: Only one of the style UP or DOWN may be specified.
+ * </p>
+ */
+ //TODO get style information for underline, strikethrough and paintbackground
+ //this should be somehow encapsulated in a more clean way so it is hidden from the interface call in IGraphicsContext
+ public static void drawVerticalText(String string, int x, int y,
+ boolean underline, boolean strikethrough, boolean paintBackground,
+ GC gc, int style) {
+ // Get the current display
+ Display display = Display.getCurrent();
+ if (display == null) 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
+ Image stringImage = new Image(display, pt.x, pt.y);
+
+ // Create a GC so we can draw the image
+ GC stringGc = new GC(stringImage);
+
+ // Set attributes from the original GC to the new GC
+ stringGc.setAntialias(gc.getAntialias());
+ stringGc.setTextAntialias(gc.getTextAntialias());
+ stringGc.setForeground(gc.getForeground());
+ stringGc.setBackground(gc.getBackground());
+ stringGc.setFont(gc.getFont());
+
+ // Fill the image with the specified background color
+ // to avoid white spaces if the text does not fill the
+ // whole image (e.g. on new lines)
+ stringGc.fillRectangle(0, 0, pt.x, pt.y);
+
+ // Draw the text onto the image
+ stringGc.drawText(string, 0, 0);
+
+ //draw underline and/or strikethrough
+ if (underline || strikethrough) {
+ //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 the baseline and the bottom
+ int underlineY = pt.y - (stringGc.getFontMetrics().getDescent() / 2);
+ stringGc.drawLine(
+ 0,
+ underlineY,
+ pt.x,
+ underlineY);
+ }
+
+ if (strikethrough) {
+ //y = start y of text + half of font height + ascent so lower case characters are
+ //also strikethrough
+ int strikeY = (pt.y / 2) + (stringGc.getFontMetrics().getLeading() / 2);
+ stringGc.drawLine(
+ 0,
+ strikeY,
+ pt.x,
+ strikeY);
+ }
+ }
+
+ // Draw the image vertically onto the original GC
+ drawVerticalImage(stringImage, x, y, paintBackground, gc, style);
+
+ // Dispose the new GC
+ stringGc.dispose();
+
+ // Dispose the image
+ stringImage.dispose();
+ }
+
+ /**
+ * Draws an image vertically (rotates plus or minus 90 degrees)
+ * <dl>
+ * <dt><b>Styles: </b></dt>
+ * <dd>UP, DOWN</dd>
+ * </dl>
+ *
+ * @param image the image to draw
+ * @param x the x coordinate of the top left corner of the drawing rectangle
+ * @param y the y coordinate of the top left corner of the drawing rectangle
+ * @param gc the GC on which to draw the image
+ * @param style the style (SWT.UP or SWT.DOWN)
+ * <p>
+ * Note: Only one of the style UP or DOWN may be specified.
+ * </p>
+ */
+ public static void drawVerticalImage(Image image, int x, int y, GC gc, int style) {
+ drawVerticalImage(image, x, y, true, gc, style);
+ }
+
+ /**
+ * Draws an image vertically (rotates plus or minus 90 degrees)
+ * <dl>
+ * <dt><b>Styles: </b></dt>
+ * <dd>UP, DOWN</dd>
+ * </dl>
+ *
+ * @param image the image to draw
+ * @param x the x coordinate of the top left corner of the drawing rectangle
+ * @param y the y coordinate of the top left corner of the drawing rectangle
+ * @param paintBackground set to <code>false</code> to render the background transparent.
+ * Needed for example to render the background with an image or gradient with another painter
+ * so the text drawn here should have no background.
+ * @param gc the GC on which to draw the image
+ * @param style the style (SWT.UP or SWT.DOWN)
+ * <p>
+ * Note: Only one of the style UP or DOWN may be specified.
+ * </p>
+ */
+ public static void drawVerticalImage(Image image, int x, int y, boolean paintBackground, GC gc, int style) {
+ // Get the current display
+ Display display = Display.getCurrent();
+ if (display == null) SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+
+ // Use the image's data to create a rotated image's data
+ ImageData sd = image.getImageData();
+ ImageData dd = new ImageData(sd.height, sd.width, sd.depth, sd.palette);
+ dd.transparentPixel = sd.transparentPixel;
+
+ //set the defined backgroundcolor to be transparent
+ if (!paintBackground) {
+ dd.transparentPixel = sd.palette.getPixel(gc.getBackground().getRGB());
+ }
+
+ // Determine which way to rotate, depending on up or down
+ boolean up = (style & SWT.UP) == SWT.UP;
+
+ // Run through the horizontal pixels
+ for (int sx = 0; sx < sd.width; sx++) {
+ // Run through the vertical pixels
+ for (int sy = 0; sy < sd.height; sy++) {
+ // Determine where to move pixel to in destination image data
+ int dx = up ? sy : sd.height - sy - 1;
+ int dy = up ? sd.width - sx - 1 : sx;
+ // Swap the x, y source data to y, x in the destination
+ dd.setPixel(dx, dy, sd.getPixel(sx, sy));
+ }
+ }
+
+ // Create the vertical image
+ Image vertical = new Image(display, dd);
+
+ // Draw the vertical image onto the original GC
+ gc.drawImage(vertical, x, y);
+
+ // Dispose the vertical image
+ vertical.dispose();
+ }
+
+ /**
+ * Creates an image containing the specified text, rotated either plus or minus
+ * 90 degrees.
+ * <dl>
+ * <dt><b>Styles: </b></dt>
+ * <dd>UP, DOWN</dd>
+ * </dl>
+ *
+ * @param text the text to rotate
+ * @param font the font to use
+ * @param foreground the color for the text
+ * @param background the background color
+ * @param style direction to rotate (up or down)
+ * @return Image
+ * <p>
+ * Note: Only one of the style UP or DOWN may be specified.
+ * </p>
+ */
+ public static Image createRotatedText(String text, Font font, Color foreground,
+ Color background, int style) {
+ // Get the current display
+ Display display = Display.getCurrent();
+ if (display == null) SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+
+ // Create a GC to calculate font's dimensions
+ GC gc = new GC(display);
+ gc.setFont(font);
+
+ // Determine string's dimensions
+// FontMetrics fm = gc.getFontMetrics();
+ Point pt = gc.textExtent(text);
+
+ // Dispose that gc
+ gc.dispose();
+
+ // Create an image the same size as the string
+ Image stringImage = new Image(display, pt.x, pt.y);
+ // Create a gc for the image
+ gc = new GC(stringImage);
+ gc.setFont(font);
+ gc.setForeground(foreground);
+ gc.setBackground(background);
+
+ // Draw the text onto the image
+ gc.drawText(text, 0, 0);
+
+ // Draw the image vertically onto the original GC
+ Image image = createRotatedImage(stringImage, style);
+
+ // Dispose the new GC
+ gc.dispose();
+
+ // Dispose the horizontal image
+ stringImage.dispose();
+
+ // Return the rotated image
+ return image;
+ }
+
+ /**
+ * Creates a rotated image (plus or minus 90 degrees)
+ * <dl>
+ * <dt><b>Styles: </b></dt>
+ * <dd>UP, DOWN</dd>
+ * </dl>
+ *
+ * @param image the image to rotate
+ * @param style direction to rotate (up or down)
+ * @return Image
+ * <p>
+ * Note: Only one of the style UP or DOWN may be specified.
+ * </p>
+ */
+ public static Image createRotatedImage(Image image, int style) {
+ // Get the current display
+ Display display = Display.getCurrent();
+ if (display == null) SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+
+ // Use the image's data to create a rotated image's data
+ ImageData sd = image.getImageData();
+ ImageData dd = new ImageData(sd.height, sd.width, sd.depth, sd.palette);
+
+ // Determine which way to rotate, depending on up or down
+ boolean up = (style & SWT.UP) == SWT.UP;
+
+ // Run through the horizontal pixels
+ for (int sx = 0; sx < sd.width; sx++) {
+ // Run through the vertical pixels
+ for (int sy = 0; sy < sd.height; sy++) {
+ // Determine where to move pixel to in destination image data
+ int dx = up ? sy : sd.height - sy - 1;
+ int dy = up ? sd.width - sx - 1 : sx;
+
+ // Swap the x, y source data to y, x in the destination
+ dd.setPixel(dx, dy, sd.getPixel(sx, sy));
+ }
+ }
+
+ // Create the vertical image
+ return new Image(display, dd);
+ }
+
+}
+
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTGraphicsContext.java b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTGraphicsContext.java
new file mode 100644
index 0000000..343d2b7
--- /dev/null
+++ b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTGraphicsContext.java
@@ -0,0 +1,72 @@
+package org.eclipse.nebula.widgets.nattable.renderer.swt;
+
+import org.eclipse.nebula.widgets.nattable.core.painter.IGraphicsContext;
+import org.eclipse.nebula.widgets.nattable.core.painter.Point;
+import org.eclipse.nebula.widgets.nattable.core.style.IStyle;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+
+/**
+ * Proxy implementation of {@link IGraphicsContext} to provide the drawing
+ * capabilities by {@link GC} so the NatTable can be painted using this.
+ *
+ * @author Dirk Fauth
+ *
+ */
+public class SWTGraphicsContext implements IGraphicsContext {
+
+ /**
+ * The SWT {@link GC} which is proxied by this implementation.
+ */
+ private final GC gc;
+
+ /**
+ * Create a new proxy instance for the specified {@link GC}.
+ * @param gc The SWT {@link GC} which is proxied by this implementation.
+ */
+ public SWTGraphicsContext(final GC gc) {
+ if (gc == null) {
+ throw new IllegalArgumentException("gc can not be null"); //$NON-NLS-1$
+ }
+ this.gc = gc;
+ }
+
+ @Override
+ public void initStyle(IStyle style) {
+ //TODO implement like AbstactTextPainter setupGCFromConfig()
+ //first store the current values within the gc so they can be restored afterwards
+ //then set the values extracted out of the style
+ //also underline, strikethrough and paintBG should be considered and stored in here
+ //as they are not part of text styling in the GC
+ }
+
+ @Override
+ public void resetStyle() {
+ //TODO implement reset
+ }
+
+ @Override
+ public void drawText(String text, int x, int y) {
+ this.gc.drawText(text, x, y, SWT.DRAW_TRANSPARENT | SWT.DRAW_DELIMITER);
+
+ //TODO draw underline and strikethrough in here instead of the TextPainter itself
+ }
+
+ @Override
+ public void drawVerticalText(String text, int x, int y, boolean up) {
+ GraphicsUtils.drawVerticalText(text, x, y, gc, up ? SWT.UP : SWT.DOWN);
+
+ //TODO draw underline and strikethrough in here, or let it do the GraphicsUtils
+ }
+
+ @Override
+ public void drawLine(int x1, int y1, int x2, int y2) {
+ this.gc.drawLine(x1, y1, x2, y2);
+ }
+
+ @Override
+ public Point calculateTextExtend(String text) {
+ org.eclipse.swt.graphics.Point swtPoint = this.gc.textExtent(text);
+ return new Point(swtPoint.x, swtPoint.y);
+ }
+}
diff --git a/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTNatTable.java b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTNatTable.java
index 8b90a9e..cb4df10 100644
--- a/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTNatTable.java
+++ b/org.eclipse.nebula.widgets.nattable.renderer.swt/src/org/eclipse/nebula/widgets/nattable/renderer/swt/SWTNatTable.java
@@ -1,9 +1,10 @@
package org.eclipse.nebula.widgets.nattable.renderer.swt;
import org.eclipse.nebula.widgets.nattable.core.NatTable;
-import org.eclipse.nebula.widgets.nattable.core.NatTableConfiguration;
+import org.eclipse.nebula.widgets.nattable.core.INatTableConfiguration;
import org.eclipse.nebula.widgets.nattable.core.layer.ILayerListener;
import org.eclipse.nebula.widgets.nattable.core.layer.event.ILayerEvent;
+import org.eclipse.nebula.widgets.nattable.core.painter.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
@@ -43,7 +44,7 @@
* @param parent A composite control which will be the parent of the new instance (cannot be null).
* @param configuration The configuration that will be used to build up the new NatTable instance.
*/
- public SWTNatTable(Composite parent, NatTableConfiguration configuration) {
+ public SWTNatTable(Composite parent, INatTableConfiguration configuration) {
this(parent, configuration, DEFAULT_STYLE_OPTIONS);
}
@@ -64,7 +65,7 @@
* @param configuration The configuration that will be used to build up the NatTable instance.
* @param style The style of control to construct.
*/
- public SWTNatTable(Composite parent, NatTableConfiguration configuration, int style) {
+ public SWTNatTable(Composite parent, INatTableConfiguration configuration, int style) {
this(parent, new NatTable(configuration), style);
}
@@ -124,11 +125,11 @@
@Override
public void paintControl(final PaintEvent event) {
- paintNatTable(event);
+ model.paintNatTable(
+ new SWTGraphicsContext(event.gc),
+ new Rectangle(event.x, event.y, event.width, event.height));
}
- private void paintNatTable(final PaintEvent event) {
- }
//TODO should this be something that is called by the presentation model, firing an event that is catched here?
public void updateResize() {