daniel
7 years ago
21 changed files with 1247 additions and 1362 deletions
@ -0,0 +1,56 @@
|
||||
package com.fr.design.hyperlink; |
||||
|
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.editor.ValueEditorPane; |
||||
import com.fr.design.editor.ValueEditorPaneFactory; |
||||
import com.fr.design.gui.frpane.ReportletParameterViewPane; |
||||
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
||||
import com.fr.js.JavaScript; |
||||
|
||||
import java.util.HashMap; |
||||
|
||||
/** |
||||
* Created by mengao on 2017/10/12. |
||||
*/ |
||||
public abstract class AbstractHyperLinkPane<T> extends FurtherBasicBeanPane<T> { |
||||
private HashMap hyperLinkEditorMap; |
||||
private boolean needRenamePane = false; |
||||
protected ReportletParameterViewPane parameterViewPane; |
||||
|
||||
|
||||
public AbstractHyperLinkPane(HashMap hyperLinkEditorMap, boolean needRenamePane) { |
||||
this.hyperLinkEditorMap = hyperLinkEditorMap; |
||||
this.needRenamePane = needRenamePane; |
||||
} |
||||
|
||||
public AbstractHyperLinkPane() { |
||||
} |
||||
|
||||
public ReportletParameterViewPane getParameterViewPane() { |
||||
return parameterViewPane; |
||||
} |
||||
|
||||
public void setParameterViewPane(ReportletParameterViewPane parameterViewPane) { |
||||
this.parameterViewPane = parameterViewPane; |
||||
} |
||||
|
||||
public boolean accept(Object ob) { |
||||
return ob instanceof JavaScript; |
||||
} |
||||
|
||||
public void reset() { |
||||
} |
||||
|
||||
protected int getChartParaType() { |
||||
return hyperLinkEditorMap != null ? ParameterTableModel.CHART_NORMAL_USE : ParameterTableModel.NO_CHART_USE; |
||||
} |
||||
|
||||
protected ValueEditorPane getValueEditorPane() { |
||||
return ValueEditorPaneFactory.createVallueEditorPaneWithUseType(getChartParaType(), hyperLinkEditorMap); |
||||
} |
||||
|
||||
protected boolean needRenamePane() { |
||||
return needRenamePane; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,145 @@
|
||||
package com.fr.design.hyperlink; |
||||
|
||||
import com.fr.base.Utils; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UINumberField; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.general.Inter; |
||||
import com.fr.js.Hyperlink; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public abstract class AbstractHyperNorthPane<T extends Hyperlink> extends BasicBeanPane<T> { |
||||
public static final int NEW_WINDOW = 0; |
||||
public static final int DIALOG = 1; |
||||
public static final int SELF = 2; |
||||
public static final int DEFAULT_H_VALUE = 400; |
||||
public static final int DEFAULT_V_VALUE = 600; |
||||
|
||||
private JPanel headerPane; |
||||
private UIComboBox targetFrameComboBox; |
||||
|
||||
private UINumberField heightTextFiled; |
||||
private UINumberField widthTextFiled; |
||||
|
||||
|
||||
public AbstractHyperNorthPane() { |
||||
this.initComponents(); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); |
||||
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
headerPane = this.setHeaderPanel(); |
||||
this.add(headerPane, BorderLayout.NORTH); |
||||
this.add(centerPane, BorderLayout.CENTER); |
||||
targetFrameComboBox = new UIComboBox(getTargetFrames()); |
||||
targetFrameComboBox.setRenderer(new DefaultListCellRenderer() { |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
return this; |
||||
} |
||||
}); |
||||
JPanel targetFramePanel = new JPanel(); |
||||
targetFramePanel.add(new UILabel(Inter.getLocText("Hyperlink-Link_Opened_in"))); |
||||
targetFramePanel.add(targetFrameComboBox); |
||||
targetFrameComboBox.setEditable(true); |
||||
targetFrameComboBox.setPreferredSize(new Dimension(100, 20)); |
||||
|
||||
final JPanel newWindowConfPane = new JPanel(); |
||||
newWindowConfPane.add(new UILabel(Inter.getLocText("FR-Designer_Height") + ": ")); |
||||
heightTextFiled = new UINumberField(); |
||||
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE)); |
||||
heightTextFiled.setPreferredSize(new Dimension(40, 20)); |
||||
newWindowConfPane.add(heightTextFiled); |
||||
newWindowConfPane.add(new UILabel(" " + Inter.getLocText("FR-Designer_Width") + ": ")); |
||||
widthTextFiled = new UINumberField(); |
||||
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE)); |
||||
widthTextFiled.setPreferredSize(new Dimension(40, 20)); |
||||
newWindowConfPane.add(widthTextFiled); |
||||
|
||||
JPanel centerPanel = new JPanel(new BorderLayout()); |
||||
centerPanel.add(targetFramePanel, BorderLayout.WEST); |
||||
centerPanel.add(newWindowConfPane, BorderLayout.EAST); |
||||
newWindowConfPane.setVisible(false); |
||||
|
||||
centerPane.add(centerPanel); |
||||
targetFrameComboBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
newWindowConfPane.setVisible(DIALOG == targetFrameComboBox.getSelectedIndex()); |
||||
} |
||||
}); |
||||
|
||||
this.add(this.setFootPanel(), BorderLayout.SOUTH); |
||||
} |
||||
|
||||
protected String[] getTargetFrames() { |
||||
return new String[]{Inter.getLocText("Hyperlink-New_Window"), Inter.getLocText("FR-Hyperlink_Dialog"), Inter.getLocText("Hyperlink-Self_Window")}; |
||||
} |
||||
|
||||
protected abstract JPanel setHeaderPanel(); |
||||
|
||||
protected abstract JPanel setFootPanel(); |
||||
|
||||
protected abstract void populateSubHyperlinkBean(T link); |
||||
|
||||
public UIComboBox getTargetFrameComboBox() { |
||||
return targetFrameComboBox; |
||||
} |
||||
|
||||
public void setTargetFrameComboBox(UIComboBox targetFrameComboBox) { |
||||
this.targetFrameComboBox = targetFrameComboBox; |
||||
} |
||||
|
||||
public UINumberField getHeightTextFiled() { |
||||
return heightTextFiled; |
||||
} |
||||
|
||||
public void setHeightTextFiled(UINumberField heightTextFiled) { |
||||
this.heightTextFiled = heightTextFiled; |
||||
} |
||||
|
||||
public UINumberField getWidthTextFiled() { |
||||
return widthTextFiled; |
||||
} |
||||
|
||||
public void setWidthTextFiled(UINumberField widthTextFiled) { |
||||
this.widthTextFiled = widthTextFiled; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(T link) { |
||||
String name = link.getTargetFrame(); |
||||
targetFrameComboBox.setSelectedIndex(HyperlinkTargetFrame.convert(name)); |
||||
heightTextFiled.setText(String.valueOf(link.getHeight() == 0 ? DEFAULT_H_VALUE : link.getHeight())); |
||||
widthTextFiled.setText(String.valueOf(link.getWidth() == 0 ? DEFAULT_V_VALUE : link.getWidth())); |
||||
populateSubHyperlinkBean(link); |
||||
} |
||||
|
||||
protected abstract T updateSubHyperlinkBean(); |
||||
|
||||
protected abstract void updateSubHyperlinkBean(T t); |
||||
|
||||
@Override |
||||
public T updateBean() { |
||||
T link = updateSubHyperlinkBean(); |
||||
|
||||
updateBean(link); |
||||
|
||||
return link; |
||||
} |
||||
|
||||
public void updateBean(T link) { |
||||
updateSubHyperlinkBean(link); |
||||
link.setTargetFrame(HyperlinkTargetFrame.parse(targetFrameComboBox.getSelectedIndex()).getName()); |
||||
link.setHeight(Utils.objectToNumber(heightTextFiled.getText(), false).intValue()); |
||||
link.setWidth(Utils.objectToNumber(widthTextFiled.getText(), false).intValue()); |
||||
} |
||||
|
||||
} |
@ -1,144 +0,0 @@
|
||||
package com.fr.design.hyperlink; |
||||
|
||||
import com.fr.base.Utils; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UINumberField; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.general.Inter; |
||||
import com.fr.js.Hyperlink; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public abstract class AbstractHyperlinkPane<T extends Hyperlink> extends BasicBeanPane<T> { |
||||
public static final int NEW_WINDOW = 0; |
||||
public static final int DIALOG = 1; |
||||
public static final int SELF = 2; |
||||
public static final int DEFAULT_H_VALUE = 400; |
||||
public static final int DEFAULT_V_VALUE = 600; |
||||
|
||||
private JPanel headerPane; |
||||
private UIComboBox targetFrameComboBox; |
||||
|
||||
private UINumberField heightTextFiled; |
||||
private UINumberField widthTextFiled; |
||||
|
||||
|
||||
public AbstractHyperlinkPane() { |
||||
this.initComponents(); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); |
||||
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
headerPane = this.setHeaderPanel(); |
||||
this.add(headerPane, BorderLayout.NORTH); |
||||
this.add(centerPane, BorderLayout.CENTER); |
||||
targetFrameComboBox = new UIComboBox(getTargetFrames()); |
||||
targetFrameComboBox.setRenderer(new DefaultListCellRenderer() { |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
return this; |
||||
} |
||||
}); |
||||
JPanel targetFramePanel = new JPanel(); |
||||
targetFramePanel.add(new UILabel(Inter.getLocText("Hyperlink-Link_Opened_in"))); |
||||
targetFramePanel.add(targetFrameComboBox); |
||||
targetFrameComboBox.setEditable(true); |
||||
targetFrameComboBox.setPreferredSize(new Dimension(100, 20)); |
||||
|
||||
final JPanel newWindowConfPane = new JPanel(); |
||||
newWindowConfPane.add(new UILabel(Inter.getLocText("FR-Designer_Height") + ": ")); |
||||
heightTextFiled = new UINumberField(); |
||||
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE)); |
||||
heightTextFiled.setPreferredSize(new Dimension(40, 20)); |
||||
newWindowConfPane.add(heightTextFiled); |
||||
newWindowConfPane.add(new UILabel(" " + Inter.getLocText("FR-Designer_Width") + ": ")); |
||||
widthTextFiled = new UINumberField(); |
||||
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE)); |
||||
widthTextFiled.setPreferredSize(new Dimension(40, 20)); |
||||
newWindowConfPane.add(widthTextFiled); |
||||
|
||||
JPanel centerPanel = new JPanel(new BorderLayout()); |
||||
centerPanel.add(targetFramePanel, BorderLayout.WEST); |
||||
centerPanel.add(newWindowConfPane, BorderLayout.EAST); |
||||
newWindowConfPane.setVisible(false); |
||||
|
||||
centerPane.add(centerPanel); |
||||
targetFrameComboBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
newWindowConfPane.setVisible(DIALOG == targetFrameComboBox.getSelectedIndex()); |
||||
} |
||||
}); |
||||
|
||||
this.add(this.setFootPanel(), BorderLayout.SOUTH); |
||||
} |
||||
protected String[] getTargetFrames(){ |
||||
return new String[]{Inter.getLocText("Hyperlink-New_Window"), Inter.getLocText("FR-Hyperlink_Dialog"), Inter.getLocText("Hyperlink-Self_Window")}; |
||||
} |
||||
|
||||
protected abstract JPanel setHeaderPanel(); |
||||
|
||||
protected abstract JPanel setFootPanel(); |
||||
|
||||
protected abstract void populateSubHyperlinkBean(T link); |
||||
|
||||
public UIComboBox getTargetFrameComboBox() { |
||||
return targetFrameComboBox; |
||||
} |
||||
|
||||
public void setTargetFrameComboBox(UIComboBox targetFrameComboBox) { |
||||
this.targetFrameComboBox = targetFrameComboBox; |
||||
} |
||||
|
||||
public UINumberField getHeightTextFiled() { |
||||
return heightTextFiled; |
||||
} |
||||
|
||||
public void setHeightTextFiled(UINumberField heightTextFiled) { |
||||
this.heightTextFiled = heightTextFiled; |
||||
} |
||||
|
||||
public UINumberField getWidthTextFiled() { |
||||
return widthTextFiled; |
||||
} |
||||
|
||||
public void setWidthTextFiled(UINumberField widthTextFiled) { |
||||
this.widthTextFiled = widthTextFiled; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(T link) { |
||||
String name = link.getTargetFrame(); |
||||
targetFrameComboBox.setSelectedIndex(HyperlinkTargetFrame.convert(name)); |
||||
heightTextFiled.setText(String.valueOf(link.getHeight() == 0 ? DEFAULT_H_VALUE : link.getHeight())); |
||||
widthTextFiled.setText(String.valueOf(link.getWidth() == 0 ? DEFAULT_V_VALUE : link.getWidth())); |
||||
populateSubHyperlinkBean(link); |
||||
} |
||||
|
||||
protected abstract T updateSubHyperlinkBean(); |
||||
|
||||
protected abstract void updateSubHyperlinkBean(T t); |
||||
|
||||
@Override |
||||
public T updateBean() { |
||||
T link = updateSubHyperlinkBean(); |
||||
|
||||
updateBean(link); |
||||
|
||||
return link; |
||||
} |
||||
|
||||
public void updateBean(T link) { |
||||
updateSubHyperlinkBean(link); |
||||
link.setTargetFrame(HyperlinkTargetFrame.parse(targetFrameComboBox.getSelectedIndex()).getName()); |
||||
link.setHeight(Utils.objectToNumber(heightTextFiled.getText(), false).intValue()); |
||||
link.setWidth(Utils.objectToNumber(widthTextFiled.getText(), false).intValue()); |
||||
} |
||||
|
||||
} |
@ -1,99 +1,81 @@
|
||||
package com.fr.design.javascript; |
||||
|
||||
import com.fr.base.Parameter; |
||||
import com.fr.base.chart.BasePlot; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.editor.ValueEditorPane; |
||||
import com.fr.design.editor.ValueEditorPaneFactory; |
||||
import com.fr.design.gui.frpane.ReportletParameterViewPane; |
||||
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.hyperlink.AbstractHyperLinkPane; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.js.ParameterJavaScript; |
||||
import com.fr.stable.ParameterProvider; |
||||
|
||||
import java.awt.*; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
|
||||
public class ParameterJavaScriptPane extends BasicBeanPane<ParameterJavaScript> { |
||||
private BasePlot plot; |
||||
public class ParameterJavaScriptPane extends AbstractHyperLinkPane<ParameterJavaScript> { |
||||
private UITextField itemNameTextField; |
||||
private ReportletParameterViewPane parameterViewPane; |
||||
|
||||
protected BasePlot getPlot() { |
||||
return plot; |
||||
} |
||||
|
||||
public ParameterJavaScriptPane(){ |
||||
this(null); |
||||
public ParameterJavaScriptPane() { |
||||
this(null, false); |
||||
} |
||||
|
||||
public ParameterJavaScriptPane(BasePlot plot){ |
||||
this.plot = plot; |
||||
this.setLayout(new BorderLayout()); |
||||
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); |
||||
this.add(parameterViewPane, BorderLayout.CENTER); |
||||
if(needRenamePane()){ |
||||
public ParameterJavaScriptPane(HashMap hyperLinkEditorMap, boolean needRenamePane) { |
||||
super(hyperLinkEditorMap, needRenamePane); |
||||
this.setLayout(new BorderLayout()); |
||||
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); |
||||
this.add(parameterViewPane, BorderLayout.CENTER); |
||||
if (needRenamePane()) { |
||||
itemNameTextField = new UITextField(); |
||||
this.add(GUICoreUtils.createNamedPane(itemNameTextField, Inter.getLocText("Name") + ":"), BorderLayout.NORTH); |
||||
this.add(GUICoreUtils.createNamedPane(itemNameTextField, Inter.getLocText("FR-Designer-Hyperlink_Name") + ":"), BorderLayout.NORTH); |
||||
} |
||||
} |
||||
|
||||
protected int getChartParaType() { |
||||
return plot != null ? ParameterTableModel.CHART_NORMAL_USE : ParameterTableModel.NO_CHART_USE; |
||||
} |
||||
|
||||
protected ValueEditorPane getValueEditorPane() { |
||||
return ValueEditorPaneFactory.createVallueEditorPaneWithUseType(getChartParaType(), plot); |
||||
} |
||||
|
||||
protected boolean needRenamePane(){ |
||||
return plot != null && plot.isNeedRenameHyperLinkPane(); |
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText("JavaScript-Dynamic_Parameters"); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("JavaScript-Dynamic_Parameters"); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(ParameterJavaScript ob){ |
||||
ParameterProvider[] parameters = ob.getParameters(); |
||||
if (parameters.length == 0){ |
||||
// TODO ALEX_SEP
|
||||
public void populateBean(ParameterJavaScript ob) { |
||||
ParameterProvider[] parameters = ob.getParameters(); |
||||
if (parameters.length == 0) { |
||||
// TODO ALEX_SEP
|
||||
// parameters = DesignUtils.getEditingTemplateReport().getTemplateWorkBook().getParameters();
|
||||
} |
||||
parameterViewPane.populate(parameters); |
||||
if(itemNameTextField != null){ |
||||
} |
||||
parameterViewPane.populate(parameters); |
||||
if (itemNameTextField != null) { |
||||
itemNameTextField.setText(ob.getItemName()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public ParameterJavaScript updateBean(){ |
||||
ParameterJavaScript js = new ParameterJavaScript(); |
||||
|
||||
updateBean(js); |
||||
if(this.itemNameTextField != null){ |
||||
public ParameterJavaScript updateBean() { |
||||
ParameterJavaScript js = new ParameterJavaScript(); |
||||
|
||||
updateBean(js); |
||||
if (this.itemNameTextField != null) { |
||||
js.setItemName(itemNameTextField.getText()); |
||||
} |
||||
return js; |
||||
} |
||||
|
||||
return js; |
||||
} |
||||
|
||||
public void updateBean(ParameterJavaScript parameter) { |
||||
List<ParameterProvider> parameterList = parameterViewPane.update(); |
||||
parameter.setParameters(parameterList.toArray(new Parameter[parameterList.size()])); |
||||
if(this.itemNameTextField != null){ |
||||
List<ParameterProvider> parameterList = parameterViewPane.update(); |
||||
parameter.setParameters(parameterList.toArray(new Parameter[parameterList.size()])); |
||||
if (this.itemNameTextField != null) { |
||||
parameter.setItemName(itemNameTextField.getText()); |
||||
} |
||||
} |
||||
|
||||
public static class CHART_NO_RENAME extends ParameterJavaScriptPane{ |
||||
public static class ChartNoRename extends ParameterJavaScriptPane { |
||||
protected int getChartParaType() { |
||||
return ParameterTableModel.CHART_NORMAL_USE; |
||||
} |
||||
protected boolean needRenamePane(){ |
||||
|
||||
protected boolean needRenamePane() { |
||||
return false; |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue