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

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

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

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 MouseEvent currentDragEvent;
private int creatorLeftTopX = -999; // 隐藏 private int creatorLeftTopX = -999; // 隐藏
private int creatorLeftTopY = -999; // 隐藏 private int creatorLeftTopY = -999; // 隐藏
private boolean dragNewWidget; // 是否正在拖拽一个新的组件下来
public DraggingModel() { public DraggingModel() {
@ -40,11 +39,6 @@ public class DraggingModel {
return this; return this;
} }
public DraggingModel dragNewWidget(boolean dragNewWidget) {
this.dragNewWidget = dragNewWidget;
return this;
}
public FormDesigner getDesigner() { public FormDesigner getDesigner() {
return designer; return designer;
} }
@ -79,10 +73,6 @@ public class DraggingModel {
return creatorLeftTopY; return creatorLeftTopY;
} }
public boolean isDragNewWidget() {
return dragNewWidget;
}
public void moveTo(int x, int y) { public void moveTo(int x, int y) {
XLayoutContainer container = designer.getDraggingHotspotLayout(); XLayoutContainer container = designer.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter(); 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()) { if (isSelectionDrag()) {
stateModel.changeSelection(e); stateModel.changeSelection(e);
return;
} }
// 调整大小这边单独提出来,不跟后面拖组件混在一起,实在不好管理 // 调整大小这边单独提出来,不跟后面拖组件混在一起,实在不好管理
if (stateModel.isDraggingSize()) { if (stateModel.isDraggingSize()) {
stateModel.dragging(e); stateModel.dragging(e);
return;
} }
designer.startDraggingFormWidget(lastXCreator, lastPressEvent, e); 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(); Point loc = dtde.getLocation();
int x = designer.getRelativeX(loc.x); int x = designer.getRelativeX(loc.x);
int y = designer.getRelativeY(loc.y); int y = designer.getRelativeY(loc.y);
if (model.isDragNewWidget()) { designer.addWidgetToForm(creator, x, y);
designer.addNewWidget(creator, x, y);
} else {
designer.changeWidgetPlace(creator, x, y);
}
// 放到事件末尾执行 // 放到事件末尾执行
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override

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

@ -1252,12 +1252,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return; return;
} }
instantiateCreator(xCreator);
draggingModel = new DraggingModel() draggingModel = new DraggingModel()
.designer(this) .designer(this)
.creator(xCreator) .creator(xCreator)
.startDragEvent(startDragEvent) .startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent) .currentDragEvent(currentDragEvent);
.dragNewWidget(true);
this.setDropTarget(new FormCreatorDropTarget(this, xCreator)); this.setDropTarget(new FormCreatorDropTarget(this, xCreator));
repaint(); repaint();
} }
@ -1273,12 +1273,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
if (currentDragEvent == null || this.getDropTarget() != null) { if (currentDragEvent == null || this.getDropTarget() != null) {
return; return;
} }
backUpCreator(xCreator);
draggingModel = new DraggingModel() draggingModel = new DraggingModel()
.designer(this) .designer(this)
.creator(xCreator) .creator(xCreator)
.startDragEvent(startDragEvent) .startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent) .currentDragEvent(currentDragEvent);
.dragNewWidget(false);
XLayoutContainer container = this.getDraggingHotspotLayout(); XLayoutContainer container = this.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter(); LayoutAdapter adapter = container.getLayoutAdapter();
adapter.dragging(this.getDraggingModel()); adapter.dragging(this.getDraggingModel());
@ -1990,7 +1990,8 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return spacingLineDrawer; return spacingLineDrawer;
} }
private void instantiateCreator(XCreator creator) { public void instantiateCreator(XCreator creator) {
if (creator != null) {
ModelUtil.renameWidgetName(this.getTarget(), creator); ModelUtil.renameWidgetName(this.getTarget(), creator);
creator.addNotify(); creator.addNotify();
@ -1998,19 +1999,16 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
adapter.initialize(); adapter.initialize();
creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter); creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
} }
public void addNewWidget(XCreator creator, int x, int y) {
instantiateCreator(creator);
addWidgetToForm(creator, x, y);
} }
public void changeWidgetPlace(XCreator creator, int x, int y) { public void backUpCreator(XCreator creator) {
if (creator != null) {
creator.backupCurrentSize(); creator.backupCurrentSize();
creator.backupParent(); creator.backupParent();
addWidgetToForm(creator, x, y); }
} }
private void addWidgetToForm(XCreator creator, int x, int y) { public void addWidgetToForm(XCreator creator, int x, int y) {
if(creator == null) { if(creator == null) {
return; 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.getPainter().paint(g, designer.getArea().getHorizontalValue(),
designer.getArea().getVerticalValue() + designer.getParaHeight()); designer.getArea().getVerticalValue() + designer.getParaHeight());
} }
DraggingModel draggingModel = designer.getDraggingModel();
if (draggingModel != null && draggingModel.getCreator() != null) { if (needPaintDraggingBean()) {
// 当前正在添加的组件 // 当前正在添加的组件
paintDraggingBean(g); paintDraggingBean(g);
} }
@ -217,6 +217,19 @@ public class FormDesignerUI extends ComponentUI {
ComponentUtils.resetBuffer(dbcomponents); 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) { private void paintAuthorityCreator(Graphics2D g2d, Rectangle creatorBounds) {
back_or_selection_rect.setRect(creatorBounds.getX(), creatorBounds.getY(), 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; return;
} }
FormDesigner designer = GuideCreateUtils.getFormDesigner(); FormDesigner designer = GuideCreateUtils.getFormDesigner();
designer.getSelectionModel().selectACreator(xLayoutContainer);
if (dragNewComponent) { if (dragNewComponent) {
designer.addNewWidget(xCreator, xLayoutContainer.getX(), xLayoutContainer.getY()); designer.instantiateCreator(xCreator);
} else { } 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); designer.getSelectionModel().selectACreator(xCreator);
} }

Loading…
Cancel
Save