forked from fanruan/design
白岳
4 years ago
41 changed files with 2081 additions and 443 deletions
@ -0,0 +1,37 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.form.ui.mobile.MobileParamStyle; |
||||
import com.fr.stable.fun.mark.Mutable; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/12/30 |
||||
*/ |
||||
|
||||
public interface MobileParamUIProvider extends Mutable { |
||||
String XML_TAG = "MobileParamUIProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
|
||||
/** |
||||
* 扩展项的参数面板样式 |
||||
* @return |
||||
*/ |
||||
Class<? extends MobileParamStyle> classForMobileParamStyle(); |
||||
|
||||
/** |
||||
* 移动端参数面板中扩展项的面板 |
||||
* @return |
||||
*/ |
||||
Class<? extends BasicBeanPane<MobileParamStyle>> classForMobileParamAppearance(); |
||||
|
||||
/** |
||||
* 扩展项的名称描述 |
||||
* @return |
||||
*/ |
||||
String displayName(); |
||||
|
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.MobileParamUIProvider; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/12/30 |
||||
*/ |
||||
@API(level = MobileParamUIProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractMobileParamUIProvider extends AbstractProvider implements MobileParamUIProvider { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return getClass().getName(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.design.mainframe.mobile.provider; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.impl.AbstractMobileParamUIProvider; |
||||
import com.fr.design.mainframe.mobile.ui.DefaultMobileParamDefinePane; |
||||
import com.fr.form.ui.mobile.MobileParamStyle; |
||||
import com.fr.form.ui.mobile.impl.DefaultMobileParameterStyle; |
||||
import com.fr.locale.InterProviderFactory; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/4 |
||||
*/ |
||||
public class DefaultMobileParamUIProvider extends AbstractMobileParamUIProvider { |
||||
|
||||
@Override |
||||
public Class<? extends MobileParamStyle> classForMobileParamStyle() { |
||||
return DefaultMobileParameterStyle.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BasicBeanPane<MobileParamStyle>> classForMobileParamAppearance() { |
||||
return DefaultMobileParamDefinePane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String displayName() { |
||||
return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT"); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.fr.design.mainframe.mobile.provider; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.impl.AbstractMobileParamUIProvider; |
||||
import com.fr.design.mainframe.mobile.ui.EmptyMobileParamDefinePane; |
||||
import com.fr.form.ui.mobile.MobileParamStyle; |
||||
import com.fr.report.fun.MobileParamStyleProvider; |
||||
import com.fr.report.mobile.EmptyMobileParamStyle; |
||||
|
||||
/** |
||||
* 作为MobileParamStyleProvider接口实现兼容转换层 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/4 |
||||
*/ |
||||
public class EmptyMobileParamUIProvider extends AbstractMobileParamUIProvider { |
||||
|
||||
private MobileParamStyleProvider styleProvider; |
||||
|
||||
public EmptyMobileParamUIProvider(MobileParamStyleProvider styleProvider) { |
||||
this.styleProvider = styleProvider; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends MobileParamStyle> classForMobileParamStyle() { |
||||
return EmptyMobileParamStyle.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BasicBeanPane<MobileParamStyle>> classForMobileParamAppearance() { |
||||
return EmptyMobileParamDefinePane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String displayName() { |
||||
return styleProvider.descriptor(); |
||||
} |
||||
|
||||
public MobileParamStyleProvider getStyleProvider() { |
||||
return styleProvider; |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.form.ui.mobile.MobileParamStyle; |
||||
import com.fr.form.ui.mobile.impl.DefaultMobileParameterStyle; |
||||
import java.awt.BorderLayout; |
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/4 |
||||
*/ |
||||
public class DefaultMobileParamDefinePane extends BasicBeanPane<MobileParamStyle> { |
||||
|
||||
public DefaultMobileParamDefinePane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
this.setLayout(new BorderLayout()); |
||||
JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Set")); |
||||
this.add(centerPane); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MobileParamStyle ob) { |
||||
// do nothing
|
||||
} |
||||
|
||||
@Override |
||||
public MobileParamStyle updateBean() { |
||||
return new DefaultMobileParameterStyle(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.form.ui.mobile.MobileParamStyle; |
||||
import com.fr.report.fun.MobileParamStyleProvider; |
||||
import com.fr.report.mobile.EmptyMobileParamStyle; |
||||
import java.awt.BorderLayout; |
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/4 |
||||
*/ |
||||
public class EmptyMobileParamDefinePane extends BasicBeanPane<MobileParamStyle> { |
||||
|
||||
private final MobileParamStyleProvider styleProvider; |
||||
|
||||
public EmptyMobileParamDefinePane(MobileParamStyleProvider styleProvider) { |
||||
this.styleProvider = styleProvider; |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
this.setLayout(new BorderLayout()); |
||||
JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Set")); |
||||
this.add(centerPane); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void populateBean(MobileParamStyle ob) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public MobileParamStyle updateBean() { |
||||
return new EmptyMobileParamStyle(styleProvider); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.MobileParamUIProvider; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.mobile.provider.EmptyMobileParamUIProvider; |
||||
import com.fr.form.ui.mobile.MobileParamStyle; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.invoke.Reflect; |
||||
import com.fr.report.mobile.EmptyMobileParamStyle; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/4 |
||||
*/ |
||||
public class MobileParamDefinePane extends BasicBeanPane<MobileParamStyle> { |
||||
|
||||
private BasicBeanPane<MobileParamStyle> customBeanPane; |
||||
|
||||
public MobileParamDefinePane(MobileParamUIProvider provider) { |
||||
if (provider == null || provider.classForMobileParamAppearance() == null || provider.classForMobileParamAppearance() == null) { |
||||
return; |
||||
} |
||||
if (ComparatorUtils.equals(provider.classForMobileParamStyle(), EmptyMobileParamStyle.class)) { |
||||
EmptyMobileParamUIProvider emptyMobileParamUIProvider = (EmptyMobileParamUIProvider) provider; |
||||
this.customBeanPane = Reflect.on(provider.classForMobileParamAppearance()).create(emptyMobileParamUIProvider.getStyleProvider()).get(); |
||||
} else { |
||||
this.customBeanPane = Reflect.on(provider.classForMobileParamAppearance()).create().get(); |
||||
} |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.add(customBeanPane); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MobileParamStyle ob) { |
||||
this.customBeanPane.populateBean(ob); |
||||
} |
||||
|
||||
@Override |
||||
public MobileParamStyle updateBean() { |
||||
|
||||
return this.customBeanPane.updateBean(); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "MobileParamDefinePane"; |
||||
} |
||||
} |
@ -0,0 +1,150 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.MobileParamUIProvider; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.mobile.provider.DefaultMobileParamUIProvider; |
||||
import com.fr.design.mainframe.mobile.provider.EmptyMobileParamUIProvider; |
||||
import com.fr.form.ui.container.WParameterLayout; |
||||
import com.fr.form.ui.mobile.MobileParamStyle; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.report.ExtraReportClassManager; |
||||
import com.fr.report.fun.MobileParamStyleProvider; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.CardLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
import java.util.stream.Collectors; |
||||
import javax.swing.DefaultListCellRenderer; |
||||
import javax.swing.DefaultListModel; |
||||
import javax.swing.JList; |
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/4 |
||||
*/ |
||||
public class MobileParamSettingPane extends BasicPane { |
||||
|
||||
private DefaultListModel<String> listModel; |
||||
private JPanel right; |
||||
private CardLayout card; |
||||
private JList paramStyleList; |
||||
|
||||
|
||||
private Map<String, BasicBeanPane<MobileParamStyle>> map = new HashMap<>(); |
||||
|
||||
|
||||
public MobileParamSettingPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
|
||||
private void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
listModel = new DefaultListModel<>(); |
||||
card = new CardLayout(); |
||||
right = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||
right.setLayout(card); |
||||
MobileParamUIProvider[] mobileParamUIProviders = getMobileParamUIProviders(); |
||||
for (MobileParamUIProvider provider : mobileParamUIProviders) { |
||||
addShowPane(provider); |
||||
} |
||||
initLeftPane(); |
||||
initRightPane(); |
||||
} |
||||
|
||||
private void initLeftPane() { |
||||
paramStyleList = new JList<>(listModel); |
||||
paramStyleList.setCellRenderer(new DefaultListCellRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
if (value instanceof MobileParamStyle) { |
||||
MobileParamStyle style = (MobileParamStyle) value; |
||||
this.setText(style.toString()); |
||||
} |
||||
return this; |
||||
} |
||||
}); |
||||
paramStyleList.addListSelectionListener(e -> { |
||||
String selectedValue = (String) paramStyleList.getSelectedValue(); |
||||
card.show(right, selectedValue); |
||||
}); |
||||
JPanel leftPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
leftPane.add(paramStyleList); |
||||
leftPane.setPreferredSize(new Dimension(100, 500)); |
||||
this.add(leftPane, BorderLayout.WEST); |
||||
} |
||||
|
||||
private void initRightPane() { |
||||
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
JPanel attrConfPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
centerPane.setPreferredSize(new Dimension(500, 500)); |
||||
attrConfPane.add(right, BorderLayout.CENTER); |
||||
centerPane.add(attrConfPane, BorderLayout.CENTER); |
||||
this.add(centerPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
|
||||
public void populate(MobileParamStyle mobileParamStyle) { |
||||
if (mobileParamStyle != null) { |
||||
MobileParamUIProvider[] mobileParamUIProviders = getMobileParamUIProviders(); |
||||
for (int i = 0; i < mobileParamUIProviders.length; i++) { |
||||
MobileParamUIProvider provider = mobileParamUIProviders[i]; |
||||
if (ComparatorUtils.equals(mobileParamStyle.disPlayName(), provider.displayName())) { |
||||
String displayName = provider.displayName(); |
||||
paramStyleList.setSelectedIndex(i); |
||||
map.get(displayName).populateBean(mobileParamStyle); |
||||
card.show(right, displayName); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
paramStyleList.setSelectedIndex(0); |
||||
} |
||||
|
||||
private void addShowPane(MobileParamUIProvider provider) { |
||||
String displayName = provider.displayName(); |
||||
listModel.addElement(provider.displayName()); |
||||
BasicBeanPane<MobileParamStyle> paramStyleBasicBeanPane = new MobileParamDefinePane(provider); |
||||
right.add(displayName, paramStyleBasicBeanPane); |
||||
map.put(displayName, paramStyleBasicBeanPane); |
||||
} |
||||
|
||||
public MobileParamStyle update() { |
||||
return map.get(paramStyleList.getSelectedValue()).updateBean(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
private MobileParamUIProvider[] getMobileParamUIProviders() { |
||||
Set<MobileParamUIProvider> paramUIProviders = ExtraDesignClassManager.getInstance().getArray(MobileParamUIProvider.XML_TAG); |
||||
List<MobileParamUIProvider> result = new ArrayList<>(); |
||||
result.add(new DefaultMobileParamUIProvider()); |
||||
result.addAll(paramUIProviders); |
||||
Set<String> nameSets = paramUIProviders.stream().map(MobileParamUIProvider::displayName).collect(Collectors.toSet()); |
||||
// 兼容老接口
|
||||
Set<MobileParamStyleProvider> paramStyleProviders = ExtraReportClassManager.getInstance().getArray(MobileParamStyleProvider.MARK_STRING); |
||||
|
||||
paramStyleProviders = paramStyleProviders.stream().filter(provider -> !nameSets.contains(provider.descriptor())).collect(Collectors.toSet()); |
||||
|
||||
for (MobileParamStyleProvider provider : paramStyleProviders) { |
||||
result.add(new EmptyMobileParamUIProvider(provider)); |
||||
} |
||||
|
||||
return result.toArray(new MobileParamUIProvider[0]); |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.fr.design.mainframe.widget.wrappers; |
||||
|
||||
import com.fr.design.Exception.ValidationException; |
||||
import com.fr.design.designer.properties.Decoder; |
||||
import com.fr.design.designer.properties.Encoder; |
||||
import com.fr.locale.InterProviderFactory; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/4 |
||||
*/ |
||||
public class MobileParamWrapper implements Encoder, Decoder { |
||||
|
||||
@Nullable |
||||
@Override |
||||
public Object decode(String txt) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void validate(String txt) throws ValidationException { |
||||
// do nothing
|
||||
} |
||||
|
||||
@Override |
||||
public String encode(Object v) { |
||||
if (v == null) { |
||||
return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT"); |
||||
} |
||||
return v.toString(); |
||||
} |
||||
} |
@ -0,0 +1,57 @@
|
||||
package com.fr.design.upm; |
||||
|
||||
import com.fr.config.ServerPreferenceConfig; |
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.GeneralContext; |
||||
import org.easymock.EasyMock; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.powermock.api.easymock.PowerMock; |
||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
|
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2021/1/5 |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({ServerPreferenceConfig.class, CloudCenter.class}) |
||||
@SuppressStaticInitializationFor("com.fr.general.CloudCenter") |
||||
public class UpmUtilsTest { |
||||
|
||||
@Test |
||||
public void testRenderMap() { |
||||
|
||||
ServerPreferenceConfig serverPreferenceConfig = EasyMock.mock(ServerPreferenceConfig.class); |
||||
EasyMock.expect(serverPreferenceConfig.getOptimizedUPMVersion()).andReturn("1.0").anyTimes(); |
||||
PowerMock.mockStatic(ServerPreferenceConfig.class); |
||||
EasyMock.expect(ServerPreferenceConfig.getInstance()).andReturn(serverPreferenceConfig).anyTimes(); |
||||
|
||||
CloudCenter cloudCenter = EasyMock.mock(CloudCenter.class); |
||||
EasyMock.expect(cloudCenter.acquireUrlByKind("upm.script.version")).andReturn("2.0").anyTimes(); |
||||
PowerMock.mockStatic(CloudCenter.class); |
||||
EasyMock.expect(CloudCenter.getInstance()).andReturn(cloudCenter).anyTimes(); |
||||
|
||||
EasyMock.replay(serverPreferenceConfig, cloudCenter); |
||||
PowerMock.replayAll(); |
||||
|
||||
GeneralContext.setLocale(Locale.CHINA); |
||||
|
||||
Map<String, String> map4Tpl = UpmUtils.renderMap(); |
||||
Assert.assertEquals(map4Tpl.size(), 3); |
||||
Assert.assertEquals(map4Tpl.get("version"), "1.0"); |
||||
Assert.assertEquals(map4Tpl.get("new_version"), "2.0"); |
||||
Assert.assertEquals(map4Tpl.get("language"), "zh_CN"); |
||||
|
||||
|
||||
EasyMock.verify(serverPreferenceConfig, cloudCenter); |
||||
PowerMock.verifyAll(); |
||||
|
||||
} |
||||
} |
@ -1,191 +0,0 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.concurrent.NamedThreadFactory; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.chart.base.AttrTooltipRichText; |
||||
import com.fr.plugin.chart.type.TextAlign; |
||||
import com.fr.stable.StringUtils; |
||||
import com.teamdev.jxbrowser.chromium.Browser; |
||||
import com.teamdev.jxbrowser.chromium.JSValue; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; |
||||
|
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
|
||||
public class VanChartRichEditorPane { |
||||
|
||||
private static final String namespace = "Pool"; |
||||
private static final String variable = "data"; |
||||
private static final String richEditorPath = "/com/fr/design/editor/rich_editor.html"; |
||||
private static final String expression = "dispatch()"; |
||||
|
||||
private static ModernUIPane<RichEditorModel> richEditorPane; |
||||
private static Browser browser; |
||||
|
||||
public static void initRichEditorPane() { |
||||
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory("VanChartRichEditor")); |
||||
|
||||
try { |
||||
singleThreadExecutor.submit(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
try { |
||||
richEditorPane = initPane(new RichEditorModel()); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
}); |
||||
} finally { |
||||
singleThreadExecutor.shutdown(); |
||||
} |
||||
} |
||||
|
||||
public static ModernUIPane<RichEditorModel> createRichEditorPane(AttrTooltipRichText richEditor) { |
||||
RichEditorModel model = getRichEditorModel(richEditor); |
||||
|
||||
if (richEditorPane == null) { |
||||
richEditorPane = initPane(model); |
||||
} else if (browser != null) { |
||||
updatePane(browser, model); |
||||
} |
||||
|
||||
return richEditorPane; |
||||
} |
||||
|
||||
public static ModernUIPane<RichEditorModel> initPane(RichEditorModel model) { |
||||
return new ModernUIPane.Builder<RichEditorModel>() |
||||
.prepare(new ScriptContextAdapter() { |
||||
public void onScriptContextCreated(ScriptContextEvent event) { |
||||
browser = event.getBrowser(); |
||||
browser.getCacheStorage().clearCache(); |
||||
|
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); |
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); |
||||
browser.executeJavaScript(generateTransformI18nJS()); |
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); |
||||
|
||||
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); |
||||
ns.asObject().setProperty(variable, model); |
||||
} |
||||
}) |
||||
.withEMB(richEditorPath) |
||||
.namespace(namespace).build(); |
||||
} |
||||
|
||||
public static void updatePane(Browser browser, RichEditorModel model) { |
||||
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); |
||||
ns.asObject().setProperty(variable, model); |
||||
browser.executeJavaScript("window." + namespace + "." + expression); |
||||
} |
||||
|
||||
public static RichEditorModel getRichEditorModel(AttrTooltipRichText richText) { |
||||
Map<String, String> paramsMap = richText.getParams(); |
||||
StringBuilder paramsStr = new StringBuilder(StringUtils.EMPTY); |
||||
|
||||
if (paramsMap != null) { |
||||
for (Map.Entry<String, String> entry : paramsMap.entrySet()) { |
||||
paramsStr.append(entry.getKey()).append(":").append(entry.getValue()); |
||||
paramsStr.append("-"); |
||||
} |
||||
} |
||||
|
||||
int len = paramsStr.length(); |
||||
|
||||
if (len > 0) { |
||||
paramsStr.deleteCharAt(len - 1); |
||||
} |
||||
|
||||
String content = richText.getContent(); |
||||
String initParams = StringUtils.EMPTY; |
||||
String align = StringUtils.EMPTY; |
||||
|
||||
if (content.contains("data-id") && !content.contains("class")) { |
||||
initParams = richText.getInitParamsContent(); |
||||
|
||||
String left = TextAlign.LEFT.getAlign(); |
||||
String center = TextAlign.CENTER.getAlign(); |
||||
|
||||
align = content.contains(left) ? left : center; |
||||
} |
||||
|
||||
return new RichEditorModel(content, richText.isAuto(), paramsStr.toString(), initParams, align); |
||||
} |
||||
|
||||
public static String generateTransformI18nJS() { |
||||
String language = "zh_CN"; |
||||
|
||||
Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); |
||||
|
||||
if (locale != null) { |
||||
language = locale.toString(); |
||||
} |
||||
|
||||
return "!(function () { window.transformI18n && window.transformI18n('" + language + "' || 'zh_CN'); }());"; |
||||
} |
||||
|
||||
public static class RichEditorModel { |
||||
private String content = StringUtils.EMPTY; |
||||
private boolean auto = true; |
||||
private String params = StringUtils.EMPTY; |
||||
private String initParams = StringUtils.EMPTY; |
||||
private String align = TextAlign.LEFT.getAlign(); |
||||
|
||||
public RichEditorModel() { |
||||
} |
||||
|
||||
public RichEditorModel(String content, boolean auto, String params, String initParams, String align) { |
||||
this.content = content; |
||||
this.auto = auto; |
||||
this.params = params; |
||||
this.initParams = initParams; |
||||
this.align = align; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public boolean isAuto() { |
||||
return auto; |
||||
} |
||||
|
||||
public void setAuto(boolean auto) { |
||||
this.auto = auto; |
||||
} |
||||
|
||||
public String getParams() { |
||||
return params; |
||||
} |
||||
|
||||
public void setParams(String params) { |
||||
this.params = params; |
||||
} |
||||
|
||||
public String getInitParams() { |
||||
return initParams; |
||||
} |
||||
|
||||
public void setInitParams(String initParams) { |
||||
this.initParams = initParams; |
||||
} |
||||
|
||||
public String getAlign() { |
||||
return align; |
||||
} |
||||
|
||||
public void setAlign(String align) { |
||||
this.align = align; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,79 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.data.util.function.AbstractDataFunction; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.style.FormatPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
import com.fr.van.chart.designer.component.format.FormatPaneWithOutFont; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionListener; |
||||
import java.text.Format; |
||||
|
||||
public class VanChartFieldAttrPane extends JPanel { |
||||
|
||||
private FormatPane fieldFormatPane; |
||||
private CalculateComboBox fieldDataFunction; |
||||
|
||||
private JPanel fieldFunctionPane; |
||||
|
||||
public VanChartFieldAttrPane() { |
||||
initComponents(); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(fieldFormatPane, BorderLayout.NORTH); |
||||
this.add(fieldFunctionPane, BorderLayout.CENTER); |
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
double p = TableLayout.PREFERRED; |
||||
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
fieldFormatPane = new FormatPaneWithOutFont() { |
||||
protected JPanel createContentPane(Component[][] components) { |
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p, p}, new double[]{d, e}); |
||||
} |
||||
}; |
||||
|
||||
fieldDataFunction = new CalculateComboBox(); |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), fieldDataFunction} |
||||
}; |
||||
|
||||
fieldFunctionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{d, e}); |
||||
} |
||||
|
||||
public void registerFunctionListener(ActionListener listener) { |
||||
fieldDataFunction.addActionListener(listener); |
||||
} |
||||
|
||||
public void registerChangeListener(UIObserverListener listener) { |
||||
fieldFormatPane.registerChangeListener(listener); |
||||
} |
||||
|
||||
public void populate(Format format, AbstractDataFunction dataFunction, boolean showDataFunction) { |
||||
fieldFormatPane.populateBean(format); |
||||
fieldDataFunction.populateBean(dataFunction); |
||||
fieldFunctionPane.setVisible(showDataFunction); |
||||
} |
||||
|
||||
public Format updateFormat() { |
||||
return fieldFormatPane.update(); |
||||
} |
||||
|
||||
public AbstractDataFunction updateDataFunction() { |
||||
return fieldDataFunction.updateBean(); |
||||
} |
||||
} |
@ -0,0 +1,141 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.data.util.function.DataFunction; |
||||
import com.fr.data.util.function.NoneFunction; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIToggleButton; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipFormat; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.Icon; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.text.Format; |
||||
|
||||
public class VanChartFieldButton extends JPanel { |
||||
|
||||
private static final Icon ADD_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"); |
||||
|
||||
private static final int W = 200; |
||||
private static final int H = 28; |
||||
|
||||
private final String fieldName; |
||||
private final String fieldId; |
||||
|
||||
private final AttrTooltipFormat tooltipFormat; |
||||
private final boolean showDataFunction; |
||||
|
||||
private UIToggleButton fieldButton; |
||||
private UIButton addButton; |
||||
|
||||
private DataFunction dataFunction = new NoneFunction(); |
||||
|
||||
public VanChartFieldButton(String fieldName, AttrTooltipFormat format, boolean showDataFunction, VanChartFieldListener listener) { |
||||
this.fieldName = fieldName; |
||||
this.tooltipFormat = format; |
||||
this.showDataFunction = showDataFunction; |
||||
|
||||
this.fieldId = format == null ? StringUtils.EMPTY : format.getFormatJSONKey(); |
||||
|
||||
initComponents(fieldName, listener); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(getContentPane(), BorderLayout.CENTER); |
||||
} |
||||
|
||||
public String getFieldName() { |
||||
return fieldName; |
||||
} |
||||
|
||||
public boolean isEnable() { |
||||
return this.tooltipFormat.isEnable(); |
||||
} |
||||
|
||||
public void setEnable(boolean enable) { |
||||
this.tooltipFormat.setEnable(enable); |
||||
} |
||||
|
||||
public Format getFormat() { |
||||
return tooltipFormat.getFormat(); |
||||
} |
||||
|
||||
public void setFormat(Format format) { |
||||
this.tooltipFormat.setFormat(format); |
||||
} |
||||
|
||||
public DataFunction getDataFunction() { |
||||
return dataFunction; |
||||
} |
||||
|
||||
public void setDataFunction(DataFunction dataFunction) { |
||||
this.dataFunction = dataFunction; |
||||
} |
||||
|
||||
public boolean isShowDataFunction() { |
||||
return showDataFunction; |
||||
} |
||||
|
||||
public String getFormatJs() { |
||||
return this.tooltipFormat.getJs(); |
||||
} |
||||
|
||||
private void initComponents(String fieldName, VanChartFieldListener listener) { |
||||
fieldButton = new UIToggleButton(fieldName) { |
||||
|
||||
protected MouseListener getMouseListener() { |
||||
|
||||
return new MouseAdapter() { |
||||
public void mousePressed(MouseEvent e) { |
||||
setSelected(true); |
||||
|
||||
listener.refreshSelectedPane(fieldName); |
||||
listener.setGlobalName(fieldName); |
||||
listener.populateFieldFormatPane(); |
||||
} |
||||
}; |
||||
} |
||||
}; |
||||
|
||||
addButton = new UIButton(ADD_ICON); |
||||
|
||||
addButton.addMouseListener(new MouseAdapter() { |
||||
|
||||
public void mousePressed(MouseEvent e) { |
||||
super.mousePressed(e); |
||||
|
||||
listener.addSelectedField(fieldName, fieldId); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private JPanel getContentPane() { |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{fieldButton, addButton} |
||||
}; |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; |
||||
|
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {e, d}; |
||||
|
||||
JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 5, 0); |
||||
content.setPreferredSize(new Dimension(W, H)); |
||||
|
||||
return content; |
||||
} |
||||
|
||||
public void setSelectedState(boolean selected) { |
||||
fieldButton.setSelected(selected); |
||||
} |
||||
} |
@ -0,0 +1,382 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.data.util.function.AbstractDataFunction; |
||||
import com.fr.data.util.function.DataFunction; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.chart.base.AttrTooltipContent; |
||||
import com.fr.plugin.chart.base.TableFieldCollection; |
||||
import com.fr.plugin.chart.base.TableFieldDefinition; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipFieldFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.text.Format; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class VanChartFieldListPane extends JPanel { |
||||
|
||||
private static final int FIELD_ADD_W = 400; |
||||
private static final int FIELD_ADD_H = 28; |
||||
|
||||
private VanChartFieldButton categoryNameButton; |
||||
private VanChartFieldButton seriesNameButton; |
||||
private VanChartFieldButton valueButton; |
||||
private VanChartFieldButton percentButton; |
||||
|
||||
private VanChartFieldAttrPane fieldAttrPane; |
||||
private ModernUIPane<VanChartRichEditorModel> richEditorPane; |
||||
private List<String> tableFieldNameList; |
||||
private List<VanChartFieldButton> tableFieldButtonList = new ArrayList<>(); |
||||
private TableFieldCollection tableFieldCollection = new TableFieldCollection(); |
||||
|
||||
private VanChartFieldListener fieldListener; |
||||
|
||||
public VanChartFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { |
||||
|
||||
List<String> richEditorFieldNames = VanChartRichEditorPane.getFieldNames(); |
||||
|
||||
this.tableFieldNameList = richEditorFieldNames == null ? new ArrayList<>() : richEditorFieldNames; |
||||
|
||||
this.fieldAttrPane = fieldAttrPane; |
||||
this.richEditorPane = richEditorPane; |
||||
|
||||
initFieldListListener(); |
||||
initDefaultFieldButton(); |
||||
|
||||
registerAttrListener(); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
this.add(createDefaultFieldPane(), BorderLayout.CENTER); |
||||
this.add(createTableFieldPane(), BorderLayout.SOUTH); |
||||
} |
||||
|
||||
public VanChartFieldButton getCategoryNameButton() { |
||||
return categoryNameButton; |
||||
} |
||||
|
||||
public void setCategoryNameButton(VanChartFieldButton categoryNameButton) { |
||||
this.categoryNameButton = categoryNameButton; |
||||
} |
||||
|
||||
public VanChartFieldButton getSeriesNameButton() { |
||||
return seriesNameButton; |
||||
} |
||||
|
||||
public void setSeriesNameButton(VanChartFieldButton seriesNameButton) { |
||||
this.seriesNameButton = seriesNameButton; |
||||
} |
||||
|
||||
public VanChartFieldButton getValueButton() { |
||||
return valueButton; |
||||
} |
||||
|
||||
public void setValueButton(VanChartFieldButton valueButton) { |
||||
this.valueButton = valueButton; |
||||
} |
||||
|
||||
public VanChartFieldButton getPercentButton() { |
||||
return percentButton; |
||||
} |
||||
|
||||
public void setPercentButton(VanChartFieldButton percentButton) { |
||||
this.percentButton = percentButton; |
||||
} |
||||
|
||||
public VanChartFieldListener getFieldListener() { |
||||
return fieldListener; |
||||
} |
||||
|
||||
private JPanel createDefaultFieldPane() { |
||||
JPanel fieldPane = new JPanel(); |
||||
|
||||
fieldPane.setLayout(new GridLayout(0, 1, 1, 0)); |
||||
|
||||
addDefaultFieldButton(fieldPane); |
||||
|
||||
fieldPane.setPreferredSize(new Dimension(FIELD_ADD_W, getDefaultFieldButtonList().size() * FIELD_ADD_H)); |
||||
fieldPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); |
||||
|
||||
return fieldPane; |
||||
} |
||||
|
||||
protected void initDefaultFieldButton() { |
||||
categoryNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"), |
||||
new AttrTooltipCategoryFormat(), false, fieldListener); |
||||
|
||||
seriesNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), |
||||
new AttrTooltipSeriesFormat(), false, fieldListener); |
||||
|
||||
valueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), |
||||
new AttrTooltipValueFormat(), false, fieldListener); |
||||
|
||||
percentButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Percent"), |
||||
new AttrTooltipPercentFormat(), false, fieldListener); |
||||
} |
||||
|
||||
protected void addDefaultFieldButton(JPanel fieldPane) { |
||||
fieldPane.add(categoryNameButton); |
||||
fieldPane.add(seriesNameButton); |
||||
fieldPane.add(valueButton); |
||||
fieldPane.add(percentButton); |
||||
} |
||||
|
||||
private JPanel createTableFieldPane() { |
||||
if (tableFieldNameList == null || tableFieldNameList.isEmpty()) { |
||||
return new JPanel(); |
||||
} |
||||
|
||||
JPanel tableField = new JPanel(); |
||||
|
||||
tableField.setLayout(new GridLayout(0, 1, 1, 0)); |
||||
|
||||
for (String name : tableFieldNameList) { |
||||
VanChartFieldButton fieldButton = new VanChartFieldButton(name, new AttrTooltipFieldFormat(name), true, fieldListener); |
||||
|
||||
tableField.add(fieldButton); |
||||
tableFieldButtonList.add(fieldButton); |
||||
} |
||||
|
||||
tableField.setPreferredSize(new Dimension(FIELD_ADD_W, tableFieldNameList.size() * FIELD_ADD_H)); |
||||
|
||||
return TableLayout4VanChartHelper.createExpandablePaneWithTitleTopGap("数据集字段", tableField); |
||||
} |
||||
|
||||
protected List<VanChartFieldButton> getDefaultFieldButtonList() { |
||||
List<VanChartFieldButton> defaultFieldButtonList = new ArrayList<>(); |
||||
|
||||
defaultFieldButtonList.add(categoryNameButton); |
||||
defaultFieldButtonList.add(seriesNameButton); |
||||
defaultFieldButtonList.add(valueButton); |
||||
defaultFieldButtonList.add(percentButton); |
||||
|
||||
return defaultFieldButtonList; |
||||
} |
||||
|
||||
private void initFieldListListener() { |
||||
|
||||
fieldListener = new VanChartFieldListener() { |
||||
|
||||
private String fieldName; |
||||
|
||||
public void setGlobalName(String fieldName) { |
||||
this.fieldName = fieldName; |
||||
} |
||||
|
||||
public String getGlobalName() { |
||||
return this.fieldName; |
||||
} |
||||
|
||||
public VanChartFieldButton getSelectedField() { |
||||
List<VanChartFieldButton> defaultFieldButtonList = getDefaultFieldButtonList(); |
||||
|
||||
for (VanChartFieldButton fieldButton : defaultFieldButtonList) { |
||||
if (ComparatorUtils.equals(fieldButton.getFieldName(), this.fieldName)) { |
||||
return fieldButton; |
||||
} |
||||
} |
||||
|
||||
for (VanChartFieldButton fieldButton : tableFieldButtonList) { |
||||
if (ComparatorUtils.equals(fieldButton.getFieldName(), this.fieldName)) { |
||||
return fieldButton; |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public void refreshSelectedPane(String fieldName) { |
||||
if (ComparatorUtils.equals(fieldName, this.fieldName)) { |
||||
return; |
||||
} |
||||
|
||||
List<VanChartFieldButton> defaultFieldButtonList = getDefaultFieldButtonList(); |
||||
|
||||
for (VanChartFieldButton fieldButton : defaultFieldButtonList) { |
||||
fieldButton.setSelectedState(ComparatorUtils.equals(fieldButton.getFieldName(), fieldName)); |
||||
} |
||||
|
||||
for (VanChartFieldButton fieldButton : tableFieldButtonList) { |
||||
fieldButton.setSelectedState(ComparatorUtils.equals(fieldButton.getFieldName(), fieldName)); |
||||
} |
||||
} |
||||
|
||||
public void addSelectedField(String fieldName, String fieldId) { |
||||
VanChartRichEditorModel model = richEditorPane.update(); |
||||
model.setAddition(fieldName); |
||||
VanChartRichEditorPane.richEditorAddField(model); |
||||
|
||||
if (tableFieldNameList.contains(fieldName)) { |
||||
int index = tableFieldNameList.indexOf(fieldName); |
||||
|
||||
VanChartFieldButton fieldButton = tableFieldButtonList.get(index); |
||||
Format fieldFormat = fieldButton.getFormat(); |
||||
DataFunction dataFunction = fieldButton.getDataFunction(); |
||||
|
||||
tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); |
||||
} |
||||
} |
||||
|
||||
public void populateFieldFormatPane() { |
||||
VanChartFieldButton fieldButton = this.getSelectedField(); |
||||
|
||||
if (fieldButton == null) { |
||||
return; |
||||
} |
||||
|
||||
Format format = fieldButton.getFormat(); |
||||
AbstractDataFunction dataFunction = (AbstractDataFunction) fieldButton.getDataFunction(); |
||||
boolean showDataFunction = fieldButton.isShowDataFunction(); |
||||
|
||||
fieldAttrPane.populate(format, dataFunction, showDataFunction); |
||||
} |
||||
|
||||
public void updateFieldFormatPane() { |
||||
VanChartFieldButton fieldButton = this.getSelectedField(); |
||||
|
||||
if (fieldButton == null) { |
||||
return; |
||||
} |
||||
|
||||
fieldButton.setFormat(fieldAttrPane.updateFormat()); |
||||
fieldButton.setDataFunction(fieldAttrPane.updateDataFunction()); |
||||
|
||||
if (tableFieldNameList.contains(fieldName)) { |
||||
Format fieldFormat = fieldButton.getFormat(); |
||||
DataFunction dataFunction = fieldButton.getDataFunction(); |
||||
|
||||
tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
private void registerAttrListener() { |
||||
|
||||
fieldAttrPane.registerFunctionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
fieldListener.updateFieldFormatPane(); |
||||
} |
||||
}); |
||||
|
||||
fieldAttrPane.registerChangeListener(new UIObserverListener() { |
||||
public void doChange() { |
||||
fieldListener.updateFieldFormatPane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkFieldListSelected() { |
||||
List<VanChartFieldButton> defaultFieldButtonList = getDefaultFieldButtonList(); |
||||
|
||||
if (defaultFieldButtonList != null && defaultFieldButtonList.size() > 0) { |
||||
String selected = defaultFieldButtonList.get(0).getFieldName(); |
||||
|
||||
fieldListener.refreshSelectedPane(selected); |
||||
fieldListener.setGlobalName(selected); |
||||
fieldListener.populateFieldFormatPane(); |
||||
} |
||||
} |
||||
|
||||
public void populate(AttrTooltipContent tooltipContent) { |
||||
populateDefaultField(tooltipContent); |
||||
populateTableField(tooltipContent); |
||||
|
||||
// 初次打开富文本界面选中第一个
|
||||
checkFieldListSelected(); |
||||
} |
||||
|
||||
public void populateDefaultField(AttrTooltipContent tooltipContent) { |
||||
populateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat()); |
||||
populateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat()); |
||||
populateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat()); |
||||
populateButtonFormat(percentButton, tooltipContent.getRichTextPercentFormat()); |
||||
} |
||||
|
||||
public void populateButtonFormat(VanChartFieldButton button, AttrTooltipFormat format) { |
||||
if (button == null || format == null) { |
||||
return; |
||||
} |
||||
|
||||
button.setEnable(format.isEnable()); |
||||
button.setFormat(format.getFormat()); |
||||
} |
||||
|
||||
public void populateTableField(AttrTooltipContent tooltipContent) { |
||||
TableFieldCollection fieldCollection = tooltipContent.getFieldCollection(); |
||||
|
||||
if (fieldCollection == null) { |
||||
return; |
||||
} |
||||
|
||||
Map<String, TableFieldDefinition> fieldDefinitionGroup = fieldCollection.getFieldNameFormulaMap(); |
||||
|
||||
if (fieldDefinitionGroup == null || fieldDefinitionGroup.isEmpty()) { |
||||
return; |
||||
} |
||||
|
||||
this.tableFieldCollection = new TableFieldCollection(); |
||||
|
||||
for (int i = 0, len = tableFieldNameList.size(); i < len; i++) { |
||||
String fieldName = tableFieldNameList.get(i); |
||||
VanChartFieldButton fieldButton = tableFieldButtonList.get(i); |
||||
TableFieldDefinition fieldDefinition = fieldDefinitionGroup.get(fieldName); |
||||
|
||||
if (fieldDefinitionGroup.containsKey(fieldName)) { |
||||
Format fieldFormat = fieldDefinition.getFormat(); |
||||
DataFunction dataFunction = fieldDefinition.getDataFunction(); |
||||
|
||||
fieldButton.setFormat(fieldFormat); |
||||
fieldButton.setDataFunction(dataFunction); |
||||
|
||||
this.tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void update(AttrTooltipContent tooltipContent) { |
||||
updateDefaultField(tooltipContent); |
||||
updateTableField(tooltipContent); |
||||
} |
||||
|
||||
public void updateDefaultField(AttrTooltipContent tooltipContent) { |
||||
updateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat()); |
||||
updateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat()); |
||||
updateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat()); |
||||
updateButtonFormat(percentButton, tooltipContent.getRichTextPercentFormat()); |
||||
} |
||||
|
||||
public void updateTableField(AttrTooltipContent tooltipContent) { |
||||
try { |
||||
tooltipContent.setFieldCollection(this.tableFieldCollection); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
public void updateButtonFormat(VanChartFieldButton button, AttrTooltipFormat format) { |
||||
if (button == null || format == null) { |
||||
return; |
||||
} |
||||
|
||||
format.setEnable(button.isEnable()); |
||||
format.setFormat(button.getFormat()); |
||||
} |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.design.event.GlobalNameListener; |
||||
|
||||
public interface VanChartFieldListener extends GlobalNameListener { |
||||
|
||||
public VanChartFieldButton getSelectedField(); |
||||
|
||||
public void refreshSelectedPane(String fieldName); |
||||
|
||||
public void addSelectedField(String fieldName, String fieldId); |
||||
|
||||
public void populateFieldFormatPane(); |
||||
|
||||
public void updateFieldFormatPane(); |
||||
|
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.plugin.chart.type.TextAlign; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
public class VanChartRichEditorModel { |
||||
|
||||
private String content = StringUtils.EMPTY; |
||||
private boolean auto = true; |
||||
private String params = StringUtils.EMPTY; |
||||
private String initParams = StringUtils.EMPTY; |
||||
private String align = TextAlign.LEFT.getAlign(); |
||||
private String addition = StringUtils.EMPTY; |
||||
|
||||
public VanChartRichEditorModel() { |
||||
} |
||||
|
||||
public VanChartRichEditorModel(String content, boolean auto, String params, String initParams, String align) { |
||||
this.content = content; |
||||
this.auto = auto; |
||||
this.params = params; |
||||
this.initParams = initParams; |
||||
this.align = align; |
||||
this.addition = StringUtils.EMPTY; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public boolean isAuto() { |
||||
return auto; |
||||
} |
||||
|
||||
public void setAuto(boolean auto) { |
||||
this.auto = auto; |
||||
} |
||||
|
||||
public String getParams() { |
||||
return params; |
||||
} |
||||
|
||||
public void setParams(String params) { |
||||
this.params = params; |
||||
} |
||||
|
||||
public String getInitParams() { |
||||
return initParams; |
||||
} |
||||
|
||||
public void setInitParams(String initParams) { |
||||
this.initParams = initParams; |
||||
} |
||||
|
||||
public String getAlign() { |
||||
return align; |
||||
} |
||||
|
||||
public void setAlign(String align) { |
||||
this.align = align; |
||||
} |
||||
|
||||
public String getAddition() { |
||||
return addition; |
||||
} |
||||
|
||||
public void setAddition(String addition) { |
||||
this.addition = addition; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,195 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.base.chart.chartdata.TopDefinitionProvider; |
||||
import com.fr.chart.chartattr.Chart; |
||||
import com.fr.chart.chartdata.MoreNameCDDefinition; |
||||
import com.fr.chart.chartdata.OneValueCDDefinition; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.data.impl.EmbeddedTableData; |
||||
import com.fr.design.DesignModelAdapter; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.chart.base.AttrTooltipRichText; |
||||
import com.fr.plugin.chart.type.TextAlign; |
||||
import com.fr.stable.StringUtils; |
||||
import com.teamdev.jxbrowser.chromium.Browser; |
||||
import com.teamdev.jxbrowser.chromium.JSValue; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; |
||||
|
||||
import java.util.List; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
public class VanChartRichEditorPane { |
||||
|
||||
private static final String NAME_SPACE = "Pool"; |
||||
private static final String VARIABLE = "data"; |
||||
|
||||
private static final String RICH_EDITOR_HTML = "/com/fr/design/editor/rich_editor.html"; |
||||
|
||||
private static final String REFRESH = "refresh()"; |
||||
private static final String ADD_FIELD = "addField()"; |
||||
|
||||
private static ModernUIPane<VanChartRichEditorModel> richEditorPane; |
||||
private static Browser browser; |
||||
private static List<String> fieldNames; |
||||
|
||||
public static List<String> getFieldNames() { |
||||
return fieldNames; |
||||
} |
||||
|
||||
public static void refreshFieldNames(Chart chart) { |
||||
VanChartRichEditorPane.fieldNames = null; |
||||
|
||||
if (chart == null) { |
||||
return; |
||||
} |
||||
|
||||
TopDefinitionProvider definition = chart.getFilterDefinition(); |
||||
|
||||
if (definition == null) { |
||||
return; |
||||
} |
||||
|
||||
DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); |
||||
TableDataSource tableDataSource = adapter == null ? null : adapter.getBook(); |
||||
|
||||
TableData tableData = null; |
||||
|
||||
if (ComparatorUtils.equals(definition.getDataDefinitionType(), OneValueCDDefinition.DEFINITION_TYPE)) { |
||||
OneValueCDDefinition oneValueCDDefinition = (OneValueCDDefinition) definition; |
||||
tableData = oneValueCDDefinition.getTableData(); |
||||
} |
||||
|
||||
if (ComparatorUtils.equals(definition.getDataDefinitionType(), MoreNameCDDefinition.DEFINITION_TYPE)) { |
||||
MoreNameCDDefinition moreNameCDDefinition = (MoreNameCDDefinition) definition; |
||||
tableData = moreNameCDDefinition.getTableData(); |
||||
} |
||||
|
||||
if (tableData == null) { |
||||
return; |
||||
} |
||||
|
||||
try { |
||||
EmbeddedTableData embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataSource, |
||||
tableData, TableData.RESULT_NOT_NEED, false); |
||||
|
||||
List<String> fieldNames = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); |
||||
VanChartRichEditorPane.fieldNames = fieldNames; |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
public static ModernUIPane<VanChartRichEditorModel> createRichEditorPane(AttrTooltipRichText richEditor) { |
||||
VanChartRichEditorModel model = getRichEditorModel(richEditor); |
||||
return createRichEditorPane(model); |
||||
} |
||||
|
||||
public static ModernUIPane<VanChartRichEditorModel> createRichEditorPane(VanChartRichEditorModel model) { |
||||
if (richEditorPane == null) { |
||||
richEditorPane = initPane(model); |
||||
} else { |
||||
richEditorRefresh(model); |
||||
} |
||||
|
||||
return richEditorPane; |
||||
} |
||||
|
||||
public static void richEditorRefresh(VanChartRichEditorModel model) { |
||||
if (richEditorPane != null && browser != null) { |
||||
refresh(browser, model); |
||||
} |
||||
} |
||||
|
||||
public static void richEditorAddField(VanChartRichEditorModel model) { |
||||
if (richEditorPane != null && browser != null) { |
||||
addField(browser, model); |
||||
} |
||||
} |
||||
|
||||
public static ModernUIPane<VanChartRichEditorModel> initPane(VanChartRichEditorModel model) { |
||||
return new ModernUIPane.Builder<VanChartRichEditorModel>() |
||||
.prepare(new ScriptContextAdapter() { |
||||
public void onScriptContextCreated(ScriptContextEvent event) { |
||||
browser = event.getBrowser(); |
||||
browser.getCacheStorage().clearCache(); |
||||
|
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); |
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); |
||||
browser.executeJavaScript(generateTransformI18nJS()); |
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); |
||||
|
||||
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); |
||||
ns.asObject().setProperty(VARIABLE, model); |
||||
} |
||||
}) |
||||
.withEMB(RICH_EDITOR_HTML) |
||||
.namespace(NAME_SPACE).build(); |
||||
} |
||||
|
||||
public static void refresh(Browser browser, VanChartRichEditorModel model) { |
||||
stateChange(browser, model, REFRESH); |
||||
} |
||||
|
||||
public static void addField(Browser browser, VanChartRichEditorModel model) { |
||||
stateChange(browser, model, ADD_FIELD); |
||||
} |
||||
|
||||
public static void stateChange(Browser browser, VanChartRichEditorModel model, String trigger) { |
||||
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); |
||||
ns.asObject().setProperty(VARIABLE, model); |
||||
browser.executeJavaScript("window." + NAME_SPACE + "." + trigger); |
||||
} |
||||
|
||||
public static VanChartRichEditorModel getRichEditorModel(AttrTooltipRichText richText) { |
||||
Map<String, String> paramsMap = richText.getParams(); |
||||
StringBuilder paramsStr = new StringBuilder(StringUtils.EMPTY); |
||||
|
||||
if (paramsMap != null) { |
||||
for (Map.Entry<String, String> entry : paramsMap.entrySet()) { |
||||
paramsStr.append(entry.getKey()).append(":").append(entry.getValue()); |
||||
paramsStr.append("-"); |
||||
} |
||||
} |
||||
|
||||
int len = paramsStr.length(); |
||||
|
||||
if (len > 0) { |
||||
paramsStr.deleteCharAt(len - 1); |
||||
} |
||||
|
||||
String content = richText.getContent(); |
||||
String initParams = StringUtils.EMPTY; |
||||
String align = StringUtils.EMPTY; |
||||
|
||||
if (content.contains("data-id") && !content.contains("class")) { |
||||
initParams = richText.getInitParamsContent(); |
||||
|
||||
String left = TextAlign.LEFT.getAlign(); |
||||
String center = TextAlign.CENTER.getAlign(); |
||||
|
||||
align = content.contains(left) ? left : center; |
||||
} |
||||
|
||||
return new VanChartRichEditorModel(content, richText.isAuto(), paramsStr.toString(), initParams, align); |
||||
} |
||||
|
||||
public static String generateTransformI18nJS() { |
||||
String language = "zh_CN"; |
||||
|
||||
Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); |
||||
|
||||
if (locale != null) { |
||||
language = locale.toString(); |
||||
} |
||||
|
||||
return "!(function () { window.transformI18n && window.transformI18n('" + language + "' || 'zh_CN'); }());"; |
||||
} |
||||
} |
@ -0,0 +1,95 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.plugin.chart.base.AttrTooltipContent; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
|
||||
// 标签提示中的富文本面板,包含字段设置和富文本编辑器
|
||||
public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> { |
||||
|
||||
private static final int FIELD_PANE_W = 470; |
||||
private static final int FIELD_PANE_H = 270; |
||||
|
||||
private static final int RICH_EDITOR_W = 940; |
||||
private static final int RICH_EDITOR_H = 260; |
||||
|
||||
private VanChartFieldListPane fieldListPane; |
||||
private VanChartFieldAttrPane fieldAttrPane; |
||||
|
||||
public VanChartRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditor) { |
||||
fieldAttrPane = new VanChartFieldAttrPane(); |
||||
fieldListPane = createFieldListPane(fieldAttrPane, richEditor); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(createFieldContentPane(), BorderLayout.CENTER); |
||||
this.add(createRichEditorPane(richEditor), BorderLayout.SOUTH); |
||||
} |
||||
|
||||
public VanChartFieldListPane getFieldListPane() { |
||||
return fieldListPane; |
||||
} |
||||
|
||||
private JPanel createFieldContentPane() { |
||||
JPanel fieldPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
|
||||
// 新增字段目录
|
||||
JPanel fieldListContent = new JPanel(); |
||||
fieldListContent.setLayout(new BorderLayout()); |
||||
fieldListContent.add(fieldListPane, BorderLayout.NORTH); |
||||
|
||||
JScrollPane fieldListScrollPane = new JScrollPane(fieldListContent); |
||||
fieldListScrollPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); |
||||
fieldListScrollPane.setHorizontalScrollBar(null); |
||||
fieldListScrollPane.setBorder(BorderFactory.createTitledBorder("添加字段")); |
||||
|
||||
// 字段格式和汇总
|
||||
JScrollPane fieldAttrScrollPane = new JScrollPane(fieldAttrPane); |
||||
fieldAttrScrollPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); |
||||
fieldAttrScrollPane.setBorder(BorderFactory.createTitledBorder("字段设置")); |
||||
|
||||
fieldPane.add(fieldListScrollPane); |
||||
fieldPane.add(fieldAttrScrollPane); |
||||
|
||||
return fieldPane; |
||||
} |
||||
|
||||
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { |
||||
return new VanChartFieldListPane(fieldAttrPane, richEditor); |
||||
} |
||||
|
||||
private JPanel createRichEditorPane(JPanel richEditor) { |
||||
JPanel richEditorPane = new JPanel(); |
||||
|
||||
richEditorPane.setLayout(new BorderLayout()); |
||||
richEditorPane.setPreferredSize(new Dimension(RICH_EDITOR_W, RICH_EDITOR_H)); |
||||
richEditorPane.add(richEditor, BorderLayout.CENTER); |
||||
|
||||
return richEditorPane; |
||||
} |
||||
|
||||
protected AttrTooltipContent getInitialTooltipContent() { |
||||
return new AttrTooltipContent(); |
||||
} |
||||
|
||||
public void populateBean(AttrTooltipContent tooltipContent) { |
||||
fieldListPane.populate(tooltipContent); |
||||
} |
||||
|
||||
public AttrTooltipContent updateBean() { |
||||
AttrTooltipContent content = getInitialTooltipContent(); |
||||
fieldListPane.update(content); |
||||
return content; |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.van.chart.map.designer.style; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldButton; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldListener; |
||||
import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; |
||||
|
||||
public class VanChartMapRichTextFieldListPane extends VanChartFieldListPane { |
||||
|
||||
public VanChartMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { |
||||
super(fieldAttrPane, richEditorPane); |
||||
} |
||||
|
||||
protected void initDefaultFieldButton() { |
||||
VanChartFieldListener fieldListener = getFieldListener(); |
||||
|
||||
VanChartFieldButton categoryNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Area_Name"), |
||||
new AttrTooltipAreaNameFormat(), false, fieldListener); |
||||
|
||||
VanChartFieldButton seriesNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), |
||||
new AttrTooltipSeriesFormat(), false, fieldListener); |
||||
|
||||
VanChartFieldButton valueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), |
||||
new AttrTooltipValueFormat(), false, fieldListener); |
||||
|
||||
VanChartFieldButton percentButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Percent"), |
||||
new AttrTooltipPercentFormat(), false, fieldListener); |
||||
|
||||
setCategoryNameButton(categoryNameButton); |
||||
setSeriesNameButton(seriesNameButton); |
||||
setValueButton(valueButton); |
||||
setPercentButton(percentButton); |
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
package com.fr.van.chart.scatter; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.plugin.chart.base.AttrTooltipContent; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipSizeFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipXFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipYFormat; |
||||
import com.fr.plugin.chart.scatter.attr.ScatterAttrTooltipContent; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldButton; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldListener; |
||||
import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class VanChartScatterRichTextFieldListPane extends VanChartFieldListPane { |
||||
|
||||
private VanChartFieldButton richTextXFormatPane; |
||||
private VanChartFieldButton richTextYFormatPane; |
||||
private VanChartFieldButton richTextSizeFormatPane; |
||||
|
||||
public VanChartScatterRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { |
||||
super(fieldAttrPane, richEditorPane); |
||||
} |
||||
|
||||
public VanChartFieldButton getRichTextXFormatPane() { |
||||
return richTextXFormatPane; |
||||
} |
||||
|
||||
public VanChartFieldButton getRichTextYFormatPane() { |
||||
return richTextYFormatPane; |
||||
} |
||||
|
||||
public VanChartFieldButton getRichTextSizeFormatPane() { |
||||
return richTextSizeFormatPane; |
||||
} |
||||
|
||||
protected void initDefaultFieldButton() { |
||||
super.initDefaultFieldButton(); |
||||
|
||||
VanChartFieldListener listener = getFieldListener(); |
||||
|
||||
richTextXFormatPane = new VanChartFieldButton("x", new AttrTooltipXFormat(), false, listener); |
||||
richTextYFormatPane = new VanChartFieldButton("y", new AttrTooltipYFormat(), false, listener); |
||||
richTextSizeFormatPane = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), new AttrTooltipSizeFormat(), false, listener); |
||||
} |
||||
|
||||
protected void addDefaultFieldButton(JPanel fieldPane) { |
||||
fieldPane.add(getSeriesNameButton()); |
||||
fieldPane.add(richTextXFormatPane); |
||||
fieldPane.add(richTextYFormatPane); |
||||
fieldPane.add(richTextSizeFormatPane); |
||||
} |
||||
|
||||
protected List<VanChartFieldButton> getDefaultFieldButtonList() { |
||||
List<VanChartFieldButton> fieldButtonList = new ArrayList<>(); |
||||
|
||||
fieldButtonList.add(getSeriesNameButton()); |
||||
fieldButtonList.add(richTextXFormatPane); |
||||
fieldButtonList.add(richTextYFormatPane); |
||||
fieldButtonList.add(richTextSizeFormatPane); |
||||
|
||||
return fieldButtonList; |
||||
} |
||||
|
||||
public void populateDefaultField(AttrTooltipContent tooltipContent) { |
||||
super.populateDefaultField(tooltipContent); |
||||
|
||||
if (tooltipContent instanceof ScatterAttrTooltipContent) { |
||||
ScatterAttrTooltipContent scatter = (ScatterAttrTooltipContent) tooltipContent; |
||||
|
||||
populateButtonFormat(richTextXFormatPane, scatter.getRichTextXFormat()); |
||||
populateButtonFormat(richTextYFormatPane, scatter.getRichTextYFormat()); |
||||
populateButtonFormat(richTextSizeFormatPane, scatter.getRichTextSizeFormat()); |
||||
} |
||||
} |
||||
|
||||
public void updateDefaultField(AttrTooltipContent tooltipContent) { |
||||
super.updateDefaultField(tooltipContent); |
||||
|
||||
if (tooltipContent instanceof ScatterAttrTooltipContent) { |
||||
ScatterAttrTooltipContent scatter = (ScatterAttrTooltipContent) tooltipContent; |
||||
|
||||
updateButtonFormat(richTextXFormatPane, scatter.getRichTextXFormat()); |
||||
updateButtonFormat(richTextYFormatPane, scatter.getRichTextYFormat()); |
||||
updateButtonFormat(richTextSizeFormatPane, scatter.getRichTextSizeFormat()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.van.chart.wordcloud.designer.style; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldButton; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldListener; |
||||
import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; |
||||
|
||||
public class VanChartWordCloudRichTextFieldListPane extends VanChartFieldListPane { |
||||
|
||||
public VanChartWordCloudRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { |
||||
super(fieldAttrPane, richEditorPane); |
||||
} |
||||
|
||||
protected void initDefaultFieldButton() { |
||||
VanChartFieldListener fieldListener = getFieldListener(); |
||||
|
||||
VanChartFieldButton categoryNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"), |
||||
new AttrTooltipCategoryFormat(), false, fieldListener); |
||||
|
||||
VanChartFieldButton seriesNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Word_Name"), |
||||
new AttrTooltipNameFormat(), false, fieldListener); |
||||
|
||||
VanChartFieldButton valueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Word_Value"), |
||||
new AttrTooltipValueFormat(), false, fieldListener); |
||||
|
||||
VanChartFieldButton percentButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Percent"), |
||||
new AttrTooltipPercentFormat(), false, fieldListener); |
||||
|
||||
setCategoryNameButton(categoryNameButton); |
||||
setSeriesNameButton(seriesNameButton); |
||||
setValueButton(valueButton); |
||||
setPercentButton(percentButton); |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.fr.design.mainframe.widget.accessibles; |
||||
|
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.design.mainframe.mobile.ui.MobileParamSettingPane; |
||||
import com.fr.design.mainframe.widget.wrappers.MobileParamWrapper; |
||||
import com.fr.form.ui.container.WParameterLayout; |
||||
import com.fr.form.ui.mobile.MobileParamStyle; |
||||
import com.fr.report.mobile.EmptyMobileParamStyle; |
||||
import javax.swing.SwingUtilities; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/4 |
||||
*/ |
||||
public class AccessibleMobileParamEditor extends UneditableAccessibleEditor { |
||||
|
||||
private MobileParamSettingPane mobileParamSettingPane; |
||||
|
||||
public AccessibleMobileParamEditor(MobileParamSettingPane mobileParamSettingPane) { |
||||
super(new MobileParamWrapper()); |
||||
this.mobileParamSettingPane = mobileParamSettingPane; |
||||
} |
||||
|
||||
@Override |
||||
protected void showEditorPane() { |
||||
mobileParamSettingPane.setPreferredSize(BasicDialog.MEDIUM); |
||||
BasicDialog dlg = mobileParamSettingPane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||
dlg.addDialogActionListener(new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
MobileParamStyle mobileParamStyle = mobileParamSettingPane.update(); |
||||
setValue(mobileParamStyle); |
||||
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||
WParameterLayout wParameterLayout = (WParameterLayout) formDesigner.getSelectionModel().getSelection().getSelectedCreator().toData(); |
||||
if (mobileParamStyle instanceof EmptyMobileParamStyle) { |
||||
wParameterLayout.setProvider(((EmptyMobileParamStyle) mobileParamStyle).getProvider()); |
||||
} |
||||
fireStateChanged(); |
||||
} |
||||
}); |
||||
mobileParamSettingPane.populate((MobileParamStyle) getValue()); |
||||
dlg.setVisible(true); |
||||
} |
||||
} |
Loading…
Reference in new issue