Browse Source

REPORT-25778 json数据集,设计器重启之后消失

换一种处理方式,刷新面板会导致各种诡异的问题
final/10.0
Harrison 5 years ago
parent
commit
03a8dd09dd
  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.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.TableDataDefineProvider; import com.fr.design.fun.TableDataDefineProvider;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.fun.TableDataPaneProcessor;
import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
@ -168,23 +168,22 @@ public class TableDataTreePane extends BasicTableDataTreePane {
//如果数据集插件禁用或启用。需要清空当前模板中的缓存 //如果数据集插件禁用或启用。需要清空当前模板中的缓存
reloadCurrTemplate(); reloadCurrTemplate();
} }
private void reloadCurrTemplate() { private void reloadCurrTemplate() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (accept(jt)) { if (accept(jt)) {
HistoryTemplateListCache.getInstance().closeSelectedReport(jt); jt.refreshResource();
DesignerContext.getDesignerFrame().openTemplate(jt.getEditingFILE());
} }
} }
private boolean accept(JTemplate<?, ?> jt) { private boolean accept(JTemplate<?, ?> jt) {
return jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists(); return jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists();
} }
}, new PluginFilter() { }, new PluginFilter() {
@Override @Override
public boolean accept(PluginContext pluginContext) { public boolean accept(PluginContext pluginContext) {
return pluginContext.contain(TableDataDefineProvider.XML_TAG); 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 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; package com.fr.design.mainframe;
import com.fr.base.io.BaseBook;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.third.javax.annotation.Nonnull; import com.fr.third.javax.annotation.Nonnull;
@ -42,6 +43,28 @@ public final class JTemplateFactory {
} }
return null; 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