Browse Source

Merge branch 'release'

# Conflicts:
#	designer_base/src/com/fr/design/extra/LoginWebBridge.java
master
paul 8 years ago
parent
commit
afd2840522
  1. 1
      designer/src/com/fr/design/actions/file/newReport/NewWorkBookAction.java
  2. 2
      designer/src/com/fr/design/cell/editor/RichTextToolBar.java
  3. 365
      designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java
  4. 1
      designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java
  5. 171
      designer/src/com/fr/design/mainframe/FormatBrushAction.java
  6. 9
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  7. 4
      designer/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java
  8. 33
      designer/src/com/fr/grid/GridKeyListener.java
  9. 24
      designer/src/com/fr/grid/GridMouseAdapter.java
  10. 7
      designer/src/com/fr/quickeditor/ChartQuickEditor.java
  11. 2
      designer_base/build.release.gradle
  12. 4
      designer_base/src/com/fr/design/actions/help/WebDemoAction.java
  13. 4
      designer_base/src/com/fr/design/actions/server/PluginManagerAction.java
  14. 59
      designer_base/src/com/fr/design/data/DesignTableDataManager.java
  15. 200
      designer_base/src/com/fr/design/data/datapane/TreeTableDataDictPane.java
  16. 15
      designer_base/src/com/fr/design/extra/LoginDialog.java
  17. 152
      designer_base/src/com/fr/design/extra/LoginPane.java
  18. 14
      designer_base/src/com/fr/design/extra/LoginWebPane.java
  19. 10
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  20. 4
      designer_base/src/com/fr/design/extra/QQLoginDialog.java
  21. 145
      designer_base/src/com/fr/design/extra/QQLoginPane.java
  22. 131
      designer_base/src/com/fr/design/extra/QQLoginWebBridge.java
  23. 87
      designer_base/src/com/fr/design/extra/QQLoginWebPane.java
  24. 36
      designer_base/src/com/fr/design/extra/ReuseWebBridge.java
  25. 54
      designer_base/src/com/fr/design/extra/ReuseWebPane.java
  26. 58
      designer_base/src/com/fr/design/extra/WebViewDlgHelper.java
  27. 30
      designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java
  28. 186
      designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java
  29. 59
      designer_base/src/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java
  30. 3
      designer_base/src/com/fr/design/gui/chart/BaseChartPropertyPane.java
  31. 18
      designer_base/src/com/fr/design/gui/icombobox/ExtendedComboBox.java
  32. 28
      designer_base/src/com/fr/design/gui/icombobox/UIComboBoxUI.java
  33. 51
      designer_base/src/com/fr/design/gui/ilist/CheckBoxList.java
  34. 11
      designer_base/src/com/fr/design/gui/ilist/UIList.java
  35. 11
      designer_base/src/com/fr/design/gui/itable/TableSorter.java
  36. 49
      designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java
  37. 18
      designer_base/src/com/fr/design/gui/itextfield/UITextField.java
  38. 47
      designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java
  39. 2
      designer_base/src/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaDefaultInputMap.java
  40. 24
      designer_base/src/com/fr/design/gui/syntax/ui/rtextarea/RTADefaultInputMap.java
  41. 9
      designer_base/src/com/fr/design/locale/designer.properties
  42. 8
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  43. 1175
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  44. 9
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  45. 9
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  46. 8
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  47. 8
      designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  48. 246
      designer_base/src/com/fr/design/module/DesignModuleFactory.java
  49. 8
      designer_base/src/com/fr/design/style/color/UsedColorPane.java
  50. 4
      designer_base/src/com/fr/design/utils/DesignUtils.java
  51. 6
      designer_base/src/com/fr/start/BaseDesigner.java
  52. 12
      designer_base/src/com/fr/start/StartServer.java
  53. 2
      designer_chart/build.release.gradle
  54. 188
      designer_chart/src/com/fr/design/ChartEnvManager.java
  55. 42
      designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
  56. 6
      designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java
  57. 10
      designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java
  58. 7
      designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java
  59. 103
      designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java
  60. 69
      designer_chart/src/com/fr/design/chart/report/GisMapDataPane4Chart.java
  61. 341
      designer_chart/src/com/fr/design/chart/report/GisMapTableDataContentPane4Chart.java
  62. 68
      designer_chart/src/com/fr/design/chart/report/MapCubeDataPane4Chart.java
  63. 133
      designer_chart/src/com/fr/design/chart/report/MapDataPane4Chart.java
  64. 113
      designer_chart/src/com/fr/design/chart/report/MapMoreCubeLayerPane4Chart.java
  65. 79
      designer_chart/src/com/fr/design/chart/report/MapSinglePane4Chart.java
  66. 93
      designer_chart/src/com/fr/design/chart/report/MapTableCubeDataPane4Chart.java
  67. 268
      designer_chart/src/com/fr/design/chart/report/MapTableDataSinglePane4Chart.java
  68. 244
      designer_chart/src/com/fr/design/mainframe/AbstractChartDataPane4Chart.java
  69. 111
      designer_chart/src/com/fr/design/mainframe/AbstractMapPlotPane4ToolBar.java
  70. 521
      designer_chart/src/com/fr/design/mainframe/ChartArea.java
  71. 230
      designer_chart/src/com/fr/design/mainframe/ChartDesigner.java
  72. 211
      designer_chart/src/com/fr/design/mainframe/ChartDesignerUI.java
  73. 16
      designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java
  74. 558
      designer_chart/src/com/fr/design/mainframe/ChartToolBarPane.java
  75. 98
      designer_chart/src/com/fr/design/mainframe/DesignerFrame4Chart.java
  76. 203
      designer_chart/src/com/fr/design/mainframe/GisMapPlotPane4ToolBar.java
  77. 339
      designer_chart/src/com/fr/design/mainframe/MapArrayPane.java
  78. 210
      designer_chart/src/com/fr/design/mainframe/MapPlotPane4ToolBar.java
  79. 17
      designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java
  80. 90
      designer_chart/src/com/fr/design/mainframe/PlotToolBarFactory.java
  81. 91
      designer_chart/src/com/fr/design/mainframe/ToolTip4Chart.java
  82. 170
      designer_chart/src/com/fr/design/mainframe/actions/ChartDownLoadWorker.java
  83. 51
      designer_chart/src/com/fr/design/mainframe/actions/ChartFeedBackAciton.java
  84. 25
      designer_chart/src/com/fr/design/mainframe/actions/ChartUpdateAction.java
  85. 56
      designer_chart/src/com/fr/design/mainframe/actions/ChartWebAction.java
  86. 35
      designer_chart/src/com/fr/design/mainframe/actions/OpenChartAction.java
  87. 74
      designer_chart/src/com/fr/design/mainframe/actions/UpdateOnlineAction.java
  88. 69
      designer_chart/src/com/fr/design/mainframe/actions/UpdateVersion.java
  89. 55
      designer_chart/src/com/fr/design/mainframe/chart/ChartDesignEditPane.java
  90. 2
      designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java
  91. 39
      designer_chart/src/com/fr/design/mainframe/chart/ChartsConfigPane.java
  92. 56
      designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java
  93. 238
      designer_chart/src/com/fr/design/mainframe/chart/UpdateOnLinePane.java
  94. 71
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartDesignerDataPane.java
  95. 48
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/ChartDesignDataLoadPane.java
  96. 124
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/EmbbeddDataPane.java
  97. 123
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/ExcelDataPane.java
  98. 117
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/ImportSetChartDataPane.java
  99. 101
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/JSONDataPane.java
  100. 69
      designer_chart/src/com/fr/design/mainframe/chart/gui/type/AreaPlotPane4ToolBar.java
  101. Some files were not shown because too many files have changed in this diff Show More

1
designer/src/com/fr/design/actions/file/newReport/NewWorkBookAction.java

