Browse Source

Pull request #7953: REPORT-66884&REPORT-66886&REPORT-66827&REPORT-66947&REPORT-66946&CHART-22936 修正拖拽组件时候备份组件的时机

Merge in DESIGN/design from ~FANGLEI/design:release/11.0 to release/11.0

* commit '94679a83332eedf6bf71cb8286212ebd51ea3b49':
  CHART-22936 图表切换控件标题设置公式无效
  REPORT-66947
  REPORT-66827&REPORT-66947&REPORT-66946
  REPORT-66886 鼠标悬浮n秒后释放,没有将组件放入tab中
  REPORT-66884
  REPORT-66884 修正拖拽组件时候备份组件的时机
bugfix/11.0
fanglei 3 years ago
parent
commit
f3d816ee49
  1. 14
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java
  2. 14
      designer-form/src/main/java/com/fr/design/designer/beans/events/AddingWidgetListenerTable.java
  3. 10
      designer-form/src/main/java/com/fr/design/designer/beans/models/DraggingModel.java
  4. 2
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  5. 6
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  6. 38
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  7. 17
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  8. 7
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java

14
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java

@ -10,6 +10,7 @@ import com.fr.chart.base.AttrChangeConfig;
import com.fr.chart.base.AttrChangeType;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.SwitchTitle;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.foldablepane.UIExpandablePane;
@ -238,13 +239,14 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
private void populateSwitchTitlePane(int chartIndex, ChartCollection collection) {
Chart chart = collection.getChart(chartIndex, Chart.class);
Object switchTitle = chart.getSwitchTitle();
SwitchTitle switchTitle = chart.getSwitchTitle();
Object content = switchTitle.getContent();
String result = StringUtils.EMPTY;
if (switchTitle != null) {
if (switchTitle instanceof BaseFormula) {
result = ((BaseFormula) switchTitle).getContent();
if (content != null) {
if (content instanceof BaseFormula) {
result = ((BaseFormula) content).getContent();
} else {
result = Utils.objectToString(switchTitle);
result = Utils.objectToString(content);
}
}
TinyFormulaPane title = new TinyFormulaPane();
@ -345,7 +347,7 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
} else {
titleObj = titleString;
}
collection.getChart(i, Chart.class).setSwitchTitle(titleObj);
collection.getChart(i, Chart.class).setSwitchTitle(new SwitchTitle(titleObj));
}
}

14
designer-form/src/main/java/com/fr/design/designer/beans/events/AddingWidgetListenerTable.java

@ -28,23 +28,13 @@ public class AddingWidgetListenerTable {
public void beforeAdded() {
for (final AddingWidgetListener listener : listeners) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
listener.beforeAdded();
}
});
listener.beforeAdded();
}
}
public void afterAdded(boolean addResult) {
for (final AddingWidgetListener listener : listeners) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
listener.afterAdded(addResult);
}
});
listener.afterAdded(addResult);
}
}

10
designer-form/src/main/java/com/fr/design/designer/beans/models/DraggingModel.java

