Browse Source

REPORT-62275&REPORT-61827

bugfix/11.0
方磊 3 years ago
parent
commit
60edfb2cbd
  1. 17
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 4
      designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java
  3. 7
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java
  4. 1
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java
  5. 14
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java
  6. 6
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  7. 6
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java
  8. 9
      designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java
  9. 13
      designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java
  10. 18
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  11. 1
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

17
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -7,11 +7,11 @@ import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.base.iofile.attr.TemplateIdAttrMark;
import com.fr.base.iofile.attr.TemplateThemeAttrMark;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.ThemedTemplate;
import com.fr.base.vcs.DesignerMode;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.decision.config.FSConfig;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
@ -70,14 +70,13 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.nx.app.designer.toolbar.TemplateTransformer;
import com.fr.nx.app.designer.utils.CptAndCptxCompatibilityUtil;
import com.fr.nx.app.designer.utils.CptCompileUtil;
import com.fr.nx.cptx.entry.metadata.CptxMetadata;
import com.fr.nx.cptx.utils.CptxFileUtils;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime;
import com.fr.nx.app.designer.toolbar.CompileAction;
import com.fr.nx.app.designer.toolbar.TemplateTransformer;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
@ -642,6 +641,16 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
fireSuperTargetModified();
}
public void undoToCurrent() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
BaseUndoState current = JTemplate.this.getUndoState();
current.applyState();
}
});
}
/**
* 模板更新
*/

4
designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java

@ -3,7 +3,6 @@ package com.fr.design.designer.beans;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate;
import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate;
import com.fr.design.designer.beans.models.AddingModel;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender;
@ -141,7 +140,4 @@ public interface LayoutAdapter {
default void dragOver(XCreator xCreator, SelectionModel selectionModel, int x, int y) {
};
void updateAddingModel(AddingModel model);
}

7
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java

@ -4,7 +4,6 @@ import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.models.AddingModel;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.painters.NullPainter;
import com.fr.design.designer.creator.XCreator;
@ -14,7 +13,7 @@ import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils;
import java.awt.*;
import java.awt.LayoutManager;
public abstract class AbstractLayoutAdapter implements LayoutAdapter {
@ -210,8 +209,4 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter {
selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight());
selectionModel.setSelectedCreator(container);
}
public void updateAddingModel(AddingModel model) {
}
}

1
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java

@ -184,5 +184,4 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) {
return new FRBorderLayoutConstraints(container, creator);
}
}

14
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java

@ -7,7 +7,6 @@ import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.form.layout.FRBorderLayout;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.ui.util.UIUtil;
import com.fr.general.ComparatorUtils;
import java.awt.BorderLayout;
@ -65,17 +64,8 @@ public class FRCardMainBorderLayoutAdapter extends FRBorderLayoutAdapter {
if (minConstraint > value) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds"));
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt != null && jt.getUndoManager().canUndo()) {
// 自适应布局平分高度导致变矮的场景,优先做撤销
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
jt.undo();
}
});
} else if (container.getBackupBound() != null) {
// 手动拖动导致变矮的场景
container.setSize(container.getBackupBound().getSize());
if (jt != null) {
jt.undoToCurrent();
}
return true;
} else {

6
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -8,7 +8,6 @@ import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.models.AddingModel;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
@ -1245,9 +1244,4 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
public void dragOver(XCreator xCreator, SelectionModel selectionModel,int x, int y) {
frLayoutState.dragOver(xCreator, selectionModel,x,y);
}
@Override
public void updateAddingModel(AddingModel model) {
frLayoutState.updateAddingModel(model);
}
}

6
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java

@ -1,6 +1,5 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.designer.beans.models.AddingModel;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.painters.AbstractPainter;
import com.fr.design.designer.beans.painters.FRFitLayoutPainter;
@ -147,9 +146,4 @@ public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter {
selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight());
selectionModel.setSelectedCreator(container);
}
@Override
public void updateAddingModel(AddingModel model) {
model.setNeedUndoWhenAddingFailed(true);
}
}

9
designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java

@ -24,7 +24,6 @@ public class AddingModel {
private int currentX;
private int currentY;
private boolean added;
private boolean needUndoWhenAddingFailed = false;
public AddingModel(FormDesigner designer, XCreator xCreator) {
this.creator = xCreator;
@ -141,12 +140,4 @@ public class AddingModel {
y + designer.getVerticalScaleValue() - rect.y);
return added;
}
public boolean isNeedUndoWhenAddingFailed() {
return needUndoWhenAddingFailed;
}
public void setNeedUndoWhenAddingFailed(boolean needUndoWhenAddingFailed) {
this.needUndoWhenAddingFailed = needUndoWhenAddingFailed;
}
}

13
designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java

@ -1,7 +1,7 @@
package com.fr.design.mainframe;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.models.AddingModel;
import com.fr.design.file.HistoryTemplateListPane;
import javax.swing.JComponent;
import javax.swing.TransferHandler;
@ -19,8 +19,15 @@ public class DesignerTransferHandler extends TransferHandler {
}
protected void exportDone(JComponent source, Transferable data, int action) {
if (!addingModel.isCreatorAdded() && !addingModel.isNeedUndoWhenAddingFailed()) {
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED);
if (!addingModel.isCreatorAdded()) {
undoWhenAddingFailed();
}
}
private void undoWhenAddingFailed() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt != null) {
jt.undoToCurrent();
}
}
}

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

@ -18,7 +18,6 @@ import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants;
@ -26,7 +25,6 @@ import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.mod.bean.ChangeItem;
import com.fr.design.mod.bean.ContentChangeItem;
import com.fr.design.mod.event.TableDataModifyEvent;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.ComponentUtils;
import com.fr.event.EventDispatcher;
import com.fr.form.share.SharableWidgetProvider;
@ -154,9 +152,6 @@ public class FormCreatorDropTarget extends DropTarget {
if (creator != null) {
creator.setSelected(false);
}
if (designer.getAddingModel().isNeedUndoWhenAddingFailed()) {
undoWhenDropFail();
}
}
// 取消提示
designer.setPainter(null);
@ -164,19 +159,6 @@ public class FormCreatorDropTarget extends DropTarget {
designer.stopAddingState();
}
private void undoWhenDropFail() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt != null) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
FormUndoState current = (FormUndoState) jt.getUndoState();
current.applyState();
}
});
}
}
private void entering(int x, int y) {
// 将要添加的组件图标移动到鼠标下的位置
addingModel.moveTo(x, y);

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

@ -1210,7 +1210,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
setTransferHandler(handler);
handler.exportAsDrag(this, lastPressEvent, TransferHandler.COPY);
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator);
parent.getLayoutAdapter().updateAddingModel(addingModel);
parent.getLayoutAdapter().dragStart(xCreator, selectionModel);
this.setDropTarget(new FormCreatorDropTarget(this));
// 触发状态添加模式事件

Loading…
Cancel
Save