@ -28,6 +28,7 @@ public class NewWorkBookAction extends UpdateAction {
/** /**
* 动作 * 动作
*
* @param e 事件 * @param e 事件
*/ */
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {

2
designer/src/com/fr/design/cell/editor/RichTextToolBar.java

@ -134,7 +134,7 @@ public class RichTextToolBar extends BasicPane{
} }
private void bindListener(){ private void bindListener(){
FRFont defaultFont = RichTextPane.DEFAUL_FONT; FRFont defaultFont = (this.textPane != null) ? FRFont.getInstance(this.textPane.getFont()) : RichTextPane.DEFAUL_FONT;
fontNameComboBox.addItemListener(fontNameItemListener); fontNameComboBox.addItemListener(fontNameItemListener);
fontNameComboBox.setSelectedItem(defaultFont.getFontName()); fontNameComboBox.setSelectedItem(defaultFont.getFontName());
fontSizeComboBox.addItemListener(fontSizeItemListener); fontSizeComboBox.addItemListener(fontSizeItemListener);

365
designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java

File diff suppressed because one or more lines are too long

1
designer/src/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java

@ -782,7 +782,6 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane {
NameJavaScriptGroup linkGroup = cellElement.getNameHyperlinkGroup(); NameJavaScriptGroup linkGroup = cellElement.getNameHyperlinkGroup();
//超链接的个数+单元格可见的操作 //超链接的个数+单元格可见的操作
hyperlinkCheckBoxes = new UICheckBox[linkGroup.size()]; hyperlinkCheckBoxes = new UICheckBox[linkGroup.size()];
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
Component[][] components = new Component[hyperlinkCheckBoxes.length + 1][]; Component[][] components = new Component[hyperlinkCheckBoxes.length + 1][];

171
designer/src/com/fr/design/mainframe/FormatBrushAction.java

File diff suppressed because one or more lines are too long

9
designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java

@ -5,7 +5,6 @@ package com.fr.design.mainframe.bbs;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.*; import com.fr.design.extra.*;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
@ -102,17 +101,13 @@ public class UserInfoLabel extends UILabel {
if (StableUtils.getMajorJavaVersion() == 8) { if (StableUtils.getMajorJavaVersion() == 8) {
PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this); PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
} }
QQLoginWebBridge.getHelper().setUILabelInPlugin(UserInfoLabel.this); LoginWebBridge.getHelper().setUILabelInPlugin(UserInfoLabel.this);
UserLoginContext.addLoginContextListener(new LoginContextListener() { UserLoginContext.addLoginContextListener(new LoginContextListener() {
@Override @Override
public void showLoginContext() { public void showLoginContext() {
LoginPane managerPane = new LoginPane(); WebViewDlgHelper.createLoginDialog();
UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), managerPane);
LoginWebBridge.getHelper().setDialogHandle(qqdlg);
LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this); LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this);
QQLoginWebBridge.getHelper().setLoginlabel();
qqdlg.setVisible(true);
clearLoginInformation(); clearLoginInformation();
updateInfoPane(); updateInfoPane();
} }

4
designer/src/com/fr/design/report/freeze/RepeatAndFreezeSettingPane.java

@ -10,7 +10,7 @@ import javax.swing.event.ChangeListener;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.extra.WebDialog; import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -553,7 +553,7 @@ public class RepeatAndFreezeSettingPane extends BasicPane {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try { try {
//Desktop.getDesktop().browse(new URI(url)); //Desktop.getDesktop().browse(new URI(url));
WebDialog.createPluginDialog(); WebViewDlgHelper.createPluginDialog();
RepeatAndFreezeSettingPane.this.getTopLevelAncestor().setVisible(false); RepeatAndFreezeSettingPane.this.getTopLevelAncestor().setVisible(false);
} catch (Exception exp) { } catch (Exception exp) {

33
designer/src/com/fr/grid/GridKeyListener.java

@ -1,22 +1,22 @@
package com.fr.grid; package com.fr.grid;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.ElementCase;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
/** /**
*
* @editor zhou * @editor zhou
* @since 2012-3-23上午10:55:36 * @since 2012-3-23上午10:55:36
*/ */
public class GridKeyListener implements KeyListener { public class GridKeyListener implements KeyListener {
private static final int DIFF = 48; // 103 - 55 = 48, 小键盘和大键盘数字的差值 48
private static final int DELAY = 32;
private Grid grid; private Grid grid;
// Keypressed last time // Keypressed last time
private long keyPressedLastTime = 0; private long keyPressedLastTime = 0;
@ -30,8 +30,7 @@ public class GridKeyListener implements KeyListener {
if (!grid.isEnabled() || evt.isConsumed()) {// 如果用户在自己的KyeListener里面consume了.就不执行下面的代码了. if (!grid.isEnabled() || evt.isConsumed()) {// 如果用户在自己的KyeListener里面consume了.就不执行下面的代码了.
return; return;
} }
KeyEvent newEvt = KeyEventWork.processKeyEvent(evt); if (KeyEventWork.processKeyEvent(evt) == null) {
if (newEvt == null) {
return; return;
} }
long systemCurrentTime = System.currentTimeMillis(); long systemCurrentTime = System.currentTimeMillis();
@ -46,17 +45,14 @@ public class GridKeyListener implements KeyListener {
keyPressedLastTime = systemCurrentTime; keyPressedLastTime = systemCurrentTime;
} }
dealWithFloatSelection(reportPane, code); dealWithFloatSelection(reportPane, code);
} else { } else {
if (systemCurrentTime - keyPressedLastTime <= 32) { if (systemCurrentTime - keyPressedLastTime <= DELAY) {
return; return;
} else { } else {
keyPressedLastTime = systemCurrentTime; keyPressedLastTime = systemCurrentTime;
} }
dealWithCellSelection(evt, code); dealWithCellSelection(evt, code);
} }
switch (code) { switch (code) {
case KeyEvent.VK_PAGE_UP: {// page up case KeyEvent.VK_PAGE_UP: {// page up
reportPane.getVerticalScrollBar().setValue(Math.max(0, grid.getVerticalValue() - grid.getVerticalExtent())); reportPane.getVerticalScrollBar().setValue(Math.max(0, grid.getVerticalValue() - grid.getVerticalExtent()));
@ -70,14 +66,12 @@ public class GridKeyListener implements KeyListener {
} }
// Richie:Ctrl + A全选单元格 // Richie:Ctrl + A全选单元格
case KeyEvent.VK_A: case KeyEvent.VK_A:
if (code == KeyEvent.VK_A && evt.isControlDown()) { if (evt.isControlDown()) {
reportPane.setSelection(new CellSelection(0, 0, report.getColumnCount(), report.getRowCount())); reportPane.setSelection(new CellSelection(0, 0, report.getColumnCount(), report.getRowCount()));
isNeedRepaint = true;
} }
isNeedRepaint = true; isNeedRepaint = true;
break; break;
} }
if (isNeedRepaint) { if (isNeedRepaint) {
reportPane.repaint(); reportPane.repaint();
} }
@ -91,7 +85,7 @@ public class GridKeyListener implements KeyListener {
*/ */
private void dealWithFloatSelection(ElementCasePane reportPane, int code) { private void dealWithFloatSelection(ElementCasePane reportPane, int code) {
boolean isContentChanged = false; boolean isContentChanged = false;
FloatSelection floatselection = (FloatSelection)reportPane.getSelection(); FloatSelection floatselection = (FloatSelection) reportPane.getSelection();
switch (code) { switch (code) {
case KeyEvent.VK_LEFT: {// left case KeyEvent.VK_LEFT: {// left
@ -187,8 +181,7 @@ public class GridKeyListener implements KeyListener {
if (grid.getCellEditor() != null && grid.editorComponent != null) { if (grid.getCellEditor() != null && grid.editorComponent != null) {
if (IS_NUM_PAD_KEY(code)) { if (IS_NUM_PAD_KEY(code)) {
// 103 - 55 = 48, 小键盘和大键盘数字的差值 48 KeyEvent ke = new KeyEvent(grid, KeyEvent.KEY_PRESSED, 0, 0, code - DIFF, ch);
KeyEvent ke = new KeyEvent(grid, KeyEvent.KEY_PRESSED, 0, 0, code - 48, ch);
grid.editorComponent.dispatchEvent(ke); grid.editorComponent.dispatchEvent(ke);
ke.consume(); ke.consume();
} else { } else {
@ -200,12 +193,14 @@ public class GridKeyListener implements KeyListener {
} }
} }
} }
/** /**
* 小键盘 * 小键盘
*
* @param code * @param code
* @return * @return
*/ */
private static boolean IS_NUM_PAD_KEY(int code){ private static boolean IS_NUM_PAD_KEY(int code) {
return code == KeyEvent.VK_NUMPAD0 || code == KeyEvent.VK_NUMPAD1 return code == KeyEvent.VK_NUMPAD0 || code == KeyEvent.VK_NUMPAD1
|| code == KeyEvent.VK_NUMPAD2 || code == KeyEvent.VK_NUMPAD2
|| code == KeyEvent.VK_NUMPAD3 || code == KeyEvent.VK_NUMPAD3

24
designer/src/com/fr/grid/GridMouseAdapter.java

@ -1,19 +1,5 @@
package com.fr.grid; package com.fr.grid;
import java.awt.Cursor;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
@ -21,6 +7,7 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.present.CellWriteAttrPane; import com.fr.design.present.CellWriteAttrPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
@ -37,7 +24,12 @@ import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.unit.FU; import com.fr.stable.unit.FU;
import com.fr.stable.unit.OLDPIX; import com.fr.stable.unit.OLDPIX;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.HashMap;
import java.util.Map;
/** /**
* the MouseListener of the Grid * the MouseListener of the Grid
@ -165,7 +157,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
* 处理左击事件 * 处理左击事件
*/ */
private void doWithLeftButtonPressed(MouseEvent evt) { private void doWithLeftButtonPressed(MouseEvent evt) {
if(BaseUtils.isAuthorityEditing()){ if (BaseUtils.isAuthorityEditing()) {
grid.setEditable(false); grid.setEditable(false);
} }

7
designer/src/com/fr/quickeditor/ChartQuickEditor.java

@ -1,24 +1,24 @@
package com.fr.quickeditor; package com.fr.quickeditor;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.design.selection.QuickEditor;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
import com.fr.poly.PolyDesigner; import com.fr.poly.PolyDesigner;
import com.fr.poly.creator.ChartBlockEditor; import com.fr.poly.creator.ChartBlockEditor;
import com.fr.report.cell.Elem; import com.fr.report.cell.Elem;
import com.fr.design.selection.QuickEditor;
import java.awt.*; import java.awt.*;
public class ChartQuickEditor extends QuickEditor<TargetComponent>{ public class ChartQuickEditor extends QuickEditor<TargetComponent>{
// kunsnat: editingPropertyPane初始化 避开设计器启动, 在用到的时候再初始化. // kunsnat: editingPropertyPane初始化 避开设计器启动, 在用到的时候再初始化.
//private BaseChartPropertyPane editingPropertyPane = null; //private BaseChartPropertyPane editingPropertyPane = null;
public ChartQuickEditor() { public ChartQuickEditor() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBorder(null); setBorder(null);
@ -45,9 +45,8 @@ public class ChartQuickEditor extends QuickEditor<TargetComponent>{
element = ((ElementCasePane)tc).getEditingElementCase().getFloatElement(fs.getSelectedFloatName()); element = ((ElementCasePane)tc).getEditingElementCase().getFloatElement(fs.getSelectedFloatName());
} }
collection = (BaseChartCollection) element.getValue(); collection = (BaseChartCollection) element.getValue();
add(editingPropertyPane = DesignModuleFactory.getChartPropertyPane(), BorderLayout.CENTER); add(editingPropertyPane = DesignModuleFactory.getChartPropertyPane(), BorderLayout.CENTER);
editingPropertyPane.setSupportCellData(true);
} }
editingPropertyPane.populateChartPropertyPane(collection, tc); editingPropertyPane.populateChartPropertyPane(collection, tc);
} }

2
designer_base/build.release.gradle

@ -53,7 +53,7 @@ def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)
// //
dependencies{ dependencies{
compile fileTree(dir:'../../../finereport-lib-stable/master',include:'**/*.jar') compile fileTree(dir:"../../../finereport-lib-stable/${branchName}",include:'**/*.jar')
compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar") compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar")
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'

4
designer_base/src/com/fr/design/actions/help/WebDemoAction.java

@ -23,7 +23,7 @@ public class WebDemoAction extends UpdateAction {
* @param evt 事件 * @param evt 事件
*/ */
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
StartServer.browerDemoURL(); StartServer.browserDemoURL();
} }
public static final MenuKeySet PRODUCT_DEMO = new MenuKeySet() { public static final MenuKeySet PRODUCT_DEMO = new MenuKeySet() {
@ -34,7 +34,7 @@ public class WebDemoAction extends UpdateAction {
@Override @Override
public String getMenuName() { public String getMenuName() {
return Inter.getLocText("Product_Demo"); return Inter.getLocText("FR-Product_Demo");
} }
@Override @Override

4
designer_base/src/com/fr/design/actions/server/PluginManagerAction.java

@ -2,7 +2,7 @@ package com.fr.design.actions.server;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.extra.WebDialog; import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -25,7 +25,7 @@ public class PluginManagerAction extends UpdateAction {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
WebDialog.createPluginDialog(); WebViewDlgHelper.createPluginDialog();
} }
public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() { public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() {

59
designer_base/src/com/fr/design/data/DesignTableDataManager.java

@ -36,7 +36,6 @@ import java.io.ByteArrayOutputStream;
import java.text.Collator; import java.text.Collator;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* 设计器管理操作数据集的类: * 设计器管理操作数据集的类:
@ -79,7 +78,7 @@ public abstract class DesignTableDataManager {
* 响应数据集改变. * 响应数据集改变.
*/ */
private static void fireDsChanged() { private static void fireDsChanged() {
for(Entry<String, List<ChangeListener>> listenerEntry : dsListenersMap.entrySet()) { for (Entry<String, List<ChangeListener>> listenerEntry : dsListenersMap.entrySet()) {
List<ChangeListener> dsListeners = listenerEntry.getValue(); List<ChangeListener> dsListeners = listenerEntry.getValue();
for (int i = 0; i < dsListeners.size(); i++) { for (int i = 0; i < dsListeners.size(); i++) {
//增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener), //增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener),
@ -91,8 +90,8 @@ public abstract class DesignTableDataManager {
} }
} }
public static void closeTemplate(JTemplate<?,?> template) { public static void closeTemplate(JTemplate<?, ?> template) {
if(template != null) { if (template != null) {
dsListenersMap.remove(template.getFullPathName()); dsListenersMap.remove(template.getFullPathName());
} }
} }
@ -151,7 +150,7 @@ public abstract class DesignTableDataManager {
public static void addDsChangeListener(ChangeListener l) { public static void addDsChangeListener(ChangeListener l) {
JTemplate<?, ?> template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
String key = StringUtils.EMPTY; String key = StringUtils.EMPTY;
if(template != null) { if (template != null) {
key = template.getFullPathName(); key = template.getFullPathName();
} }
List<ChangeListener> dsListeners = dsListenersMap.get(key); List<ChangeListener> dsListeners = dsListenersMap.get(key);
@ -319,7 +318,6 @@ public abstract class DesignTableDataManager {
} }
private static void addStoreProcedureData(java.util.Map<String, TableDataWrapper> resMap) { private static void addStoreProcedureData(java.util.Map<String, TableDataWrapper> resMap) {
DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance(); DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance();
String[] namearray = new String[0]; String[] namearray = new String[0];
@ -381,42 +379,34 @@ public abstract class DesignTableDataManager {
private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception { private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception {
final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar();
Env currentEnv = FRContext.getCurrentEnv(); Env currentEnv = FRContext.getCurrentEnv();
EmbeddedTableData embeddedTableData = null;
ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata); ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata);
boolean isNullParameter = parameters == null || parameters.length == 0; if (ArrayUtils.isEmpty(parameters)) {
ParameterProvider[] tableDataParameter = tabledata.getParameters(Calculator.createCalculator()); parameters = tabledata.getParameters(Calculator.createCalculator());
boolean isOriginalNUllParameter = tableDataParameter == null || tableDataParameter.length == 0;
if (isNullParameter && !isOriginalNUllParameter) {
parameters = tableDataParameter;
}
boolean hasValue = true;
for (ParameterProvider parameter : parameters) {
if (parameter.getValue() == null || ComparatorUtils.equals(StringUtils.EMPTY, parameter.getValue())) {
hasValue = false;
break;
} }
} final Map<String, Object> parameterMap = new HashMap<>();
final Map<String, Object> parameterMap = new HashMap<String, Object>(); if (needInputParams(isMustInputParameters, parameters)) {
if (!hasValue || isMustInputParameters) {
if (parameters != null && parameters.length > 0) {
final ParameterInputPane pPane = new ParameterInputPane(parameters); final ParameterInputPane pPane = new ParameterInputPane(parameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() { public void doOk() {
parameterMap.putAll(pPane.update()); parameterMap.putAll(pPane.update());
} }
}).setVisible(true); }).setVisible(true);
}
} else { } else {
for (int i = 0; i < parameters.length; i++) { for (ParameterProvider parameter : parameters) {
parameterMap.put(parameters[i].getName(), parameters[i].getValue()); parameterMap.put(parameter.getName(), parameter.getValue());
} }
} }
if (loadingBar != null && needLoadingBar) { if (loadingBar != null && needLoadingBar) {
loadingBar.start(); loadingBar.start();
} }
try { try {
embeddedTableData = currentEnv.previewTableData(tabledata, parameterMap, rowCount); for (ParameterProvider parameter : currentEnv.getTableDataParameters(tabledata)) {
if (parameterMap.containsKey(parameter.getName())) {
parameter.setValue(parameterMap.get(parameter.getName()));
}
}
return currentEnv.previewTableData(tabledata, parameterMap, rowCount);
} catch (TableDataException e) { } catch (TableDataException e) {
throw new TableDataException(e.getMessage(), e); throw new TableDataException(e.getMessage(), e);
} finally { } finally {
@ -426,7 +416,18 @@ public abstract class DesignTableDataManager {
} }
}, 100); }, 100);
} }
return embeddedTableData; }
private static boolean needInputParams(boolean mustInputParameters, ParameterProvider[] parameters) {
if (mustInputParameters && ArrayUtils.isNotEmpty(parameters)) {
return true;
}
for (ParameterProvider parameter : parameters) {
if (parameter.getValue() == null || StringUtils.EMPTY.equals(parameter.getValue())) {
return true;
}
}
return false;
} }
/** /**
@ -495,6 +496,4 @@ public abstract class DesignTableDataManager {
public static void setThreadLocal(String value) { public static void setThreadLocal(String value) {
threadLocal.set(value); threadLocal.set(value);
} }
} }

200
designer_base/src/com/fr/design/data/datapane/TreeTableDataDictPane.java

@ -1,21 +1,21 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.design.data.DesignTableDataManager;
import com.fr.data.impl.RecursionTableData; import com.fr.data.impl.RecursionTableData;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.PreviewLabel; import com.fr.design.data.datapane.preview.PreviewLabel;
import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; import com.fr.design.data.datapane.preview.PreviewLabel.Previewable;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.editor.editor.ColumnIndexEditor; import com.fr.design.editor.editor.ColumnIndexEditor;
import com.fr.design.editor.editor.ColumnNameEditor; import com.fr.design.editor.editor.ColumnNameEditor;
import com.fr.design.editor.editor.Editor; import com.fr.design.editor.editor.Editor;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -36,29 +36,30 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
private UIRadioButton lengthMarkRadio; private UIRadioButton lengthMarkRadio;
private ButtonGroup markButtonGroup; private ButtonGroup markButtonGroup;
UILabel originalMarkedFieldLabel1; private UILabel originFieldDependsOnParentLabel;
UILabel parentMarkedFieldLabel1; private UILabel parentFieldLabel;
UILabel treeDataFieldLabel1; private UILabel treeDataFieldLabel1;
UILabel originalMarkedFieldLabel2; private UILabel originFieldDependsOnLengthLabel;
UILabel treeDataFieldLabel2; private UILabel treeDataFieldLabel2;
private ValueEditorPane originalMarkedFieldPane1; private ValueEditorPane originFieldDependsOnParentPane;
private ValueEditorPane parentMarkedFieldPane1; private ValueEditorPane parentFieldPane;
private ValueEditorPane originalMarkedFieldPane2; private ValueEditorPane originFieldDependsOnLengthPane;
public TreeTableDataDictPane(){ public TreeTableDataDictPane() {
this(StringUtils.EMPTY); this(StringUtils.EMPTY);
} }
public TreeTableDataDictPane(String treeName) { public TreeTableDataDictPane(String treeName) {
this.setLayout(new BorderLayout(5,30)); this.setLayout(new BorderLayout(5, 30));
this.setBorder(BorderFactory.createEmptyBorder(20, 20, 0, 0)); this.setBorder(BorderFactory.createEmptyBorder(20, 20, 0, 0));
selectTableDataLabel = new UILabel(Inter.getLocText(new String[]{"Please_Select","Single", "DS-TableData"}) + " :"); selectTableDataLabel = new UILabel(Inter.getLocText(new String[]{"Please_Select", "Single", "DS-TableData"}) + " :");
setTableDataNameComboBox(treeName); setTableDataNameComboBox(treeName);
tableDataNameComboBox.setPreferredSize(new Dimension(180, 20)); tableDataNameComboBox.setPreferredSize(new Dimension(180, 20));
JPanel tableFlowPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); JPanel tableFlowPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane();
tableFlowPane.add(selectTableDataLabel); tableFlowPane.add(selectTableDataLabel);
tableFlowPane.add(tableDataNameComboBox); tableFlowPane.add(tableDataNameComboBox);
tableDataNameComboBox.addItemListener(new ItemListener(){ tableDataNameComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
tdChange(); tdChange();
} }
@ -66,12 +67,12 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
tableFlowPane.add(new PreviewLabel(this)); tableFlowPane.add(new PreviewLabel(this));
this.add(tableFlowPane, BorderLayout.NORTH); this.add(tableFlowPane, BorderLayout.NORTH);
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(centerPane,BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
parentMarkRadio = new UIRadioButton(Inter.getLocText("Build_Tree_Accord_Parent_Marked_Filed"), true); parentMarkRadio = new UIRadioButton(Inter.getLocText("FR-Designer_Build_Tree_Accord_Parent_Marked_Filed"), true);
lengthMarkRadio = new UIRadioButton(Inter.getLocText("Build_Tree_Accord_Marked_Filed_Length")); lengthMarkRadio = new UIRadioButton(Inter.getLocText("FR-Designer_Build_Tree_Accord_Marked_Filed_Length"));
parentMarkRadio.addActionListener(new ActionListener() { parentMarkRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if(isBuildByParentFiled()) { if (isBuildByParentFiled()) {
makeParentEnable(); makeParentEnable();
tdChange(); tdChange();
} }
@ -79,7 +80,7 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
}); });
lengthMarkRadio.addActionListener(new ActionListener() { lengthMarkRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if(!isBuildByParentFiled()) { if (!isBuildByParentFiled()) {
makeLengthEnable(); makeLengthEnable();
tdChange(); tdChange();
} }
@ -89,60 +90,69 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
markButtonGroup.add(parentMarkRadio); markButtonGroup.add(parentMarkRadio);
markButtonGroup.add(lengthMarkRadio); markButtonGroup.add(lengthMarkRadio);
originalMarkedFieldLabel1 = new UILabel(Inter.getLocText("Original_Marked_Filed") + " :", SwingConstants.RIGHT); originFieldDependsOnParentLabel = new UILabel(Inter.getLocText("FR-Designer_Original_Marked_Filed") + " :", SwingConstants.RIGHT);
parentMarkedFieldLabel1 = new UILabel(" " + Inter.getLocText("Parent_Marked_Field") + " :", SwingConstants.RIGHT); parentFieldLabel = new UILabel(" " + Inter.getLocText("FR-Designer_Parent_Marked_Field") + " :", SwingConstants.RIGHT);
treeDataFieldLabel1 = new UILabel(" " + Inter.getLocText("Tree_Data_Field") + " :", SwingConstants.RIGHT); treeDataFieldLabel1 = new UILabel(" " + Inter.getLocText("FR-Designer_Tree_Data_Field") + " :", SwingConstants.RIGHT);
originalMarkedFieldLabel2 = new UILabel(Inter.getLocText("Original_Marked_Filed") + " :", SwingConstants.RIGHT); originFieldDependsOnLengthLabel = new UILabel(Inter.getLocText("FR-Designer_Original_Marked_Filed") + " :", SwingConstants.RIGHT);
treeDataFieldLabel2 = new UILabel(" " + Inter.getLocText("Tree_Data_Field") + " :", SwingConstants.RIGHT); treeDataFieldLabel2 = new UILabel(" " + Inter.getLocText("FR-Designer_Tree_Data_Field") + " :", SwingConstants.RIGHT);
// originalMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] {new OldColumnIndexEditor(Inter.getLocText("Columns"))}); // originFieldDependsOnParentPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[] {new OldColumnIndexEditor(Inter.getLocText("Columns"))});
// parentMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] {new OldColumnIndexEditor(Inter.getLocText("Columns"))}); // parentFieldPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[] {new OldColumnIndexEditor(Inter.getLocText("Columns"))});
// originalMarkedFieldPane2 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] {new OldColumnIndexEditor(Inter.getLocText("Columns"))}); // originFieldDependsOnLengthPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[] {new OldColumnIndexEditor(Inter.getLocText("Columns"))});
originalMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] { new ColumnNameEditor(), new ColumnIndexEditor() }); originFieldDependsOnParentPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
parentMarkedFieldPane1 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] { new ColumnNameEditor(), new ColumnIndexEditor() }); parentFieldPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
originalMarkedFieldPane2 = ValueEditorPaneFactory.createValueEditorPane(new Editor[] { new ColumnNameEditor(), new ColumnIndexEditor() }); originFieldDependsOnLengthPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
makeParentEnable(); makeParentEnable();
JPanel p1 = createCenterFlowZeroGapBorderPane(originalMarkedFieldLabel1, originalMarkedFieldPane1); JPanel p1 = createCenterFlowZeroGapBorderPane(originFieldDependsOnParentLabel, originFieldDependsOnParentPane);
JPanel p2 = createCenterFlowZeroGapBorderPane(parentMarkedFieldLabel1, parentMarkedFieldPane1); JPanel p2 = createCenterFlowZeroGapBorderPane(parentFieldLabel, parentFieldPane);
JPanel border1 = new JPanel(); JPanel border1 = new JPanel();
border1.setLayout(new BorderLayout(0, 10)); border1.setLayout(new BorderLayout(0, 10));
border1.add(p1, BorderLayout.NORTH); border1.add(p1, BorderLayout.NORTH);
border1.add(p2, BorderLayout.CENTER); border1.add(p2, BorderLayout.CENTER);
JPanel p4 = createCenterFlowZeroGapBorderPane(originalMarkedFieldLabel2, originalMarkedFieldPane2); JPanel p4 = createCenterFlowZeroGapBorderPane(originFieldDependsOnLengthLabel, originFieldDependsOnLengthPane);
JPanel border2 = new JPanel(); JPanel border2 = new JPanel();
border2.setLayout(new BorderLayout(0, 20)); border2.setLayout(new BorderLayout(0, 20));
border2.add(p4, BorderLayout.NORTH); border2.add(p4, BorderLayout.NORTH);
JPanel xx = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel xx = FRGUIPaneFactory.createBorderLayout_S_Pane();
xx.add(parentMarkRadio,BorderLayout.NORTH); xx.add(parentMarkRadio, BorderLayout.NORTH);
xx.add(border1,BorderLayout.CENTER); xx.add(border1, BorderLayout.CENTER);
JPanel xxx = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel xxx = FRGUIPaneFactory.createBorderLayout_S_Pane();
xxx.add(lengthMarkRadio,BorderLayout.NORTH); xxx.add(lengthMarkRadio, BorderLayout.NORTH);
xxx.add(border2,BorderLayout.CENTER); xxx.add(border2, BorderLayout.CENTER);
JPanel buildTreePanel = new JPanel(new BorderLayout(5, 30)); JPanel buildTreePanel = new JPanel(new BorderLayout(5, 30));
buildTreePanel.add(xx,BorderLayout.NORTH); buildTreePanel.add(xx, BorderLayout.NORTH);
buildTreePanel.add(xxx,BorderLayout.CENTER); buildTreePanel.add(xxx, BorderLayout.CENTER);
centerPane.add(buildTreePanel, BorderLayout.NORTH); centerPane.add(buildTreePanel, BorderLayout.NORTH);
JPanel previewPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel previewPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
UIButton treeDataPreviewButton = new UIButton(Inter.getLocText("Preview")); UIButton treeDataPreviewButton = new UIButton(Inter.getLocText("FR-Designer_Preview"));
previewPanel.add(treeDataPreviewButton); previewPanel.add(treeDataPreviewButton);
treeDataPreviewButton.addActionListener(new ActionListener() { treeDataPreviewButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
TableDataWrapper tableDataWrappe = tableDataNameComboBox.getSelectedItem(); TableDataWrapper tableDataWrappe = tableDataNameComboBox.getSelectedItem();
if(tableDataWrappe == null) { if (tableDataWrappe == null) {
return; return;
} }
RecursionTableData rtd = new RecursionTableData(); RecursionTableData rtd = new RecursionTableData();
rtd.setOriginalTableDataName(tableDataWrappe.getTableDataName()); rtd.setOriginalTableDataName(tableDataWrappe.getTableDataName());
if(isBuildByParentFiled()) { if (isBuildByParentFiled()) {
rtd.setMarkFields((Integer.parseInt(originalMarkedFieldPane1.update().toString()) - 1) + ""); Object o = parentFieldPane.update();
rtd.setParentmarkFields(Integer.parseInt(parentMarkedFieldPane1.update().toString()) - 1 + ""); rtd.setParentmarkFields((Integer) o - 1 + "");
rtd.setParentmarkFieldName("" + o);
Object o2 = originFieldDependsOnParentPane.update();
rtd.setMarkFields((Integer) o2 - 1 + "");
rtd.setMarkFieldName("" + o2);
} else { } else {
rtd.setMarkFields(Integer.parseInt(originalMarkedFieldPane2.update().toString()) - 1 + ""); Object o = originFieldDependsOnLengthPane.update();
rtd.setParentmarkFields("-1"); if (o == null) {
rtd.setMarkFields("-1");
} else {
rtd.setMarkFields((Integer) o - 1 + "");
rtd.setMarkFieldName("" + o);
}
} }
rtd.setTableDataSource(DesignTableDataManager.getEditingTableDataSource()); rtd.setTableDataSource(DesignTableDataManager.getEditingTableDataSource());
rtd.createDataModel(Calculator.createCalculator()); rtd.createDataModel(Calculator.createCalculator());
@ -153,32 +163,32 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
} }
protected void setTableDataNameComboBox(String treeName) { protected void setTableDataNameComboBox(String treeName) {
tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource(),treeName); tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource(), treeName);
} }
private void tdChange(){ private void tdChange() {
TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem();
if (tableDataWrappe == null) { if (tableDataWrappe == null) {
return; return;
} }
ValueEditorPane[] valueEditorPanes; ValueEditorPane[] valueEditorPanes;
if(isBuildByParentFiled()) { if (isBuildByParentFiled()) {
valueEditorPanes = new ValueEditorPane[]{originalMarkedFieldPane1, parentMarkedFieldPane1}; valueEditorPanes = new ValueEditorPane[]{originFieldDependsOnParentPane, parentFieldPane};
} else { } else {
valueEditorPanes = new ValueEditorPane[]{originalMarkedFieldPane2}; valueEditorPanes = new ValueEditorPane[]{originFieldDependsOnLengthPane};
} }
try { try {
List<String> namelist = tableDataWrappe.calculateColumnNameList(); List<String> namelist = tableDataWrappe.calculateColumnNameList();
int len = namelist.size(); int len = namelist.size();
String[] columnNames = new String[len]; String[] columnNames = new String[len];
namelist.toArray(columnNames); namelist.toArray(columnNames);
for(int i = 0; i < valueEditorPanes.length; i ++) { for (int i = 0; i < valueEditorPanes.length; i++) {
valueEditorPanes[i].setEditors(new Editor[] { new ColumnNameEditor(columnNames), new ColumnIndexEditor(len) }, columnNames[0]); valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(len)}, columnNames[0]);
} }
} catch (Exception e) { } catch (Exception e) {
for(int i = 0; i < valueEditorPanes.length; i ++) { for (int i = 0; i < valueEditorPanes.length; i++) {
valueEditorPanes[i].setEditors(new Editor[] { new ColumnNameEditor(), new ColumnIndexEditor() }, 1); valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}, 1);
} }
} finally { } finally {
valueEditorPanes = null; valueEditorPanes = null;
@ -192,31 +202,31 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
public RecursionTableData update() { public RecursionTableData update() {
RecursionTableData td = new RecursionTableData(); RecursionTableData td = new RecursionTableData();
if(tableDataNameComboBox.getSelectedItem()==null){ if (tableDataNameComboBox.getSelectedItem() == null) {
td.setOriginalTableDataName(null); td.setOriginalTableDataName(null);
}else{ } else {
td.setOriginalTableDataName(tableDataNameComboBox.getSelectedItem().getTableDataName()); td.setOriginalTableDataName(tableDataNameComboBox.getSelectedItem().getTableDataName());
} }
if(isBuildByParentFiled()) { if (isBuildByParentFiled()) {
Object o = parentMarkedFieldPane1.update(StringUtils.EMPTY); Object o = parentFieldPane.update(StringUtils.EMPTY);
if(o instanceof Object[]){ if (o instanceof Object[]) {
Object[] temp = (Object[]) o; Object[] temp = (Object[]) o;
td.setParentmarkFields(((Integer)temp[0]).intValue() - 1 + ""); td.setParentmarkFields((Integer) temp[0] - 1 + "");
td.setParentmarkFieldName((String) temp[1]); td.setParentmarkFieldName((String) temp[1]);
} }
Object o2 = originalMarkedFieldPane1.update(StringUtils.EMPTY); Object o2 = originFieldDependsOnParentPane.update(StringUtils.EMPTY);
if(o2 instanceof Object[]){ if (o2 instanceof Object[]) {
Object[] temp = (Object[]) o2; Object[] temp = (Object[]) o2;
td.setMarkFields(((Integer)temp[0]).intValue() - 1 + ""); td.setMarkFields((Integer) temp[0] - 1 + "");
td.setMarkFieldName((String) temp[1]); td.setMarkFieldName((String) temp[1]);
} }
} else { } else {
Object o = originalMarkedFieldPane2.update(StringUtils.EMPTY); Object o = originFieldDependsOnLengthPane.update(StringUtils.EMPTY);
if(o == null || !(o instanceof Object[])){ if (o == null || !(o instanceof Object[])) {
td.setMarkFields("-1"); td.setMarkFields("-1");
} else { } else {
Object[] temp = (Object[]) o; Object[] temp = (Object[]) o;
td.setMarkFields(((Integer)temp[0]).intValue() - 1 + ""); td.setMarkFields((Integer) temp[0] - 1 + "");
td.setMarkFieldName((String) temp[1]); td.setMarkFieldName((String) temp[1]);
} }
} }
@ -225,30 +235,30 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
} }
public void populate(RecursionTableData rtb) { public void populate(RecursionTableData rtb) {
if(StringUtils.isNotEmpty(rtb.getParentmarkFields())) { if (StringUtils.isNotEmpty(rtb.getParentmarkFields())) {
makeParentEnable(); makeParentEnable();
parentMarkRadio.setSelected(true); parentMarkRadio.setSelected(true);
lengthMarkRadio.setSelected(false); lengthMarkRadio.setSelected(false);
tableDataNameComboBox.setSelectedTableDataByName(rtb.getOriginalTableDataName()); tableDataNameComboBox.setSelectedTableDataByName(rtb.getOriginalTableDataName());
if(StringUtils.isNotEmpty(rtb.getMarkFieldName())){ if (StringUtils.isNotEmpty(rtb.getMarkFieldName())) {
originalMarkedFieldPane1.populate(rtb.getMarkFieldName()); originFieldDependsOnParentPane.populate(rtb.getMarkFieldName());
}else{ } else {
originalMarkedFieldPane1.populate(rtb.getMarkFieldIndex() + 1); originFieldDependsOnParentPane.populate(rtb.getMarkFieldIndex() + 1);
} }
if(StringUtils.isNotEmpty(rtb.getParentmarkFieldName())){ if (StringUtils.isNotEmpty(rtb.getParentmarkFieldName())) {
parentMarkedFieldPane1.populate(rtb.getParentmarkFieldName()); parentFieldPane.populate(rtb.getParentmarkFieldName());
}else{ } else {
parentMarkedFieldPane1.populate(rtb.getParentmarkFieldIndex() + 1); parentFieldPane.populate(rtb.getParentmarkFieldIndex() + 1);
} }
} else { } else {
makeLengthEnable(); makeLengthEnable();
lengthMarkRadio.setSelected(true); lengthMarkRadio.setSelected(true);
parentMarkRadio.setSelected(false); parentMarkRadio.setSelected(false);
tableDataNameComboBox.setSelectedTableDataByName(rtb.getOriginalTableDataName()); tableDataNameComboBox.setSelectedTableDataByName(rtb.getOriginalTableDataName());
if(StringUtils.isNotEmpty(rtb.getMarkFieldName())){ if (StringUtils.isNotEmpty(rtb.getMarkFieldName())) {
originalMarkedFieldPane2.populate(rtb.getMarkFieldName()); originFieldDependsOnLengthPane.populate(rtb.getMarkFieldName());
}else{ } else {
originalMarkedFieldPane2.populate(rtb.getMarkFieldIndex() + 1); originFieldDependsOnLengthPane.populate(rtb.getMarkFieldIndex() + 1);
} }
} }
} }
@ -276,24 +286,24 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
} }
private void makeParentEnable() { private void makeParentEnable() {
originalMarkedFieldPane1.setEnabled(true); originFieldDependsOnParentPane.setEnabled(true);
parentMarkedFieldPane1.setEnabled(true); parentFieldPane.setEnabled(true);
originalMarkedFieldLabel1.setEnabled(true); originFieldDependsOnParentLabel.setEnabled(true);
parentMarkedFieldLabel1.setEnabled(true); parentFieldLabel.setEnabled(true);
treeDataFieldLabel1.setEnabled(true); treeDataFieldLabel1.setEnabled(true);
originalMarkedFieldLabel2.setEnabled(false); originFieldDependsOnLengthLabel.setEnabled(false);
treeDataFieldLabel2.setEnabled(false); treeDataFieldLabel2.setEnabled(false);
originalMarkedFieldPane2.setEnabled(false); originFieldDependsOnLengthPane.setEnabled(false);
} }
private void makeLengthEnable() { private void makeLengthEnable() {
originalMarkedFieldPane1.setEnabled(false); originFieldDependsOnParentPane.setEnabled(false);
parentMarkedFieldPane1.setEnabled(false); parentFieldPane.setEnabled(false);
originalMarkedFieldLabel1.setEnabled(false); originFieldDependsOnParentLabel.setEnabled(false);
parentMarkedFieldLabel1.setEnabled(false); parentFieldLabel.setEnabled(false);
treeDataFieldLabel1.setEnabled(false); treeDataFieldLabel1.setEnabled(false);
originalMarkedFieldLabel2.setEnabled(true); originFieldDependsOnLengthLabel.setEnabled(true);
treeDataFieldLabel2.setEnabled(true); treeDataFieldLabel2.setEnabled(true);
originalMarkedFieldPane2.setEnabled(true); originFieldDependsOnLengthPane.setEnabled(true);
} }
} }

15
designer/src/com/fr/design/mainframe/bbs/LoginDialog.java → designer_base/src/com/fr/design/extra/LoginDialog.java

@ -1,32 +1,29 @@
package com.fr.design.mainframe.bbs; package com.fr.design.extra;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter; import com.fr.stable.StableUtils;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
/** /**
* Created by zhaohehe on 16/7/26. * Created by vito on 2017/5/5.
*/ */
public class LoginDialog extends UIDialog { public class LoginDialog extends UIDialog {
private static final Dimension DEFAULT_SHOP = new Dimension(401, 201); private static final Dimension DEFAULT_SHOP = new Dimension(401, 201);
public LoginDialog(Frame frame, BasicPane pane) { public LoginDialog(Frame frame, Component pane) {
super(frame); super(frame);
if (StableUtils.getMajorJavaVersion() == 8) {
setUndecorated(true); setUndecorated(true);
}
JPanel panel = (JPanel) getContentPane(); JPanel panel = (JPanel) getContentPane();
panel.setLayout(new BorderLayout()); panel.setLayout(new BorderLayout());
add(pane, BorderLayout.CENTER); add(pane, BorderLayout.CENTER);
setSize(DEFAULT_SHOP); setSize(DEFAULT_SHOP);
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
setResizable(false); setResizable(false);
setTitle(Inter.getLocText("FR-Designer-Plugin_Manager"));
} }
@Override @Override

152
designer_base/src/com/fr/design/extra/LoginPane.java

@ -1,152 +0,0 @@
package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.plugin.PluginVerifyException;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.ExecutionException;
/**
* Created by zhaohehe on 16/7/27.
*/
public class LoginPane extends BasicPane {
private static final String LATEST = "latest";
public LoginPane() {
setLayout(new BorderLayout());
if (StableUtils.getMajorJavaVersion() == 8) {
String installHome;
if (StableUtils.isDebug()) {
URL url = ClassLoader.getSystemResource("");
installHome = url.getPath();
addPane(installHome);
} else {
installHome = StableUtils.getInstallHome();
File file = new File(StableUtils.pathJoin(installHome, "scripts"));
if (!file.exists()) {
int rv = JOptionPane.showConfirmDialog(
this,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts();
}
} else {
addPane(installHome);
updateShopScripts();
}
}
} else {
initTraditionalStore();
}
}
private void addPane(String installHome) {
LoginWebPane webPane = new LoginWebPane(new File(installHome).getAbsolutePath(),LoginPane.this);
add(webPane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-Plugin_Manager");
}
private void downloadShopScripts() {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
String id = "shop_scripts";
String username = DesignerEnvManager.getEnvManager().getBBSName();
String password = DesignerEnvManager.getEnvManager().getBBSPassword();
try {
PluginHelper.downloadPluginFile(id, username, password, new Process<Double>() {
@Override
public void process(Double integer) {
}
});
} catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(LoginPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
return false;
}
return true;
}
@Override
protected void done() {
try {
if (get()) {
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome());
int rv = JOptionPane.showOptionDialog(
LoginPane.this,
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")},
null
);
if (rv == JOptionPane.OK_OPTION) {
RestartHelper.restart();
}
}
} catch (InterruptedException | ExecutionException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private void updateShopScripts() {
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION);
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) {
int rv = JOptionPane.showConfirmDialog(
LoginPane.this,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts();
}
}
}
return null;
}
}.execute();
}
private void initTraditionalStore() {
UITabbedPane tabbedPane = new UITabbedPane();
add(tabbedPane, BorderLayout.CENTER);
PluginInstalledPane installedPane = new PluginInstalledPane();
tabbedPane.addTab(installedPane.tabTitle(), installedPane);
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_Update"), new PluginUpdatePane(tabbedPane));
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_All_Plugins"), new PluginFromStorePane(tabbedPane));
}
}

14
designer_base/src/com/fr/design/extra/LoginWebPane.java

@ -17,11 +17,7 @@ import javax.swing.*;
*/ */
public class LoginWebPane extends JFXPanel { public class LoginWebPane extends JFXPanel {
private WebEngine webEngine; public LoginWebPane(final String installHome) {
private LoginPane loginPane;
public LoginWebPane(final String installHome,LoginPane loginPane) {
this.loginPane = loginPane;
Platform.setImplicitExit(false); Platform.setImplicitExit(false);
Platform.runLater(new Runnable() { Platform.runLater(new Runnable() {
@Override @Override
@ -30,7 +26,7 @@ public class LoginWebPane extends JFXPanel {
Scene scene = new Scene(root); Scene scene = new Scene(root);
LoginWebPane.this.setScene(scene); LoginWebPane.this.setScene(scene);
WebView webView = new WebView(); WebView webView = new WebView();
webEngine = webView.getEngine(); WebEngine webEngine = webView.getEngine();
webEngine.load("file:///" + installHome + "/scripts/qqLogin/web/login.html"); webEngine.load("file:///" + installHome + "/scripts/qqLogin/web/login.html");
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() { webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override @Override
@ -39,17 +35,13 @@ public class LoginWebPane extends JFXPanel {
} }
}); });
JSObject obj = (JSObject) webEngine.executeScript("window"); JSObject obj = (JSObject) webEngine.executeScript("window");
obj.setMember("LoginHelper", LoginWebBridge.getHelper(webEngine)); obj.setMember("LoginHelper", LoginWebBridge.getHelper());
webView.setContextMenuEnabled(false);//屏蔽右键 webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView); root.setCenter(webView);
} }
}); });
} }
public void setEngine(WebEngine webEngine) {
this.webEngine = webEngine;
}
private void showAlert(final String message) { private void showAlert(final String message) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override

10
designer_base/src/com/fr/design/extra/PluginWebBridge.java

@ -136,6 +136,7 @@ public class PluginWebBridge {
} }
public void setDialogHandle(UIDialog uiDialog) { public void setDialogHandle(UIDialog uiDialog) {
closeWindow();
this.uiDialog = uiDialog; this.uiDialog = uiDialog;
} }
@ -367,6 +368,7 @@ public class PluginWebBridge {
/** /**
* 获取系统登录的用户名 * 获取系统登录的用户名
*
* @param callback * @param callback
*/ */
public void getLoginInfo(final JSObject callback) { public void getLoginInfo(final JSObject callback) {
@ -381,7 +383,7 @@ public class PluginWebBridge {
try { try {
String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default"); String loginUrl = SiteCenter.getInstance().acquireUrlByKind("bbs.default");
Desktop.getDesktop().browse(new URI(loginUrl)); Desktop.getDesktop().browse(new URI(loginUrl));
}catch (Exception exp) { } catch (Exception exp) {
FRContext.getLogger().info(exp.getMessage()); FRContext.getLogger().info(exp.getMessage());
} }
} }
@ -493,13 +495,14 @@ public class PluginWebBridge {
/*-------------------------------登录部分的处理----------------------------------*/ /*-------------------------------登录部分的处理----------------------------------*/
/** /**
* 注册页面 * 注册页面
*/ */
public void registerHref() { public void registerHref() {
try { try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.register"))); Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.register")));
}catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().info(e.getMessage()); FRContext.getLogger().info(e.getMessage());
} }
} }
@ -510,7 +513,7 @@ public class PluginWebBridge {
public void forgetHref() { public void forgetHref() {
try { try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.reset"))); Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("bbs.reset")));
}catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().info(e.getMessage()); FRContext.getLogger().info(e.getMessage());
} }
} }
@ -521,6 +524,7 @@ public class PluginWebBridge {
/** /**
* 登录操作的回调 * 登录操作的回调
*
* @param username * @param username
* @param password * @param password
* @return * @return

4
designer_base/src/com/fr/design/extra/QQLoginDialog.java

@ -1,6 +1,5 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -14,7 +13,7 @@ import java.awt.*;
public class QQLoginDialog extends UIDialog { public class QQLoginDialog extends UIDialog {
private static final Dimension DEFAULT_SHOP = new Dimension(700, 500); private static final Dimension DEFAULT_SHOP = new Dimension(700, 500);
public QQLoginDialog(Frame frame, BasicPane pane) { public QQLoginDialog(Frame frame, Component pane) {
super(frame); super(frame);
setUndecorated(true); setUndecorated(true);
JPanel panel = (JPanel) getContentPane(); JPanel panel = (JPanel) getContentPane();
@ -24,7 +23,6 @@ public class QQLoginDialog extends UIDialog {
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
setResizable(false); setResizable(false);
setTitle(Inter.getLocText("FR-Designer-Plugin_Manager")); setTitle(Inter.getLocText("FR-Designer-Plugin_Manager"));
} }
@Override @Override

145
designer_base/src/com/fr/design/extra/QQLoginPane.java

@ -1,145 +0,0 @@
package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.BasicPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.plugin.PluginVerifyException;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.ExecutionException;
/**
* Created by zhaohehe on 16/7/28.
*/
public class QQLoginPane extends BasicPane {
private static final String LATEST = "latest";
public QQLoginPane() {
setLayout(new BorderLayout());
if (StableUtils.getMajorJavaVersion() == 8) {
String installHome;
if (StableUtils.isDebug()) {
URL url = ClassLoader.getSystemResource("");
installHome = url.getPath();
addPane(installHome);
} else {
installHome = StableUtils.getInstallHome();
File file = new File(StableUtils.pathJoin(installHome, "scripts"));
if (!file.exists()) {
int rv = JOptionPane.showConfirmDialog(
this,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts();
}
} else {
addPane(installHome);
updateShopScripts();
}
}
} else {
}
}
private void addPane(String installHome) {
QQLoginWebPane webPane = new QQLoginWebPane(new File(installHome).getAbsolutePath());
add(webPane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer-Plugin_Manager");
}
private void downloadShopScripts() {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
String id = "shop_scripts";
String username = DesignerEnvManager.getEnvManager().getBBSName();
String password = DesignerEnvManager.getEnvManager().getBBSPassword();
try {
PluginHelper.downloadPluginFile(id, username, password, new Process<Double>() {
@Override
public void process(Double integer) {
}
});
} catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(QQLoginPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
return false;
}
return true;
}
@Override
protected void done() {
try {
if (get()) {
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome());
int rv = JOptionPane.showOptionDialog(
QQLoginPane.this,
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")},
null
);
if (rv == JOptionPane.OK_OPTION) {
RestartHelper.restart();
}
}
} catch (InterruptedException | ExecutionException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}.execute();
}
private void updateShopScripts() {
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION);
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) {
int rv = JOptionPane.showConfirmDialog(
QQLoginPane.this,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts();
}
}
}
return null;
}
}.execute();
}
}

131
designer_base/src/com/fr/design/extra/QQLoginWebBridge.java

@ -1,131 +0,0 @@
package com.fr.design.extra;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRLogger;
import com.fr.general.SiteCenter;
import javafx.scene.web.WebEngine;
import org.json.JSONObject;
import netscape.javascript.JSObject;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
/**
* Created by lp on 2016/8/10.
*/
public class QQLoginWebBridge {
private static com.fr.design.extra.QQLoginWebBridge helper;
private WebEngine webEngine;
private static String LOGINSUCCESS = "ok";
private static String LOGINFAILED = "failed";
private UIDialog uiDialog;
private UILabel uiLabel;
private UILabel pluginuiLabel;
private UIDialog qqDialog;
private String username;
private QQLoginWebBridge() {
}
public static com.fr.design.extra.QQLoginWebBridge getHelper() {
if (helper != null) {
return helper;
}
synchronized (com.fr.design.extra.QQLoginWebBridge.class) {
if (helper == null) {
helper = new com.fr.design.extra.QQLoginWebBridge();
}
return helper;
}
}
public void setEngine(WebEngine webEngine) {
this.webEngine = webEngine;
}
public void setDialogHandle(UIDialog uiDialog) {
this.uiDialog = uiDialog;
}
public void setQQDialogHandle(UIDialog uiDialog) {
this.qqDialog = uiDialog;
}
public void setUILabel(UILabel uiLabel) {
this.uiLabel = uiLabel;
}
public void setUILabelInPlugin(UILabel uiLabel) {
this.pluginuiLabel = uiLabel;
}
public void setLoginlabel() {
username = DesignerEnvManager.getEnvManager().getBBSName();
}
private static JSObject window;
public static com.fr.design.extra.QQLoginWebBridge getHelper(WebEngine webEngine) {
getHelper();
helper.setEngine(webEngine);
return helper;
}
/**
* 关闭QQ授权窗口
*/
public void closeQQWindow() {
if (qqDialog != null) {
qqDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
qqDialog.setVisible(false);
}
}
/**
* 关闭父窗口
*/
public void closeParentWindow() {
if (uiDialog != null) {
uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
uiDialog.setVisible(false);
}
}
/**
* 获取用户信息
* @param userInfo
*/
public void getLoginInfo(String userInfo) {
JSONObject jo = new JSONObject(userInfo);
String status = jo.get("status").toString();
if (status.equals(LOGINSUCCESS)) {
String username = jo.get("username").toString();
int uid = Integer.parseInt(jo.get("uid") == null ? "" : jo.get("uid").toString());
closeQQWindow();
closeParentWindow();
pluginuiLabel.setText(username);
DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setBbsUid(uid);
DesignerEnvManager.getEnvManager().setInShowBBsName(username);
}else if (status.equals(LOGINFAILED)){
//账号没有QQ授权
closeQQWindow();
try {
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("QQ_binding")));
}catch (Exception exp) {
}
}
}
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) {
if (url.indexOf("qqLogin.html") > 0) {
return;
}
}
}

87
designer_base/src/com/fr/design/extra/QQLoginWebPane.java

@ -40,6 +40,7 @@ import java.awt.*;
public class QQLoginWebPane extends JFXPanel { public class QQLoginWebPane extends JFXPanel {
private WebEngine webEngine; private WebEngine webEngine;
private String url;
private static JSObject window; private static JSObject window;
@ -50,7 +51,9 @@ public class QQLoginWebPane extends JFXPanel {
private static int DEFAULT_CONFIRM_HEIGHT = 160; private static int DEFAULT_CONFIRM_HEIGHT = 160;
private static int DEFAULT_OFFEST = 20; private static int DEFAULT_OFFEST = 20;
class Delta { double x, y; } class Delta {
double x, y;
}
public QQLoginWebPane(final String installHome) { public QQLoginWebPane(final String installHome) {
Platform.setImplicitExit(false); Platform.setImplicitExit(false);
@ -62,7 +65,8 @@ public class QQLoginWebPane extends JFXPanel {
QQLoginWebPane.this.setScene(scene); QQLoginWebPane.this.setScene(scene);
final WebView webView = new WebView(); final WebView webView = new WebView();
webEngine = webView.getEngine(); webEngine = webView.getEngine();
webEngine.load("file:///" + installHome + "/scripts/qqLogin/web/qqLogin.html"); url = "file:///" + installHome + "/scripts/qqLogin/web/qqLogin.html";
webEngine.load(url);
final Stage primaryStage = new Stage(); final Stage primaryStage = new Stage();
@ -76,49 +80,54 @@ public class QQLoginWebPane extends JFXPanel {
primaryStage.setX(0); primaryStage.setX(0);
primaryStage.setY(Screen.getPrimary().getBounds().getHeight() + DEFAULT_PRIMARYSTAGE_HEIGHT); primaryStage.setY(Screen.getPrimary().getBounds().getHeight() + DEFAULT_PRIMARYSTAGE_HEIGHT);
primaryStage.show(); primaryStage.show();
}catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().info(e.getMessage()); FRContext.getLogger().info(e.getMessage());
} }
webEngine.setConfirmHandler(new Callback<String, Boolean>() {
webView.getEngine().setConfirmHandler(new Callback<String, Boolean>() { @Override
@Override public Boolean call(String msg) { public Boolean call(String msg) {
Boolean confirmed = confirm(primaryStage, msg, installHome, webView); Boolean confirmed = confirm(primaryStage, msg, webView);
return confirmed; return confirmed;
} }
}); });
configWebEngine();
webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView);
}
});
}
private void configWebEngine() {
webEngine.locationProperty().addListener(new ChangeListener<String>() { webEngine.locationProperty().addListener(new ChangeListener<String>() {
@Override @Override
public void changed(ObservableValue<? extends String> observable, final String oldValue, String newValue) { public void changed(ObservableValue<? extends String> observable, final String oldValue, String newValue) {
disableLink(webEngine); disableLink(webEngine);
// webView好像默认以手机版显示网页,浏览器里过滤掉这个跳转 // webView好像默认以手机版显示网页,浏览器里过滤掉这个跳转
if (ComparatorUtils.equals(newValue, "file:///" + installHome + "/scripts/qqLogin/web/qqLogin.html") || ComparatorUtils.equals(newValue, SiteCenter.getInstance().acquireUrlByKind("bbs.mobile"))) { if (ComparatorUtils.equals(newValue, url) || ComparatorUtils.equals(newValue, SiteCenter.getInstance().acquireUrlByKind("bbs.mobile"))) {
return; return;
} }
QQLoginWebBridge.getHelper().openUrlAtLocalWebBrowser(webEngine, newValue); LoginWebBridge.getHelper().openUrlAtLocalWebBrowser(webEngine, newValue);
} }
}); });
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() { webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override @Override
public void handle(WebEvent<String> event) { public void handle(WebEvent<String> event) {
showAlert(event.getData()); showAlert(event.getData());
} }
}); });
webEngine.getLoadWorker().stateProperty().addListener( webEngine.getLoadWorker().stateProperty().addListener(
new ChangeListener<Worker.State>() { new ChangeListener<Worker.State>() {
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) { public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
if (newState == Worker.State.SUCCEEDED) { if (newState == Worker.State.SUCCEEDED) {
window = (JSObject) webEngine.executeScript("window"); window = (JSObject) webEngine.executeScript("window");
window.setMember("QQLoginHelper", QQLoginWebBridge.getHelper(webEngine)); window.setMember("QQLoginHelper", LoginWebBridge.getHelper());
} }
} }
} }
); );
webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView);
}
});
} }
private void showAlert(final String message) { private void showAlert(final String message) {
@ -138,7 +147,7 @@ public class QQLoginWebPane extends JFXPanel {
@Override @Override
public void run() { public void run() {
eng.executeScript("location.reload()"); eng.executeScript("location.reload()");
QQLoginWebBridge.getHelper().closeQQWindow(); LoginWebBridge.getHelper().closeQQWindow();
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -146,12 +155,12 @@ public class QQLoginWebPane extends JFXPanel {
} }
} }
private Boolean confirm(final Stage parent, String msg, final String installHome,final WebView webView) { private Boolean confirm(final Stage parent, String msg, final WebView webView) {
final BooleanProperty confirmationResult = new SimpleBooleanProperty(); final BooleanProperty confirmationResult = new SimpleBooleanProperty();
// initialize the confirmation dialog // initialize the confirmation dialog
final Stage dialog = new Stage(StageStyle.UTILITY); final Stage dialog = new Stage(StageStyle.UTILITY);
dialog.setX(Toolkit.getDefaultToolkit().getScreenSize().getWidth()/2 - DEFAULT_CONFIRM_WIDTH / 2 + DEFAULT_OFFEST); dialog.setX(Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - DEFAULT_CONFIRM_WIDTH / 2 + DEFAULT_OFFEST);
dialog.setY(Toolkit.getDefaultToolkit().getScreenSize().getHeight()/2 + DEFAULT_OFFEST); dialog.setY(Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 + DEFAULT_OFFEST);
dialog.setHeight(DEFAULT_CONFIRM_HEIGHT); dialog.setHeight(DEFAULT_CONFIRM_HEIGHT);
dialog.setWidth(DEFAULT_CONFIRM_WIDTH); dialog.setWidth(DEFAULT_CONFIRM_WIDTH);
dialog.setIconified(false); dialog.setIconified(false);
@ -162,7 +171,8 @@ public class QQLoginWebPane extends JFXPanel {
HBoxBuilder.create().styleClass("modal-dialog").children( HBoxBuilder.create().styleClass("modal-dialog").children(
LabelBuilder.create().text(msg).build(), LabelBuilder.create().text(msg).build(),
ButtonBuilder.create().text(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account")).defaultButton(true).onAction(new EventHandler<ActionEvent>() { ButtonBuilder.create().text(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account")).defaultButton(true).onAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) { @Override
public void handle(ActionEvent actionEvent) {
// take action and close the dialog. // take action and close the dialog.
confirmationResult.set(true); confirmationResult.set(true);
webView.getEngine().reload(); webView.getEngine().reload();
@ -170,7 +180,8 @@ public class QQLoginWebPane extends JFXPanel {
} }
}).build(), }).build(),
ButtonBuilder.create().text(Inter.getLocText("FR-Engine_Cancel")).cancelButton(true).onAction(new EventHandler<ActionEvent>() { ButtonBuilder.create().text(Inter.getLocText("FR-Engine_Cancel")).cancelButton(true).onAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) { @Override
public void handle(ActionEvent actionEvent) {
// abort action and close the dialog. // abort action and close the dialog.
confirmationResult.set(false); confirmationResult.set(false);
dialog.close(); dialog.close();
@ -180,35 +191,39 @@ public class QQLoginWebPane extends JFXPanel {
, Color.TRANSPARENT , Color.TRANSPARENT
) )
); );
configDrag(dialog);
// style and show the dialog.
dialog.getScene().getStylesheets().add(getClass().getResource("modal-dialog.css").toExternalForm());
dialog.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
event.consume();
dialog.close();
}
});
dialog.showAndWait();
return confirmationResult.get();
}
private void configDrag(final Stage dialog) {
// allow the dialog to be dragged around. // allow the dialog to be dragged around.
final Node root = dialog.getScene().getRoot(); final Node root = dialog.getScene().getRoot();
final Delta dragDelta = new Delta(); final Delta dragDelta = new Delta();
root.setOnMousePressed(new EventHandler<MouseEvent>() { root.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent mouseEvent) { @Override
public void handle(MouseEvent mouseEvent) {
// record a delta distance for the drag and drop operation. // record a delta distance for the drag and drop operation.
dragDelta.x = dialog.getX() - mouseEvent.getScreenX(); dragDelta.x = dialog.getX() - mouseEvent.getScreenX();
dragDelta.y = dialog.getY() - mouseEvent.getScreenY(); dragDelta.y = dialog.getY() - mouseEvent.getScreenY();
} }
}); });
root.setOnMouseDragged(new EventHandler<MouseEvent>() { root.setOnMouseDragged(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent mouseEvent) { @Override
public void handle(MouseEvent mouseEvent) {
dialog.setX(mouseEvent.getScreenX() + dragDelta.x); dialog.setX(mouseEvent.getScreenX() + dragDelta.x);
dialog.setY(mouseEvent.getScreenY() + dragDelta.y); dialog.setY(mouseEvent.getScreenY() + dragDelta.y);
} }
}); });
// style and show the dialog.
dialog.getScene().getStylesheets().add(getClass().getResource("modal-dialog.css").toExternalForm());
dialog.setOnCloseRequest(new EventHandler<WindowEvent>(){
@Override
public void handle(WindowEvent event){
event.consume();
dialog.close();
}
});
dialog.showAndWait();
return confirmationResult.get();
} }
} }

36
designer_base/src/com/fr/design/extra/ReuseWebBridge.java

@ -1,36 +0,0 @@
package com.fr.design.extra;
import javafx.scene.web.WebEngine;
/**
* Created by vito on 2016/9/28.
*/
public class ReuseWebBridge {
public static ReuseWebBridge helper;
private WebEngine webEngine;
public static ReuseWebBridge getHelper() {
if (helper != null) {
return helper;
}
synchronized (ReuseWebBridge.class) {
if (helper == null) {
helper = new ReuseWebBridge();
}
return helper;
}
}
public static ReuseWebBridge getHelper(WebEngine webEngine) {
getHelper();
helper.setEngine(webEngine);
return helper;
}
private ReuseWebBridge() {
}
public void setEngine(WebEngine webEngine) {
this.webEngine = webEngine;
}
}

54
designer_base/src/com/fr/design/extra/ReuseWebPane.java

@ -1,54 +0,0 @@
package com.fr.design.extra;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;
import netscape.javascript.JSObject;
import javax.swing.*;
/**
* Created by vito on 2016/9/28.
*/
public class ReuseWebPane extends JFXPanel {
private WebEngine webEngine;
public ReuseWebPane(final String mainJs) {
Platform.setImplicitExit(false);
Platform.runLater(new Runnable() {
@Override
public void run() {
BorderPane root = new BorderPane();
Scene scene = new Scene(root);
ReuseWebPane.this.setScene(scene);
WebView webView = new WebView();
webEngine = webView.getEngine();
webEngine.load("file:///" + mainJs);
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> event) {
showAlert(event.getData());
}
});
JSObject obj = (JSObject) webEngine.executeScript("window");
obj.setMember("ReuseHelper", ReuseWebBridge.getHelper(webEngine));
webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView);
}
});
}
private void showAlert(final String message) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(ReuseWebPane.this, message);
}
});
}
}

58
designer_base/src/com/fr/design/extra/WebDialog.java → designer_base/src/com/fr/design/extra/WebViewDlgHelper.java

