Browse Source

Merge pull request #1526 in DESIGN/design from ~JEO/report-design:persist/10.0 to persist/10.0

* commit 'd157a12f21d6a81f63e525617f958f1ac6cfb06c':
  REPORT-28459 JWorkBook 未释放 同步到final
  REPORT-28459 场景补充
  REPORT-28459 JWorkBook未释放问题 同步到final
  REPORT-27434 1.15jar假保存问题 更换下位置。 重构后改动了代码的位置。 没再测试
  REPORT-27434 1.15jar假保存问题 监听装置需要同步刷新
persist/10.0
Kara 5 years ago
parent
commit
e8a5ed1fc1
  1. 1
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  2. 11
      designer-base/src/main/java/com/fr/design/event/RemoveListener.java
  3. 17
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  4. 25
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  5. 35
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  6. 33
      designer-base/src/test/java/com/fr/design/file/HistoryTemplateListCacheTest.java
  7. 5
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  8. 8
      designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java
  9. 21
      designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java

1
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -114,6 +114,7 @@ public abstract class DesignTableDataManager {
public static void closeTemplate(JTemplate<?, ?> template) {
if (template != null) {
template.whenClose();
columnCache.remove(getEditingTableDataSource());
dsListenersMap.remove(template.getPath());
}

11
designer-base/src/main/java/com/fr/design/event/RemoveListener.java

@ -0,0 +1,11 @@
package com.fr.design.event;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/19
*/
public interface RemoveListener {
void doRemoveAction();
}

17
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -178,15 +178,28 @@ public class HistoryTemplateListCache implements CallbackEvent {
* @return 位置
*/
public int contains(JTemplate<?, ?> jt) {
return contains(jt, null);
}
public int contains(FILE file) {
return contains(null, file);
}
private int contains(JTemplate jt, FILE file) {
FILE item = null;
if (jt != null) {
item = jt.getEditingFILE();
} else {
item = file;
}
for (int i = 0; i < historyList.size(); i++) {
if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) {
if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), item)) {
return i;
}
}
return -1;
}
/**
* 判断是否打开过该模板
* 由于切换环境不会关闭模板可能存在同名的模板所以该方法不能准确找到所选的模板

25
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -1085,6 +1085,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/
private void openFile(FILE tplFile) {
if (tplFile != null) {
int index = HistoryTemplateListCache.getInstance().contains(tplFile);
if (index != -1) {
HistoryTemplateListCache.getInstance().getHistoryList().get(index).activeOldJTemplate();
return;
}
}
JTemplate jt = JTemplateFactory.createJTemplate(tplFile);
if (jt == null) {
return;
@ -1094,23 +1102,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.addAndActivateJTemplate();
MutilTempalteTabPane.getInstance().setTemTemplate(
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
} else {
activeTemplate(jt);
}
}
/**
* 激活指定的模板
*
* @param jt 当前报表
* @date 2014-10-14-下午6:31:23
*/
private void activeTemplate(JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了
int index = HistoryTemplateListCache.getInstance().contains(jt);
List<JTemplate<?, ?>> historyList = HistoryTemplateListCache.getInstance().getHistoryList();
if (index != -1) {
historyList.get(index).activeJTemplate(index, jt);
} else {
this.addAndActivateJTemplate(jt);
}

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

@ -93,6 +93,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected U authorityUndoState = null;
protected T template; // 当前模板
protected TemplateProcessInfo<T> processInfo; // 模板过程的相关信息
private JComponent centerPane;
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
private DesignModelAdapter<T, ?> designModel;
private PreviewProvider previewType;
@ -123,13 +124,13 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this.editingFILE = file;
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder());
this.add(createCenterPane(), BorderLayout.CENTER);
addCenterPane();
this.undoState = createUndoState();
designModel = createDesignModel();
consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile));
}
void onGetFocus() {
consumeTimer.start();
}
@ -246,19 +247,47 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
/**
* 模板关闭时
*/
public void whenClose() {
// do nothing
}
/**
* 刷新内部资源
*
* 刷新资源的同时
* CenterPane 负责监听改动
* 所以需要同步处理
*/
public void refreshResource() {
try {
this.template = JTemplateFactory.asIOFile(this.editingFILE);
setTarget(this.template);
// 先移除旧的。
removeCenterPane();
// 加入新的
addCenterPane();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private void addCenterPane() {
this.centerPane = createCenterPane();
this.add(centerPane, BorderLayout.CENTER);
}
private void removeCenterPane() {
JComponent centerPane = this.centerPane;
this.remove(centerPane);
}
/**
* 刷新容器
*/

33
designer-base/src/test/java/com/fr/design/file/HistoryTemplateListCacheTest.java

@ -0,0 +1,33 @@
package com.fr.design.file;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.invoke.Reflect;
import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert;
import java.util.ArrayList;
import java.util.Arrays;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/23
*/
public class HistoryTemplateListCacheTest extends TestCase {
public void testContains() {
JTemplate jTemplate = EasyMock.mock(JTemplate.class);
FILE file = EasyMock.mock(FILE.class);
EasyMock.expect(jTemplate.getEditingFILE()).andReturn(file).anyTimes();
EasyMock.replay(file);
EasyMock.replay(jTemplate);
Assert.assertEquals(-1, HistoryTemplateListCache.getInstance().contains(file));
Assert.assertEquals(-1, HistoryTemplateListCache.getInstance().contains(jTemplate));
Reflect.on(HistoryTemplateListCache.getInstance()).set("historyList", new ArrayList<>(Arrays.asList(jTemplate)));
Assert.assertEquals(0, HistoryTemplateListCache.getInstance().contains(file));
Assert.assertEquals(0, HistoryTemplateListCache.getInstance().contains(jTemplate));
}
}

5
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -1188,4 +1188,9 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
provider.addChooseFileFilter(fileChooser, this.suffix());
}
}
@Override
public void whenClose() {
reportComposite.doRemoveAction();
}
}

