Browse Source

REPORT-22634 19fdc_决策报表增加预览方式接口

feature/big-screen
zack 5 years ago
parent
commit
ae444f7eed
  1. 83
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  2. 3
      designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java
  3. 10
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractPreviewProvider.java
  4. 12
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  5. 2
      designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java
  6. 3
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  7. 13
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

83
designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java

@ -7,7 +7,14 @@ package com.fr.design;
import com.fr.base.BaseUtils;
import com.fr.common.annotations.Open;
import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.fun.*;
import com.fr.design.fun.CellWidgetOptionProvider;
import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.fun.MobileWidgetStyleProvider;
import com.fr.design.fun.ParameterWidgetOptionProvider;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.fun.ServerTableDataDefineProvider;
import com.fr.design.fun.TableDataDefineProvider;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.core.WidgetOptionFactory;
import com.fr.design.menu.ShortCut;
@ -24,6 +31,7 @@ import com.fr.stable.Filter;
import com.fr.stable.plugin.ExtraDesignClassManagerProvider;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@ -127,21 +135,25 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
}
public WidgetOption[] getWebWidgetOptions(Set<ToolbarItemProvider> set, Filter<ToolbarItemProvider> filter) {
if (set == null || set.isEmpty()) {
return new WidgetOption[0];
}
List<WidgetOption> list = new ArrayList<>();
for (ToolbarItemProvider provider : set) {
if (filter != null && filter.accept(provider)) {
WidgetOption option = WidgetOptionFactory.createByWidgetClass(
return new DesignExtraBridge<WidgetOption, ToolbarItemProvider>() {
@Override
WidgetOption createT(ToolbarItemProvider provider) {
return WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(),
IOUtils.readIcon(provider.iconPathForWidget()),
provider.classForWidget()
);
list.add(option);
}
@Override
WidgetOption[] toArray(Collection<?> sCollection) {
if (sCollection == null) {
return new WidgetOption[0];
}
return sCollection.toArray(new WidgetOption[sCollection.size()]);
}
return list.toArray(new WidgetOption[list.size()]);
}.filterSAndTransformT(set, filter);
}
@ -256,4 +268,55 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
return Collections.unmodifiableSet(shortCuts);
}
public PreviewProvider[] getTemplatePreviews(Filter<PreviewProvider> filter) {
Set<PreviewProvider> set = ExtraDesignClassManager.getInstance().getArray(PreviewProvider.MARK_STRING);
return new DesignExtraBridge<PreviewProvider, PreviewProvider>() {
@Override
PreviewProvider createT(PreviewProvider previewProvider) {
return previewProvider;
}
@Override
PreviewProvider[] toArray(Collection<?> sCollection) {
if (sCollection == null) {
return new PreviewProvider[0];
}
return sCollection.toArray(new PreviewProvider[sCollection.size()]);
}
}.filterSAndTransformT(set, filter);
}
/**
* 抽了一个可能用到的公用逻辑出来通过filter过滤接口实现Set<s>并将对外接口实例转成内部实例S转成T,比如ToolItemProvider转成WidgetOption,当然也可以不转
*
* @param <T> 你想要得到的类型可以跟S相同
* @param <S> 待转换的目标类型
*/
abstract class DesignExtraBridge<T, S> {
T[] filterSAndTransformT(Set<S> set, Filter<S> filter) {
if (set == null || set.isEmpty()) {
return toArray(set);
}
List<T> list = new ArrayList<>();
for (S provider : set) {
if (filter == null || filter.accept(provider)) {
list.add(createT(provider));
}
}
return toArray(list);
}
/**
* S转T
* @param s
* @return
*/
abstract T createT(S s);
abstract T[] toArray(Collection<?> sCollection);
}
}

3
designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java

@ -1,6 +1,7 @@
package com.fr.design.fun;
import com.fr.design.mainframe.JTemplate;
import com.fr.stable.Filter;
import com.fr.stable.fun.mark.Mutable;
import java.util.Map;
@ -11,7 +12,7 @@ import java.util.Map;
* @since 8.0
* 自定义预览方式接口
*/
public interface PreviewProvider extends Mutable {
public interface PreviewProvider extends Mutable, Filter<JTemplate> {
String MARK_STRING = "PreviewProvider";

10
designer-base/src/main/java/com/fr/design/fun/impl/AbstractPreviewProvider.java

@ -1,7 +1,9 @@
package com.fr.design.fun.impl;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.general.ComparatorUtils;
import com.fr.general.web.ParameterConstants;
import com.fr.stable.fun.impl.AbstractProvider;
@ -52,4 +54,12 @@ public abstract class AbstractPreviewProvider extends AbstractProvider implement
public String getActionType() {
return ParameterConstants.VIEWLET;
}
@Override
public boolean accept(JTemplate jTemplate) {
if (jTemplate == null) {
jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
}
return jTemplate == null || jTemplate.isJWorkBook() || jTemplate instanceof JVirtualTemplate;
}
}

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

@ -4,7 +4,6 @@ import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.base.extension.FileExtension;
import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.base.iofile.attr.TemplateIdAttrMark;
@ -27,8 +26,8 @@ import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.DesignerFrameUpButtonProvider;
import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.design.gui.ibutton.UIButton;
@ -50,7 +49,6 @@ import com.fr.design.write.submit.DBManipulationPane;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.MemFILE;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
@ -58,6 +56,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.report.cell.Elem;
import com.fr.report.cell.cellattr.CellImage;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Filter;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.core.UUID;
@ -1154,7 +1153,12 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* @return 预览模式
*/
public PreviewProvider[] supportPreview() {
return new PreviewProvider[0];
return ExtraDesignClassManager.getInstance().getTemplatePreviews(new Filter<PreviewProvider>() {
@Override
public boolean accept(PreviewProvider previewProvider) {
return previewProvider.accept(JTemplate.this);
}
});
}
/**

2
designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java

@ -62,7 +62,9 @@ public class ExtraDesignClassManagerTest extends TestCase {
return toolbarItemProvider.accept(jTemplate);
}
});
WidgetOption[] widgetOptions1 = ExtraDesignClassManager.getInstance().getWebWidgetOptions(set, null);
Assert.assertEquals(1, widgetOptions.length);
Assert.assertEquals(2, widgetOptions1.length);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}

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

@ -937,7 +937,8 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
*/
@Override
public PreviewProvider[] supportPreview() {
return new PreviewProvider[]{new FormPreview(), new MobilePreview()};
PreviewProvider[] templatePreviews = super.supportPreview();
return ArrayUtils.addAll(new PreviewProvider[]{new FormPreview(), new MobilePreview()}, templatePreviews);
}
/**

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

@ -35,8 +35,8 @@ import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.design.gui.ibutton.UIButton;
@ -102,6 +102,10 @@ import com.fr.stable.module.Module;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.controller.ViewRequestConstants;
import com.fr.workspace.WorkContext;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileOutputStream;
@ -109,9 +113,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
/**
* JWorkBook used to edit WorkBook.
@ -900,10 +901,10 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
*/
@Override
public PreviewProvider[] supportPreview() {
Set<PreviewProvider> set = ExtraDesignClassManager.getInstance().getArray(PreviewProvider.MARK_STRING);
PreviewProvider[] templatePreviews = super.supportPreview();
return ArrayUtils.addAll(new PreviewProvider[]{
new PagePreview(), new WritePreview(), new ViewPreview(), new WriteEnhancePreview(), new MobilePreview()
}, set.toArray(new PreviewProvider[set.size()]));
}, templatePreviews);
}
/**

Loading…
Cancel
Save