@ -24,14 +24,14 @@ import java.util.concurrent.ExecutionException;
/** /**
* Created by vito on 2016/9/28. * Created by vito on 2016/9/28.
*/ */
public class WebDialog { public class WebViewDlgHelper {
private static final String LATEST = "latest"; private static final String LATEST = "latest";
private static final String SHOP_SCRIPTS = "shop_scripts"; private static final String SHOP_SCRIPTS = "shop_scripts";
private static final int VERSION_8 = 8; private static final int VERSION_8 = 8;
// 调试时,使用installHome = ClassLoader.getSystemResource("").getPath()代替下面
private static String installHome = StableUtils.getInstallHome(); private static String installHome = StableUtils.getInstallHome();
public static void createPluginDialog() { public static void createPluginDialog() {
UIDialog dlg;
if (StableUtils.getMajorJavaVersion() >= VERSION_8) { if (StableUtils.getMajorJavaVersion() >= VERSION_8) {
String relativePath = "/scripts/store/web/index.html"; String relativePath = "/scripts/store/web/index.html";
String mainJsPath = StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath); String mainJsPath = StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath);
@ -49,10 +49,7 @@ public class WebDialog {
} }
} else { } else {
updateShopScripts(SHOP_SCRIPTS); updateShopScripts(SHOP_SCRIPTS);
BasicPane managerPane = new ShopManagerPane(new PluginWebPane(mainJsPath)); showPluginDlg(mainJsPath);
dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
} }
} else { } else {
BasicPane traditionalStorePane = new BasicPane() { BasicPane traditionalStorePane = new BasicPane() {
@ -63,21 +60,62 @@ public class WebDialog {
}; };
traditionalStorePane.setLayout(new BorderLayout()); traditionalStorePane.setLayout(new BorderLayout());
traditionalStorePane.add(initTraditionalStore(), BorderLayout.CENTER); traditionalStorePane.add(initTraditionalStore(), BorderLayout.CENTER);
dlg = new ShopDialog(DesignerContext.getDesignerFrame(), traditionalStorePane); UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), traditionalStorePane);
dlg.setVisible(true); dlg.setVisible(true);
} }
} }
/** /**
* 以关键词打开设计器商店 * 以关键词打开设计器商店
* <p> *
* // * @param keyword 关键词 * @param keyword 关键词
*/ */
public void createPluginDialog(String keyword) { public static void createPluginDialog(String keyword) {
PluginWebBridge.getHelper().openWithSearch(keyword); PluginWebBridge.getHelper().openWithSearch(keyword);
createPluginDialog(); createPluginDialog();
} }
public static void createLoginDialog() {
if (StableUtils.getMajorJavaVersion() == VERSION_8) {
File file = new File(StableUtils.pathJoin(installHome, "scripts"));
if (!file.exists()) {
int rv = JOptionPane.showConfirmDialog(
null,
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
downloadShopScripts(SHOP_SCRIPTS);
}
} else {
showLoginDlg();
updateShopScripts(SHOP_SCRIPTS);
}
}
}
public static void createQQLoginDialog() {
QQLoginWebPane webPane = new QQLoginWebPane(new File(installHome).getAbsolutePath());
UIDialog qqlog = new QQLoginDialog(DesignerContext.getDesignerFrame(), webPane);
LoginWebBridge.getHelper().setQqDialog(qqlog);
qqlog.setVisible(true);
}
private static void showPluginDlg(String mainJsPath) {
BasicPane managerPane = new ShopManagerPane(new PluginWebPane(mainJsPath));
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true);
}
private static void showLoginDlg() {
LoginWebPane webPane = new LoginWebPane(new File(installHome).getAbsolutePath());
UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), webPane);
LoginWebBridge.getHelper().setDialogHandle(qqdlg);
qqdlg.setVisible(true);
}
private static Component initTraditionalStore() { private static Component initTraditionalStore() {
UITabbedPane tabbedPane = new UITabbedPane(); UITabbedPane tabbedPane = new UITabbedPane();

30
designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java

@ -10,6 +10,7 @@
package com.fr.design.gui.autocomplete; package com.fr.design.gui.autocomplete;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.PopupWindowDecorator; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.PopupWindowDecorator;
import com.fr.general.FRLogger;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.CaretEvent; import javax.swing.event.CaretEvent;
@ -40,6 +41,7 @@ import java.util.List;
class AutoCompletePopupWindow extends JWindow implements CaretListener, class AutoCompletePopupWindow extends JWindow implements CaretListener,
ListSelectionListener, MouseListener { ListSelectionListener, MouseListener {
private final static int DIS = 5;
/** /**
* The parent AutoCompletion instance. * The parent AutoCompletion instance.
*/ */
@ -179,7 +181,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
} else { } else {
doAutocomplete(); doAutocomplete();
} }
} else if (AutoCompletion.getDebug()) { } else if (AutoCompletion.isDebug()) {
Thread.dumpStack(); Thread.dumpStack();
} }
} }
@ -300,8 +302,8 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
*/ */
private void installKeyBindings() { private void installKeyBindings() {
if (AutoCompletion.getDebug()) { if (AutoCompletion.isDebug()) {
System.out.println("PopupWindow: Installing keybindings"); FRLogger.getLogger().debug("PopupWindow: Installing keybindings");
} }
if (escapeKap == null) { // Lazily create actions. if (escapeKap == null) { // Lazily create actions.
@ -313,7 +315,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
ActionMap am = comp.getActionMap(); ActionMap am = comp.getActionMap();
replaceAction(im, am, KeyEvent.VK_ESCAPE, escapeKap, oldEscape); replaceAction(im, am, KeyEvent.VK_ESCAPE, escapeKap, oldEscape);
if (AutoCompletion.getDebug() && oldEscape.action == escapeKap.action) { if (AutoCompletion.isDebug() && oldEscape.action == escapeKap.action) {
Thread.dumpStack(); Thread.dumpStack();
} }
replaceAction(im, am, KeyEvent.VK_UP, upKap, oldUp); replaceAction(im, am, KeyEvent.VK_UP, upKap, oldUp);
@ -371,7 +373,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
*/ */
private void positionDescWindow() { private void positionDescWindow() {
boolean showDescWindow = descWindow != null && ac.getShowDescWindow(); boolean showDescWindow = descWindow != null && ac.isShowDescWindow();
if (!showDescWindow) { if (!showDescWindow) {
return; return;
} }
@ -387,14 +389,14 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
// Try to position to the right first (LTR) // Try to position to the right first (LTR)
int x; int x;
if (ac.getTextComponentOrientation().isLeftToRight()) { if (ac.getTextComponentOrientation().isLeftToRight()) {
x = getX() + getWidth() + 5; x = getX() + getWidth() + DIS;
if (x + descWindow.getWidth() > screenBounds.x + screenBounds.width) { // doesn't fit if (x + descWindow.getWidth() > screenBounds.x + screenBounds.width) { // doesn't fit
x = getX() - 5 - descWindow.getWidth(); x = getX() - DIS - descWindow.getWidth();
} }
} else { // RTL } else { // RTL
x = getX() - 5 - descWindow.getWidth(); x = getX() - DIS - descWindow.getWidth();
if (x < screenBounds.x) { // Doesn't fit if (x < screenBounds.x) { // Doesn't fit
x = getX() + getWidth() + 5; x = getX() + getWidth() + DIS;
} }
} }
@ -604,7 +606,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
Rectangle screenBounds = Util.getScreenBoundsForPoint(r.x, r.y); Rectangle screenBounds = Util.getScreenBoundsForPoint(r.x, r.y);
//Dimension screenSize = getToolkit().getScreenSize(); //Dimension screenSize = getToolkit().getScreenSize();
boolean showDescWindow = descWindow != null && ac.getShowDescWindow(); boolean showDescWindow = descWindow != null && ac.isShowDescWindow();
int totalH = getHeight(); int totalH = getHeight();
if (showDescWindow) { if (showDescWindow) {
totalH = Math.max(totalH, descWindow.getHeight()); totalH = Math.max(totalH, descWindow.getHeight());
@ -655,7 +657,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
installKeyBindings(); installKeyBindings();
lastLine = ac.getLineOfCaret(); lastLine = ac.getLineOfCaret();
selectFirstItem(); selectFirstItem();
if (descWindow == null && ac.getShowDescWindow()) { if (descWindow == null && ac.isShowDescWindow()) {
descWindow = createDescriptionWindow(); descWindow = createDescriptionWindow();
positionDescWindow(); positionDescWindow();
} }
@ -693,7 +695,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
// because of the way child JWindows' visibility is handled - in // because of the way child JWindows' visibility is handled - in
// some ways it's dependent on the parent, in other ways it's not. // some ways it's dependent on the parent, in other ways it's not.
if (descWindow != null) { if (descWindow != null) {
descWindow.setVisible(visible && ac.getShowDescWindow()); descWindow.setVisible(visible && ac.isShowDescWindow());
} }
} }
@ -708,8 +710,8 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
*/ */
private void uninstallKeyBindings() { private void uninstallKeyBindings() {
if (AutoCompletion.getDebug()) { if (AutoCompletion.isDebug()) {
System.out.println("PopupWindow: Removing keybindings"); FRLogger.getLogger().debug("PopupWindow: Removing keybindings");
} }
JTextComponent comp = ac.getTextComponent(); JTextComponent comp = ac.getTextComponent();

186
designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java

@ -8,26 +8,25 @@
*/ */
package com.fr.design.gui.autocomplete; package com.fr.design.gui.autocomplete;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.CaretEvent; import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener; import javax.swing.event.CaretListener;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.text.*; import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
/** /**
* Adds auto-completion to a text component. Provides a popup window with a * Adds auto-completion to a text component. Provides a popup window with a
* list of auto-complete choices on a given keystroke, such as Crtrl+Space.<p> * list of auto-complete choices on a given keystroke, such as Crtrl+Space.<p>
* * <p>
* Depending on the {@link CompletionProvider} installed, the following * Depending on the {@link CompletionProvider} installed, the following
* auto-completion features may be enabled: * auto-completion features may be enabled:
* * <p>
* <ul> * <ul>
* <li>An auto-complete choices list made visible via e.g. Ctrl+Space</li> * <li>An auto-complete choices list made visible via e.g. Ctrl+Space</li>
* <li>A "description" window displayed alongside the choices list that * <li>A "description" window displayed alongside the choices list that
@ -212,7 +211,7 @@ public class AutoCompletion {
* Stores how to render auto-completion-specific highlights in text * Stores how to render auto-completion-specific highlights in text
* components. * components.
*/ */
private static final AutoCompletionStyleContext styleContext = private static final AutoCompletionStyleContext STYLE_CONTEXT =
new AutoCompletionStyleContext(); new AutoCompletionStyleContext();
/** /**
@ -275,7 +274,7 @@ public class AutoCompletion {
* @return Whether to auto-complete single choices. * @return Whether to auto-complete single choices.
* @see #setAutoCompleteSingleChoices(boolean) * @see #setAutoCompleteSingleChoices(boolean)
*/ */
public boolean getAutoCompleteSingleChoices() { public boolean isAutoCompleteSingleChoices() {
return autoCompleteSingleChoices; return autoCompleteSingleChoices;
} }
@ -295,7 +294,7 @@ public class AutoCompletion {
* *
* @return Whether debug is enabled. * @return Whether debug is enabled.
*/ */
static boolean getDebug() { static boolean isDebug() {
return DEBUG; return DEBUG;
} }
@ -308,8 +307,7 @@ public class AutoCompletion {
*/ */
public static KeyStroke getDefaultTriggerKey() { public static KeyStroke getDefaultTriggerKey() {
// Default to CTRL, even on Mac, since Ctrl+Space activates Spotlight // Default to CTRL, even on Mac, since Ctrl+Space activates Spotlight
int mask = InputEvent.CTRL_MASK; return KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.CTRL_MASK);
return KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, mask);
} }
@ -397,7 +395,7 @@ public class AutoCompletion {
* @return Whether the description window should be shown. * @return Whether the description window should be shown.
* @see #setShowDescWindow(boolean) * @see #setShowDescWindow(boolean)
*/ */
public boolean getShowDescWindow() { public boolean isShowDescWindow() {
return showDescWindow; return showDescWindow;
} }
@ -409,7 +407,7 @@ public class AutoCompletion {
* @return The style context. * @return The style context.
*/ */
public static AutoCompletionStyleContext getStyleContext() { public static AutoCompletionStyleContext getStyleContext() {
return styleContext; return STYLE_CONTEXT;
} }
@ -432,7 +430,7 @@ public class AutoCompletion {
* we are not installed on one. * we are not installed on one.
*/ */
ComponentOrientation getTextComponentOrientation() { ComponentOrientation getTextComponentOrientation() {
return textComponent==null ? null : return textComponent == null ? null :
textComponent.getComponentOrientation(); textComponent.getComponentOrientation();
} }
@ -467,7 +465,7 @@ public class AutoCompletion {
* @return Whether any such windows were visible (and thus hidden). * @return Whether any such windows were visible (and thus hidden).
*/ */
private boolean hideParameterCompletionPopups() { private boolean hideParameterCompletionPopups() {
if (pcc!=null) { if (pcc != null) {
pcc.deactivate(); pcc.deactivate();
pcc = null; pcc = null;
return true; return true;
@ -482,7 +480,7 @@ public class AutoCompletion {
* @return Whether the popup window was visible. * @return Whether the popup window was visible.
*/ */
private boolean hidePopupWindow() { private boolean hidePopupWindow() {
if (popupWindow!=null) { if (popupWindow != null) {
if (popupWindow.isVisible()) { if (popupWindow.isVisible()) {
popupWindow.setVisible(false); popupWindow.setVisible(false);
return true; return true;
@ -539,7 +537,7 @@ public class AutoCompletion {
int dot = caret.getDot(); int dot = caret.getDot();
int len = alreadyEntered.length(); int len = alreadyEntered.length();
int start = dot-len; int start = dot - len;
String replacement = getReplacementText(c, textComp.getDocument(), String replacement = getReplacementText(c, textComp.getDocument(),
start, len); start, len);
@ -549,7 +547,7 @@ public class AutoCompletion {
if (isParameterAssistanceEnabled() && if (isParameterAssistanceEnabled() &&
(c instanceof ParameterizedCompletion)) { (c instanceof ParameterizedCompletion)) {
ParameterizedCompletion pc = (ParameterizedCompletion)c; ParameterizedCompletion pc = (ParameterizedCompletion) c;
startParameterizedCompletionAssistance(pc, typedParamListStartChar); startParameterizedCompletionAssistance(pc, typedParamListStartChar);
} }
@ -566,7 +564,7 @@ public class AutoCompletion {
*/ */
public void install(JTextComponent c) { public void install(JTextComponent c) {
if (textComponent!=null) { if (textComponent != null) {
uninstall(); uninstall();
} }
@ -580,7 +578,7 @@ public class AutoCompletion {
// hoses ctrl+space, shift+space, etc., even though I think it // hoses ctrl+space, shift+space, etc., even though I think it
// shouldn't... // shouldn't...
char start = provider.getParameterListStart(); char start = provider.getParameterListStart();
if (start!=0 && start!=' ') { if (start != 0 && start != ' ') {
InputMap im = c.getInputMap(); InputMap im = c.getInputMap();
ActionMap am = c.getActionMap(); ActionMap am = c.getActionMap();
KeyStroke ks = KeyStroke.getKeyStroke(start); KeyStroke ks = KeyStroke.getKeyStroke(start);
@ -665,7 +663,7 @@ public class AutoCompletion {
* @return Whether the completion popup window is visible. * @return Whether the completion popup window is visible.
*/ */
public boolean isPopupVisible() { public boolean isPopupVisible() {
return popupWindow!=null && popupWindow.isVisible(); return popupWindow != null && popupWindow.isVisible();
} }
@ -680,60 +678,32 @@ public class AutoCompletion {
* @return The current line number of the caret. * @return The current line number of the caret.
*/ */
protected int refreshPopupWindow() { protected int refreshPopupWindow() {
// A return value of null => don't suggest completions // A return value of null => don't suggest completions
String text = provider.getAlreadyEnteredText(textComponent); String text = provider.getAlreadyEnteredText(textComponent);
if (text==null && !isPopupVisible()) { if (text == null && !isPopupVisible()) {
return getLineOfCaret(); return getLineOfCaret();
} }
// If the popup is currently visible, and they type a space (or any // If the popup is currently visible, and they type a space (or any
// character that resets the completion list to "all completions"), // character that resets the completion list to "all completions"),
// the popup window should be hidden instead of being reset to show // the popup window should be hidden instead of being reset to show
// everything. // everything.
int textLen = text==null ? 0 : text.length(); int textLen = text == null ? 0 : text.length();
if (textLen==0) { if (textLen == 0 && isPopupVisible()) {
if (isPopupVisible()) {
hidePopupWindow(); hidePopupWindow();
return getLineOfCaret(); return getLineOfCaret();
} }
} final List<Completion> completions = provider.getCompletions(textComponent);
final List<Completion> completions = provider.
getCompletions(textComponent);
int count = completions.size(); int count = completions.size();
if (needSetPopupWindow(count, textLen)) {
if (count>1 || (count==1 && (isPopupVisible() || textLen==0)) || if (popupWindow == null) {
(count==1 && !getAutoCompleteSingleChoices())) { popupWindow = createAutoCompletePopupWindow();
if (popupWindow==null) {
popupWindow = new AutoCompletePopupWindow(parentWindow, this);
// Completion is usually done for code, which is always done
// LTR, so make completion stuff RTL only if text component is
// also RTL.
popupWindow.applyComponentOrientation(
getTextComponentOrientation());
if (renderer!=null) {
popupWindow.setListCellRenderer(renderer);
}
if (preferredChoicesWindowSize!=null) {
popupWindow.setSize(preferredChoicesWindowSize);
}
if (preferredDescWindowSize!=null) {
popupWindow.setDescriptionWindowSize(
preferredDescWindowSize);
} }
}
popupWindow.setCompletions(completions); popupWindow.setCompletions(completions);
if (!popupWindow.isVisible()) { if (!popupWindow.isVisible()) {
Rectangle r = null; Rectangle r = null;
try { try {
r = textComponent.modelToView(textComponent. r = textComponent.modelToView(textComponent.getCaretPosition());
getCaretPosition());
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
return -1; return -1;
} }
Point p = new Point(r.x, r.y); Point p = new Point(r.x, r.y);
@ -743,25 +713,43 @@ public class AutoCompletion {
popupWindow.setLocationRelativeTo(r); popupWindow.setLocationRelativeTo(r);
popupWindow.setVisible(true); popupWindow.setVisible(true);
} }
} else if (count == 1) { // !isPopupVisible && autoCompleteSingleChoices
}
else if (count==1) { // !isPopupVisible && autoCompleteSingleChoices
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
insertCompletion(completions.get(0)); insertCompletion(completions.get(0));
} }
}); });
} } else {
else {
hidePopupWindow(); hidePopupWindow();
} }
return getLineOfCaret(); return getLineOfCaret();
}
private boolean needSetPopupWindow(int count, int textLen) {
return (count == 1 && (isPopupVisible() || textLen == 0))
|| (count == 1 && !isAutoCompleteSingleChoices())
|| count > 1;
} }
private AutoCompletePopupWindow createAutoCompletePopupWindow() {
AutoCompletePopupWindow popupWindow = new AutoCompletePopupWindow(parentWindow, this);
// Completion is usually done for code, which is always done
// LTR, so make completion stuff RTL only if text component is
// also RTL.
popupWindow.applyComponentOrientation(
getTextComponentOrientation());
if (renderer != null) {
popupWindow.setListCellRenderer(renderer);
}
if (preferredChoicesWindowSize != null) {
popupWindow.setSize(preferredChoicesWindowSize);
}
if (preferredDescWindowSize != null) {
popupWindow.setDescriptionWindowSize(
preferredDescWindowSize);
}
return popupWindow;
}
/** /**
* Sets the delay between when the user types a character and when the * Sets the delay between when the user types a character and when the
@ -786,13 +774,12 @@ public class AutoCompletion {
* @see #setAutoActivationDelay(int) * @see #setAutoActivationDelay(int)
*/ */
public void setAutoActivationEnabled(boolean enabled) { public void setAutoActivationEnabled(boolean enabled) {
if (enabled!=autoActivationEnabled) { if (enabled != autoActivationEnabled) {
autoActivationEnabled = enabled; autoActivationEnabled = enabled;
if (textComponent!=null) { if (textComponent != null) {
if (autoActivationEnabled) { if (autoActivationEnabled) {
autoActivationListener.addTo(textComponent); autoActivationListener.addTo(textComponent);
} } else {
else {
autoActivationListener.removeFrom(textComponent); autoActivationListener.removeFrom(textComponent);
} }
} }
@ -807,7 +794,7 @@ public class AutoCompletion {
* @see #isAutoCompleteEnabled() * @see #isAutoCompleteEnabled()
*/ */
public void setAutoCompleteEnabled(boolean enabled) { public void setAutoCompleteEnabled(boolean enabled) {
if (enabled!=autoCompleteEnabled) { if (enabled != autoCompleteEnabled) {
autoCompleteEnabled = enabled; autoCompleteEnabled = enabled;
hidePopupWindow(); hidePopupWindow();
} }
@ -819,7 +806,7 @@ public class AutoCompletion {
* be automatically inserted, without displaying the popup menu. * be automatically inserted, without displaying the popup menu.
* *
* @param autoComplete Whether to auto-complete single choices. * @param autoComplete Whether to auto-complete single choices.
* @see #getAutoCompleteSingleChoices() * @see #isAutoCompleteSingleChoices()
*/ */
public void setAutoCompleteSingleChoices(boolean autoComplete) { public void setAutoCompleteSingleChoices(boolean autoComplete) {
autoCompleteSingleChoices = autoComplete; autoCompleteSingleChoices = autoComplete;
@ -835,7 +822,7 @@ public class AutoCompletion {
* <code>null</code>. * <code>null</code>.
*/ */
public void setCompletionProvider(CompletionProvider provider) { public void setCompletionProvider(CompletionProvider provider) {
if (provider==null) { if (provider == null) {
throw new IllegalArgumentException("provider cannot be null"); throw new IllegalArgumentException("provider cannot be null");
} }
this.provider = provider; this.provider = provider;
@ -852,7 +839,7 @@ public class AutoCompletion {
*/ */
public void setChoicesWindowSize(int w, int h) { public void setChoicesWindowSize(int w, int h) {
preferredChoicesWindowSize = new Dimension(w, h); preferredChoicesWindowSize = new Dimension(w, h);
if (popupWindow!=null) { if (popupWindow != null) {
popupWindow.setSize(preferredChoicesWindowSize); popupWindow.setSize(preferredChoicesWindowSize);
} }
} }
@ -867,7 +854,7 @@ public class AutoCompletion {
*/ */
public void setDescriptionWindowSize(int w, int h) { public void setDescriptionWindowSize(int w, int h) {
preferredDescWindowSize = new Dimension(w, h); preferredDescWindowSize = new Dimension(w, h);
if (popupWindow!=null) { if (popupWindow != null) {
popupWindow.setDescriptionWindowSize(preferredDescWindowSize); popupWindow.setDescriptionWindowSize(preferredDescWindowSize);
} }
} }
@ -914,7 +901,7 @@ public class AutoCompletion {
*/ */
public void setListCellRenderer(ListCellRenderer renderer) { public void setListCellRenderer(ListCellRenderer renderer) {
this.renderer = renderer; this.renderer = renderer;
if (popupWindow!=null) { if (popupWindow != null) {
popupWindow.setListCellRenderer(renderer); popupWindow.setListCellRenderer(renderer);
hidePopupWindow(); hidePopupWindow();
} }
@ -956,7 +943,7 @@ public class AutoCompletion {
* completion window. * completion window.
* *
* @param show Whether to show the description window. * @param show Whether to show the description window.
* @see #getShowDescWindow() * @see #isShowDescWindow()
*/ */
public void setShowDescWindow(boolean show) { public void setShowDescWindow(boolean show) {
hidePopupWindow(); // Needed to force it to take effect hidePopupWindow(); // Needed to force it to take effect
@ -973,11 +960,11 @@ public class AutoCompletion {
* @see #getTriggerKey() * @see #getTriggerKey()
*/ */
public void setTriggerKey(KeyStroke ks) { public void setTriggerKey(KeyStroke ks) {
if (ks==null) { if (ks == null) {
throw new IllegalArgumentException("trigger key cannot be null"); throw new IllegalArgumentException("trigger key cannot be null");
} }
if (!ks.equals(trigger)) { if (!ks.equals(trigger)) {
if (textComponent!=null) { if (textComponent != null) {
// Put old trigger action back. // Put old trigger action back.
uninstallTriggerKey(); uninstallTriggerKey();
// Grab current action for new trigger and replace it. // Grab current action for new trigger and replace it.
@ -1003,17 +990,16 @@ public class AutoCompletion {
// Don't bother with a tool tip if there are no parameters, but if // Don't bother with a tool tip if there are no parameters, but if
// they typed e.g. the opening '(', make them overtype the ')'. // they typed e.g. the opening '(', make them overtype the ')'.
if (pc.getParamCount()==0 && !(pc instanceof TemplateCompletion)) { if (pc.getParamCount() == 0 && !(pc instanceof TemplateCompletion)) {
CompletionProvider p = pc.getProvider(); CompletionProvider p = pc.getProvider();
char end = p.getParameterListEnd(); // Might be '\0' char end = p.getParameterListEnd(); // Might be '\0'
String text = end=='\0' ? "" : Character.toString(end); String text = end == '\0' ? "" : Character.toString(end);
if (typedParamListStartChar) { if (typedParamListStartChar) {
String template = "${}" + text + "${cursor}"; String template = "${}" + text + "${cursor}";
textComponent.replaceSelection(Character.toString(p.getParameterListStart())); textComponent.replaceSelection(Character.toString(p.getParameterListStart()));
TemplateCompletion tc = new TemplateCompletion(p, null, null, template); TemplateCompletion tc = new TemplateCompletion(p, null, null, template);
pc = tc; pc = tc;
} } else {
else {
text = p.getParameterListStart() + text; text = p.getParameterListStart() + text;
textComponent.replaceSelection(text); textComponent.replaceSelection(text);
return; return;
@ -1034,7 +1020,7 @@ public class AutoCompletion {
*/ */
public void uninstall() { public void uninstall() {
if (textComponent!=null) { if (textComponent != null) {
hidePopupWindow(); // Unregisters listeners, actions, etc. hidePopupWindow(); // Unregisters listeners, actions, etc.
@ -1042,7 +1028,7 @@ public class AutoCompletion {
// Uninstall the function completion key. // Uninstall the function completion key.
char start = provider.getParameterListStart(); char start = provider.getParameterListStart();
if (start!=0) { if (start != 0) {
KeyStroke ks = KeyStroke.getKeyStroke(start); KeyStroke ks = KeyStroke.getKeyStroke(start);
InputMap im = textComponent.getInputMap(); InputMap im = textComponent.getInputMap();
im.put(ks, oldParenKey); im.put(ks, oldParenKey);
@ -1051,7 +1037,7 @@ public class AutoCompletion {
} }
textComponentListener.removeFrom(textComponent); textComponentListener.removeFrom(textComponent);
if (parentWindow!=null) { if (parentWindow != null) {
parentWindowListener.removeFrom(parentWindow); parentWindowListener.removeFrom(parentWindow);
} }
@ -1089,15 +1075,15 @@ public class AutoCompletion {
* at runtime. * at runtime.
*/ */
private void updateUI() { private void updateUI() {
if (popupWindow!=null) { if (popupWindow != null) {
popupWindow.updateUI(); popupWindow.updateUI();
} }
if (pcc!=null) { if (pcc != null) {
pcc.updateUI(); pcc.updateUI();
} }
// Will practically always be a JComponent (a JLabel) // Will practically always be a JComponent (a JLabel)
if (paramChoicesRenderer instanceof JComponent) { if (paramChoicesRenderer instanceof JComponent) {
((JComponent)paramChoicesRenderer).updateUI(); ((JComponent) paramChoicesRenderer).updateUI();
} }
} }
@ -1130,8 +1116,7 @@ public class AutoCompletion {
public void caretUpdate(CaretEvent e) { public void caretUpdate(CaretEvent e) {
if (justInserted) { if (justInserted) {
justInserted = false; justInserted = false;
} } else {
else {
timer.stop(); timer.stop();
} }
} }
@ -1149,16 +1134,14 @@ public class AutoCompletion {
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
justInserted = false; justInserted = false;
if (isAutoCompleteEnabled() && isAutoActivationEnabled() && if (isAutoCompleteEnabled() && isAutoActivationEnabled() &&
e.getLength()==1) { e.getLength() == 1) {
if (provider.isAutoActivateOkay(textComponent)) { if (provider.isAutoActivateOkay(textComponent)) {
timer.restart(); timer.restart();
justInserted = true; justInserted = true;
} } else {
else {
timer.stop(); timer.stop();
} }
} } else {
else {
timer.stop(); timer.stop();
} }
} }
@ -1187,8 +1170,7 @@ public class AutoCompletion {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (isAutoCompleteEnabled()) { if (isAutoCompleteEnabled()) {
refreshPopupWindow(); refreshPopupWindow();
} } else if (oldTriggerAction != null) {
else if (oldTriggerAction!=null) {
oldTriggerAction.actionPerformed(e); oldTriggerAction.actionPerformed(e);
} }
} }
@ -1322,11 +1304,11 @@ public class AutoCompletion {
Window oldParentWindow = parentWindow; Window oldParentWindow = parentWindow;
parentWindow = SwingUtilities.getWindowAncestor(textComponent); parentWindow = SwingUtilities.getWindowAncestor(textComponent);
if (parentWindow!=oldParentWindow) { if (parentWindow != oldParentWindow) {
if (oldParentWindow!=null) { if (oldParentWindow != null) {
parentWindowListener.removeFrom(oldParentWindow); parentWindowListener.removeFrom(oldParentWindow);
} }
if (parentWindow!=null) { if (parentWindow != null) {
parentWindowListener.addTo(parentWindow); parentWindowListener.addTo(parentWindow);
} }
} }

59
designer_base/src/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java

@ -14,6 +14,7 @@ import com.fr.design.gui.autocomplete.ParameterizedCompletionInsertionInfo.Repla
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.DocumentRange; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.DocumentRange;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rtextarea.ChangeableHighlightPainter; import com.fr.design.gui.syntax.ui.rtextarea.ChangeableHighlightPainter;
import com.fr.general.FRLogger;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.CaretEvent; import javax.swing.event.CaretEvent;
@ -438,11 +439,9 @@ class ParameterizedCompletionContext {
* @see #uninstallKeyBindings() * @see #uninstallKeyBindings()
*/ */
private void installKeyBindings() { private void installKeyBindings() {
if (AutoCompletion.isDebug()) {
if (AutoCompletion.getDebug()) { FRLogger.getLogger().debug("CompletionContext: Installing keybindings");
System.out.println("CompletionContext: Installing keybindings");
} }
JTextComponent tc = ac.getTextComponent(); JTextComponent tc = ac.getTextComponent();
InputMap im = tc.getInputMap(); InputMap im = tc.getInputMap();
ActionMap am = tc.getActionMap(); ActionMap am = tc.getActionMap();
@ -489,7 +488,6 @@ class ParameterizedCompletionContext {
im.put(ks, IM_KEY_CLOSING); im.put(ks, IM_KEY_CLOSING);
oldClosingAction = am.get(IM_KEY_CLOSING); oldClosingAction = am.get(IM_KEY_CLOSING);
am.put(IM_KEY_CLOSING, new ClosingAction()); am.put(IM_KEY_CLOSING, new ClosingAction());
} }
@ -513,12 +511,7 @@ class ParameterizedCompletionContext {
List<Highlight> highlights = getParameterHighlights(); List<Highlight> highlights = getParameterHighlights();
for (int i = 0; i < highlights.size(); i++) { for (int i = 0; i < highlights.size(); i++) {
Highlight hl = highlights.get(i); Highlight hl = highlights.get(i);
// Check "< dot", not "<= dot" as OutlineHighlightPainter paints if (needUpdate(currentNext, hl, dot)) {
// starting at one char AFTER the highlight starts, to work around
// Java issue. Thanks to Matthew Adereth!
if (currentNext == null || currentNext.getStartOffset() </*=*/dot ||
(hl.getStartOffset() > dot &&
hl.getStartOffset() <= currentNext.getStartOffset())) {
currentNext = hl; currentNext = hl;
pos = i; pos = i;
} }
@ -538,6 +531,15 @@ class ParameterizedCompletionContext {
} }
private boolean needUpdate(Highlight currentNext, Highlight hl, int dot) {
// Check "< dot", not "<= dot" as OutlineHighlightPainter paints
// starting at one char AFTER the highlight starts, to work around
// Java issue. Thanks to Matthew Adereth!
return currentNext == null || currentNext.getStartOffset() </*=*/dot ||
(hl.getStartOffset() > dot &&
hl.getStartOffset() <= currentNext.getStartOffset());
}
/** /**
* Moves to and selects the previous parameter. * Moves to and selects the previous parameter.
@ -562,10 +564,7 @@ class ParameterizedCompletionContext {
for (int i = 0; i < highlights.size(); i++) { for (int i = 0; i < highlights.size(); i++) {
Highlight h = highlights.get(i); Highlight h = highlights.get(i);
if (currentPrev == null || currentPrev.getStartOffset() >= dot || if (pos == lastSelectedParam || needUpdate(currentPrev, dot, h, selStart)) {
(h.getStartOffset() < selStart &&
(h.getStartOffset() > currentPrev.getStartOffset() ||
pos == lastSelectedParam))) {
currentPrev = h; currentPrev = h;
pos = i; pos = i;
} }
@ -593,6 +592,12 @@ class ParameterizedCompletionContext {
} }
private boolean needUpdate(Highlight currentPrev, int dot, Highlight h, int selStart) {
return currentPrev == null
|| currentPrev.getStartOffset() >= dot
|| (currentPrev.getStartOffset() < h.getStartOffset() && h.getStartOffset() < selStart);
}
private void possiblyUpdateParamCopies(Document doc) { private void possiblyUpdateParamCopies(Document doc) {
@ -733,8 +738,8 @@ class ParameterizedCompletionContext {
*/ */
private void uninstallKeyBindings() { private void uninstallKeyBindings() {
if (AutoCompletion.getDebug()) { if (AutoCompletion.isDebug()) {
System.out.println("CompletionContext Uninstalling keybindings"); FRLogger.getLogger().debug("CompletionContext Uninstalling keybindings");
} }
JTextComponent tc = ac.getTextComponent(); JTextComponent tc = ac.getTextComponent();
@ -1037,7 +1042,6 @@ class ParameterizedCompletionContext {
* @see #uninstall() * @see #uninstall()
*/ */
public void install(JTextComponent tc) { public void install(JTextComponent tc) {
boolean replaceTabs = false; boolean replaceTabs = false;
if (tc instanceof RSyntaxTextArea) { if (tc instanceof RSyntaxTextArea) {
RSyntaxTextArea textArea = (RSyntaxTextArea) tc; RSyntaxTextArea textArea = (RSyntaxTextArea) tc;
@ -1047,14 +1051,10 @@ class ParameterizedCompletionContext {
} }
Highlighter h = tc.getHighlighter(); Highlighter h = tc.getHighlighter();
try { try {
// Insert the parameter text // Insert the parameter text
ParameterizedCompletionInsertionInfo info = ParameterizedCompletionInsertionInfo info = pc.getInsertionInfo(tc, replaceTabs);
pc.getInsertionInfo(tc, replaceTabs);
tc.replaceSelection(info.getTextToInsert()); tc.replaceSelection(info.getTextToInsert());
// Add highlights around the parameters. // Add highlights around the parameters.
final int replacementCount = info.getReplacementCount(); final int replacementCount = info.getReplacementCount();
for (int i = 0; i < replacementCount; i++) { for (int i = 0; i < replacementCount; i++) {
@ -1067,40 +1067,31 @@ class ParameterizedCompletionContext {
for (int i = 0; i < info.getReplacementCopyCount(); i++) { for (int i = 0; i < info.getReplacementCopyCount(); i++) {
ReplacementCopy rc = info.getReplacementCopy(i); ReplacementCopy rc = info.getReplacementCopy(i);
paramCopyInfos.add(new ParamCopyInfo(rc.getId(), paramCopyInfos.add(new ParamCopyInfo(rc.getId(),
(Highlight) h.addHighlight(rc.getStart(), rc.getEnd(), (Highlight) h.addHighlight(rc.getStart(), rc.getEnd(), paramCopyP)));
paramCopyP)));
} }
// Go back and start at the first parameter. // Go back and start at the first parameter.
tc.setCaretPosition(info.getSelectionStart()); tc.setCaretPosition(info.getSelectionStart());
if (info.hasSelection()) { if (info.hasSelection()) {
tc.moveCaretPosition(info.getSelectionEnd()); tc.moveCaretPosition(info.getSelectionEnd());
} }
minPos = info.getMinOffset(); minPos = info.getMinOffset();
maxPos = info.getMaxOffset(); maxPos = info.getMaxOffset();
try { try {
defaultEndOffs = tc.getDocument().createPosition( defaultEndOffs = tc.getDocument().createPosition(info.getDefaultEndOffs());
info.getDefaultEndOffs());
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
// Never happens // Never happens
} }
// Listen for document events AFTER we insert // Listen for document events AFTER we insert
tc.getDocument().addDocumentListener(this); tc.getDocument().addDocumentListener(this);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
// Never happens // Never happens
} }
// Add listeners to the text component, AFTER text insertion. // Add listeners to the text component, AFTER text insertion.
tc.addCaretListener(this); tc.addCaretListener(this);
tc.addFocusListener(this); tc.addFocusListener(this);
installKeyBindings(); installKeyBindings();
} }
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
handleDocumentEvent(e); handleDocumentEvent(e);
} }

3
designer_base/src/com/fr/design/gui/chart/BaseChartPropertyPane.java

@ -2,7 +2,6 @@ package com.fr.design.gui.chart;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.mainframe.BaseWidgetPropertyPane;
import com.fr.design.mainframe.DockingView; import com.fr.design.mainframe.DockingView;
/** /**
@ -23,5 +22,7 @@ public abstract class BaseChartPropertyPane extends DockingView {
public abstract ChartEditPaneProvider getChartEditPane(); public abstract ChartEditPaneProvider getChartEditPane();
public abstract void addChartEditPane(String plotID);
//public abstract void clear(); //public abstract void clear();
} }

18
designer_base/src/com/fr/design/gui/icombobox/ExtendedComboBox.java

@ -1,21 +1,15 @@
package com.fr.design.gui.icombobox; package com.fr.design.gui.icombobox;
import java.awt.Component; import javax.swing.*;
import java.awt.Dimension; import javax.swing.plaf.ComponentUI;
import java.awt.Point; import javax.swing.plaf.basic.BasicComboPopup;
import java.awt.Rectangle; import javax.swing.plaf.basic.ComboPopup;
import java.awt.*;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Vector; import java.util.Vector;
import javax.swing.ComboBoxModel; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
public class ExtendedComboBox extends UIComboBox { public class ExtendedComboBox extends UIComboBox {

28
designer_base/src/com/fr/design/gui/icombobox/UIComboBoxUI.java

@ -1,28 +1,20 @@
package com.fr.design.gui.icombobox; package com.fr.design.gui.icombobox;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import sun.swing.DefaultLookup;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import sun.swing.DefaultLookup;
import javax.swing.*;
import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/** /**
* @author zhou F * @author zhou F

51
designer_base/src/com/fr/design/gui/ilist/CheckBoxList.java

@ -1,34 +1,24 @@
package com.fr.design.gui.ilist; package com.fr.design.gui.ilist;
import java.awt.BorderLayout; import com.fr.design.gui.icheckbox.UICheckBox;
import java.awt.Component; import com.fr.stable.StringUtils;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import javax.swing.*;
import java.awt.event.KeyAdapter; import javax.swing.border.Border;
import java.awt.event.KeyEvent; import javax.swing.border.EmptyBorder;
import java.awt.event.MouseAdapter; import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.EventListener; import java.util.EventListener;
import java.util.List; import java.util.List;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.stable.StringUtils;
/** /**
* CheckBoxs + JList. * CheckBoxs + JList.
*/ */
public class CheckBoxList extends JComponent { public class CheckBoxList extends JComponent {
private final static int X_COORDINATE = 20;
/** /**
* 选择状态----全选和全不选 * 选择状态----全选和全不选
* *
@ -54,10 +44,8 @@ public class CheckBoxList extends JComponent {
/** /**
* Class constructor. * Class constructor.
* *
* @param items * @param items Items with which to populate the list.
* Items with which to populate the list. * @param state default state, true or false
* @param default_state
* default state, true or false
*/ */
public CheckBoxList(Object[] items, SelectedState state, String name) { public CheckBoxList(Object[] items, SelectedState state, String name) {
jlist = new BOXLIST(items); jlist = new BOXLIST(items);
@ -175,8 +163,9 @@ public class CheckBoxList extends JComponent {
@Override @Override
protected void processMouseEvent(MouseEvent e) { protected void processMouseEvent(MouseEvent e) {
if (e.getX() < 20) { if (e.getX() < X_COORDINATE) {
if (e.isControlDown() || e.isAltDown() || e.isShiftDown() || e.isMetaDown()) { boolean anyMaskDown = e.isControlDown() || e.isAltDown() || e.isShiftDown() || e.isMetaDown();
if (anyMaskDown) {
int[] indices = getSelectedIndices(); int[] indices = getSelectedIndices();
if (indices.length == 0) { if (indices.length == 0) {
super.processMouseEvent(e); super.processMouseEvent(e);
@ -205,7 +194,7 @@ public class CheckBoxList extends JComponent {
@Override @Override
protected void processMouseMotionEvent(MouseEvent e) { protected void processMouseMotionEvent(MouseEvent e) {
if (e.getX() < 20) { if (e.getX() < X_COORDINATE) {
return; return;
} }
@ -246,13 +235,13 @@ public class CheckBoxList extends JComponent {
repaint(); repaint();
} }
private static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); private static final Border NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
private class CheckListCellRenderer extends UICheckBox implements ListCellRenderer { private class CheckListCellRenderer extends UICheckBox implements ListCellRenderer {
public CheckListCellRenderer() { public CheckListCellRenderer() {
this.setOpaque(true); this.setOpaque(true);
this.setBorder(noFocusBorder); this.setBorder(NO_FOCUS_BORDER);
} }
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) {
@ -271,7 +260,7 @@ public class CheckBoxList extends JComponent {
if (cellHasFocus) { if (cellHasFocus) {
this.setBorder(UIManager.getBorder("List.focusCellHighlightBorder")); this.setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
} else { } else {
this.setBorder(noFocusBorder); this.setBorder(NO_FOCUS_BORDER);
} }
return this; return this;
@ -294,7 +283,7 @@ public class CheckBoxList extends JComponent {
// those that are interested in this event // those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2) { for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == CheckBoxListSelectionChangeListener.class) { if (listeners[i] == CheckBoxListSelectionChangeListener.class) {
((CheckBoxListSelectionChangeListener)listeners[i + 1]).selectionChanged(this); ((CheckBoxListSelectionChangeListener) listeners[i + 1]).selectionChanged(this);
} }
} }

11
designer_base/src/com/fr/design/gui/ilist/UIList.java

@ -17,7 +17,7 @@ import java.util.Vector;
* Time: 上午11:07 * Time: 上午11:07
* To change this template use File | Settings | File Templates. * To change this template use File | Settings | File Templates.
*/ */
public class UIList extends JList{ public class UIList extends JList {
private Icon icon; private Icon icon;
public UIList() { public UIList() {
@ -46,12 +46,12 @@ public class UIList extends JList{
if (rendererComp.getPreferredSize().width > getVisibleRect().width) { if (rendererComp.getPreferredSize().width > getVisibleRect().width) {
String tips = (rendererComp instanceof JComponent) ? ((JComponent) rendererComp).getToolTipText() : null; String tips = (rendererComp instanceof JComponent) ? ((JComponent) rendererComp).getToolTipText() : null;
if (tips == null) { if (tips == null) {
if(value instanceof JTemplate){ if (value instanceof JTemplate) {
tips = ((JTemplate) value).getEditingFILE().getName(); tips = ((JTemplate) value).getEditingFILE().getName();
icon = ((JTemplate) value).getEditingFILE().getIcon(); icon = ((JTemplate) value).getEditingFILE().getIcon();
} else if (value instanceof ListModelElement || value instanceof TableProcedure){ } else if (value instanceof ListModelElement || value instanceof TableProcedure) {
tips = ((JLabel)rendererComp).getText(); tips = ((JLabel) rendererComp).getText();
icon = ((JLabel)rendererComp).getIcon(); icon = ((JLabel) rendererComp).getIcon();
} }
} }
return tips; return tips;
@ -71,6 +71,7 @@ public class UIList extends JList{
} }
return null; return null;
} }
public JToolTip createToolTip() { public JToolTip createToolTip() {
UIToolTip tip = new UIToolTip(icon); UIToolTip tip = new UIToolTip(icon);
tip.setComponent(this); tip.setComponent(this);

11
designer_base/src/com/fr/design/gui/itable/TableSorter.java

@ -15,6 +15,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.Icon; import javax.swing.Icon;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelEvent;
@ -79,7 +80,7 @@ import javax.swing.table.TableModel;
public class TableSorter extends AbstractTableModel { public class TableSorter extends AbstractTableModel {
protected TableModel tableModel; protected TableModel tableModel;
private static final int ADD = 4;
public static final int DESCENDING = -1; public static final int DESCENDING = -1;
public static final int NOT_SORTED = 0; public static final int NOT_SORTED = 0;
public static final int ASCENDING = 1; public static final int ASCENDING = 1;
@ -341,16 +342,13 @@ public class TableSorter extends AbstractTableModel {
fireTableChanged(e); fireTableChanged(e);
return; return;
} }
// If the table structure has changed, cancel the sorting; the // If the table structure has changed, cancel the sorting; the
// sorting columns may have been either moved or deleted from // sorting columns may have been either moved or deleted from the model.
// the model.
if (e.getFirstRow() == TableModelEvent.HEADER_ROW) { if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
cancelSorting(); cancelSorting();
fireTableChanged(e); fireTableChanged(e);
return; return;
} }
// We can map a cell event through to the view without widening // We can map a cell event through to the view without widening
// when the following conditions apply: // when the following conditions apply:
// //
@ -380,7 +378,6 @@ public class TableSorter extends AbstractTableModel {
column, e.getType())); column, e.getType()));
return; return;
} }
// Something has happened to the data that may have invalidated the row order. // Something has happened to the data that may have invalidated the row order.
clearSortingState(); clearSortingState();
fireTableDataChanged(); fireTableDataChanged();
@ -402,7 +399,7 @@ public class TableSorter extends AbstractTableModel {
// Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
// {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
status = status + (e.isShiftDown() ? -1 : 1); status = status + (e.isShiftDown() ? -1 : 1);
status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1} status = (status + ADD) % 3 - 1; // signed mod, returning {-1, 0, 1}
setSortingStatus(column, status); setSortingStatus(column, status);
} }
} }

49
designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java

@ -1,37 +1,22 @@
package com.fr.design.gui.itabpane; package com.fr.design.gui.itabpane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.InputMap;
import javax.swing.JComponent;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.core.UITabComponent; import com.fr.design.gui.core.UITabComponent;
import com.fr.design.gui.ibutton.UITabButton; import com.fr.design.gui.ibutton.UITabButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** /**
* 本来想弄个延迟加载的发现在单元格属性表那边没有意义就算了.这个面板是纯粹的没有与模板的任何交互操作(比如说populate() update()) * 本来想弄个延迟加载的发现在单元格属性表那边没有意义就算了.这个面板是纯粹的没有与模板的任何交互操作(比如说populate() update())
* *
@ -40,6 +25,7 @@ import com.fr.stable.StringUtils;
*/ */
public class UITabsHeaderIconPane extends JPanel implements UITabComponent { public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final int DIS = 30;
private UILabel nameLabel; private UILabel nameLabel;
@ -143,9 +129,7 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
private void show(final JPanel panel) { private void show(final JPanel panel) {
int count = centerPane.getComponentCount();// 获取centerPanel中控件数 int count = centerPane.getComponentCount();// 获取centerPanel中控件数
List<Component> list = new ArrayList<Component>();// List<Component> list = new ArrayList<Component>();//
for (Component comp : centerPane.getComponents()) { list.addAll(Arrays.asList(centerPane.getComponents()));
list.add(comp);
}
if (count > 0) {// 如果centerPanel中控件数大于0就执行效果 if (count > 0) {// 如果centerPanel中控件数大于0就执行效果
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Component comp = centerPane.getComponent(i);// 获得该位置的控件 Component comp = centerPane.getComponent(i);// 获得该位置的控件
@ -159,11 +143,11 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
int height = centerPane.getHeight(); int height = centerPane.getHeight();
int width = centerPane.getWidth(); int width = centerPane.getWidth();
int y = -height; int y = -height;
for (int i = 0; i <= height; i += 30) { for (int i = 0; i <= height; i += DIS) {
// 设置面板位置 // 设置面板位置
currentPanel.setBounds(0, i, width, height); currentPanel.setBounds(0, i, width, height);
panel.setBounds(0, y, width, height); panel.setBounds(0, y, width, height);
y += 30; y += DIS;
try { try {
Thread.sleep(3); Thread.sleep(3);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -173,7 +157,6 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
centerPane.remove(currentPanel);// 移除当前面板 centerPane.remove(currentPanel);// 移除当前面板
} }
panel.setBounds(0, 0, width, height); panel.setBounds(0, 0, width, height);
} }
}.start(); }.start();
break; break;

18
designer_base/src/com/fr/design/gui/itextfield/UITextField.java

@ -1,20 +1,17 @@
package com.fr.design.gui.itextfield; package com.fr.design.gui.itextfield;
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import java.awt.*;
/** /**
* @author Jerry * @author Jerry
@ -186,6 +183,7 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
/** /**
* 主函数 * 主函数
*
* @param args 参数 * @param args 参数
*/ */
public static void main(String... args) { public static void main(String... args) {

47
designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java

@ -5,8 +5,14 @@
*/ */
package com.fr.design.gui.itree.checkboxtree; package com.fr.design.gui.itree.checkboxtree;
import java.awt.Component; import com.fr.design.gui.icheckbox.UICheckBox;
import java.awt.Rectangle;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.text.Position;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -16,19 +22,6 @@ import java.beans.PropertyChangeListener;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.text.Position;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import com.fr.design.gui.icheckbox.UICheckBox;
/** /**
* CheckBoxTree is a special JTree which uses UICheckBox as the tree renderer. * CheckBoxTree is a special JTree which uses UICheckBox as the tree renderer.
* In addition to regular JTree's features, it also allows you select any number * In addition to regular JTree's features, it also allows you select any number
@ -177,8 +170,7 @@ public class CheckBoxTree extends JTree {
} }
if (_treeCellRenderer == null) { if (_treeCellRenderer == null) {
_treeCellRenderer = createCellRenderer(cellRenderer); _treeCellRenderer = createCellRenderer(cellRenderer);
} } else {
else {
_treeCellRenderer.setActualTreeRenderer(cellRenderer); _treeCellRenderer.setActualTreeRenderer(cellRenderer);
} }
return _treeCellRenderer; return _treeCellRenderer;
@ -194,8 +186,7 @@ public class CheckBoxTree extends JTree {
public TreeCellRenderer getActualCellRenderer() { public TreeCellRenderer getActualCellRenderer() {
if (_treeCellRenderer != null) { if (_treeCellRenderer != null) {
return _treeCellRenderer.getActualTreeRenderer(); return _treeCellRenderer.getActualTreeRenderer();
} } else {
else {
return super.getCellRenderer(); return super.getCellRenderer();
} }
} }
@ -245,13 +236,13 @@ public class CheckBoxTree extends JTree {
} }
TreePath path = _tree.getPathForLocation(e.getX(), e.getY()); TreePath path = _tree.getPathForLocation(e.getX(), e.getY());
if (path == null) if (path == null) {
return null; return null;
}
if (clicksInCheckBox(e, path)) { if (clicksInCheckBox(e, path)) {
return path; return path;
} } else {
else {
return null; return null;
} }
} }
@ -259,13 +250,11 @@ public class CheckBoxTree extends JTree {
protected boolean clicksInCheckBox(MouseEvent e, TreePath path) { protected boolean clicksInCheckBox(MouseEvent e, TreePath path) {
if (!_tree.isCheckBoxVisible(path)) { if (!_tree.isCheckBoxVisible(path)) {
return false; return false;
} } else {
else {
Rectangle bounds = _tree.getPathBounds(path); Rectangle bounds = _tree.getPathBounds(path);
if (_tree.getComponentOrientation().isLeftToRight()) { if (_tree.getComponentOrientation().isLeftToRight()) {
return e.getX() < bounds.x + _hotspot; return e.getX() < bounds.x + _hotspot;
} } else {
else {
return e.getX() > bounds.x + bounds.width - _hotspot; return e.getX() > bounds.x + bounds.width - _hotspot;
} }
} }
@ -320,9 +309,10 @@ public class CheckBoxTree extends JTree {
return; return;
} }
if (e.getModifiers() == 0 && e.getKeyChar() == KeyEvent.VK_SPACE) if (e.getModifiers() == 0 && e.getKeyChar() == KeyEvent.VK_SPACE) {
toggleSelections(); toggleSelections();
} }
}
public void keyTyped(KeyEvent e) { public void keyTyped(KeyEvent e) {
} }
@ -349,8 +339,7 @@ public class CheckBoxTree extends JTree {
selectionModel.removeSelectionPath(path); selectionModel.removeSelectionPath(path);
else else
selectionModel.addSelectionPath(path); selectionModel.addSelectionPath(path);
} } finally {
finally {
if (!selectionModel.isSingleEventMode()) { if (!selectionModel.isSingleEventMode()) {
selectionModel.setBatchMode(false); selectionModel.setBatchMode(false);
} }

2
designer_base/src/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaDefaultInputMap.java

@ -34,7 +34,7 @@ public class RSyntaxTextAreaDefaultInputMap extends RTADefaultInputMap {
*/ */
public RSyntaxTextAreaDefaultInputMap() { public RSyntaxTextAreaDefaultInputMap() {
int defaultMod = getDefaultModifier(); int defaultMod = DEFAULT_MODIFIER;
//int ctrl = InputEvent.CTRL_MASK; //int ctrl = InputEvent.CTRL_MASK;
int shift = InputEvent.SHIFT_MASK; int shift = InputEvent.SHIFT_MASK;
//int alt = InputEvent.ALT_MASK; //int alt = InputEvent.ALT_MASK;

24
designer_base/src/com/fr/design/gui/syntax/ui/rtextarea/RTADefaultInputMap.java

@ -41,6 +41,14 @@ import javax.swing.text.DefaultEditorKit;
public class RTADefaultInputMap extends InputMap { public class RTADefaultInputMap extends InputMap {
/**
* Returns the default modifier key for a system. For example, on Windows
* this would be the CTRL key (<code>InputEvent.CTRL_MASK</code>).
*
* @return The default modifier key.
*/
public static final int DEFAULT_MODIFIER = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
/** /**
* Constructs the default input map for an <code>RTextArea</code>. * Constructs the default input map for an <code>RTextArea</code>.
*/ */
@ -48,7 +56,7 @@ public class RTADefaultInputMap extends InputMap {
super(); super();
int defaultModifier = getDefaultModifier(); int defaultModifier = DEFAULT_MODIFIER;
//int ctrl = InputEvent.CTRL_MASK; //int ctrl = InputEvent.CTRL_MASK;
int alt = InputEvent.ALT_MASK; int alt = InputEvent.ALT_MASK;
int shift = InputEvent.SHIFT_MASK; int shift = InputEvent.SHIFT_MASK;
@ -134,18 +142,4 @@ public class RTADefaultInputMap extends InputMap {
*/ */
} }
/**
* Returns the default modifier key for a system. For example, on Windows
* this would be the CTRL key (<code>InputEvent.CTRL_MASK</code>).
*
* @return The default modifier key.
*/
protected static final int getDefaultModifier() {
return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
}
} }

9
designer_base/src/com/fr/design/locale/designer.properties

@ -1132,7 +1132,7 @@ FRFont-bold=bold
FR-Designer_Set_Submit_Condition= FR-Designer_Set_Submit_Condition=
Form-Change_Widget_Name=Change Widget Name Form-Change_Widget_Name=Change Widget Name
ReportColumns-Report_Columns=Report Columns ReportColumns-Report_Columns=Report Columns
Can_not_use_FormatBursh= FR-Designer_Can_not_use_FormatBursh=
CellElement-Property_Table=CellElement Property Table CellElement-Property_Table=CellElement Property Table
Dictionary-Dynamic_SQL=Dynamic SQL Dictionary-Dynamic_SQL=Dynamic SQL
FR-Designer_Form-CheckBoxGroup=CheckBoxGroup FR-Designer_Form-CheckBoxGroup=CheckBoxGroup
@ -1994,3 +1994,10 @@ FR-Designer_Parameter=
FR-Designer-Plugin_Plugin=Plugin FR-Designer-Plugin_Plugin=Plugin
FR-Designer_Background=Background FR-Designer_Background=Background
Template=Template Template=Template
FR-Designer_Parent_Marked_Field=Parent Marked Field
FR-Designer_Original_Marked_Filed=Original Marked Filed
FR-Designer_Build_Tree_Accord_Parent_Marked_Filed=Build Tree according parent's marked filed
FR-Designer_Build_Tree_Accord_Marked_Filed_Length=Build Tree according marked filed's length
FR-Product_Demo=Demo
FR-Designer_Tree_Data_Field=Tree Data Field

8
designer_base/src/com/fr/design/locale/designer_en_US.properties

@ -1994,3 +1994,11 @@ FR-Designer_Parameter=Parameter
FR-Designer-Plugin_Plugin=Plugin FR-Designer-Plugin_Plugin=Plugin
FR-Designer_Background=BG FR-Designer_Background=BG
Template=Template Template=Template
FR-Designer_Original_Marked_Filed=Original Tag Field
FR-Designer_Build_Tree_Accord_Marked_Filed_Length=Build tree according to tag field's length
FR-Designer_Can_not_use_FormatBursh=Can't use format painter in multiple selections
FR-Designer_Tree_Data_Field=Tree Data Field
FR-Designer_Parent_Marked_Field=Parent Tag Field
FR-Designer_Build_Tree_Accord_Parent_Marked_Filed=Build Tree according to the parent tag field of the selected data set
FR-Product_Demo=Demo

1175
designer_base/src/com/fr/design/locale/designer_ja_JP.properties

File diff suppressed because it is too large Load Diff

9
designer_base/src/com/fr/design/locale/designer_ko_KR.properties

@ -1132,7 +1132,7 @@ FRFont-bold=\uAD75\uAC8C
FR-Designer_Set_Submit_Condition=\uC81C\uCD9C\uC870\uAC74\uC124\uC815 FR-Designer_Set_Submit_Condition=\uC81C\uCD9C\uC870\uAC74\uC124\uC815
Form-Change_Widget_Name=\uC18C\uD504\uD2B8\uC6E8\uC5B4\uC81C\uC5B4\uC774\uB984\uBCC0\uACBD Form-Change_Widget_Name=\uC18C\uD504\uD2B8\uC6E8\uC5B4\uC81C\uC5B4\uC774\uB984\uBCC0\uACBD
ReportColumns-Report_Columns=\uBB38\uC11C\uC140\uB098\uB204\uAE30 ReportColumns-Report_Columns=\uBB38\uC11C\uC140\uB098\uB204\uAE30
Can_not_use_FormatBursh=\uC911\uBCF5\uC120\uD0DD\uB41C\uC601\uC5ED\uC5D0\uC11C\uC2DD\uC744\uC774\uC6A9\uD558\uC5EC\uC778\uC1C4\uD560\uC218\uC5C6\uC2B5\uB2C8\uB2E4.\! FR-Designer_Can_not_use_FormatBursh=\uC911\uBCF5\uC120\uD0DD\uB41C\uC601\uC5ED\uC5D0\uC11C\uC2DD\uC744\uC774\uC6A9\uD558\uC5EC\uC778\uC1C4\uD560\uC218\uC5C6\uC2B5\uB2C8\uB2E4.\!
CellElement-Property_Table=\uC140\uC18D\uC131\uD45C CellElement-Property_Table=\uC140\uC18D\uC131\uD45C
Dictionary-Dynamic_SQL=\uB3D9\uC801 SQL Dictionary-Dynamic_SQL=\uB3D9\uC801 SQL
FR-Designer_Form-CheckBoxGroup=\uCCB4\uD06C\uBC15\uC2A4\uADF8\uB8F9 FR-Designer_Form-CheckBoxGroup=\uCCB4\uD06C\uBC15\uC2A4\uADF8\uB8F9
@ -1994,3 +1994,10 @@ FR-Designer_Parameter=\uB9E4\uAC1C\uBCC0\uC218
FR-Designer-Plugin_Plugin=\uD50C\uB7EC\uADF8\uC778 FR-Designer-Plugin_Plugin=\uD50C\uB7EC\uADF8\uC778
FR-Designer_Background=\uBC30\uACBD FR-Designer_Background=\uBC30\uACBD
Template=\uD15C\uD50C\uB9BF Template=\uD15C\uD50C\uB9BF
FR-Designer_Original_Marked_Filed=\uCD08\uAE30\uD0DC\uADF8\uD544\uB4DC
FR-Designer_Build_Tree_Accord_Marked_Filed_Length=\uC120\uD0DD\uD55C\uB370\uC774\uD130\uC138\uD2B8\uC758\uD0DC\uADF8\uD544\uB4DC\uAE38\uC774\uC5D0\uB530\uB77C\uD2B8\uB9AC\uC0DD\uC131
FR-Designer_Tree_Data_Field=\uD2B8\uB9AC\uB370\uC774\uD130\uD544\uB4DC
FR-Designer_Parent_Marked_Field=\uBD80\uBAA8\uD0DC\uADF8\uD544\uB4DC
FR-Designer_Build_Tree_Accord_Parent_Marked_Filed=\uC120\uD0DD\uD55C\uB370\uC774\uD130\uC138\uD2B8\uC758\uBD80\uBAA8\uD0DC\uADF8\uD544\uB4DC\uC5D0\uB530\uB77C\uD2B8\uB9AC\uC0DD\uC131
FR-Product_Demo=\uC81C\uD488\uC2DC\uC5F0

9
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -1132,7 +1132,7 @@ FRFont-bold=\u52A0\u7C97
FR-Designer_Set_Submit_Condition=\u8BBE\u7F6E\u63D0\u4EA4\u6761\u4EF6 FR-Designer_Set_Submit_Condition=\u8BBE\u7F6E\u63D0\u4EA4\u6761\u4EF6
Form-Change_Widget_Name=\u66F4\u6539\u63A7\u4EF6\u540D Form-Change_Widget_Name=\u66F4\u6539\u63A7\u4EF6\u540D
ReportColumns-Report_Columns=\u62A5\u8868\u5206\u680F ReportColumns-Report_Columns=\u62A5\u8868\u5206\u680F
Can_not_use_FormatBursh=\u4E0D\u80FD\u5BF9\u591A\u91CD\u9009\u5B9A\u533A\u57DF\u4F7F\u7528\u683C\u5F0F\u5237\! FR-Designer_Can_not_use_FormatBursh=\u4E0D\u80FD\u5BF9\u591A\u91CD\u9009\u5B9A\u533A\u57DF\u4F7F\u7528\u683C\u5F0F\u5237\!
CellElement-Property_Table=\u5355\u5143\u683C\u5C5E\u6027\u8868 CellElement-Property_Table=\u5355\u5143\u683C\u5C5E\u6027\u8868
Dictionary-Dynamic_SQL=\u52A8\u6001SQL Dictionary-Dynamic_SQL=\u52A8\u6001SQL
FR-Designer_Form-CheckBoxGroup=\u590D\u9009\u6846\u7EC4 FR-Designer_Form-CheckBoxGroup=\u590D\u9009\u6846\u7EC4
@ -1994,3 +1994,10 @@ FR-Designer_Parameter=\u53C2\u6570
FR-Designer-Plugin_Plugin=\u63D2\u4EF6 FR-Designer-Plugin_Plugin=\u63D2\u4EF6
FR-Designer_Background=\u80CC\u666F FR-Designer_Background=\u80CC\u666F
Template=\u6A21\u7248 Template=\u6A21\u7248
FR-Designer_Original_Marked_Filed=\u539F\u59CB\u6807\u8BB0\u5B57\u6BB5
FR-Designer_Build_Tree_Accord_Marked_Filed_Length=\u4F9D\u8D56\u6240\u9009\u6570\u636E\u96C6\u7684\u6807\u8BB0\u5B57\u6BB5\u7684\u957F\u5EA6\u6784\u5EFA\u6811
FR-Designer_Tree_Data_Field=\u6811\u6570\u636E\u5B57\u6BB5
FR-Designer_Parent_Marked_Field=\u7236\u6807\u8BB0\u5B57\u6BB5
FR-Designer_Build_Tree_Accord_Parent_Marked_Filed=\u4F9D\u8D56\u6240\u9009\u6570\u636E\u96C6\u7684\u7236\u6807\u8BB0\u5B57\u6BB5\u6784\u5EFA\u6811
FR-Product_Demo=\u4EA7\u54C1\u6F14\u793A

8
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -1994,3 +1994,11 @@ FR-Designer_Parameter=\u53C3\u6578
FR-Designer-Plugin_Plugin=\u63D2\u4EF6 FR-Designer-Plugin_Plugin=\u63D2\u4EF6
FR-Designer_Background=\u586B\u6EFF\u8272\u5F69 FR-Designer_Background=\u586B\u6EFF\u8272\u5F69
Template=\u7BC4\u672C Template=\u7BC4\u672C
FR-Designer_Original_Marked_Filed=\u539F\u59CB\u6A19\u8A18\u6B04\u4F4D
FR-Designer_Build_Tree_Accord_Marked_Filed_Length=\u4F9D\u8CF4\u6240\u9078\u8CC7\u6599\u96C6\u7684\u6A19\u8A18\u6B04\u4F4D\u7684\u9577\u5EA6\u69CB\u5EFA\u6A39\u72C0
FR-Designer_Can_not_use_FormatBursh=\u7121\u6CD5\u4F7F\u7528\u8907\u88FD\u683C\u5F0F
FR-Designer_Tree_Data_Field=\u6A39\u72C0\u8CC7\u6599\u6B04\u4F4D
FR-Designer_Parent_Marked_Field=\u7236\u6A19\u8A18\u6B04\u4F4D
FR-Designer_Build_Tree_Accord_Parent_Marked_Filed=\u4F9D\u8CF4\u6240\u9078\u8CC7\u6599\u96C6\u7684\u7236\u6A19\u8A18\u6B04\u4F4D\u69CB\u5EFA\u6A39
FR-Product_Demo=\u529F\u80FD\u5C55\u793A

8
designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -13,10 +13,7 @@ import com.fr.general.LogRecordTime;
import com.fr.stable.xml.LogRecordTimeProvider; import com.fr.stable.xml.LogRecordTimeProvider;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.BadLocationException; import javax.swing.text.*;
import javax.swing.text.Document;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -133,7 +130,6 @@ public class DesignerLogHandler {
private LogHandlerArea() { private LogHandlerArea() {
jTextArea = new JTextPane(); jTextArea = new JTextPane();
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
UIScrollPane js = new UIScrollPane(jTextArea); UIScrollPane js = new UIScrollPane(jTextArea);
this.add(js, BorderLayout.CENTER); this.add(js, BorderLayout.CENTER);
@ -297,6 +293,4 @@ public class DesignerLogHandler {
}; };
} }
} }

246
designer_base/src/com/fr/design/module/DesignModuleFactory.java

File diff suppressed because one or more lines are too long

8
designer_base/src/com/fr/design/style/color/UsedColorPane.java

@ -42,7 +42,7 @@ public class UsedColorPane extends BasicPane {
* @param rows * @param rows
* @param columns * @param columns
* @param reserveCells 留白的单元格个数 * @param reserveCells 留白的单元格个数
* @param colors 最近使用的颜色 * @param selectable
* @param needPickColorButton 是否需要加上取色器按钮 * @param needPickColorButton 是否需要加上取色器按钮
* @param setColorRealTime 取色器是否实时设定颜色 * @param setColorRealTime 取色器是否实时设定颜色
*/ */
@ -68,7 +68,6 @@ public class UsedColorPane extends BasicPane {
//最近使用颜色 //最近使用颜色
Color[] colors = ColorSelectConfigManager.getInstance().getColors(); Color[] colors = ColorSelectConfigManager.getInstance().getColors();
int size = colors.length; int size = colors.length;
int i = 0; int i = 0;
if (needPickColorButton) { if (needPickColorButton) {
// 取色按钮 // 取色按钮
@ -84,7 +83,8 @@ public class UsedColorPane extends BasicPane {
i++; i++;
} }
while (i < total) { while (i < total) {
Color color = i < size ? colors[size - (i - this.reserveCells) - 1] : DEFAULT_COLOR; Color color = i - this.reserveCells < size ? colors[size - (i - this.reserveCells) - 1] :
DEFAULT_COLOR;
panel.add(new ColorCell(color == null ? DEFAULT_COLOR : color, selectable)); panel.add(new ColorCell(color == null ? DEFAULT_COLOR : color, selectable));
i++; i++;
} }
@ -100,7 +100,7 @@ public class UsedColorPane extends BasicPane {
int size = colors.length; int size = colors.length;
for (int i = this.reserveCells; i < total; i++) { for (int i = this.reserveCells; i < total; i++) {
ColorCell cell = (ColorCell) this.pane.getComponent(i); ColorCell cell = (ColorCell) this.pane.getComponent(i);
Color color = i < size ? colors[size - (i - this.reserveCells) - 1] : DEFAULT_COLOR; Color color = i - this.reserveCells < size ? colors[size - (i - this.reserveCells) - 1] : DEFAULT_COLOR;
cell.setColor(color == null ? DEFAULT_COLOR : color); cell.setColor(color == null ? DEFAULT_COLOR : color);
} }
} }

4
designer_base/src/com/fr/design/utils/DesignUtils.java

@ -112,7 +112,7 @@ public class DesignUtils {
String line = null; String line = null;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
if (line.startsWith("demo")) { if (line.startsWith("demo")) {
StartServer.browerDemoURL(); StartServer.browserDemoURL();
} else if (StringUtils.isNotEmpty(line)) { } else if (StringUtils.isNotEmpty(line)) {
File f = new File(line); File f = new File(line);
String path = f.getAbsolutePath(); String path = f.getAbsolutePath();
@ -315,7 +315,7 @@ public class DesignUtils {
String web = GeneralContext.getCurrentAppNameOfEnv(); String web = GeneralContext.getCurrentAppNameOfEnv();
String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ConfigManager.getProviderInstance().getServletMapping() String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ConfigManager.getProviderInstance().getServletMapping()
+ postfixOfUri; + postfixOfUri;
StartServer.browerURLWithLocalEnv(url); StartServer.browserURLWithLocalEnv(url);
} catch (Throwable e) { } catch (Throwable e) {
// //
} }

6
designer_base/src/com/fr/start/BaseDesigner.java

@ -7,7 +7,7 @@ import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.extra.WebDialog; import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
@ -72,7 +72,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
for (String arg : args) { for (String arg : args) {
if (ComparatorUtils.equals(arg, "demo")) { if (ComparatorUtils.equals(arg, "demo")) {
DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); DesignerEnvManager.getEnvManager().setCurrentEnv2Default();
StartServer.browerDemoURL(); StartServer.browserDemoURL();
break; break;
} }
} }
@ -128,7 +128,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
String text = StableUtils.join(plugins, ",") + ": " + Inter.getLocText("FR-Designer_Plugin_Should_Update_Please_Contact_Developer"); String text = StableUtils.join(plugins, ",") + ": " + Inter.getLocText("FR-Designer_Plugin_Should_Update_Please_Contact_Developer");
int r = JOptionPane.showConfirmDialog(null, text, Inter.getLocText("FR-Designer_Plugin_Should_Update_Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); int r = JOptionPane.showConfirmDialog(null, text, Inter.getLocText("FR-Designer_Plugin_Should_Update_Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (r == JOptionPane.OK_OPTION) { if (r == JOptionPane.OK_OPTION) {
WebDialog.createPluginDialog(); WebViewDlgHelper.createPluginDialog();
} }
} }
timer.stop(); timer.stop();

12
designer_base/src/com/fr/start/StartServer.java

@ -45,10 +45,10 @@ public class StartServer {
* 预览Demo * 预览Demo
* 找默认工作目录不应该按照名字去找而应该按照安装路径因为默认工作目录的名字可能会改变 * 找默认工作目录不应该按照名字去找而应该按照安装路径因为默认工作目录的名字可能会改变
*/ */
public static void browerDemoURL() { public static void browserDemoURL() {
if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用
String web = GeneralContext.getCurrentAppNameOfEnv(); String web = GeneralContext.getCurrentAppNameOfEnv();
browerURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ConfigManager.getProviderInstance().getServletMapping() browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ConfigManager.getProviderInstance().getServletMapping()
+ "?op=fs"); + "?op=fs");
return; return;
} }
@ -65,16 +65,16 @@ public class StartServer {
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().errorWithServerLevel(e.getMessage()); FRContext.getLogger().errorWithServerLevel(e.getMessage());
} }
initDemoServerAndBrower(); initDemoServerAndBrowser();
} }
}).setVisible(true); }).setVisible(true);
} else { } else {
initDemoServerAndBrower(); initDemoServerAndBrowser();
} }
} }
private static void initDemoServerAndBrower() { private static void initDemoServerAndBrowser() {
if (jettyHost != null) { if (jettyHost != null) {
if (!jettyHost.isDemoAppLoaded()) { if (!jettyHost.isDemoAppLoaded()) {
jettyHost.exit(); jettyHost.exit();
@ -104,7 +104,7 @@ public class StartServer {
* *
* @param url 指定路径 * @param url 指定路径
*/ */
public static void browerURLWithLocalEnv(String url) { public static void browserURLWithLocalEnv(String url) {
try { try {
if (jettyHost != null) { if (jettyHost != null) {
if (NEED_LOAD_ENV) { if (NEED_LOAD_ENV) {

2
designer_chart/build.release.gradle

@ -48,7 +48,7 @@ def branchName=buildDir.substring(buildDir.lastIndexOf ('\\')+1)
// //
dependencies{ dependencies{
compile fileTree(dir:'../../../finereport-lib-stable/master',include:'**/*.jar') compile fileTree(dir:"../../../finereport-lib-stable/${branchName}",include:'**/*.jar')
compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar") compile fileTree(dir:'../../../',include:"finereport-*-stable/${branchName}/**/build/libs/*.jar")
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'

188
designer_chart/src/com/fr/design/ChartEnvManager.java

@ -1,188 +0,0 @@
package com.fr.design;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils;
import com.fr.general.IOUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.*;
import java.io.*;
import java.util.Date;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class ChartEnvManager implements XMLReadable, XMLWriter {
public static final String ACTIVE_KEY = "RXWY-A25421-K58F47757-7373";
private static final int ONE_MONTH_SECOND = 30*24*60*60;//30天,以秒为单位
private static final int MS =1000;
boolean isPushUpdateAuto = true; //是否自动推送更新
private String activationKey = null;
private static ChartEnvManager chartEnvManager;
private Date lastCheckDate;
private long checkTimeSpan =ONE_MONTH_SECOND;
/**
* DesignerEnvManager.
*/
public static ChartEnvManager getEnvManager() {
if(chartEnvManager == null){
chartEnvManager = new ChartEnvManager();
try {
XMLTools.readFileXML(chartEnvManager, chartEnvManager.getDesignerEnvFile());
}catch (Exception exp){
FRContext.getLogger().error(exp.getMessage(), exp);
}
}
return chartEnvManager;
}
private static File envFile = new File(ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "ChartEnv.xml");
private File getEnvFile() {
return envFile;
}
private File getDesignerEnvFile() {
File envFile = getEnvFile();
if (!envFile.exists()) {
createEnvFile(envFile);
}
return envFile;
}
private void createEnvFile(File envFile) {
try {
FileWriter fileWriter = new FileWriter(envFile);
StringReader stringReader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><Env></Env>");
Utils.copyCharTo(stringReader, fileWriter);
stringReader.close();
fileWriter.close();
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
/**
* 返回激活码
*/
public String getActivationKey() {
return activationKey;
}
/**
* 设置激活码
*/
public void setActivationKey(String activationKey) {
this.activationKey = activationKey;
}
public void setPushUpdateAuto(boolean isPushUpdateAuto){
this.isPushUpdateAuto = isPushUpdateAuto;
if(!this.isPushUpdateAuto){
lastCheckDate = new Date();
}
}
/**
* 是否设置了自动推送图表设计器在线更行
* @return 是则返回true
*/
public boolean isPushUpdateAuto(){
return isPushUpdateAuto;
}
/**
*在设置不自动推送在线更新的情况下每30天自动检测一次
* @return 是否需要检测
*/
public boolean isOverOneMonth(){
return !isPushUpdateAuto && ((new Date().getTime()-lastCheckDate.getTime())/MS>=checkTimeSpan);
}
/***
* 重新设置最新检查的日期
*/
public void resetCheckDate(){
this.lastCheckDate = new Date();
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String name = reader.getTagName();
if(ComparatorUtils.equals(name,"ChartAttributes")){
activationKey = reader.getAttrAsString("activationKey",null);
isPushUpdateAuto = reader.getAttrAsBoolean("isPushUpdateAuto",true);
checkTimeSpan = reader.getAttrAsLong("checkTimeSpan",ONE_MONTH_SECOND);
String date = reader.getAttrAsString("lastCheckDate", null);
if(!StringUtils.isEmpty(date)){
lastCheckDate = DateUtils.string2Date(date,true);
} else {
lastCheckDate = new Date();
}
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG("ChartDesigner");
writer.startTAG("ChartAttributes").attr("activationKey",activationKey)
.attr("isPushUpdateAuto",isPushUpdateAuto)
.attr("checkTimeSpan",checkTimeSpan)
.attr("lastCheckDate", DateUtils.getDate2LStr(lastCheckDate))
.end();
writer.end();
}
/**
* 保存设计器的配置文件, 该文件不在env的resource目录下
* 而是在Consts.getEnvHome() + File.separator + Consts.APP_NAME
*
*
* @date 2014-9-29-上午11:04:23
*/
public void saveXMLFile() {
File xmlFile = this.getDesignerEnvFile();
if (xmlFile == null) {
return;
}
if (!xmlFile.getParentFile().exists()) {//建立目录.
StableUtils.mkdirs(xmlFile.getParentFile());
}
String tempName = xmlFile.getName() + ProjectConstants.TEMP_SUFFIX;
File tempFile = new File(xmlFile.getParentFile(), tempName);
writeTempFile(tempFile);
IOUtils.renameTo(tempFile, xmlFile);
}
private void writeTempFile(File tempFile){
try{
OutputStream fout = new FileOutputStream(tempFile);
XMLTools.writeOutputStreamXML(this, fout);
fout.flush();
fout.close();
}catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
}

42
designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java

@ -11,9 +11,12 @@ import com.fr.design.chart.fun.IndependentChartUIProvider;
import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.chart.gui.ChartWidgetOption;
import com.fr.design.chartinterface.*; import com.fr.design.chartinterface.*;
import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.extra.ChartTypeInterfaceCloseableHandler;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.ChartsConfigPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
@ -21,11 +24,13 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.file.XMLFileManager; import com.fr.file.XMLFileManager;
import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ChartEditor;
import com.fr.general.*; import com.fr.general.FRLogger;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.plugin.PluginCollector; import com.fr.plugin.PluginCollector;
import com.fr.plugin.PluginLicenseManager; import com.fr.plugin.PluginLicenseManager;
import com.fr.plugin.PluginMessage; import com.fr.plugin.PluginMessage;
import com.fr.design.extra.ChartTypeInterfaceCloseableHandler;
import com.fr.plugin.proxy.PluginInstanceProxyFactory; import com.fr.plugin.proxy.PluginInstanceProxyFactory;
import com.fr.plugin.proxy.PluginInvocationHandler; import com.fr.plugin.proxy.PluginInvocationHandler;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -410,6 +415,39 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getTableDataSourcePane(plot, parent); return chartTypeInterfaces.get(priority).get(plot.getPlotID()).getTableDataSourcePane(plot, parent);
} }
//获取指定图表的编辑面板
public ChartEditPane getChartEditPane(String plotID) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String priority = (String) entry.getKey();
if (plotInChart(plotID, priority)) {
return getChartEditPane(priority, plotID);
}
}
return getChartEditPane(ChartTypeManager.CHART_PRIORITY, plotID);
}
private ChartEditPane getChartEditPane(String priority, String plotID) {
return chartTypeInterfaces.get(priority).get(plotID).getChartEditPane(plotID);
}
public ChartsConfigPane getChartConfigPane(String plotID) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String priority = (String) entry.getKey();
if (plotInChart(plotID, priority)) {
return getChartConfigPane(priority, plotID);
}
}
return getChartConfigPane(ChartTypeManager.CHART_PRIORITY, plotID);
}
private ChartsConfigPane getChartConfigPane(String priority, String plotID) {
return chartTypeInterfaces.get(priority).get(plotID).getChartConfigPane(plotID);
}
public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator(); Iterator iterator = chartTypeInterfaces.entrySet().iterator();

6
designer_chart/src/com/fr/design/chart/fun/IndependentChartUIProvider.java

@ -5,6 +5,8 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.ChartsConfigPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
@ -89,5 +91,9 @@ public interface IndependentChartUIProvider extends Level {
*/ */
String getPlotTypeTitle4PopupWindow(); String getPlotTypeTitle4PopupWindow();
ChartEditPane getChartEditPane(String plotID);
ChartsConfigPane getChartConfigPane(String plotID);
} }

10
designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java

@ -7,9 +7,12 @@ import com.fr.design.chart.series.SeriesCondition.DataSeriesConditionPane;
import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.ChartsConfigPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StableUtils;
/** /**
@ -30,6 +33,7 @@ public abstract class AbstractIndependentChartUI implements IndependentChartUIPr
public ChartDataPane getChartDataPane(AttributeChangeListener listener){ public ChartDataPane getChartDataPane(AttributeChangeListener listener){
return new ChartDataPane(listener); return new ChartDataPane(listener);
} }
/** /**
* 是否使用默认的界面为了避免界面来回切换 * 是否使用默认的界面为了避免界面来回切换
* @return 是否使用默认的界面 * @return 是否使用默认的界面
@ -53,4 +57,10 @@ public abstract class AbstractIndependentChartUI implements IndependentChartUIPr
public ConditionAttributesPane getPlotConditionPane(Plot plot){ public ConditionAttributesPane getPlotConditionPane(Plot plot){
return new DataSeriesConditionPane(); return new DataSeriesConditionPane();
} }
public ChartEditPane getChartEditPane(String plotID){ return StableUtils.construct(ChartEditPane.class);}
public ChartsConfigPane getChartConfigPane(String plotID){return null;}
} }

7
designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java

@ -7,9 +7,12 @@ import com.fr.design.chart.series.SeriesCondition.DataSeriesConditionPane;
import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.ChartsConfigPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StableUtils;
/** /**
* Created by Mitisky on 16/3/7. * Created by Mitisky on 16/3/7.
@ -65,4 +68,8 @@ public abstract class AbstractIndependentChartUIWithAPILevel implements Independ
public String getPlotTypeTitle4PopupWindow(){ public String getPlotTypeTitle4PopupWindow(){
return getPlotTypePane().title4PopupWindow(); return getPlotTypePane().title4PopupWindow();
} }
public ChartEditPane getChartEditPane(String plotID){ return StableUtils.construct(ChartEditPane.class);}
public ChartsConfigPane getChartConfigPane(String plotID){return null;}
} }

103
designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java

@ -0,0 +1,103 @@
package com.fr.design.chart.fun.impl;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chart.fun.IndependentChartUIProvider;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.ChartsEditPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.report.CategoryPlotReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.mainframe.chart.gui.type.PiePlotPane;
import com.fr.general.ComparatorUtils;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* Created by mengao on 2017/4/24.
* 用户使用第三方图表需要继承的面板抽象类
*/
@API(level = IndependentChartUIProvider.CURRENT_API_LEVEL)
public abstract class AbstractIndependentChartsUI extends AbstractProvider implements IndependentChartUIProvider {
public String mark4Provider() {
return getClass().getName();
}
@Override
public AbstractChartTypePane getPlotTypePane() {
return new PiePlotPane();
}
@Override
public ChartDataPane getChartDataPane(AttributeChangeListener listener) {
return new ChartDataPane(listener);
}
@Override
public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) {
return new CategoryPlotTableDataContentPane(parent);
}
@Override
public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) {
return new CategoryPlotReportDataContentPane(parent);
}
public BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot){
return null;
}
public BasicBeanPane<Plot> getPlotSeriesPane(){
return null;
}
public boolean equals(Object obj) {
return obj != null && ComparatorUtils.equals(obj.getClass(), this.getClass());
}
public ConditionAttributesPane getPlotConditionPane(Plot plot){
return null;
}
@Override
public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){
return new AbstractChartAttrPane[]{};
}
@Override
public boolean isUseDefaultPane(){
return false;
}
@Override
public String getIconPath() {
return "com/fr/design/images/form/toolbar/ChartF-Column.png";
}
@Override
/**
* plot面板的标题
* 插件兼容
*/
public String getPlotTypeTitle4PopupWindow(){
return getPlotTypePane().title4PopupWindow();
}
@Override
public ChartEditPane getChartEditPane(String plotID) {
return new ChartsEditPane();
}
}

69
designer_chart/src/com/fr/design/chart/report/GisMapDataPane4Chart.java

@ -1,69 +0,0 @@
package com.fr.design.chart.report;
import com.fr.base.TableData;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartdata.*;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.AbstractChartDataPane4Chart;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import javax.swing.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class GisMapDataPane4Chart extends AbstractChartDataPane4Chart {
private GisMapTableDataContentPane4Chart tablePane = new GisMapTableDataContentPane4Chart();
public GisMapDataPane4Chart(AttributeChangeListener listener, ChartDataPane parent) {
super(listener, parent);
}
protected JPanel getDataContentPane() {
return tablePane;
}
@Override
public void populate(ChartCollection collection) {
tablePane = new GisMapTableDataContentPane4Chart();
if (collection != null && collection.getSelectedChart() != null) {
Chart chart = collection.getSelectedChart();
TopDefinitionProvider definition = chart.getFilterDefinition();
if (definition instanceof TableDataDefinition) {
TableData tableData = ((TableDataDefinition) definition).getTableData();
if (tableData != null) {
populateChoosePane(tableData);
fireTableDataChange();
}
}
if (definition instanceof GisMapTableDefinition) {
tablePane.populateBean((GisMapTableDefinition) definition);
}
}
this.remove(leftContentPane);
this.initContentPane();
this.validate();
dataSource.addItemListener(dsListener);
initAllListeners();
initSelfListener(tablePane);
this.addAttributeChangeListener(attributeChangeListener);
}
@Override
public void update(ChartCollection collection) {
collection.getSelectedChart().setFilterDefinition(tablePane.updateBean());
}
/**
* 数据集数据改变
*/
public void fireTableDataChange() {
tablePane.fireTableDataChange(choosePane.getTableDataWrapper());
}
}

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

@ -1,341 +0,0 @@
package com.fr.design.chart.report;
import com.fr.base.Utils;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartdata.GisMapTableDefinition;
import com.fr.chart.chartdata.SeriesDefinition;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class GisMapTableDataContentPane4Chart extends FurtherBasicBeanPane<GisMapTableDefinition> implements UIObserver {
private ArrayList<ChangeListener> changeListeners = new ArrayList<ChangeListener>();
private String[] initNames = {""};
private UIButtonGroup<String> addressType;
private UIButtonGroup<String> lnglatOrder;
private UIComboBox addressBox;
private UIComboBox addressNameBox;
private UICorrelationPane titleValuePane;
private JPanel orderPane;
private TableDataWrapper tableDataWrapper;
public GisMapTableDataContentPane4Chart() {
this.setLayout(new BorderLayout());
addressType = new UIButtonGroup<String>(new String[]{Inter.getLocText("Chart-Gis_Address"), Inter.getLocText("Chart-Gis_LatLng")});
lnglatOrder = new UIButtonGroup<String>(new String[]{Inter.getLocText("Chart-Lng_First"), Inter.getLocText("Chart-Lat_First")});
addressBox = new UIComboBox();
addressNameBox = new UIComboBox();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = new double[]{p, f};
double[] rowSize = new double[]{p, p, p};
orderPane = new JPanel(new BorderLayout(LayoutConstants.VGAP_MEDIUM, 0)) {
@Override
public Dimension getPreferredSize() {
if (this.isVisible()) {
return super.getPreferredSize();
} else {
return new Dimension(0, 0);
}
}
};
orderPane.add(new UILabel(Inter.getLocText("Chart-LatLng_Order")), BorderLayout.WEST);
orderPane.add(lnglatOrder, BorderLayout.CENTER);
orderPane.setVisible(false);
lnglatOrder.setSelectedIndex(0);
addressType.setSelectedIndex(0);
addressNameBox.removeAllItems();
addressNameBox.addItem(Inter.getLocText("Chart-Use_None"));
Component[][] components = new Component[][]{
new Component[]{addressType, addressBox},
new Component[]{orderPane, null},
new Component[]{new UILabel(Inter.getLocText("Chart-Address_Name") + ":", SwingConstants.RIGHT), addressNameBox},
};
JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
JPanel pane = new JPanel();
this.add(pane, BorderLayout.CENTER);
pane.setLayout(new BorderLayout());
pane.add(centerPane, BorderLayout.NORTH);
String[] titles = {Inter.getLocText("Chart-Area_Title"), Inter.getLocText("Chart-Area_Value")};
titleValuePane = new UICorrelationPane(titles) {
public UITableEditor createUITableEditor() {
return new InnerTableEditor();
}
};
pane.add(titleValuePane, BorderLayout.CENTER);
}
private void refresh2ComboBox() {// 刷新地址 地址名 名称列表
TableDataWrapper tableDataWrappe =tableDataWrapper;
if (tableDataWrappe == null) {
return;
}
java.util.List<String> columnNameList = tableDataWrappe.calculateColumnNameList();
initNames = columnNameList.toArray(new String[columnNameList.size()]);
addressBox.removeAllItems();
addressNameBox.removeAllItems();
addressNameBox.addItem(Inter.getLocText("Chart-Use_None"));
for (int i = 0, size = initNames.length; i < size; i++) {
addressBox.addItem(initNames[i]);
addressNameBox.addItem(initNames[i]);
}
if(initNames.length > 0){
addressBox.setSelectedIndex(0);
}
addressNameBox.setSelectedIndex(0);
stopEditing();
}
/**
* 界面接入
*
* @param ob 对象
* @return true表示接受
*/
public boolean accept(Object ob) {
return false;
}
/**
* 界面重置
*/
public void reset() {
}
/**
* 界面弹出标题
*
* @return 标题
*/
public String title4PopupWindow() {
return Inter.getLocText("Chart-DS_TableData");
}
private void stopEditing() {
}
@Override
public void populateBean(GisMapTableDefinition ob) {
stopEditing();
if (ob instanceof GisMapTableDefinition) {
GisMapTableDefinition mapDefinition = (GisMapTableDefinition) ob;
if (ob.isAddress()) {
addressType.setSelectedIndex(0);
orderPane.setVisible(false);
} else {
addressType.setSelectedIndex(1);
orderPane.setVisible(true);
}
if (ob.isLngFirst()) {
lnglatOrder.setSelectedIndex(0);
} else {
lnglatOrder.setSelectedIndex(1);
}
addressBox.setSelectedItem(mapDefinition.getAddress());
if (StringUtils.isEmpty(mapDefinition.getAddressName())) {
addressNameBox.setSelectedItem(Inter.getLocText("Chart-Use_None"));
} else {
addressNameBox.setSelectedItem(mapDefinition.getAddressName());
}
java.util.List paneList = new ArrayList();
int titleValueSize = mapDefinition.getTittleValueSize();
for (int i = 0; i < titleValueSize; i++) {
SeriesDefinition definition = mapDefinition.getTittleValueWithIndex(i);
if (definition != null && definition.getSeriesName() != null && definition.getValue() != null) {
paneList.add(new Object[]{definition.getSeriesName(), definition.getValue()});
}
}
if (!paneList.isEmpty()) {
titleValuePane.populateBean(paneList);
}
}
}
@Override
public GisMapTableDefinition updateBean() {// 从一行内容中update
stopEditing();
GisMapTableDefinition definition = new GisMapTableDefinition();
TableDataWrapper tableDataWrappe = tableDataWrapper;
if (tableDataWrappe == null || addressBox.getSelectedItem() == null) {
return null;
}
definition.setTableData(tableDataWrapper.getTableData());
definition.setAddress(Utils.objectToString(addressBox.getSelectedItem()));
if (this.addressType.getSelectedIndex() == 0) {
definition.setAddressType(true);
lnglatOrder.setVisible(false);
} else {
definition.setAddressType(false);
lnglatOrder.setVisible(true);
}
if (this.lnglatOrder.getSelectedIndex() == 0) {
definition.setLnglatOrder(true);
} else {
definition.setLnglatOrder(false);
}
if (addressNameBox.getSelectedItem() != null) {
String adName = Utils.objectToString(addressNameBox.getSelectedItem());
if (ArrayUtils.contains(ChartConstants.getNoneKeys(), adName)) {
definition.setAddressName(StringUtils.EMPTY);
} else {
definition.setAddressName(adName);
}
}
java.util.List paneList = titleValuePane.updateBean();
for (int i = 0, size = paneList.size(); i < size; i++) {
Object[] values = (Object[]) paneList.get(i);
if (values.length == 2) {
SeriesDefinition seriesDefinition = new SeriesDefinition();
seriesDefinition.setSeriesName(values[0]);
seriesDefinition.setValue(values[1]);
definition.addTittleValue(seriesDefinition);
}
}
return definition;
}
/**
* 给组件登记一个观察者监听事件
*
* @param listener 观察者监听事件
*/
public void registerChangeListener(final UIObserverListener listener) {
changeListeners.add(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
}
/**
* 组件是否需要响应添加的观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
public boolean shouldResponseChangeListener() {
return true;
}
private class InnerTableEditor extends UITableEditor {
private JComponent editorComponent;
/**
* 返回当前编辑器的值
*/
public Object getCellEditorValue() {
if (editorComponent instanceof UITextField) {
UITextField textField = (UITextField) editorComponent;
return textField.getText();
} else if (editorComponent instanceof UIComboBox) {
UIComboBox boxPane = (UIComboBox) editorComponent;
return boxPane.getSelectedItem();
}
return super.getCellEditorValue();
}
/**
* 返回当前编辑器..
*/
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (column == table.getModel().getColumnCount()) {
return null;
}
if (column == 0) {
UITextField text = new UITextField();
if (value != null) {
text.setText(Utils.objectToString(value));
}
text.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
titleValuePane.stopCellEditing();
titleValuePane.fireTargetChanged();
}
});
this.editorComponent = text;
} else {
UIComboBox box = new UIComboBox(initNames);
box.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
titleValuePane.fireTargetChanged();
titleValuePane.stopCellEditing();
}
});
if (value != null && StringUtils.isNotEmpty(value.toString())) {
box.setSelectedItem(value);
} else {
box.setSelectedItem(value);
}
this.editorComponent = box;
}
return this.editorComponent;
}
}
/**
* 出发数据集改变
* @param wrapper 数据集
*/
public void fireTableDataChange(TableDataWrapper wrapper){
this.tableDataWrapper = wrapper;
refresh2ComboBox();
}
}

68
designer_chart/src/com/fr/design/chart/report/MapCubeDataPane4Chart.java

@ -1,68 +0,0 @@
package com.fr.design.chart.report;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartdata.MapMoreLayerTableDefinition;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.general.Inter;
import java.awt.*;
import java.util.*;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class MapCubeDataPane4Chart extends UIComboBoxPane<TopDefinitionProvider> {
private MapTableCubeDataPane4Chart tablePane;
protected void initLayout() {
this.setLayout(new BorderLayout(0, 0));
this.add(cardPane, BorderLayout.CENTER);
}
@Override
protected List<FurtherBasicBeanPane<? extends TopDefinitionProvider>> initPaneList() {
List list = new ArrayList();
list.add(tablePane = new MapTableCubeDataPane4Chart());
return list;
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Chart-Map_LayerData");
}
/**
* 对数据集或者单元格数据加载界面
*/
public void populateBean(TopDefinitionProvider definition) {
if(definition instanceof MapMoreLayerTableDefinition) {
MapMoreLayerTableDefinition tableDefinition = (MapMoreLayerTableDefinition)definition;
this.setSelectedIndex(0);
tablePane.populateBean(tableDefinition);
}
}
/**
* 根据界面 下载保存数据
*/
public TopDefinitionProvider update() {
return tablePane.updateBean();
}
/**
* 出发数据集改变
* @param tableDataWrapper 数据集
*/
public void fireTableDataChanged(TableDataWrapper tableDataWrapper) {
tablePane.setTableDataWrapper(tableDataWrapper);
tablePane.refreshAreaNameBox();
}
}

133
designer_chart/src/com/fr/design/chart/report/MapDataPane4Chart.java

@ -1,133 +0,0 @@
package com.fr.design.chart.report;
import com.fr.base.TableData;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartdata.*;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.mainframe.AbstractChartDataPane4Chart;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* Date: 14/12/3
* Time: 下午6:49
*/
public class MapDataPane4Chart extends AbstractChartDataPane4Chart {
private UIComboBoxPane dataContentPane;
private MapMoreCubeLayerPane4Chart morePane = new MapMoreCubeLayerPane4Chart();
private MapSinglePane4Chart singlePane = new MapSinglePane4Chart();
private ChartCollection currentCollection;
private ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
fireTableDataChange();
}
};
public MapDataPane4Chart(AttributeChangeListener listener, ChartDataPane parent) {
super(listener, parent);
dataContentPane = new UIComboBoxPane<Chart>() {
protected void initLayout() {
this.setLayout(new BorderLayout(0, 6));
JPanel northPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
northPane.add(new BoldFontTextLabel(Inter.getLocText("FR-Chart-Map_ShowWay") + ":"));
northPane.add(jcb);
this.add(northPane, BorderLayout.NORTH);
this.add(cardPane, BorderLayout.CENTER);
}
protected java.util.List<FurtherBasicBeanPane<? extends Chart>> initPaneList() {
java.util.List list = new ArrayList();
list.add(singlePane);
list.add(morePane);
return list;
}
protected void comboBoxItemStateChanged() {
if(currentCollection == null){
return;
}
fireTableDataChange();
morePane.init4PopuMapTree(currentCollection);
}
protected String title4PopupWindow() {
return Inter.getLocText(new String[]{"Chart-Map", "Data"});
}
};
}
protected JPanel getDataContentPane(){
return dataContentPane;
}
@Override
public void populate(ChartCollection collection) {
currentCollection = collection;
morePane.init4PopuMapTree(collection);
if (collection != null && collection.getSelectedChart() != null) {
Chart chart = collection.getSelectedChart();
TopDefinitionProvider definition = chart.getFilterDefinition();
if (definition instanceof TableDataDefinition) {
TableData tableData = ((TableDataDefinition) definition).getTableData();
if(tableData != null){
populateChoosePane(tableData);
fireTableDataChange();
}
}
if(definition instanceof MapSingleLayerTableDefinition) {
singlePane.populateBean(definition);
} else if(definition instanceof MapMoreLayerTableDefinition) {
morePane.populateBean(collection);
}
}
this.remove(leftContentPane);
this.initContentPane();
this.validate();
dataSource.addItemListener(dsListener);
initAllListeners();
initSelfListener(dataContentPane);
this.addAttributeChangeListener(attributeChangeListener);
}
@Override
public void update(ChartCollection collection) {
if(dataContentPane.getSelectedIndex() == 0) {
collection.getSelectedChart().setFilterDefinition(singlePane.updateBean());
} else {
morePane.updateBean(collection);
}
currentCollection = collection;
}
/**
* 数据集数据改变
*/
public void fireTableDataChange() {
if (dataContentPane == null) {
return;
}
if(dataContentPane.getSelectedIndex() == 0) {
singlePane.fireTableDataChanged(choosePane.getTableDataWrapper());
} else {
morePane.fireTableDataChanged(choosePane.getTableDataWrapper());
}
}
}

113
designer_chart/src/com/fr/design/chart/report/MapMoreCubeLayerPane4Chart.java

@ -1,113 +0,0 @@
package com.fr.design.chart.report;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.MapPlot;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.MultiTabPane;
import com.fr.general.Inter;
import java.util.ArrayList;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class MapMoreCubeLayerPane4Chart extends MultiTabPane<ChartCollection> {
private static final long serialVersionUID = -174286187746442527L;
private MapCubeLayerPane layerPane;
private MapCubeDataPane4Chart dataPane;
@Override
protected List<BasicPane> initPaneList() {
List<BasicPane> paneList = new ArrayList<BasicPane>();
paneList.add(layerPane = new MapCubeLayerPane());
paneList.add(dataPane = new MapCubeDataPane4Chart());
return paneList;
}
public ChartCollection updateBean() {
return null;// do nothing
}
public void populateBean(ChartCollection collection) {
Chart selectChart = collection.getSelectedChart();
if(selectChart != null && selectChart.getPlot() instanceof MapPlot) {
MapPlot map = (MapPlot)selectChart.getPlot();
layerPane.populateBean(map.getMapName());
}
// 确认层级关系
dataPane.populateBean(collection.getSelectedChart().getFilterDefinition());
}
public void updateBean(ChartCollection collection) {
collection.getSelectedChart().setFilterDefinition(dataPane.update());
Chart selectChart = collection.getSelectedChart();
if(selectChart != null && selectChart.getPlot() instanceof MapPlot) {
MapPlot map = (MapPlot)selectChart.getPlot();
layerPane.updateBean(map.getMapName());// 确定更新地图名称所对应的层级关系
}
}
/**
* 刷新层级树 数据中populate 数据的层数
* @param collection 图表收集器.
*/
public void init4PopuMapTree(ChartCollection collection) {
Chart selectChart = collection.getSelectedChart();
if(selectChart != null && selectChart.getPlot() instanceof MapPlot) {
MapPlot map = (MapPlot)selectChart.getPlot();
if(layerPane != null) {
layerPane.initRootTree(map.getMapName());
}
}
}
/**
* 判断是否合格
* @param ob 参数判断
* @return 默认合格.
*/
public boolean accept(Object ob) {
return true;
}
/**
* 界面标题
* @return 返回标题
*/
public String title4PopupWindow() {
return Inter.getLocText("FR-Chart-Map_Multilayer");
}
/**
* 重置
*/
public void reset() {
}
/**
* 设置是否支持单元格数据.
*/
public void setSurpportCellData(boolean surpportCellData) {
dataPane.justSupportOneSelect(surpportCellData);
}
/**
* 出发数据集改变
* @param tableDataWrapper 数据集
*/
public void fireTableDataChanged(TableDataWrapper tableDataWrapper) {
dataPane.fireTableDataChanged(tableDataWrapper);
}
}

79
designer_chart/src/com/fr/design/chart/report/MapSinglePane4Chart.java

@ -1,79 +0,0 @@
package com.fr.design.chart.report;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartdata.MapSingleLayerTableDefinition;
import com.fr.chart.chartdata.TopDefinition;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.general.Inter;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class MapSinglePane4Chart extends FurtherBasicBeanPane<TopDefinitionProvider> {
private MapTableDataSinglePane4Chart tableSinglePane;
public MapSinglePane4Chart() {
initCom();
}
private void initCom() {
this.setLayout(new BorderLayout());
this.add(tableSinglePane = new MapTableDataSinglePane4Chart(), BorderLayout.CENTER);
}
/**
* 判断准许的情况
* @param ob 数据集
* @return 是不是顶层数据
*/
public boolean accept(Object ob) {
return ob instanceof TopDefinition;
}
/**
* 重置
*/
public void reset() {
}
/**
*界面标题
* @return 界面标题
*/
public String title4PopupWindow() {
return Inter.getLocText(new String[]{"SingleLayer", "Chart-Map"});
}
/**
* 加载单层地图时的 数据来源界面
*/
public void populateBean(TopDefinitionProvider ob) {
if(ob instanceof MapSingleLayerTableDefinition) {
tableSinglePane.populateBean((MapSingleLayerTableDefinition)ob);
}
}
/**
* 保存下载 单层数据界面
*/
public TopDefinitionProvider updateBean() {
return tableSinglePane.updateBean();
}
/**
* 出发数据集改变
* @param tableDataWrapper 数据集
*/
public void fireTableDataChanged(TableDataWrapper tableDataWrapper) {
tableSinglePane.setTableDataWrapper(tableDataWrapper);
tableSinglePane.refreshAreaNameBox();
}
}

93
designer_chart/src/com/fr/design/chart/report/MapTableCubeDataPane4Chart.java

@ -1,93 +0,0 @@
package com.fr.design.chart.report;
import com.fr.chart.chartdata.MapMoreLayerTableDefinition;
import com.fr.chart.chartdata.MapSingleLayerTableDefinition;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.general.Inter;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class MapTableCubeDataPane4Chart extends FurtherBasicBeanPane<MapMoreLayerTableDefinition> {
private MapMoreTableIndexPane tablePane;
private TableDataWrapper tableDataWrapper;
public MapTableCubeDataPane4Chart() {
this.setLayout(new BorderLayout());
tablePane = new MapMoreTableIndexPane();
this.add(tablePane, BorderLayout.CENTER);
}
/**
* 刷新区域名称列表
*/
public void refreshAreaNameBox() {
TableDataWrapper tableDataWrappe = tableDataWrapper;
if (tableDataWrappe == null) {
return;
}
java.util.List<String> columnNameList = tableDataWrappe.calculateColumnNameList();
tablePane.initAreaComBox(columnNameList.toArray(new String[columnNameList.size()]));
}
public void setTableDataWrapper(TableDataWrapper wrapper){
this.tableDataWrapper = wrapper;
}
/**
* 界面接入
* @param ob 界面
* @return 返回接入.
*/
public boolean accept(Object ob) {
return true;
}
/**
* 重置
*/
public void reset() {
}
/**
* 界面弹出标题
* @return 返回标题.
*/
public String title4PopupWindow() {
return Inter.getLocText("FR-Chart-Table_Data");
}
@Override
public void populateBean(MapMoreLayerTableDefinition tableDefinition) {
if (tableDefinition != null) {
MapSingleLayerTableDefinition[] values = tableDefinition.getNameValues();
if(values != null && values.length > 0) {
tablePane.populateBean(values[0]);
}
}
}
@Override
public MapMoreLayerTableDefinition updateBean() {
MapMoreLayerTableDefinition tableDefinition = new MapMoreLayerTableDefinition();
TableDataWrapper tableDataWrappe =tableDataWrapper;
if (tableDataWrappe != null) {
tableDefinition.setTableData(tableDataWrappe.getTableData());
tableDefinition.clearNameValues();
tableDefinition.addNameValue(tablePane.updateBean());
}
return tableDefinition;
}
}

268
designer_chart/src/com/fr/design/chart/report/MapTableDataSinglePane4Chart.java

@ -1,268 +0,0 @@
package com.fr.design.chart.report;
import com.fr.base.Utils;
import com.fr.chart.chartdata.MapSingleLayerTableDefinition;
import com.fr.chart.chartdata.SeriesDefinition;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.UICorrelationPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.UITableEditor;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class MapTableDataSinglePane4Chart extends FurtherBasicBeanPane<MapSingleLayerTableDefinition> implements UIObserver {
private static final int LABEL_WIDTH_GAP = 5;
private static final int COM_HEIGHT = 20;
private ArrayList<ChangeListener> changeListeners = new ArrayList<ChangeListener>();
private String[] initNames = {""};
private UIComboBox areaNameBox;
private UICorrelationPane titleValuePane;
private TableDataWrapper tableDataWrapper;
public MapTableDataSinglePane4Chart() {
this.setLayout(new BorderLayout());
JPanel pane = new JPanel();
this.add(pane, BorderLayout.CENTER);
pane.setLayout(new BorderLayout());
pane.add(getAreaNamePane(), BorderLayout.NORTH);
String[] titles = {Inter.getLocText("FR-Chart-Area_Title"), Inter.getLocText("FR-Chart-Area_Value")};
titleValuePane = new UICorrelationPane(titles){
public UITableEditor createUITableEditor() {
return new InnerTableEditor();
}
};
pane.add(titleValuePane, BorderLayout.CENTER);
}
private JPanel getAreaNamePane(){
final UILabel label = new BoldFontTextLabel(Inter.getLocText("FR-Chart-Map_ShowWay") + ":");
UILabel nameLabel = new UILabel(Inter.getLocText("FR-Chart-Area_Name") + ":", SwingConstants.RIGHT){
public Dimension getPreferredSize() {
return new Dimension(label.getPreferredSize().width+LABEL_WIDTH_GAP,COM_HEIGHT);
}
};
areaNameBox = new UIComboBox();
areaNameBox.setPreferredSize(new Dimension(80, 20));
double p =TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p};
Component[][] components = new Component[][]{
new Component[]{nameLabel, areaNameBox},
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
/**
*刷新区域名称列表
*/
public void refreshAreaNameBox() {// 刷新区域名称列表
TableDataWrapper tableDataWrappe = tableDataWrapper;
if (tableDataWrappe == null) {
return;
}
java.util.List<String> columnNameList = tableDataWrappe.calculateColumnNameList();
initNames = columnNameList.toArray(new String[columnNameList.size()]);
Object oldSelected = areaNameBox.getSelectedItem();
areaNameBox.removeAllItems();
for(int i = 0, size = initNames.length; i < size; i++) {
areaNameBox.addItem(initNames[i]);
}
areaNameBox.getModel().setSelectedItem(oldSelected);
stopEditing();
}
/**
* 是否接受数据集
* @param ob 具体变量
* @return 不是
*/
public boolean accept(Object ob) {
return false;
}
/**
* 界面重置
*/
public void reset() {
}
/**
* 界面弹出标题
* @return 标题
*/
public String title4PopupWindow() {
return Inter.getLocText("FR-Chart-Table_Data");
}
private void stopEditing() {
}
@Override
public void populateBean(MapSingleLayerTableDefinition ob) {
stopEditing();
if (ob instanceof MapSingleLayerTableDefinition) {
MapSingleLayerTableDefinition mapDefinition = (MapSingleLayerTableDefinition) ob;
// fromTableData.populateBean(((NameTableData) mapDefinition.getTableData()));
areaNameBox.setSelectedItem(mapDefinition.getAreaName());
java.util.List paneList = new ArrayList();
int titleValueSize = mapDefinition.getTitleValueSize();
for(int i = 0; i < titleValueSize; i++) {
SeriesDefinition definition = mapDefinition.getTitleValueWithIndex(i);
if(definition != null && definition.getSeriesName() != null && definition.getValue() != null) {
paneList.add(new Object[]{definition.getSeriesName(), definition.getValue()});
}
}
if(!paneList.isEmpty()) {
titleValuePane.populateBean(paneList);
}
}
}
@Override
public MapSingleLayerTableDefinition updateBean() {// 从一行内容中update
stopEditing();
MapSingleLayerTableDefinition definition = new MapSingleLayerTableDefinition();
TableDataWrapper tableDataWrappe = tableDataWrapper;
// = fromTableData.getTableDataWrapper();
if (tableDataWrappe == null || areaNameBox.getSelectedItem() == null) {
return null;
}
definition.setTableData(tableDataWrapper.getTableData());
definition.setAreaName(Utils.objectToString(areaNameBox.getSelectedItem()));
java.util.List paneList = titleValuePane.updateBean();
for(int i = 0, size = paneList.size(); i < size; i++) {
Object[] values = (Object[])paneList.get(i);
if(values.length == 2) {
SeriesDefinition seriesDefinition = new SeriesDefinition();
seriesDefinition.setSeriesName(values[0]);
seriesDefinition.setValue(values[1]);
definition.addTitleValue(seriesDefinition);
}
}
return definition;
}
/**
* 给组件登记一个观察者监听事件
*
* @param listener 观察者监听事件
*/
public void registerChangeListener(final UIObserverListener listener) {
changeListeners.add(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
}
/**
* 组件是否需要响应添加的观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
public boolean shouldResponseChangeListener() {
return true;
}
private class InnerTableEditor extends UITableEditor {
private JComponent editorComponent;
/**
* 返回当前编辑器的值
*/
public Object getCellEditorValue() {
if(editorComponent instanceof UITextField) {
UITextField textField = (UITextField)editorComponent;
return textField.getText();
} else if(editorComponent instanceof UIComboBox) {
UIComboBox boxPane = (UIComboBox)editorComponent;
return boxPane.getSelectedItem();
}
return super.getCellEditorValue();
}
/**
* 返回当前编辑器..
*/
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (column == table.getModel().getColumnCount()) {
return null;
}
if(column == 0 ) {
UITextField text = new UITextField();
if(value != null) {
text.setText(Utils.objectToString(value));
}
text.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
titleValuePane.fireTargetChanged();
}
});
this.editorComponent = text;
} else {
UIComboBox box = new UIComboBox(initNames);
box.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
titleValuePane.fireTargetChanged();
titleValuePane.stopCellEditing();
}
});
if (value != null && StringUtils.isNotEmpty(value.toString())) {
box.setSelectedItem(value);
} else {
box.setSelectedItem(value);
}
this.editorComponent = box;
}
return this.editorComponent;
}
}
public void setTableDataWrapper(TableDataWrapper wrapper){
this.tableDataWrapper = wrapper;
}
}

244
designer_chart/src/com/fr/design/mainframe/AbstractChartDataPane4Chart.java

@ -1,244 +0,0 @@
package com.fr.design.mainframe;
import com.fr.base.TableData;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartdata.JSONTableData;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.ExcelTableData;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.*;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* Date: 14/12/3
* Time: 下午6:53
*/
public class AbstractChartDataPane4Chart extends DataContentsPane implements UIObserver {
private static final int DATA_SOURCE_GAP = 18;
private static final int WIDTH = 262;
protected ChartDataPane parentPane;
protected ChartDesignDataLoadPane choosePane;
protected JComponent choose = new UILabel();
protected UIObserverListener observerListener;
protected UIComboBox dataSource = new UIComboBox(
new String[]{"JSON" + Inter.getLocText("Chart-DS_TableData"), Inter.getLocText("Chart-Use_Local") + "EXCEL", Inter.getLocText("Chart-DS_Embedded_TableData")});
protected ItemListener dsListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
int index = dataSource.getSelectedIndex();
if (index == 0) {
initJSON();
} else if (index == 1) {
initExcel();
} else {
initEmbbed();
}
remove(leftContentPane);
clearTableDataSetting();
initContentPane();
AbstractChartDataPane4Chart.this.validate();
}
};
protected AttributeChangeListener attributeChangeListener;
public AbstractChartDataPane4Chart(final AttributeChangeListener listener, ChartDataPane parent) {
this.parentPane = parent;
this.attributeChangeListener = listener;
initJSON();
initAll();
}
protected void populateChoosePane(TableData tableData) {
dataSource.removeItemListener(dsListener);
if (tableData instanceof JSONTableData) {
initJSON();
dataSource.setSelectedIndex(0);
} else if (tableData instanceof ExcelTableData) {
initExcel();
dataSource.setSelectedIndex(1);
} else if (tableData instanceof EmbeddedTableData) {
initEmbbed();
dataSource.setSelectedIndex(2);
}
choosePane.populateChartTableData(tableData);
dataSource.addItemListener(dsListener);
}
protected void initJSON() {
choosePane = new JSONDataPane(this);
UILabel url = new UILabel("URL:");
url.setHorizontalAlignment(SwingConstants.RIGHT);
choose = url;
}
protected void initExcel() {
choose = new UIButton(Inter.getLocText("Chart-Select_Path"));
choosePane = new ExcelDataPane(this, choose);
}
protected void initEmbbed() {
choosePane = new EmbbeddDataPane(this);
choose = null;
}
@Override
public void setSupportCellData(boolean supportCellData) {
}
@Override
protected JPanel createContentPane() {
double p = TableLayout.PREFERRED;
double[] columnSize = {WIDTH};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("Chart-Data_Import"))},
new Component[]{createDataImportPane()}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
private JPanel createDataImportPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{
new Component[]{createDataSourcePane()},
new Component[]{new JSeparator()},
new Component[]{createDataSetPane()}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
/**
* 数据配置面板
*
* @return
*/
protected JPanel createDataSetPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("Chart-Data_Configuration"))},
new Component[]{getDataContentPane()}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
protected JPanel getDataContentPane() {
return new JPanel();
}
private JPanel createDataSourcePane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {DATA_SOURCE_GAP, f};
double[] rowSize = {p,};
Component[][] components = new Component[][]{
new Component[]{null, createChooseBoxPane()},
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
private JPanel createChooseBoxPane() {
UILabel dataSourceLabel = new UILabel(Inter.getLocText("Chart-Data_Resource") + ":");
dataSourceLabel.setHorizontalAlignment(SwingConstants.RIGHT);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{dataSourceLabel, dataSource},
new Component[]{choose, choosePane}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
/**
* 注册观察者监听事件
*
* @param listener 观察者监听事件
*/
public void registerChangeListener(UIObserverListener listener) {
this.observerListener = listener;
}
/**
* 使用应该响应listener
*
* @return 应该响应
*/
public boolean shouldResponseChangeListener() {
return true;
}
protected void initSelfListener(Container parentComponent) {
for (int i = 0; i < parentComponent.getComponentCount(); i++) {
Component tmpComp = parentComponent.getComponent(i);
if (tmpComp instanceof Container) {
initListener((Container) tmpComp);
}
if (tmpComp instanceof UIObserver) {
((UIObserver) tmpComp).registerChangeListener(observerListener);
}
}
}
@Override
public void populate(ChartCollection collection) {
}
@Override
public void update(ChartCollection collection) {
}
/**
* 清空数据集的设置
*/
public void clearTableDataSetting() {
}
/**
* 数据集数据改变
*/
public void fireTableDataChange() {
}
}

111
designer_chart/src/com/fr/design/mainframe/AbstractMapPlotPane4ToolBar.java

@ -1,111 +0,0 @@
package com.fr.design.mainframe;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.MapSvgXMLHelper;
import com.fr.chart.chartattr.*;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.chart.ChartDesignEditPane;
import com.fr.general.ComparatorUtils;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* Date: 14/12/1
* Time: 下午3:15
*/
public abstract class AbstractMapPlotPane4ToolBar extends JPanel{
protected static final int COM_HEIGHT = 22;
protected static final int COM_GAP = 14;
protected static final int COMBOX_WIDTH = 230;
protected ChartDesigner chartDesigner;
protected UIComboBox mapTypeComboBox;
protected ItemListener mapTypeListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
calculateDetailMaps(mapTypeComboBox.getSelectedIndex());
}
};
public AbstractMapPlotPane4ToolBar(ChartDesigner designer){
this.chartDesigner = designer;
this.setLayout(new FlowLayout(FlowLayout.LEFT, COM_GAP, 0));
this.setBorder(new EmptyBorder(2, 0, 2, 0));
mapTypeComboBox = new UIComboBox(getMapTypes()) {
public Dimension getPreferredSize() {
return new Dimension(COMBOX_WIDTH, COM_HEIGHT);
}
};
mapTypeComboBox.addItemListener(mapTypeListener);
this.add(mapTypeComboBox);
}
protected abstract void calculateDetailMaps(int mapType);
/**
* 更新地图面板
* @param mapType 地图名字
*/
public void populateMapPane(String mapType){
mapTypeComboBox.removeItemListener(mapTypeListener);
for (String type : getMapTypes()) {
java.util.List list = MapSvgXMLHelper.getInstance().getNamesListWithCateName(type);
for (Object name : list) {
if(ComparatorUtils.equals(name,mapType)){
mapTypeComboBox.setSelectedItem(type);
break;
}
}
}
mapTypeComboBox.addItemListener(mapTypeListener);
}
public abstract String[] getMapTypes();
/**
* 切换图表类型
*/
public void fireChange(){
ChartCollection chartCollection = (ChartCollection)chartDesigner.getTarget().getChartCollection();
Chart chart =chartCollection.getSelectedChart();
if(chart.getPlot().getPlotStyle() != ChartConstants.STYLE_NONE){
resetChart(chart);
}
chart.switchPlot(getSelectedClonedPlot());
if(chart.getPlot().getPlotStyle() != ChartConstants.STYLE_NONE){
resetChart(chart);
}
chartDesigner.fireTargetModified();
ChartDesignEditPane.getInstance().populateSelectedTabPane();
}
protected void resetChart(Chart chart){
chart.setTitle(new Title(chart.getTitle().getTextObject()));
chart.setBorderStyle(Constants.LINE_NONE);
chart.setBorderColor(new Color(150, 150, 150));
chart.setBackground(null);
}
protected abstract Plot getSelectedClonedPlot();
/**
* 触发更新
*/
public void fireTargetModified() {
chartDesigner.fireTargetModified();
}
}

521
designer_chart/src/com/fr/design/mainframe/ChartArea.java

@ -1,521 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.scrollruler.*;
import com.fr.general.FRScreen;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-13
* Time: 下午5:08
*/
public class ChartArea extends JComponent implements ScrollRulerComponent {
private static final int TOPGAP = 8;
private static final int MIN_WIDTH = 36;
private static final int MIN_HEIGHT = 21;
private static final double SLIDER_FLOAT = 120.0;
private static final double SLIDER_MIN = 60.0;
private static final double DEFAULT_SLIDER = 100.0;
private static final int ROTATIONS = 50;
private int designerwidth = 810;
private int designerheight = 500;
private int customWidth = 810;
private int customHeight = 500;
private ChartDesigner designer;
private int horizontalValue = 0;
private int verticalValue = 0;
private int verticalMax = 0;
private int horicalMax = 0;
private FormScrollBar verScrollBar;
private FormScrollBar horScrollBar;
//显示和设置图表界面大小的控件
private UINumberField widthPane;
private UINumberField heightPane;
private boolean isValid = true;
private double START_VALUE = DEFAULT_SLIDER;
public ChartArea(ChartDesigner designer) {
this(designer, true);
}
public ChartArea(ChartDesigner designer, boolean useScrollBar) {
this.designer = designer;
this.designer.setParent(this);
this.customWidth = designer.getTarget().getWidth();
this.customHeight = designer.getTarget().getHeight();
this.designerwidth = this.customWidth;
this.designerheight = this.customHeight;
isValid = useScrollBar;
verScrollBar = new FormScrollBar(Adjustable.VERTICAL, this);
horScrollBar = new FormScrollBar(Adjustable.HORIZONTAL, this);
if (useScrollBar) {
this.setLayout(new FormRulerLayout());
designer.setBorder(new LineBorder(new Color(198, 198, 198)));
this.add(FormRulerLayout.CENTER, designer);
addFormSize();
this.add(FormRulerLayout.VERTICAL, verScrollBar);
this.add(FormRulerLayout.HIRIZONTAL, horScrollBar);
enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
} else {
// 报表参数界面只要标尺和中心pane
this.setLayout(new RulerLayout());
this.add(RulerLayout.CENTER, designer);
addFormRuler();
}
this.setFocusTraversalKeysEnabled(false);
}
/**
* 增加表单的页面大小控制界面包括手动修改和滑块拖动
*/
private void addFormSize() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {f};
double[] columnSize = {p, f, p, p, p, p, p,f,p};
UILabel tipsPane = new UILabel("chart");
tipsPane.setPreferredSize(new Dimension(200, 0));
widthPane = new UINumberField();
widthPane.setPreferredSize(new Dimension(60, 0));
heightPane = new UINumberField();
heightPane.setPreferredSize(new Dimension(60, 0));
JPanel panel = new JPanel(){
public Dimension getPreferredSize(){
return new Dimension(200,0);
}
};
JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{
{tipsPane, new UILabel(), widthPane, new UILabel(Inter.getLocText("Indent-Pixel")), new UILabel("x"),
heightPane, new UILabel(Inter.getLocText("Indent-Pixel")),new UILabel(),panel}},
rowSize, columnSize, 8
);
this.add(FormRulerLayout.BOTTOM, resizePane);
setWidgetsConfig();
// 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小
initCalculateSize();
}
private void setWidgetsConfig() {
widthPane.setHorizontalAlignment(widthPane.CENTER);
heightPane.setHorizontalAlignment(heightPane.CENTER);
widthPane.setMaxDecimalLength(0);
heightPane.setMaxDecimalLength(0);
//控件初始值就是根节点组件初始的宽和高
widthPane.setValue(designerwidth);
heightPane.setValue(designerheight);
addWidthPaneListener();
addHeightPaneListener();
}
private void initCalculateSize() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize();
double value = FRScreen.getByDimension(scrnsize).getValue();
if (value != DEFAULT_SLIDER) {
reCalculateRoot(value, true);
}
}
//设置宽度的控件及响应事件
private void addWidthPaneListener() {
widthPane.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent evt) {
reCalculateWidth((int) ((UINumberField) evt.getSource()).getValue());
}
}
);
widthPane.addFocusListener(
new FocusAdapter() {
public void focusLost(FocusEvent e) {
// 失去焦点时,可以认为输入结束
reCalculateWidth((int) ((UINumberField) e.getSource()).getValue());
}
}
);
}
private void addHeightPaneListener() {
heightPane.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent evt) {
reCalculateHeight((int) ((UINumberField) evt.getSource()).getValue());
}
}
);
heightPane.addFocusListener(
new FocusAdapter() {
public void focusLost(FocusEvent e) {
// 失去焦点时,可以认为输入结束
reCalculateHeight((int) ((UINumberField) e.getSource()).getValue());
}
}
);
}
private void reCalculateWidth(int width) {
int dW = width - designerwidth;
if (dW == 0) {
return;
}
// 图表设计器先设大小为实际的高和当前的宽,然后按此调整内部的组件
designer.setSize(width, designerheight);
designerwidth = width;
customWidth = width;
designer.getTarget().setWidth(width);
ChartArea.this.validate();
designer.fireTargetModified();
}
private void reCalculateHeight(int height) {
int dW = height - designerwidth;
if (dW == 0) {
return;
}
// 图表设计器先设大小为实际的高和当前的宽,然后按此调整内部的组件
designer.setSize(designerwidth, height);
designerheight = height;
customHeight = height;
this.designer.getTarget().setHeight(height);
ChartArea.this.validate();
designer.fireTargetModified();
}
/**
* 按照界面大小的百分比值调整root大小
*
* @param needCalculateParaHeight 是否需要调整参数界面高度
* @param value
*/
private void reCalculateRoot(double value, boolean needCalculateParaHeight) {
if (value == START_VALUE) {
return;
}
double percent = (value - START_VALUE) / START_VALUE;
Dimension d = new Dimension(designerwidth, designerheight);
// 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea
ChartArea.this.validate();
START_VALUE = value;
}
/**
* 增加刻度条
*/
public void addFormRuler() {
BaseRuler vRuler = new VerticalRuler(this);
BaseRuler hRuler = new HorizontalRuler(this);
this.add(RulerLayout.VRULER, vRuler);
this.add(RulerLayout.HRULER, hRuler);
}
/**
* 鼠标滚轮事件
* 由于表单设计界面要求 容器大小大于界面时滚动条才可以拖动所以不支持滚动无限往下滚
*/
@Override
protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent evt) {
int id = evt.getID();
switch (id) {
case MouseEvent.MOUSE_WHEEL: {
int rotations = evt.getWheelRotation();
int value = this.verScrollBar.getValue() + rotations * ROTATIONS;
value = Math.min(value, verticalMax);
value = Math.max(0, value);
doLayout(); //加dolayout是因为每次滚动都要重置 Max的大小
this.verScrollBar.setValue(value);
break;
}
}
}
/**
* 容器布局
*/
public void doLayout() {
layout();
if (isValid) {
setScrollBarProperties(customWidth - designer.getWidth(), horScrollBar);
//计算滚动条值的时候应该算上参数面板的高度
setScrollBarProperties(customHeight - designer.getHeight(), verScrollBar);
}
}
/**
* 设置滚动条的属性
*/
private void setScrollBarProperties(int value, FormScrollBar bar) {
if (value <= 0) {
// 界面有滚动条时,手动缩小容器宽度到界面内,重置滚动条值和max
setScrollBarMax(0, bar);
bar.setMaximum(0);
bar.setValue(0);
bar.setEnabled(false);
} else {
//参数面板拖拽过程中value一直为当前value
int oldValue = verticalValue;
setScrollBarMax(value, bar);
bar.setEnabled(true);
bar.setMaximum(value);
bar.setValue(value);
bar.setValue(oldValue);
}
}
private boolean isScrollNotVisible(FormScrollBar bar) {
if (bar.getOrientation() == Adjustable.VERTICAL) {
return verticalMax == 0;
} else {
return horicalMax == 0;
}
}
private void setScrollBarMax(int max, FormScrollBar bar) {
if (bar.getOrientation() == Adjustable.VERTICAL) {
verticalMax = max;
} else {
horicalMax = max;
}
}
/**
* 返回designer的最小高度
*
* @return int
*/
public int getMinHeight() {
return MIN_HEIGHT;
}
/**
* 返回designer的最小宽度
*
* @return int
*/
public int getMinWidth() {
return MIN_WIDTH;
}
/**
* getRulerLengthUnit
*
* @return short
*/
public short getRulerLengthUnit() {
return -1;
}
/**
* 返回水平滚动条的value
*
* @return int
*/
public int getHorizontalValue() {
return horizontalValue;
}
/**
* 设置水平滚动条的value
*
* @param newValue
*/
public void setHorizontalValue(int newValue) {
this.horizontalValue = newValue;
}
/**
* 返回竖直滚动条的value
*
* @return
*/
public int getVerticalValue() {
return verticalValue;
}
/**
* 竖直滚动条赋值
*
* @param newValue
*/
public void setVerticalValue(int newValue) {
this.verticalValue = newValue;
}
/**
* 返回当前designer的高度
*
* @return height
*/
public int getDesignerHeight() {
return designer.getHeight();
}
/**
* 返回当前designer的宽度
*
* @return
*/
public int getDesignerWidth() {
return designer.getWidth();
}
/**
* 返回宽度控件的value
*
* @return 宽度
*/
public double getWidthPaneValue() {
return widthPane.getValue();
}
/**
* 设置宽度值
*
* @param value
*/
public void setWidthPaneValue(int value) {
widthPane.setValue(value);
}
/**
* 设置高度值
*
* @param value
*/
public void setHeightPaneValue(int value) {
heightPane.setValue(value);
}
/**
* 返回高度控件的value
*
* @return 高度
*/
public double getHeightPaneValue() {
return heightPane.getValue();
}
/**
* 返回界面区域大小
*
* @return Dimension
*/
public Dimension getAreaSize() {
return new Dimension(horScrollBar.getMaximum(), verScrollBar.getMaximum());
}
/**
* setAreaSize
*
* @param totalSize
* @param horizontalValue
* @param verticalValue
*/
public void setAreaSize(Dimension totalSize, int horizontalValue, int verticalValue, double width, double height, double slide) {
horScrollBar.setMaximum((int) totalSize.getWidth());
verScrollBar.setMaximum((int) totalSize.getHeight());
horScrollBar.setValue(horizontalValue);
verScrollBar.setValue(verticalValue);
// 撤销会refresh底层容器,需要按照之前的宽高和百分比重置下容器size
if (width != widthPane.getValue()) {
widthPane.setValue(width);
reCalculateWidth((int) width);
}
if (height != heightPane.getValue()) {
heightPane.setValue(height);
reCalculateHeight((int) height);
}
// undo时会重新refreshRoot,需要再次按照百分比调整下
START_VALUE = DEFAULT_SLIDER;
reCalculateRoot(slide, true);
}
public int getCustomWidth(){
return this.customWidth;
}
public int getCustomHeight(){
return this.customHeight;
}
/**
* 计算滚动条的值和max
*
* @param oldmax 之前最大值
* @param max 当前最大值
* @param newValue 当前value
* @param oldValue 之前value
* @param visi designer的大小
* @param orientation 滚动条方向
* @return 计算后的值和max
*/
@Override
public Point calculateScroll(int oldmax, int max, int newValue, int oldValue, int visi, int orientation) {
int scrollMax = orientation == 1 ? verticalMax : horicalMax;
//防止滚动条到达低端还可以继续点击移动(滚动条最大范围不变时,newValue要在范围之内)
if (oldmax == scrollMax + visi && newValue > scrollMax) {
return new Point(oldValue, oldmax);
}
return new Point(newValue, max);
}
private class FormRulerLayout extends RulerLayout {
public FormRulerLayout() {
super();
}
/**
* 表单用的layout当前不需要标尺
*/
public void layoutContainer(Container target) {
synchronized (target.getTreeLock()) {
Insets insets = target.getInsets();
int top = insets.top;
int left = insets.left;
int bottom = target.getHeight() - insets.bottom;
int right = target.getWidth() - insets.right;
Dimension resize = resizePane.getPreferredSize();
Dimension hbarPreferredSize = null;
Dimension vbarPreferredSize = null;
resizePane.setBounds(left, bottom - resize.height, right, resize.height);
if (horScrollBar != null) {
hbarPreferredSize = horScrollBar.getPreferredSize();
vbarPreferredSize = verScrollBar.getPreferredSize();
horScrollBar.setBounds(left, bottom - hbarPreferredSize.height - resize.height, right - BARSIZE, hbarPreferredSize.height);
verScrollBar.setBounds(right - vbarPreferredSize.width, top, vbarPreferredSize.width, bottom - BARSIZE - resize.height);
}
ChartDesigner dg = ((ChartDesigner) designer);
Rectangle rec = new Rectangle(left + (right - designerwidth) / 2, TOPGAP, right, bottom);
//是否为图表
if (isValid) {
int maxHeight = bottom - hbarPreferredSize.height - resize.height - TOPGAP * 2;
int maxWidth = right - vbarPreferredSize.width;
designerwidth = designerwidth> maxWidth ? maxWidth : designerwidth;
designerheight = designerheight > maxHeight ? maxHeight : designerheight;
int designerLeft = left + (verScrollBar.getX() - designerwidth) / 2;
rec = new Rectangle(designerLeft, TOPGAP, designerwidth, designerheight);
}
// designer是整个表单设计界面中的面板部分,目前只放自适应布局和参数界面。
designer.setBounds(rec);
}
}
}
}

230
designer_chart/src/com/fr/design/mainframe/ChartDesigner.java

@ -1,230 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe;
import com.fr.form.ui.ChartBook;
import com.fr.design.designer.TargetComponent;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-13
* Time: 下午4:30
*/
public class ChartDesigner extends TargetComponent<ChartBook> implements MouseListener{
private ChartArea chartArea;//上层区域
private boolean hasCalGap = false;
private ArrayList<ChangeListener> changeListeners = new ArrayList<ChangeListener>();
public ChartDesigner(ChartBook chartBook) {
super(chartBook);
this.addMouseListener(this);
updateUI();// 初始化界面设计工具的UI实例
}
/**
* 设置上层区域
* @param chartArea 图表区域
*/
public void setParent(ChartArea chartArea) {
this.chartArea = chartArea;
}
/**
* 复制
*/
public void copy() {
}
/**
* 黏贴
* @return 成功返回true
*/
public boolean paste() {
return false;
}
/**
* 剪切
* @return 成功返回TRUE
*/
public boolean cut() {
return false;
}
/**
* 停止编辑
*/
public void stopEditing() {
}
/**
* 权限编辑面板
* @return 面板
*/
public AuthorityEditPane createAuthorityEditPane() {
return null;
}
/**
* 工具条
* @return 工具条
*/
public ToolBarMenuDockPlus getToolBarMenuDockPlus() {
return null;
}
/**
* 菜单状态
* @return 状态
*/
public int getMenuState() {
return 0;
}
/**
* 东上面板
* @return 面板
*/
public JPanel getEastUpPane() {
return null;
}
/**
* 东下面板
* @return 面板
*/
public JPanel getEastDownPane() {
return null;
}
/**
* 取消格式
*/
public void cancelFormat() {
}
/**
* 图表设计器得工具条项
* @return 图表设计器得工具条项
*/
public ToolBarDef[] toolbars4Target() {
return new ToolBarDef[0];
}
/**
* 菜单
* @return 菜单
*/
public MenuDef[] menus4Target() {
return new MenuDef[0];
}
/**
* 菜单项
* @return 菜单项
*/
public ShortCut[] shortcut4TemplateMenu() {
return new ShortCut[0];
}
/**
* 权限编辑得菜单项
* @return 菜单项
*/
public ShortCut[] shortCuts4Authority() {
return new ShortCut[0];
}
/**
* 表单得工具条按钮
* @return 表单得工具条按钮
*/
public JComponent[] toolBarButton4Form() {
return new JComponent[0];
}
/**
* 返回表单区域
* @return 表单区域
*/
public ChartArea getArea() {
return chartArea;
}
/**
* 鼠标点击
* @param e 事件
*/
public void mouseClicked(MouseEvent e) {
}
/**
* 鼠标按下
* @param e 事件
*/
public void mousePressed(MouseEvent e) {
}
/**
* 鼠标释放
* @param e 事件
*/
public void mouseReleased(MouseEvent e) {
}
/**
* 鼠标进入
* @param e 事件
*/
public void mouseEntered(MouseEvent e) {
}
/**
* 鼠标退出
* @param e 事件
*/
public void mouseExited(MouseEvent e) {
}
private void registerChangeListener(ChangeListener changeListener){
if(changeListener == null){
return;
}
this.changeListeners.add(changeListener);
}
public void populate(){
}
/**
* 清除工具栏上面全局风格按钮的选中
*/
public void clearToolBarStyleChoose(){
}
}

211
designer_chart/src/com/fr/design/mainframe/ChartDesignerUI.java

@ -1,211 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChartGlyph;
import com.fr.chart.chartattr.*;
import com.fr.chart.charttypes.ColumnIndependentChart;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.chart.ChartDesignEditPane;
import com.fr.general.FRLogger;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import java.awt.*;
import java.awt.event.MouseEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-13
* Time: 下午4:55
*/
public class ChartDesignerUI extends ComponentUI {
private static final Icon ADD = BaseUtils.readIcon("/com/fr/design/images/add.png");
private static final Icon DEL = BaseUtils.readIcon("/com/fr/design/images/del.png");
private static final int ICON_SIZE = 22;
private static final int H_GAP = 2;
private static final int V_GAP = 6;
private Rectangle[] iconLocations;
private Rectangle add;
private Rectangle del;
private UILabel tooltipLabel;
private int overIndex = -1;//鼠标悬浮上去的图表的INDEX
// 图表当前的设计器
private ChartDesigner designer;
public ChartDesignerUI() {
}
/**
* 加载界面
*
* @param c 组件
*/
public void installUI(JComponent c) {
designer = (ChartDesigner) c;
}
/**
* 渲染当前的设计界面以及设计辅助状态
*
* @param g 画图类
* @param c 组件
*/
@Override
public void paint(Graphics g, JComponent c) {
ChartCollection chartCollection = (ChartCollection) designer.getTarget().getChartCollection();
Chart editingChart = chartCollection.getSelectedChart();
BaseChartGlyph chartGlyph = null;
if (editingChart != null && editingChart.getPlot() != null) {
chartGlyph = editingChart.createGlyph(editingChart.defaultChartData());
}
int parentWidth = designer.getSize().width;
int parentHeight = designer.getSize().height;
int chartWidth = designer.getArea().getCustomWidth();
int chartHeight = designer.getArea().getCustomHeight();
Graphics clipg;
clipg = g.create(-designer.getArea().getHorizontalValue(), -designer.getArea().getVerticalValue(), parentWidth + designer.getArea().getHorizontalValue(), parentHeight + designer.getArea().getVerticalValue());
clipg = clipg.create(1, 1, designer.getArea().getCustomWidth(), designer.getArea().getCustomHeight());
g.setColor(Color.white);
g.fillRect(0, 0, chartWidth, chartHeight);
chartGlyph.setUseChangeChart(true);
Image chartImage = chartGlyph.toImage(chartWidth, chartHeight, ScreenResolution.getScreenResolution());
clipg.drawImage(chartImage, 0, 0, chartWidth, chartHeight, null);
paintChange(clipg, c);
}
//绘制切换的东西
private void paintChange(Graphics g, JComponent c) {
int chartWidth = designer.getArea().getCustomWidth();
ChartCollection collection = (ChartCollection) designer.getTarget().getChartCollection();
int chartCount = collection.getChartCount();
iconLocations = new Rectangle[chartCount];
int startX = chartWidth - V_GAP - ICON_SIZE;
if (chartCount == 1) {
//只有一个时,只绘制新增按钮,不绘制删除按钮
ADD.paintIcon(c, g, startX, H_GAP);
add = new Rectangle(startX, H_GAP, ICON_SIZE, ICON_SIZE);
del = null;
} else {
DEL.paintIcon(c, g, startX, H_GAP);
del = new Rectangle(startX, H_GAP, ICON_SIZE, ICON_SIZE);
startX -= (V_GAP + ICON_SIZE);
ADD.paintIcon(c, g, startX, H_GAP);
add = new Rectangle(startX, H_GAP, ICON_SIZE, ICON_SIZE);
}
for (int i = chartCount - 1; i >= 0; i--) {
Plot plot = collection.getChart(i).getPlot();
if (plot == null) {
continue;
}
if (collection.getSelectedIndex() == i) {
Icon ploticon = BaseUtils.readIcon(plot.getPlotSmallIconPath() + "_normal.png");
if (ploticon != null) {
startX -= (V_GAP + ICON_SIZE);
ploticon.paintIcon(c, g, startX, H_GAP);
}
}else if(overIndex == i){
Icon ploticon = BaseUtils.readIcon(plot.getPlotSmallIconPath() + "_over.png");
if (ploticon != null) {
startX -= (V_GAP + ICON_SIZE);
ploticon.paintIcon(c, g, startX, H_GAP);
}
} else {
Icon ploticon = BaseUtils.readIcon(plot.getPlotSmallIconPath() + "_gray.png");
if (ploticon != null) {
startX -= (V_GAP + ICON_SIZE);
ploticon.paintIcon(c, g, startX, H_GAP);
}
}
iconLocations[i] = new Rectangle(startX, H_GAP, ICON_SIZE, ICON_SIZE);
}
}
/**
* 鼠标点击
*
* @param e 事件
*/
public void mouseClicked(MouseEvent e) {
Point clikPoint = new Point(e.getPoint().x + designer.getArea().getHorizontalValue(), e.getPoint().y + designer.getArea().getVerticalValue());
ChartCollection collection = (ChartCollection) designer.getTarget().getChartCollection();
for (int i = 0; i < iconLocations.length; i++) {
if (iconLocations[i].contains(clikPoint)) {
if (i == collection.getSelectedIndex()) {
return;
}
collection.setSelectedIndex(i);
designer.repaint();
ChartDesignEditPane.getInstance().populateSelectedTabPane();
return;
}
}
if (add.contains(clikPoint)) {
Chart[] barChart = ColumnIndependentChart.columnChartTypes;
try {
Chart newChart = (Chart) barChart[0].clone();
int select = collection.getSelectedIndex();
collection.addNamedChartAtIndex(newChart.getTitle().getTextObject().toString(), newChart,select+1);
collection.setSelectedIndex(select+1);
ChartDesignEditPane.getInstance().populateSelectedTabPane();
} catch (CloneNotSupportedException e1) {
FRLogger.getLogger().error("Error in Clone");
}
designer.fireTargetModified();
ChartDesignEditPane.getInstance().populateSelectedTabPane();
return;
}
if (del != null && del.contains(clikPoint)) {
int selectedIndex = collection.getSelectedIndex();
collection.removeNameObject(selectedIndex);
if (selectedIndex > 0) {
collection.setSelectedIndex(selectedIndex - 1);
} else {
collection.setSelectedIndex(0);
}
designer.fireTargetModified();
ChartDesignEditPane.getInstance().populateSelectedTabPane();
}
}
/**
* 鼠标悬浮上时的数据点提示
*
* @param e 事件
*/
public void mouseMoved(MouseEvent e) {
Point clikPoint = new Point(e.getPoint().x + designer.getArea().getHorizontalValue(), e.getPoint().y + designer.getArea().getVerticalValue());
if (clikPoint.getY() < H_GAP || clikPoint.getY() > H_GAP + ICON_SIZE) {
ToolTip4Chart.getInstance().hideToolTip();
overIndex = -1;
return;
}
ChartCollection collection = (ChartCollection) designer.getTarget().getChartCollection();
for (int i = 0; i < iconLocations.length; i++) {
if (iconLocations[i].contains(clikPoint)) {
overIndex = i;
String chartName = collection.getChartName(i);
ToolTip4Chart.getInstance().showToolTip(chartName,e.getXOnScreen(),e.getYOnScreen());
return;
}
}
ToolTip4Chart.getInstance().hideToolTip();
overIndex = -1;
}
}

16
designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java

@ -3,26 +3,20 @@
*/ */
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.SwingConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import javax.swing.*;
import java.awt.*;
public class ChartPropertyPane extends MiddleChartPropertyPane{ public class ChartPropertyPane extends MiddleChartPropertyPane{
/** /**
* 创建图表属性表实例. * 创建图表属性表实例.
*/ */
private synchronized static ChartPropertyPane getInstance() { private synchronized static ChartPropertyPane getInstance() {
if(singleton == null) { //todo
//创建新图表时,创建属性表配置面板
singleton = new ChartPropertyPane(); singleton = new ChartPropertyPane();
}
singleton.setSureProperty();
return singleton; return singleton;
} }

558
designer_chart/src/com/fr/design/mainframe/ChartToolBarPane.java

@ -1,558 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe;
import com.fr.base.ChartPreStyleManagerProvider;
import com.fr.base.ChartPreStyleServerManager;
import com.fr.base.background.ColorBackground;
import com.fr.chart.base.*;
import com.fr.chart.chartattr.*;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.chart.ChartDesignEditPane;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.gui.type.ColumnPlotPane4ToolBar;
import com.fr.design.mainframe.chart.gui.type.PlotPane4ToolBar;
import com.fr.general.FRFont;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-13
* Time: 下午8:32
*/
public class ChartToolBarPane extends JPanel {
public static final int TOTAL_HEIGHT = 42;
private static final int COM_HEIGHT = 22;
private static final int GAP = 7;
private static final int COM_GAP = 14;
private static final int COMBOX_WIDTH = 230;
private static final String[] CHOOSEITEM = new String[]{
Inter.getLocText("FR-Chart-Type_Column"),
Inter.getLocText("FR-Chart-Type_Line"),
Inter.getLocText("FR-Chart-Type_Bar"),
Inter.getLocText("FR-Chart-Type_Pie"),
Inter.getLocText("FR-Chart-Type_Area"),
Inter.getLocText("FR-Chart-Type_XYScatter"),
Inter.getLocText("FR-Chart-Chart_BubbleChart"),
Inter.getLocText("FR-Chart-Type_Radar"),
Inter.getLocText("FR-Chart-Type_Stock"),
Inter.getLocText("FR-Chart-Type_Meter"),
Inter.getLocText("FR-Chart-Type_Range"),
Inter.getLocText("FR-Chart-Type_Comb"),
Inter.getLocText("FR-Chart-Type_Gantt"),
Inter.getLocText("FR-Chart-Type_Donut"),
Inter.getLocText("FR-Chart-Map_Map"),
"gis"+Inter.getLocText("FR-Chart-Map_Map")
};
private UIComboBox chooseComboBox = new UIComboBox(CHOOSEITEM) {
public Dimension getPreferredSize() {
return new Dimension(COMBOX_WIDTH, COM_HEIGHT);
}
};
private JPanel stylePane;
private JPanel plotTypeComboBoxPane;
private UIButton topDownShade = new UIButton(Inter.getLocText("FR-Chart-Style_TopDownShade"));
private UIButton transparent = new UIButton(Inter.getLocText("FR-Chart-Style_Transparent"));
private UIButton plane3D = new UIButton(Inter.getLocText("FR-Chart-Style_Plane3D"));
private UIButton gradient = new UIButton(Inter.getLocText("FR-Chart-Style_GradientHighlight"));
private ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.DESELECTED) {
ChartToolBarPane.this.remove(centerPane);
ChartToolBarPane.this.remove(stylePane);
if(chooseComboBox.getSelectedIndex() < ChartTypeValueCollection.MAP.toInt()){
calSubChartTypesPane(chooseComboBox.getSelectedIndex());
ChartToolBarPane.this.add(subChartTypesPane,BorderLayout.CENTER);
centerPane = subChartTypesPane;
ChartToolBarPane.this.add(stylePane, BorderLayout.EAST);
} else{
calMapSubChartTypesPane(chooseComboBox.getSelectedIndex());
ChartToolBarPane.this.add(mapTypePane, BorderLayout.CENTER);
centerPane = mapTypePane;
}
ChartCollection chartCollection = (ChartCollection) chartDesigner.getTarget().getChartCollection();
Chart chart = chartCollection.getSelectedChart();
ChartToolBarPane.this.validate();
fireTypeChange();
if(chooseComboBox.getSelectedIndex() == ChartTypeValueCollection.MAP.toInt()){
mapTypePane.populateMapPane(((MapPlot) chart.getPlot()).getMapName());
}else if(chooseComboBox.getSelectedIndex() == ChartTypeValueCollection.GIS.toInt()){
mapTypePane.populateMapPane(chart.getChartName());
}
}
}
};
private PlotPane4ToolBar subChartTypesPane;//默认柱形图
private AbstractMapPlotPane4ToolBar mapTypePane;//地图类型选择的面板
private JPanel centerPane;
private ChartDesigner chartDesigner;
private int lastStyleIndex = -1;
private MouseAdapter styleListener = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
ChartCollection chartCollection = (ChartCollection) chartDesigner.getTarget().getChartCollection();
Chart chart = chartCollection.getSelectedChart();
Plot newPlot;
int chartType =chart.getPlot().getPlotType().toInt();
if(chartType >= ChartTypeValueCollection.MAP.toInt()){
return;
}
newPlot = subChartTypesPane.setSelectedClonedPlotWithCondition(chart.getPlot());
chartDesigner.fireTargetModified();
UIButton button = (UIButton)e.getSource();
//如果是第二次选中,就是消除
if(button.isSelected()){
button.setSelected(false);
chart.setPlot(newPlot);
resetChart(chart);
lastStyleIndex = -1;
ChartDesignEditPane.getInstance().populateSelectedTabPane();
return;
}
clearStyleChoose();
setStyle(chart,e,newPlot);
lastStyleIndex = chart.getPlot().getPlotStyle();
}
};
private void setStyle( Chart chart,MouseEvent e,Plot newPlot){
if (e.getSource() == topDownShade) {
topDownShade.setSelected(true);
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_SHADE);
resetChart(chart);
createCondition4Shade(chart);
setPlotFillStyle(chart);
} else if (e.getSource() == transparent) {
transparent.setSelected(true);
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_TRANSPARENT);
resetChart(chart);
createCondition4Transparent(chart);
setPlotFillStyle(chart);
} else if (e.getSource() == plane3D) {
plane3D.setSelected(true);
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_3D);
resetChart(chart);
createCondition4Plane3D(chart);
setPlotFillStyle(chart);
} else if (e.getSource() == gradient) {
gradient.setSelected(true);
chart.setPlot(newPlot);
chart.getPlot().setPlotStyle(ChartConstants.STYLE_OUTER);
resetChart(chart);
createCondition4HighLight(chart);
setPlotFillStyle(chart);
}
chart.setStyleGlobal(true);
ChartEditPane pane = ChartDesignEditPane.getInstance();
pane.styleChange(true);
ChartDesignEditPane.getInstance().populate((ChartCollection)chartDesigner.getTarget().getChartCollection());
pane.styleChange(false);
}
public ChartToolBarPane(ChartDesigner designer) {
chartDesigner = designer;
subChartTypesPane = new ColumnPlotPane4ToolBar(designer);//默认柱形图
this.setLayout(new BorderLayout());
this.setBorder(new EmptyBorder(GAP, COM_GAP, GAP, 0));
plotTypeComboBoxPane = new JPanel();
plotTypeComboBoxPane.setBorder(new EmptyBorder(2, 0, 2, 0));
plotTypeComboBoxPane.setLayout(new BorderLayout());
plotTypeComboBoxPane.add(chooseComboBox, BorderLayout.CENTER);
chooseComboBox.addItemListener(itemListener);
//默认选择第一个
chooseComboBox.setSelectedIndex(0);
this.add(plotTypeComboBoxPane, BorderLayout.WEST);
initStylePane();
this.add(stylePane, BorderLayout.EAST);
this.add(subChartTypesPane, BorderLayout.CENTER);
this.centerPane = subChartTypesPane;
topDownShade.addMouseListener(styleListener);
transparent.addMouseListener(styleListener);
plane3D.addMouseListener(styleListener);
gradient.addMouseListener(styleListener);
}
private void initStylePane(){
stylePane = new JPanel() {
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
return new Dimension(size.width, COM_HEIGHT);
}
};
stylePane.setLayout(new FlowLayout(FlowLayout.LEFT, COM_GAP, 0));
stylePane.setBorder(new EmptyBorder(3, 0, 3, 0));
stylePane.add(topDownShade);
stylePane.add(transparent);
stylePane.add(plane3D);
stylePane.add(gradient);
}
/**
* 清除工具栏上面全局风格按钮的选中
*/
public void clearStyleChoose() {
topDownShade.setSelected(false);
transparent.setSelected(false);
plane3D.setSelected(false);
gradient.setSelected(false);
}
private void calMapSubChartTypesPane(int index){
ChartTypeValueCollection type = ChartTypeValueCollection.parse(index);
mapTypePane = PlotToolBarFactory.createToolBar4MapPlot(type,chartDesigner);
}
private void calSubChartTypesPane(int index) {
ChartTypeValueCollection type = ChartTypeValueCollection.parse(index);
subChartTypesPane = PlotToolBarFactory.createToolBar4NormalPlot(type,chartDesigner);
}
private void fireTypeChange() {
if(chooseComboBox.getSelectedIndex() < ChartTypeValueCollection.MAP.toInt()){
subChartTypesPane.fireChange();
}else{
mapTypePane.fireChange();
}
}
//图表区属性清空
private void resetChart(Chart chart) {
chart.setTitle(new Title(chart.getTitle().getTextObject()));
chart.setBorderStyle(Constants.LINE_NONE);
chart.setBorderColor(new Color(150, 150, 150));
chart.setBackground(null);
setPlotFillStyle(chart);
}
//高光渐变的默认属性设置
private void createCondition4HighLight(Chart chart) {
if (chart != null) {
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.LEFT);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(51, 51, 51)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139)));
legend.setPosition(Constants.RIGHT_TOP);
chart.getPlot().setLegend(legend);
//分类轴,现在只有柱形图,条形图,面积图
if (chart.getPlot() instanceof CategoryPlot) {
CategoryPlot plot = (CategoryPlot) chart.getPlot();
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(204, 220, 228));
cateAxis.setTickMarkType(Constants.TICK_MARK_INSIDE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(138, 140, 139)));
//值轴
Axis valueAxis = plot.getyAxis();
valueAxis.setAxisStyle(Constants.NONE);
valueAxis.setAxisColor(null);
valueAxis.setTickMarkType(Constants.TICK_MARK_INSIDE);
valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
valueAxis.setShowAxisLabel(true);
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(138, 140, 139)));
//绘图区
plot.setBorderStyle(Constants.LINE_THIN);
plot.setBorderColor(new Color(204, 220, 228));
plot.setBackground(ColorBackground.getInstance(new Color(248, 247, 245)));
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN);
plot.getyAxis().setMainGridColor(new Color(192, 192, 192));
}
}
}
//平面3D的默认属性设置
private void createCondition4Plane3D(Chart chart) {
if (chart != null) {
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.CENTER);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 16f, new Color(51, 51, 51)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128)));
legend.setPosition(Constants.TOP);
chart.getPlot().setLegend(legend);
//分类轴,现在只有柱形图,条形图,面积图
if (chart.getPlot() instanceof CategoryPlot) {
CategoryPlot plot = (CategoryPlot) chart.getPlot();
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(57, 57, 57));
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(57, 57, 57)));
//值轴设置
Axis valueAxis = plot.getyAxis();
valueAxis.setAxisStyle(Constants.LINE_NONE);
valueAxis.setTickMarkType(Constants.TICK_MARK_NONE);
valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
valueAxis.setShowAxisLabel(false);
//绘图区
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN);
plot.getyAxis().setMainGridColor(new Color(192, 192, 192));
chart.setBorderStyle(Constants.LINE_NONE);
//数据标签
ConditionAttr attrList = plot.getConditionCollection().getDefaultAttr();
DataSeriesCondition attr = attrList.getExisted(AttrContents.class);
if (attr != null) {
attrList.remove(attr);
}
AttrContents attrContents = new AttrContents();
attrContents.setPosition(Constants.OUTSIDE);
attrContents.setSeriesLabel(ChartConstants.VALUE_PARA);
attrContents.setTextAttr(new TextAttr(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(51, 51, 51))));
attrList.addDataSeriesCondition(attrContents);
}
}
}
//透明风格的默认属性设置
private void createCondition4Transparent(Chart chart) {
if (chart != null) {
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.LEFT);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(192, 192, 192)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139)));
legend.setPosition(Constants.RIGHT_TOP);
chart.getPlot().setLegend(legend);
Plot plot = chart.getPlot();
//绘图区
chart.setBackground(ColorBackground.getInstance(new Color(51, 51, 51)));
//分类轴,现在只有柱形图,条形图,面积图
if (plot instanceof CategoryPlot) {
//边框
plot.setBorderStyle(Constants.LINE_THIN);
plot.setBorderColor(new Color(65, 65, 65));
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(192, 192, 192));
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(150, 150, 150)));
//值轴
Axis valueAxis = plot.getyAxis();
valueAxis.setShowAxisLabel(true);
valueAxis.setAxisStyle(Constants.LINE_NONE);
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(150, 150, 150)));
valueAxis.setMainGridStyle(Constants.LINE_THIN);
valueAxis.setMainGridColor(new Color(63, 62, 62));
}
}
}
//渐变的默认属性设置
private void createCondition4Shade(Chart chart) {
if (chart != null) {
//标题
Title title = new Title(chart.getTitle().getTextObject());
chart.setTitle(title);
title.setTitleVisible(true);
TextAttr textAttr = title.getTextAttr();
if (textAttr == null) {
textAttr = new TextAttr();
title.setTextAttr(textAttr);
}
title.setPosition(Constants.CENTER);
textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(0, 51, 102)));
//图例
Legend legend = new Legend();
legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128)));
legend.setPosition(Constants.BOTTOM);
chart.getPlot().setLegend(legend);
//分类轴,现在只有柱形图,条形图,面积图
if (chart.getPlot() instanceof CategoryPlot) {
CategoryPlot plot = (CategoryPlot) chart.getPlot();
//分类轴设置
Axis cateAxis = plot.getxAxis();
cateAxis.setAxisStyle(Constants.LINE_THICK);
cateAxis.setAxisColor(new Color(73, 100, 117));
cateAxis.setTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE);
cateAxis.setShowAxisLabel(true);
cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(128, 128, 128)));
//值轴
Axis valueAxis = plot.getyAxis();
valueAxis.setShowAxisLabel(true);
valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(128, 128, 128)));
valueAxis.setAxisStyle(Constants.LINE_NONE);
//绘图区
plot.getyAxis().setMainGridStyle(Constants.LINE_THIN);
plot.getyAxis().setMainGridColor(new Color(192, 192, 192));
plot.setHorizontalIntervalBackgroundColor(new Color(243, 243, 243));
}
}
}
private void setPlotFillStyle(Chart chart) {
ChartPreStyleManagerProvider manager = ChartPreStyleServerManager.getProviderInstance();
Plot plot = chart.getPlot();
Object preStyle = null;
String name = "";
if (topDownShade.isSelected()) {
name = Inter.getLocText("FR-Chart-Style_Retro");
preStyle = manager.getPreStyle(name);
} else if (transparent.isSelected()) {
name = Inter.getLocText("FR-Chart-Style_Fresh");
preStyle = manager.getPreStyle(name);
} else if (plane3D.isSelected()) {
name = Inter.getLocText("FR-Chart-Style_Bright");
preStyle = manager.getPreStyle(name);
} else if (gradient.isSelected()) {
name = Inter.getLocText("FR-Chart-Style_Bright");
preStyle = manager.getPreStyle(name);
}else{
preStyle = null;
}
if (preStyle == null) {
plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT);
} else {
AttrFillStyle fillStyle = ((ChartPreStyle) preStyle).getAttrFillStyle();
fillStyle.setFillStyleName(name);
plot.setPlotFillStyle(fillStyle);
}
}
public void populate(){
ChartCollection chartCollection = (ChartCollection) chartDesigner.getTarget().getChartCollection();
Chart chart = chartCollection.getSelectedChart();
chooseComboBox.removeItemListener(itemListener);
chooseComboBox.setSelectedIndex(chart.getPlot().getPlotType().toInt());
int chartType =chart.getPlot().getPlotType().toInt();
this.removeAll();
populateStyle();
this.add(plotTypeComboBoxPane, BorderLayout.WEST);
initStylePane();
if(chartType < ChartTypeValueCollection.MAP.toInt()){
calSubChartTypesPane(chartType);
subChartTypesPane.setSelectedIndex(chart.getPlot().getDetailType());
ChartToolBarPane.this.add(subChartTypesPane, BorderLayout.CENTER);
this.add(subChartTypesPane, BorderLayout.CENTER);
centerPane = subChartTypesPane;
this.add(stylePane, BorderLayout.EAST);
}else if(chartType == ChartTypeValueCollection.MAP.toInt()){
calMapSubChartTypesPane(chartType);
mapTypePane.populateMapPane(((MapPlot) chart.getPlot()).getMapName());
ChartToolBarPane.this.add(mapTypePane, BorderLayout.CENTER);
centerPane = mapTypePane;
}else{
calMapSubChartTypesPane(chartType);
mapTypePane.populateMapPane((chart.getPlot()).getPlotName());
ChartToolBarPane.this.add(mapTypePane, BorderLayout.CENTER);
centerPane = mapTypePane;
}
ChartToolBarPane.this.validate();
chooseComboBox.addItemListener(itemListener);
}
private void populateStyle() {
clearStyleChoose();
ChartCollection chartCollection = (ChartCollection) chartDesigner.getTarget().getChartCollection();
Chart chart = chartCollection.getSelectedChart();
int plotStyle = chart.getPlot().getPlotStyle();
switch (plotStyle) {
case ChartConstants.STYLE_SHADE:
topDownShade.setSelected(chart.isStyleGlobal() && true);
break;
case ChartConstants.STYLE_TRANSPARENT:
transparent.setSelected(chart.isStyleGlobal() && true);
break;
case ChartConstants.STYLE_3D:
plane3D.setSelected(chart.isStyleGlobal() && true);
break;
case ChartConstants.STYLE_OUTER:
gradient.setSelected(chart.isStyleGlobal() && true);
break;
default:
clearStyleChoose();
break;
}
lastStyleIndex = plotStyle;
}
}

98
designer_chart/src/com/fr/design/mainframe/DesignerFrame4Chart.java

@ -1,98 +0,0 @@
package com.fr.design.mainframe;
import com.fr.design.ChartEnvManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.mainframe.actions.UpdateVersion;
import com.fr.design.mainframe.chart.UpdateOnLinePane;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class DesignerFrame4Chart extends DesignerFrame {
/**
* Constructor.
*
* @param ad
*/
public DesignerFrame4Chart(ToolBarMenuDock ad) {
super(ad);
}
protected ArrayList<WindowListener> getFrameListeners(){
ArrayList<WindowListener> listeners = super.getFrameListeners();
listeners.add(0, new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
super.windowOpened(e);
judgeFirstUseWhenStart();
}
});
return listeners;
}
/**
* 退出
*/
public void exit() {
ChartEnvManager.getEnvManager().saveXMLFile();
super.exit();
}
//不需要西侧的文件树面板
protected void laoyoutWestPane(){
}
protected void judgeFirstUseWhenStart(){
boolean isNeed2Check =ChartEnvManager.getEnvManager().isPushUpdateAuto() || ChartEnvManager.getEnvManager().isOverOneMonth();
if(!StableUtils.checkDesignerActive(ChartEnvManager.getEnvManager().getActivationKey())
|| isNeed2Check){
ChartEnvManager.getEnvManager().setActivationKey(ChartEnvManager.ACTIVE_KEY);
checkVersion();
if(ChartEnvManager.getEnvManager().isOverOneMonth()){
ChartEnvManager.getEnvManager().resetCheckDate();
}
}
}
private void checkVersion(){
new UpdateVersion(){
protected void done() {
try {
JSONObject serverVersion = get();
String version = serverVersion.getString(UpdateVersion.VERSION);
if(!ComparatorUtils.equals(ProductConstants.RELEASE_VERSION, version)){
UpdateOnLinePane updateOnLinePane = new UpdateOnLinePane(version);
BasicDialog dg = updateOnLinePane.showWindow4UpdateOnline(DesignerContext.getDesignerFrame());
updateOnLinePane.setParentDialog(dg);
dg.setVisible(true);
}
}catch (Exception e){
FRLogger.getLogger().error(e.getMessage());
}
}
}.execute();
}
}

203
designer_chart/src/com/fr/design/mainframe/GisMapPlotPane4ToolBar.java

@ -1,203 +0,0 @@
package com.fr.design.mainframe;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.*;
import com.fr.chart.charttypes.GisMapIndependentChart;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* Date: 14/12/1
* Time: 下午3:11
*/
public class GisMapPlotPane4ToolBar extends AbstractMapPlotPane4ToolBar {
private static final int BAIDU = 0;
private static final int GOOGLE= 1;
private static final String[] TYPE_NAMES = new String[]{
Inter.getLocText("FR-Chart-Map_Baidu"),
Inter.getLocText("FR-Chart-Map_Google")};
private UITextField keyField = new UITextField(){
public Dimension getPreferredSize() {
return new Dimension(COMBOX_WIDTH, COM_HEIGHT);
}
};
private DocumentListener keyListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
fireKeyChange();
}
@Override
public void removeUpdate(DocumentEvent e) {
fireKeyChange();
}
@Override
public void changedUpdate(DocumentEvent e) {
fireKeyChange();
}
} ;
private void fireKeyChange(){
ChartCollection chartCollection = (ChartCollection)chartDesigner.getTarget().getChartCollection();
Chart chart =chartCollection.getSelectedChart();
GisMapPlot plot =(GisMapPlot) chart.getPlot();
String key = this.keyField.getText().trim();
if(plot.isGisType() && key != plot.getBaiduKey()){
plot.setBaiduKey(key);
}else if(!plot.isGisType() && key != plot.getGoogleKey()){
plot.setGoogleKey(key);
}
chartDesigner.fireTargetModified();
}
public GisMapPlotPane4ToolBar(final ChartDesigner chartDesigner){
super(chartDesigner);
this.add(getKeyPane());
keyField.getDocument().addDocumentListener(keyListener);
}
private JPanel getKeyPane(){
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p,f};
double[] rowSize = {p};
Component[][] components = new Component[][]{
new Component[]{new UILabel("key"),keyField},
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
protected void calculateDetailMaps(int mapType){
switch (mapType) {
case BAIDU:
populateDetilMaps(Inter.getLocText("FR-Chart-Map_Baidu"));
break;
case GOOGLE:
populateDetilMaps(Inter.getLocText("FR-Chart-Map_Google"));
break;
default:
populateDetilMaps(Inter.getLocText("FR-Chart-Map_Baidu"));
}
fireMapChange();
}
/**
* 更新地图面板
* @param mapType 地图名字
*/
public void populateMapPane(String mapType){
super.populateMapPane(mapType);
populateDetilMaps(mapTypeComboBox.getSelectedItem().toString());
}
protected void populateDetilMaps(String mapType){
mapTypeComboBox.removeItemListener(mapTypeListener);
ChartCollection chartCollection = (ChartCollection)chartDesigner.getTarget().getChartCollection();
Chart chart =chartCollection.getSelectedChart();
GisMapPlot plot = (GisMapPlot) chart.getPlot();
keyField.getDocument().removeDocumentListener(keyListener);
if(plot.isGisType()){
keyField.setText(plot.getBaiduKey());
mapTypeComboBox.setSelectedIndex(0);
}else{
keyField.setText(plot.getGoogleKey());
mapTypeComboBox.setSelectedIndex(1);
}
keyField.getDocument().addDocumentListener(keyListener);
mapTypeComboBox.addItemListener(mapTypeListener);
}
private void fireMapChange(){
ChartCollection chartCollection = (ChartCollection)chartDesigner.getTarget().getChartCollection();
Chart chart =chartCollection.getSelectedChart();
if(chart.getPlot().getPlotStyle() != ChartConstants.STYLE_NONE){
resetChart(chart);
}
Chart[] cs = GisMapIndependentChart.gisChartTypes;
GisMapPlot plot;
if (cs.length > 0) {
try {
plot = (GisMapPlot)cs[0].getPlot().clone();
} catch (Exception e) {
plot = new GisMapPlot();
}
} else {
plot = new GisMapPlot();
}
try {
chart.switchPlot((Plot)plot.clone());
} catch (CloneNotSupportedException e) {
FRLogger.getLogger().error("Error In GisChart");
chart.switchPlot(new GisMapPlot());
}
plot = (GisMapPlot) chart.getPlot();
boolean index = plot.isGisType();
plot.setGisType(mapTypeComboBox.getSelectedIndex() == 1);
if(index != plot.isGisType()){
if(plot.isGisType()){
this.keyField.setText(plot.getBaiduKey());
}else{
this.keyField.setText(plot.getGoogleKey());
}
}else{
String key = this.keyField.getText().trim();
if(plot.isGisType() && key != plot.getBaiduKey()){
plot.setBaiduKey(key);
}else if(!plot.isGisType() && key != plot.getGoogleKey()){
plot.setGoogleKey(key);
}
}
chartDesigner.fireTargetModified();
}
protected Plot getSelectedClonedPlot() {
Chart[] mapChart = GisMapIndependentChart.gisChartTypes;
GisMapPlot newPlot;
if (mapChart.length > 0) {
try {
newPlot = (GisMapPlot)mapChart[0].getPlot().clone();
} catch (Exception e) {
newPlot = new GisMapPlot();
}
} else {
newPlot = new GisMapPlot();
}
Plot cloned = null;
try {
cloned = (Plot) newPlot.clone();
} catch (CloneNotSupportedException e) {
FRLogger.getLogger().error("Error In GisMapChart");
}
return cloned;
}
public String[] getMapTypes(){
return TYPE_NAMES;
}
}

339
designer_chart/src/com/fr/design/mainframe/MapArrayPane.java

@ -1,339 +0,0 @@
package com.fr.design.mainframe;
import com.fr.chart.base.MapSvgAttr;
import com.fr.chart.base.MapSvgXMLHelper;
import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.*;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.stable.CoreConstants;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* Date: 14/12/3
* Time: 上午10:00
*/
public class MapArrayPane extends JListControlPane {
private static final int LEFT_WIDTH = 180;
private static final Color LINE_COLOR = new Color(176, 176, 176);
private static final int TOP_GAP = 5;
private static final String[] TYPE_NAMES = new String[]{
Inter.getLocText("FR-Chart-World_Map"),
Inter.getLocText("FR-Chart-State_Map"),
Inter.getLocText("FR-Chart-Province_Map"),
Inter.getLocText("FR-Chart-Custom_Map")};
private String mapType;
private String mapDetailName;
MapPlotPane4ToolBar toolBar;
UIComboBox mapTypeBox;
private ArrayList<String> editedNames = new ArrayList<String>();
private ItemListener typeListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
MapArrayPane.this.updateBeans();
mapType = mapTypeBox.getSelectedItem().toString();
MapArrayPane.this.populate(MapSvgXMLHelper.getInstance().getAllMapObjects4Cate(mapType));
}
};
private ArrayList<String> removeNames = new ArrayList<String>();
private MapEditPane mapEditPane;
private ChartDesigner chartDesigner;
public MapArrayPane(String mapType, String mapDetailName,ChartDesigner chartDesigner) {
this.mapDetailName = mapDetailName;
this.mapType = mapType;
if (mapTypeBox != null) {
mapTypeBox.setSelectedItem(mapType);
}
this.chartDesigner = chartDesigner;
mapTypeBox.addItemListener(typeListener);
this.setBorder(new EmptyBorder(TOP_GAP, 0, 0, 0));
this.addEditingListner(new PropertyChangeAdapter() {
public void propertyChange() {
dealPropertyChange();
}
});
}
public void setToolBarPane(MapPlotPane4ToolBar pane) {
this.toolBar = pane;
}
protected void doWhenPopulate(BasicBeanPane beanPane) {
mapEditPane = (MapEditPane)beanPane;
mapEditPane.dealWidthMap(mapType);
String editingName = ((MapEditPane)beanPane).getCurrentMapName();
if(!editedNames.contains(editingName)){
editedNames.add(editingName);
}
}
protected JPanel getLeftPane() {
JPanel centerPane = super.getLeftPane();
mapTypeBox = new UIComboBox(TYPE_NAMES);
JPanel leftPane = new JPanel();
leftPane.setLayout(new BorderLayout());
leftPane.setBorder(new EmptyBorder(3, 0, 0, 0));
leftPane.add(mapTypeBox, BorderLayout.NORTH);
leftPane.add(centerPane, BorderLayout.CENTER);
return leftPane;
}
private void dealPropertyChange() {
MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance();
java.util.List nameList =helper.getNamesListWithCateName(mapType);
String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName();
if (StringUtils.isEmpty(tempName)) {
String[] warning = new String[]{"NOT_NULL_Des", "Please_Rename"};
String[] sign = new String[]{",", "!"};
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(MapArrayPane.this), Inter.getLocText(warning, sign));
setWarnigText(editingIndex);
return;
}
if (!ComparatorUtils.equals(tempName, selectedName)
&& isNameRepeted(new List[]{nameList, Arrays.asList(allListNames)}, tempName)) {
nameableList.stopEditing();
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(MapArrayPane.this),
Inter.getLocText(new String[]{"FR-Chart-Map_NameAlreadyExist", "Please_Rename"}, new String[]{",", "!"}));
setWarnigText(editingIndex);
return;
}
String oldname = mapEditPane.getCurrentMapName();
mapEditPane.setCurrentMapName(tempName);
mapEditPane.dealWidthMap(mapType);
if(editedNames.contains(oldname)){
editedNames.remove(oldname);
editedNames.add(tempName);
}
if(helper.getNewMapAttr(oldname) != null){
MapSvgAttr attr = helper.getNewMapAttr(oldname);
attr.renameMap(tempName);
helper.removeNewMapAttr(oldname);
helper.addNewSvgMaps(tempName,attr);
}
this.toolBar.fireTargetModified();
this.saveMapInfo(tempName);
}
protected void doAfterRemove(){
for(String map2Remove : removeNames){
MapSvgXMLHelper.getInstance().removeMapAttr(map2Remove);
MapSvgXMLHelper.getInstance().removeNewMapAttr(map2Remove);
}
update4AllType();
}
protected void doBeforeRemove(){
removeNames.clear();
for(int index : nameableList.getSelectedIndices()){
removeNames.add(nameableList.getNameAt(index));
}
}
//保存修改过的地图信息
private void saveMapInfo(final String mapName) {
SwingWorker worker = new SwingWorker<Integer, Void>() {
@Override
protected Integer doInBackground() throws Exception {
MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);// 只有在编辑地图时才需要储存相关数据 @kuns
if (attr != null) {
attr.writeBack(mapName);
}
return 0;
}
@Override
protected void done() {
FRLogger.getLogger().info(Inter.getLocText("FR-Chart-Map_Saved")); // 地图已经保存.
}
};
worker.execute();
DesignerEnvManager.addWorkers(worker);
}
private void update4AllType() {
MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance();
helper.clearNames4Cate(mapType);
for(String name : nameableList.getAllNames()){
MapSvgAttr attr = helper.getMapAttr(name);
if(attr == null){
continue;
}
helper.addCateNames(attr.getMapType(),attr.getName());
}
}
/**
* 创建菜单
*
* @return 菜单
*/
public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{
new NameableSelfCreator(Inter.getLocText("FR-Chart-Custom_Map"), MapSvgAttr.class, MapEditPane.class) {
public MapSvgAttr createNameable(UnrepeatedNameHelper helper) {
MapSvgAttr attr = new MapSvgAttr();
attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + helper.createUnrepeatedName(Inter.getLocText("FR-Chart-Custom_Map")) + ".svg");
MapSvgXMLHelper.getInstance().addNewSvgMaps(attr.getName(), attr);
update4Edited(attr.getName());
// 返回参数设置面板.
return attr;
}
@Override
public String createTooltip() {
return null;
}
public void saveUpdatedBean(ListModelElement wrapper, Object bean) {
wrapper.wrapper = (Nameable)bean;
}
}
};
}
protected boolean isCreatorNeedIocn() {
return false;
}
protected ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{
addItemShortCut(),
removeItemShortCut(),
};
}
protected int getLeftPreferredSize() {
return LEFT_WIDTH;
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText(new String[]{"FR-Chart-Map_Map", "FR-Chart-Data_Edit"});
}
/**
* 更新
*/
public void updateBeans() {
super.update();
this.update4AllType();
this.updateAllEditedAttrMaps();
MapSvgXMLHelper.getInstance().clearTempAttrMaps();
//versionID递增
this.toolBar.fireTargetModified();
this.saveMapInfo(selectedName);
}
/**
* 创建list
* @return 返回list
*/
public JNameEdList createJNameList() {
JNameEdList nameEdList = new JNameEdList(new DefaultListModel()) {
public Rectangle createRect(Rectangle rect, int iconWidth) {
return rect;
}
protected void doAfterLostFocus() {
MapArrayPane.this.updateControlUpdatePane();
}
public void setNameAt(String name, int index) {
super.setNameAt(name,index);
update4Edited(name);
}
};
nameEdList.setCellRenderer(new NameableListCellRenderer());
return nameEdList;
}
protected void update4Edited(String editingName){
}
private void updateAllEditedAttrMaps(){
MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance();
for(String editedName : editedNames){
if(helper.getMapAttr(editedName)!=null){
helper.getMapAttr(editedName).writeBack(editedName);
}else if(helper.getNewMapAttr(editedName)!=null){
helper.getNewMapAttr(editedName).writeBack(editedName);
}
}
}
//根据地图的名字返回地图的图片
private Image getMapImage(String mapName) {
if (MapSvgXMLHelper.getInstance().containsMapName(mapName)) {
MapSvgAttr mapAttr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);
if (mapAttr == null) {
return null;
}
return mapAttr.getMapImage();
}
return null;
}
/*
* Nameable的ListCellRenerer
*/
private class NameableListCellRenderer extends
DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
if (value instanceof ListModelElement) {
Nameable wrappee = ((ListModelElement) value).wrapper;
this.setText(((ListModelElement) value).wrapper.getName());
for (NameableCreator creator : MapArrayPane.this.creators()) {
if (creator.menuIcon() != null && creator.acceptObject2Populate(wrappee) != null) {
this.setIcon(creator.menuIcon());
this.setToolTipText(creator.createTooltip());
break;
}
}
}
return this;
}
}
}

210
designer_chart/src/com/fr/design/mainframe/MapPlotPane4ToolBar.java

@ -1,210 +0,0 @@
package com.fr.design.mainframe;
import com.fr.chart.base.MapSvgXMLHelper;
import com.fr.chart.chartattr.*;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.chart.ChartDesignEditPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* Date: 14/12/1
* Time: 上午11:57
*/
public class MapPlotPane4ToolBar extends AbstractMapPlotPane4ToolBar{
private static final int WORLD_MAP = 0;
private static final int STATE_MAP = 1;
private static final int PROVINCE_MAP = 2;
private static final int CUSTOM_MAP = 3;
private static final int BUTTON_WIDTH = 44;
private static final String[] TYPE_NAMES = new String[]{
Inter.getLocText("FR-Chart-World_Map"),
Inter.getLocText("FR-Chart-State_Map"),
Inter.getLocText("FR-Chart-Province_Map"),
Inter.getLocText("FR-Chart-Custom_Map")};
private String lastEditingName =StringUtils.EMPTY;
private UIButton mapEditButton = new UIButton(Inter.getLocText("FR-Chart-Data_Edit")){
public Dimension getPreferredSize() {
return new Dimension(BUTTON_WIDTH, COM_HEIGHT);
}
};
protected UIComboBox detailMaps = new UIComboBox(){
public Dimension getPreferredSize() {
return new Dimension(COMBOX_WIDTH, COM_HEIGHT);
}
};
private ItemListener detailListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
fireMapChange();
}
};
private ActionListener mapEditListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String selectedName =StringUtils.EMPTY;
if(detailMaps.getSelectedItem() != null){
selectedName = detailMaps.getSelectedItem().toString();
}
final MapArrayPane mapArrayPane = new MapArrayPane(mapTypeComboBox.getSelectedItem().toString(),selectedName,chartDesigner){
public void updateBeans() {
super.updateBeans();
if(reCalculateDetailsMaps(mapTypeComboBox.getSelectedItem().toString(),lastEditingName) ||
ComparatorUtils.equals(StringUtils.EMPTY,lastEditingName)){
detailMaps.setSelectedItem(lastEditingName);
ChartCollection chartCollection = (ChartCollection)chartDesigner.getTarget().getChartCollection();
com.fr.chart.chartattr.Chart chart =chartCollection.getSelectedChart();
if(chart.getPlot().isMapPlot()){
MapPlot mapPlot = (MapPlot) chart.getPlot();
mapPlot.setMapName(lastEditingName);
}
}
}
protected void update4Edited(String editingName){
lastEditingName = editingName;
}
};
BasicDialog mapArrayDialog = mapArrayPane.showWindow4ChartMapArray(DesignerContext.getDesignerFrame(),
new DialogActionAdapter() {
@Override
public void doOk() {
mapArrayPane.updateBeans();
}
});
mapArrayDialog.setModal(true);
mapArrayPane.setToolBarPane(MapPlotPane4ToolBar.this);
mapArrayPane.populate(MapSvgXMLHelper.getInstance().getAllMapObjects4Cate(mapTypeComboBox.getSelectedItem().toString()));
if(detailMaps.getSelectedItem() != null){
mapArrayPane.setSelectedName(detailMaps.getSelectedItem().toString());
}
mapArrayDialog.setVisible(true);
}
};
public MapPlotPane4ToolBar(ChartDesigner chartDesigner){
super(chartDesigner);
this.add(detailMaps);
detailMaps.addItemListener(detailListener);
mapEditButton.addActionListener(mapEditListener);
this.add(mapEditButton);
}
/**
* 更新地图面板
* @param mapType 地图名字
*/
public void populateMapPane(String mapType){
super.populateMapPane(mapType);
populateDetilMaps(mapTypeComboBox.getSelectedItem().toString());
detailMaps.removeItemListener(detailListener);
detailMaps.setSelectedItem(mapType);
detailMaps.addItemListener(detailListener);
}
/**
* 触发地图改变
*/
public void fireMapChange(){
MapPlot plot = new MapPlot();
String selectedName = StringUtils.EMPTY;
if(detailMaps.getSelectedItem() !=null ){
selectedName = detailMaps.getSelectedItem().toString();
}
plot.setMapName(selectedName);// 名字问题
ChartCollection chartCollection = (ChartCollection)chartDesigner.getTarget().getChartCollection();
Chart chart =chartCollection.getSelectedChart();
chart.setPlot(plot);
ChartDesignEditPane.getInstance().populate(chartCollection);
chartDesigner.fireTargetModified();
}
//默认选中国家地图
protected void calculateDetailMaps(int mapType){
switch (mapType) {
case WORLD_MAP:
populateDetilMaps(Inter.getLocText("FR-Chart-World_Map"));
break;
case STATE_MAP:
populateDetilMaps(Inter.getLocText("FR-Chart-State_Map"));
break;
case PROVINCE_MAP:
populateDetilMaps(Inter.getLocText("FR-Chart-Province_Map"));
break;
case CUSTOM_MAP:
populateDetilMaps(Inter.getLocText("FR-Chart-Custom_Map"));
break;
default:
populateDetilMaps(Inter.getLocText("FR-Chart-State_Map"));
}
fireMapChange();
}
private boolean reCalculateDetailsMaps(String mapType ,String detailMap){
detailMaps.removeItemListener(detailListener);
detailMaps.removeAllItems();
java.util.List list = MapSvgXMLHelper.getInstance().getNamesListWithCateName(mapType);
boolean isContains = false;
for (Object name : list) {
detailMaps.addItem(name);
if(ComparatorUtils.equals(detailMap,name)){
isContains = true;
}
}
detailMaps.addItemListener(detailListener);
return isContains;
}
protected void populateDetilMaps(String mapType){
detailMaps.removeItemListener(detailListener);
detailMaps.removeAllItems();
java.util.List list = MapSvgXMLHelper.getInstance().getNamesListWithCateName(mapType);
for (Object name : list) {
detailMaps.addItem(name);
}
detailMaps.addItemListener(detailListener);
if(detailMaps.getSelectedItem() != null){
lastEditingName = detailMaps.getSelectedItem().toString();
}
}
protected Plot getSelectedClonedPlot() {
MapPlot mapPlot = new MapPlot();
populateDetilMaps(Inter.getLocText("FR-Chart-State_Map"));
if(detailMaps.getSelectedItem()!= null && !StringUtils.isEmpty(detailMaps.getSelectedItem().toString())){
mapPlot.setMapName(detailMaps.getSelectedItem().toString());
}
return mapPlot;
}
public String[] getMapTypes(){
return TYPE_NAMES;
}
}