@ -14,7 +14,6 @@ public class DraggingModel {
private MouseEvent currentDragEvent;
private int creatorLeftTopX = -999; // 隐藏
private int creatorLeftTopY = -999; // 隐藏
private boolean dragNewWidget; // 是否正在拖拽一个新的组件下来
public DraggingModel() {
@ -40,11 +39,6 @@ public class DraggingModel {
return this;
}
public DraggingModel dragNewWidget(boolean dragNewWidget) {
this.dragNewWidget = dragNewWidget;
return this;
}
public FormDesigner getDesigner() {
return designer;
}
@ -79,10 +73,6 @@ public class DraggingModel {
return creatorLeftTopY;
}
public boolean isDragNewWidget() {
return dragNewWidget;
}
public void moveTo(int x, int y) {
XLayoutContainer container = designer.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter();

2
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -459,13 +459,11 @@ public class EditingMouseListener extends MouseInputAdapter {
if (isSelectionDrag()) {
stateModel.changeSelection(e);
return;
}
// 调整大小这边单独提出来,不跟后面拖组件混在一起,实在不好管理
if (stateModel.isDraggingSize()) {
stateModel.dragging(e);
return;
}
designer.startDraggingFormWidget(lastXCreator, lastPressEvent, e);

6
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -264,11 +264,7 @@ public class FormCreatorDropTarget extends DropTarget {
Point loc = dtde.getLocation();
int x = designer.getRelativeX(loc.x);
int y = designer.getRelativeY(loc.y);
if (model.isDragNewWidget()) {
designer.addNewWidget(creator, x, y);
} else {
designer.changeWidgetPlace(creator, x, y);
}
designer.addWidgetToForm(creator, x, y);
// 放到事件末尾执行
SwingUtilities.invokeLater(new Runnable() {
@Override

38
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1252,12 +1252,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return;
}
instantiateCreator(xCreator);
draggingModel = new DraggingModel()
.designer(this)
.creator(xCreator)
.startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent)
.dragNewWidget(true);
.currentDragEvent(currentDragEvent);
this.setDropTarget(new FormCreatorDropTarget(this, xCreator));
repaint();
}
@ -1273,12 +1273,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
if (currentDragEvent == null || this.getDropTarget() != null) {
return;
}
backUpCreator(xCreator);
draggingModel = new DraggingModel()
.designer(this)
.creator(xCreator)
.startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent)
.dragNewWidget(false);
.currentDragEvent(currentDragEvent);
XLayoutContainer container = this.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter();
adapter.dragging(this.getDraggingModel());
@ -1990,27 +1990,25 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return spacingLineDrawer;
}
private void instantiateCreator(XCreator creator) {
ModelUtil.renameWidgetName(this.getTarget(), creator);
creator.addNotify();
ComponentAdapter adapter = new CompositeComponentAdapter(this, creator);
adapter.initialize();
creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
}
public void instantiateCreator(XCreator creator) {
if (creator != null) {
ModelUtil.renameWidgetName(this.getTarget(), creator);
creator.addNotify();
public void addNewWidget(XCreator creator, int x, int y) {
instantiateCreator(creator);
addWidgetToForm(creator, x, y);
ComponentAdapter adapter = new CompositeComponentAdapter(this, creator);
adapter.initialize();
creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
}
}
public void changeWidgetPlace(XCreator creator, int x, int y) {
creator.backupCurrentSize();
creator.backupParent();
addWidgetToForm(creator, x, y);
public void backUpCreator(XCreator creator) {
if (creator != null) {
creator.backupCurrentSize();
creator.backupParent();
}
}
private void addWidgetToForm(XCreator creator, int x, int y) {
public void addWidgetToForm(XCreator creator, int x, int y) {
if(creator == null) {
return;
}

17
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -116,8 +116,8 @@ public class FormDesignerUI extends ComponentUI {
designer.getPainter().paint(g, designer.getArea().getHorizontalValue(),
designer.getArea().getVerticalValue() + designer.getParaHeight());
}
DraggingModel draggingModel = designer.getDraggingModel();
if (draggingModel != null && draggingModel.getCreator() != null) {
if (needPaintDraggingBean()) {
// 当前正在添加的组件
paintDraggingBean(g);
}
@ -217,6 +217,19 @@ public class FormDesignerUI extends ComponentUI {
ComponentUtils.resetBuffer(dbcomponents);
}
private boolean needPaintDraggingBean() {
DraggingModel draggingModel = designer.getDraggingModel();
if (draggingModel == null || draggingModel.getCreator() == null) {
return false;
}
XCreator creator = draggingModel.getCreator();
int leftTopX = draggingModel.getCreatorLeftTopX();
int leftTopY = draggingModel.getCreatorLeftTopY();
return leftTopX + creator.getWidth() > 0 && leftTopY + creator.getHeight() > 0;
}
private void paintAuthorityCreator(Graphics2D g2d, Rectangle creatorBounds) {
back_or_selection_rect.setRect(creatorBounds.getX(), creatorBounds.getY(),

7
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java

@ -130,12 +130,13 @@ public class GuideCreateUtils {
return;
}
FormDesigner designer = GuideCreateUtils.getFormDesigner();
designer.getSelectionModel().selectACreator(xLayoutContainer);
if (dragNewComponent) {
designer.addNewWidget(xCreator, xLayoutContainer.getX(), xLayoutContainer.getY());
designer.instantiateCreator(xCreator);
} else {
designer.changeWidgetPlace(xCreator, xLayoutContainer.getX(), xLayoutContainer.getY());
designer.backUpCreator(xCreator);
}
designer.getSelectionModel().selectACreator(xLayoutContainer);
designer.addWidgetToForm(xCreator, xLayoutContainer.getX(), xLayoutContainer.getY());
designer.getSelectionModel().selectACreator(xCreator);
}

Loading…
Cancel
Save