Browse Source

REPORT-52512 共享组件删除后删除对应的数据集

feature/10.0
kuangshuai 4 years ago
parent
commit
b087607a94
  1. 40
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java

40
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -4,6 +4,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.PaperSize; import com.fr.base.PaperSize;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
@ -64,6 +65,11 @@ import com.fr.file.filter.ChooseFileFilter;
import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseContainerProvider;
import com.fr.form.FormElementCaseProvider; import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.WidgetGatherAdapter;
import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.editor.SharableEditorProvider;
import com.fr.form.share.utils.ShareUtils;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
@ -77,6 +83,7 @@ import com.fr.report.worksheet.FormElementCase;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.web.controller.ViewRequestConstants; import com.fr.web.controller.ViewRequestConstants;
@ -96,6 +103,7 @@ import java.awt.event.ActionListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
@ -305,6 +313,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) { } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) {
// 在 delete 之前,会先 select 父组件。这里直接传入 lastAffectedCreator 就好了 // 在 delete 之前,会先 select 父组件。这里直接传入 lastAffectedCreator 就好了
setPropertyPaneChange(lastAffectedCreator); setPropertyPaneChange(lastAffectedCreator);
refreshSharableWidgetTableDataTree((XCreator) lastAffectedCreator);
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
lastAffectedCreator = evt.getAffectedCreator(); lastAffectedCreator = evt.getAffectedCreator();
setPropertyPaneChange(lastAffectedCreator); setPropertyPaneChange(lastAffectedCreator);
@ -1038,4 +1047,35 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
// richer:form文件 daniel 改成三个字 // richer:form文件 daniel 改成三个字
fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
} }
private void refreshSharableWidgetTableDataTree(XCreator lastAffectedCreator) {
String lastAffectedCreatorShareID = lastAffectedCreator.getShareId();
if (StringUtils.isNotEmpty(lastAffectedCreatorShareID)) {
final boolean[] needDeleteTableData = {true};
Form.traversalWidget(template.getContainer(), new WidgetGatherAdapter() {
@Override
public void dealWith(Widget widget) {
AbstractBorderStyleWidget borderStyleWidget = (AbstractBorderStyleWidget) widget;
ExtendSharableAttrMark attrMark = borderStyleWidget.getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG);
if (attrMark != null) {
needDeleteTableData[0] = needDeleteTableData[0] && !ComparatorUtils.equals(lastAffectedCreatorShareID, attrMark.getShareId());
}
}
}, AbstractBorderStyleWidget.class);
if (!needDeleteTableData[0]) {
return;
}
SharableWidgetProvider bindInfo = ShareUtils.getElCaseBindInfoById(lastAffectedCreatorShareID);
SharableEditorProvider sharableEditor = ShareUtils.getSharedElCaseEditorById(lastAffectedCreatorShareID);
if (sharableEditor == null || bindInfo == null) {
return;
}
Iterator tdIterator = sharableEditor.getTableDataSource().getTableDataNameIterator();
while (tdIterator.hasNext()) {
String tdName = bindInfo.getName() + "-" + tdIterator.next();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).removeTableData(tdName);
}
}
}
} }

Loading…
Cancel
Save