17
designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java

@ -3,14 +3,10 @@
*/ */
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.BorderLayout;
import javax.swing.Icon;
import javax.swing.JComponent;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.chart.ChartEditPaneProvider;
@ -19,7 +15,9 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.gui.itabpane.TitleChangeListener;
import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{
@ -38,10 +36,13 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{
createNameLabel(); createNameLabel();
this.add(createNorthComponent(), BorderLayout.NORTH); this.add(createNorthComponent(), BorderLayout.NORTH);
}
chartEditPane = StableUtils.construct(ChartEditPane.class); public void addChartEditPane(String plotID){
chartEditPane = ChartTypeInterfaceManager.getInstance().getChartEditPane(plotID);
chartEditPane.setSupportCellData(true); chartEditPane.setSupportCellData(true);
this.createMainPane(); this.createMainPane();
setSureProperty();
} }
protected abstract void createNameLabel(); protected abstract void createNameLabel();
@ -86,6 +87,8 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{
* @param ePane 面板 * @param ePane 面板
*/ */
public void populateChartPropertyPane(ChartCollection collection, TargetComponent<?> ePane) { public void populateChartPropertyPane(ChartCollection collection, TargetComponent<?> ePane) {
addChartEditPane(collection.getSelectedChart().getPlot().getPlotID());
setSupportCellData(true);
this.container.setEPane(ePane); this.container.setEPane(ePane);
chartEditPane.populate(collection); chartEditPane.populate(collection);
} }

90
designer_chart/src/com/fr/design/mainframe/PlotToolBarFactory.java

@ -1,90 +0,0 @@
package com.fr.design.mainframe;
import com.fr.chart.base.ChartTypeValueCollection;
import com.fr.design.mainframe.chart.gui.type.*;
import com.fr.general.FRLogger;
import java.lang.reflect.Constructor;
import java.util.HashMap;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* 图表设计器工具栏面板的工厂类
*/
public class PlotToolBarFactory {
private static HashMap<ChartTypeValueCollection,Class<? extends PlotPane4ToolBar>> panes4NormalPlot =
new HashMap<ChartTypeValueCollection, Class<? extends PlotPane4ToolBar>>();
private static HashMap<ChartTypeValueCollection,Class<? extends AbstractMapPlotPane4ToolBar>> panes4MapPlot =
new HashMap<ChartTypeValueCollection, Class<? extends AbstractMapPlotPane4ToolBar>>();
static {
panes4NormalPlot.put(ChartTypeValueCollection.COLUMN, ColumnPlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.LINE, LinePlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.BAR, BarPlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.PIE, PiePlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.AREA,AreaPlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.XYSCATTER,XYSCatterPlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.BUBBLE,BubblePlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.RADAR,RadarPlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.STOCK,StockPlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.METER,MeterPlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.RANGE,RangePlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.COMB,CustomPlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.GANTT,GanttPlotPane4ToolBar.class);
panes4NormalPlot.put(ChartTypeValueCollection.DONUT,DonutPlotPane4ToolBar.class);
panes4MapPlot.put(ChartTypeValueCollection.MAP,MapPlotPane4ToolBar.class);
panes4MapPlot.put(ChartTypeValueCollection.GIS,GisMapPlotPane4ToolBar.class);
}
private PlotToolBarFactory(){
}
/**
* 为了地图和gis以外的图表类型创建工具栏
* @param type 图表类型
* @param chartDesigner 图表设计器
* @return 工具栏
*/
public static PlotPane4ToolBar createToolBar4NormalPlot(ChartTypeValueCollection type,ChartDesigner chartDesigner){
if(!panes4NormalPlot.containsKey(type)){
return new ColumnPlotPane4ToolBar(chartDesigner);
}
try {
Class<? extends PlotPane4ToolBar> cls = panes4NormalPlot.get(type);
Constructor<? extends PlotPane4ToolBar > constructor = cls.getConstructor(ChartDesigner.class);
return constructor.newInstance(chartDesigner);
}catch (Exception e){
FRLogger.getLogger().error(e.getMessage());
return new ColumnPlotPane4ToolBar(chartDesigner);
}
}
/**
*为地图和gis创建工具栏
* @param type 类型
* @param chartDesigner 图表设计器
* @return 工具栏
*/
public static AbstractMapPlotPane4ToolBar createToolBar4MapPlot(ChartTypeValueCollection type,ChartDesigner chartDesigner){
if(!panes4MapPlot.containsKey(type)){
return new MapPlotPane4ToolBar(chartDesigner);
}
try {
Class<? extends AbstractMapPlotPane4ToolBar> cls = panes4MapPlot.get(type);
Constructor<? extends AbstractMapPlotPane4ToolBar > constructor = cls.getConstructor(ChartDesigner.class);
return constructor.newInstance(chartDesigner);
}catch (Exception e){
FRLogger.getLogger().error(e.getMessage());
return new MapPlotPane4ToolBar(chartDesigner);
}
}
}

91
designer_chart/src/com/fr/design/mainframe/ToolTip4Chart.java

@ -1,91 +0,0 @@
package com.fr.design.mainframe;
import com.fr.base.GraphHelper;
import com.fr.base.background.ColorBackground;
import com.fr.stable.CoreConstants;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Dimension2D;
import java.awt.geom.RoundRectangle2D;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-25
* Time: 下午4:11
*/
public class ToolTip4Chart extends JWindow {
private static ToolTip4Chart instance = new ToolTip4Chart();
private static final int HGAP = 5;
private static final int VGAP = 3;
private static final int FONT_SIZE = 12;
private ToolTipStringPane stringPane;
private Font font = new Font("Dialog", Font.PLAIN, FONT_SIZE);
public ToolTip4Chart() {
stringPane = new ToolTipStringPane();
this.getContentPane().add(stringPane);
}
public static ToolTip4Chart getInstance() {
if (instance == null) {
instance = new ToolTip4Chart();
}
return instance;
}
/**
* 现实提示信息
*
* @param toolTip 提示信息
* @param xAbs 绝对位置x
* @param yAbs 绝对位置Y
*/
public void showToolTip(String toolTip, int xAbs, int yAbs) {
stringPane.text = toolTip.trim();
Dimension2D dim = GraphHelper.stringDimensionWithRotation(toolTip, font, 0, CoreConstants.DEFAULT_FRC);
this.setSize(new Dimension((int) dim.getWidth() + HGAP * 2, (int) dim.getHeight() + VGAP * 2));
stringPane.setPreferredSize(new Dimension((int) dim.getWidth(), (int) dim.getHeight()));
if (!this.isVisible()) {
this.setVisible(true);
if (xAbs + this.getWidth() > Toolkit.getDefaultToolkit().getScreenSize().width) {
xAbs -= this.getWidth();
}
this.setLocation(xAbs, yAbs+HGAP*2);
}
}
/**
* 隐藏弹出框
*/
public void hideToolTip() {
this.setVisible(false);
}
private class ToolTipStringPane extends JPanel {
String text;
public ToolTipStringPane() {
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (!isOpaque()) {
return;
}
g.setFont(font);
Rectangle r = new Rectangle(0, 0, this.getWidth(), this.getHeight());
ColorBackground background = ColorBackground.getInstance(Color.white);
background.paint(g, new RoundRectangle2D.Double(r.getX(), r.getY(), r.getWidth(), r.getHeight(), HGAP, HGAP));
Graphics2D g2d = (Graphics2D) g;
g2d.drawString(text, HGAP, this.getHeight() - HGAP);
}
}
}

170
designer_chart/src/com/fr/design/mainframe/actions/ChartDownLoadWorker.java

@ -1,170 +0,0 @@
package com.fr.design.mainframe.actions;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.SaveSomeTemplatePane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.json.JSONObject;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class ChartDownLoadWorker extends SwingWorker<Void, Double>{
private static final String FILE_PATH = "http://chart.finedevelop.com/update/";
private static final String VERSION = "version";
private static final String TEMP = "_temp";
private static final int BYTE = 153600;
private static final int FILE_BYTE = 1024;
private HashMap<String,String> files = new HashMap<String, String>();
public ChartDownLoadWorker() {
}
private void loadFilesPaths() throws Exception {
files.clear();
final String installHome = StableUtils.getInstallHome();
JSONObject serverVersion = UpdateVersion.getJsonContent();
if(serverVersion == null){
return;
}
Iterator<String> keys = serverVersion.keys();
while (keys.hasNext()){
String jarName = keys.next();
if(!ComparatorUtils.equals(jarName, VERSION)){
String filePath = (String) serverVersion.get(jarName);
String path =installHome + filePath.substring(2);
files.put(jarName,path);
}
}
files.isEmpty();
}
@Override
protected Void doInBackground() throws Exception {
try {
loadFilesPaths();
Set key = files.keySet();
Iterator iterator = key.iterator();
int totalSize = 0;
//先得到所有的长度,方便计算百分比
while (iterator.hasNext()) {
String jarName = (String) iterator.next();
String jarUrl = FILE_PATH + jarName;
URL url = new URL(jarUrl);
URLConnection connection = url.openConnection();
totalSize += connection.getContentLength();
}
int totalBytesRead = 0;
iterator = key.iterator();
while (iterator.hasNext()) {
String jarName = (String) iterator.next();
String jarUrl = FILE_PATH + jarName;
URL url = new URL(jarUrl);
InputStream reader = url.openStream();
String filePath = files.get(jarName);
int point = filePath.lastIndexOf(".");
//先写临时文件,防止更新一半意外中止
String tmpFilePath = filePath.substring(0,point)+TEMP+filePath.substring(point);
FileOutputStream writer = new FileOutputStream(tmpFilePath);
byte[] buffer = new byte[BYTE];
int bytesRead = 0;
while ((bytesRead = reader.read(buffer)) > 0) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[BYTE];
totalBytesRead += bytesRead;
publish(totalBytesRead/(double)totalSize);
}
}
} catch (Exception e) {
throw new Exception("Update Failed !" + e.getMessage());
}
return null;
}
//替换更新下来的临时文件
protected void replaceFiles(){
try {
Set key = files.keySet();
Iterator iterator = key.iterator();
while (iterator.hasNext()) {
String jarName = (String) iterator.next();
String filePath = files.get(jarName);
int point = filePath.lastIndexOf(".");
//先写临时文件,防止更新一半意外中止
String tmpFilePath = filePath.substring(0,point)+TEMP+filePath.substring(point);
FileInputStream inputStream = new FileInputStream(tmpFilePath);
FileOutputStream writer = new FileOutputStream(filePath);
byte[] buffer = new byte[FILE_BYTE];
int bytesRead = 0;
while ((bytesRead = inputStream.read(buffer))>0){
writer.write(buffer,0,bytesRead);
buffer = new byte[FILE_BYTE];
}
writer.flush();
writer.close();
inputStream.close();
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
}
/**
* 完成时的动作
*/
public void done() {
//检测是否没有保存的模版
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
// 只有一个文件未保存时
if (HistoryTemplateListPane.getInstance().getHistoryCount() == 1) {
int choose = saveSomeTempaltePane.saveLastOneTemplate();
if (choose != JOptionPane.CANCEL_OPTION) {
restartChartDesigner();
}
} else {
if (saveSomeTempaltePane.showSavePane()) {
restartChartDesigner();
}
}
}
private void restartChartDesigner(){
String installHome = StableUtils.getInstallHome();
if(StringUtils.isEmpty(installHome) || ComparatorUtils.equals(".",installHome)){
DesignerContext.getDesignerFrame().exit();
return;
}
try {
String path = installHome + File.separator + "bin" + File.separator + "restart.bat";
ProcessBuilder builder = new ProcessBuilder(path,installHome);
builder.start();
DesignerContext.getDesignerFrame().exit();
}catch (Exception e){
FRLogger.getLogger().error(e.getMessage());
}
}
}

51
designer_chart/src/com/fr/design/mainframe/actions/ChartFeedBackAciton.java

@ -1,51 +0,0 @@
package com.fr.design.mainframe.actions;
import com.fr.design.actions.help.FeedBackAction;
import com.fr.design.actions.help.FeedBackPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class ChartFeedBackAciton extends FeedBackAction{
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
ChartFeedBackPane feedBackPane = new ChartFeedBackPane();
BasicDialog basicDialog =feedBackPane.showWindow(designerFrame,false);
feedBackPane.setFeedbackDialog(basicDialog);
basicDialog.setVisible(true);
}
private class ChartFeedBackPane extends FeedBackPane{
protected JPanel getContactPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("email") + ":", SwingConstants.RIGHT), email},
new Component[]{new UILabel(Inter.getLocText("mobile_number") + ":", SwingConstants.RIGHT), phone}
};
double[] rowSize = {p, p, p};
double[] columnSize = {p, p};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
}
}
}

