Browse Source

REPORT-19557 ToolbarItemProvider接口需要支持表单报表块

feature/big-screen
zack 5 years ago
parent
commit
23d2e69bb4
  1. 17
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  2. 6
      designer-base/src/main/java/com/fr/design/fun/ToolbarItemProvider.java
  3. 10
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolbarItem.java
  4. 3
      designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleElementCaseToolBarEditor.java

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

@ -114,13 +114,28 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
} }
/**
* 获取插件注册的工具栏按钮严格区分决策报表与普通模板
* @return
*/
public WidgetOption[] getStrictWebWidgetOptions() {
return createWebWidgetOptions(true);
}
public WidgetOption[] getWebWidgetOptions() { public WidgetOption[] getWebWidgetOptions() {
return createWebWidgetOptions(false);
}
private WidgetOption[] createWebWidgetOptions(boolean filterByTemplateType) {
Set<ToolbarItemProvider> set = getArray(ToolbarItemProvider.XML_TAG); Set<ToolbarItemProvider> set = getArray(ToolbarItemProvider.XML_TAG);
if (set.isEmpty()) { if (set.isEmpty()) {
return new WidgetOption[0]; return new WidgetOption[0];
} }
List<WidgetOption> list = new ArrayList<>(); List<WidgetOption> list = new ArrayList<>();
for (ToolbarItemProvider provider : set) { for (ToolbarItemProvider provider : set) {
if (filterByTemplateType && !provider.accept()) {
continue;
}
WidgetOption option = WidgetOptionFactory.createByWidgetClass( WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(), provider.nameForWidget(),
IOUtils.readIcon(provider.iconPathForWidget()), IOUtils.readIcon(provider.iconPathForWidget()),
@ -132,7 +147,6 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
} }
public Map<Class<? extends Widget>, Class<?>> getFormWidgetOptionsMap() { public Map<Class<? extends Widget>, Class<?>> getFormWidgetOptionsMap() {
Set<FormWidgetOptionProvider> set = getArray(FormWidgetOptionProvider.XML_TAG); Set<FormWidgetOptionProvider> set = getArray(FormWidgetOptionProvider.XML_TAG);
Map<Class<? extends Widget>, Class<?>> map = new HashMap<>(); Map<Class<? extends Widget>, Class<?>> map = new HashMap<>();
@ -170,7 +184,6 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
} }
public WidgetOption[] getCellWidgetOptions() { public WidgetOption[] getCellWidgetOptions() {
Set<CellWidgetOptionProvider> set = getArray(CellWidgetOptionProvider.XML_TAG); Set<CellWidgetOptionProvider> set = getArray(CellWidgetOptionProvider.XML_TAG);
if (set.isEmpty()) { if (set.isEmpty()) {

6
designer-base/src/main/java/com/fr/design/fun/ToolbarItemProvider.java

@ -36,4 +36,10 @@ public interface ToolbarItemProvider extends Mutable {
*/ */
String nameForWidget(); String nameForWidget();
/**
* 当前编辑的模板类型决策报表 or cpt是否支持
* @return 支持返回true,否则false
*/
boolean accept();
} }

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

@ -1,6 +1,9 @@
package com.fr.design.fun.impl; package com.fr.design.fun.impl;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.ToolbarItemProvider; import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API; import com.fr.stable.fun.mark.API;
@ -10,6 +13,7 @@ import com.fr.stable.fun.mark.API;
@API(level = ToolbarItemProvider.CURRENT_LEVEL) @API(level = ToolbarItemProvider.CURRENT_LEVEL)
public abstract class AbstractToolbarItem extends AbstractProvider implements ToolbarItemProvider { public abstract class AbstractToolbarItem extends AbstractProvider implements ToolbarItemProvider {
@Override
public int currentAPILevel() { public int currentAPILevel() {
return CURRENT_LEVEL; return CURRENT_LEVEL;
} }
@ -18,4 +22,10 @@ public abstract class AbstractToolbarItem extends AbstractProvider implements To
public String mark4Provider() { public String mark4Provider() {
return getClass().getName(); return getClass().getName();
} }
@Override
public boolean accept() {
JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return currentTemplate.isJWorkBook() || currentTemplate instanceof JVirtualTemplate;
}
} }

3
designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleElementCaseToolBarEditor.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.widget.accessibles; package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
@ -52,6 +53,8 @@ public class AccessibleElementCaseToolBarEditor extends UneditableAccessibleEdit
List<WidgetOption> defaultOptions = Arrays.asList(FormWebWidgetConstants.getFormElementCaseToolBarInstance()); List<WidgetOption> defaultOptions = Arrays.asList(FormWebWidgetConstants.getFormElementCaseToolBarInstance());
List<WidgetOption> options = new ArrayList<WidgetOption>(); List<WidgetOption> options = new ArrayList<WidgetOption>();
options.addAll(defaultOptions); options.addAll(defaultOptions);
WidgetOption[] widgetOptions = ExtraDesignClassManager.getInstance().getStrictWebWidgetOptions();
options.addAll(Arrays.asList(widgetOptions));
return options.toArray(new WidgetOption[options.size()]); return options.toArray(new WidgetOption[options.size()]);
} }

Loading…
Cancel
Save