Browse Source

REPORT-79881 多结果数据集树节点图标查找性能问题

new-design
rinoux 2 years ago
parent
commit
a323dbbb39
  1. 7
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataNameWrapper.java
  2. 18
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapper.java
  3. 54
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapperHelper.java

7
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataNameWrapper.java

@ -68,12 +68,7 @@ public final class MultiResultTableDataNameWrapper implements TableDataWrapper {
@Override @Override
public Icon getIcon() { public Icon getIcon() {
for (TableDataNameObjectCreator creator : TableDataCreatorProducer.getInstance().createReportTableDataCreator()) { return MultiResultTableDataWrapperHelper.getIcon(this.tableData.getClass());
if (creator.createObject().getClass().isAssignableFrom(this.tableData.getClass())) {
return IOUtils.readIcon(creator.getIconPath());
}
}
return IOUtils.readIcon("/com/fr/design/images/data/multi.png");
} }
private void createResult(boolean needLoadingBar) { private void createResult(boolean needLoadingBar) {

18
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapper.java

@ -10,13 +10,21 @@ import com.fr.design.data.datapane.TableDataCreatorProducer;
import com.fr.design.data.datapane.TableDataNameObjectCreator; import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.ServerTableDataDefineProvider;
import com.fr.design.fun.TableDataDefineProvider;
import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.observer.PluginEventType;
import com.fr.stable.Filter;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -24,7 +32,9 @@ import javax.swing.SwingWorker;
import java.awt.Component; import java.awt.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
/** /**
@ -163,12 +173,7 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
@Override @Override
public Icon getIcon() { public Icon getIcon() {
for (TableDataNameObjectCreator creator : TableDataCreatorProducer.getInstance().createReportTableDataCreator()) { return MultiResultTableDataWrapperHelper.getIcon(this.tableData.getClass());
if (creator.createObject().getClass().isAssignableFrom(this.tableData.getClass())) {
return IOUtils.readIcon(creator.getIconPath());
}
}
return IOUtils.readIcon("/com/fr/design/images/data/multi.png");
} }
/** /**
@ -303,6 +308,7 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
/** /**
* 获取当前节点所属可编辑的数据集名称 * 获取当前节点所属可编辑的数据集名称
*
* @return * @return
*/ */
public String getMultiResultTableDataName() { public String getMultiResultTableDataName() {

54
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapperHelper.java

@ -0,0 +1,54 @@
package com.fr.design.data.tabledata.wrapper;
import com.fr.base.TableData;
import com.fr.design.data.datapane.TableDataCreatorProducer;
import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.fun.ServerTableDataDefineProvider;
import com.fr.design.fun.TableDataDefineProvider;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.IOUtils;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.observer.PluginEventType;
import com.fr.stable.Filter;
import org.jetbrains.annotations.NotNull;
import javax.swing.Icon;
import java.util.HashMap;
import java.util.Map;
/**
* @author rinoux
* @version 11.0
* Created by rinoux on 2022/9/7
*/
class MultiResultTableDataWrapperHelper {
private static final Map<Class<? extends TableData>, Icon> TABLE_DATA_ICON_PATHS = new HashMap<>();
private static final String DEFAULT_MULTI_RESULT_TD_ICON = "/com/fr/design/images/data/multi.png";
static {
Listener<PluginContext> listener = new Listener<PluginContext>() {
@Override
public void on(Event event, PluginContext param) {
TABLE_DATA_ICON_PATHS.clear();
}
};
Filter<PluginContext> filter = pluginContext -> pluginContext.contain(TableDataDefineProvider.XML_TAG) || pluginContext.contain(ServerTableDataDefineProvider.XML_TAG);
EventDispatcher.listen(PluginEventType.AfterRun, listener, filter);
EventDispatcher.listen(PluginEventType.BeforeStop, listener, filter);
}
public static @NotNull Icon getIcon(@NotNull Class<? extends TableData> tableDataClass) {
return TABLE_DATA_ICON_PATHS.computeIfAbsent(tableDataClass, cls -> {
for (TableDataNameObjectCreator creator : TableDataCreatorProducer.getInstance().createReportTableDataCreator()) {
if (creator.createObject().getClass().isAssignableFrom(tableDataClass)) {
return IOUtils.readIcon(creator.getIconPath());
}
}
return IOUtils.readIcon(DEFAULT_MULTI_RESULT_TD_ICON);
});
}
}
Loading…
Cancel
Save