25
designer_chart/src/com/fr/design/mainframe/actions/ChartUpdateAction.java

@ -1,25 +0,0 @@
package com.fr.design.mainframe.actions;
import com.fr.design.actions.UpdateAction;
import java.awt.event.ActionEvent;
/**
* @author : richie
* @since : 8.0
*/
public class ChartUpdateAction extends UpdateAction {
private static final String DOWNLOAD_DESIGNER="";
private static final String DOWNLOAD_CHART="";
private static final String DOWNLOAD_THIRD="";
public ChartUpdateAction() {
}
@Override
public void actionPerformed(ActionEvent e) {
}
}

56
designer_chart/src/com/fr/design/mainframe/actions/ChartWebAction.java

@ -1,56 +0,0 @@
package com.fr.design.mainframe.actions;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import com.fr.start.StartServer;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* 图表设计器得产品演示
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-27
* Time: 下午9:01
*/
public class ChartWebAction extends UpdateAction {
public ChartWebAction() {
this.setMenuKeySet(getSelfMenuKeySet());
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_help/demo.png"));
}
private MenuKeySet getSelfMenuKeySet(){
return new MenuKeySet() {
@Override
public char getMnemonic() {
return 'D';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Chart-Product_Demo");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
StartServer.browerURLWithLocalEnv("http://www.vancharts.com/demo.html");
return;
}
}

35
designer_chart/src/com/fr/design/mainframe/actions/OpenChartAction.java

@ -1,35 +0,0 @@
package com.fr.design.mainframe.actions;
import com.fr.design.actions.file.OpenTemplateAction;
import com.fr.design.mainframe.DesignerContext;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.FILEChooserPane4Chart;
import java.awt.event.ActionEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-20
* Time: 下午7:35
*/
public class OpenChartAction extends OpenTemplateAction {
/**
* 动作
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
FILEChooserPane fileChooser = FILEChooserPane4Chart.getInstance(true, true);
if (fileChooser.showOpenDialog(DesignerContext.getDesignerFrame(),".crt")
== FILEChooserPane.OK_OPTION) {
final FILE file = fileChooser.getSelectedFILE();
if (file == null) {//选择的文件不能是 null
return;
}
DesignerContext.getDesignerFrame().openTemplate(file);
}
}
}

74
designer_chart/src/com/fr/design/mainframe/actions/UpdateOnlineAction.java

@ -1,74 +0,0 @@
package com.fr.design.mainframe.actions;
import com.fr.design.ChartEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.chart.UpdateOnLinePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* 图表设计器在线更新
*/
public class UpdateOnlineAction extends UpdateAction {
public UpdateOnlineAction() {
this.setMenuKeySet(getKeySet());
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
}
private MenuKeySet getKeySet() {
return new MenuKeySet() {
@Override
public char getMnemonic() {
return 'U';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Chart-Help_UpdateOnline");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}
/**
*动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
new UpdateVersion(){
protected void done() {
try {
ChartEnvManager.getEnvManager().resetCheckDate();
JSONObject serverVersion = get();
String version = serverVersion.getString(UpdateVersion.VERSION);
UpdateOnLinePane updateOnLinePane = new UpdateOnLinePane(StringUtils.isEmpty(version)? ProductConstants.RELEASE_VERSION:version);
BasicDialog dg = updateOnLinePane.showWindow4UpdateOnline(DesignerContext.getDesignerFrame());
updateOnLinePane.setParentDialog(dg);
dg.setVisible(true);
}catch (Exception e){
FRLogger.getLogger().error(e.getMessage());
}
}
}.execute();
}
}

69
designer_chart/src/com/fr/design/mainframe/actions/UpdateVersion.java

@ -1,69 +0,0 @@
package com.fr.design.mainframe.actions;
import com.fr.general.FRLogger;
import com.fr.json.JSONObject;
import javax.swing.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
*/
public class UpdateVersion extends SwingWorker<JSONObject,Void> {
private static final String VERSION_URL ="http://chart.finedevelop.com/update/update.json";
private static final int TIME_OUT = 300;//5s
public static final String VERSION = "version";
public UpdateVersion(){
}
@Override
protected JSONObject doInBackground() throws Exception {
return getJsonContent();
}
public static JSONObject getJsonContent() throws Exception{
String res = null;
try {
res = readVersionFromServer(TIME_OUT);
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
}
return new JSONObject(res);
}
/**
* 从服务器读取版本
*/
private static String readVersionFromServer(int timeOut) throws IOException {
URL getUrl = new URL(VERSION_URL);
// 根据拼凑的URL,打开连接,URL.openConnection函数会根据URL的类型,
// 返回不同的URLConnection子类的对象,这里URL是一个http,因此实际返回的是HttpURLConnection
HttpURLConnection connection = (HttpURLConnection) getUrl
.openConnection();
connection.setReadTimeout(timeOut);
// 进行连接,但是实际上get request要在下一句的connection.getInputStream()函数中才会真正发到
// 服务器
connection.connect();
// 取得输入流,并使用Reader读取
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf8"));//设置编码,否则中文乱码
String lines;
StringBuffer sb = new StringBuffer();
while ((lines = reader.readLine()) != null) {
sb.append(lines);
}
reader.close();
// 断开连接
connection.disconnect();
return sb.toString();
}
}

55
designer_chart/src/com/fr/design/mainframe/chart/ChartDesignEditPane.java

@ -1,55 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.chart;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.chart.gui.*;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 下午5:47
*/
public class ChartDesignEditPane extends ChartEditPane {
private static ChartDesignEditPane instance;
private boolean isFromToolBar = false;
public synchronized static ChartEditPane getInstance() {
if (instance == null) {
instance = new ChartDesignEditPane();
}
return instance;
}
public ChartDesignEditPane() {
paneList = new ArrayList<AbstractChartAttrPane>();
dataPane4SupportCell = new ChartDesignerDataPane(listener);
paneList.add(dataPane4SupportCell);
paneList.add(new StylePane4Chart(listener, false));
paneList.add(new ChartDesignerOtherPane());
createTabsPane();
}
protected void dealWithStyleChange(){
if(!isFromToolBar){
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().styleChange();
}
}
/**
*主要用于图表设计器判断样式改变是否来自工具栏的全局样式按钮
* @param isFromToolBar 是否来自工具栏
*/
public void styleChange(boolean isFromToolBar){
this.isFromToolBar = isFromToolBar;
}
}

2
designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java

@ -51,7 +51,6 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
protected JPanel center; protected JPanel center;
private TargetComponentContainer container = null; private TargetComponentContainer container = null;
private TitleChangeListener titleChangeListener = null; private TitleChangeListener titleChangeListener = null;
private Calendar lastTime; private Calendar lastTime;
protected ChartEditPane() { protected ChartEditPane() {
@ -108,6 +107,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
} }
AbstractChartAttrPane selectedPane = paneList.get(tabsHeaderIconPane.getSelectedIndex()); AbstractChartAttrPane selectedPane = paneList.get(tabsHeaderIconPane.getSelectedIndex());
selectedPane.update(collection); selectedPane.update(collection);
if (!ComparatorUtils.equals(collection, lastCollection)) { if (!ComparatorUtils.equals(collection, lastCollection)) {
//此处画图 //此处画图

39
designer_chart/src/com/fr/design/mainframe/chart/ChartsConfigPane.java

@ -0,0 +1,39 @@
package com.fr.design.mainframe.chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.general.Inter;
import javax.swing.*;
/**
* Created by mengao on 2017/5/16.
*/
public class ChartsConfigPane extends AbstractChartAttrPane {
public final static String CHART_STYLE_TITLE = Inter.getLocText("Chart-Style_Name");
@Override
public void populate(ChartCollection collection) {
}
@Override
public void update(ChartCollection collection) {
}
@Override
protected JPanel createContentPane() {
return new JPanel();
}
@Override
public String getIconPath() {
return "com/fr/design/images/chart/ChartStyle.png";
}
@Override
public String title4PopupWindow() {
return CHART_STYLE_TITLE;
}
}

56
designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java

@ -0,0 +1,56 @@
package com.fr.design.mainframe.chart;
import com.fr.chart.chartattr.Chart;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import java.awt.*;
import java.util.ArrayList;
/**
* Created by mengao on 2017/5/3.
*/
public class ChartsEditPane extends ChartEditPane {
protected ChartsConfigPane chartsConfigPane;
public ChartsEditPane() {
this.setLayout(new BorderLayout());
paneList = new ArrayList<AbstractChartAttrPane>();
dataPane4SupportCell = new ChartDataPane(listener);
dataPane4SupportCell.setSupportCellData(true);
chartsConfigPane = new ChartsConfigPane();
paneList.add(dataPane4SupportCell);
paneList.add(chartsConfigPane);
createTabsPane();
}
/**
* 重新构造面板
* @param currentChart 图表
*/
public void reLayout(Chart currentChart) {
if (currentChart != null) {
this.removeAll();
this.setLayout(new BorderLayout());
paneList = new ArrayList<AbstractChartAttrPane>();
String plotID = "";
if (currentChart.getPlot() != null) {
plotID = currentChart.getPlot().getPlotID();
}
dataPane4SupportCell = createChartDataPane(plotID);
chartsConfigPane = ChartTypeInterfaceManager.getInstance().getChartConfigPane(plotID);
paneList.add(dataPane4SupportCell);
paneList.add(chartsConfigPane);
createTabsPane();
}
}
}

238
designer_chart/src/com/fr/design/mainframe/chart/UpdateOnLinePane.java

@ -1,238 +0,0 @@
package com.fr.design.mainframe.chart;
import com.fr.design.ChartEnvManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.actions.ChartDownLoadWorker;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.stable.ProductConstants;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.text.DecimalFormat;
import java.text.NumberFormat;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 7.1.1
* 在线更新面板
*/
public class UpdateOnLinePane extends BasicPane{
private static final int GAP = 40;
private static final int H_GAP = 16;
private static final int SIDE_GAP =30;
private static final int RIGHT_BORDER_GAP = 34;
private static final Color LABEL_COLOR = new Color(114,114,114);
private static final int MESSAGE_FONT_SIZE = 20;
private static final int PUSH_FONT_SIZE = 12;
private static final int PROGRESS_WIDTH = 500;
private static final int PROGRESS_HEIGHT = 14;
private static final NumberFormat NUMBER_FORMAT = new DecimalFormat("##.##");
private static final int PRECENT =100;
private static final Color FOREGROUNG = new Color(23,190,86);
private static final Color BACKGROUND = new Color(210,210,210);
String serverVersion = ProductConstants.RELEASE_VERSION;
UIButton okButton = new UIButton(Inter.getLocText("FR-Chart-Dialog_OK"));
UIButton updateButton = new UIButton(Inter.getLocText("FR-Chart-App_Update"));
UIButton cancleButton = new UIButton(Inter.getLocText("FR-Chart-Dialog_Cancle"));
UICheckBox pushAuto = new UICheckBox(Inter.getLocText("FR-Chart-UpdateMessage_PushAuto"));
private JPanel messagePane;
private JPanel optionsPane;
private BasicDialog parentDialog;
private ChartDownLoadWorker downLoadWorker = null;
private boolean isUpdateCancle = false;
private ActionListener updateListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JProgressBar progressBar = init4UpdatingPane();
downLoadWorker = new ChartDownLoadWorker(){
protected void process(java.util.List<Double> v) {
progressBar.setValue((int)(v.get(v.size() - 1) * PRECENT));
}
public void done() {
try {
get();
} catch (Exception e1) {
init4UpdateFaild();
return;
}
if(!isUpdateCancle){
replaceFiles();
dialogExit();
super.done();
}
}
};
downLoadWorker.execute();
}
};
private ActionListener okListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialogExit();
}
};
private ActionListener cancleListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(downLoadWorker !=null){
isUpdateCancle = true;
downLoadWorker.cancel(true);
}
dialogExit();
}
};
public void setParentDialog(BasicDialog dialog){
this.parentDialog = dialog;
}
public UpdateOnLinePane(String serverVersion){
this.serverVersion = serverVersion;
this.isUpdateCancle = false;
pushAuto.setSelected(ChartEnvManager.getEnvManager().isPushUpdateAuto());
pushAuto.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
ChartEnvManager.getEnvManager().setPushUpdateAuto(pushAuto.isSelected());
}
});
init4PanesLayout();
initListeners();
judge();
}
private void initListeners(){
updateButton.addActionListener(updateListener);
okButton.addActionListener(okListener);
cancleButton.addActionListener(cancleListener);
}
private void init4PanesLayout(){
this.setLayout(new BorderLayout());
this.messagePane = FRGUIPaneFactory.createBorderLayout_L_Pane();
this.optionsPane = new JPanel(new FlowLayout(FlowLayout.RIGHT,H_GAP ,0)) ;
this.optionsPane.setBorder(new EmptyBorder(0, 0, GAP, RIGHT_BORDER_GAP));
this.add(this.messagePane, BorderLayout.CENTER);
this.add(this.optionsPane, BorderLayout.SOUTH);
pushAuto.setFont(new Font(Inter.getLocText("FR-Designer-All_MSBold"), 0, PUSH_FONT_SIZE));
pushAuto.setForeground(LABEL_COLOR);
this.revalidate();
}
//更新失败的提示
private void init4UpdateFaild(){
this.messagePane.removeAll();
UILabel label = new UILabel(Inter.getLocText("FR-Chart-Version_UpdateFail")+"!");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(new Font(Inter.getLocText("FR-Designer-All_MSBold"), 0, MESSAGE_FONT_SIZE));
label.setForeground(LABEL_COLOR);
this.messagePane.add(label,BorderLayout.CENTER);
optionsPane.removeAll();
optionsPane.add(okButton);
this.revalidate();
}
private JProgressBar init4UpdatingPane(){
this.messagePane.removeAll();
JPanel centerPane = new JPanel(new GridLayout(2,1));
UILabel label = new UILabel(Inter.getLocText("FR-Chart-App_UpdateProgress"));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(new Font(Inter.getLocText("FR-Designer-All_MSBold"), 0, MESSAGE_FONT_SIZE));
label.setForeground(LABEL_COLOR);
label.setBorder(new EmptyBorder(PUSH_FONT_SIZE,0,0,0));
centerPane.add(label);
JProgressBar progressBar = new JProgressBar();
progressBar.setMaximum(PRECENT);
progressBar.setMinimum(0);
progressBar.setValue(0);
progressBar.setBorder(new EmptyBorder(MESSAGE_FONT_SIZE,SIDE_GAP,SIDE_GAP*2,SIDE_GAP));
centerPane.add(progressBar);
messagePane.add(centerPane,BorderLayout.CENTER);
optionsPane.removeAll();
optionsPane.add(cancleButton);
this.revalidate();
return progressBar;
}
private void init4VersionSamePane(){
this.messagePane.removeAll();
UILabel label = new UILabel(Inter.getLocText("FR-Chart-Versions_Lasted"));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(new Font(Inter.getLocText("FR-Designer-All_MSBold"), 0, MESSAGE_FONT_SIZE));
label.setForeground(LABEL_COLOR);
this.messagePane.add(label,BorderLayout.CENTER);
optionsPane.removeAll();
optionsPane.add(pushAuto);
optionsPane.add(okButton);
this.revalidate();
}
private void init4VersionDifferentPane(){
this.messagePane.removeAll();
createPaneShowVersions();
optionsPane.removeAll();
optionsPane.add(pushAuto);
optionsPane.add(updateButton);
optionsPane.add(cancleButton);
this.revalidate();
}
private void createPaneShowVersions(){
JPanel centerPane = new JPanel(new GridLayout(2,1));
UILabel localLabel = new UILabel(Inter.getLocText("FR-Chart-Version_Local")+":"+ ProductConstants.RELEASE_VERSION);
localLabel.setFont(new Font(Inter.getLocText("FR-Designer-All_MSBold"), 0, MESSAGE_FONT_SIZE));
localLabel.setForeground(LABEL_COLOR);
localLabel.setBorder(new EmptyBorder(PUSH_FONT_SIZE,0,0,0));
UILabel serverLabel = new UILabel(Inter.getLocText("FR-Chart-Version_Lasted")+":"+serverVersion);
serverLabel.setFont(new Font(Inter.getLocText("FR-Designer-All_MSBold"), 0, MESSAGE_FONT_SIZE));
serverLabel.setForeground(LABEL_COLOR);
serverLabel.setBorder(new EmptyBorder(-MESSAGE_FONT_SIZE - PUSH_FONT_SIZE, 0, 0,0));
localLabel.setHorizontalAlignment(SwingConstants.CENTER);
serverLabel.setHorizontalAlignment(SwingConstants.CENTER);
centerPane.add(localLabel);
centerPane.add(serverLabel);
messagePane.add(centerPane,BorderLayout.CENTER);
}
private void judge(){
if(ComparatorUtils.equals(ProductConstants.RELEASE_VERSION,serverVersion)){
//版本一致,提示已经是最新版本
init4VersionSamePane();
}else{
init4VersionDifferentPane();
}
}
/**
* Dialog exit.
*/
private void dialogExit() {
parentDialog.setVisible(false);
parentDialog.dispose();
}
protected String title4PopupWindow() {
return Inter.getLocText("FR-Chart-Help_UpdateOnline");
}
}

