Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/AbstractProrCellRenderer.java24
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGrid.java43
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrAgileGridViewer.java43
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrCellRenderer.java2
-rw-r--r--org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLayoutAdvisor.java2
5 files changed, 110 insertions, 4 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 bd29995d..aec14dc8 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
@@ -106,7 +106,7 @@ public class AbstractProrCellRenderer extends TextCellRenderer {
Color hBorderColor = COLOR_LINE_LIGHTGRAY;
if (agileGrid instanceof ProrAgileGrid){
- if (((ProrAgileGrid)agileGrid).dndHoverCell != null && row == ((ProrAgileGrid)agileGrid).dndHoverCell.row){
+ if (((ProrAgileGrid)agileGrid).dndHoverCell != null && row == ((ProrAgileGrid)agileGrid).dndHoverCell.row && ((ProrAgileGrid)agileGrid).dndHoverCellMode == 0){
hBorderColor = COLOR_LINE_DARKGRAY;
}
}
@@ -123,5 +123,27 @@ public class AbstractProrCellRenderer extends TextCellRenderer {
drawDefaultCellLine(gc, rect, vBorderColor, hBorderColor);
}
+
+ 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) {
+ this.background = COLOR_BGROWSELECTION;
+ }
+ }
+
+ // initial color for current cell.
+ initialColor(row, col);
+
+ // Clear background.
+ clearCellContentRect(gc, rect);
+
+ // draw text and image in the given area.
+ doDrawCellContent(gc, rect, row, col);
+ }
}
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 4cc30329..f2212b7b 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
@@ -12,6 +12,7 @@ package org.eclipse.rmf.pror.reqif10.editor.agilegrid;
import org.agilemore.agilegrid.AgileGrid;
import org.agilemore.agilegrid.Cell;
+import org.agilemore.agilegrid.ILayoutAdvisor;
import org.eclipse.swt.widgets.Composite;
/**
@@ -24,6 +25,8 @@ import org.eclipse.swt.widgets.Composite;
public class ProrAgileGrid extends AgileGrid {
protected Cell dndHoverCell;
+ //TODO use constants for Hover Mode
+ protected int dndHoverCellMode;
public ProrAgileGrid(Composite parent, int style) {
super(parent, style);
@@ -44,4 +47,44 @@ public class ProrAgileGrid extends AgileGrid {
// });
}
+ public int getYForRow(int row) {
+ if (row < 0 || row > topRow + getRowsVisible() - 1) {
+ return Integer.MIN_VALUE;
+ }
+
+ ILayoutAdvisor layoutAdvisor = getLayoutAdvisor();
+ int fixedRowCount = layoutAdvisor.getFixedRowCount();
+
+ if (row < fixedRowCount){
+ return Integer.MIN_VALUE;
+ }
+
+
+ int y = getLinePixels();
+
+ if (layoutAdvisor.isTopHeaderVisible()) {
+ y += layoutAdvisor.getTopHeaderHeight();
+ y += getLinePixels();
+ }
+
+ for (int i = 0; i < fixedRowCount; i++) {
+ if (row == i) {
+ return y;
+ }
+ y += layoutAdvisor.getRowHeight(i);
+ y += getLinePixels();
+ }
+
+ for (int i = topRow; i <= topRow + getRowsVisible() - 1; i++) {
+ if (row == i) {
+ return y;
+ }
+ y += layoutAdvisor.getRowHeight(i);
+ y += getLinePixels();
+ }
+
+
+ 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 0ea75208..61cc73ec 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,6 +74,7 @@ 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;
@@ -548,6 +549,13 @@ public class ProrAgileGridViewer extends Viewer {
}
super.dragStart(event);
}
+
+ @Override
+ public void dragFinished(DragSourceEvent event) {
+ super.dragFinished(event);
+ agileGrid.dndHoverCell = null;
+ agileGrid.redraw();
+ }
});
// Modified to make the EMF-Based Drag and Drop work.
@@ -571,15 +579,44 @@ public class ProrAgileGridViewer extends Viewer {
Object target = contentProvider.getProrRow(cell.row).element;
if (target instanceof SpecHierarchy) {
dragTarget = (SpecHierarchy) target;
- agileGrid.dndHoverCell = cell;
+ float location = getLocation(e);
+ if (location == 0.5){
+ agileGrid.dndHoverCell = cell;
+ agileGrid.dndHoverCellMode = 1;
+ }
+ 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;
+ }
+ if (location == 1.0){
+ agileGrid.dndHoverCell = cell;
+ agileGrid.dndHoverCellMode = 0;
+ }
agileGrid.redraw();
}
}
@Override
protected float getLocation(DropTargetEvent event) {
- //return 1.0F;
- return super.getLocation(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 (location < 0.3){
+ return 0.0F;
+ }else if(location <= 0.7){
+ return 0.5F;
+ }else{
+ return 1.0F;
+ }
+
+
}
});
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrCellRenderer.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrCellRenderer.java
index 304b4acc..bfbba956 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrCellRenderer.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrCellRenderer.java
@@ -11,6 +11,7 @@
package org.eclipse.rmf.pror.reqif10.editor.agilegrid;
import org.agilemore.agilegrid.AgileGrid;
+import org.agilemore.agilegrid.Cell;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
@@ -123,4 +124,5 @@ public class ProrCellRenderer extends AbstractProrCellRenderer {
}
}
+
}
diff --git a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLayoutAdvisor.java b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLayoutAdvisor.java
index cdb5757d..977b903a 100644
--- a/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLayoutAdvisor.java
+++ b/org.eclipse.rmf.pror.reqif10.editor/src/org/eclipse/rmf/pror/reqif10/editor/agilegrid/ProrLayoutAdvisor.java
@@ -13,6 +13,7 @@ package org.eclipse.rmf.pror.reqif10.editor.agilegrid;
import java.util.HashMap;
import org.agilemore.agilegrid.AgileGrid;
+import org.agilemore.agilegrid.Cell;
import org.agilemore.agilegrid.DefaultLayoutAdvisor;
import org.agilemore.agilegrid.ICellRenderer;
import org.eclipse.rmf.reqif10.SpecHierarchy;
@@ -87,6 +88,7 @@ public class ProrLayoutAdvisor extends DefaultLayoutAdvisor {
agileGrid.redraw();
}
}
+
@Override
public int getRowHeight(int row) {

Back to the top