Browse Source

Merge pull request #726 in BA/design from ~NEIL/design:master to dev

* commit '0ebe0c91847de19db1183f69f78b2efd8bc3a853': (74 commits)
  ct
  ct
  REPORT-1967 国际化
  REPORT-1940 表单从绝对布局切换到自适应,预览空白 pmd
  REPORT-1940 表单从绝对布局切换到自适应,预览空白
  提示用户升级插件
  无JIRA任务。新增国际化key
  修改配置文件
  股价图属性配置问题
  无JIRA任务。国际化
  国际化翻译
  国际化修改
  国际化翻译
  无JIRA任务。国际化key
  无JIRA任务, 冲突修正
  ct
  ct
  国际化翻译
  无JIRA任务 tab功能屏蔽
  REPORT-1814 表单tab块的改良bug 功能屏蔽
  ...
master
superman 8 years ago
parent
commit
ce36df9dba
  1. 2
      .gitignore
  2. 9
      designer/designer.iml
  3. 13
      designer/src/com/fr/design/mainframe/CellElementPropertyPane.java
  4. 2
      designer/src/com/fr/design/mainframe/JWorkBook.java
  5. 48
      designer/src/com/fr/design/webattr/EditToolBar.java
  6. 6
      designer/src/com/fr/design/webattr/ReportWebWidgetConstants.java
  7. 6
      designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java
  8. 6
      designer/src/com/fr/grid/selection/CellSelection.java
  9. 6
      designer/src/com/fr/grid/selection/FloatSelection.java
  10. 2
      designer/src/com/fr/grid/selection/Selection.java
  11. 62
      designer_base/src/com/fr/design/actions/file/LocalePane.java
  12. 418
      designer_base/src/com/fr/design/formula/FormulaPane.java
  13. 51
      designer_base/src/com/fr/design/formula/FunctionConstants.java
  14. 2
      designer_base/src/com/fr/design/formula/FunctionDefNAD.java
  15. 3
      designer_base/src/com/fr/design/fun/ConnectionProvider.java
  16. 41
      designer_base/src/com/fr/design/fun/ExtraButtonToolBarProvider.java
  17. 19
      designer_base/src/com/fr/design/fun/impl/AbstractExtraButtonToolBarProvider.java
  18. 8
      designer_base/src/com/fr/design/gui/icombobox/UIComboBox.java
  19. 7
      designer_base/src/com/fr/design/style/color/ColorPicker.java
  20. 1
      designer_base/src/com/fr/design/style/color/ColorSelectBox.java
  21. 2
      designer_chart/src/com/fr/design/chart/report/GisMapTableDataContentPane.java
  22. 2
      designer_chart/src/com/fr/design/chart/report/GisMapTableDataContentPane4Chart.java
  23. 4
      designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java
  24. 7
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  25. 11
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  26. 2
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/BubblePlotTableDataContentPane.java
  27. 2
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java
  28. 2
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/StockPlotTableDataContentPane.java
  29. 2
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/XYScatterPlotTableDataContentPane.java
  30. 16
      designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java
  31. 311
      designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java

2
.gitignore vendored

@ -3,3 +3,5 @@ designer_base/bin
designer_chart/bin designer_chart/bin
designer_form/bin designer_form/bin
*.iml *.iml

9
designer/designer.iml

@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4"> <module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false"> <component name="NewModuleRootManager" inherit-compiler-output="true">
<output url="file://$MODULE_DIR$/../../env/WebReport/WEB-INF/classes" /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content> </content>
<orderEntry type="jdk" jdkName="jdk1.8" jdkType="JavaSDK" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="designer_base" /> <orderEntry type="module" module-name="designer_base" />
<orderEntry type="library" name="lib" level="project" /> <orderEntry type="module" module-name="designer_form" />
<orderEntry type="module" module-name="designer_chart" />
</component> </component>
</module> </module>

13
designer/src/com/fr/design/mainframe/CellElementPropertyPane.java

@ -102,12 +102,23 @@ public class CellElementPropertyPane extends DockingView {
return element; return element;
} }
public void removeAll() {
this.remove(titlePane);
this.remove(cellElementEditPane);
}
public void reInit(ElementCasePane ePane) {
this.add(titlePane, BorderLayout.NORTH);
this.add(cellElementEditPane, BorderLayout.CENTER);
cellElementEditPane.populate(ePane);
}
public void populate(ElementCasePane ePane) { public void populate(ElementCasePane ePane) {
TemplateElementCase elementCase = ePane.getEditingElementCase(); TemplateElementCase elementCase = ePane.getEditingElementCase();
if (elementCase == null) { if (elementCase == null) {
return; return;
} }
cellElementEditPane.populate(ePane); ePane.getSelection().populatePropertyPane(ePane);
} }
@Override @Override

2
designer/src/com/fr/design/mainframe/JWorkBook.java

@ -463,7 +463,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
*/ */
public ShortCut[] shortCuts4Authority() { public ShortCut[] shortCuts4Authority() {
return new ShortCut[]{ return new ShortCut[]{
new NameSeparator(Inter.getLocText(new String[]{"DashBoard-Potence", "Edit"})), new NameSeparator(Inter.getLocText("FR-Designer_Permissions_Edition")),
BaseUtils.isAuthorityEditing() ? new ExitAuthorityEditAction(this) : new AllowAuthorityEditAction(this), BaseUtils.isAuthorityEditing() ? new ExitAuthorityEditAction(this) : new AllowAuthorityEditAction(this),
}; };

48
designer/src/com/fr/design/webattr/EditToolBar.java

@ -7,6 +7,7 @@ import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.fun.ExportToolBarProvider; import com.fr.design.fun.ExportToolBarProvider;
import com.fr.design.fun.ExtraButtonToolBarProvider;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -199,7 +200,7 @@ public class EditToolBar extends BasicPane {
toolBarButton.setWidget(widget); toolBarButton.setWidget(widget);
if (widget instanceof Button) { if (widget instanceof Button) {
String iconname = ((Button) widget).getIconName(); String iconname = ((Button) widget).getIconName();
if (!StringUtils.isBlank(iconname)) { if (StringUtils.isNotBlank(iconname)) {
Image iimage = WidgetManager.getProviderInstance().getIconManager().getIconImage(iconname); Image iimage = WidgetManager.getProviderInstance().getIconManager().getIconImage(iconname);
toolBarButton.setIcon(new ImageIcon(iimage)); toolBarButton.setIcon(new ImageIcon(iimage));
} }
@ -326,7 +327,7 @@ public class EditToolBar extends BasicPane {
private IconDefinePane iconPane; private IconDefinePane iconPane;
private UIButton button; private UIButton button;
private JavaScriptActionPane javaScriptPane; private JavaScriptActionPane javaScriptPane;
private ExportToolBarProvider[] exportToolBarProviders; private ExportToolBarProvider[] exportToolBarProviders;
private ChangeListener changeListener = new ChangeListener() { private ChangeListener changeListener = new ChangeListener() {
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
@ -386,6 +387,11 @@ public class EditToolBar extends BasicPane {
centerPane.add(getCpane(), "appendcount"); centerPane.add(getCpane(), "appendcount");
centerPane.add(getSubmitPane(), "submit"); centerPane.add(getSubmitPane(), "submit");
Set<ExtraButtonToolBarProvider> extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG);
for (ExtraButtonToolBarProvider provider : extraButtonSet) {
provider.updateCenterPane(centerPane);
}
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
} }
@ -479,7 +485,6 @@ public class EditToolBar extends BasicPane {
return submitPane; return submitPane;
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "Button"; return "Button";
@ -528,13 +533,18 @@ public class EditToolBar extends BasicPane {
} else if (widget instanceof CustomToolBarButton) { } else if (widget instanceof CustomToolBarButton) {
populateCustomToolBarButton(); populateCustomToolBarButton();
} }
}
Set<ExtraButtonToolBarProvider> extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG);
for (ExtraButtonToolBarProvider provider : extraButtonSet) {
provider.populate(widget, card, centerPane);
}
}
private void populateAppendColumnRow(){ private void populateAppendColumnRow(){
card.show(centerPane, "appendcount"); card.show(centerPane, "appendcount");
count.setValue(((AppendColumnRow) widget).getCount()); count.setValue(((AppendColumnRow) widget).getCount());
} }
private void populateExport(){ private void populateExport(){
card.show(centerPane, "export"); card.show(centerPane, "export");
Export export = (Export) widget; Export export = (Export) widget;
@ -550,7 +560,7 @@ public class EditToolBar extends BasicPane {
} }
} }
} }
private void populateCustomToolBarButton(){ private void populateCustomToolBarButton(){
card.show(centerPane, "custom"); card.show(centerPane, "custom");
CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget; CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget;
@ -558,7 +568,7 @@ public class EditToolBar extends BasicPane {
this.javaScriptPane.populateBean(customToolBarButton.getJSImpl()); this.javaScriptPane.populateBean(customToolBarButton.getJSImpl());
} }
} }
private void populateSubmit(){ private void populateSubmit(){
card.show(centerPane, "submit"); card.show(centerPane, "submit");
Submit submit = ((Submit) widget); Submit submit = ((Submit) widget);
@ -566,13 +576,13 @@ public class EditToolBar extends BasicPane {
this.failSubmit.setSelected(submit.isFailVerifySubmit()); this.failSubmit.setSelected(submit.isFailVerifySubmit());
this.isCurSheet.setSelected(submit.isOnlySubmitSelect()); this.isCurSheet.setSelected(submit.isOnlySubmitSelect());
} }
private void populatePDFPrint(){ private void populatePDFPrint(){
card.show(centerPane, "pdfprint"); card.show(centerPane, "pdfprint");
PDFPrint pdfPrint = (PDFPrint) widget; PDFPrint pdfPrint = (PDFPrint) widget;
this.isPopup.setSelected(pdfPrint.isPopup()); this.isPopup.setSelected(pdfPrint.isPopup());
} }
private void populatePrint(){ private void populatePrint(){
card.show(centerPane, "print"); card.show(centerPane, "print");
Print print = (Print) widget; Print print = (Print) widget;
@ -581,7 +591,7 @@ public class EditToolBar extends BasicPane {
this.flashPrint.setSelected(print.isFlashPrint()); this.flashPrint.setSelected(print.isFlashPrint());
this.serverPrint.setSelected(print.isServerPrint()); this.serverPrint.setSelected(print.isServerPrint());
} }
private void populateDefault(){ private void populateDefault(){
Button button = (Button) widget; Button button = (Button) widget;
this.icon.setSelected(button.isShowIcon()); this.icon.setSelected(button.isShowIcon());
@ -592,7 +602,7 @@ public class EditToolBar extends BasicPane {
/** /**
* 更新 * 更新
* *
* @return 对应组件 * @return 对应组件
*/ */
public Widget update() { public Widget update() {
@ -613,23 +623,29 @@ public class EditToolBar extends BasicPane {
if (widget instanceof Button) { if (widget instanceof Button) {
updateDefault(); updateDefault();
} }
Set<ExtraButtonToolBarProvider> extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG);
for (ExtraButtonToolBarProvider provider : extraButtonSet) {
provider.update(widget);
}
return widget; return widget;
} }
private void updateDefault(){ private void updateDefault(){
((Button) widget).setShowIcon(this.icon.isSelected()); ((Button) widget).setShowIcon(this.icon.isSelected());
((Button) widget).setShowText(this.text.isSelected()); ((Button) widget).setShowText(this.text.isSelected());
((Button) widget).setText(this.nameField.getText()); ((Button) widget).setText(this.nameField.getText());
((Button) widget).setIconName(this.iconPane.update()); ((Button) widget).setIconName(this.iconPane.update());
} }
private void updateSubmit(){ private void updateSubmit(){
Submit submit = ((Submit) widget); Submit submit = ((Submit) widget);
submit.setVerify(this.isVerify.isSelected()); submit.setVerify(this.isVerify.isSelected());
submit.setFailVerifySubmit(this.failSubmit.isSelected()); submit.setFailVerifySubmit(this.failSubmit.isSelected());
submit.setOnlySubmitSelect(this.isCurSheet.isSelected()); submit.setOnlySubmitSelect(this.isCurSheet.isSelected());
} }
private void updatePrint(){ private void updatePrint(){
Print print = (Print) widget; Print print = (Print) widget;
print.setAppletPrint(this.appletPrint.isSelected()); print.setAppletPrint(this.appletPrint.isSelected());
@ -637,7 +653,7 @@ public class EditToolBar extends BasicPane {
print.setPDFPrint(this.pdfPrint.isSelected()); print.setPDFPrint(this.pdfPrint.isSelected());
print.setServerPrint(this.serverPrint.isSelected()); print.setServerPrint(this.serverPrint.isSelected());
} }
private void updateExport(){ private void updateExport(){
Export export = (Export) widget; Export export = (Export) widget;
export.setPdfAvailable(this.pdf.isSelected()); export.setPdfAvailable(this.pdf.isSelected());

6
designer/src/com/fr/design/webattr/ReportWebWidgetConstants.java

@ -78,13 +78,13 @@ public class ReportWebWidgetConstants {
public static final WidgetOption EDIT = WidgetOptionFactory.createByWidgetClass("Edit", Edit.class); public static final WidgetOption EDIT = WidgetOptionFactory.createByWidgetClass("Edit", Edit.class);
// 导出成Excel 分页导出 // 导出成Excel 分页导出
public static final WidgetOption EXCELP = WidgetOptionFactory.createByWidgetClass(Inter.getLocText(new String[]{"Excel", "Export-Excel-Page"}, new String[]{"(", ")"}), public static final WidgetOption EXCELP = WidgetOptionFactory.createByWidgetClass(Inter.getLocText(new String[]{"Excel", "FR-Designer_Export_Excel_Page"}, new String[]{"(", ")"}),
BaseUtils.readIcon("/com/fr/web/images/excel.png"), ExcelP.class); BaseUtils.readIcon("/com/fr/web/images/excel.png"), ExcelP.class);
// 导出成Excel 原样导出 // 导出成Excel 原样导出
public static final WidgetOption EXCELO = WidgetOptionFactory.createByWidgetClass(Inter.getLocText(new String[]{"Excel", "Export-Excel-Simple"}, new String[]{"(", ")"}), public static final WidgetOption EXCELO = WidgetOptionFactory.createByWidgetClass(Inter.getLocText(new String[]{"Excel", "FR-Designer_Export_Excel_Simple"}, new String[]{"(", ")"}),
BaseUtils.readIcon("/com/fr/web/images/excel.png"), ExcelO.class); BaseUtils.readIcon("/com/fr/web/images/excel.png"), ExcelO.class);
// 导出成Excel 分页分Sheet导出 // 导出成Excel 分页分Sheet导出
public static final WidgetOption EXCELS = WidgetOptionFactory.createByWidgetClass(Inter.getLocText(new String[]{"Excel", "Export-Excel-PageToSheet"}, new String[]{"(", ")"}), public static final WidgetOption EXCELS = WidgetOptionFactory.createByWidgetClass(Inter.getLocText(new String[]{"Excel", "FR-Designer_Export_Excel_PageToSheet"}, new String[]{"(", ")"}),
BaseUtils.readIcon("/com/fr/web/images/excel.png"), ExcelS.class); BaseUtils.readIcon("/com/fr/web/images/excel.png"), ExcelS.class);
// 导出成Word // 导出成Word

6
designer/src/com/fr/design/widget/ui/TextFieldEditorDefinePane.java

@ -61,11 +61,7 @@ public class TextFieldEditorDefinePane extends FieldEditorDefinePane<TextEditor>
regPane.getRegComboBox().addActionListener(new ActionListener() { regPane.getRegComboBox().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
RegExp regExp = (RegExp) regPane.getRegComboBox().getSelectedItem(); RegExp regExp = (RegExp) regPane.getRegComboBox().getSelectedItem();
if (!StringUtils.isNotEmpty(regExp.toRegText())) { getRegErrorMsgTextField().setEnabled(regExp.errorMessageEditable());
getRegErrorMsgTextField().setEnabled(false);
} else {
getRegErrorMsgTextField().setEnabled(true);
}
} }
}); });

6
designer/src/com/fr/grid/selection/CellSelection.java

@ -18,6 +18,7 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.imenu.UIMenu; import com.fr.design.gui.imenu.UIMenu;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.ElementCasePane.Clear; import com.fr.design.mainframe.ElementCasePane.Clear;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
@ -684,4 +685,9 @@ public class CellSelection extends Selection {
editor.populate(tc); editor.populate(tc);
return editor; return editor;
} }
@Override
public void populatePropertyPane(ElementCasePane ePane) {
CellElementPropertyPane.getInstance().reInit(ePane);
}
} }

6
designer/src/com/fr/grid/selection/FloatSelection.java

@ -20,6 +20,7 @@ import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
@ -230,4 +231,9 @@ public class FloatSelection extends Selection {
editor.populate(tc); editor.populate(tc);
return editor; return editor;
} }
@Override
public void populatePropertyPane(ElementCasePane ePane) {
CellElementPropertyPane.getInstance().removeAll();
}
} }

