mengao
7 years ago
14 changed files with 249 additions and 378 deletions
@ -0,0 +1,144 @@ |
|||||||
|
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 +1,56 @@ |
|||||||
package com.fr.design.hyperlink; |
package com.fr.design.hyperlink; |
||||||
|
|
||||||
import com.fr.base.Utils; |
import com.fr.base.chart.BasePlot; |
||||||
import com.fr.design.beans.BasicBeanPane; |
import com.fr.design.beans.FurtherBasicBeanPane; |
||||||
import com.fr.design.gui.icombobox.UIComboBox; |
import com.fr.design.editor.ValueEditorPane; |
||||||
import com.fr.design.gui.ilable.UILabel; |
import com.fr.design.editor.ValueEditorPaneFactory; |
||||||
import com.fr.design.gui.itextfield.UINumberField; |
import com.fr.design.gui.frpane.ReportletParameterViewPane; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
||||||
import com.fr.general.Inter; |
import com.fr.js.JavaScript; |
||||||
import com.fr.js.Hyperlink; |
|
||||||
|
|
||||||
import javax.swing.*; |
/** |
||||||
import java.awt.*; |
* Created by mengao on 2017/10/12. |
||||||
import java.awt.event.ActionEvent; |
*/ |
||||||
import java.awt.event.ActionListener; |
public abstract class AbstractHyperLinkPane<T> extends FurtherBasicBeanPane<T> { |
||||||
|
private BasePlot plot; |
||||||
|
protected ReportletParameterViewPane parameterViewPane; |
||||||
|
|
||||||
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; |
public AbstractHyperLinkPane(BasePlot plot) { |
||||||
private UIComboBox targetFrameComboBox; |
this.plot = plot; |
||||||
|
|
||||||
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(); |
public AbstractHyperLinkPane() { |
||||||
|
|
||||||
protected abstract JPanel setFootPanel(); |
|
||||||
|
|
||||||
protected abstract void populateSubHyperlinkBean(T link); |
|
||||||
|
|
||||||
public UIComboBox getTargetFrameComboBox() { |
|
||||||
return targetFrameComboBox; |
|
||||||
} |
} |
||||||
|
|
||||||
public void setTargetFrameComboBox(UIComboBox targetFrameComboBox) { |
public BasePlot getPlot() { |
||||||
this.targetFrameComboBox = targetFrameComboBox; |
return plot; |
||||||
} |
} |
||||||
|
|
||||||
public UINumberField getHeightTextFiled() { |
public ReportletParameterViewPane getParameterViewPane() { |
||||||
return heightTextFiled; |
return parameterViewPane; |
||||||
} |
} |
||||||
|
|
||||||
public void setHeightTextFiled(UINumberField heightTextFiled) { |
public void setParameterViewPane(ReportletParameterViewPane parameterViewPane) { |
||||||
this.heightTextFiled = heightTextFiled; |
this.parameterViewPane = parameterViewPane; |
||||||
} |
} |
||||||
|
|
||||||
public UINumberField getWidthTextFiled() { |
public boolean accept(Object ob){ |
||||||
return widthTextFiled; |
return ob instanceof JavaScript; |
||||||
} |
} |
||||||
|
|
||||||
public void setWidthTextFiled(UINumberField widthTextFiled) { |
public void reset() {} |
||||||
this.widthTextFiled = widthTextFiled; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
protected int getChartParaType() { |
||||||
public void populateBean(T link) { |
return plot != null ? ParameterTableModel.CHART_NORMAL_USE : ParameterTableModel.NO_CHART_USE; |
||||||
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 ValueEditorPane getValueEditorPane() { |
||||||
|
return ValueEditorPaneFactory.createVallueEditorPaneWithUseType(getChartParaType(), plot); |
||||||
protected abstract void updateSubHyperlinkBean(T t); |
|
||||||
|
|
||||||
@Override |
|
||||||
public T updateBean() { |
|
||||||
T link = updateSubHyperlinkBean(); |
|
||||||
|
|
||||||
updateBean(link); |
|
||||||
|
|
||||||
return link; |
|
||||||
} |
} |
||||||
|
|
||||||
public void updateBean(T link) { |
protected boolean needRenamePane(){ |
||||||
updateSubHyperlinkBean(link); |
return plot != null && plot.isNeedRenameHyperLinkPane(); |
||||||
link.setTargetFrame(HyperlinkTargetFrame.parse(targetFrameComboBox.getSelectedIndex()).getName()); |
|
||||||
link.setHeight(Utils.objectToNumber(heightTextFiled.getText(), false).intValue()); |
|
||||||
link.setWidth(Utils.objectToNumber(widthTextFiled.getText(), false).intValue()); |
|
||||||
} |
} |
||||||
|
|
||||||
} |
} |
Loading…
Reference in new issue