Browse Source

Merge branch 'release/10.0' of http://cloud.finedevelop.com:2015/scm/~harrison/design into release/10.0

feature/big-screen
Harrison 5 years ago
parent
commit
b3355f517a
  1. 21
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  2. 12
      designer-base/src/main/java/com/fr/design/fun/ToolbarItemProvider.java
  3. 12
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolbarItem.java
  4. 70
      designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java
  5. 11
      designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleElementCaseToolBarEditor.java

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

@ -23,6 +23,7 @@ import com.fr.plugin.AbstractExtraClassManager;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.injectable.PluginSingleInjection; import com.fr.plugin.injectable.PluginSingleInjection;
import com.fr.plugin.solution.closeable.CloseableContainedSet; import com.fr.plugin.solution.closeable.CloseableContainedSet;
import com.fr.stable.Filter;
import com.fr.stable.plugin.ExtraDesignClassManagerProvider; import com.fr.stable.plugin.ExtraDesignClassManagerProvider;
import java.util.ArrayList; import java.util.ArrayList;
@ -113,14 +114,27 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
return result.toArray(new WidgetOption[result.size()]); return result.toArray(new WidgetOption[result.size()]);
} }
public WidgetOption[] getWebWidgetOptions() { public WidgetOption[] getWebWidgetOptions() {
return getWebWidgetOptions(new Filter<ToolbarItemProvider>() {
@Override
public boolean accept(ToolbarItemProvider toolbarItemProvider) {
return true;
}
});
}
public WidgetOption[] getWebWidgetOptions(Filter<ToolbarItemProvider> filter) {
Set<ToolbarItemProvider> set = getArray(ToolbarItemProvider.XML_TAG); Set<ToolbarItemProvider> set = getArray(ToolbarItemProvider.XML_TAG);
if (set.isEmpty()) { return getWebWidgetOptions(set, filter);
}
public WidgetOption[] getWebWidgetOptions(Set<ToolbarItemProvider> set, Filter<ToolbarItemProvider> filter) {
if (set == null || 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 (filter != null && filter.accept(provider)) {
WidgetOption option = WidgetOptionFactory.createByWidgetClass( WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(), provider.nameForWidget(),
IOUtils.readIcon(provider.iconPathForWidget()), IOUtils.readIcon(provider.iconPathForWidget()),
@ -128,11 +142,11 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
); );
list.add(option); list.add(option);
} }
}
return list.toArray(new WidgetOption[list.size()]); return list.toArray(new WidgetOption[list.size()]);
} }
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()) {

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

@ -1,6 +1,8 @@
package com.fr.design.fun; package com.fr.design.fun;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.stable.Filter;
import com.fr.stable.fun.mark.Mutable; import com.fr.stable.fun.mark.Mutable;
/** /**
@ -8,7 +10,7 @@ import com.fr.stable.fun.mark.Mutable;
* @since : 8.0 * @since : 8.0
* 自定义web工具栏菜单 * 自定义web工具栏菜单
*/ */
public interface ToolbarItemProvider extends Mutable { public interface ToolbarItemProvider extends Mutable, Filter<JTemplate> {
String XML_TAG = "ToolbarItemProvider"; String XML_TAG = "ToolbarItemProvider";
@ -36,4 +38,12 @@ public interface ToolbarItemProvider extends Mutable {
*/ */
String nameForWidget(); String nameForWidget();
/**
* 模板决策报表 or cpt是否支持此工具栏按钮
* JTemplate 模板
* @return 支持返回true, 否则false
*/
@Override
boolean accept(JTemplate template);
} }

12
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,12 @@ 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 jTemplate) {
if (jTemplate == null) {
jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
}
return jTemplate == null || jTemplate.isJWorkBook() || jTemplate instanceof JVirtualTemplate;
}
} }

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

@ -0,0 +1,70 @@
package com.fr.design;
import com.fr.config.dao.DaoContext;
import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.fun.ToolbarItemProvider;
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;
import com.fr.stable.Filter;
import com.fr.stable.module.Module;
import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert;
import java.util.HashSet;
import java.util.Set;
/**
* @author zack
* @version 10.0
* Created by zack on 2019/9/17
*/
public class ExtraDesignClassManagerTest extends TestCase {
@Override
protected void setUp() throws Exception {
DaoContext.setEntityDao(new LocalEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
ModuleContext.startModule(Module.PAGE_MODULE);
Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction());
}
public void testGetWebOption() {
try {
final JTemplate jTemplate = new JVirtualTemplate(null);
ToolbarItemProvider item = EasyMock.mock(ToolbarItemProvider.class);
ToolbarItemProvider item1 = EasyMock.mock(ToolbarItemProvider.class);
EasyMock.expect(item.accept(jTemplate)).andReturn(false).anyTimes();
EasyMock.expect(item.classForWidget()).andReturn(null).anyTimes();
EasyMock.expect(item.iconPathForWidget()).andReturn("").anyTimes();
EasyMock.expect(item.nameForWidget()).andReturn("1").anyTimes();
EasyMock.expect(item1.accept(jTemplate)).andReturn(true).anyTimes();
EasyMock.expect(item1.classForWidget()).andReturn(null).anyTimes();
EasyMock.expect(item1.iconPathForWidget()).andReturn("").anyTimes();
EasyMock.expect(item1.nameForWidget()).andReturn("2").anyTimes();
EasyMock.replay(item);
EasyMock.replay(item1);
Set<ToolbarItemProvider> set = new HashSet<>();
set.add(item);
set.add(item1);
WidgetOption[] widgetOptions = ExtraDesignClassManager.getInstance().getWebWidgetOptions(set, new Filter<ToolbarItemProvider>() {
@Override
public boolean accept(ToolbarItemProvider toolbarItemProvider) {
return toolbarItemProvider.accept(jTemplate);
}
});
Assert.assertEquals(1, widgetOptions.length);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}

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

@ -1,13 +1,17 @@
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.file.HistoryTemplateListCache;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.design.mainframe.FormWebWidgetConstants; import com.fr.design.mainframe.FormWebWidgetConstants;
import com.fr.design.mainframe.widget.editors.ElementCaseToolBarPane; import com.fr.design.mainframe.widget.editors.ElementCaseToolBarPane;
import com.fr.design.mainframe.widget.wrappers.ElementCaseToolBarWrapper; import com.fr.design.mainframe.widget.wrappers.ElementCaseToolBarWrapper;
import com.fr.form.web.FormToolBarManager; import com.fr.form.web.FormToolBarManager;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Filter;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.util.ArrayList; import java.util.ArrayList;
@ -52,6 +56,13 @@ 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().getWebWidgetOptions(new Filter<ToolbarItemProvider>() {
@Override
public boolean accept(ToolbarItemProvider toolbarItemProvider) {
return toolbarItemProvider.accept(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
}
});
options.addAll(Arrays.asList(widgetOptions));
return options.toArray(new WidgetOption[options.size()]); return options.toArray(new WidgetOption[options.size()]);
} }

Loading…
Cancel
Save