Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.rmf.pror.reqif10.editor')
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/AbstractProrCellRenderer.java20
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGrid.java13
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGridViewer.java34
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLinkCellRenderer.java9
4 files changed, 45 insertions, 31 deletions
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/AbstractProrCellRenderer.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/AbstractProrCellRenderer.java
index aec14dc8..1973a21b 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/AbstractProrCellRenderer.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/AbstractProrCellRenderer.java
@@ -33,7 +33,7 @@ import org.eclipse.swt.graphics.Rectangle;
/**
* @author Lukas Ladenberger
- *
+ * @author Ingo Weigelt
*/
public class AbstractProrCellRenderer extends TextCellRenderer {
@@ -46,6 +46,10 @@ public class AbstractProrCellRenderer extends TextCellRenderer {
super(agileGrid);
this.adapterFactory = adapterFactory;
}
+
+ public AbstractProrCellRenderer(AgileGrid agileGrid) {
+ this(agileGrid, null);
+ }
protected int doDrawCellContentDefault(GC gc, Rectangle rect, Object value) {
String stringValue;
@@ -105,8 +109,11 @@ public class AbstractProrCellRenderer extends TextCellRenderer {
Color vBorderColor = COLOR_LINE_LIGHTGRAY;
Color hBorderColor = COLOR_LINE_LIGHTGRAY;
- if (agileGrid instanceof ProrAgileGrid){
- if (((ProrAgileGrid)agileGrid).dndHoverCell != null && row == ((ProrAgileGrid)agileGrid).dndHoverCell.row && ((ProrAgileGrid)agileGrid).dndHoverCellMode == 0){
+ if (agileGrid instanceof ProrAgileGrid) {
+ ProrAgileGrid grid = (ProrAgileGrid) agileGrid;
+ if (grid.dndHoverCell != null
+ && row == grid.dndHoverCell.row
+ && grid.dndHoverDropMode == ProrAgileGrid.DND_DROP_AS_SIBLING) {
hBorderColor = COLOR_LINE_DARKGRAY;
}
}
@@ -124,14 +131,15 @@ public class AbstractProrCellRenderer extends TextCellRenderer {
drawDefaultCellLine(gc, rect, vBorderColor, hBorderColor);
}
+ @Override
protected void drawCellContent(GC gc, Rectangle rect, int row, int col) {
this.foreground = this.getDefaultForeground();
this.background = this.getDefaultBackground();
if (agileGrid instanceof ProrAgileGrid) {
- if (((ProrAgileGrid) agileGrid).dndHoverCell != null
- && row == ((ProrAgileGrid) agileGrid).dndHoverCell.row
- && ((ProrAgileGrid) agileGrid).dndHoverCellMode == 1) {
+ ProrAgileGrid grid = (ProrAgileGrid) agileGrid;
+ if (grid.dndHoverCell != null && row == grid.dndHoverCell.row
+ && grid.dndHoverDropMode == ProrAgileGrid.DND_DROP_AS_CHILD) {
this.background = COLOR_BGROWSELECTION;
}
}
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGrid.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGrid.java
index f2212b7b..5bb862cc 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGrid.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGrid.java
@@ -24,9 +24,12 @@ import org.eclipse.swt.widgets.Composite;
*/
public class ProrAgileGrid extends AgileGrid {
+ public static final int DND_DROP_AS_SIBLING = 0;
+ public static final int DND_DROP_AS_CHILD = 1;
+
protected Cell dndHoverCell;
- //TODO use constants for Hover Mode
- protected int dndHoverCellMode;
+ protected int dndHoverDropMode;
+
public ProrAgileGrid(Composite parent, int style) {
super(parent, style);
@@ -47,6 +50,12 @@ public class ProrAgileGrid extends AgileGrid {
// });
}
+ /**
+ * Returns the upper y-coordinate of a row.
+ * Returns a negative value id the row does not exist or is invisible
+ * @param row
+ * @return
+ */
public int getYForRow(int row) {
if (row < 0 || row > topRow + getRowsVisible() - 1) {
return Integer.MIN_VALUE;
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGridViewer.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGridViewer.java
index 61cc73ec..f7ba5f2c 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGridViewer.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGridViewer.java
@@ -74,7 +74,6 @@ import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
@@ -582,17 +581,16 @@ public class ProrAgileGridViewer extends Viewer {
float location = getLocation(e);
if (location == 0.5){
agileGrid.dndHoverCell = cell;
- agileGrid.dndHoverCellMode = 1;
+ agileGrid.dndHoverDropMode = ProrAgileGrid.DND_DROP_AS_CHILD;
}
if (location == 0.0){
- //Cell prevCell = agileGrid.getCell(pos.x, pos.y-1);
Cell prevCell = agileGrid.getNeighbor(cell, AgileGrid.ABOVE, true);
agileGrid.dndHoverCell = prevCell;
- agileGrid.dndHoverCellMode = 0;
+ agileGrid.dndHoverDropMode = ProrAgileGrid.DND_DROP_AS_SIBLING;
}
if (location == 1.0){
agileGrid.dndHoverCell = cell;
- agileGrid.dndHoverCellMode = 0;
+ agileGrid.dndHoverDropMode = ProrAgileGrid.DND_DROP_AS_SIBLING;
}
agileGrid.redraw();
}
@@ -602,20 +600,26 @@ public class ProrAgileGridViewer extends Viewer {
protected float getLocation(DropTargetEvent event) {
Point pos = agileGrid.toControl(event.x, event.y);
Cell cell = agileGrid.getCell(pos.x, pos.y);
- int rowHeight = ((ProrLayoutAdvisor) agileGrid.getLayoutAdvisor()).getRowHeight(cell.row);
- int y = agileGrid.getYForRow(cell.row);
- int mouseY = pos.y - y;
- float location = (float)mouseY / (float)rowHeight;
+ if (agileGrid.getLayoutAdvisor() instanceof ProrLayoutAdvisor) {
+ ProrLayoutAdvisor layoutAdvisor = (ProrLayoutAdvisor) agileGrid.getLayoutAdvisor();
- if (location < 0.3){
- return 0.0F;
- }else if(location <= 0.7){
- return 0.5F;
- }else{
- return 1.0F;
+ int rowHeight = layoutAdvisor.getRowHeight(cell.row);
+ int y = agileGrid.getYForRow(cell.row);
+ int mouseY = pos.y - y;
+
+ float location = (float)mouseY / (float)rowHeight;
+
+ if (location < 0.3){
+ return 0.0F;
+ }else if(location <= 0.7){
+ return 0.5F;
+ }else{
+ return 1.0F;
+ }
}
+ return 1.0F;
}
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLinkCellRenderer.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLinkCellRenderer.java
index 25d89ba4..9aa19c3b 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLinkCellRenderer.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLinkCellRenderer.java
@@ -29,7 +29,7 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
-public class ProrLinkCellRenderer extends TextCellRenderer {
+public class ProrLinkCellRenderer extends AbstractProrCellRenderer {
private Set<SpecRelation> incoming;
private Set<SpecRelation> outgoing;
@@ -100,12 +100,5 @@ public class ProrLinkCellRenderer extends TextCellRenderer {
}
}
- // Workaround: Upon closing a UIEditor and reopening a new one, the color got
- // disposed. No idea why. This is a workaround.
- protected void initialColor(int row, int col) {
- if (agileGrid.isCellSelected(row, col)) {
- background = SWTResourceManager.getColor(223, 227, 237);
- }
- }
}

Back to the top