71
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartDesignerDataPane.java

@ -1,71 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.chart.gui;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.GisMapPlot;
import com.fr.chart.chartattr.MapPlot;
import com.fr.design.chart.report.GisMapDataPane4Chart;
import com.fr.design.chart.report.MapDataPane4Chart;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.gui.data.ImportSetChartDataPane;
import com.fr.general.FRLogger;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 下午1:57
*/
public class ChartDesignerDataPane extends ChartDataPane {
private AttributeChangeListener listener;
public ChartDesignerDataPane(AttributeChangeListener listener) {
super(listener);
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
FRLogger.getLogger().info("SD");
}
});
this.listener = listener;
}
@Override
protected JPanel createContentPane() {
contentsPane = new ImportSetChartDataPane(listener,ChartDesignerDataPane.this);
return contentsPane;
}
protected void repeatLayout(ChartCollection collection) {
if(contentsPane != null) {
this.remove(contentsPane);
}
this.setLayout(new BorderLayout(0, 0));
if (collection.getSelectedChart().getPlot() instanceof MapPlot) {
contentsPane = new MapDataPane4Chart(listener,this);
}else if(collection.getSelectedChart().getPlot() instanceof GisMapPlot){
contentsPane = new GisMapDataPane4Chart(listener,this);
} else{
contentsPane = new ImportSetChartDataPane(listener,ChartDesignerDataPane.this);
}
}
/**
* 主要用于图表设计器
* @return
*/
public boolean isNeedPresentPaneWhenFilterData(){
return true;
}
}