2
designer/src/com/fr/grid/selection/Selection.java

@ -87,6 +87,8 @@ public abstract class Selection implements FCloneable, Serializable , Selectable
// //////////////////////////Just4CellSelection/////////////////////////////// // //////////////////////////Just4CellSelection///////////////////////////////
public abstract boolean containsColumnRow(ColumnRow cr); public abstract boolean containsColumnRow(ColumnRow cr);
public abstract void populatePropertyPane(ElementCasePane ePane);
@Override @Override

62
designer_base/src/com/fr/design/actions/file/LocalePane.java

@ -27,6 +27,8 @@ import com.fr.design.dialog.BasicPane;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.*; import com.fr.general.*;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
/** /**
@ -51,8 +53,8 @@ public class LocalePane extends BasicPane {
add(tabbedPane, BorderLayout.CENTER); add(tabbedPane, BorderLayout.CENTER);
predefineTableModel = new DefaultTableModel() { predefineTableModel = new DefaultTableModel() {
public boolean isCellEditable(int col, int row) { public boolean isCellEditable(int row, int column) {
return false; return column == 0;
} }
}; };
@ -109,23 +111,39 @@ public class LocalePane extends BasicPane {
} }
private void initPredefinedProperties() { private void initPredefinedProperties() {
Map<Locale, LocalePackage> map = Inter.getPredefinedPackageMap();
LocalePackage chinese = map.get(Locale.SIMPLIFIED_CHINESE); Map<Locale, String> supportLocaleMap = Inter.getSupportLocaleMap();
String[] localeFiles = StableFactory.getLocaleFiles();
List<String> sortKeys = new ArrayList<String>(); List<String> sortKeys = new ArrayList<String>();
Set<ResourceBundle> bundles = chinese.getKindsOfResourceBundle(); for (String path : localeFiles) {
for (ResourceBundle bundle : bundles) { ResourceBundle chineseBundle = loadResourceBundle(path, Locale.SIMPLIFIED_CHINESE);
sortKeys.addAll(bundle.keySet()); sortKeys.addAll(chineseBundle.keySet());
} }
Collections.sort(sortKeys); Collections.sort(sortKeys);
Map<Locale, List<ResourceBundle>> localeResourceBundleMap = new HashMap<Locale, List<ResourceBundle>>();
for (Map.Entry<Locale, String> entry : supportLocaleMap.entrySet()) {
Locale locale = entry.getKey();
List<ResourceBundle> list = new ArrayList<>();
for (String path : localeFiles) {
ResourceBundle chineseBundle = loadResourceBundle(path, locale);
list.add(chineseBundle);
}
localeResourceBundleMap.put(locale, list);
}
Map<Locale, Vector<String>> data = new HashMap<Locale, Vector<String>>(); Map<Locale, Vector<String>> data = new HashMap<Locale, Vector<String>>();
for (Map.Entry<Locale, LocalePackage> entry : map.entrySet()) { for (Map.Entry<Locale, List<ResourceBundle>> entry : localeResourceBundleMap.entrySet()) {
Vector<String> column = new Vector<String>(); Vector<String> column = new Vector<String>();
List<ResourceBundle> rbs = entry.getValue();
for (String key : sortKeys) { for (String key : sortKeys) {
column.add(entry.getValue().getLocText(key)); column.add(readText(rbs, key));
} }
data.put(entry.getKey(), column); data.put(entry.getKey(), column);
} }
@ -140,6 +158,19 @@ public class LocalePane extends BasicPane {
} }
} }
private String readText(List<ResourceBundle> rbs, String key) {
for (ResourceBundle rb : rbs) {
if (rb.containsKey(key)) {
return rb.getString(key);
}
}
return null;
}
private ResourceBundle loadResourceBundle(String dir, Locale locale) {
return ResourceBundle.getBundle(dir, locale, Inter.class.getClassLoader());
}
private void initCustomProperties() throws Exception { private void initCustomProperties() throws Exception {
Env env = FRContext.getCurrentEnv(); Env env = FRContext.getCurrentEnv();
if (env == null) { if (env == null) {
@ -176,22 +207,9 @@ public class LocalePane extends BasicPane {
} }
} }
private Properties loadLocaleProperties(String name) {
Properties properties = new Properties();
InputStream inputStream = IOUtils.readResource("/com/fr/general/locale/" + name);
try {
properties.load(inputStream);
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
}
return properties;
}
/** /**
* 保存当前编辑的国际化 * 保存当前编辑的国际化
* *
*
* @date 2014-9-30-下午3:10:30
*/ */
public void save() { public void save() {
Env env = FRContext.getCurrentEnv(); Env env = FRContext.getCurrentEnv();

418
designer_base/src/com/fr/design/formula/FormulaPane.java

@ -32,10 +32,12 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener; import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.*; import javax.swing.tree.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.io.*; import java.io.*;
import java.util.Locale; import java.util.Locale;
import java.util.Set;
/** /**
* 公式编辑面板 * 公式编辑面板
* @editor zhou * @editor zhou
@ -60,29 +62,16 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
public FormulaPane() { public FormulaPane() {
initComponents(); initComponents();
} }
protected void initComponents() { private void initFormulaTextAreaKeyListener(){
this.setLayout(new BorderLayout(4, 4)); formulaTextArea.addKeyListener(this);
formulaTextArea.addKeyListener(new KeyAdapter() {
// text
JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(textPane, BorderLayout.CENTER);
JPanel checkBoxandbuttonPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
UILabel formulaLabel = new UILabel(Inter.getLocText("FormulaD-Input_formula_in_the_text_area_below") + ":"
+ " ");
formulaLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
formulaTextArea = new RSyntaxTextArea();
configFormulaArea();
formulaTextArea.addKeyListener(this);
formulaTextArea.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
formulaTextArea.setForeground(Color.black); formulaTextArea.setForeground(Color.black);
String text = formulaTextArea.getText(); String text = formulaTextArea.getText();
// 判断在中文输入状态是否还包含提示符 要删掉 // 判断在中文输入状态是否还包含提示符 要删掉
String tip = "\n\n\n" + Inter.getLocText("Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column"); //Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column
String tip = "\n\n\n" + Inter.getLocText("FR-Designer_FormulaPane_Tips");
if(text.contains(tip)) { if(text.contains(tip)) {
text = text.substring(0, text.indexOf(tip)); text = text.substring(0, text.indexOf(tip));
insertPosition = 0; insertPosition = 0;
@ -90,9 +79,10 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
} }
} }
}); });
}
formulaTextArea.addMouseListener(new MouseAdapter() {
private void initFormulaTextAreaMouseListener(){
formulaTextArea.addMouseListener(new MouseAdapter() {
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
insertPosition = formulaTextArea.getCaretPosition(); insertPosition = formulaTextArea.getCaretPosition();
@ -115,52 +105,81 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
} }
} }
}); });
UIScrollPane formulaTextAreaScrollPane = new UIScrollPane(formulaTextArea); }
formulaTextAreaScrollPane.setBorder(null);
textPane.add(formulaLabel, BorderLayout.NORTH); private void initFormulaTextArea(){
textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER); formulaTextArea = new RSyntaxTextArea();
textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH); configFormulaArea();
initFormulaTextAreaKeyListener();
// tipsPane initFormulaTextAreaMouseListener();
JPanel tipsPane = new JPanel(new BorderLayout(4, 4)); }
this.add(tipsPane, BorderLayout.EAST);
private void initKeyWordTextFieldKeyListener(){
JPanel searchPane = new JPanel(new BorderLayout(4, 4)); keyWordTextField.addKeyListener(new KeyListener() {
searchPane.add(keyWordTextField, BorderLayout.CENTER);
UIButton searchButton = new UIButton(Inter.getLocText("Search"));
searchPane.add(searchButton, BorderLayout.EAST);
tipsPane.add(searchPane, BorderLayout.NORTH);
keyWordTextField.addKeyListener(new KeyListener() {
@Override @Override
public void keyTyped(KeyEvent e) { public void keyTyped(KeyEvent e) {
} }
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
} }
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
String toFind = keyWordTextField.getText(); String toFind = keyWordTextField.getText();
search(toFind, false); search(toFind, false);
fixFunctionNameList(); fixFunctionNameList();
e.consume(); e.consume();
} }
} }
}); });
}
private void initTipsPane(){
// tipsPane
JPanel tipsPane = new JPanel(new BorderLayout(4, 4));
this.add(tipsPane, BorderLayout.EAST);
JPanel searchPane = new JPanel(new BorderLayout(4, 4));
searchPane.add(keyWordTextField, BorderLayout.CENTER);
UIButton searchButton = new UIButton(Inter.getLocText("FR-Designer_FormulaPane_Search"));
searchPane.add(searchButton, BorderLayout.EAST);
tipsPane.add(searchPane, BorderLayout.NORTH);
initKeyWordTextFieldKeyListener();
tipsList = new JList(listModel); tipsList = new JList(listModel);
tipsList.addMouseListener(new DoubleClick()); tipsList.addMouseListener(new DoubleClick());
UIScrollPane tipsScrollPane = new UIScrollPane(tipsList); UIScrollPane tipsScrollPane = new UIScrollPane(tipsList);
tipsScrollPane.setPreferredSize(new Dimension(170, 75)); tipsScrollPane.setPreferredSize(new Dimension(170, 75));
tipsScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); tipsScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
tipsPane.add(tipsScrollPane, BorderLayout.CENTER); tipsPane.add(tipsScrollPane, BorderLayout.CENTER);
searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String toFind = keyWordTextField.getText();
search(toFind, false);
formulaTextArea.requestFocusInWindow();
fixFunctionNameList();
}
});
}
protected void initComponents() {
this.setLayout(new BorderLayout(4, 4));
// text
JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(textPane, BorderLayout.CENTER);
JPanel checkBoxandbuttonPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
UILabel formulaLabel = new UILabel(Inter.getLocText("FormulaD-Input_formula_in_the_text_area_below") + ":"
+ " ");
formulaLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
initFormulaTextArea();
UIScrollPane formulaTextAreaScrollPane = new UIScrollPane(formulaTextArea);
formulaTextAreaScrollPane.setBorder(null);
textPane.add(formulaLabel, BorderLayout.NORTH);
textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER);
textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH);
initTipsPane();
UIButton checkValidButton = new UIButton(Inter.getLocText("FormulaD-Check_Valid")); UIButton checkValidButton = new UIButton(Inter.getLocText("FormulaD-Check_Valid"));
checkValidButton.addActionListener(checkValidActionListener); checkValidButton.addActionListener(checkValidActionListener);
@ -169,20 +188,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
checkBoxPane.setPreferredSize(new Dimension(450, 30)); checkBoxPane.setPreferredSize(new Dimension(450, 30));
checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST); checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST);
checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST); checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST);
extendCheckBoxPane(checkBoxPane); extendCheckBoxPane(checkBoxPane);
searchButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String toFind = keyWordTextField.getText();
search(toFind, false);
formulaTextArea.requestFocusInWindow();
fixFunctionNameList();
}
});
variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea(); variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea();
this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH); this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH);
} }
@ -253,11 +259,17 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
this.formulaTextArea.setText(StringUtils.EMPTY); this.formulaTextArea.setText(StringUtils.EMPTY);
} }
} }
//hugh:为啥会是10呢?搞不懂~~~
private static final int KEY_10 = 10;
//上下左右
private static final int KEY_37 = 37;
private static final int KEY_38 = 38;
private static final int KEY_39 = 39;
private static final int KEY_40 = 40;
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
int key = e.getKeyCode(); int key = e.getKeyCode();
if (key == 38 || key == 40 || key == 37 || key == 39 || key == 10) //如果是删除符号 ,为了可读性 没有和其他按键的程序相融合 if (key == KEY_38 || key == KEY_40 || key == KEY_37 || key == KEY_39 || key == KEY_10) //如果是删除符号 ,为了可读性 没有和其他按键的程序相融合
{ {
listModel.removeAllElements(); listModel.removeAllElements();
currentPosition = formulaTextArea.getCaretPosition(); currentPosition = formulaTextArea.getCaretPosition();
@ -461,7 +473,8 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
String content = formula.getContent(); String content = formula.getContent();
if (content.trim().equals("=")) { if (content.trim().equals("=")) {
this.formulaTextArea.setForeground(Color.gray); this.formulaTextArea.setForeground(Color.gray);
this.formulaTextArea.setText("\n\n\n" + Inter.getLocText("Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column")); //Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column
this.formulaTextArea.setText("\n\n\n" + Inter.getLocText("FR-Designer_FormulaPane_Tips"));
this.formulaTextArea.setCaretPosition(0); this.formulaTextArea.setCaretPosition(0);
ifHasBeenWriten = 0; ifHasBeenWriten = 0;
this.listModel.removeAllElements(); this.listModel.removeAllElements();
@ -548,22 +561,21 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
public VariableTreeAndDescriptionArea() { public VariableTreeAndDescriptionArea() {
this.initComponents(); this.initComponents();
} }
private void initComponents() { private void initFunctionTypeList(JPanel functionPane){
this.setLayout(new BorderLayout(4, 4)); functionTypeList = new QuickList(functionTypeListModel);
// Function
JPanel functionPane = new JPanel(new BorderLayout(4, 4));
this.add(functionPane, BorderLayout.WEST);
functionTypeList = new QuickList(functionTypeListModel);
UIScrollPane functionTypeScrollPane = new UIScrollPane(functionTypeList); UIScrollPane functionTypeScrollPane = new UIScrollPane(functionTypeList);
functionTypeScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); functionTypeScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
functionTypeScrollPane.setPreferredSize(new Dimension(140, 200)); functionTypeScrollPane.setPreferredSize(new Dimension(140, 200));
functionPane.add(this.createNamePane(Inter.getLocText("FormulaD-Function_category") + ":", functionTypeScrollPane), BorderLayout.WEST); functionPane.add(this.createNamePane(Inter.getLocText("FormulaD-Function_category") + ":", functionTypeScrollPane), BorderLayout.WEST);
functionTypeList.setCellRenderer(new DefaultListCellRenderer() { initTypeListCellRenderer();
initGroupTypeModel();
initTypeListSelectionListener();
}
private void initTypeListCellRenderer(){
functionTypeList.setCellRenderer(
new DefaultListCellRenderer() {
@Override @Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
@ -573,48 +585,44 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
return this; return this;
} }
}); });
}
functionTypeListModel.addElement(FunctionConstants.COMMON);
for (int i = 0; i < FunctionConstants.EMBFUNCTIONS.length; i++) { private void initTypeListSelectionListener(){
functionTypeListModel.addElement(FunctionConstants.EMBFUNCTIONS[i]); functionTypeList.addListSelectionListener(new ListSelectionListener() {
}
functionTypeListModel.addElement(FunctionConstants.ALL);
functionTypeListModel.addElement(FunctionConstants.CUSTOM);
functionTypeListModel.addElement(FunctionConstants.PLUGIN);
functionTypeList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) { public void valueChanged(ListSelectionEvent evt) {
Object selectedValue = ((JList) evt.getSource()).getSelectedValue(); Object selectedValue = ((JList) evt.getSource()).getSelectedValue();
if (!(selectedValue instanceof FunctionGroup)) { if (!(selectedValue instanceof FunctionGroup)) {
return; return;
} }
NameAndDescription[] nads = ((FunctionGroup) selectedValue).getDescriptions(); NameAndDescription[] nads = ((FunctionGroup) selectedValue).getDescriptions();
functionNameModel = (DefaultListModel) functionNameList.getModel(); functionNameModel = (DefaultListModel) functionNameList.getModel();
functionNameModel.clear(); functionNameModel.clear();
for (NameAndDescription nad : nads) { for (NameAndDescription nad : nads) {
functionNameModel.addElement(nad); functionNameModel.addElement(nad);
} }
if (functionNameModel.size() > 0) { if (functionNameModel.size() > 0) {
functionNameList.setSelectedIndex(0); functionNameList.setSelectedIndex(0);
functionNameList.ensureIndexIsVisible(0); functionNameList.ensureIndexIsVisible(0);
} }
} }
}); });
}
functionNameList = new JList(new DefaultListModel());
UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList); private void initGroupTypeModel(){
functionNameScrollPane.setPreferredSize(new Dimension(140, 200)); functionTypeListModel.addElement(FunctionConstants.COMMON);
functionPane.add( for (int i = 0; i < FunctionConstants.EMBFUNCTIONS.length; i++) {
this.createNamePane(Inter.getLocText("FormulaD-Function_name") + ":", functionNameScrollPane), functionTypeListModel.addElement(FunctionConstants.EMBFUNCTIONS[i]);
BorderLayout.CENTER); }
functionNameScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); functionTypeListModel.addElement(FunctionConstants.ALL);
functionTypeListModel.addElement(FunctionConstants.CUSTOM);
functionNameList.setCellRenderer(new DefaultListCellRenderer() { functionTypeListModel.addElement(FunctionConstants.PLUGIN);
//hugh: 从函数分组插件中添加分组
FunctionConstants.addFunctionGroupFromPlugins(functionTypeListModel);
}
private void initFunctionNameListCellRenderer(){
functionNameList.setCellRenderer(new DefaultListCellRenderer() {
@Override @Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
@ -625,8 +633,10 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
return this; return this;
} }
}); });
}
functionNameList.addListSelectionListener(new ListSelectionListener() {
private void initFunctionNameListSelectionListener(){
functionNameList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) { public void valueChanged(ListSelectionEvent evt) {
Object selectedValue = functionNameList.getSelectedValue(); Object selectedValue = functionNameList.getSelectedValue();
@ -640,11 +650,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
descriptionTextArea.moveCaretPosition(0); descriptionTextArea.moveCaretPosition(0);
} }
}); });
}
functionNameList.addMouseListener(new MouseAdapter() {
private void initFunctionNameListMouseListener(){
functionNameList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) { public void mouseClicked(MouseEvent evt) {
if (evt.getClickCount() >= 2) { if (evt.getClickCount() >= 2) {
Object selectedValue = functionNameList.getSelectedValue(); Object selectedValue = functionNameList.getSelectedValue();
if (!(selectedValue instanceof NameAndDescription)) { if (!(selectedValue instanceof NameAndDescription)) {
@ -654,7 +664,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
applyText(insert); applyText(insert);
} }
if (SwingUtilities.isRightMouseButton(evt)) { if (SwingUtilities.isRightMouseButton(evt)) {
JPopupMenu popupMenu = new JPopupMenu(); JPopupMenu popupMenu = new JPopupMenu();
LookDetailAction lookDetailAction = new LookDetailAction(); LookDetailAction lookDetailAction = new LookDetailAction();
@ -665,24 +674,28 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
} }
} }
}); });
}
// vairable.
variablesTree = new JTree(); private void initFunctionNameList(JPanel functionPane){
UIScrollPane variablesTreePane = new UIScrollPane(variablesTree); functionNameList = new JList(new DefaultListModel());
variablesTreePane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList);
this.add(this.createNamePane( functionNameScrollPane.setPreferredSize(new Dimension(140, 200));
Inter.getLocText("Variables") + ":", variablesTreePane), BorderLayout.CENTER); functionPane.add(
variablesTree.setRootVisible(false); this.createNamePane(Inter.getLocText("FormulaD-Function_name") + ":", functionNameScrollPane),
variablesTree.setShowsRootHandles(true); BorderLayout.CENTER);
variablesTree.addMouseListener(applyTextMouseListener); functionNameScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
variablesTree.setCellRenderer(applyTreeCellRenderer); initFunctionNameListCellRenderer();
initFunctionNameListSelectionListener();
// Description initFunctionNameListMouseListener();
}
private void initDescriptionTextArea(){
// Description
descriptionTextArea = new UITextArea(16, 27); descriptionTextArea = new UITextArea(16, 27);
UIScrollPane desScrollPane = new UIScrollPane(descriptionTextArea); UIScrollPane desScrollPane = new UIScrollPane(descriptionTextArea);
desScrollPane.setBorder(null); desScrollPane.setBorder(null);
this.add(this.createNamePane(Inter.getLocText("Formula_Description") + ":", desScrollPane), BorderLayout.EAST); this.add(this.createNamePane(Inter.getLocText("FR-Designer_FormulaPane_Formula_Description") + ":", desScrollPane), BorderLayout.EAST);
descriptionTextArea.setBackground(new Color(255, 255, 225)); descriptionTextArea.setBackground(new Color(255, 255, 225));
descriptionTextArea.setLineWrap(true); descriptionTextArea.setLineWrap(true);
descriptionTextArea.setWrapStyleWord(true); descriptionTextArea.setWrapStyleWord(true);
@ -696,19 +709,41 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
} }
}); });
variablesTree.addTreeSelectionListener(new TreeSelectionListener() { }
public void valueChanged(TreeSelectionEvent e) { private StringBuilder getText(TextUserObject selectedValue,String path) throws IOException{
Object selectedValue = ((DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent()).getUserObject(); Reader desReader;
StringBuilder desBuf = new StringBuilder();
InputStream desInputStream = BaseUtils.readResource(path+ ((TextUserObject) selectedValue).displayText+".txt");
if (desInputStream == null) {
String description = "";
desReader = new StringReader(description);
} else {
desReader = new InputStreamReader(desInputStream);
}
BufferedReader reader = new BufferedReader(desReader);
String lineText;
while ((lineText = reader.readLine()) != null) {
if (desBuf.length() > 0) {
desBuf.append('\n');
}
desBuf.append(lineText);
}
reader.close();
desReader.close();
return desBuf;
}
private void initVariablesTreeSelectionListener(){
variablesTree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
Object selectedValue = ((DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent()).getUserObject();
if (selectedValue == null) { if (selectedValue == null) {
return; return;
} }
StringBuilder desBuf = new StringBuilder(); StringBuilder desBuf = new StringBuilder();
try { try {
Reader desReader;
String path; String path;
Locale locale = FRContext.getLocale(); Locale locale = FRContext.getLocale();
if (locale.equals(Locale.CHINA)) { if (locale.equals(Locale.CHINA)) {
path = "/com/fr/design/insert/formula/variable/cn/"; path = "/com/fr/design/insert/formula/variable/cn/";
@ -716,43 +751,42 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
path = "/com/fr/design/insert/formula/variable/en/"; path = "/com/fr/design/insert/formula/variable/en/";
} }
if (selectedValue instanceof TextUserObject) { if (selectedValue instanceof TextUserObject) {
desBuf = getText((TextUserObject)selectedValue,path);
InputStream desInputStream = BaseUtils.readResource(path
+ ((TextUserObject) selectedValue).displayText
+ ".txt");
if (desInputStream == null) {
String description = "";
desReader = new StringReader(description);
} else {
desReader = new InputStreamReader(
desInputStream);
}
BufferedReader reader = new BufferedReader(
desReader);
String lineText;
while ((lineText = reader.readLine()) != null) {
if (desBuf.length() > 0) {
desBuf.append('\n');
}
desBuf.append(lineText);
}
reader.close();
desReader.close();
} }
} catch (IOException exp) { } catch (IOException exp) {
FRContext.getLogger().error(exp.getMessage(), exp); FRContext.getLogger().error(exp.getMessage(), exp);
} }
descriptionTextArea.setText(desBuf.toString()); descriptionTextArea.setText(desBuf.toString());
descriptionTextArea.moveCaretPosition(0); descriptionTextArea.moveCaretPosition(0);
} }
}); });
}
private void initVariablesTree(){
// vairable.
variablesTree = new JTree();
UIScrollPane variablesTreePane = new UIScrollPane(variablesTree);
variablesTreePane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
this.add(this.createNamePane(
Inter.getLocText("FR-Designer_FormulaPane_Variables") + ":", variablesTreePane), BorderLayout.CENTER);
variablesTree.setRootVisible(false);
variablesTree.setShowsRootHandles(true);
variablesTree.addMouseListener(applyTextMouseListener);
variablesTree.setCellRenderer(applyTreeCellRenderer);
initDescriptionTextArea();
initVariablesTreeSelectionListener();
}
private void initComponents() {
this.setLayout(new BorderLayout(4, 4));
// Function
JPanel functionPane = new JPanel(new BorderLayout(4, 4));
this.add(functionPane, BorderLayout.WEST);
initFunctionTypeList(functionPane);
initFunctionNameList(functionPane);
initVariablesTree();
// 选择: // 选择:
functionTypeList.setSelectedIndex(0); functionTypeList.setSelectedIndex(0);
} }
@ -763,7 +797,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
private class LookDetailAction extends UpdateAction { private class LookDetailAction extends UpdateAction {
public LookDetailAction() { public LookDetailAction() {
this.setName(Inter.getLocText("Function_Detail")); this.setName(Inter.getLocText("FR-Designer_FormulaPane_Function_Detail"));
this.setMnemonic('L'); this.setMnemonic('L');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
} }
@ -778,7 +812,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
BasicPane basicPane = new BasicPane() { BasicPane basicPane = new BasicPane() {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("Function_Detail"); return Inter.getLocText("FR-Designer_FormulaPane_Function_Detail");
} }
}; };
basicPane.setLayout(FRGUIPaneFactory.createBorderLayout()); basicPane.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -855,7 +889,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
return this; return this;
} }
}; };
public void populate(VariableResolver variableResolver) { public void populate(VariableResolver variableResolver) {
// varibale tree. // varibale tree.
DefaultTreeModel variableModel = (DefaultTreeModel) variablesTree.getModel(); DefaultTreeModel variableModel = (DefaultTreeModel) variablesTree.getModel();
@ -868,53 +902,29 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
DefaultMutableTreeNode bindCellNode = new DefaultMutableTreeNode(new TextUserObject("$$$")); DefaultMutableTreeNode bindCellNode = new DefaultMutableTreeNode(new TextUserObject("$$$"));
rootNode.add(bindCellNode); rootNode.add(bindCellNode);
} }
{ rootNode.add(new TextFolderUserObject(Inter.getLocText("FormulaD-Data_Fields"),
MutableTreeNode tableTreeNode = new TextFolderUserObject( BaseUtils.readIcon("/com/fr/design/images/dialog/table.png"),
Inter.getLocText("FormulaD-Data_Fields"), variableResolver.resolveColumnNames()).createMutableTreeNode());
BaseUtils.readIcon("/com/fr/design/images/dialog/table.png"),
variableResolver.resolveColumnNames()).createMutableTreeNode(); // Set cutReport Variable
rootNode.add(new TextFolderUserObject(Inter.getLocText("FR-Designer_FormulaPane_Variables"),
rootNode.add(tableTreeNode); BaseUtils.readIcon("/com/fr/design/images/dialog/variable.png"),
} variableResolver.resolveCurReportVariables()).createMutableTreeNode());
{ rootNode.add(new TextFolderUserObject(Inter.getLocText(new String[]{"Datasource-Datasource", "Parameter"}),
// Set cutReport Variable BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"),
rootNode.add(new TextFolderUserObject( variableResolver.resolveTableDataParameterVariables()).createMutableTreeNode());
Inter.getLocText("Variables"),
BaseUtils.readIcon("/com/fr/design/images/dialog/variable.png"), rootNode.add(new TextFolderUserObject(Inter.getLocText("ParameterD-Report_Parameter"),
variableResolver.resolveCurReportVariables()).createMutableTreeNode()); BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif"),
} variableResolver.resolveReportParameterVariables()).createMutableTreeNode());
rootNode.add(new TextFolderUserObject(Inter.getLocText("M_Server-Global_Parameters"),
{ BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"),
rootNode.add(new TextFolderUserObject( variableResolver.resolveGlobalParameterVariables()).createMutableTreeNode());
Inter.getLocText(new String[]{"Datasource-Datasource", "Parameter"}),
BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"),
variableResolver.resolveTableDataParameterVariables()).createMutableTreeNode());
}
{
MutableTreeNode reportParameterTreeNode = new TextFolderUserObject(
Inter.getLocText("ParameterD-Report_Parameter"),
BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif"),
variableResolver.resolveReportParameterVariables()).createMutableTreeNode();
rootNode.add(reportParameterTreeNode);
}
{
MutableTreeNode globalParameterTreeNode = new TextFolderUserObject(
Inter.getLocText("M_Server-Global_Parameters"),
BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"),
variableResolver.resolveGlobalParameterVariables()).createMutableTreeNode();
rootNode.add(globalParameterTreeNode);
}
variableModel.reload(); variableModel.reload();
// Expand // Expand
for (int row = 0; row < this.variablesTree.getRowCount(); row++) { for (int row = 0; row < this.variablesTree.getRowCount(); row++) {
this.variablesTree.expandRow(row); this.variablesTree.expandRow(row);
@ -993,6 +1003,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
buffer.append("|"); buffer.append("|");
buffer.append("\n"); buffer.append("\n");
} }
System.out.println(buffer.toString()); FRContext.getLogger().debug(buffer.toString());
} }
} }

51
designer_base/src/com/fr/design/formula/FunctionConstants.java

@ -11,6 +11,8 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.fun.FunctionDefContainer;
import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.Function; import com.fr.stable.script.Function;
import com.fr.stable.script.FunctionDef; import com.fr.stable.script.FunctionDef;
@ -23,8 +25,49 @@ import java.util.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import javax.swing.DefaultListModel;
public abstract class FunctionConstants { public abstract class FunctionConstants {
/**
* 将函数分组插件中的函数添加到对应的列表中
* @param listModel
*/
public static void addFunctionGroupFromPlugins(DefaultListModel listModel){
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
for(Mutable container : containers){
listModel.addElement(createFunctionGroup((FunctionDefContainer)container));
}
}
}
/**
* 创建一个新的分组
* @param container
* @return
*/
private static FunctionGroup createFunctionGroup(final FunctionDefContainer container){
return new FunctionGroup() {
@Override
public String getGroupName() {
return container.getGroupName();
}
@Override
public NameAndDescription[] getDescriptions() {
FunctionDef[] fs = container.getFunctionDefs();
int count = fs.length;
FunctionDefNAD[] nads = new FunctionDefNAD[count];
for (int i = 0; i < count; i ++) {
nads[i] = new FunctionDefNAD(fs[i]);
}
return nads;
}
};
}
public static FunctionGroup PLUGIN = new FunctionGroup() { public static FunctionGroup PLUGIN = new FunctionGroup() {
@Override @Override
public String getGroupName() { public String getGroupName() {
@ -96,7 +139,13 @@ public abstract class FunctionConstants {
} }
Collections.addAll(all, PLUGIN.getDescriptions()); Collections.addAll(all, PLUGIN.getDescriptions());
Collections.addAll(all, CUSTOM.getDescriptions()); Collections.addAll(all, CUSTOM.getDescriptions());
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
for(Mutable container : containers){
Collections.addAll(all,createFunctionGroup(((FunctionDefContainer)container)).getDescriptions());
}
}
java.util.Collections.sort(all, NameAndDescriptionComparator); java.util.Collections.sort(all, NameAndDescriptionComparator);
return all.toArray(new NameAndDescription[all.size()]); return all.toArray(new NameAndDescription[all.size()]);

2
designer_base/src/com/fr/design/formula/FunctionDefNAD.java

@ -6,7 +6,7 @@ import com.fr.stable.StringUtils;
public class FunctionDefNAD extends AbstractNameAndDescription { public class FunctionDefNAD extends AbstractNameAndDescription {
private FunctionDef def; private FunctionDef def;
FunctionDefNAD(FunctionDef def) { public FunctionDefNAD(FunctionDef def) {
this.def = def; this.def = def;
} }

3
designer_base/src/com/fr/design/fun/ConnectionProvider.java

@ -12,7 +12,8 @@ public interface ConnectionProvider extends Mutable {
public static final String XML_TAG = "ConnectionProvider"; public static final String XML_TAG = "ConnectionProvider";
int CURRENT_LEVEL = 1; // 2016-12-14 1 -> 2 , 增加connection.feature方法导致不兼容.
int CURRENT_LEVEL = 2;
/** /**
* 数据连接弹出菜单的名字 * 数据连接弹出菜单的名字

41
designer_base/src/com/fr/design/fun/ExtraButtonToolBarProvider.java

@ -0,0 +1,41 @@
package com.fr.design.fun;
import com.fr.form.ui.Widget;
import com.fr.stable.fun.mark.Mutable;
import javax.swing.*;
import java.awt.*;
/**
* 报表工具栏设计器端拓展用于配置按钮额外属性
* Created by harry on 2016-12-23.
*/
public interface ExtraButtonToolBarProvider extends Mutable {
String XML_TAG = "ExtraButtonToolBarProvider";
int CURRENT_LEVEL = 1;
/**
* 用于添加属性面板
*
* @param centerPane 面板
*/
void updateCenterPane(JPanel centerPane);
/**
* 更新界面
*
* @param widget 控件
* @param card 卡片布局
* @param centerPane 面板
*/
void populate(Widget widget, CardLayout card, JPanel centerPane);
/**
* 保存界面设置
*
* @param widget 控件
*/
void update(Widget widget);
}

19
designer_base/src/com/fr/design/fun/impl/AbstractExtraButtonToolBarProvider.java

@ -0,0 +1,19 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.ExtraButtonToolBarProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* Created by harry on 2016-12-23.
*/
@API(level = ExtraButtonToolBarProvider.CURRENT_LEVEL)
public abstract class AbstractExtraButtonToolBarProvider extends AbstractProvider implements ExtraButtonToolBarProvider {
public int currentAPILevel() {
return ExtraButtonToolBarProvider.CURRENT_LEVEL;
}
public String mark4Provider() {
return getClass().getName();
}
}

8
designer_base/src/com/fr/design/gui/icombobox/UIComboBox.java

@ -160,6 +160,14 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser
uiObserverListener = listener; uiObserverListener = listener;
} }
public void removeChangeListener(){
uiObserverListener = null;
}
public UIObserverListener getUiObserverListener(){
return uiObserverListener;
}
/** /**
* @return * @return
*/ */

7
designer_base/src/com/fr/design/style/color/ColorPicker.java

@ -7,11 +7,14 @@ package com.fr.design.style.color;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Ellipse2D; import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.swing.*;
/** /**
* 取色框 * 取色框

1
designer_base/src/com/fr/design/style/color/ColorSelectBox.java

@ -63,6 +63,7 @@ public class ColorSelectBox extends AbstractSelectBox<Color> implements UIObserv
fireDisplayComponent(ColorBackground.getInstance(color)); fireDisplayComponent(ColorBackground.getInstance(color));
} }
}); });
colorPane.setColor(color);
return colorPane; return colorPane;
} }

2
designer_chart/src/com/fr/design/chart/report/GisMapTableDataContentPane.java

@ -245,7 +245,7 @@ public class GisMapTableDataContentPane extends FurtherBasicBeanPane<GisMapTable
if(addressNameBox.getSelectedItem() != null){ if(addressNameBox.getSelectedItem() != null){
String adName = Utils.objectToString(addressNameBox.getSelectedItem()); String adName = Utils.objectToString(addressNameBox.getSelectedItem());
if(ArrayUtils.contains(ChartConstants.NONE_KEYS, adName)) { if(ArrayUtils.contains(ChartConstants.getNoneKeys(), adName)) {
definition.setAddressName(StringUtils.EMPTY); definition.setAddressName(StringUtils.EMPTY);
} else { } else {
definition.setAddressName(adName); definition.setAddressName(adName);

2
designer_chart/src/com/fr/design/chart/report/GisMapTableDataContentPane4Chart.java

@ -226,7 +226,7 @@ public class GisMapTableDataContentPane4Chart extends FurtherBasicBeanPane<GisMa
if (addressNameBox.getSelectedItem() != null) { if (addressNameBox.getSelectedItem() != null) {
String adName = Utils.objectToString(addressNameBox.getSelectedItem()); String adName = Utils.objectToString(addressNameBox.getSelectedItem());
if (ArrayUtils.contains(ChartConstants.NONE_KEYS, adName)) { if (ArrayUtils.contains(ChartConstants.getNoneKeys(), adName)) {
definition.setAddressName(StringUtils.EMPTY); definition.setAddressName(StringUtils.EMPTY);
} else { } else {
definition.setAddressName(adName); definition.setAddressName(adName);

4
designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java

@ -188,7 +188,7 @@ public class MapCubeLayerPane extends BasicBeanPane<String>{
while(names.hasNext()) { while(names.hasNext()) {
Object name = names.next(); Object name = names.next();
String layName = editingAttr.getLayerTo(Utils.objectToString(name)); String layName = editingAttr.getLayerTo(Utils.objectToString(name));
if(ArrayUtils.contains(ChartConstants.NONE_KEYS, layName)) {// kunsnat: 考虑切换设计器语言. if(ArrayUtils.contains(ChartConstants.getNoneKeys(), layName)) {// kunsnat: 考虑切换设计器语言.
layName = StringUtils.EMPTY; layName = StringUtils.EMPTY;
} }
list.add(new Object[]{name, layName}); list.add(new Object[]{name, layName});
@ -230,7 +230,7 @@ public class MapCubeLayerPane extends BasicBeanPane<String>{
while(names.hasNext()) { while(names.hasNext()) {
Object name = names.next(); Object name = names.next();
String layName = editingAttr.getLayerTo(Utils.objectToString(name)); String layName = editingAttr.getLayerTo(Utils.objectToString(name));
if(ArrayUtils.contains(ChartConstants.NONE_KEYS, layName)) {// kunsnat: 考虑切换设计器语言. if(ArrayUtils.contains(ChartConstants.getNoneKeys(), layName)) {// kunsnat: 考虑切换设计器语言.
layName = StringUtils.EMPTY; layName = StringUtils.EMPTY;
} }
list.add(new Object[]{name, layName}); list.add(new Object[]{name, layName});

7
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

@ -425,6 +425,8 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private void deleteAButton() { private void deleteAButton() {
//先重构属性,在重构面板,否则面板在重构过程中,会重新将属性中的切换图表加到indexList中,导致面板无法删除 //先重构属性,在重构面板,否则面板在重构过程中,会重新将属性中的切换图表加到indexList中,导致面板无法删除
//记录改变前的plotID
String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChart().getPlot().getPlotID();
if (editingCollection != null) { if (editingCollection != null) {
int count = editingCollection.getChartCount(); int count = editingCollection.getChartCount();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@ -447,6 +449,11 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
checkoutChange(); checkoutChange();
relayoutPane(); relayoutPane();
//重构面板
if (parent != null ){
parent.reLayoutEditPane(lastPlotID, editingCollection);
}
} }
private void relayoutPane() { private void relayoutPane() {

11
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -206,6 +206,8 @@ public class ChartTypePane extends AbstractChartAttrPane{
} }
//第一步就是重构cardNames //第一步就是重构cardNames
cardNames = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(chartID); cardNames = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(chartID);
//下拉框重构开始。为了防止重构是触发update
((FlexibleComboBox)jcb).setItemEvenType(ItemEventType.REACTOR);
//重构下拉框选项 //重构下拉框选项
reactorComboBox(); reactorComboBox();
//重新选择选中的下拉项 //重新选择选中的下拉项
@ -213,6 +215,8 @@ public class ChartTypePane extends AbstractChartAttrPane{
String plotID = chart.getPlot().getPlotID(); String plotID = chart.getPlot().getPlotID();
Object item = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(chartID, plotID); Object item = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(chartID, plotID);
jcb.setSelectedItem(item); jcb.setSelectedItem(item);
//下拉框重构结束
((FlexibleComboBox)jcb).setItemEvenType(ItemEventType.DEFAULT);
//重新选中 //重新选中
checkPlotPane(); checkPlotPane();
} }
@ -223,13 +227,10 @@ public class ChartTypePane extends AbstractChartAttrPane{
} }
private void reactorComboBox() { private void reactorComboBox() {
FlexibleComboBox fcb = (FlexibleComboBox)jcb; jcb.removeAllItems();
fcb.setItemEvenType(ItemEventType.REACTOR);
fcb.removeAllItems();
for (int i = 0; i < this.cardNames.length; i++) { for (int i = 0; i < this.cardNames.length; i++) {
fcb.addItem(cardNames[i]); jcb.addItem(cardNames[i]);
} }
fcb.setItemEvenType(ItemEventType.DEFAULT);
} }
@Override @Override

2
designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/BubblePlotTableDataContentPane.java

@ -137,7 +137,7 @@ public class BubblePlotTableDataContentPane extends AbstractTableDataContentPane
Object resultY = yCombox.getSelectedItem(); Object resultY = yCombox.getSelectedItem();
Object resultSize = bubbleSize.getSelectedItem(); Object resultSize = bubbleSize.getSelectedItem();
if(resultName == null || ArrayUtils.contains(ChartConstants.NONE_KEYS, resultName)) { if(resultName == null || ArrayUtils.contains(ChartConstants.getNoneKeys(), resultName)) {
definition.setSeriesName(StringUtils.EMPTY); definition.setSeriesName(StringUtils.EMPTY);
} else { } else {
definition.setSeriesName(resultName.toString()); definition.setSeriesName(resultName.toString());

2
designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java

@ -113,7 +113,7 @@ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPa
} }
Object categoryName = categoryCombox.getSelectedItem(); Object categoryName = categoryCombox.getSelectedItem();
if(ArrayUtils.contains(ChartConstants.NONE_KEYS, categoryName)) { if(ArrayUtils.contains(ChartConstants.getNoneKeys(), categoryName)) {
dataDefinition.setCategoryName(StringUtils.EMPTY); dataDefinition.setCategoryName(StringUtils.EMPTY);
} else { } else {
dataDefinition.setCategoryName(categoryName == null ? null : categoryName.toString()); dataDefinition.setCategoryName(categoryName == null ? null : categoryName.toString());

2
designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/StockPlotTableDataContentPane.java

@ -160,7 +160,7 @@ public class StockPlotTableDataContentPane extends AbstractTableDataContentPane
openLabel.setText(stockLabel.getOpenLabel()); openLabel.setText(stockLabel.getOpenLabel());
highLabel.setText(stockLabel.getHighLabel()); highLabel.setText(stockLabel.getHighLabel());
lowLabel.setText(stockLabel.getLowLabel()); lowLabel.setText(stockLabel.getLowLabel());
closeLabel.setText(stockLabel.getLowLabel()); closeLabel.setText(stockLabel.getCloseLabel());
combineCustomEditValue(axisBox, stock.getCateTime()); combineCustomEditValue(axisBox, stock.getCateTime());
combineCustomEditValue(volumeBox, stock.getVolumnString()); combineCustomEditValue(volumeBox, stock.getVolumnString());

2
designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/XYScatterPlotTableDataContentPane.java

@ -107,7 +107,7 @@ public class XYScatterPlotTableDataContentPane extends AbstractTableDataContentP
Object resultX = xCombox.getSelectedItem(); Object resultX = xCombox.getSelectedItem();
Object resultY = yCombox.getSelectedItem(); Object resultY = yCombox.getSelectedItem();
if(resultName == null || ArrayUtils.contains(ChartConstants.NONE_KEYS, resultName)) { if(resultName == null || ArrayUtils.contains(ChartConstants.getNoneKeys(), resultName)) {
definition.setSeriesName(StringUtils.EMPTY); definition.setSeriesName(StringUtils.EMPTY);
} else { } else {
definition.setSeriesName(resultName.toString()); definition.setSeriesName(resultName.toString());

16
designer_chart/src/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java

@ -11,6 +11,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.chart.base.TextAttr; import com.fr.chart.base.TextAttr;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
@ -71,6 +72,8 @@ public class ChartTextAttrPane extends BasicPane {
} }
public void populate(FRFont frFont) { public void populate(FRFont frFont) {
UIObserverListener listener = fontNameComboBox == null ? null : fontNameComboBox.getUiObserverListener();
removeAllComboBoxListener();
if (frFont == null) { if (frFont == null) {
return; return;
} }
@ -83,6 +86,19 @@ public class ChartTextAttrPane extends BasicPane {
if (fontColor != null) { if (fontColor != null) {
fontColor.setColor(frFont.getForeground()); fontColor.setColor(frFont.getForeground());
} }
//更新结束后,注册监听器
registerAllComboBoxListener(listener);
}
private void removeAllComboBoxListener() {
fontNameComboBox.removeChangeListener();
fontSizeComboBox.removeChangeListener();
}
private void registerAllComboBoxListener(UIObserverListener listener) {
fontNameComboBox.registerChangeListener(listener);
fontSizeComboBox.registerChangeListener(listener);
} }
/** /**

311
designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java

@ -18,7 +18,6 @@ import com.fr.form.ui.*;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.OperatingSystem;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -27,14 +26,14 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
public class FormParaWidgetPane extends JPanel{ public class FormParaWidgetPane extends JPanel {
private static FormParaWidgetPane THIS; private static FormParaWidgetPane THIS;
private List<WidgetOption> predifinedwidgeList = new ArrayList<WidgetOption>(); private List<WidgetOption> predifinedwidgeList = new ArrayList<WidgetOption>();
private JWindow chartTypeWindow; private JWindow chartTypeWindow;
private JWindow widgetTypeWindow; private JWindow widgetTypeWindow;
private WidgetOption[] widgetOptions = null; private WidgetOption[] widgetOptions = null;
private WidgetOption[] chartOptions = null; private WidgetOption[] chartOptions = null;
private WidgetOption[] layoutOptions = null; private WidgetOption[] layoutOptions = null;
private int widgetButtonWidth = 22; private int widgetButtonWidth = 22;
private int widgetButtonHeight = 20; private int widgetButtonHeight = 20;
@ -46,49 +45,49 @@ public class FormParaWidgetPane extends JPanel{
//预定义控件最多显示20行 //预定义控件最多显示20行
private int preWidgetShowMaxRow = 20; private int preWidgetShowMaxRow = 20;
//显示8个图表组件 //显示8个图表组件
private static final int commonChartNum = 8; private static final int COMMON_CHAR_NUM = 8;
//显示10个普通控件 //显示10个普通控件
private int commonWidgetNum = 10; private int commonWidgetNum = 10;
private JSeparator jSeparatorPara; private JSeparator jSeparatorPara;
private JSeparator jSeparatorChart; private JSeparator jSeparatorChart;
private JSeparator jSeparatorLayout; private JSeparator jSeparatorLayout;
private UILabel paraLabel ; private UILabel paraLabel;
private FormDesigner designer; private FormDesigner designer;
public static final FormParaWidgetPane getInstance(FormDesigner designer) { public static final FormParaWidgetPane getInstance(FormDesigner designer) {
if(THIS == null) { if (THIS == null) {
THIS = new FormParaWidgetPane(); THIS = new FormParaWidgetPane();
} }
THIS.designer = designer; THIS.designer = designer;
THIS.setTarget(designer); THIS.setTarget(designer);
return THIS; return THIS;
} }
public FormParaWidgetPane() { public FormParaWidgetPane() {
setLayout(new FlowLayout(FlowLayout.LEFT)); setLayout(new FlowLayout(FlowLayout.LEFT));
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().addComponentListener(new ComponentAdapter() { DesignerContext.getDesignerFrame().getCenterTemplateCardPane().addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
if (FormParaWidgetPane.this.getParent() != null) { if (FormParaWidgetPane.this.getParent() != null) {
JPanel fother = (JPanel)FormParaWidgetPane.this.getParent(); JPanel fother = (JPanel) FormParaWidgetPane.this.getParent();
int delta_wdith = 0; int delta_wdith = 0;
for (int i = 0; i < fother.getComponentCount() - 1; i ++) { for (int i = 0; i < fother.getComponentCount() - 1; i++) {
delta_wdith += fother.getComponent(i).getWidth(); delta_wdith += fother.getComponent(i).getWidth();
} }
if(delta_wdith == 0){ if (delta_wdith == 0) {
return; return;
} }
Dimension d = fother.getSize(); Dimension d = fother.getSize();
setPreferredSize(new Dimension(d.width - delta_wdith, d.height)); setPreferredSize(new Dimension(d.width - delta_wdith, d.height));
LayoutUtils.layoutContainer(fother); LayoutUtils.layoutContainer(fother);
} }
} }
}); });
initFormParaComponent(); initFormParaComponent();
} }
private void initFormParaComponent() { private void initFormParaComponent() {
@ -97,16 +96,16 @@ public class FormParaWidgetPane extends JPanel{
JPanel paraPane = new JPanel(new FlowLayout()); JPanel paraPane = new JPanel(new FlowLayout());
ToolBarButton paraButton = new paraButton(FormWidgetOption.PARAMETERCONTAINER); ToolBarButton paraButton = new paraButton(FormWidgetOption.PARAMETERCONTAINER);
paraPane.add(paraButton); paraPane.add(paraButton);
add(createNormalCombinationPane(paraPane,Inter.getLocText("FR-Designer_Parameter"))); add(createNormalCombinationPane(paraPane, Inter.getLocText("FR-Designer_Parameter")));
jSeparatorPara = createJSeparator(); jSeparatorPara = createJSeparator();
add(jSeparatorPara); add(jSeparatorPara);
JPanel layoutPane = new JPanel(new FlowLayout()); JPanel layoutPane = new JPanel(new FlowLayout());
for(WidgetOption option : loadLayoutOptions()){ for (WidgetOption option : loadLayoutOptions()) {
layoutPane.add(new ToolBarButton(option)); layoutPane.add(new ToolBarButton(option));
} }
layoutPane.add(new ToolBarButton(FormWidgetOption.ELEMENTCASE)); layoutPane.add(new ToolBarButton(FormWidgetOption.ELEMENTCASE));
add(createNormalCombinationPane(layoutPane,Inter.getLocText("FR-Designer_Layout_Block_Blank"))); add(createNormalCombinationPane(layoutPane, Inter.getLocText("FR-Designer_Layout_Block_Blank")));
jSeparatorLayout = createJSeparator(); jSeparatorLayout = createJSeparator();
add(jSeparatorLayout); add(jSeparatorLayout);
@ -114,8 +113,8 @@ public class FormParaWidgetPane extends JPanel{
int totalChartNums = loadChartOptions().length; int totalChartNums = loadChartOptions().length;
if (totalChartNums > 0) { if (totalChartNums > 0) {
JPanel chartTypePane = new JPanel(new FlowLayout()); JPanel chartTypePane = new JPanel(new FlowLayout());
for (int i = 0;i < commonChartNum ;i++) { for (int i = 0; i < COMMON_CHAR_NUM; i++) {
chartTypePane.add( new ToolBarButton(loadChartOptions()[i])); chartTypePane.add(new ToolBarButton(loadChartOptions()[i]));
} }
add(createChartCombinationPane(chartTypePane, Inter.getLocText("FR-Designer-Form-ToolBar_Chart"))); add(createChartCombinationPane(chartTypePane, Inter.getLocText("FR-Designer-Form-ToolBar_Chart")));
jSeparatorChart = createJSeparator(); jSeparatorChart = createJSeparator();
@ -123,115 +122,113 @@ public class FormParaWidgetPane extends JPanel{
} }
JPanel widgetPane = new JPanel(new FlowLayout()); JPanel widgetPane = new JPanel(new FlowLayout());
for (int i = 0;i < commonWidgetNum;i++) { for (int i = 0; i < commonWidgetNum; i++) {
widgetPane.add(new ToolBarButton(loadWidgetOptions()[i])); widgetPane.add(new ToolBarButton(loadWidgetOptions()[i]));
} }
widgetPane.add(createJSeparator(20)); widgetPane.add(createJSeparator(20));
loadPredefinedWidget(); loadPredefinedWidget();
int num = Math.min(predifinedwidgeList.size(),preWidgetShowMaxNum); int num = Math.min(predifinedwidgeList.size(), preWidgetShowMaxNum);
for (int i = 0 ;i < num ;i++) { for (int i = 0; i < num; i++) {
widgetPane.add(new ToolBarButton(predifinedwidgeList.get(i))); widgetPane.add(new ToolBarButton(predifinedwidgeList.get(i)));
} }
add(createWidgetCombinationPane(widgetPane, Inter.getLocText("FR-Designer-Form-ToolBar_Widget"))); add(createWidgetCombinationPane(widgetPane, Inter.getLocText("FR-Designer-Form-ToolBar_Widget")));
add(createJSeparator()); add(createJSeparator());
} }
private void loadPredefinedWidget() { private void loadPredefinedWidget() {
predifinedwidgeList.clear(); predifinedwidgeList.clear();
if(designer != null) { if (designer != null) {
WidgetOption[] designerPre = designer.getDesignerMode().getPredefinedWidgetOptions(); WidgetOption[] designerPre = designer.getDesignerMode().getPredefinedWidgetOptions();
for(int i = 0; i < designerPre.length; i++) { for (int i = 0; i < designerPre.length; i++) {
predifinedwidgeList.add(designerPre[i]); predifinedwidgeList.add(designerPre[i]);
} }
} }
WidgetManagerProvider mgr = WidgetManager.getProviderInstance(); WidgetManagerProvider mgr = WidgetManager.getProviderInstance();
Iterator<String> nameIt = mgr.getWidgetConfigNameIterator(); Iterator<String> nameIt = mgr.getWidgetConfigNameIterator();
while (nameIt.hasNext()) { while (nameIt.hasNext()) {
String name = nameIt.next(); String name = nameIt.next();
WidgetConfig widgetConfig = mgr.getWidgetConfig(name); WidgetConfig widgetConfig = mgr.getWidgetConfig(name);
if (widgetConfig instanceof UserDefinedWidgetConfig) { if (widgetConfig instanceof UserDefinedWidgetConfig) {
Widget widget = ((UserDefinedWidgetConfig) widgetConfig).getWidget(); Widget widget = ((UserDefinedWidgetConfig) widgetConfig).getWidget();
String widgetClassName = widget.getClass().getName(); String widgetClassName = widget.getClass().getName();
if (isButtonWidget(widgetClassName)) { if (isButtonWidget(widgetClassName)) {
// ... // ...
continue; continue;
} }
if (!XCreatorUtils.createXCreator(widget).canEnterIntoParaPane()){ if (!XCreatorUtils.createXCreator(widget).canEnterIntoParaPane()) {
//预定义控件工具栏这儿不显示工具栏中没有的预定义控件 //预定义控件工具栏这儿不显示工具栏中没有的预定义控件
continue; continue;
} }
predifinedwidgeList.add(new UserDefinedWidgetOption(name)); predifinedwidgeList.add(new UserDefinedWidgetOption(name));
} }
} }
} }
private boolean isButtonWidget(String widgetClassName) { private boolean isButtonWidget(String widgetClassName) {
return widgetClassName.endsWith("DeleteRowButton") || widgetClassName.endsWith("AppendRowButton") || widgetClassName.endsWith("TreeNodeToogleButton"); return widgetClassName.endsWith("DeleteRowButton") || widgetClassName.endsWith("AppendRowButton") || widgetClassName.endsWith("TreeNodeToogleButton");
} }
private void setTarget(FormDesigner designer) { private void setTarget(FormDesigner designer) {
if (designer == null) { if (designer == null) {
return; return;
} }
initFormParaComponent(); initFormParaComponent();
} }
private JPanel createNormalCombinationPane(JComponent jComponent,String typeName){ private JPanel createNormalCombinationPane(JComponent jComponent, String typeName) {
JPanel reportPane = new JPanel(new BorderLayout(17,5)); JPanel reportPane = new JPanel(new BorderLayout(17, 5));
reportPane.add(jComponent,BorderLayout.CENTER); reportPane.add(jComponent, BorderLayout.CENTER);
JPanel labelPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new BorderLayout());
UILabel label = new UILabel(typeName,UILabel.CENTER); UILabel label = new UILabel(typeName, UILabel.CENTER);
if(ComparatorUtils.equals(Inter.getLocText("FR-Designer_Parameter"),typeName )){ if (ComparatorUtils.equals(Inter.getLocText("FR-Designer_Parameter"), typeName)) {
paraLabel = label; paraLabel = label;
} }
labelPane.add(label,BorderLayout.CENTER); labelPane.add(label, BorderLayout.CENTER);
reportPane.add(labelPane,BorderLayout.SOUTH); reportPane.add(labelPane, BorderLayout.SOUTH);
reportPane.setPreferredSize(new Dimension((int)reportPane.getPreferredSize().getWidth(),(int)reportPane.getPreferredSize().getHeight())); reportPane.setPreferredSize(new Dimension((int) reportPane.getPreferredSize().getWidth(), (int) reportPane.getPreferredSize().getHeight()));
return reportPane; return reportPane;
} }
private JPanel createChartCombinationPane(JComponent jComponent,String typeName){ private JPanel createChartCombinationPane(JComponent jComponent, String typeName) {
JPanel chartPane = new JPanel(new BorderLayout(17,5)); JPanel chartPane = new JPanel(new BorderLayout(17, 5));
chartPane.add(jComponent, BorderLayout.CENTER); chartPane.add(jComponent, BorderLayout.CENTER);
JPanel labelPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new BorderLayout());
labelPane.add(new UILabel(typeName,UILabel.CENTER),BorderLayout.CENTER); labelPane.add(new UILabel(typeName, UILabel.CENTER), BorderLayout.CENTER);
UIButton chartPopUpButton = createPopUpButton(); UIButton chartPopUpButton = createPopUpButton();
chartPopUpButton.addMouseListener(new MouseAdapter() { chartPopUpButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if(chartTypeWindow == null) { JPanel componentsPara = new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel componentsPara = new JPanel(new FlowLayout(FlowLayout.LEFT)); WidgetOption[] chartOptions = loadChartOptions();
WidgetOption[] chartOptions = loadChartOptions(); for (WidgetOption chartOption : chartOptions) {
for (WidgetOption chartOption : chartOptions) { componentsPara.add(new ToolBarButton(chartOption));
componentsPara.add( new ToolBarButton(chartOption));
}
int x = commonChartNum * (widgetButtonWidth + smallGAP);
int y = (int)Math.ceil(chartOptions.length/((double)commonChartNum)) * (widgetButtonHeight + smallGAP);
componentsPara.setPreferredSize(new Dimension(x,y));
chartTypeWindow = new PopUpWindow(componentsPara, Inter.getLocText("FR-Designer-Form-ToolBar_Chart"));
chartTypeWindow.setLocation((int)jSeparatorLayout.getLocationOnScreen().getX() + 1, (int)jSeparatorLayout.getLocationOnScreen().getY());
chartTypeWindow.setSize(chartTypeWindow.getPreferredSize());
} }
int x = COMMON_CHAR_NUM * (widgetButtonWidth + smallGAP);
int y = (int) Math.ceil(chartOptions.length / ((double) COMMON_CHAR_NUM)) * (widgetButtonHeight + smallGAP);
componentsPara.setPreferredSize(new Dimension(x, y));
chartTypeWindow = new PopUpWindow(componentsPara, Inter.getLocText("FR-Designer-Form-ToolBar_Chart"));
chartTypeWindow.setLocation((int) jSeparatorLayout.getLocationOnScreen().getX() + 1, (int) jSeparatorLayout.getLocationOnScreen().getY());
chartTypeWindow.setSize(chartTypeWindow.getPreferredSize());
chartTypeWindow.setVisible(true); chartTypeWindow.setVisible(true);
} }
}); });
labelPane.add(chartPopUpButton,BorderLayout.EAST); labelPane.add(chartPopUpButton, BorderLayout.EAST);
chartPane.add(labelPane,BorderLayout.SOUTH); chartPane.add(labelPane, BorderLayout.SOUTH);
return chartPane; return chartPane;
} }
private JPanel createWidgetCombinationPane(JComponent jComponent,String typeName){ private JPanel createWidgetCombinationPane(JComponent jComponent, String typeName) {
JPanel widgetPane = new JPanel(new BorderLayout(17,5)); JPanel widgetPane = new JPanel(new BorderLayout(17, 5));
widgetPane.add(jComponent,BorderLayout.CENTER); widgetPane.add(jComponent, BorderLayout.CENTER);
JPanel labelPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new BorderLayout());
labelPane.add(new UILabel(typeName,UILabel.CENTER),BorderLayout.CENTER); labelPane.add(new UILabel(typeName, UILabel.CENTER), BorderLayout.CENTER);
UIButton chartPopUpButton = createPopUpButton(); UIButton chartPopUpButton = createPopUpButton();
chartPopUpButton.addMouseListener(new MouseAdapter() { chartPopUpButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
JPanel widgetPane = new JPanel(new FlowLayout(FlowLayout.LEFT,0,0)); JPanel widgetPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
loadPredefinedWidget(); loadPredefinedWidget();
int rowNum = calculateWidgetWindowRowNum(); int rowNum = calculateWidgetWindowRowNum();
JPanel westPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel westPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
@ -239,27 +236,27 @@ public class FormParaWidgetPane extends JPanel{
westPanel.add(new ToolBarButton(o)); westPanel.add(new ToolBarButton(o));
} }
int x = commonWidgetNum * (widgetButtonWidth + smallGAP); int x = commonWidgetNum * (widgetButtonWidth + smallGAP);
westPanel.setPreferredSize(new Dimension(x,(int)(rowNum * westPanel.getPreferredSize().getHeight()))); westPanel.setPreferredSize(new Dimension(x, (int) (rowNum * westPanel.getPreferredSize().getHeight())));
JPanel eastPane = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel eastPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
for (WidgetOption no : predifinedwidgeList) { for (WidgetOption no : predifinedwidgeList) {
eastPane.add(new ToolBarButton(no)); eastPane.add(new ToolBarButton(no));
} }
int maxWidth = preWidgetShowMaxNum * (widgetButtonWidth + smallGAP); int maxWidth = preWidgetShowMaxNum * (widgetButtonWidth + smallGAP);
int width = predifinedwidgeList.size() >= preWidgetShowMaxNum ? maxWidth:(int)eastPane.getPreferredSize().getWidth(); int width = predifinedwidgeList.size() >= preWidgetShowMaxNum ? maxWidth : (int) eastPane.getPreferredSize().getWidth();
eastPane.setPreferredSize(new Dimension(width,(int)(rowNum*eastPane.getPreferredSize().getHeight()))); eastPane.setPreferredSize(new Dimension(width, (int) (rowNum * eastPane.getPreferredSize().getHeight())));
UIScrollPane eastScrollPane = new UIScrollPane(eastPane); UIScrollPane eastScrollPane = new UIScrollPane(eastPane);
eastScrollPane.setBorder(null); eastScrollPane.setBorder(null);
int maxHeight = preWidgetShowMaxRow * (widgetButtonHeight + smallGAP); int maxHeight = preWidgetShowMaxRow * (widgetButtonHeight + smallGAP);
int height = predifinedwidgeList.size() >= preWidgetShowMaxNum * preWidgetShowMaxRow ? maxHeight : (int)eastPane.getPreferredSize().getHeight(); int height = predifinedwidgeList.size() >= preWidgetShowMaxNum * preWidgetShowMaxRow ? maxHeight : (int) eastPane.getPreferredSize().getHeight();
width = predifinedwidgeList.size() >= preWidgetShowMaxNum * preWidgetShowMaxRow ? (int)eastPane.getPreferredSize().getWidth() + smallGAP + jsparatorWidth : (int)eastPane.getPreferredSize().getWidth(); width = predifinedwidgeList.size() >= preWidgetShowMaxNum * preWidgetShowMaxRow ? (int) eastPane.getPreferredSize().getWidth() + smallGAP + jsparatorWidth : (int) eastPane.getPreferredSize().getWidth();
eastScrollPane.setPreferredSize(new Dimension(width,height)); eastScrollPane.setPreferredSize(new Dimension(width, height));
widgetPane.add(westPanel); widgetPane.add(westPanel);
widgetPane.add(createJSeparator(height)); widgetPane.add(createJSeparator(height));
widgetPane.add(eastScrollPane); widgetPane.add(eastScrollPane);
widgetTypeWindow = new PopUpWindow( widgetPane, Inter.getLocText("FR-Designer-Form-ToolBar_Widget")); widgetTypeWindow = new PopUpWindow(widgetPane, Inter.getLocText("FR-Designer-Form-ToolBar_Widget"));
widgetTypeWindow.setSize(widgetTypeWindow.getPreferredSize()); widgetTypeWindow.setSize(widgetTypeWindow.getPreferredSize());
if (jSeparatorChart != null) { if (jSeparatorChart != null) {
widgetTypeWindow.setLocation((int) jSeparatorChart.getLocationOnScreen().getX() + 1, (int) jSeparatorChart.getLocationOnScreen().getY()); widgetTypeWindow.setLocation((int) jSeparatorChart.getLocationOnScreen().getX() + 1, (int) jSeparatorChart.getLocationOnScreen().getY());
@ -268,59 +265,60 @@ public class FormParaWidgetPane extends JPanel{
} }
}); });
labelPane.add(chartPopUpButton,BorderLayout.EAST); labelPane.add(chartPopUpButton, BorderLayout.EAST);
widgetPane.add(labelPane,BorderLayout.SOUTH); widgetPane.add(labelPane, BorderLayout.SOUTH);
return widgetPane; return widgetPane;
} }
private int calculateWidgetWindowRowNum(){ private int calculateWidgetWindowRowNum() {
//向上取整 //向上取整
int rowNum = (int)Math.ceil((double)predifinedwidgeList.size()/(double)preWidgetShowMaxNum); int rowNum = (int) Math.ceil((double) predifinedwidgeList.size() / (double) preWidgetShowMaxNum);
rowNum = Math.max(rowNum,2); rowNum = Math.max(rowNum, 2);
rowNum = Math.min(rowNum,preWidgetShowMaxRow); rowNum = Math.min(rowNum, preWidgetShowMaxRow);
return rowNum; return rowNum;
} }
private JSeparator createJSeparator(){ private JSeparator createJSeparator() {
JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL ); JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL);
jSeparator.setPreferredSize(new Dimension(jsparatorWidth,jsparatorHeight)); jSeparator.setPreferredSize(new Dimension(jsparatorWidth, jsparatorHeight));
return jSeparator; return jSeparator;
} }
private JSeparator createJSeparator(double height){ private JSeparator createJSeparator(double height) {
JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL ); JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL);
jSeparator.setPreferredSize(new Dimension(jsparatorWidth,(int)height)); jSeparator.setPreferredSize(new Dimension(jsparatorWidth, (int) height));
return jSeparator; return jSeparator;
} }
private UIButton createPopUpButton(){ private UIButton createPopUpButton() {
UIButton popUpButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png")); UIButton popUpButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png"));
popUpButton.set4ToolbarButton(); popUpButton.set4ToolbarButton();
return popUpButton; return popUpButton;
} }
private UIButton createPopDownButton(){ private UIButton createPopDownButton() {
UIButton popUpButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png")); UIButton popUpButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png"));
popUpButton.set4ToolbarButton(); popUpButton.set4ToolbarButton();
return popUpButton; return popUpButton;
} }
private class paraButton extends ToolBarButton{ private class paraButton extends ToolBarButton {
public paraButton(WidgetOption no){ public paraButton(WidgetOption no) {
super(no); super(no);
this.setDisabledIcon(BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter2.png")); this.setDisabledIcon(BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter2.png"));
if(designer != null){ if (designer != null) {
this.setEnabled(designer.getParaComponent() == null); this.setEnabled(designer.getParaComponent() == null);
} }
} }
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
if (designer.getParaComponent() != null){ if (designer.getParaComponent() != null) {
return; return;
} }
designer.addParaComponent(); designer.addParaComponent();
JPanel pane =FormWidgetDetailPane.getInstance(designer); JPanel pane = FormWidgetDetailPane.getInstance(designer);
EastRegionContainerPane.getInstance().replaceDownPane(pane); EastRegionContainerPane.getInstance().replaceDownPane(pane);
this.setEnabled(false); this.setEnabled(false);
@ -334,7 +332,7 @@ public class FormParaWidgetPane extends JPanel{
public void setEnabled(boolean b) { public void setEnabled(boolean b) {
super.setEnabled(b); super.setEnabled(b);
paraLabel.setForeground(b ? Color.BLACK : new Color(198,198,198)); paraLabel.setForeground(b ? Color.BLACK : new Color(198, 198, 198));
} }
} }
@ -347,8 +345,9 @@ public class FormParaWidgetPane extends JPanel{
} }
/** /**
* 响应界面改变事件 * 响应界面改变事件
* @param evt 事件 *
* @param evt 事件
*/ */
public void fireCreatorModified(DesignerEvent evt) { public void fireCreatorModified(DesignerEvent evt) {
button.setEnabled(designer.getParaComponent() == null); button.setEnabled(designer.getParaComponent() == null);
@ -356,14 +355,13 @@ public class FormParaWidgetPane extends JPanel{
} }
private class PopUpWindow extends JWindow { private class PopUpWindow extends JWindow {
private JPanel northPane; private JPanel northPane;
private String typeName; private String typeName;
private int LineWidth = 5; private int LineWidth = 5;
private int BarWidth = 10; private int BarWidth = 10;
public PopUpWindow(JPanel northPane,String typeName){ public PopUpWindow(JPanel northPane, String typeName) {
super(); super();
this.northPane = northPane; this.northPane = northPane;
this.typeName = typeName; this.typeName = typeName;
@ -376,17 +374,14 @@ public class FormParaWidgetPane extends JPanel{
public void eventDispatched(AWTEvent event) { public void eventDispatched(AWTEvent event) {
if (event instanceof MouseEvent) { if (event instanceof MouseEvent) {
MouseEvent mv = (MouseEvent) event; MouseEvent mv = (MouseEvent) event;
Point point = mv.getLocationOnScreen(); if (mv.getClickCount() > 0) {
double endX = PopUpWindow.this.getX() + northPane.getWidth() + LineWidth; Point point = new Point((int) (mv.getLocationOnScreen().getX()), (int) mv.getLocationOnScreen().getY());
double startX = endX - BarWidth; // 直接contains在mac下,点击内部也会消失
double startY = PopUpWindow.this.getY() + northPane.getY(); Dimension d = PopUpWindow.this.getSize();
double endY = startY + northPane.getHeight(); Point p = PopUpWindow.this.getLocation();
boolean dragBar = startX < point.getX() && endX > point.getX() && endY > point.getY(); Rectangle rect = new Rectangle(p, d);
if (!dragBar && mv.getClickCount() > 0 && mv.getID() != MouseEvent.MOUSE_RELEASED) { if (!rect.contains(point)) {
if(!ComparatorUtils.equals(mv.getSource(), PopUpWindow.this)) { PopUpWindow.this.setVisible(false);
if (!OperatingSystem.isMacOS()) {
PopUpWindow.this.setVisible(false);
}
} }
} }
} }
@ -398,9 +393,9 @@ public class FormParaWidgetPane extends JPanel{
JPanel rootPane = new EditorChoosePane(); JPanel rootPane = new EditorChoosePane();
JPanel contentPane = new JPanel(); JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout(17, 0)); contentPane.setLayout(new BorderLayout(17, 0));
contentPane.add(northPane,BorderLayout.CENTER); contentPane.add(northPane, BorderLayout.CENTER);
JPanel labelPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new BorderLayout());
labelPane.add(new UILabel(typeName,UILabel.CENTER),BorderLayout.CENTER); labelPane.add(new UILabel(typeName, UILabel.CENTER), BorderLayout.CENTER);
JButton popUpButton = createPopDownButton(); JButton popUpButton = createPopDownButton();
popUpButton.addMouseListener(new MouseAdapter() { popUpButton.addMouseListener(new MouseAdapter() {
@Override @Override
@ -409,8 +404,8 @@ public class FormParaWidgetPane extends JPanel{
} }
}); });
labelPane.add(popUpButton, BorderLayout.EAST); labelPane.add(popUpButton, BorderLayout.EAST);
contentPane.add(labelPane,BorderLayout.SOUTH); contentPane.add(labelPane, BorderLayout.SOUTH);
rootPane.add(contentPane,BorderLayout.CENTER); rootPane.add(contentPane, BorderLayout.CENTER);
return rootPane; return rootPane;
} }
@ -421,31 +416,31 @@ public class FormParaWidgetPane extends JPanel{
private class EditorChoosePane extends JPanel { private class EditorChoosePane extends JPanel {
public EditorChoosePane() { public EditorChoosePane() {
super(); super();
((FlowLayout)this.getLayout()).setVgap(1); ((FlowLayout) this.getLayout()).setVgap(1);
} }
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
Rectangle r = this.getBounds(); Rectangle r = this.getBounds();
g.setColor(UIConstants.NORMAL_BACKGROUND); g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillRoundRect(r.x, r.y, r.width, r.height,0,0); g.fillRoundRect(r.x, r.y, r.width, r.height, 0, 0);
g.setColor(UIConstants.LINE_COLOR); g.setColor(UIConstants.LINE_COLOR);
g.drawLine(r.x, r.y, r.x, r.y+r.height); g.drawLine(r.x, r.y, r.x, r.y + r.height);
g.drawLine(r.x, r.y+r.height-1, r.x+r.width-1, r.y+r.height-1); g.drawLine(r.x, r.y + r.height - 1, r.x + r.width - 1, r.y + r.height - 1);
g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height-1); g.drawLine(r.x + r.width - 1, r.y, r.x + r.width - 1, r.y + r.height - 1);
} }
} }
private WidgetOption[] loadWidgetOptions() { private WidgetOption[] loadWidgetOptions() {
if (widgetOptions == null) { if (widgetOptions == null) {
widgetOptions = (WidgetOption[])ArrayUtils.addAll(WidgetOption.getFormWidgetIntance(), ExtraDesignClassManager.getInstance().getFormWidgetOptions()); widgetOptions = (WidgetOption[]) ArrayUtils.addAll(WidgetOption.getFormWidgetIntance(), ExtraDesignClassManager.getInstance().getFormWidgetOptions());
} }
return widgetOptions; return widgetOptions;
} }
private WidgetOption[] loadLayoutOptions() { private WidgetOption[] loadLayoutOptions() {
if (layoutOptions == null) { if (layoutOptions == null) {
layoutOptions = (WidgetOption[])ArrayUtils.addAll(FormWidgetOption.getFormLayoutInstance(), ExtraDesignClassManager.getInstance().getFormWidgetContainerOptions()); layoutOptions = (WidgetOption[]) ArrayUtils.addAll(FormWidgetOption.getFormLayoutInstance(), ExtraDesignClassManager.getInstance().getFormWidgetContainerOptions());
} }
return layoutOptions; return layoutOptions;
} }

Loading…
Cancel
Save