diff --git a/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java b/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java index 2a73de7a4..a4a781e53 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java @@ -27,7 +27,7 @@ public final class WebPreviewUtils { @SuppressWarnings("unchecked") public static void preview(JTemplate jt, PreviewProvider provider) { String baseRoute = jt.route(); - actionPerformed(jt, baseRoute, provider == null ? Collections.EMPTY_MAP : provider.parametersForPreview(), ParameterConstants.VIEWLET); + actionPerformed(jt, baseRoute, provider == null ? Collections.EMPTY_MAP : provider.parametersForPreview(), provider.getActionType()); } private static void actionPerformed(JTemplate jt, String baseRoute, Map map, String actionType) { diff --git a/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java b/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java index 876c7d202..1cb070aff 100644 --- a/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java @@ -54,4 +54,12 @@ public interface PreviewProvider extends Mutable{ */ Map parametersForPreview(); + /** + * 该种预览方式下对模板的处理方式 + * 分页填报等需要计算输出模板,移动端预览直接输出url + * @return 处理方式 + */ + String getActionType(); + + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPreviewProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPreviewProvider.java index 3f824d4bb..f0b780903 100644 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPreviewProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPreviewProvider.java @@ -3,6 +3,7 @@ package com.fr.design.fun.impl; import com.fr.design.fun.PreviewProvider; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; +import com.fr.general.web.ParameterConstants; import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.mark.API; @@ -45,4 +46,10 @@ public abstract class AbstractPreviewProvider extends AbstractProvider implement public int hashCode() { return nameForPopupItem().hashCode(); } + + + @Override + public String getActionType() { + return ParameterConstants.VIEWLET; + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index bf4eb0d0c..6f9383e4d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.Parameter; import com.fr.base.ScreenResolution; @@ -1006,7 +1007,9 @@ public abstract class JTemplate> * @return */ public Icon getPreviewLargeIcon() { - return UIConstants.RUN_BIG_ICON; + PreviewProvider provider = getPreviewType(); + String iconPath = provider.iconPathForLarge(); + return BaseUtils.readIcon(iconPath); } /** diff --git a/designer-base/src/main/java/com/fr/design/preview/FormPreview.java b/designer-base/src/main/java/com/fr/design/preview/FormPreview.java new file mode 100644 index 000000000..d6206a2c0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/preview/FormPreview.java @@ -0,0 +1,34 @@ +package com.fr.design.preview; + +import com.fr.design.fun.impl.AbstractPreviewProvider; +import com.fr.locale.InterProviderFactory; + + +/** + * @author kerry + * @date 2018/5/22 + */ +public class FormPreview extends AbstractPreviewProvider { + private static final int PREVIEW_TYPE = 5; + + @Override + public String nameForPopupItem() { + return InterProviderFactory.getProvider().getLocText("Fine-Design_Form_M_Form_Preview"); + } + + @Override + public String iconPathForPopupItem() { + return "com/fr/design/images/buttonicon/runs.png"; + } + + @Override + public String iconPathForLarge() { + return "com/fr/design/images/buttonicon/run24.png"; + } + + @Override + public int previewTypeCode() { + return PREVIEW_TYPE; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/preview/MobilePreview.java b/designer-base/src/main/java/com/fr/design/preview/MobilePreview.java new file mode 100644 index 000000000..8650ec12b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/preview/MobilePreview.java @@ -0,0 +1,48 @@ +package com.fr.design.preview; + +import com.fr.design.fun.impl.AbstractPreviewProvider; +import com.fr.general.Inter; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author kerry + * @date 2018/5/11 + */ +public class MobilePreview extends AbstractPreviewProvider { + private static final int PREVIEW_TYPE = 4; + private static final String ACTION_TYPE = "path"; + + @Override + public String nameForPopupItem() { + return Inter.getLocText("Fine-Engine_Mobile_Preview"); + } + + @Override + public String iconPathForPopupItem() { + return "com/fr/design/images/buttonicon/mobile.png"; + } + + @Override + public String iconPathForLarge() { + return "com/fr/design/images/buttonicon/mobileb24.png"; + } + + @Override + public int previewTypeCode() { + return PREVIEW_TYPE; + } + + @Override + public String getActionType() { + return ACTION_TYPE; + } + + @Override + public Map parametersForPreview() { + Map map = new HashMap(); + map.put("op", "mobile"); + return map; + } +} diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/mobile.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/mobile.png new file mode 100644 index 000000000..989111f3d Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/mobile.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/mobileb24.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/mobileb24.png new file mode 100644 index 000000000..c1f62a6fb Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/mobileb24.png differ diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 36bd3f32f..d7cc7ea85 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -25,6 +25,7 @@ import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.ilable.UILabel; @@ -46,6 +47,8 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.parameter.ParameterPropertyPane; +import com.fr.design.preview.FormPreview; +import com.fr.design.preview.MobilePreview; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.file.FILE; @@ -78,7 +81,9 @@ import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; public class JForm extends JTemplate implements BaseJForm { private static final String FORM_CARD = "FORM"; @@ -678,7 +683,7 @@ public class JForm extends JTemplate implements BaseJForm { * */ public Icon getPreviewLargeIcon() { - return UIConstants.RUN_BIG_ICON; + return super.getPreviewLargeIcon(); } @Override @@ -693,14 +698,19 @@ public class JForm extends JTemplate implements BaseJForm { * @return 菜单 */ public UIMenuItem[] createMenuItem4Preview() { - UIMenuItem form = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Form_Preview"), UIConstants.RUN_SMALL_ICON); - form.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - WebPreviewUtils.preview(JForm.this); - } - }); - return new UIMenuItem[]{form}; + List menuItems = new ArrayList(); + PreviewProvider[] previewProviders = supportPreview(); + for (final PreviewProvider provider : previewProviders) { + UIMenuItem item = new UIMenuItem(provider.nameForPopupItem(), BaseUtils.readIcon(provider.iconPathForPopupItem())); + item.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + provider.onClick(JForm.this); + } + }); + menuItems.add(item); + } + return menuItems.toArray(new UIMenuItem[menuItems.size()]); } /** @@ -917,6 +927,25 @@ public class JForm extends JTemplate implements BaseJForm { return creator.toData(); } + /** + * 支持的预览模式 + * @return 预览模式 + */ + @Override + public PreviewProvider[] supportPreview() { + return new PreviewProvider[]{new FormPreview(), new MobilePreview()}; + } + + /** + * 预览按钮点击事件 + * + * @param provider 预览接口 + */ + @Override + public void previewMenuActionPerformed(PreviewProvider provider) { + super.previewMenuActionPerformed(provider); + } + @Override public String route() { return ViewRequestConstants.FORM_VIEW_PATH; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index fc1945daf..e60fa5978 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -53,6 +53,7 @@ import com.fr.design.menu.ToolBarDef; import com.fr.design.module.DesignModuleFactory; import com.fr.design.parameter.ParameterDefinitePane; import com.fr.design.parameter.ParameterInputPane; +import com.fr.design.preview.MobilePreview; import com.fr.design.preview.PagePreview; import com.fr.design.preview.ViewPreview; import com.fr.design.preview.WriteEnhancePreview; @@ -890,7 +891,7 @@ public class JWorkBook extends JTemplate { public PreviewProvider[] supportPreview() { Set set = ExtraDesignClassManager.getInstance().getArray(PreviewProvider.MARK_STRING); return ArrayUtils.addAll(new PreviewProvider[]{ - new PagePreview(), new WritePreview(), new ViewPreview(), new WriteEnhancePreview() + new PagePreview(), new WritePreview(), new ViewPreview(), new WriteEnhancePreview(), new MobilePreview() }, set.toArray(new PreviewProvider[set.size()])); }