48
designer_chart/src/com/fr/design/mainframe/chart/gui/data/ChartDesignDataLoadPane.java

@ -1,48 +0,0 @@
package com.fr.design.mainframe.chart.gui.data;
import com.fr.base.TableData;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.design.dialog.BasicPane;
import com.fr.design.mainframe.AbstractChartDataPane4Chart;
/**
* 图表设计器导入 界面
* Created by kunsnat on 14-10-21.
* kunsnat@gmail.com
*/
public abstract class ChartDesignDataLoadPane extends BasicPane {
private AbstractChartDataPane4Chart parentPane;
public ChartDesignDataLoadPane(AbstractChartDataPane4Chart parentPane){
this.parentPane = parentPane;
}
/**
* 加载数据集
*
* @param tableData 数据集
*/
public abstract void populateChartTableData(TableData tableData);
/**
* 根据界面 获取数据集相关.
*
* @return 返回数据集
*/
public abstract TableData getTableData();
protected abstract String getNamePrefix();
//响应属性事件
protected void fireChange() {
parentPane.fireTableDataChange();
}
public TableDataWrapper getTableDataWrapper(){
return new TemplateTableDataWrapper(getTableData());
}
}

124
designer_chart/src/com/fr/design/mainframe/chart/gui/data/EmbbeddDataPane.java