8
designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe;
import com.fr.base.ScreenResolution;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.designer.EditingState;
import com.fr.design.event.RemoveListener;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.icontainer.UIModeControlContainer;
@ -30,7 +31,7 @@ import java.util.ArrayList;
* @editor zhou
* @since 2012-3-27下午12:12:05
*/
public class ReportComponentComposite extends JComponent {
public class ReportComponentComposite extends JComponent implements RemoveListener {
private static final int MAX = 400;
private static final int HUND = 100;
@ -250,4 +251,9 @@ public class ReportComponentComposite extends JComponent {
public void fireTargetModified() {
parent.fireTargetModified();
}
@Override
public void doRemoveAction() {
sheetNameTab.doRemoveAction();
}
}

21
designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java

@ -5,6 +5,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
@ -27,6 +28,7 @@ import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.UpdateAction;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.event.RemoveListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
@ -44,7 +46,6 @@ import com.fr.poly.PolyDesigner;
import com.fr.report.poly.PolyWorkSheet;
import com.fr.report.report.TemplateReport;
import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.ProductConstants;
/**
* NameTabPane of sheets
@ -52,7 +53,7 @@ import com.fr.stable.ProductConstants;
* @editor zhou
* @since 2012-3-26下午1:45:53
*/
public class SheetNameTabPane extends JComponent implements MouseListener, MouseMotionListener {
public class SheetNameTabPane extends JComponent implements MouseListener, MouseMotionListener, RemoveListener {
private static final Color LINE_COLOR = new Color(0xababab);
@ -140,6 +141,10 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
private boolean isAuthorityEditing = false;
private ComponentListener listener;
private DesignerFrame designerFrame;
public SheetNameTabPane(ReportComponentComposite reportCompositeX) {
this.reportComposite = reportCompositeX;
this.setLayout(new BorderLayout(0, 0));
@ -203,14 +208,20 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse
}
}
});
DesignerContext.getDesignerFrame().addComponentListener(new ComponentAdapter(){
listener = new ComponentAdapter(){
@Override public void componentResized(ComponentEvent e) {
for (int i = 0; i < lastOneIndex * NUM; i++) {
moveLeft();
}
}
});
};
designerFrame = DesignerContext.getDesignerFrame();
designerFrame.addComponentListener(listener);
}
@Override
public void doRemoveAction() {
designerFrame.removeComponentListener(listener);
}
private ActionListener createLeftButtonActionListener() {

Loading…
Cancel
Save