|
|
|
@ -1,22 +1,19 @@
|
|
|
|
|
package com.fr.van.chart.designer.component; |
|
|
|
|
|
|
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
|
import com.fr.design.beans.BasicBeanPane; |
|
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
|
import com.fr.design.gui.autocomplete.AutoCompletion; |
|
|
|
|
import com.fr.design.gui.autocomplete.DefaultCompletionProvider; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
|
|
|
|
import com.fr.design.gui.icontainer.UIScrollPane; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.gui.syntax.ui.rtextarea.RTextArea; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
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.AttrTooltipRichEditor; |
|
|
|
|
import com.fr.plugin.chart.base.AttrTooltipRichText; |
|
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipFormat; |
|
|
|
|
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
|
|
|
|
import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; |
|
|
|
@ -31,9 +28,7 @@ import com.fr.van.chart.designer.style.VanChartStylePane;
|
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
import javax.swing.JFrame; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.KeyStroke; |
|
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
|
import javax.swing.text.Document; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.CardLayout; |
|
|
|
|
import java.awt.Component; |
|
|
|
@ -42,6 +37,7 @@ import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 内容界面 。数据点提示 |
|
|
|
@ -63,18 +59,17 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
|
|
|
|
|
private JPanel centerPane; |
|
|
|
|
private JPanel commonPanel; |
|
|
|
|
private JPanel editorPane; |
|
|
|
|
private RTextArea contentTextArea; |
|
|
|
|
private VanChartHtmlLabelPane htmlLabelPane; |
|
|
|
|
|
|
|
|
|
private VanChartStylePane parent; |
|
|
|
|
private JPanel showOnPane; |
|
|
|
|
|
|
|
|
|
private AttrTooltipRichEditor richEditor; |
|
|
|
|
private AttrTooltipRichText richText; |
|
|
|
|
|
|
|
|
|
public VanChartTooltipContentPane(VanChartStylePane parent, JPanel showOnPane){ |
|
|
|
|
this.parent = parent; |
|
|
|
|
this.showOnPane = showOnPane; |
|
|
|
|
this.richEditor = new AttrTooltipRichEditor(); |
|
|
|
|
this.richText = new AttrTooltipRichText(); |
|
|
|
|
|
|
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
|
this.add(createLabelContentPane(),BorderLayout.CENTER); |
|
|
|
@ -164,44 +159,29 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
|
|
|
|
|
|
|
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
|
new Component[]{null, null}, |
|
|
|
|
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Content_Style")), createContentStylePane()} |
|
|
|
|
new Component[]{null, createContentStylePane()} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JComponent createContentStylePane() { |
|
|
|
|
contentTextArea = new RTextArea(); |
|
|
|
|
contentTextArea.setLineWrap(true); |
|
|
|
|
UIButton contentTextArea = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Content_Style")); |
|
|
|
|
|
|
|
|
|
contentTextArea.addMouseListener(new MouseAdapter() { |
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
fireRichEditor(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
fireRichEditor(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
DefaultCompletionProvider provider = new DefaultCompletionProvider(); |
|
|
|
|
AutoCompletion ac = new AutoCompletion(provider); |
|
|
|
|
String shortCuts = DesignerEnvManager.getEnvManager().getAutoCompleteShortcuts(); |
|
|
|
|
|
|
|
|
|
ac.setTriggerKey(KeyStroke.getKeyStroke(shortCuts.replace("+", "pressed"))); |
|
|
|
|
ac.install(contentTextArea); |
|
|
|
|
|
|
|
|
|
return new UIScrollPane(contentTextArea) { |
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
return new Dimension(super.getPreferredSize().width, 100); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
return contentTextArea; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void fireRichEditor() { |
|
|
|
|
final ModernUIPane<VanChartRichEditorPane.RichEditorModel> pane = VanChartRichEditorPane.getInstance(); |
|
|
|
|
final ModernUIPane<VanChartRichEditorPane.RichEditorModel> pane = VanChartRichEditorPane.createRichEditorPane(richText); |
|
|
|
|
BasicDialog dialog = pane.showWindow(new JFrame()); |
|
|
|
|
|
|
|
|
|
pane.populate(VanChartRichEditorPane.getRichEditorModel(richEditor)); |
|
|
|
|
pane.populate(VanChartRichEditorPane.getRichEditorModel(richText)); |
|
|
|
|
|
|
|
|
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
|
|
|
|
|
@ -209,11 +189,9 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
|
|
|
|
|
VanChartRichEditorPane.RichEditorModel model = pane.update(); |
|
|
|
|
|
|
|
|
|
String content = model.getContent(); |
|
|
|
|
|
|
|
|
|
populateContentTextArea(content); |
|
|
|
|
|
|
|
|
|
richEditor.setContent(content); |
|
|
|
|
richEditor.setAuto(model.isAuto()); |
|
|
|
|
List<String> params = VanChartRichEditorPane.richParamsParser(content, richText.getParams()); |
|
|
|
|
populateFormatParams(params); |
|
|
|
|
updateLocalRichText(content, model.isAuto()); |
|
|
|
|
|
|
|
|
|
SwingUtilities.getWindowAncestor(pane).setVisible(false); |
|
|
|
|
} |
|
|
|
@ -304,6 +282,59 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected VanChartFormatPaneWithCheckBox[] getFormatPaneGroup() { |
|
|
|
|
return new VanChartFormatPaneWithCheckBox[]{ |
|
|
|
|
categoryNameFormatPane, seriesNameFormatPane, |
|
|
|
|
valueFormatPane, percentFormatPane, |
|
|
|
|
changedValueFormatPane, changedPercentFormatPane |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected VanChartFormatPaneWithCheckBox getTargetFormatPane(Object param) { |
|
|
|
|
VanChartFormatPaneWithCheckBox[] formatPaneGroup = getFormatPaneGroup(); |
|
|
|
|
|
|
|
|
|
Object[] params = richText.getParams().values().toArray(); |
|
|
|
|
|
|
|
|
|
for (int i = 0, len = Math.min(params.length, formatPaneGroup.length); i < len; i++) { |
|
|
|
|
if (ComparatorUtils.equals(params[i], param) && formatPaneGroup[i] != null) { |
|
|
|
|
return formatPaneGroup[i]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getParamsRichText() { |
|
|
|
|
VanChartFormatPaneWithCheckBox[] formatPaneGroup = getFormatPaneGroup(); |
|
|
|
|
|
|
|
|
|
// todo 获取参数对应的富文本字符串,正确的流程是:
|
|
|
|
|
// 在BI的富文本组件中,先清空content,然后addParam,最后读取最新的content,
|
|
|
|
|
// 但是当前接口还没开出来,暂时先在本地写死,模拟类似的效果
|
|
|
|
|
String[] richTextGroup = new String[]{ |
|
|
|
|
"<img alt=\"categoryFormat\" class=\"rich-editor-param\" style=\"background-color: rgba(54, 133, 242, 0.1);vertical-align: middle; margin: 0 1px; width:88.17578125px;height: 16px; max-width:88.17578125px;max-height: 16px; min-width:88.17578125px;min-height: 16px\" name=\"categoryFormat\"/>", |
|
|
|
|
"<img alt=\"seriesFormat\" class=\"rich-editor-param\" style=\"background-color: rgba(54, 133, 242, 0.1);vertical-align: middle; margin: 0 1px; width:73.73828125px;height: 16px; max-width:73.73828125px;max-height: 16px; min-width:73.73828125px;min-height: 16px\" name=\"seriesFormat\"/>", |
|
|
|
|
"<img alt=\"valueFormat\" class=\"rich-editor-param\" style=\"background-color: rgba(54, 133, 242, 0.1);vertical-align: middle; margin: 0 1px; width:71.4765625px;height: 16px; max-width:71.4765625px;max-height: 16px; min-width:71.4765625px;min-height: 16px\" name=\"valueFormat\"/>", |
|
|
|
|
"<img alt=\"percentFormat\" class=\"rich-editor-param\" style=\"background-color: rgba(54, 133, 242, 0.1);vertical-align: middle; margin: 0 1px; width:83.388671875px;height: 16px; max-width:83.388671875px;max-height: 16px; min-width:83.388671875px;min-height: 16px\" name=\"percentFormat\"/>", |
|
|
|
|
"<img alt=\"changedValueFormat\" class=\"rich-editor-param\" style=\"background-color: rgba(54, 133, 242, 0.1);vertical-align: middle; margin: 0 1px; width:117.888671875px;height: 16px; max-width:117.888671875px;max-height: 16px; min-width:117.888671875px;min-height: 16px\" name=\"changedValueFormat\"/>", |
|
|
|
|
"<img alt=\"changedPercentFormat\" class=\"rich-editor-param\" style=\"background-color: rgba(54, 133, 242, 0.1);vertical-align: middle; margin: 0 1px; width:128.224609375px;height: 16px; max-width:128.224609375px;max-height: 16px; min-width:128.224609375px;min-height: 16px\" name=\"changedPercentFormat\"/>" |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
StringBuilder result = new StringBuilder("<p>"); |
|
|
|
|
|
|
|
|
|
for (int i = 0, len = formatPaneGroup.length; i < len; i++) { |
|
|
|
|
VanChartFormatPaneWithCheckBox formatPane = formatPaneGroup[i]; |
|
|
|
|
String paramRichText = richTextGroup[i]; |
|
|
|
|
|
|
|
|
|
if (formatPane != null && formatPane.isSelected()) { |
|
|
|
|
result.append(paramRichText); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result.append("</p>"); |
|
|
|
|
|
|
|
|
|
return result.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return ""; |
|
|
|
@ -328,10 +359,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { |
|
|
|
|
VanChartFormatPaneWithCheckBox[] formatPaneGroup = new VanChartFormatPaneWithCheckBox[]{ |
|
|
|
|
categoryNameFormatPane, seriesNameFormatPane, valueFormatPane, percentFormatPane, |
|
|
|
|
changedValueFormatPane, changedPercentFormatPane |
|
|
|
|
}; |
|
|
|
|
VanChartFormatPaneWithCheckBox[] formatPaneGroup = getFormatPaneGroup(); |
|
|
|
|
|
|
|
|
|
AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ |
|
|
|
|
attrTooltipContent.getCategoryFormat(), |
|
|
|
@ -350,37 +378,45 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
|
|
|
|
|
formatPane.populate(format); |
|
|
|
|
|
|
|
|
|
// 填充面板时,更新富文本编辑器参数
|
|
|
|
|
formatPane.updateFormatParams(richEditor.getParams(), format.getFormatJSONKey()); |
|
|
|
|
formatPane.updateFormatParams(richText.getParams(), format.getFormatJSONKey()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
AttrTooltipRichEditor tooltipRichEditor = attrTooltipContent.getRichEditor(); |
|
|
|
|
AttrTooltipRichText tooltipRichText = attrTooltipContent.getRichText(); |
|
|
|
|
|
|
|
|
|
if (tooltipRichEditor != null) { |
|
|
|
|
populateContentTextArea(tooltipRichEditor.getContent()); |
|
|
|
|
if (tooltipRichText != null) { |
|
|
|
|
updateLocalRichText(tooltipRichText.getContent(), tooltipRichText.isAuto()); |
|
|
|
|
setDirty(false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void populateContentTextArea(String content) { |
|
|
|
|
try { |
|
|
|
|
if (contentTextArea != null) { |
|
|
|
|
Document document = contentTextArea.getDocument(); |
|
|
|
|
document.remove(0, document.getLength()); |
|
|
|
|
document.insertString(0, content, null); |
|
|
|
|
private void populateFormatParams(List<String> params) { |
|
|
|
|
if (params == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (String param : params) { |
|
|
|
|
VanChartFormatPaneWithCheckBox formatPane = getTargetFormatPane(param); |
|
|
|
|
|
|
|
|
|
if (formatPane != null) { |
|
|
|
|
formatPane.setSelected(true); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AttrTooltipContent updateBean() { |
|
|
|
|
AttrTooltipContent attrTooltipContent = createAttrTooltip(); |
|
|
|
|
|
|
|
|
|
attrTooltipContent.setCommon(content.getSelectedIndex() == 0); |
|
|
|
|
boolean isCommon = content.getSelectedIndex() == 0; |
|
|
|
|
|
|
|
|
|
updateFormatPane(attrTooltipContent); |
|
|
|
|
updateRichEditor(attrTooltipContent); |
|
|
|
|
attrTooltipContent.setCommon(isCommon); |
|
|
|
|
if (isDirty() && isCommon) { |
|
|
|
|
updateLocalRichText(getParamsRichText(), false); |
|
|
|
|
setDirty(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
updateFormatPane(attrTooltipContent); |
|
|
|
|
updateTooltipRichText(attrTooltipContent); |
|
|
|
|
updateFormatsWithPaneWidth(attrTooltipContent); |
|
|
|
|
|
|
|
|
|
htmlLabelPane.update(attrTooltipContent.getHtmlLabel()); |
|
|
|
@ -406,9 +442,18 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void updateRichEditor(AttrTooltipContent attrTooltipContent) { |
|
|
|
|
if (attrTooltipContent != null) { |
|
|
|
|
attrTooltipContent.setRichEditor(richEditor); |
|
|
|
|
private void updateLocalRichText(String content, boolean isAuto) { |
|
|
|
|
richText.setContent(content); |
|
|
|
|
richText.setAuto(isAuto); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void updateTooltipRichText(AttrTooltipContent attrTooltipContent) { |
|
|
|
|
try { |
|
|
|
|
if (attrTooltipContent != null) { |
|
|
|
|
attrTooltipContent.setRichText((AttrTooltipRichText) richText.clone()); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e){ |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|