@ -1,124 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.chart.gui.data;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.TableData;
import com.fr.design.constants.UIConstants;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.design.data.tabledata.tabledatapane.EmbeddedTableDataPane;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.AbstractChartDataPane4Chart;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* 图表设计器内置数据集面板
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-16
* Time: 上午12:09
*/
public class EmbbeddDataPane extends ChartDesignDataLoadPane {
private UIButton edit;
private UIButton reviewButton;
private EmbeddedTableData tableData;
public EmbbeddDataPane(AbstractChartDataPane4Chart parentPane) {
super(parentPane);
tableData = new EmbeddedTableData();
initEditButton();
initReviewButton();
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 3));
this.add(edit);
this.add(reviewButton);
}
private void initEditButton() {
edit = new UIButton(BaseUtils.readIcon("com/fr/design/images/control/edit.png"));
edit.setBorder(new LineBorder(UIConstants.LINE_COLOR));
edit.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
EmbeddedTableDataPane tableDataPane = new EmbeddedTableDataPane();
tableDataPane.populateBean(tableData);
dgEdit(tableDataPane, getNamePrefix());
}
});
}
private void initReviewButton() {
reviewButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/search.png"));
reviewButton.setBorder(new LineBorder(UIConstants.LINE_COLOR));
reviewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
//预览图表设计器内置数据集
TableDataWrapper tableDataWrappe = getTableDataWrapper();
if (tableDataWrappe != null) {
try {
tableDataWrappe.previewData();
} catch (Exception e1) {
FRContext.getLogger().error(e1.getMessage(), e1);
}
}
}
});
}
@Override
protected String title4PopupWindow() {
return null;
}
@Override
public TableData getTableData() {
return tableData;
}
/**
* 加载数据集
*
* @param tableData 数据集
*/
public void populateChartTableData(TableData tableData) {
if (tableData instanceof EmbeddedTableData) {
this.tableData =(EmbeddedTableData) tableData;
}
}
protected String getNamePrefix() {
return "Embedded";
}
/**
* 编辑面板
*
* @param uPanel 面板
* @param originalName 原始名字
*/
private void dgEdit(final EmbeddedTableDataPane uPanel, String originalName) {
final BasicPane.NamePane nPanel = uPanel.asNamePane();
nPanel.setObjectName(originalName);
final BasicDialog dg;
dg = nPanel.showLargeWindow(SwingUtilities.getWindowAncestor(EmbbeddDataPane.this), new DialogActionAdapter() {
public void doOk() {
tableData = uPanel.updateBean();
fireChange();
}
});
dg.setVisible(true);
}
}

123
designer_chart/src/com/fr/design/mainframe/chart/gui/data/ExcelDataPane.java

@ -1,123 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.chart.gui.data;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.TableData;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.data.impl.ExcelTableData;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.AbstractChartDataPane4Chart;
import com.fr.design.mainframe.DesignerContext;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 下午11:58
*/
public class ExcelDataPane extends ChartDesignDataLoadPane {
private UITextField path = new UITextField();
private UIButton reviewButton;
private ExcelTableData tableData;
private MouseListener listener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
FILEChooserPane fileChooserPane = new FILEChooserPane(true, true);
if (fileChooserPane.showOpenDialog(DesignerContext.getDesignerFrame(), ".xlsx")
== FILEChooserPane.OK_OPTION) {
FILE chooseFILE = fileChooserPane.getSelectedFILE();
if (chooseFILE != null && chooseFILE.exists()) {
path.setText(chooseFILE.getPath());
} else {
JOptionPane.showConfirmDialog(ExcelDataPane.this, Inter.getLocText("FR-Template-Path_chooseRightPath"),
Inter.getLocText("FR-App-All_Warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
path.setText("");
}
tableData.setFilePath(path.getText().toString());
tableData.setFromEnv(chooseFILE.isEnvFile());
tableData.setNeedColumnName(true);
fireChange();
}
}
};
public ExcelDataPane(AbstractChartDataPane4Chart parentPane, JComponent pathChooseButton) {
super(parentPane);
initReviewButton();
tableData = new ExcelTableData();
tableData.setFilePath(path.getText().toString());
tableData.setNeedColumnName(true);
path.setEditable(false);
pathChooseButton.addMouseListener(listener);
this.setLayout(new BorderLayout(0, 0));
JPanel pane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0));
pane.add(path, BorderLayout.CENTER);
pane.add(reviewButton, BorderLayout.EAST);
this.add(pane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return null;
}
private void initReviewButton() {
reviewButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/search.png"));
reviewButton.setBorder(new LineBorder(UIConstants.LINE_COLOR));
reviewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
//预览本地excel
try {
PreviewTablePane.previewTableData(getTableData());
} catch (Exception e1) {
FRContext.getLogger().error(e1.getMessage(), e1);
}
}
});
}
@Override
public TableData getTableData() {
return tableData;
}
@Override
protected String getNamePrefix() {
return null;
}
/**
* 加载数据集
*
* @param tableData 数据集
*/
public void populateChartTableData(TableData tableData) {
if (tableData instanceof ExcelTableData) {
path.setText(((ExcelTableData) tableData).getFilePath());
this.tableData = (ExcelTableData)tableData;
this.tableData.setNeedColumnName(true);
}
fireChange();
}
}

117
designer_chart/src/com/fr/design/mainframe/chart/gui/data/ImportSetChartDataPane.java

@ -1,117 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.chart.gui.data;
import com.fr.base.TableData;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.TableDataDefinition;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.AbstractChartDataPane4Chart;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotMoreCateTableDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.Factory4TableDataContentPane;
import javax.swing.*;
/**
* 数据导入数据设置面板
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 下午2:35
*/
public class ImportSetChartDataPane extends AbstractChartDataPane4Chart {
private AbstractTableDataContentPane dataContentPane;
public ImportSetChartDataPane(final AttributeChangeListener listener, ChartDataPane parent) {
super(listener,parent);
}
/**
* 更新界面 数据内容
*/
public void populate(ChartCollection collection) {
dataContentPane = getContentPane(collection.getSelectedChart().getPlot());
dataContentPane.setNeedSummaryCaculateMethod(false);
dataContentPane.redoLayoutPane();
if (collection != null && collection.getSelectedChart() != null) {
Chart chart = collection.getSelectedChart();
TopDefinitionProvider definition = chart.getFilterDefinition();
if (definition instanceof TableDataDefinition) {
TableData tableData = ((TableDataDefinition) definition).getTableData();
if(tableData != null){
populateChoosePane(tableData);
fireTableDataChange();
}
if (dataContentPane != null) {
dataContentPane.populateBean(collection);
}
}
}
this.remove(leftContentPane);
this.initContentPane();
this.validate();
dataSource.addItemListener(dsListener);
initAllListeners();
initSelfListener(dataContentPane);
this.addAttributeChangeListener(attributeChangeListener);
}
protected JPanel getDataContentPane(){
return dataContentPane;
}
@Override
public void update(ChartCollection collection) {
if (collection != null && collection.getSelectedChart() != null) {
if (dataContentPane != null) {
dataContentPane.updateBean(collection);
}
TableDataDefinition topDefinition =(TableDataDefinition)collection.getSelectedChart().getFilterDefinition();
if(topDefinition !=null){
topDefinition.setTableData(choosePane.getTableData());
}
}
}
private AbstractTableDataContentPane getContentPane(Plot plot) {
if (plot == null || plot.isSupportMoreCate()) {
return new CategoryPlotMoreCateTableDataContentPane(parentPane){
public boolean isNeedSummaryCaculateMethod(){
return false;
}
};
} else{
return Factory4TableDataContentPane.createTableDataContenetPaneWithPlotType(plot, parentPane);
}
}
/**
* 数据集数据改变
*/
public void fireTableDataChange() {
if (dataContentPane != null) {
dataContentPane.onSelectTableData(choosePane.getTableDataWrapper());
}
}
/**
* 清空数据集的设置
*/
public void clearTableDataSetting(){
if(dataContentPane != null){
dataContentPane.clearAllBoxList();
}
}
}

101
designer_chart/src/com/fr/design/mainframe/chart/gui/data/JSONDataPane.java

@ -1,101 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.chart.gui.data;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.TableData;
import com.fr.chart.chartdata.JSONTableData;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.AbstractChartDataPane4Chart;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 下午6:45
*/
public class JSONDataPane extends ChartDesignDataLoadPane {
private UITextField url = new UITextField();
private UIButton reviewButton;
private JSONTableData tableData;
public JSONDataPane(AbstractChartDataPane4Chart parentPane) {
super(parentPane);
initReviewButton();
url.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if(e.getKeyChar() == KeyEvent.VK_ENTER){
tableData.setFilePath(url.getText());
fireChange();
}
}
});
this.setLayout(new BorderLayout(0, 0));
JPanel pane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0));
pane.add(url, BorderLayout.CENTER);
pane.add(reviewButton, BorderLayout.EAST);
this.add(pane, BorderLayout.CENTER);
tableData = new JSONTableData(url.getText());
}
@Override
protected String title4PopupWindow() {
return null;
}
private void initReviewButton() {
reviewButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/search.png"));
reviewButton.setBorder(new LineBorder(UIConstants.LINE_COLOR));
reviewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
tableData.setFilePath(url.getText());
fireChange();
//预览JSON数据
TableDataWrapper tableDataWrappe = getTableDataWrapper();
if (tableDataWrappe != null) {
try {
tableDataWrappe.previewData();
} catch (Exception e1) {
FRContext.getLogger().error(e1.getMessage(), e1);
}
}
}
});
}
@Override
public TableData getTableData() {
return tableData;
}
@Override
protected String getNamePrefix() {
return null;
}
/**
* 加载数据集
* @param tableData 数据集
*/
public void populateChartTableData(TableData tableData) {
if(tableData instanceof JSONTableData) {
url.setText(((JSONTableData) tableData).getFilePath());
this.tableData = (JSONTableData)tableData;
}
}
}

69
designer_chart/src/com/fr/design/mainframe/chart/gui/type/AreaPlotPane4ToolBar.java

@ -1,69 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.chart.gui.type;
import com.fr.chart.chartattr.*;
import com.fr.chart.charttypes.AreaIndependentChart;
import com.fr.design.mainframe.ChartDesigner;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import java.util.ArrayList;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-16
* Time: 下午5:55
*/
public class AreaPlotPane4ToolBar extends PlotPane4ToolBar {
private static final int STACK_AREA_CHART = 0;
private static final int PERCENT_AREA_LINE_CHART = 1;
private static final int STACK_3D_AREA_CHART = 2;
private static final int PERCENT_3D_AREA_LINE_CHART = 3;
public AreaPlotPane4ToolBar(ChartDesigner designer) {
super(designer);
}
@Override
protected String getTypeIconPath() {
return "com/fr/design/images/toolbar/area/";
}
@Override
protected List<ChartDesignerImagePane> initDemoList() {
List<ChartDesignerImagePane> demoList = new ArrayList<ChartDesignerImagePane>();
String area = Inter.getLocText("FR-Chart-Type_Area");
String stack = Inter.getLocText("FR-Chart-Type_Stacked");
String percent = Inter.getLocText("FR-Chart-Use_Percent");
ChartDesignerImagePane pane = new ChartDesignerImagePane(getTypeIconPath(), STACK_AREA_CHART, stack + area,this);
pane.setSelected(true);
demoList.add(pane);
demoList.add(new ChartDesignerImagePane(getTypeIconPath(), PERCENT_AREA_LINE_CHART, percent + stack + area,this));
String td = Inter.getLocText("FR-Chart-Chart_3D");
demoList.add(new ChartDesignerImagePane(getTypeIconPath(), STACK_3D_AREA_CHART, td + stack + area,this));
demoList.add(new ChartDesignerImagePane(getTypeIconPath(), PERCENT_3D_AREA_LINE_CHART, td + percent + stack + area,this));
return demoList;
}
protected Plot getSelectedClonedPlot() {
Chart[] barChart = AreaIndependentChart.areaChartTypes;
Plot newPlot =barChart[this.getSelectedIndex()].getPlot();
Plot cloned = null;
try {
cloned = (Plot) newPlot.clone();
} catch (CloneNotSupportedException e) {
FRLogger.getLogger().error("Error In AreaChart");
}
return cloned;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save