Browse Source

修改代码质量

master
mengao 7 years ago
parent
commit
7f49ecbea4
  1. 2
      designer_base/src/com/fr/design/hyperlink/ReportletHyperlinkPane.java
  2. 326
      designer_base/src/com/fr/design/javascript/JavaScriptImplPane.java

2
designer_base/src/com/fr/design/hyperlink/ReportletHyperlinkPane.java

@ -124,7 +124,7 @@ public class ReportletHyperlinkPane extends AbstractHyperLinkPane<ReportletHyper
@Override @Override
public void checkEnabled() { public void checkEnabled() {
//do nothing
} }
} }

326
designer_base/src/com/fr/design/javascript/JavaScriptImplPane.java

@ -26,201 +26,205 @@ import java.util.List;
public class JavaScriptImplPane extends AbstractHyperLinkPane<JavaScriptImpl> { public class JavaScriptImplPane extends AbstractHyperLinkPane<JavaScriptImpl> {
private UITextField itemNameTextField; private UITextField itemNameTextField;
private JSContentPane jsPane; private JSContentPane jsPane;
private UITableEditorPane<String> importedJsPane; private UITableEditorPane<String> importedJsPane;
private ReportletParameterViewPane parameterPane; private ReportletParameterViewPane parameterPane;
private String[] defaultArgs; private String[] defaultArgs;
public JavaScriptImplPane() { public JavaScriptImplPane() {
this(new String[0]); this(new String[0]);
} }
public JavaScriptImplPane(HashMap hyperLinkEditorMap, boolean needRenamePane) { public JavaScriptImplPane(HashMap hyperLinkEditorMap, boolean needRenamePane) {
super(hyperLinkEditorMap, needRenamePane); super(hyperLinkEditorMap, needRenamePane);
this.defaultArgs = new String[0]; this.defaultArgs = new String[0];
initComponents(); initComponents();
} }
public JavaScriptImplPane(String[] args) { public JavaScriptImplPane(String[] args) {
this.defaultArgs = args; this.defaultArgs = args;
initComponents(); initComponents();
} }
protected void initComponents() { protected void initComponents() {
parameterPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); parameterPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane());
parameterPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Inter.getLocText("FR-Designer_Parameter"))); parameterPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Inter.getLocText("FR-Designer_Parameter")));
parameterPane.addTableEditorListener(new TableModelListener() { parameterPane.addTableEditorListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) { public void tableChanged(TableModelEvent e) {
List<ParameterProvider> list = parameterPane.update(); List<ParameterProvider> list = parameterPane.update();
HashSet tempSet = new HashSet(); HashSet tempSet = new HashSet();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if (StringUtils.isEmpty(list.get(i).getName())) { if (StringUtils.isEmpty(list.get(i).getName())) {
continue; continue;
} }
if (tempSet.contains(list.get(i).toString())) { if (tempSet.contains(list.get(i).toString())) {
list.remove(i); list.remove(i);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Repeat", "Parameter_Name"}) + "!"); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"Repeat", "Parameter_Name"}) + "!");
parameterChanger(list); parameterChanger(list);
return; return;
} }
tempSet.add(list.get(i).toString()); tempSet.add(list.get(i).toString());
} }
parameterChanger(list); parameterChanger(list);
} }
}); });
OneListTableModel<String> model = new OneListTableModel<String>(Inter.getLocText("ReportServerP-Import_JavaScript"), this) { OneListTableModel<String> model = new OneListTableModel<String>(Inter.getLocText("ReportServerP-Import_JavaScript"), this) {
public UITableEditAction[] createAction() { public UITableEditAction[] createAction() {
return new UITableEditAction[] { getAddAction(),new DeleteAction(this.component), new MoveUpAction(), new MoveDownAction() }; return new UITableEditAction[]{getAddAction(), new DeleteAction(this.component), new MoveUpAction(), new MoveDownAction()};
} }
@Override @Override
public UITableEditAction getAddAction() { public UITableEditAction getAddAction() {
return new AddJsAction(); return new AddJsAction();
} }
}; };
importedJsPane = new UITableEditorPane<String>(model); importedJsPane = new UITableEditorPane<String>(model);
importedJsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Inter.getLocText("ReportServerP-Import_JavaScript"))); importedJsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Inter.getLocText("ReportServerP-Import_JavaScript")));
importedJsPane.setPreferredSize(new Dimension(265, 150)); importedJsPane.setPreferredSize(new Dimension(265, 150));
jsPane = new JSContentPane(defaultArgs); jsPane = new JSContentPane(defaultArgs);
jsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Inter.getLocText("FR-Designer_JavaScript"))); jsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Inter.getLocText("FR-Designer_JavaScript")));
parameterPane.setPreferredSize(new Dimension(265, 150)); parameterPane.setPreferredSize(new Dimension(265, 150));
JPanel topPane = GUICoreUtils.createBorderLayoutPane( JPanel topPane = GUICoreUtils.createBorderLayoutPane(
importedJsPane, BorderLayout.CENTER, importedJsPane, BorderLayout.CENTER,
parameterPane, BorderLayout.EAST parameterPane, BorderLayout.EAST
); );
topPane.setPreferredSize(new Dimension(300, 150)); topPane.setPreferredSize(new Dimension(300, 150));
topPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 12, 0)); topPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 12, 0));
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(topPane,BorderLayout.NORTH) ; this.add(topPane, BorderLayout.NORTH);
this.add(jsPane,BorderLayout.CENTER); this.add(jsPane, BorderLayout.CENTER);
this.reLayoutForChart(); this.reLayoutForChart();
} }
/** /**
*参数改变 * 参数改变
* @param list 参数列表. *
*/ * @param list 参数列表.
public void parameterChanger(List<ParameterProvider> list) { */
String[] name = new String[list.size()]; public void parameterChanger(List<ParameterProvider> list) {
for (int i = 0; i < list.size(); i++) { String[] name = new String[list.size()];
if (list.get(i) instanceof Parameter) { for (int i = 0; i < list.size(); i++) {
name[i] = list.get(i).getName(); if (list.get(i) instanceof Parameter) {
} name[i] = list.get(i).getName();
} }
jsPane.setFunctionTitle(name, defaultArgs); }
} jsPane.setFunctionTitle(name, defaultArgs);
}
/**
* title for popup window 弹出界面标题 /**
* @return 标题. * title for popup window 弹出界面标题
*/ *
public String title4PopupWindow() { * @return 标题.
return Inter.getLocText("FR-Designer_JavaScript"); */
} public String title4PopupWindow() {
return Inter.getLocText("FR-Designer_JavaScript");
}
/** /**
* 重置 * 重置
*/ */
public void reset() { public void reset() {
populateBean(null); populateBean(null);
} }
public void populateBean(JavaScriptImpl javaScriptImpl) { public void populateBean(JavaScriptImpl javaScriptImpl) {
if (javaScriptImpl == null) { if (javaScriptImpl == null) {
javaScriptImpl = new JavaScriptImpl(); javaScriptImpl = new JavaScriptImpl();
} }
int rowCount = javaScriptImpl.getJSImportSize(); int rowCount = javaScriptImpl.getJSImportSize();
String[] value = new String[rowCount]; String[] value = new String[rowCount];
for (int i = 0; i < rowCount; i++) { for (int i = 0; i < rowCount; i++) {
value[i] = javaScriptImpl.getJSImport(i); value[i] = javaScriptImpl.getJSImport(i);
} }
importedJsPane.populate(value); importedJsPane.populate(value);
parameterPane.populate(javaScriptImpl.getParameters()); parameterPane.populate(javaScriptImpl.getParameters());
jsPane.populate(javaScriptImpl.getContent()); jsPane.populate(javaScriptImpl.getContent());
if(itemNameTextField != null){ if (itemNameTextField != null) {
itemNameTextField.setText(javaScriptImpl.getItemName()); itemNameTextField.setText(javaScriptImpl.getItemName());
} }
} }
public JavaScriptImpl updateBean() { public JavaScriptImpl updateBean() {
JavaScriptImpl javaScript = new JavaScriptImpl(); JavaScriptImpl javaScript = new JavaScriptImpl();
updateBean(javaScript); updateBean(javaScript);
return javaScript; return javaScript;
} }
public void updateBean(JavaScriptImpl javaScript) { public void updateBean(JavaScriptImpl javaScript) {
List<String> list = importedJsPane.update(); List<String> list = importedJsPane.update();
javaScript.clearJSImports(); javaScript.clearJSImports();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
String a = list.get(i); String a = list.get(i);
javaScript.addJSImort(a); javaScript.addJSImort(a);
} }
List<ParameterProvider> parameterList = parameterPane.update(); List<ParameterProvider> parameterList = parameterPane.update();
javaScript.setParameters(parameterList.toArray(new Parameter[parameterList.size()])); javaScript.setParameters(parameterList.toArray(new Parameter[parameterList.size()]));
javaScript.setContent(jsPane.update()); javaScript.setContent(jsPane.update());
if(this.itemNameTextField != null){ if (this.itemNameTextField != null) {
javaScript.setItemName(itemNameTextField.getText()); javaScript.setItemName(itemNameTextField.getText());
} }
} }
private GridBagConstraints setConstraints(int x, int y, int w, int h, double wx, double wy, GridBagConstraints c) { private GridBagConstraints setConstraints(int x, int y, int w, int h, double wx, double wy, GridBagConstraints c) {
if (c == null) { if (c == null) {
return null; return null;
} }
c.gridx = x; c.gridx = x;
c.gridy = y; c.gridy = y;
c.gridheight = h; c.gridheight = h;
c.gridwidth = w; c.gridwidth = w;
c.weightx = wx; c.weightx = wx;
c.weighty = wy; c.weighty = wy;
return c; return c;
} }
protected void reLayoutForChart(){ protected void reLayoutForChart() {
if(needRenamePane()){ if (needRenamePane()) {
this.removeAll(); this.removeAll();
itemNameTextField = new UITextField(); itemNameTextField = new UITextField();
JPanel topPane = GUICoreUtils.createBorderLayoutPane( JPanel topPane = GUICoreUtils.createBorderLayoutPane(
GUICoreUtils.createNamedPane(itemNameTextField,Inter.getLocText("FR-Chart-Use_Name") + ":"), BorderLayout.NORTH, GUICoreUtils.createNamedPane(itemNameTextField, Inter.getLocText("FR-Chart-Use_Name") + ":"), BorderLayout.NORTH,
importedJsPane, BorderLayout.CENTER, importedJsPane, BorderLayout.CENTER,
parameterPane, BorderLayout.EAST parameterPane, BorderLayout.EAST
); );
topPane.setPreferredSize(new Dimension(300, 150)); topPane.setPreferredSize(new Dimension(300, 150));
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(topPane,BorderLayout.NORTH) ; this.add(topPane, BorderLayout.NORTH);
this.add(jsPane,BorderLayout.CENTER); this.add(jsPane, BorderLayout.CENTER);
this.repaint(); this.repaint();
} }
} }
public static class CHART_NO_RENAME extends JavaScriptImplPane{ public static class CHART_NO_RENAME extends JavaScriptImplPane {
protected int getChartParaType() { protected int getChartParaType() {
return ParameterTableModel.CHART_NORMAL_USE; return ParameterTableModel.CHART_NORMAL_USE;
} }
protected boolean needRenamePane(){
protected boolean needRenamePane() {
return false; return false;
} }
} }
/** /**
* 判断类型 * 判断类型
* @param ob 判断目标 *
* @param ob 判断目标
* @return 返回是否符合类型. * @return 返回是否符合类型.
*/ */
public boolean accept(Object ob) { public boolean accept(Object ob) {
return ob instanceof JavaScriptImpl; return ob instanceof JavaScriptImpl;
} }
} }
Loading…
Cancel
Save