Browse Source

REPORT-54998 设计器单元格右下角‘十’拖动,向右向下正常,向左无法递减,向上无法操作

zheng-1641779399395
方磊 4 years ago
parent
commit
b8f32bf0a0
  1. 2
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java
  2. 128
      designer-realize/src/main/java/com/fr/grid/IntelliElements.java

2
designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

@ -474,7 +474,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
grid.getDragRectangle().y = cellRectangle.y;
grid.getDragRectangle().height = cellRectangle.height;
} else {
grid.getDragRectangle().y = cellRectangle.y;
grid.getDragRectangle().y = selectedCellPoint.getRow();
grid.getDragRectangle().height = cellRectangle.y - selectedCellPoint.getRow() + cellRectangle.height;
}
}

128
designer-realize/src/main/java/com/fr/grid/IntelliElements.java

@ -183,42 +183,40 @@ public class IntelliElements {
}
public void doIntelliAction() {
for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex++) {
for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex++) {
TemplateCellElement sourceCellElement = getSourceCellElementByColumnRow(colIndex, rowIndex);
public abstract void doIntelliAction();
if (sourceCellElement == null) {
sourceCellElement = new DefaultTemplateCellElement();
}
TemplateCellElement newCellElement = new DefaultTemplateCellElement(colIndex, rowIndex);
applyStyle(newCellElement, sourceCellElement);//style
if (sourceCellElement.getValue() instanceof DSColumn) {
try{
DSColumn dsColumn = (DSColumn)((DSColumn) sourceCellElement.getValue()).clone();
newCellElement.setValue(dsColumn);
}catch (CloneNotSupportedException e){
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
newCellElement.setCellExpandAttr(sourceCellElement.getCellExpandAttr());
} else if (sourceCellElement.getValue() instanceof Number) {
newCellElement.setValue(processNumber((Number) sourceCellElement.getValue()));
} else if (sourceCellElement.getValue() instanceof BaseFormula) {
BaseFormula formula = (BaseFormula) sourceCellElement.getValue();
formula = this.generateSimpleFormula(formula, 1);
newCellElement.setValue(formula);
} else {
try {
//richer:不改变原单元格
newCellElement.setValue(BaseUtils.cloneObject(sourceCellElement.getValue()));
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public void expandCellValue(int colIndex, int rowIndex) {
TemplateCellElement sourceCellElement = getSourceCellElementByColumnRow(colIndex, rowIndex);
report.addCellElement(newCellElement);
if (sourceCellElement == null) {
sourceCellElement = new DefaultTemplateCellElement();
}
TemplateCellElement newCellElement = new DefaultTemplateCellElement(colIndex, rowIndex);
applyStyle(newCellElement, sourceCellElement);//style
if (sourceCellElement.getValue() instanceof DSColumn) {
try{
DSColumn dsColumn = (DSColumn)((DSColumn) sourceCellElement.getValue()).clone();
newCellElement.setValue(dsColumn);
}catch (CloneNotSupportedException e){
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
newCellElement.setCellExpandAttr(sourceCellElement.getCellExpandAttr());
} else if (sourceCellElement.getValue() instanceof Number) {
newCellElement.setValue(processNumber((Number) sourceCellElement.getValue()));
} else if (sourceCellElement.getValue() instanceof BaseFormula) {
BaseFormula formula = (BaseFormula) sourceCellElement.getValue();
formula = this.generateSimpleFormula(formula, 1);
newCellElement.setValue(formula);
} else {
try {
//richer:不改变原单元格
newCellElement.setValue(BaseUtils.cloneObject(sourceCellElement.getValue()));
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
report.addCellElement(newCellElement);
}
protected abstract int getStartColumnIndex();
@ -328,6 +326,15 @@ public class IntelliElements {
};
}
@Override
public void doIntelliAction() {
for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex ++) {
for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex ++) {
expandCellValue(colIndex, rowIndex);
}
}
}
@Override
public boolean havetoModify() {
return IntelliElements.this.dragCellRectangle.width > IntelliElements.this.oldCellRectangle.width;
@ -397,34 +404,43 @@ public class IntelliElements {
};
}
@Override
public void doIntelliAction() {
for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex > colEnd; colIndex --) {
for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex ++) {
expandCellValue(colIndex, rowIndex);
}
}
}
@Override
public boolean havetoModify() {
return true;
}
@Override
public int getStartRowIndex() {
public int getStartRowIndex() {
return IntelliElements.this.oldCellRectangle.y;
}
@Override
public int getEndRowIndex() {
public int getEndRowIndex() {
return IntelliElements.this.oldCellRectangle.y + IntelliElements.this.oldCellRectangle.height;
}
@Override
public int getStartColumnIndex() {
return IntelliElements.this.dragCellRectangle.x;
public int getStartColumnIndex() {
return IntelliElements.this.oldCellRectangle.x - 1;
}
@Override
public int getEndColumnIndex() {
return IntelliElements.this.oldCellRectangle.x;
public int getEndColumnIndex() {
return IntelliElements.this.dragCellRectangle.x - 1;
}
@Override
public TemplateCellElement getSourceCellElementByColumnRow(int columnIndex, int rowIndex) {
return report.getTemplateCellElement(IntelliElements.this.oldCellRectangle.x + (columnIndex - IntelliElements.this.dragCellRectangle.x) % (IntelliElements.this.oldCellRectangle.width), rowIndex);
return report.getTemplateCellElement(columnIndex + IntelliElements.this.oldCellRectangle.width, rowIndex);
}
@Override
@ -465,6 +481,15 @@ public class IntelliElements {
};
}
@Override
public void doIntelliAction() {
for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex ++) {
for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex < rowEnd; rowIndex ++) {
expandCellValue(colIndex, rowIndex);
}
}
}
@Override
public boolean havetoModify() {
return IntelliElements.this.dragCellRectangle.height > IntelliElements.this.oldCellRectangle.height;
@ -534,33 +559,42 @@ public class IntelliElements {
}
@Override
public boolean havetoModify() {
public void doIntelliAction() {
for (int colIndex = getStartColumnIndex(), colEnd = getEndColumnIndex(); colIndex < colEnd; colIndex++) {
for (int rowIndex = getStartRowIndex(), rowEnd = getEndRowIndex(); rowIndex > rowEnd; rowIndex--) {
expandCellValue(colIndex, rowIndex);
}
}
}
@Override
public boolean havetoModify() {
return true;
}
@Override
public int getStartRowIndex() {
return IntelliElements.this.dragCellRectangle.y;
public int getStartRowIndex() {
return IntelliElements.this.oldCellRectangle.y - 1;
}
@Override
public int getEndRowIndex() {
return IntelliElements.this.oldCellRectangle.y;
public int getEndRowIndex() {
return IntelliElements.this.dragCellRectangle.y - 1;
}
@Override
public int getStartColumnIndex() {
public int getStartColumnIndex() {
return IntelliElements.this.oldCellRectangle.x;
}
@Override
public int getEndColumnIndex() {
public int getEndColumnIndex() {
return IntelliElements.this.oldCellRectangle.x + IntelliElements.this.oldCellRectangle.width;
}
@Override
public TemplateCellElement getSourceCellElementByColumnRow(int columnIndex, int rowIndex) {
return report.getTemplateCellElement(columnIndex, IntelliElements.this.oldCellRectangle.y + (rowIndex - IntelliElements.this.dragCellRectangle.y) % (IntelliElements.this.oldCellRectangle.height));
return report.getTemplateCellElement(columnIndex, rowIndex + IntelliElements.this.oldCellRectangle.height);
}
@Override

Loading…
Cancel
Save