Browse Source

Merge pull request #1265 in DESIGN/design from ~ZACK/design:release/10.0 to release/10.0

* commit '0f1d7aa907bbe1b49dda183b3af90eed6e5e906a':
  rt
  REPORT-22634 19fdc_决策报表增加预览方式接口
feature/big-screen
zack 5 years ago
parent
commit
38949938fb
  1. 89
      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. 18
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  5. 5
      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

89
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);
}
}
return list.toArray(new WidgetOption[list.size()]);
@Override
WidgetOption[] toArray(Collection<?> sCollection) {
if (sCollection == null) {
return new WidgetOption[0];
}
return sCollection.toArray(new WidgetOption[sCollection.size()]);
}
}.filterSAndTransformT(set, filter);
}
@ -224,8 +236,8 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
return new MobileWidgetStyleProvider[0];
}
List<MobileWidgetStyleProvider> providers = new ArrayList<>();
for (MobileWidgetStyleProvider provider: set) {
if(ComparatorUtils.equalsIgnoreCase(provider.xTypeForWidget(), xType)) {
for (MobileWidgetStyleProvider provider : set) {
if (ComparatorUtils.equalsIgnoreCase(provider.xTypeForWidget(), xType)) {
providers.add(provider);
}
}
@ -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;
}
}

18
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;
@ -628,7 +627,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
}
protected void addChooseFILEFilter(FILEChooserPane fileChooser){
protected void addChooseFILEFilter(FILEChooserPane fileChooser) {
}
@ -651,13 +650,13 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return result;
}
protected boolean saveToNewFile(String oldName){
protected boolean saveToNewFile(String oldName) {
boolean result = false;
Set<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (ReportSupportedFileUIProvider provider : providers) {
result = result || provider.saveToNewFile(this.editingFILE.getPath(), this);
}
if(!result){
if (!result) {
result = result || this.saveFile();
//更换最近打开
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath());
@ -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);
}
});
}
/**

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

@ -9,7 +9,6 @@ import com.fr.design.gui.core.WidgetOption;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.general.ModuleContext;
import com.fr.log.FineLoggerFactory;
import com.fr.report.restriction.CellCountRestriction;
import com.fr.report.restriction.ReportRestrictionScene;
import com.fr.restriction.Restrictions;
@ -62,9 +61,11 @@ 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);
Assert.fail(e.getMessage());
}
}
}

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