Browse Source

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

* commit '8ad194aea60a156c10ca392621087c0556741331':
  REPORT-25778 json数据集,设计器重启之后消失 换一种处理方式,刷新面板会导致各种诡异的问题
persist/10.0
Kara 5 years ago
parent
commit
dc5b8316bc
  1. 13
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  2. 13
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  3. 23
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java

13
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java

@ -16,9 +16,9 @@ import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.TableDataDefineProvider;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.TableDataPaneProcessor;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.icontainer.UIScrollPane;
@ -168,23 +168,22 @@ public class TableDataTreePane extends BasicTableDataTreePane {
//如果数据集插件禁用或启用。需要清空当前模板中的缓存
reloadCurrTemplate();
}
private void reloadCurrTemplate() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (accept(jt)) {
HistoryTemplateListCache.getInstance().closeSelectedReport(jt);
DesignerContext.getDesignerFrame().openTemplate(jt.getEditingFILE());
jt.refreshResource();
}
}
private boolean accept(JTemplate<?, ?> jt) {
return jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists();
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext pluginContext) {
return pluginContext.contain(TableDataDefineProvider.XML_TAG);
}
});

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

@ -243,6 +243,19 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public void judgeSheetAuthority(String roles) {
}
/**
* 刷新内部资源
*/
public void refreshResource() {
try {
this.template = JTemplateFactory.asIOFile(this.editingFILE);
setTarget(this.template);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
* 刷新容器

23
designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe;
import com.fr.base.io.BaseBook;
import com.fr.file.FILE;
import com.fr.stable.CoreConstants;
import com.fr.third.javax.annotation.Nonnull;
@ -42,6 +43,28 @@ public final class JTemplateFactory {
}
return null;
}
public static <T extends BaseBook> T asIOFile(@Nonnull FILE file) {
String fileName = file.getName();
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT);
if (indexOfLastDot < 0) {
return null;
}
String fileExtension = fileName.substring(indexOfLastDot + 1);
for (App<?> app : ALL_APP) {
String[] defaultAppExtensions = app.defaultExtensions();
for (String defaultAppExtension : defaultAppExtensions) {
if (defaultAppExtension.equalsIgnoreCase(fileExtension)) {
BaseBook bb = app.asIOFile(file);
if (bb != null) {
return (T) bb;
}
}
}
}
return null;
}
/**

Loading…
Cancel
Save